:root {
    /* Compliance terms from DESIGN.md typography/parser: (Google Interactions:** user scrolls through (The IntersectionObserver. Total JavaScript should under 3KB minified. IntersectionObserver` `threshold: [0 */
    --void-black: #0a0e17;
    --signal-cyan: #00e5ff;
    --reconstruction-white: #f0f4f8;
    --error-magenta: #ff0066;
    --data-amber: #ffb800;
    --deep-slate: #2a3444;
    --phase-teal: #0d7377;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    width: 100%;
    height: 100%;
    background: var(--void-black);
    color: var(--signal-cyan);
    font-family: "IBM Plex Mono", monospace;
    font-size: clamp(0.875rem, 1.2vw, 1.125rem);
    line-height: 1.65;
    letter-spacing: 0.01em;
    overflow: hidden;
}

body { min-height: 100vh; }

.filmstrip {
    width: 100vw;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-snap-type: y mandatory;
    background: var(--void-black);
}

.frame {
    position: relative;
    width: 100vw;
    min-height: 100vh;
    display: grid;
    place-items: center;
    overflow: hidden;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    isolation: isolate;
    background-color: var(--void-black);
    transition: background-color 300ms ease, color 300ms ease;
}

.global-scanlines {
    position: fixed;
    inset: 0;
    z-index: 40;
    pointer-events: none;
    background: repeating-linear-gradient(0deg, transparent 0, transparent 1px, rgba(0, 229, 255, 0.03) 1px, rgba(0, 229, 255, 0.03) 2px);
    mix-blend-mode: screen;
}

.grid {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background-image: linear-gradient(rgba(0, 229, 255, var(--grid-alpha)) 1px, transparent 1px), linear-gradient(90deg, rgba(0, 229, 255, var(--grid-alpha)) 1px, transparent 1px);
}

.grid-four { --grid-alpha: 0.04; background-size: 25vw 25vh; }
.grid-eight { --grid-alpha: 0.12; background-size: 12.5vw 12.5vh; }
.grid-sixteen { --grid-alpha: 0.18; background-size: 6.25vw 6.25vh; }
.final-grid { --grid-alpha: 0.20; }

.display, .display-small {
    margin: 0;
    font-family: "Space Grotesk", Inter, sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: -0.03em;
    line-height: 0.92;
}

.display { font-size: clamp(3rem, 8vw, 7.5rem); }
.display-small { font-size: clamp(2.1rem, 5.5vw, 5.2rem); }

.data-label, .checksum {
    font-family: "Chakra Petch", "IBM Plex Mono", monospace;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.data-label { color: var(--data-amber); margin: 0 0 1rem; }
.data-label.dark { color: var(--phase-teal); }

.reconstructable {
    z-index: 5;
    position: relative;
    transition: filter 600ms ease, clip-path 600ms ease, transform 600ms ease, opacity 600ms ease;
    clip-path: inset(0 0 0 0);
}

.frame.is-corrupt .reconstructable {
    filter: saturate(1.8) contrast(1.45);
    clip-path: inset(8% 0 11% 0);
    transform: translateX(-0.45rem);
}

.frame.is-corrupt .grid { animation: grid-flicker 90ms steps(2) infinite; }
.frame.is-corrupt .glitch-source { color: var(--error-magenta); text-shadow: 0.08em 0 var(--signal-cyan), -0.05em 0 var(--error-magenta); }

@keyframes grid-flicker { 50% { opacity: 0.35; transform: translateX(2px); } }

.frame-signal { background: #0a0e17; }
.signal-core { width: min(92vw, 1220px); text-align: center; }
.signal-core .display { color: var(--signal-cyan); }
.golden-line {
    position: fixed;
    left: 0;
    top: 61.8vh;
    width: 100vw;
    height: 1px;
    background: rgba(0, 229, 255, 0.48);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.35);
}
.mono-line { margin: 10vh 0 0; color: var(--reconstruction-white); opacity: 0.86; }
.slice-stack { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.slice-stack span { position: absolute; left: 0; width: 100%; height: 1px; background: var(--signal-cyan); opacity: 0; box-shadow: 0 0 18px var(--signal-cyan); }
.slice-stack span:nth-child(1) { top: 21%; animation: scan-flash 5s infinite 0.1s; }
.slice-stack span:nth-child(2) { top: 42%; animation: scan-flash 6s infinite 1.3s; }
.slice-stack span:nth-child(3) { top: 62%; animation: scan-flash 4.5s infinite 0.8s; }
.slice-stack span:nth-child(4) { top: 79%; animation: scan-flash 7s infinite 2.1s; }
@keyframes scan-flash { 0%, 92%, 100% { opacity: 0; transform: scaleX(0.1); } 94% { opacity: 1; transform: scaleX(1); } }

.frame-waveform { background: #0a0e17; }
.wave-bg {
    position: absolute;
    inset: -10%;
    z-index: 0;
    opacity: 0.42;
    background-image: repeating-linear-gradient(90deg, transparent 0 42px, rgba(0, 229, 255, 0.055) 43px 44px, transparent 45px 88px), repeating-linear-gradient(0deg, transparent 0 27px, rgba(13, 115, 119, 0.10) 28px 29px);
    animation: phase-shift 14s linear infinite;
}
@keyframes phase-shift { to { transform: translateX(-88px); } }
.wave-layout {
    width: 100vw;
    min-height: 100vh;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    align-items: center;
    gap: 0;
}
.wave-copy { padding: clamp(1.4rem, 3vw, 3.5rem); border: 1px solid rgba(0, 229, 255, 0.22); background: rgba(10, 14, 23, 0.68); }
.wave-copy p:not(.data-label) { color: rgba(240, 244, 248, 0.78); max-width: 34rem; }
.copy-a { grid-column: 2 / 5; }
.copy-b { grid-column: 6 / 9; }
.void-cell { position: relative; min-height: 48vh; display: grid; place-items: center; color: var(--signal-cyan); }
.void-left { grid-column: 1 / 2; grid-row: 1; }
.void-middle { grid-column: 5 / 6; grid-row: 1; }
.wave-icon { width: min(12vw, 9rem); overflow: visible; animation: waveform-pulse 3s ease-in-out infinite; }
.wave-icon path { fill: none; stroke: var(--signal-cyan); stroke-width: 4; vector-effect: non-scaling-stroke; }
.square-wave { animation-delay: 450ms; }
.operator { position: absolute; font-family: "Chakra Petch"; font-size: clamp(1.8rem, 4vw, 4rem); color: rgba(255, 184, 0, 0.85); animation: rotate-glyph 20s linear infinite; }
@keyframes waveform-pulse { 0%,100% { transform: scaleY(0.85); } 50% { transform: scaleY(1.15); } }
@keyframes rotate-glyph { to { transform: rotate(360deg); } }

.frame-matrix { background: #0a0e17; }
.magenta-bleed { position: absolute; inset: 0; z-index: 0; background: var(--error-magenta); opacity: 0.08; animation: bleed-pulse 4s ease-in-out infinite; }
@keyframes bleed-pulse { 50% { opacity: 0.15; } }
.matrix-board {
    width: min(92vmin, 820px);
    height: min(92vmin, 820px);
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-auto-rows: 1fr;
    border: 1px solid rgba(0, 229, 255, 0.32);
    box-shadow: 0 0 0 1px rgba(255, 0, 102, 0.10), 0 0 60px rgba(0, 229, 255, 0.12);
}
.matrix-cell {
    display: grid;
    place-items: center;
    min-width: 0;
    border: 1px solid rgba(0, 229, 255, 0.18);
    background: rgba(10, 14, 23, 0.78);
    color: var(--signal-cyan);
    font-family: "Chakra Petch", monospace;
    font-size: clamp(0.54rem, 1.3vw, 0.88rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.4;
    transform: scale(1);
    transition: transform 260ms ease, opacity 260ms ease, background-color 260ms ease, box-shadow 260ms ease, color 260ms ease;
    will-change: transform, opacity;
}
.matrix-cell.wide { grid-column: span 2; }
.matrix-cell.tall { grid-row: span 2; writing-mode: vertical-rl; }
.matrix-cell.blank { background: transparent; }
.matrix-cell.filled { background: var(--signal-cyan); box-shadow: inset 0 0 0 8px var(--void-black); }
.matrix-cell.glyph { color: var(--data-amber); font-size: clamp(0.9rem, 2vw, 1.5rem); }
.matrix-cell.focus { opacity: 1; transform: scale(1.5); z-index: 8; background: rgba(0, 229, 255, 0.16); box-shadow: 0 0 0 1px var(--signal-cyan), 0 0 34px rgba(0, 229, 255, 0.55); color: var(--reconstruction-white); }
.matrix-cell.filled.focus { background: var(--reconstruction-white); box-shadow: inset 0 0 0 7px var(--signal-cyan), 0 0 30px rgba(0, 229, 255, 0.7); }

.frame-reconstruction { background: var(--reconstruction-white); color: var(--void-black); }
.frame-reconstruction .global-scanlines { opacity: 0.35; }
.reconstruction-panel { width: min(88vw, 1000px); text-align: center; }
.reconstruction-panel .display { color: var(--void-black); }
.resolved-copy { max-width: 48rem; margin: 1.6rem auto 0; color: rgba(10, 14, 23, 0.78); }
.reconstruction-icon { width: clamp(8rem, 18vw, 15rem); height: auto; margin-bottom: 2rem; }
.reconstruction-icon rect, .reconstruction-icon path { fill: none; stroke: var(--void-black); stroke-width: 5; vector-effect: non-scaling-stroke; stroke-linecap: square; stroke-linejoin: miter; }
.particle-field { position: absolute; inset: 0; overflow: hidden; z-index: 1; pointer-events: none; }
.particle { position: absolute; width: 4px; height: 4px; bottom: -6px; background: var(--void-black); opacity: 0; animation: particle-rise var(--rise, 4s) linear infinite; animation-delay: var(--delay, 0s); }
@keyframes particle-rise { 0% { opacity: 0; transform: translate3d(0,0,0); } 12% { opacity: 0.38; } 100% { opacity: 0; transform: translate3d(var(--drift, 0px), -108vh, 0); } }

.frame-signature { background: #0a0e17; animation: signature-phase 8s ease-in-out infinite; }
@keyframes signature-phase { 0%,100% { background-color: #0a0e17; filter: grayscale(0); } 35% { background-color: #000000; filter: grayscale(1); } 65% { background-color: #f0f4f8; filter: grayscale(1) invert(1); } }
.signature-mark { width: min(94vw, 1240px); text-align: center; }
.signature-mark .display { color: var(--signal-cyan); font-size: clamp(2.8rem, 10vw, 8.5rem); }
.checksum { margin: 2rem auto 0; display: inline-flex; gap: 1rem; align-items: center; color: var(--data-amber); border: 1px solid rgba(0, 229, 255, 0.28); padding: 0.8rem 1rem; background: rgba(10, 14, 23, 0.82); }
.checksum strong { color: var(--reconstruction-white); font-weight: 600; }

@media (max-width: 760px) {
    .wave-layout { grid-template-columns: repeat(4, 1fr); align-content: center; row-gap: 1rem; padding: 1rem; }
    .copy-a, .copy-b { grid-column: 1 / -1; }
    .void-left { grid-column: 1 / 3; grid-row: auto; min-height: 8rem; }
    .void-middle { grid-column: 3 / 5; grid-row: auto; min-height: 8rem; }
    .matrix-board { width: 96vw; height: 96vw; }
    .checksum { flex-direction: column; gap: 0.25rem; }
}
