/* ================================================================
   FLEET — the "your real numbers are the animation" layer
   Loaded after style.css. Adds:
     1. a dark theme (html[data-theme="dark"]) beside the light one
     2. solid "targeting-bracket" cards instead of frosted glass
     3. the 10,000-endpoint fleet canvas in the hero
     4. declassifying case files
     5. a timeline that draws itself, stamped certifications
     6. a circular theme-switch reveal (View Transitions)
   Budget: transform/opacity (or short one-shot paints) only, every
   loop pauses off-screen, prefers-reduced-motion gets end states.
   ================================================================ */

/* ── 1. THEME TOKENS ─────────────────────────────────────────── */
:root {
    --slab:        #ffffff;
    --slab-alt:    #fbfaff;
    --slab-line:   rgba(104,48,168,0.16);
    --bk:          rgba(104,48,168,0.55);   /* bracket corners */
    --ink:         #1a1a2e;                 /* redaction bars */
    --ok:          #12805a;
    --threat:      #d23c5a;
    --fleet-dot:   rgba(104,48,168,0.30);
    --fleet-ok:    #12a06e;
    --fleet-threat:#e0284f;
    --fleet-scan:  #6830a8;
    --hud:         #54546e;
    --nav-bg:      rgba(247,246,252,0.94);
    color-scheme: light;
}

html[data-theme="dark"] {
    --bg:          #0d0b14;
    --bg-alt:      #120f1c;
    --surface:     #17131f;
    --surface-light: #1c1726;
    --border:      rgba(255,255,255,0.10);
    --border-dim:  rgba(183,148,255,0.20);
    --accent:      #b794ff;
    --accent-dim:  rgba(183,148,255,0.13);
    --accent-blue: #6cb6ff;
    --accent-cyan: #4fd6a6;
    --text:        #eeeaf6;
    --text-dim:    #b3abc9;
    --text-muted:  #918aab;
    --g-shad-sm:   0 4px 20px rgba(0,0,0,.35);
    --g-shad-md:   0 8px 40px rgba(0,0,0,.45);
    --g-shad-lg:   0 16px 60px rgba(0,0,0,.55);

    --slab:        #17131f;
    --slab-alt:    #1b1626;
    --slab-line:   rgba(183,148,255,0.16);
    --bk:          rgba(183,148,255,0.65);
    --ink:         #000000;
    --ok:          #4fd6a6;
    --threat:      #ff6b86;
    --fleet-dot:   rgba(183,148,255,0.22);
    --fleet-ok:    #4fd6a6;
    --fleet-threat:#ff4d6d;
    --fleet-scan:  #d9c7ff;
    --hud:         #a9a1c4;
    --nav-bg:      rgba(13,11,20,0.94);
    color-scheme: dark;
}

/* ── dark: the surfaces style.css hard-codes as light ────────── */
html[data-theme="dark"] body {
    background-color: var(--bg);
    background-image:
        radial-gradient(ellipse at 20% 10%, rgba(120,70,220,0.20) 0%, transparent 50%),
        radial-gradient(ellipse at 85% 30%, rgba(40,110,200,0.14) 0%, transparent 45%),
        radial-gradient(ellipse at 55% 90%, rgba(200,60,130,0.10) 0%, transparent 50%);
}
html[data-theme="dark"] .scanlines { opacity: .55; }
html[data-theme="dark"] a:hover { color: #d2bcff; }
html[data-theme="dark"] .stats-bar,
html[data-theme="dark"] .footer { background: var(--bg-alt); border-color: var(--border); }
html[data-theme="dark"] .section-dark { background: rgba(255,255,255,0.025); }
html[data-theme="dark"] .section-contact {
    background:
        radial-gradient(ellipse at center top, rgba(183,148,255,0.10) 0%, transparent 40%),
        var(--bg-alt);
}
/* style.css gives cards a bright white top-edge highlight meant for light glass */
html[data-theme="dark"] .highlight-card, html[data-theme="dark"] .timeline-card,
html[data-theme="dark"] .arsenal-card, html[data-theme="dark"] .cert-card,
html[data-theme="dark"] .contact-card { box-shadow: var(--g-shad-sm), inset 0 1px 0 rgba(255,255,255,0.06) !important; }
html[data-theme="dark"] .cmd-palette,
html[data-theme="dark"] .ctf-panel { background: rgba(20,16,30,0.97); border-color: var(--border); }
html[data-theme="dark"] .cmd-esc,
html[data-theme="dark"] .cmd-item-badge,
html[data-theme="dark"] .cmd-footer kbd,
html[data-theme="dark"] .cmd-trigger kbd { background: rgba(255,255,255,0.08); }
html[data-theme="dark"] .cmd-item.active,
html[data-theme="dark"] .cmd-item-icon { background: rgba(183,148,255,0.12); }
html[data-theme="dark"] .form-group input,
html[data-theme="dark"] .form-group textarea,
html[data-theme="dark"] #ctfInput,
html[data-theme="dark"] .ctf-flag { background: #120f1a; border-color: rgba(183,148,255,0.22); color: var(--text); }
html[data-theme="dark"] .nav-links.open { background: rgba(13,11,20,0.98); border-color: var(--border); }
html[data-theme="dark"] .btn-primary { background: #7c4dff; color: #fff; box-shadow: 0 4px 22px rgba(124,77,255,.35); }
html[data-theme="dark"] .btn-primary:hover { background: #8c63ff; }
html[data-theme="dark"] .btn-ghost { background: transparent; border-color: rgba(183,148,255,0.45); color: var(--accent); }
html[data-theme="dark"] .btn-ghost:hover { background: #7c4dff; color: #fff; }
html[data-theme="dark"] .arsenal-tags span,
html[data-theme="dark"] .timeline-tags span { background: rgba(183,148,255,0.08); border-color: rgba(183,148,255,0.22); }
html[data-theme="dark"] .github-chart { filter: invert(.88) hue-rotate(180deg) saturate(1.4); }
html[data-theme="dark"] .hero-line.accent {
    background: linear-gradient(135deg,#ffb07a 0%,#6cb6ff 40%,#ff7ab6 70%,#c49bff 100%);
    -webkit-background-clip: text; background-clip: text;
}

/* ── 2. SOLID BRACKET CARDS (both themes) ─────────────────────
   Opaque surfaces with targeting-reticle corners; no backdrop
   blur. Brackets extend on hover (a one-off paint, not a loop). */
.nav {
    background: var(--nav-bg) !important;
    backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
    border-bottom-color: var(--slab-line) !important;
}
.highlight-card, .timeline-card, .arsenal-card, .cert-card,
.certs-education, .contact-card, .contact-form-wrap, .case-card {
    --bl: 14px;
    backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
    border: 1px solid var(--slab-line) !important;
    background-color: var(--slab) !important;
    background-image:
        linear-gradient(var(--bk),var(--bk)), linear-gradient(var(--bk),var(--bk)),
        linear-gradient(var(--bk),var(--bk)), linear-gradient(var(--bk),var(--bk)),
        linear-gradient(var(--bk),var(--bk)), linear-gradient(var(--bk),var(--bk)),
        linear-gradient(var(--bk),var(--bk)), linear-gradient(var(--bk),var(--bk)) !important;
    background-repeat: no-repeat !important;
    background-position: 0 0, 0 0, 100% 0, 100% 0, 0 100%, 0 100%, 100% 100%, 100% 100% !important;
    background-size:
        var(--bl) 2px, 2px var(--bl), var(--bl) 2px, 2px var(--bl),
        var(--bl) 2px, 2px var(--bl), var(--bl) 2px, 2px var(--bl) !important;
    transition: background-size .35s cubic-bezier(.22,1,.36,1), transform .35s cubic-bezier(.22,1,.36,1), border-color .35s;
}
.highlight-card:hover, .timeline-card:hover, .arsenal-card:hover, .cert-card:hover,
.contact-card:hover, .case-card:hover { --bl: 30px; }
/* the form block became a framed card, so it needs inner room like the contact cards */
.contact-form-wrap { padding: 32px 36px 36px; border-radius: var(--radius); }
@media (max-width: 640px) { .contact-form-wrap { padding: 24px 20px 26px; } }
.github-chart { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; background: var(--slab) !important; border-color: var(--slab-line) !important; }
.btn-ghost { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }

/* ── 3. THE FLEET (hero) ─────────────────────────────────────── */
.hero { isolation: isolate; }
.hero-content, .hero-terminal { position: relative; z-index: 2; }
.fleet {
    position: absolute; z-index: 0;
    top: 70px; bottom: 30px;
    right: calc(50% - 50vw);
    width: min(64vw, 980px);
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 26%, #000 100%);
            mask-image: linear-gradient(to right, transparent 0, #000 26%, #000 100%);
    cursor: crosshair;
}
.fleet-canvas { display: block; width: 100%; height: 100%; }
.fleet-hud {
    position: absolute; z-index: 3; right: max(24px, calc(50% - 50vw + 32px)); bottom: 34px;
    display: flex; gap: 18px; flex-wrap: wrap; justify-content: flex-end;
    font: 500 11px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase;
    color: var(--hud); pointer-events: none;
}
.fleet-hud span { background: var(--bg); padding: 3px 7px; border-radius: 5px; }
.fleet-hud b { color: var(--text); font-weight: 500; }
.fleet-hud .hud-threat b { color: var(--threat); }
.fleet-hud .hud-ok b { color: var(--ok); }
.fleet-hud .hud-hint { opacity: .8; }
/* the terminal floats over the fleet: make it solid so dots don't show through */
.hero-terminal { background: #0f0c18 !important; }

@media (max-width: 900px) {
    .fleet {
        top: 60px; bottom: auto; height: 380px;
        left: calc(50% - 50vw); right: auto; width: 100vw;
        opacity: .55;
        -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 55%, transparent 100%);
                mask-image: linear-gradient(to bottom, #000 0, #000 55%, transparent 100%);
    }
    .fleet-hud { position: relative; right: auto; bottom: auto; justify-content: flex-start; margin-top: 18px; order: 3; }
    .fleet-hud .hud-hint { display: none; }
}

/* ── 4. CASE FILES ───────────────────────────────────────────── */
.case-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; margin-top: 40px; text-align: left; }
.case-card { position: relative; border-radius: var(--radius); padding: 26px 24px 24px; overflow: hidden; }
.case-meta {
    padding-right: 96px;
    display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 14px;
    font: 500 10.5px/1.3 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted);
}
.case-meta .sev { color: var(--threat); }
.case-card h3 { font-size: 19px; line-height: 1.25; margin-bottom: 16px; letter-spacing: -.01em; }
.case-card dl { display: grid; gap: 12px; }
.case-card dt { font: 500 10.5px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-bottom: 5px; }
.case-card dd { font-size: 14px; line-height: 1.6; color: var(--text-dim); margin: 0; }
/* redaction bars: the bar is the span's own background, cloned per
   line fragment, so multi-line text wipes line by line */
.redact {
    color: transparent;
    background-image: linear-gradient(var(--ink), var(--ink));
    background-repeat: no-repeat;
    background-position: 100% 0;
    background-size: 100% 100%;
    -webkit-box-decoration-break: clone; box-decoration-break: clone;
    border-radius: 2px;
    transition: background-size .75s cubic-bezier(.7,0,.2,1), color .3s ease;
    transition-delay: var(--rd, 0ms);
}
.declassified .redact { background-size: 0% 100%; color: inherit; }
.case-stamp {
    position: absolute; top: 18px; right: 16px;
    padding: 4px 10px; border: 2px solid var(--ok); border-radius: 4px;
    font: 700 11px/1 var(--mono); letter-spacing: .16em; color: var(--ok);
    transform: rotate(-9deg) scale(1.7); opacity: 0;
    transition: transform .45s cubic-bezier(.2,1.6,.4,1), opacity .2s;
    transition-delay: var(--sd, 1.4s);
}
.declassified .case-stamp { transform: rotate(-9deg) scale(1); opacity: .9; }
.case-note { margin-top: 18px; font: 400 12px/1.5 var(--mono); color: var(--text-muted); }
@media (max-width: 900px) { .case-grid { grid-template-columns: 1fr; } }

/* ── 5. TIMELINE THAT DRAWS ITSELF + STAMPED CERTS ───────────── */
.timeline::after {
    content: ''; position: absolute; left: 7px; top: 0; bottom: 0; width: 2px;
    background: linear-gradient(to bottom, var(--accent-cyan), var(--accent));
    transform-origin: 0 0; transform: scaleY(var(--tl, 0));
    box-shadow: 0 0 10px var(--accent-cyan);
}
.timeline-item.tl-hit .timeline-dot { animation: tlPing .9s cubic-bezier(.22,1,.36,1) 1; }
@keyframes tlPing {
    0% { box-shadow: 0 0 0 0 var(--accent-cyan); transform: scale(1); }
    40% { transform: scale(1.35); }
    100% { box-shadow: 0 0 0 16px transparent; transform: scale(1); }
}
.cert-card.visible .cert-badge { animation: stampIn .55s cubic-bezier(.2,1.6,.4,1) .15s both; }
@keyframes stampIn {
    from { transform: scale(2.2) rotate(-14deg); opacity: 0; }
    to   { transform: scale(1) rotate(0); opacity: 1; }
}

/* ── 6. THEME TOGGLE + circular reveal ───────────────────────── */
.theme-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; margin-right: 8px; border-radius: 10px;
    border: 1px solid var(--slab-line); background: var(--slab); color: var(--text-dim);
    cursor: pointer; transition: color .2s, border-color .2s, transform .3s cubic-bezier(.2,1.6,.4,1);
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle:active { transform: rotate(-25deg) scale(.92); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle .i-sun { display: none; }
html[data-theme="dark"] .theme-toggle .i-sun { display: block; }
html[data-theme="dark"] .theme-toggle .i-moon { display: none; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { animation: themeReveal .65s cubic-bezier(.65,0,.35,1); }
@keyframes themeReveal {
    from { clip-path: circle(0 at var(--tx, 90%) var(--ty, 30px)); }
    to   { clip-path: circle(150vmax at var(--tx, 90%) var(--ty, 30px)); }
}

/* ── reduced motion: end states ──────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .redact, .case-stamp { transition: none !important; }
    .timeline::after { transform: scaleY(1); }
    .timeline-item.tl-hit .timeline-dot, .cert-card.visible .cert-badge { animation: none; }
    ::view-transition-new(root) { animation: none; }
}
