body[data-console-phase="boot"] { overflow: hidden; }

body[data-console-phase="boot"] :is(.terminal-console, .terminal-display > .market-structure__panel) {
    border-color: transparent;
}

.console-intro {
    --boot-accent: var(--pale-phosphor, #9ff77b);
    --boot-ink: var(--pale-ink, #e1eddf);
    --boot-muted: color-mix(in srgb, var(--boot-ink) 67%, #000);
    --boot-line: color-mix(in srgb, var(--boot-accent) 28%, #0c100d);
    --boot-grid: color-mix(in srgb, var(--boot-accent) 14%, transparent);
    position: fixed;
    inset: 0;
    z-index: 20;
    overflow: hidden;
    color: var(--boot-ink);
    font: 500 .825rem/1.45 var(--mono);
}

/* The seal and rail align with the seal recesses at the midpoint of the artwork. */
.console-shutter {
    --shutter-accent: var(--pale-phosphor, #9df47c);
    --shutter-seal-height: 50%;
    --shutter-seal-size: min(27vmin, 9.5cqw, 250px);
    --shutter-unlock-duration: 1100ms;
    --shutter-latch-clearance: clamp(3px, .5cqw, 12px);
    --shutter-seam-width: clamp(5px, .7vw, 12px);
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    container-type: inline-size;
    overflow: hidden;
    contain: paint;
    pointer-events: none;
}

.console-shutter-door {
    --shutter-travel: -104%;
    --door-sheet-position: 1.0319%;
    --channel-sheet-position: 45.8427%;
    position: relative;
    /* Back the CRT apertures without painting behind the rounded steel corners. */
    background: radial-gradient(ellipse, color-mix(in srgb, var(--boot-accent) 6%, #090e10), #050809 75%)
        center / 96% 70% no-repeat;
}

.console-shutter-door:last-child {
    --shutter-travel: 104%;
    --door-sheet-position: 99.0619%;
    --channel-sheet-position: 54.3071%;
}

.console-shutter-door::before {
    content: "";
    position: absolute;
    z-index: 3;
    inset: 0 var(--shutter-seam-width) 0 0;
    /* Each leaf uses a 1034 × 730 crop from the 2100 × 749 door sheet. */
    background: url('/assets/pale-eye/pale-eye-crt-doors-v5.png') var(--door-sheet-position) 31.5789%
        / 203.0948% 102.6027% no-repeat;
}

.console-shutter-door:last-child::before { inset-inline: var(--shutter-seam-width) 0; }

.console-shutter-door::after {
    content: "";
    position: absolute;
    inset: 0 0 0 auto;
    width: var(--shutter-seam-width);
    /* Split the 113px visible track so each half leaves with its door. */
    background: #0d1214 url('/assets/pale-eye/pale-eye-center-channel-track-v1.png') var(--channel-sheet-position) 48%
        / 1281.4159% 101.1644% no-repeat;
}

.console-shutter-door:last-child::after { inset-inline: 0 auto; }

.console-shutter-progress {
    position: absolute;
    z-index: 1;
    inset: 0 1px 0 auto;
    width: clamp(2px, .4vw, 5px);
    color: var(--shutter-accent);
    background: repeating-linear-gradient(to top, currentColor 0 8px, transparent 8px 11px);
    filter: drop-shadow(0 0 4px currentColor);
    clip-path: inset(calc(100% - var(--shutter-progress, 0%)) -5px 0);
}

.console-shutter-door:last-child .console-shutter-progress { inset-inline: 1px auto; }

.console-shutter-lock-track {
    --shutter-track-inset: calc(var(--shutter-seam-width) + 4px);
    position: absolute;
    z-index: 4;
    top: var(--shutter-seal-height);
    left: var(--shutter-track-inset);
    inline-size: calc(var(--shutter-seal-size) / 2 + var(--shutter-latch-clearance) - var(--shutter-track-inset));
    block-size: clamp(10px, 2.6vmin, 24px);
    /* Tighten the crop to the visible 2050 × 157 rail on its transparent sheet. */
    background: url('/assets/pale-eye/pale-eye-right-seal-track-v1.png') 50% 50.0882% / 105.9512% 461.1465% no-repeat;
    transform: translateY(-50%);
}

.console-shutter-seal {
    position: absolute;
    z-index: 5;
    top: var(--shutter-seal-height);
    left: 0;
    display: grid;
    grid-template: 100% / 100%;
    place-items: center;
    width: 1em;
    aspect-ratio: 1;
    font-size: var(--shutter-seal-size);
    --mark-color: color-mix(in srgb, var(--shutter-accent) 38%, #e6f0ec);
    background: radial-gradient(circle closest-side, #0a1010 78%, transparent 79%);
    transform: translate(-50%, -50%);
}

.console-shutter-seal > * { grid-area: 1 / 1; }

.console-shutter-seal-graphite,
.console-shutter-seal-rim {
    display: block;
    block-size: auto;
}

.console-shutter-seal-graphite {
    inline-size: 81%;
    transform: translate(.2%, -.5%);
}

.console-shutter-seal .view-mark {
    z-index: 1;
    font-size: .74em;
}

.console-shutter-seal-rim {
    z-index: 2;
    inline-size: 100%;
    /* The approved plate has a filled center. Match the mask to its inner groove. */
    mask-image: radial-gradient(ellipse 36.3% 36.3% at 49.3% 50.8%, transparent 98%, #000 100%);
    transform: translate(.7%, -.8%);
}

@media (prefers-reduced-motion: no-preference) {
    .console-shutter-progress { transition: clip-path 260ms ease-out; }

    [data-console-greeting] .console-shutter-seal {
        animation: console-shutter-unlock var(--shutter-unlock-duration) cubic-bezier(.34, 0, .66, 1) both;
    }

    .console-shutter[data-state="opening"] .console-shutter-door {
        animation: console-shutter-open 1.5s cubic-bezier(.44, 0, .38, 1) both;
    }

    [data-console-handoff]:not([data-console-welcome]) .console-intro-pane > :not(.console-intro-interaction) {
        animation: uplink-diagnostics-on var(--boot-handoff-duration) ease-out both;
    }
}

@keyframes console-shutter-unlock {
    from { transform: translate(-50%, -50%); }
    to { transform: translate(var(--shutter-latch-clearance), -50%); }
}

@keyframes console-shutter-open {
    from { transform: translate3d(0, 0, 0); }
    to { transform: translate3d(var(--shutter-travel), 0, 0); }
}

@keyframes uplink-diagnostics-on {
    from { opacity: 0; }
    to { opacity: 1; }
}

[data-console-welcome] .console-intro-pane > :not(.console-intro-interaction),
.console-intro-pane:has(> .console-intro-interaction:not(:empty)) > .console-intro-diagnostics {
    display: none;
}

.console-intro-pane {
    --boot-window-outer: 10.5%;
    position: absolute;
    /* Keep live content inside the narrowest part of each opening. */
    inset-block: 28.5% 29.5%;
    inset-inline: var(--boot-window-outer) calc(17.5% + var(--shutter-seam-width));
    z-index: 2;
    display: grid;
    align-items: center;
    overflow: hidden;
}

.console-shutter-door:last-child .console-intro-pane {
    inset-inline: calc(23.5% + var(--shutter-seam-width)) var(--boot-window-outer);
}

.console-intro-interaction,
.console-intro-diagnostics { grid-area: 1 / 1; }

.console-intro-interaction {
    justify-self: center;
    max-inline-size: 33ch;
    margin: 0;
    padding-inline: clamp(2px, 1cqw, 12px);
    color: var(--boot-accent);
    font: 600 clamp(12px, 1.6cqw, 1.15rem)/1.35 var(--mono);
    text-align: center;
    text-wrap: balance;
    overflow-wrap: anywhere;
    text-shadow: 0 0 12px var(--boot-grid);
}

.console-intro-message {
    margin: 0 0 clamp(8px, 2.4dvh, 26px);
    color: var(--boot-accent);
    font: 600 clamp(1rem, min(2.1vw, 3.9dvh), 1.55rem)/1.25 var(--mono);
    letter-spacing: .045em;
    text-transform: uppercase;
    text-shadow: 0 0 12px var(--boot-grid);
}

.console-greeting-text { display: inline-block; }

@media (prefers-reduced-motion: no-preference) {
    .console-greeting-text { animation: uplink-greeting-type 1.5s steps(23, end) both; }
}

@keyframes uplink-greeting-type {
    from { clip-path: inset(0 100% 0 0); }
    to { clip-path: inset(0); }
}

#console-intro-checks { margin: 0; padding: 0; list-style: none; }

#console-intro-checks li {
    display: grid;
    grid-template-columns: auto minmax(6px, 1fr) 8ch;
    gap: clamp(4px, 1vw, 12px);
    align-items: baseline;
    padding: clamp(2px, .75dvh, 6px) 0;
    font-size: clamp(.7rem, 1.25vw, .95rem);
}

#console-intro-checks li::before {
    content: "";
    grid-column: 2;
    grid-row: 1;
    border-bottom: 1px dotted var(--boot-muted);
    opacity: .6;
}

#console-intro-checks li[data-state="pending"] { visibility: hidden; }
.console-intro-check-status { grid-column: 3; grid-row: 1; text-align: right; }
#console-intro-checks li[data-state="active"] .console-intro-check-status,
[data-console-ready] .console-intro-check-status { color: var(--boot-accent); }

.console-intro-display { block-size: 100%; }

.console-inspection-chamber {
    --inspection-light: color-mix(in srgb, var(--boot-accent) 38%, #dde9ef);
    position: relative;
    block-size: 100%;
    overflow: hidden;
    isolation: isolate;
}

.console-inspection-chamber::after {
    content: "";
    position: absolute;
    inset: 11% 12% auto;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--inspection-light) 15% 85%, transparent);
    box-shadow: 0 0 8px var(--boot-grid);
    opacity: .4;
}

.console-inspection-tubes {
    position: absolute;
    inset: 24% 11% 13%;
    display: grid;
    grid-template-rows: repeat(6, minmax(0, 1fr));
    gap: 8%;
}

.console-inspection-tube {
    --tube-light: #e9e9e9;
    --tube-length: 92%;
    --tube-base: 26%;
    --tube-rate: .73;
    --tube-delay: 0ms;
    position: relative;
    width: var(--tube-length);
    border-radius: 999px;
    background: linear-gradient(#1e282c, #10191c 33%, #050a0c 70%, #263137);
    box-shadow: 0 0 0 1px #4a575a, 0 2px 4px #0008;
}

.console-inspection-tube:nth-child(2) {
    --tube-light: #b7b7b7;
    --tube-length: 75%;
    --tube-base: 14%;
    --tube-rate: .84;
    --tube-delay: 80ms;
}

.console-inspection-tube:nth-child(3) {
    --tube-light: #d6d6d6;
    --tube-length: 87%;
    --tube-base: 36%;
    --tube-rate: .64;
    --tube-delay: 40ms;
}

.console-inspection-tube:nth-child(4) {
    --tube-light: #989898;
    --tube-length: 65%;
    --tube-base: 18%;
    --tube-rate: .73;
    --tube-delay: 120ms;
}

.console-inspection-tube:nth-child(5) {
    --tube-light: #c8c8c8;
    --tube-length: 98%;
    --tube-base: 32%;
    --tube-rate: .68;
    --tube-delay: 70ms;
}

.console-inspection-tube:nth-child(6) {
    --tube-light: #a7a7a7;
    --tube-length: 80%;
    --tube-base: 22%;
    --tube-rate: .84;
    --tube-delay: 30ms;
}

.console-inspection-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: min(100%, calc(var(--tube-base) + var(--shutter-progress, 0%) * var(--tube-rate)));
    overflow: hidden;
    border-radius: inherit;
    background: linear-gradient(
        color-mix(in srgb, var(--tube-light) 52%, white),
        var(--tube-light) 38%,
        color-mix(in srgb, var(--tube-light) 52%, #0b0b0b) 78%,
        color-mix(in srgb, var(--tube-light) 28%, #0b0b0b)
    );
    box-shadow: 0 0 5px color-mix(in srgb, var(--tube-light) 34%, transparent);
}

[data-console-ready] .console-inspection-chamber::after { opacity: .85; }
[data-console-ready] .console-inspection-fill { width: 100%; }

@media (prefers-reduced-motion: no-preference) {
    .console-inspection-chamber::after { transition: opacity 350ms ease-out; }
    .console-inspection-fill { transition: width 340ms ease-out var(--tube-delay); }

    .console-inspection-fill::after {
        content: "";
        position: absolute;
        inset: 0 auto 0 0;
        width: 45%;
        background: linear-gradient(90deg, transparent, #fff6 65%, transparent);
        animation: inspection-tube-pulse 1.14s linear var(--tube-delay) infinite;
    }

    [data-console-ready] .console-inspection-fill::after {
        opacity: 0;
        animation-play-state: paused;
        transition: opacity 200ms ease-out;
    }
}

@keyframes inspection-tube-pulse {
    from { transform: translateX(-100%); }
    to { transform: translateX(225%); }
}

@media (max-width: 760px) {
    #console-intro-checks li {
        grid-template-columns: minmax(0, 1fr);
        gap: 2px;
        padding-block: 4px;
    }
    #console-intro-checks li::before { content: none; }
    .console-intro-check-status { grid-column: 1; grid-row: 2; text-align: left; }
}

@media (max-width: 760px) and (max-height: 700px) {
    .console-intro-message {
        margin-block-end: 8px;
        font-size: .75rem;
        line-height: 1.2;
    }

    #console-intro-checks li {
        grid-template-columns: 8px minmax(0, 1fr);
        align-items: start;
        gap: 4px;
        padding-block: 2px;
        font-size: .675rem;
        line-height: 1.2;
    }

    #console-intro-checks li::before {
        content: "";
        grid-column: 1;
        inline-size: 6px;
        block-size: 6px;
        margin-block-start: .38em;
        border: 1px solid var(--boot-accent);
        border-radius: 50%;
        opacity: 1;
    }

    #console-intro-checks li[data-state="complete"]::before {
        inline-size: 5px;
        block-size: 8px;
        margin-block-start: .16em;
        margin-inline-start: 1px;
        border-width: 0 1px 1px 0;
        border-radius: 0;
        transform: rotate(45deg);
    }

    .console-intro-check-status {
        position: absolute;
        inline-size: 1px;
        block-size: 1px;
        clip-path: inset(50%);
        overflow: hidden;
        white-space: nowrap;
    }
}

@media (max-width: 760px) and (max-height: 400px) {
    .console-intro-pane { inset-block: 27% 28.5%; }

    .console-intro-message,
    #console-intro-checks li {
        font-family: system-ui, sans-serif;
        letter-spacing: .01em;
    }

    .console-intro-message {
        margin-block-end: 4px;
        font-size: .675rem;
        line-height: 1.1;
    }

    #console-intro-checks li {
        padding-block: 0;
        font-size: .625rem;
        line-height: 1;
    }
}

