/* ============================================================
   op9.rs / signal archive
   Vaporwave requiem in terracotta-warm
   ============================================================ */

:root {
    /* Palette — earth-pigment colors */
    --kiln-white: #F5E6D3;
    --dark-loam: #1E1008;
    --umber-dark: #3D2014;
    --burnt-umber: #5A3D2B;
    --raw-sienna: #8B5E3C;
    --terracotta-blush: #C4785A;
    --fired-copper: #D4956A;
    --tape-amber: #E8A85C;

    /* Typography stacks */
    --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
    --font-secondary: "Outfit", "Inter", system-ui, sans-serif;
    --font-body: "Work Sans", "Inter", system-ui, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, "Menlo", monospace;

    --pad-x: clamp(24px, 5vw, 80px);
    --grid-step: 60px;
}

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

html, body {
    background: var(--kiln-white);
    color: var(--umber-dark);
    overflow-x: hidden;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.65;
    cursor: none; /* cursor replaced by glow / flare */
    min-height: 100vh;
}

.defs { position: absolute; width: 0; height: 0; pointer-events: none; }

/* ============================================================
   GRID SUBSTRATE — persistent decorative layer
   ============================================================ */
.grid-substrate {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    --grid-opacity: 0.08;
    transition: opacity 600ms ease;
}

.grid-layer {
    position: absolute;
    inset: 0;
}

.grid-base {
    background-image:
        repeating-linear-gradient(
            to right,
            rgba(139, 94, 60, var(--grid-opacity)) 0,
            rgba(139, 94, 60, var(--grid-opacity)) 1px,
            transparent 1px,
            transparent var(--grid-step)
        ),
        repeating-linear-gradient(
            to bottom,
            rgba(139, 94, 60, var(--grid-opacity)) 0,
            rgba(139, 94, 60, var(--grid-opacity)) 1px,
            transparent 1px,
            transparent var(--grid-step)
        );
    animation: grid-breathe 12s ease-in-out infinite;
}

@keyframes grid-breathe {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.06); }
}

/* Heat-distortion warp at outer 15% via SVG filter */
.grid-warp-edges {
    background-image:
        repeating-linear-gradient(
            to right,
            rgba(139, 94, 60, calc(var(--grid-opacity) * 0.9)) 0,
            rgba(139, 94, 60, calc(var(--grid-opacity) * 0.9)) 1px,
            transparent 1px,
            transparent var(--grid-step)
        ),
        repeating-linear-gradient(
            to bottom,
            rgba(139, 94, 60, calc(var(--grid-opacity) * 0.9)) 0,
            rgba(139, 94, 60, calc(var(--grid-opacity) * 0.9)) 1px,
            transparent 1px,
            transparent var(--grid-step)
        );
    -webkit-mask-image:
        radial-gradient(ellipse 70% 70% at center, transparent 0%, transparent 70%, black 100%);
    mask-image:
        radial-gradient(ellipse 70% 70% at center, transparent 0%, transparent 70%, black 100%);
    filter: url(#heatWarp);
    opacity: 0.65;
}

/* Per-section grid opacities */
body.section-active-01 .grid-substrate { --grid-opacity: 0.04; }
body.section-active-02 .grid-substrate { --grid-opacity: 0.08; }
body.section-active-03 .grid-substrate { --grid-opacity: 0.12; }
body.section-active-04 .grid-substrate { --grid-opacity: 0.08; }
body.section-active-05 .grid-substrate { --grid-opacity: 0.06; }

/* Section-thicken zone — at top of each section after first */
.grid-thicken {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 18vh;
    pointer-events: none;
    background-image:
        repeating-linear-gradient(
            to right,
            rgba(139, 94, 60, 0.16) 0,
            rgba(139, 94, 60, 0.16) 1px,
            transparent 1px,
            transparent 30px
        ),
        repeating-linear-gradient(
            to bottom,
            rgba(139, 94, 60, 0.16) 0,
            rgba(139, 94, 60, 0.16) 1px,
            transparent 1px,
            transparent 30px
        );
    -webkit-mask-image: linear-gradient(to bottom, black 0%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 0%, transparent 100%);
    z-index: 2;
}

.section-entry .grid-thicken { display: none; }

[data-mode="dark"] .grid-thicken {
    background-image:
        repeating-linear-gradient(
            to right,
            rgba(196, 120, 90, 0.18) 0,
            rgba(196, 120, 90, 0.18) 1px,
            transparent 1px,
            transparent 30px
        ),
        repeating-linear-gradient(
            to bottom,
            rgba(196, 120, 90, 0.18) 0,
            rgba(196, 120, 90, 0.18) 1px,
            transparent 1px,
            transparent 30px
        );
}

/* ============================================================
   SECTION COUNTER
   ============================================================ */
.section-counter {
    position: fixed;
    left: var(--pad-x);
    bottom: 30px;
    z-index: 90;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--terracotta-blush);
    opacity: 0.6;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 400ms ease;
    pointer-events: none;
}

.counter-divider, .counter-total { opacity: 0.55; }
.counter-label {
    margin-left: 10px;
    padding-left: 10px;
    border-left: 1px solid currentColor;
    opacity: 0.7;
}

body.section-active-01 .section-counter,
body.section-active-03 .section-counter,
body.section-active-05 .section-counter {
    color: var(--tape-amber);
}

/* ============================================================
   SECTIONS — full-bleed bands
   ============================================================ */
.document {
    position: relative;
    z-index: 5;
}

.section {
    position: relative;
    width: 100%;
    min-height: 100vh;
    padding: 12vh var(--pad-x);
    display: flex;
    align-items: center;
    overflow: hidden;
}

.section[data-mode="dark"] {
    background: var(--dark-loam);
    color: var(--kiln-white);
}

.section[data-mode="light"] {
    background: var(--kiln-white);
    color: var(--umber-dark);
}

/* ============================================================
   COMMON TAGS
   ============================================================ */
.column-tag, .entry-meta {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--terracotta-blush);
    opacity: 0.75;
    margin-bottom: 32px;
    display: inline-block;
}

.light-tag { color: var(--tape-amber); }
.dark-tag { color: var(--raw-sienna); }

/* ============================================================
   SECTION 1 — ENTRY
   ============================================================ */
.section-entry {
    align-items: center;
    min-height: 100vh;
}

.entry-grid {
    position: relative;
    width: 100%;
    display: grid;
    grid-template-columns: 40% 60%;
    align-items: center;
    gap: 0;
}

.entry-left {
    z-index: 5;
    padding-right: 4vw;
}

.entry-meta {
    color: var(--tape-amber);
    opacity: 0.6;
    margin-bottom: 48px;
}

.entry-headline {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(48px, 6vw, 86px);
    line-height: 0.95;
    letter-spacing: -0.03em;
    color: var(--kiln-white);
    margin-bottom: 36px;
}

.entry-sub {
    font-family: var(--font-secondary);
    font-weight: 300;
    font-size: clamp(20px, 1.6vw, 26px);
    letter-spacing: 0.01em;
    color: var(--fired-copper);
    max-width: 38ch;
    line-height: 1.45;
}

.entry-right {
    position: relative;
    height: 70vh;
    min-height: 480px;
}

/* ============================================================
   SECTION 2 — STATEMENT
   ============================================================ */
.section-statement {
    align-items: flex-start;
    padding-top: 16vh;
}

.statement-grid {
    position: relative;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(40px, 6vw, 100px);
}

.statement-left {
    z-index: 5;
}

.statement-display {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(28px, 3vw, 42px);
    line-height: 1.1;
    letter-spacing: -0.025em;
    color: var(--umber-dark);
    max-width: 22ch;
}

.statement-right {
    z-index: 5;
    padding-top: 30vh;
}

.statement-body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 17px;
    line-height: 1.65;
    color: var(--burnt-umber);
    max-width: 55ch;
    margin-bottom: 22px;
}

.statement-body:last-child { margin-bottom: 0; }

/* ============================================================
   SECTION 3 — ARCHIVE
   ============================================================ */
.section-archive {
    align-items: center;
}

.archive-grid {
    position: relative;
    width: 100%;
    display: grid;
    grid-template-columns: 1.2fr 0.6fr 1.2fr;
    gap: clamp(30px, 4vw, 70px);
    align-items: center;
}

.archive-col { z-index: 5; }

.archive-fragment {
    font-family: var(--font-secondary);
    font-weight: 300;
    font-size: clamp(20px, 1.7vw, 28px);
    line-height: 1.35;
    letter-spacing: 0.01em;
    color: var(--fired-copper);
    margin-bottom: 28px;
    padding: 14px 16px;
    background: rgba(139, 94, 60, 0.03);
    border-left: 1px solid rgba(232, 168, 92, 0.18);
}

.archive-fragment:last-child { margin-bottom: 0; }

.archive-center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.rotated-path {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--terracotta-blush);
    opacity: 0.75;
    transform: rotate(-90deg);
    white-space: nowrap;
    display: inline-block;
}

/* ============================================================
   SECTION 4 — PROCESS
   ============================================================ */
.section-process {
    align-items: flex-start;
    padding-top: 0;
}

.process-grid {
    position: relative;
    width: 100%;
    min-height: 90vh;
    padding-top: 40vh;
    display: flex;
    justify-content: center;
}

.process-body {
    max-width: 55ch;
    z-index: 5;
}

.process-title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(36px, 4vw, 64px);
    line-height: 0.98;
    letter-spacing: -0.03em;
    color: var(--umber-dark);
    margin-bottom: 36px;
}

.process-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 17px;
    line-height: 1.7;
    color: var(--burnt-umber);
    margin-bottom: 22px;
}

.process-text:last-child { margin-bottom: 0; }

/* ============================================================
   SECTION 5 — SIGNAL (void)
   ============================================================ */
.section-signal {
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 110vh;
}

.signal-whisper {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: var(--tape-amber);
    opacity: 0.18;
    transition: opacity 800ms ease;
    pointer-events: none;
}

body.signal-engaged .signal-whisper { opacity: 0; }

/* ============================================================
   LENS-FLARE COMPONENT
   ============================================================ */
.flare {
    position: absolute;
    left: var(--x, 50%);
    top: var(--y, 50%);
    width: 0;
    height: 0;
    pointer-events: none;
    transform: translate(-50%, -50%);
    z-index: 3;
}

.flare-core,
.flare-ring,
.flare-bloom,
.flare-streak {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.flare-core {
    width: var(--core, 80px);
    height: var(--core, 80px);
    border-radius: 50%;
    background: var(--fired-copper);
    filter: blur(20px);
    opacity: 0.7;
}

.flare-ring {
    width: calc(var(--core, 80px) * 1.5);
    height: calc(var(--core, 80px) * 1.5);
    border-radius: 50%;
    border: 1px solid rgba(232, 168, 92, 0.32);
}

.flare-bloom {
    width: calc(var(--core, 80px) * 4);
    height: calc(var(--core, 80px) * 4);
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(196, 120, 90, 0.18) 0%,
        rgba(196, 120, 90, 0.10) 35%,
        rgba(196, 120, 90, 0) 75%
    );
}

.flare-streak {
    width: calc(var(--core, 80px) * 5.5);
    height: 1px;
    background: linear-gradient(
        to right,
        transparent 0%,
        rgba(232, 168, 92, 0.0) 5%,
        rgba(232, 168, 92, 0.18) 50%,
        rgba(232, 168, 92, 0.0) 95%,
        transparent 100%
    );
}

.streak-a { transform: translate(-50%, -50%) rotate(15deg); }
.streak-b { transform: translate(-50%, -50%) rotate(-15deg); }

/* Mega flare in section 1: enormous bloom */
.flare-mega .flare-core { filter: blur(28px); opacity: 0.78; }
.flare-mega .flare-bloom {
    width: calc(var(--core, 120px) * 6);
    height: calc(var(--core, 120px) * 6);
    background: radial-gradient(
        circle,
        rgba(212, 149, 106, 0.32) 0%,
        rgba(196, 120, 90, 0.18) 25%,
        rgba(232, 168, 92, 0.08) 55%,
        rgba(196, 120, 90, 0) 80%
    );
}
.flare-mega .flare-streak {
    width: calc(var(--core, 120px) * 8);
    background: linear-gradient(
        to right,
        transparent 0%,
        rgba(232, 168, 92, 0.0) 8%,
        rgba(232, 168, 92, 0.22) 50%,
        rgba(232, 168, 92, 0.0) 92%,
        transparent 100%
    );
}

.flare-pulse {
    animation: flare-pulse 8s ease-in-out infinite;
}

@keyframes flare-pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.05); }
}

/* Light-section flares: ring color slightly different */
[data-mode="light"] .flare-ring { border-color: rgba(196, 120, 90, 0.28); }
[data-mode="light"] .flare-core { opacity: 0.55; }
[data-mode="light"] .flare-bloom {
    background: radial-gradient(
        circle,
        rgba(212, 149, 106, 0.22) 0%,
        rgba(196, 120, 90, 0.10) 40%,
        rgba(196, 120, 90, 0) 80%
    );
}

/* ============================================================
   CURSOR-FOLLOW SYSTEMS
   ============================================================ */
.cursor-glow {
    position: fixed;
    left: 0;
    top: 0;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(196, 120, 90, 0.32) 0%,
        rgba(196, 120, 90, 0.14) 40%,
        rgba(196, 120, 90, 0) 75%
    );
    filter: blur(18px);
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 60;
    mix-blend-mode: screen;
    transition: opacity 400ms ease, filter 400ms ease;
    opacity: 1;
}

body.signal-engaged .cursor-glow { opacity: 0; }

.cursor-flare {
    position: fixed;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 70;
    --core: 70px;
    opacity: 0;
    transition: opacity 400ms ease;
}

body.signal-engaged .cursor-flare { opacity: 1; }

.cursor-flare .flare-core {
    width: var(--core);
    height: var(--core);
    border-radius: 50%;
    background: var(--fired-copper);
    filter: blur(18px);
    opacity: 0.85;
}

.cursor-flare .flare-ring {
    width: calc(var(--core) * 1.5);
    height: calc(var(--core) * 1.5);
    border-radius: 50%;
    border: 1px solid rgba(232, 168, 92, 0.45);
}

.cursor-flare .flare-bloom {
    width: calc(var(--core) * 4);
    height: calc(var(--core) * 4);
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(212, 149, 106, 0.28) 0%,
        rgba(196, 120, 90, 0.14) 40%,
        rgba(196, 120, 90, 0) 80%
    );
}

.cursor-flare .flare-streak {
    width: calc(var(--core) * 6);
    height: 1px;
    background: linear-gradient(
        to right,
        transparent 0%,
        rgba(232, 168, 92, 0.22) 50%,
        transparent 100%
    );
}

/* Trail container */
.flare-trail {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 65;
    opacity: 0;
    transition: opacity 400ms ease;
}

body.signal-engaged .flare-trail { opacity: 1; }

.trail-spark {
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(212, 149, 106, 0.55) 0%,
        rgba(196, 120, 90, 0.22) 40%,
        rgba(196, 120, 90, 0) 80%
    );
    transform: translate(-50%, -50%);
    pointer-events: none;
    filter: blur(6px);
    mix-blend-mode: screen;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 880px) {
    .entry-grid {
        grid-template-columns: 1fr;
        gap: 8vh;
    }
    .entry-right { height: 50vh; min-height: 320px; }
    .statement-grid { grid-template-columns: 1fr; gap: 6vh; }
    .statement-right { padding-top: 0; }
    .archive-grid {
        grid-template-columns: 1fr;
        gap: 6vh;
    }
    .archive-center { display: none; }
    .process-grid { padding-top: 25vh; }
    .entry-headline { font-size: clamp(40px, 9vw, 60px); }
    body { cursor: auto; }
    .cursor-glow { display: none; }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .flare-pulse { animation: none; }
    .grid-base { animation: none; }
    body { cursor: auto; }
    .cursor-glow {
        left: 50% !important;
        top: 50% !important;
        opacity: 0.4;
    }
    .cursor-flare { display: none; }
    .flare-trail { display: none; }
    html { scroll-behavior: auto; }
}
