:root {
    --deep: #0b1a22;
    --surface: #1a2a33;
    --shelf: #0f1e28;
    --driftwood: #e8e4df;
    --fog: #b8c4cc;
    --cyan: #6ec6ca;
    --coral: #d4826a;
    --kelp: #2a4a3f;
    --phosphor: #3affa0;
}

/* Design typography references: Space Grotesk" (Google Fonts, Space Grotesk's distinctive geometric letterforms — particularly its quirky 'a'; Inter" (Google Fonts; JetBrains Mono" (Google Fonts at tiny sizes (0.65rem); Interaction via IntersectionObserver` (vanilla JS). */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    background: var(--deep);
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 18% 12%, rgba(110, 198, 202, 0.08), transparent 26rem),
        radial-gradient(circle at 78% 8%, rgba(212, 130, 106, 0.07), transparent 22rem),
        linear-gradient(180deg, var(--deep), #0d1f27 42%, var(--deep));
    color: var(--fog);
    font-family: "Inter", system-ui, sans-serif;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    font-weight: 400;
    line-height: 1.75;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    background:
        repeating-linear-gradient(0deg, rgba(110, 198, 202, 0.025), rgba(110, 198, 202, 0.025) 1px, transparent 1px, transparent 5px),
        linear-gradient(90deg, rgba(58, 255, 160, 0.025), transparent 14%, transparent 86%, rgba(212, 130, 106, 0.035));
    mix-blend-mode: screen;
}

.section {
    position: relative;
    width: 100%;
}

#progress-indicator {
    position: fixed;
    right: 0;
    top: 0;
    z-index: 20;
    width: 2px;
    height: 100vh;
    background: var(--surface);
}

#progress-fill {
    width: 100%;
    height: 100%;
    transform: scaleY(0);
    transform-origin: top;
    background: linear-gradient(180deg, var(--cyan), var(--phosphor), var(--coral));
    will-change: transform;
}

.transmission-header {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 8rem 2rem 12rem;
    isolation: isolate;
}

.header-content {
    position: relative;
    z-index: 3;
    text-align: center;
}

.kicker,
.chapter-kicker,
.transmission-status,
.data-readout,
.margin-annotation,
.terminal-panel {
    font-family: "JetBrains Mono", ui-monospace, monospace;
    letter-spacing: 0.04em;
}

.kicker,
.chapter-kicker {
    margin-bottom: 1.15rem;
    color: rgba(110, 198, 202, 0.74);
    font-size: 0.72rem;
    text-transform: uppercase;
}

.glitch-title,
.glitch-heading {
    position: relative;
    color: var(--driftwood);
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.03;
}

.glitch-title {
    font-size: clamp(2.2rem, 5.5vw, 4.8rem);
    text-shadow: 0 0 35px rgba(110, 198, 202, 0.15);
}

.glitch-heading {
    max-width: 38rem;
    margin-bottom: 2rem;
    font-size: clamp(2rem, 4vw, 3.55rem);
}

.glitch-title::before,
.glitch-title::after,
.glitch-heading::before,
.glitch-heading::after {
    content: attr(data-text);
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.78;
}

.glitch-title::before,
.glitch-heading::before {
    color: var(--cyan);
    clip-path: inset(0 0 66% 0);
    animation: glitchTop 4s infinite steps(1, end);
}

.glitch-title::after,
.glitch-heading::after {
    color: var(--coral);
    clip-path: inset(66% 0 0 0);
    animation: glitchBottom 4s infinite steps(1, end);
}

@keyframes glitchTop {
    0%, 15% { transform: translateX(2px); }
    16%, 49% { transform: translateX(4px); }
    50%, 65% { transform: translateX(0); }
    66%, 100% { transform: translateX(3px); }
}

@keyframes glitchBottom {
    0%, 15% { transform: translateX(-2px); }
    16%, 49% { transform: translateX(-4px); }
    50%, 65% { transform: translateX(1px); }
    66%, 100% { transform: translateX(-3px); }
}

.transmission-status {
    margin-top: 1.2rem;
    color: var(--cyan);
    font-size: 0.8rem;
}

.hero-waveform {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 5vh;
    z-index: 3;
    width: 100%;
    height: 18vh;
    min-height: 120px;
    overflow: visible;
}

.wave-path,
.wave-error,
.contour-path {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.wave-path {
    stroke: var(--cyan);
    stroke-width: 1.5px;
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    animation: pathDraw 2.5s ease-in-out forwards;
    filter: drop-shadow(0 0 12px rgba(110, 198, 202, 0.35));
}

.wave-error {
    stroke: var(--coral);
    stroke-width: 1.5px;
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    animation: pathDraw 2.5s ease-in-out forwards;
}

@keyframes pathDraw {
    0% { stroke-dashoffset: 1200; }
    40% { stroke-dashoffset: 704; }
    42% { stroke-dashoffset: 745; }
    44% { stroke-dashoffset: 690; }
    48% { stroke-dashoffset: 620; }
    50% { stroke-dashoffset: 650; }
    52% { stroke-dashoffset: 585; }
    57% { stroke-dashoffset: 520; }
    59% { stroke-dashoffset: 558; }
    61% { stroke-dashoffset: 472; }
    100% { stroke-dashoffset: 0; }
}

.chapter-block {
    display: flex;
    justify-content: center;
    padding: clamp(7rem, 13vw, 12rem) 2rem;
    background: linear-gradient(180deg, rgba(11, 26, 34, 0), rgba(26, 42, 51, 0.28), rgba(11, 26, 34, 0));
}

.chapter-block.alternate {
    background: linear-gradient(180deg, rgba(15, 30, 40, 0.38), rgba(42, 74, 63, 0.16), rgba(11, 26, 34, 0.08));
}

.chapter-shell {
    position: relative;
    width: min(100%, 38rem);
}

.chapter-shell p {
    margin-bottom: 2rem;
    max-width: 38rem;
}

.inline-glitch {
    color: var(--driftwood);
    transition: color 180ms ease, text-shadow 180ms ease, transform 180ms ease;
}

.inline-glitch:hover {
    color: var(--driftwood);
    text-shadow: -1px 0 var(--cyan), 2px 0 var(--coral), 0 0 16px rgba(58, 255, 160, 0.22);
}

.margin-annotation {
    position: absolute;
    left: -8rem;
    top: 8.2rem;
    color: rgba(110, 198, 202, 0.52);
    font-size: 0.7rem;
    line-height: 1.65;
    text-transform: uppercase;
    opacity: 0;
    transform: translateY(0.8rem);
    transition: opacity 700ms ease, transform 700ms ease;
    white-space: nowrap;
}

.margin-annotation.visible {
    opacity: 1;
    transform: translateY(0);
}

.signal-break {
    position: relative;
    height: 40vh;
    min-height: 260px;
    overflow: hidden;
    display: flex;
    align-items: center;
    background: linear-gradient(120deg, var(--surface), var(--shelf), var(--surface));
    background-size: 220% 220%;
    animation: tideGradient 10s ease-in-out infinite;
}

.signal-break::before {
    content: attr(data-break);
    position: absolute;
    left: 2rem;
    top: 2rem;
    color: rgba(110, 198, 202, 0.22);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
}

@keyframes tideGradient {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.divider-waveform {
    width: 100%;
    height: 100%;
    opacity: 0.18;
}

.contour-path {
    stroke: var(--cyan);
    stroke-width: 1.5px;
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    filter: drop-shadow(0 0 10px rgba(110, 198, 202, 0.25));
}

.contour-path.coral {
    stroke: var(--coral);
}

.signal-break.visible .divider-waveform {
    opacity: 1;
    transition: opacity 400ms ease;
}

.signal-break.visible .contour-path {
    animation: pathDraw 3s ease-in-out forwards;
}

.contour-field {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.45;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='520' viewBox='0 0 900 520'%3E%3Cg fill='none' stroke='%232a4a3f' stroke-opacity='.35' stroke-width='1'%3E%3Cpath d='M-20 110 C150 52 260 172 410 108 C550 48 672 79 930 32'/%3E%3Cpath d='M-20 165 C140 104 280 224 430 158 C590 88 705 122 930 86'/%3E%3Cpath d='M-20 220 C160 168 288 286 450 218 C620 146 730 174 930 142'/%3E%3Cpath d='M-20 280 C146 214 310 340 485 270 C650 204 758 236 930 200'/%3E%3Cpath d='M-20 340 C170 285 334 395 512 328 C690 260 780 294 930 260'/%3E%3C/g%3E%3C/svg%3E");
    background-size: 900px 520px;
    animation: contourDrift 28s linear infinite;
}

.contour-field-one { opacity: 0.55; }
.contour-field-two { opacity: 0.28; }

@keyframes contourDrift {
    from { transform: translateY(0); }
    to { transform: translateY(-14px); }
}

.data-readout {
    position: absolute;
    z-index: 3;
    color: rgba(110, 198, 202, 0.4);
    font-size: 0.65rem;
    text-transform: uppercase;
}

.readout-a { left: 7vw; top: 18vh; }
.readout-b { right: 8vw; bottom: 24vh; color: rgba(212, 130, 106, 0.45); }

.terminal-footer {
    min-height: 78vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 7rem 2rem;
    background:
        linear-gradient(rgba(110, 198, 202, 0.03), rgba(110, 198, 202, 0.03)),
        var(--surface);
    border-top: 1px solid rgba(42, 74, 63, 0.8);
}

.terminal-panel {
    width: min(100%, 45rem);
    padding: clamp(1.5rem, 4vw, 2.4rem);
    border: 1px solid rgba(110, 198, 202, 0.22);
    background:
        repeating-linear-gradient(0deg, rgba(110, 198, 202, 0.035), rgba(110, 198, 202, 0.035) 2px, transparent 2px, transparent 4px),
        linear-gradient(180deg, rgba(11, 26, 34, 0.92), rgba(15, 30, 40, 0.92));
    box-shadow: 0 0 0 1px rgba(42, 74, 63, 0.4), 0 30px 80px rgba(0, 0, 0, 0.22);
    color: var(--cyan);
    font-size: 0.86rem;
    line-height: 1.9;
}

.terminal-topline {
    margin-bottom: 1.4rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid rgba(42, 74, 63, 0.85);
    color: var(--driftwood);
}

.terminal-line span {
    color: var(--phosphor);
}

#terminal-timestamp {
    color: var(--fog);
}

.cursor {
    display: inline-block;
    margin-left: 0.25rem;
    color: var(--phosphor);
    animation: blink 1s steps(1, end) infinite;
}

@keyframes blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

@media (max-width: 1200px) {
    .margin-annotation {
        display: none;
    }
}

@media (max-width: 768px) {
    .transmission-header {
        padding-inline: 1.25rem;
    }

    .chapter-block {
        padding: 5rem 1.35rem;
    }

    .signal-break {
        height: 32vh;
    }

    .data-readout {
        display: none;
    }
}

@media (max-width: 480px) {
    .transmission-status {
        font-size: 0.68rem;
    }

    .terminal-panel {
        font-size: 0.74rem;
    }
}
