/* Delta Security: the security cockpit (/pentest). A desktop-like shell with a draggable/resizable terminal window,
   an attack dock on the left and a steps/explanation panel on the right. Builds on site.css tokens. No inline styles
   (strict CSP) — the window's live position/size are set via element.style from pentest.js (CSSOM, allowed). */

.page-pentest { background:
    radial-gradient(900px 480px at 80% -5%, var(--accent-2-soft), transparent 60%),
    radial-gradient(760px 420px at 0% 10%, var(--accent-soft), transparent 55%), var(--bg); }

/* ---------- Full-screen stage ---------- */
.pentest { position: relative; display: flex; flex-direction: column; min-height: calc(100svh - 65px); padding: 0; }
@media (min-width: 961px) { .pentest { height: calc(100svh - 65px); overflow: hidden; } }

.pentest__hero { max-width: 840px; margin: 0 auto; padding: 0 24px; text-align: center; }
.pentest__hero h1 { font-size: clamp(2rem, 5.4vw, 3.3rem); letter-spacing: -.03em; margin: 12px 0 18px; }
.pentest__pitch { display: inline-block; margin: 0 auto; padding: 8px 18px; border-left: 3px solid var(--accent);
    background: var(--accent-soft); border-radius: var(--r); font: 650 1.12rem/1.4 var(--font); color: var(--accent-h); }

/* Intro splash: centred title/subtitle that fades to reveal the cockpit (pentest.js toggles .is-ready). */
.pentest__intro { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; opacity: 1; transition: opacity .9s ease;
    background:
      radial-gradient(900px 480px at 80% -5%, var(--accent-2-soft), transparent 60%),
      radial-gradient(760px 420px at 0% 10%, var(--accent-soft), transparent 55%),
      linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 34px 34px,
      linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 34px 34px, var(--bg); }
.pentest__intro .pentest__hero { transition: transform .9s ease; }
.js-stage.is-ready .pentest__intro { opacity: 0; pointer-events: none; }
.js-stage.is-ready .pentest__intro .pentest__hero { transform: translateY(-26px); }
@media (prefers-reduced-motion: reduce) { .pentest__intro, .pentest__intro .pentest__hero { transition-duration: .3s; } }

/* Disclaimer: thin strip along the bottom of the cockpit. */
.pentest__disclaimer { flex: none; margin: 0; padding: 7px 14px; text-align: center; font-size: .72rem; color: var(--ck-dim);
    background: #0a1e26; border-top: 1px solid var(--ck-line); }

/* ---------- Cockpit shell (dark desktop) ---------- */
.cockpit { --ck-bg: #091820; --ck-bar: #0d2630; --ck-line: rgba(255, 255, 255, .09); --ck-ink: #cfe6e3; --ck-dim: #7fa6a3;
    position: relative; flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; overflow: hidden; background: var(--ck-bg);
    border: none; }
.cockpit [hidden] { display: none !important; }

.cockpit__bar { position: relative; z-index: 30; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 9px 14px;
    background: linear-gradient(180deg, #11323c, #0d242d); border-bottom: 1px solid var(--ck-line); color: var(--ck-ink); }
.cockpit__cta { display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px; border-radius: var(--r); white-space: nowrap; cursor: pointer;
    border: 1px solid var(--accent); background: linear-gradient(180deg, #0c8478, var(--accent)); color: #fff; font: 650 .8rem var(--font);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .22) inset, 0 6px 16px -8px rgba(13, 148, 136, .7); }
.cockpit__cta:hover { background: var(--accent-h); border-color: var(--accent-h); }
.cockpit__cta .btn__ps { font-family: var(--mono); font-weight: 700; opacity: .8; }
.cockpit__brand { display: inline-flex; align-items: center; gap: 9px; font: 700 .74rem var(--mono); letter-spacing: .14em; color: #d9efe9; }
.cockpit__mark { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 5px; font: 700 .9rem/1 var(--mono);
    color: #fff; background: linear-gradient(135deg, #14b8a6, var(--accent-2)); box-shadow: 0 3px 10px -4px rgba(13, 148, 136, .7); }
.cockpit__spacer { flex: 1 1 auto; }
.cockpit__status { display: inline-flex; align-items: center; gap: 7px; font: 700 .68rem var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ck-dim); }
.cockpit__dot { width: 8px; height: 8px; border-radius: 50%; background: #f2766d; box-shadow: 0 0 0 3px rgba(242, 118, 109, .18); }
.cockpit__status.is-open { color: #4fd6a0; }
.cockpit__status.is-open .cockpit__dot { background: #3cc58b; box-shadow: 0 0 0 3px rgba(60, 197, 139, .2); animation: labpulse 1.8s ease-in-out infinite; }
.cockpit__user { font: 600 .74rem var(--mono); color: #9fc3bf; }

.cockpit__body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 220px minmax(0, 1fr) 340px; align-items: stretch; }

/* ---------- Left: attack dock ---------- */
.dock { padding: 14px 12px; border-right: 1px solid var(--ck-line); background: #0a1e26; display: flex; flex-direction: column; }
.dock__title { margin: 2px 4px 10px; font: 700 .68rem var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--ck-dim); }
.dock__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.dock__item { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 1px solid transparent; border-radius: var(--r);
    background: #0e2831; color: #bcd7d3; cursor: pointer; transition: border-color .15s, background .15s, transform .08s; }
.dock__item:hover { border-color: rgba(79, 214, 160, .4); background: #113039; }
.dock__item:active { transform: translateY(1px); }
.dock__item.is-active { border-color: #2bbd8a; background: linear-gradient(180deg, rgba(43, 189, 138, .16), #0e2831); box-shadow: 0 0 0 3px rgba(43, 189, 138, .12); }
.dock__tag { display: block; font: 700 .62rem var(--mono); text-transform: uppercase; letter-spacing: .07em; color: #5fd3a3; margin-bottom: 3px; }
.dock__name { display: block; font-weight: 650; font-size: .92rem; color: #e4f4f0; line-height: 1.25; }
.dock__hint { margin: auto 4px 2px; padding-top: 12px; font-size: .74rem; color: var(--ck-dim); font-style: italic; }

/* ---------- Center: desktop + draggable window ---------- */
.desktop { position: relative; overflow: hidden; min-height: 0; background:
    radial-gradient(540px 300px at 70% 0%, rgba(13, 148, 136, .12), transparent 60%),
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 30px 30px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 30px 30px, var(--ck-bg); }

.win { position: absolute; left: 32px; top: 30px; width: min(60%, 820px); height: 74%; display: flex; flex-direction: column;
    background: #0b1f28; border: 1px solid #16303a; border-radius: 9px; overflow: hidden;
    box-shadow: 0 30px 70px -24px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .03); }
.win__bar { display: flex; align-items: center; gap: 10px; padding: 8px 10px; cursor: grab; user-select: none;
    background: linear-gradient(180deg, #123139, #0d252e); border-bottom: 1px solid var(--ck-line); }
.win__bar:active { cursor: grabbing; }
.win__lights { display: inline-flex; gap: 6px; }
.win__lights i { width: 11px; height: 11px; border-radius: 50%; background: #2b4a52; }
.win__lights i:nth-child(1) { background: #ff5f57; }
.win__lights i:nth-child(2) { background: #febc2e; }
.win__lights i:nth-child(3) { background: #28c840; }
.win__title { flex: 0 1 auto; font: 600 .8rem var(--mono); color: #9fc3bf; font-style: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win__badge { margin-left: auto; font: 700 .64rem var(--mono); text-transform: uppercase; letter-spacing: .08em; padding: 2px 8px; border-radius: 3px; color: #0b1f28; background: #3cc58b; }
.win__badge.is-live { background: #f2766d; color: #1a0606; animation: labpulse 1.6s ease-in-out infinite; }
.win__badge.is-queue { background: #f0b429; color: #231a02; animation: labpulse 1.8s ease-in-out infinite; }
.win__ctl { flex: none; width: 24px; height: 22px; display: grid; place-items: center; border: 1px solid #1d3841; border-radius: 5px;
    background: #0e2731; color: #8fb6b1; cursor: pointer; font-size: .82rem; line-height: 1; }
.win__ctl:hover { border-color: #2bbd8a; color: #cfe6e3; }
@keyframes labpulse { 50% { opacity: .62; } }

.win__body { flex: 1 1 auto; overflow-y: auto; padding: 13px 15px; margin: 0; font: .86rem/1.5 var(--mono); color: var(--ck-ink);
    background: linear-gradient(rgba(255, 255, 255, .022) 1px, transparent 1px) 0 0 / 100% 26px; scroll-behavior: smooth; }
.win__resize { position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, rgba(127, 166, 163, .5) 50%, rgba(127, 166, 163, .5) 60%, transparent 60%, transparent 72%, rgba(127, 166, 163, .5) 72%, rgba(127, 166, 163, .5) 82%, transparent 82%); }
.win.is-dragging, .win.is-resizing { box-shadow: 0 36px 90px -20px rgba(0, 0, 0, .8), 0 0 0 1px rgba(43, 189, 138, .25); }

/* Pop-up script viewer: a second terminal window, cascaded over the main one and raised above it. */
.win--viewer { left: auto; right: 26px; top: 52px; width: min(52%, 640px); height: 66%; z-index: 12;
    box-shadow: 0 40px 100px -26px rgba(0, 0, 0, .82), 0 0 0 1px rgba(43, 189, 138, .22); }
.win--viewer[hidden] { display: none; }
.win--viewer .win__body { white-space: pre-wrap; word-break: break-word; }
.win--viewer .lab__src { border-left: 0; padding-left: 0; color: #cfe6e3; }
.win--viewer .lab__cmd { color: #8fe3c4; }
/* The red traffic-light dot closes the script window (macOS-style); the main terminal's lights stay decorative. */
.win--viewer .win__lights--close i:first-child { cursor: pointer; position: relative; }
.win--viewer .win__lights--close i:first-child:hover { box-shadow: 0 0 0 2px rgba(255, 95, 87, .35); }
.win--viewer .win__lights--close i:first-child::after { content: "\00d7"; position: absolute; inset: 0; display: grid; place-items: center;
    font: 700 9px/1 var(--mono); color: rgba(60, 0, 0, .75); opacity: 0; transition: opacity .12s ease; }
.win--viewer .win__lights--close i:first-child:hover::after { opacity: 1; }

/* terminal content (classes emitted by pentest.js) */
.lab__cmd { margin: 13px 0 4px; color: #eafaf5; word-break: break-word; }
.lab__cmd:first-child { margin-top: 0; }
.lab__cmd .term__ps { color: #4fd6a0; }
.lab__out { margin: 0 0 4px; white-space: pre-wrap; word-break: break-word; color: #b7d2ce; }
.lab__out .flag { color: #ffd166; font-weight: 700; }
.lab__out .hit { color: #ff8f85; font-weight: 700; }
.lab__out .boot-ok { color: #4fd6a0; font-weight: 700; }
.lab__out .boot-live { color: #eafaf5; font-weight: 700; }
.lab__out .boot-run { color: #ffd166; font-weight: 700; }
.lab__out .boot-pending { color: #5e7f7b; }
.lab__caret { display: inline-block; width: .5em; height: 1.05em; vertical-align: -.2em; background: #4fd6a0; animation: blink 1.05s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Right: steps + explanation + CTA ---------- */
.panel { padding: 16px; border-left: 1px solid var(--ck-line); background: var(--panel); display: flex; flex-direction: column; gap: 0; overflow-y: auto; }
.panel__title { margin: 0 0 12px; font-weight: 700; font-size: 1.04rem; color: var(--head); letter-spacing: -.01em; }
.panel__steps { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 7px; }
.lab__step { display: flex; align-items: flex-start; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel-2); color: var(--muted); }
.lab__step-idx { flex: none; width: 22px; height: 22px; margin-top: 1px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line-2); font: 700 .74rem var(--mono); color: var(--muted); background: var(--panel); }
.lab__step-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.lab__step-label { font-weight: 600; font-size: .92rem; color: var(--ink-2); }
/* The command renders as a button: clicking it reveals the real script in the terminal. Reset the native chrome. */
.lab__step-cmd { display: inline; width: 100%; margin: 0; padding: 0; border: 0; background: none; text-align: left; font: 600 .74rem/1.35 var(--mono); color: var(--muted); word-break: break-word; cursor: default; }
.lab__step-cmd:disabled { cursor: default; }
.lab__step-cmd.is-viewable { cursor: pointer; transition: color .15s ease; }
.lab__step-cmd.is-viewable::after { content: " \29C9"; opacity: .55; font-size: .9em; } /* ⧉ view-script affordance */
.lab__step-cmd.is-viewable:hover { color: var(--accent-h); text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px; }
.lab__step-cmd.is-viewable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.lab__step.is-active .lab__step-cmd { color: var(--accent-h); }
.lab__step.is-done .lab__step-cmd { color: var(--ok); }
/* Revealed script source in the terminal: calmer than live output, so it reads as "here is the file". */
.lab__out.lab__src { color: #9fb6c9; border-left: 2px solid var(--ck-line); padding-left: 10px; margin-bottom: 10px; }
.lab__step-stat { flex: none; margin-top: 2px; font: 700 .68rem var(--mono); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.lab__step.is-active { border-color: var(--accent); background: linear-gradient(180deg, var(--accent-soft), var(--panel)); color: var(--ink); box-shadow: var(--glow-g); }
.lab__step.is-active .lab__step-idx { border-color: var(--accent); color: var(--accent-h); }
.lab__step.is-running .lab__step-stat { color: var(--accent-2); }
.lab__step.is-done .lab__step-idx { background: var(--accent); border-color: var(--accent); color: #fff; }
.lab__step.is-done .lab__step-stat { color: var(--ok); }

.panel__box { padding: 12px 14px; border: 1px solid var(--line); border-left-width: 3px; border-radius: var(--r); margin-bottom: 11px; background: var(--panel-2); }
.panel__box p:last-child { margin: 0; }
.panel__label { margin: 0 0 5px; display: inline-flex; align-items: center; gap: 6px; font: 700 .72rem var(--mono); text-transform: uppercase; letter-spacing: .05em; }
.panel__box--what { border-left-color: var(--high); background: linear-gradient(180deg, rgba(192, 74, 12, .05), var(--panel)); }
.panel__box--what .panel__label { color: var(--high); }
.panel__box--fix { border-left-color: var(--accent); background: linear-gradient(180deg, var(--accent-soft), var(--panel)); }
.panel__box--fix .panel__label { color: var(--accent-h); }

.panel__controls { display: flex; flex-wrap: wrap; gap: 9px; }
.panel__controls .btn { flex: 1 1 auto; }

.panel__cta { margin-top: auto; padding-top: 16px; }
.panel__cta-title { margin: 0 0 5px; font-weight: 700; color: var(--head); font-size: 1rem; }
.panel__cta-body { margin: 0 0 11px; font-size: .9rem; color: var(--ink-2); }
.panel__cta-note { margin: 8px 0 0; text-align: center; font-size: .8rem; color: var(--muted); }

/* ---------- Lock overlay: email → one-time code gate ---------- */
.lock { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: 22px;
    background: rgba(6, 18, 24, .74); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.lock.is-unlocked { display: none; }
.lock__card { width: min(420px, 100%); padding: 24px; border-radius: var(--r-lg); background: var(--panel); box-shadow: var(--shadow-lg); }
.lock__card h2 { margin: 0 0 6px; font-size: 1.22rem; color: var(--head); }
.lock__cmd { margin: 0 0 14px; font: 600 .82rem var(--mono); color: var(--accent); }
.lock__cmd .term__ps { color: var(--accent-2); }
.lock__step { display: grid; gap: 12px; }
.lock__step .muted { margin: -4px 0 2px; font-size: .9rem; }
.lock__field { display: grid; gap: 5px; font-size: .9rem; color: var(--ink-2); }
.lock__field input { font: inherit; padding: 11px 13px; border: 1px solid var(--line-2); border-radius: var(--r); background: #fff; color: var(--ink); }
.lock__field input:focus { outline: none; border-color: var(--accent); box-shadow: var(--glow-g); }
.lock__consent { display: flex; align-items: flex-start; gap: 9px; font-size: .88rem; color: var(--ink-2); }
.lock__code { display: block; box-sizing: border-box; width: 100%; max-width: 240px; margin: 0 auto;
    font: 700 1.55rem/1 var(--mono); letter-spacing: .55em; text-indent: .55em; text-align: center; padding: 14px 12px;
    border: 1px solid var(--line-2); border-radius: var(--r); background: #fff; color: var(--ink); }
.lock__code:focus { outline: none; border-color: var(--accent); box-shadow: var(--glow-g); }
.lock__msg { margin: 0; text-align: center; color: var(--critical); font-size: .88rem; }
.lock__msg.is-ok { color: var(--ok); }
.lock__links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 22px; }
.link { background: none; border: none; padding: 0; font: inherit; font-size: .86rem; color: var(--accent-2); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--accent-2-h); }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
    .cockpit__body { grid-template-columns: 1fr; min-height: 0; }
    .dock { border-right: none; border-bottom: 1px solid var(--ck-line); }
    .dock__list { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .dock__hint { display: none; }
    .desktop { min-height: 420px; }
    .panel { border-left: none; border-top: 1px solid var(--ck-line); }
}
@media (max-width: 560px) {
    .desktop { min-height: 360px; }
    /* On a phone the window is pinned full-bleed; drag/resize are disabled in JS. */
    .win { left: 10px !important; top: 10px !important; width: auto !important; right: 10px; height: 330px !important; }
    /* The pop-up viewer sits a touch lower so the main window's bar stays reachable to dismiss it. */
    .win--viewer { top: 26px !important; height: 70% !important; }
    .win__resize { display: none; }
}
