/* ============================================
   mysterious.boo - Retro-Futuristic Noir
   ============================================ */
:root {
    --void-black: #0A0A0F;
    --signal-magenta: #CF3E76;
    --neon-teal: #2DE2B8;
    --static-gray: #3A3A4A;
    --fog-white: #D8D8E8;
    --rain-blue: #1A2A3F;
    --amber-warning: #E89B3E;
    --charcoal-mortar: #0D0D12;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    background: var(--void-black);
    color: var(--fog-white);
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.85rem, 1.2vw, 1.05rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

/* --- Rain Canvas --- */
#rainCanvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    mix-blend-mode: screen;
}

/* --- Scan Lines --- */
.scan-lines {
    position: fixed;
    inset: 0;
    z-index: 9998;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(10, 10, 15, 0.08) 2px,
        rgba(10, 10, 15, 0.08) 4px
    );
}

/* --- Section Navigation --- */
.section-nav {
    position: fixed;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.nav-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid var(--static-gray);
    background: transparent;
    cursor: pointer;
    padding: 0;
    transition: all 300ms ease;
}
.nav-dot.active {
    border-color: var(--signal-magenta);
    background: var(--signal-magenta);
    box-shadow: 0 0 8px 2px rgba(207, 62, 118, 0.6);
    animation: dotPulse 2s ease-in-out infinite;
}
@keyframes dotPulse {
    0%, 100% { box-shadow: 0 0 8px 2px rgba(207, 62, 118, 0.6); }
    50% { box-shadow: 0 0 12px 4px rgba(207, 62, 118, 0.3); }
}

/* --- Scenes --- */
.scene {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.scene--signal { min-height: 100vh; padding: clamp(1rem, 2vw, 2rem); }
.scene--frequency { min-height: 90vh; padding: clamp(1rem, 2vw, 2rem); }
.scene--grid { min-height: 120vh; padding: clamp(1rem, 2vw, 2rem); flex-direction: column; gap: 2rem; }
.scene--corridor { min-height: 80vh; padding: clamp(2rem, 4vw, 4rem); }
.scene--window { min-height: 100vh; padding: clamp(2rem, 4vw, 4rem); justify-content: flex-end; }
.scene--static { min-height: 60vh; padding: clamp(1rem, 2vw, 2rem); }

/* --- Bento Grid Base --- */
.bento {
    display: grid;
    gap: 2px;
    width: 100%;
    max-width: 1200px;
    transition: gap 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.bento-cell {
    background: var(--static-gray);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    transition: border-color 300ms ease, box-shadow 300ms ease, opacity 200ms ease;
}
.bento-cell:hover {
    border-color: var(--signal-magenta);
    box-shadow: inset 0 0 20px rgba(207, 62, 118, 0.08);
}
.bento:hover .bento-cell:not(:hover) {
    opacity: 0.85;
}

/* --- Signal Bento (Scene 1) --- */
.bento--signal {
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: repeat(4, minmax(80px, 1fr));
    min-height: 70vh;
}
.cell--a1 { grid-column: 1 / 5; grid-row: 1 / 3; }
.cell--a2 { grid-column: 5 / 8; grid-row: 1; }
.cell--a3 { grid-column: 8 / 10; grid-row: 1; }
.cell--a4 { grid-column: 10 / 13; grid-row: 1; }
.cell--hero { grid-column: 5 / 13; grid-row: 2 / 4; }
.cell--a5 { grid-column: 1 / 5; grid-row: 3; }
.cell--a6 { grid-column: 1 / 4; grid-row: 4; }
.cell--a7 { grid-column: 4 / 7; grid-row: 4; }
.cell--a8 { grid-column: 7 / 13; grid-row: 4; }

/* --- Frequency Bento (Scene 2) --- */
.bento--frequency {
    grid-template-columns: 1fr 6fr 1fr;
    min-height: 70vh;
}
.cell--ticker-left,
.cell--ticker-right {
    overflow: hidden;
    padding: 1rem 0.5rem;
}
.cell--kinetic {
    padding: clamp(2rem, 4vw, 4rem);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* --- Grid Bento (Scene 3) --- */
.bento--grid {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, minmax(100px, 1fr));
    min-height: 80vh;
}
.scan-lines-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(10, 10, 15, 0.15) 2px,
        rgba(10, 10, 15, 0.15) 4px
    );
}
.grid-cell {
    min-height: 120px;
}

/* --- Static Bento (Scene 6) --- */
.bento--static {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, minmax(80px, 1fr));
    min-height: 40vh;
}
.static-cell {
    transition: opacity 800ms ease;
}
.static-cell.faded {
    opacity: 0.15;
}
.static-cell--last {
    grid-column: 2;
    grid-row: 2;
    z-index: 2;
    background: var(--void-black);
    border: 1px solid var(--signal-magenta);
}
.static-cell--last:hover ~ .static-cell,
.static-cell--last:hover ~ .static-cell.faded {
    opacity: 1;
}

/* --- Noise Texture --- */
.noise-texture {
    position: absolute;
    inset: 0;
    filter: url(#noise);
    opacity: 0.04;
    background: var(--fog-white);
}
.noise-texture--heavy {
    opacity: 0.08;
}
.noise-texture--animated {
    opacity: 0.12;
    animation: noiseShift 2s steps(5) infinite;
}
@keyframes noiseShift {
    0% { transform: translate(0, 0); }
    20% { transform: translate(-5px, 3px); }
    40% { transform: translate(3px, -5px); }
    60% { transform: translate(-3px, 5px); }
    80% { transform: translate(5px, -3px); }
    100% { transform: translate(0, 0); }
}

/* --- Cityscape Blur --- */
.cityscape-blur {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        var(--rain-blue) 0%,
        var(--void-black) 60%,
        var(--static-gray) 80%,
        var(--void-black) 100%
    );
    filter: blur(8px);
    opacity: 0.6;
}

/* --- Rain Cell --- */
.rain-cell {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(216, 216, 232, 0.06) 0%, transparent 100%),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 8px,
            rgba(216, 216, 232, 0.04) 8px,
            rgba(216, 216, 232, 0.04) 9px
        );
    animation: rainDrift 3s linear infinite;
}
.rain-cell--dense {
    background:
        linear-gradient(180deg, rgba(216, 216, 232, 0.1) 0%, transparent 100%),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 5px,
            rgba(216, 216, 232, 0.06) 5px,
            rgba(216, 216, 232, 0.06) 6px
        );
}
@keyframes rainDrift {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100%); }
}

/* --- Neon Signs --- */
.neon-sign {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(1rem, 2vw, 1.6rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    position: relative;
    z-index: 1;
}
.neon--sm {
    font-size: clamp(0.8rem, 1.2vw, 1.1rem);
}
.neon--magenta {
    color: var(--signal-magenta);
    text-shadow: 0 0 7px var(--signal-magenta), 0 0 15px var(--signal-magenta), 0 0 30px var(--signal-magenta);
    animation: neonFlicker 4s ease-in-out infinite;
}
.neon--teal {
    color: var(--neon-teal);
    text-shadow: 0 0 7px var(--neon-teal), 0 0 15px var(--neon-teal), 0 0 30px var(--neon-teal);
    animation: neonFlicker 4s ease-in-out infinite 1.3s;
}
.neon--amber {
    color: var(--amber-warning);
    text-shadow: 0 0 7px var(--amber-warning), 0 0 15px var(--amber-warning), 0 0 30px var(--amber-warning);
    animation: neonFlicker 4s ease-in-out infinite 2.7s;
}
@keyframes neonFlicker {
    0%, 100% { opacity: 1; }
    4% { opacity: 0.7; }
    6% { opacity: 1; }
    42% { opacity: 1; }
    44% { opacity: 0.75; }
    45% { opacity: 1; }
    76% { opacity: 1; }
    77% { opacity: 0.7; }
    78% { opacity: 1; }
    79% { opacity: 0.7; }
    80% { opacity: 1; }
}

/* --- Pulse Dots --- */
.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    will-change: transform, opacity;
    animation: pulseDot 10s ease-in-out infinite;
}
.pulse-dot--magenta { background: var(--signal-magenta); box-shadow: 0 0 8px var(--signal-magenta); }
.pulse-dot--teal { background: var(--neon-teal); box-shadow: 0 0 8px var(--neon-teal); }
.pulse-dot--amber { background: var(--amber-warning); box-shadow: 0 0 8px var(--amber-warning); }
@keyframes pulseDot {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    33% { background-color: var(--signal-magenta); }
    50% { transform: scale(1.3); opacity: 1; }
    66% { background-color: var(--neon-teal); }
}

/* --- Mini Cityscape --- */
.mini-cityscape {
    position: absolute;
    inset: 0;
    overflow: hidden;
}
.building {
    position: absolute;
    bottom: 0;
    background: var(--static-gray);
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 8px,
            rgba(216, 216, 232, 0.06) 8px,
            rgba(216, 216, 232, 0.06) 10px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 12px,
            rgba(216, 216, 232, 0.04) 12px,
            rgba(216, 216, 232, 0.04) 14px
        );
}

/* --- Morse Blink --- */
.morse-blink {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--neon-teal);
    animation: morse 3s steps(1) infinite;
}
@keyframes morse {
    0% { opacity: 1; }
    10% { opacity: 0; }
    20% { opacity: 1; }
    30% { opacity: 0; }
    40% { opacity: 1; }
    60% { opacity: 1; }
    65% { opacity: 0; }
    70% { opacity: 1; }
    100% { opacity: 1; }
}

/* --- Glitch Bars --- */
.glitch-bars {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 6px,
        var(--signal-magenta) 6px,
        var(--signal-magenta) 7px
    );
    opacity: 0.12;
    animation: glitchShift 5s steps(3) infinite;
}
@keyframes glitchShift {
    0% { transform: translateX(0); }
    33% { transform: translateX(3px); }
    66% { transform: translateX(-2px); }
    100% { transform: translateX(0); }
}

/* --- Hero Title --- */
.hero-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(2rem, 6vw, 5.5rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--fog-white);
    text-align: center;
    position: relative;
    z-index: 1;
}

/* --- Frequency --- */
.frequency-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(1.4rem, 3vw, 2.8rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--fog-white);
    margin-bottom: 2rem;
}
.kinetic-text {
    overflow: hidden;
}
.kinetic-line {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    line-height: 1.75;
    color: var(--fog-white);
    overflow: hidden;
    white-space: nowrap;
    animation: kineticScroll 20s linear infinite;
}
@keyframes kineticScroll {
    0% { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

/* --- Data Stream --- */
.data-stream {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--neon-teal);
    letter-spacing: 0.02em;
    animation: streamScroll 15s linear infinite;
}
.data-stream span {
    white-space: nowrap;
    opacity: 0.7;
}
@keyframes streamScroll {
    0% { transform: translateY(0); }
    100% { transform: translateY(-50%); }
}

/* --- Grid Label --- */
.grid-label {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(1.4rem, 3vw, 2.8rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--fog-white);
    text-align: center;
}

/* --- Corridor --- */
.corridor-column {
    width: 40%;
    max-width: 480px;
    margin: 0 auto;
}
.corridor-heading {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(1.4rem, 3vw, 2.8rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--fog-white);
    margin-bottom: 2rem;
    text-align: center;
}
.corridor-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    line-height: 1.75;
    color: var(--fog-white);
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 600ms cubic-bezier(0.16, 1, 0.3, 1), transform 600ms cubic-bezier(0.16, 1, 0.3, 1);
}
.corridor-text.visible {
    opacity: 1;
    transform: translateX(0);
}
.corridor-rule {
    height: 1px;
    background: var(--static-gray);
    margin-bottom: 1.5rem;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 800ms cubic-bezier(0.16, 1, 0.3, 1);
}
.corridor-rule.visible {
    transform: scaleX(1);
}

/* --- Window --- */
.window-frame {
    width: 70%;
    max-width: 900px;
    position: relative;
}
.window-glass {
    position: relative;
    background: var(--rain-blue);
    clip-path: polygon(5% 0%, 100% 0%, 95% 100%, 0% 100%);
    min-height: 60vh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.window-city {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 300px;
}
.building-row {
    display: flex;
    align-items: flex-end;
    height: 100%;
    gap: 4px;
    justify-content: center;
}
.window-building {
    background: var(--static-gray);
    flex-shrink: 0;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 12px,
            rgba(216, 216, 232, 0.08) 12px,
            rgba(216, 216, 232, 0.08) 16px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 16px,
            rgba(216, 216, 232, 0.05) 16px,
            rgba(216, 216, 232, 0.05) 20px
        );
}
.window-rain-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        rgba(26, 42, 63, 0.3) 0%,
        rgba(26, 42, 63, 0.7) 100%
    );
    pointer-events: none;
}
.condensation-text {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 2rem;
}
.condensation-line {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: rgba(216, 216, 232, 0.6);
    line-height: 2;
    opacity: 0;
    filter: blur(3px);
    transform: translateY(2px);
    transition: opacity 400ms ease, filter 400ms ease, transform 400ms ease;
}
.condensation-line.visible {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
}

/* --- Final Name --- */
.final-name {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(1rem, 2vw, 1.6rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--fog-white);
    position: relative;
    z-index: 1;
}

/* --- Reveal Animation --- */
[data-reveal] {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 500ms cubic-bezier(0.16, 1, 0.3, 1), transform 500ms cubic-bezier(0.16, 1, 0.3, 1);
}
[data-reveal].visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Decode Character Spans --- */
.decode-char {
    display: inline-block;
    min-width: 0.1em;
}

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 1200px) {
    .bento--signal {
        grid-template-columns: repeat(6, 1fr);
        grid-template-rows: repeat(5, minmax(60px, 1fr));
    }
    .cell--a1 { grid-column: 1 / 4; grid-row: 1 / 3; }
    .cell--a2 { grid-column: 4 / 7; grid-row: 1; }
    .cell--a3 { grid-column: 4 / 5; grid-row: 2; }
    .cell--a4 { grid-column: 5 / 7; grid-row: 2; }
    .cell--hero { grid-column: 1 / 7; grid-row: 3 / 5; }
    .cell--a5 { grid-column: 1 / 3; grid-row: 5; }
    .cell--a6 { grid-column: 3 / 5; grid-row: 5; }
    .cell--a7 { grid-column: 5 / 6; grid-row: 5; }
    .cell--a8 { grid-column: 6 / 7; grid-row: 5; }

    .bento--grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .section-nav { display: none; }

    .bento--signal {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
    .cell--a1, .cell--a2, .cell--a3, .cell--a4,
    .cell--hero, .cell--a5, .cell--a6, .cell--a7, .cell--a8 {
        grid-column: 1;
        grid-row: auto;
        min-height: 80px;
    }
    .cell--hero { min-height: 200px; }

    .bento--frequency {
        grid-template-columns: 1fr;
    }
    .cell--ticker-left,
    .cell--ticker-right {
        min-height: 60px;
    }
    .cell--kinetic {
        min-height: 200px;
    }

    .bento--grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .bento--static {
        grid-template-columns: repeat(3, 1fr);
    }

    .corridor-column {
        width: 90%;
    }

    .window-frame {
        width: 95%;
    }
    .window-glass {
        clip-path: none;
    }
}

@media (max-width: 480px) {
    .bento--grid {
        grid-template-columns: 1fr;
    }
}
