/* ==========================================================================
   Defense page: a dark band that pins under the menu (desktop ≥992px) while the scroll drives the 3D rocket in
   defense-3d.js. The copy chapters (.dive-beat) are stacked on the left and swapped by the script; the finale is
   centred over the whole band. The canvas covers the band so the rocket can fly out of it.
   Phones and tablets, reduced motion and desktops where WebGL fails (.is-flat) get the chapters one under another.
   ========================================================================== */

/* overflow-x: clip, not hidden: hidden would make the band a scroll container and break the sticky pin. */
.dive {
    position: relative; overflow-x: clip; color: rgba(255, 255, 255, .72);
    background-color: #0d0e12;
    background-image:
        radial-gradient(ellipse 34% 52% at 74% 50%, rgba(215, 25, 32, .12), transparent 70%),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, .028) 0 1px, transparent 1px 80px),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, .028) 0 1px, transparent 1px 80px);
}
.dive .section-title { color: var(--ar-white); }
.dive .lead-text { color: rgba(255, 255, 255, .9); }
.dive-pin { position: relative; padding: 4rem 0; }
.dive-beat p { max-width: 52ch; }
.dive-beat + .dive-beat { margin-top: 3.5rem; }
.dive-stage, .dive-hint, .dive-rail, .dive-hud { display: none; }
.dive-words {
    margin: 0; padding: 0; list-style: none; color: var(--ar-white);
    font-family: var(--ar-font-heading); font-size: clamp(2.2rem, 8vw, 3.4rem); font-weight: 700; line-height: 1.06;
    text-transform: uppercase;
}
/* Every other line outlined: a stencil feel next to the solid ones. */
.dive-words li:nth-child(even) { color: transparent; -webkit-text-stroke: 1.5px var(--ar-white); }
.dive-clearance {
    display: flex; gap: .9rem; margin-top: 2rem; padding: 1.1rem 1.25rem;
    border-left: 3px solid var(--ar-red); background: rgba(255, 255, 255, .04);
}
.dive-clearance i { margin-top: .2rem; color: var(--ar-red); font-size: 1.35rem; }
.dive-clearance strong { display: block; margin-bottom: .2rem; color: var(--ar-white); font-family: var(--ar-font-heading); letter-spacing: .04em; }

@media (min-width: 992px) and (prefers-reduced-motion: no-preference) {
    /* The band is the scroll track; the pin holds the screen while it is scrolled through. */
    .dive:not(.is-flat) { height: 500vh; }
    .dive:not(.is-flat) .dive-pin {
        position: sticky; top: var(--ar-header-height); height: calc(100vh - var(--ar-header-height));
        display: flex; align-items: center; padding: 0;
    }
    .dive:not(.is-flat) .dive-copy { position: relative; z-index: 1; pointer-events: none; }
    .dive:not(.is-flat) .dive-copy .section-title { font-size: clamp(2rem, 3.2vw, 3rem); }

    /* Chapters share one grid cell. The one coming in rises out of a blur; the one leaving lifts away. */
    .dive:not(.is-flat) .dive-copy { display: grid; }
    .dive:not(.is-flat) .dive-beat {
        grid-area: 1 / 1; align-self: center; max-width: 40%; margin: 0;
        opacity: 0; visibility: hidden; translate: 0 3rem; filter: blur(12px);
        transition: opacity .6s ease, translate .9s cubic-bezier(.2, .7, .2, 1), filter .6s ease, visibility 0s .9s;
    }
    .dive:not(.is-flat) .dive-beat.is-past { translate: 0 -3rem; }
    .dive:not(.is-flat) .dive-beat.is-active {
        opacity: 1; visibility: visible; translate: 0 0; filter: none; pointer-events: auto;
        transition-delay: .2s, .2s, .2s, 0s;
    }
    .dive:not(.is-flat) .dive-finale { justify-self: center; max-width: none; text-align: center; }
    .dive:not(.is-flat) .dive-words { font-size: clamp(3rem, 6.2vw, 6.5rem); }
    .dive:not(.is-flat) .dive-words li { opacity: .1; translate: 0 .25em; transition: opacity .7s ease, translate .9s cubic-bezier(.2, .7, .2, 1); }
    .dive:not(.is-flat) .dive-words li.is-lit { opacity: 1; translate: 0 0; }

    /* Chapter marks on the right edge. */
    .dive:not(.is-flat) .dive-rail {
        display: flex; flex-direction: column; gap: 1.1rem; position: absolute; right: 2rem; top: 50%; z-index: 1;
        translate: 0 -50%; margin: 0; padding: 0; list-style: none;
    }
    .dive-rail li { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .25); transition: background .4s ease, scale .4s ease; }
    .dive-rail li.is-active { background: var(--ar-red); scale: 1.7; }

    /* HUD: corner brackets round the band, the phase top right, altitude and speed bottom right. */
    .dive:not(.is-flat) .dive-hud {
        --hud: rgba(255, 255, 255, .3);
        display: block; position: absolute; inset: 1.5rem; z-index: 1; pointer-events: none;
        background:
            linear-gradient(var(--hud) 0 0) left top / 28px 1px, linear-gradient(var(--hud) 0 0) left top / 1px 28px,
            linear-gradient(var(--hud) 0 0) right top / 28px 1px, linear-gradient(var(--hud) 0 0) right top / 1px 28px,
            linear-gradient(var(--hud) 0 0) left bottom / 28px 1px, linear-gradient(var(--hud) 0 0) left bottom / 1px 28px,
            linear-gradient(var(--hud) 0 0) right bottom / 28px 1px, linear-gradient(var(--hud) 0 0) right bottom / 1px 28px;
        background-repeat: no-repeat;
        color: rgba(255, 255, 255, .5); font: 500 .72rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
        letter-spacing: .18em; text-transform: uppercase;
    }
    .dive-hud > span { position: absolute; right: 1.25rem; display: flex; align-items: center; gap: .6rem; }
    .hud-phase { top: 1.25rem; color: var(--ar-white); }
    .hud-phase i { width: 7px; height: 7px; border-radius: 50%; background: var(--ar-red); animation: dive-blink 1.2s steps(1) infinite; }
    .hud-telemetry { bottom: 1.25rem; }
    .hud-telemetry small { font-size: inherit; text-transform: none; }
    .hud-telemetry b { color: var(--ar-white); font-weight: 600; font-variant-numeric: tabular-nums; }

    /* Close-up on the liner: only its label stays. */
    .stage-labels.is-dive .stage-label:not(:nth-child(3)) { opacity: 0; }
    /* The ignition burst over the rocket, driven by the script. */
    .dive-flash {
        position: absolute; inset: 0; opacity: 0; pointer-events: none; mix-blend-mode: screen;
        background: radial-gradient(circle at var(--fx, 72%) var(--fy, 80%), rgba(255, 236, 200, .95), rgba(255, 130, 40, .45) 18%, transparent 60%);
    }

    .dive:not(.is-flat) .dive-stage { display: block; position: absolute; inset: 0; }
    .dive-stage canvas { display: block; width: 100%; height: 100%; opacity: 0; transition: opacity 1s ease; }
    .dive-stage.is-ready canvas { opacity: 1; }
    /* While three.js loads: a quiet ring where the rocket will appear. */
    .dive-stage::before {
        content: ""; position: absolute; left: 72%; top: 50%; width: 120px; height: 120px; margin: -60px 0 0 -60px;
        border: 1px solid rgba(255, 255, 255, .12); border-top-color: var(--ar-red); border-radius: 50%;
        animation: dive-spin 1.2s linear infinite; transition: opacity .4s ease;
    }
    .dive-stage.is-ready::before { opacity: 0; animation: none; }

    /* Scroll cue, faded out by the script once the scroll starts. */
    .dive:not(.is-flat) .dive-hint {
        display: flex; flex-direction: column; align-items: center; gap: .6rem; position: absolute; left: 50%; bottom: 1.5rem;
        translate: -50% 0; color: rgba(255, 255, 255, .55); font-size: .8rem; letter-spacing: .12em; text-transform: uppercase;
        transition: opacity .4s ease;
    }
    .dive-hint span { position: relative; width: 22px; height: 34px; border: 1.5px solid rgba(255, 255, 255, .4); border-radius: 12px; }
    .dive-hint span::after {
        content: ""; position: absolute; left: 50%; top: 7px; width: 3px; height: 7px; margin-left: -1.5px; border-radius: 2px;
        background: var(--ar-red); animation: dive-wheel 1.6s ease-in-out infinite;
    }
    .dive.is-scrolled .dive-hint { opacity: 0; }
}
/* Reduced motion: no pin; the still exploded view sits beside the copy. */
@media (min-width: 992px) and (prefers-reduced-motion: reduce) {
    .dive:not(.is-flat) .dive-beat { max-width: 44%; }
    .dive:not(.is-flat) .dive-stage { display: block; position: absolute; top: 0; right: 0; bottom: 0; width: 56%; }
    .dive-stage canvas { display: block; width: 100%; height: 100%; }
}

@keyframes dive-blink { 50% { opacity: .15; } }
@keyframes dive-spin { to { transform: rotate(360deg); } }
@keyframes dive-wheel { 0% { transform: translateY(0); opacity: 1; } 70% { transform: translateY(10px); opacity: 0; } 100% { opacity: 0; } }
