/* ============================================================================
   MISSION LOAD — boot sequence overlay
   ----------------------------------------------------------------------------
   Reproduces the SENTINEL mission-load screen from ASTROC_MultiDomain_Showcase:
   a 3x3 subsystem grid that arms panel by panel while a red-to-green progress
   rail fills, then dissolves into the page.

   Timing is driven from mission-load.js. Everything here is presentation only,
   so the sequence can be skipped at any moment without leaving the page in a
   half-animated state.
   ========================================================================= */

.mload {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #05080d;
    font-family: var(--mono, 'JetBrains Mono', monospace);
    /* The overlay is decorative and announced to nobody: the real page sits
       underneath, already parsed, and screen readers go straight to it. */
    opacity: 1;
    transition: opacity 420ms cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity;
    overflow: hidden;
}

.mload.is-out {
    opacity: 0;
    pointer-events: none;
}

/* Faint survey grid + a slow vertical sweep, as in the source footage. */
.mload::before {
    content: '';
    position: absolute;
    inset: -2px;
    background-image:
        linear-gradient(rgba(94, 184, 142, 0.075) 1px, transparent 1px),
        linear-gradient(90deg, rgba(94, 184, 142, 0.075) 1px, transparent 1px);
    background-size: 54px 54px, 54px 54px;
    mask-image: radial-gradient(ellipse 85% 75% at 50% 45%, #000 20%, transparent 100%);
    -webkit-mask-image: radial-gradient(ellipse 85% 75% at 50% 45%, #000 20%, transparent 100%);
    pointer-events: none;
}

.mload::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 38vh;
    top: -38vh;
    background: linear-gradient(180deg, transparent, rgba(46, 224, 122, 0.035) 62%, transparent);
    animation: mload-sweep 3.4s cubic-bezier(0.33, 0, 0.3, 1) 180ms both;
    pointer-events: none;
}

@keyframes mload-sweep {
    to { transform: translateY(160vh); }
}

.mload-inner {
    position: relative;
    width: min(1120px, 100%);
}

/* ---- lockup --------------------------------------------------------------- */

.mload-lockup {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 26px;
    opacity: 0;
    animation: mload-rise 520ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.mload-diamond {
    width: 26px;
    height: 26px;
    flex: none;
    border: 1px solid rgba(46, 224, 122, 0.55);
    transform: rotate(45deg);
    position: relative;
}

.mload-diamond::after {
    content: '';
    position: absolute;
    inset: 5px;
    background: rgba(46, 224, 122, 0.22);
}

/* ---- per-platform schematic ------------------------------------------------
   The line-art airframe drawing from the showcase film. Geometry and timing
   live in platform-glyph.js; this is only its palette and keyframes.         */

.mload-glyph {
    width: 74px;
    height: 74px;
    flex: none;
    margin-right: 2px;
}


.mload-brand {
    font-size: 0.98rem;
    font-weight: 600;
    letter-spacing: 0.42em;
    color: #e8f0ec;
}

.mload-sub {
    font-size: 0.56rem;
    letter-spacing: 0.3em;
    color: rgba(176, 206, 190, 0.72);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- header + progress rail ----------------------------------------------- */

.mload-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.17em;
    white-space: nowrap;
    overflow: hidden;
    opacity: 0;
    animation: mload-rise 460ms cubic-bezier(0.16, 1, 0.3, 1) 120ms both;
}

.mload-head b { color: #e8f0ec; font-weight: 600; }
.mload-head i { color: #2ee07a; font-style: normal; }
.mload-head span { color: #27c96d; }

.mload-caret {
    display: inline-block;
    width: 0.56em;
    height: 1em;
    background: #2ee07a;
    translate: 0 0.12em;
    animation: mload-blink 780ms steps(1) infinite;
}

@keyframes mload-blink { 50% { opacity: 0; } }

.mload-rail {
    position: relative;
    height: 4px;
    margin: 14px 0 22px;
    background: rgba(255, 255, 255, 0.07);
    overflow: hidden;
}

/* The rail is the spine of the sequence: red through amber to green, exactly
   the colour march the source video uses to signal subsystems coming online.
   Driven by a compositor transform rather than JS, so it cannot fall out of
   step with the panels if the tab is backgrounded mid-sequence. */
.mload-rail-fill {
    position: absolute;
    inset: 0;
    transform: scaleX(0);
    transform-origin: left center;
    background: linear-gradient(90deg, #e8463a 0%, #f0872a 34%, #e8c33a 62%, #2ee07a 100%);
    box-shadow: 0 0 14px rgba(46, 224, 122, 0.4);
    animation: mload-rail 1700ms cubic-bezier(0.22, 0.61, 0.36, 1) 200ms both;
}

@keyframes mload-rail {
    to { transform: scaleX(1); }
}

/* ---- subsystem grid ------------------------------------------------------- */

.mload-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 24px;
}

.mload-cell {
    position: relative;
    padding: 15px 17px 16px;
    min-height: 74px;
    background: rgba(255, 255, 255, 0.022);
    opacity: 0;
    transform: translateY(7px);
}

.mload-cell.is-in {
    animation: mload-rise 420ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Corner ticks on all four corners rather than a closed border — the source
   frames never close the box, which is what keeps the grid reading as
   instrumented rather than boxy. Drawn as eight gradient slivers so one custom
   property recolours every corner the instant a subsystem arms. */
.mload-cell {
    --tick: rgba(46, 224, 122, 0.38);
    background-image:
        linear-gradient(var(--tick), var(--tick)), linear-gradient(var(--tick), var(--tick)),
        linear-gradient(var(--tick), var(--tick)), linear-gradient(var(--tick), var(--tick)),
        linear-gradient(var(--tick), var(--tick)), linear-gradient(var(--tick), var(--tick)),
        linear-gradient(var(--tick), var(--tick)), linear-gradient(var(--tick), var(--tick));
    background-repeat: no-repeat;
    background-size:
        12px 1px, 1px 12px,   /* top-left    */
        12px 1px, 1px 12px,   /* top-right   */
        12px 1px, 1px 12px,   /* bottom-left */
        12px 1px, 1px 12px;   /* bottom-right*/
    background-position:
        0 0, 0 0,
        100% 0, 100% 0,
        0 100%, 0 100%,
        100% 100%, 100% 100%;
}

.mload-cell.is-armed { --tick: rgba(46, 224, 122, 0.92); }

/* A hairline that sweeps the cell as it arms — the "latched" beat. */
.mload-cell::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    height: 1px;
    width: 0;
    background: linear-gradient(90deg, transparent, rgba(46, 224, 122, 0.5), transparent);
}

.mload-cell.is-armed::after {
    animation: mload-latch 520ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes mload-latch {
    from { width: 0; opacity: 1; }
    to   { width: 100%; opacity: 0; }
}

.mload-k {
    font-size: 0.58rem;
    letter-spacing: 0.19em;
    color: rgba(176, 206, 190, 0.78);
    margin-bottom: 7px;
}

.mload-v {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: #f0a62a;
    transition: color 320ms ease;
}

.mload-cell.is-armed .mload-v { color: #2ee07a; }

/* ---- status lines --------------------------------------------------------- */

.mload-lines { display: grid; gap: 7px; margin-bottom: 20px; }

.mload-line {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 0.66rem;
    letter-spacing: 0.13em;
    opacity: 0;
}

.mload-line.is-in { animation: mload-rise 360ms cubic-bezier(0.16, 1, 0.3, 1) both; }
.mload-line em { font-style: normal; color: rgba(176, 206, 190, 0.8); white-space: nowrap; }

/* Dot leaders drawn, not typed, so they reflow at any width. */
.mload-line span {
    flex: 1;
    height: 0.62em;
    border-bottom: 1px dotted rgba(176, 206, 190, 0.3);
    min-width: 18px;
}

.mload-line b { color: #2ee07a; font-weight: 600; white-space: nowrap; }

/* ---- footer --------------------------------------------------------------- */

.mload-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    font-size: 0.6rem;
    letter-spacing: 0.16em;
    color: rgba(176, 206, 190, 0.6);
}

.mload-live { color: #2ee07a; opacity: 0; }
.mload-live.is-in { animation: mload-rise 360ms cubic-bezier(0.16, 1, 0.3, 1) both; }

.mload-skip {
    position: absolute;
    right: 0;
    bottom: -34px;
    background: none;
    border: 1px solid rgba(176, 206, 190, 0.22);
    color: rgba(176, 206, 190, 0.7);
    font-family: inherit;
    font-size: 0.56rem;
    letter-spacing: 0.17em;
    padding: 6px 13px;
    cursor: pointer;
    transition: color 200ms ease, border-color 200ms ease;
}

.mload-skip:hover,
.mload-skip:focus-visible { color: #2ee07a; border-color: rgba(46, 224, 122, 0.6); }

@keyframes mload-rise {
    from { opacity: 0; transform: translateY(7px); }
    to   { opacity: 1; transform: none; }
}

/* ---- narrow screens ------------------------------------------------------- */

@media (max-width: 860px) {
    .mload-grid { grid-template-columns: repeat(2, 1fr); }
    .mload-sub { display: none; }
    .mload-head { font-size: 0.7rem; letter-spacing: 0.12em; white-space: normal; }
}

@media (max-width: 540px) {
    .mload { padding: 18px; }
    .mload-grid { grid-template-columns: 1fr; gap: 7px; }
    .mload-cell { padding: 10px 12px 11px; }
    /* Below this width the leader dots squeeze the value off the line. */
    .mload-line span { display: none; }
    .mload-line { justify-content: space-between; }
}

/* Someone who has asked for less motion gets no boot sequence at all — the JS
   also bails early, this is the belt to that braces. */
@media (prefers-reduced-motion: reduce) {
    .mload { display: none !important; }
}
