/* =============================================
   a6c.boo — Alphabet Primer meets Haunted Toybox
   Memphis Design x Phantasmagoria
   ============================================= */

/* --- CSS Custom Properties --- */
:root {
    --stage: #0b0b14;
    --spotlight: #1a1a2e;
    --red: #e63946;
    --amber: #f4a261;
    --teal: #2a9d8f;
    --golden: #e9c46a;
    --violet: #7b2d8e;
    --ice: #48bfe3;
    --bone: #f0ede6;
    --void: #0b0b14;
    --shadow: #050509;

    --red-dark: #b22d37;
    --amber-dark: #c47f4a;
    --teal-dark: #1f7a6f;
    --golden-dark: #b89b50;
    --violet-dark: #5e2069;
    --ice-dark: #358dae;

    --font-display: 'Bungee Shade', cursive;
    --font-headline: 'Fredoka', sans-serif;
    --font-body: 'Nunito', sans-serif;
    --font-mono: 'Fira Code', monospace;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: var(--stage);
    color: var(--bone);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.75;
    overflow-x: hidden;
    position: relative;
}

/* --- SVG Noise Filter (hidden) --- */
.noise-svg {
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* --- Noise Overlay --- */
.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    filter: url(#noiseFilter);
    opacity: 0.03;
    pointer-events: none;
    z-index: 1000;
}

/* --- Spotlight --- */
.spotlight {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse 60% 50% at 50% 50%, var(--spotlight) 0%, transparent 70%);
    pointer-events: none;
    z-index: 1;
    transition: background-position 0.3s ease;
}

/* --- Dotted Grid Background --- */
.grid-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle, var(--spotlight) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.3;
    pointer-events: none;
    z-index: 0;
}

/* --- Alphabet Navigation Rail --- */
.alpha-rail {
    position: fixed;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 100;
}

.alpha-rail span {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--bone);
    opacity: 0.25;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-align: center;
    width: 24px;
    height: 18px;
    line-height: 18px;
    user-select: none;
}

.alpha-rail span:hover {
    opacity: 1;
    font-size: 28px;
    color: var(--ice);
    text-shadow: 0 0 12px rgba(72, 191, 227, 0.6);
    transform: scale(1.3);
}

/* --- Blinking Eyes --- */
.eyes-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.eye-pair {
    position: absolute;
    display: flex;
    gap: 8px;
    opacity: 0.5;
}

.eye {
    width: 8px;
    height: 8px;
    background: var(--bone);
    border-radius: 50%;
    position: relative;
    animation: blink var(--blink-dur, 5s) infinite;
    animation-delay: var(--blink-delay, 0s);
}

.eye::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 3px;
    height: 3px;
    background: var(--stage);
    border-radius: 50%;
}

.eye-pair:nth-child(1) { --blink-dur: 4.5s; --blink-delay: 1s; }
.eye-pair:nth-child(2) { --blink-dur: 6s; --blink-delay: 2.5s; }
.eye-pair:nth-child(3) { --blink-dur: 5.5s; --blink-delay: 0.5s; }
.eye-pair:nth-child(4) { --blink-dur: 7s; --blink-delay: 3s; }
.eye-pair:nth-child(5) { --blink-dur: 4s; --blink-delay: 1.8s; }

@keyframes blink {
    0%, 90%, 100% { transform: scaleY(1); }
    95% { transform: scaleY(0.1); }
}

/* --- Overture Section --- */
.overture {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 10;
}

.wordmark {
    display: flex;
    gap: 0.05em;
    font-family: var(--font-display);
    font-size: clamp(3rem, 12vw, 8rem);
}

.wm-letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(-120vh);
    animation: letterFall 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.wm-letter:nth-child(1) { animation-delay: 0.6s; }
.wm-letter:nth-child(2) { animation-delay: 0.75s; }
.wm-letter:nth-child(3) { animation-delay: 0.9s; }
.wm-letter:nth-child(4) { animation-delay: 1.05s; }
.wm-letter:nth-child(5) { animation-delay: 1.2s; }
.wm-letter:nth-child(6) { animation-delay: 1.35s; }
.wm-letter:nth-child(7) { animation-delay: 1.5s; }

@keyframes letterFall {
    0% { opacity: 0; transform: translateY(-120vh); }
    60% { opacity: 1; transform: translateY(10px); }
    80% { transform: translateY(-5px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Letter colors */
[data-color="red"] { color: var(--red); }
[data-color="amber"] { color: var(--amber); }
[data-color="teal"] { color: var(--teal); }
[data-color="golden"] { color: var(--golden); }
[data-color="violet"] { color: var(--violet); }
[data-color="ice"] { color: var(--ice); }

.overture-subtitle {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 14px;
    color: var(--bone);
    opacity: 0;
    margin-top: 2rem;
    animation: fadeIn 1s ease forwards;
    animation-delay: 2.5s;
}

@keyframes fadeIn {
    to { opacity: 0.6; }
}

/* --- Act Sections (shared) --- */
.act {
    min-height: 150vh;
    padding: 10vh 5vw;
    position: relative;
    z-index: 10;
}

.act-letter-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
    position: relative;
}

.act-letter {
    font-family: var(--font-display);
    font-size: clamp(20rem, 40vw, 50rem);
    line-height: 1;
    opacity: 0;
    transform: translateY(100px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.act-letter.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Act-specific colors for act letters */
.act-a .act-letter { color: var(--red); text-shadow: 8px 8px 0 var(--shadow); }
.act-b .act-letter { color: var(--amber); text-shadow: 8px 8px 0 var(--shadow); }
.act-c .act-letter { color: var(--teal); text-shadow: 8px 8px 0 var(--shadow); }
.act-d .act-letter { color: var(--golden); text-shadow: 8px 8px 0 var(--shadow); }
.act-e .act-letter { color: var(--violet); text-shadow: 8px 8px 0 var(--shadow); }
.act-f .act-letter { color: var(--ice); text-shadow: 8px 8px 0 var(--shadow); }

/* --- Shadow Puppets --- */
.shadow-puppet {
    position: absolute;
    width: 200px;
    height: 200px;
    color: rgba(11, 11, 20, 0.8);
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.shadow-puppet.visible {
    opacity: 1;
    animation: puppetSlide 4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.sp-a { top: 20%; left: -200px; }
.sp-b { top: 30%; right: -200px; }
.sp-c { top: 15%; left: -200px; }
.sp-d { top: 25%; right: -200px; }
.sp-e { top: 20%; left: -200px; }
.sp-f { top: 30%; right: -200px; }

@keyframes puppetSlide {
    0% { transform: translateX(0); }
    50% { transform: translateX(calc(100vw + 400px)); }
    100% { transform: translateX(calc(100vw + 400px)); opacity: 0; }
}

.sp-b, .sp-d, .sp-f {
    animation-name: puppetSlideReverse;
}

@keyframes puppetSlideReverse {
    0% { transform: translateX(0); }
    50% { transform: translateX(calc(-100vw - 400px)); }
    100% { transform: translateX(calc(-100vw - 400px)); opacity: 0; }
}

/* --- Blocks Grid --- */
.blocks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* --- Block Styling --- */
.block {
    padding: 2.5rem;
    border-radius: 12px;
    position: relative;
    transform: rotate(var(--rot, 0deg));
    opacity: 0;
    transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
    filter: drop-shadow(8px 8px 0px var(--shadow));
}

.block.visible {
    opacity: 1;
}

.block:hover {
    transform: rotate(var(--rot, 0deg)) scale(1.03);
    z-index: 20;
}

/* 3D bevel effect for blocks */
.block::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    box-shadow: inset 2px 2px 4px rgba(255, 255, 255, 0.15);
    pointer-events: none;
}

/* Act A blocks - Haunted Red */
.block[data-act="a"] {
    background-color: var(--red);
    color: var(--void);
    border-bottom: 4px solid var(--red-dark);
    border-right: 4px solid var(--red-dark);
    box-shadow: 0 0 40px rgba(230, 57, 70, 0.15);
}

/* Act B blocks - Amber Phantom */
.block[data-act="b"] {
    background-color: var(--amber);
    color: var(--void);
    border-bottom: 4px solid var(--amber-dark);
    border-right: 4px solid var(--amber-dark);
    box-shadow: 0 0 40px rgba(244, 162, 97, 0.15);
}

/* Act C blocks - Spectral Teal */
.block[data-act="c"] {
    background-color: var(--teal);
    color: var(--void);
    border-bottom: 4px solid var(--teal-dark);
    border-right: 4px solid var(--teal-dark);
    box-shadow: 0 0 40px rgba(42, 157, 143, 0.15);
}

/* Act D blocks - Golden Poltergeist */
.block[data-act="d"] {
    background-color: var(--golden);
    color: var(--void);
    border-bottom: 4px solid var(--golden-dark);
    border-right: 4px solid var(--golden-dark);
    box-shadow: 0 0 40px rgba(233, 196, 106, 0.15);
}

/* Act E blocks - Violet Wraith */
.block[data-act="e"] {
    background-color: var(--violet);
    color: var(--bone);
    border-bottom: 4px solid var(--violet-dark);
    border-right: 4px solid var(--violet-dark);
    box-shadow: 0 0 40px rgba(123, 45, 142, 0.15);
}

/* Act F blocks - Ice Specter */
.block[data-act="f"] {
    background-color: var(--ice);
    color: var(--void);
    border-bottom: 4px solid var(--ice-dark);
    border-right: 4px solid var(--ice-dark);
    box-shadow: 0 0 40px rgba(72, 191, 227, 0.15);
}

.block-headline {
    font-family: var(--font-headline);
    font-weight: 600;
    font-size: clamp(1.8rem, 4vw, 3rem);
    letter-spacing: 0.04em;
    margin-bottom: 1rem;
}

.block-body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 17px;
    line-height: 1.75;
}

.block-icon {
    font-family: var(--font-display);
    font-size: clamp(6rem, 15vw, 12rem);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.3;
}

/* --- Ghost Trace Effect --- */
.block.ghost-trace::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    background: inherit;
    opacity: 0.3;
    animation: ghostFade 0.8s ease forwards;
    pointer-events: none;
    z-index: -1;
}

@keyframes ghostFade {
    0% { transform: translate(-5px, -5px); opacity: 0.3; }
    100% { transform: translate(-15px, -15px); opacity: 0; }
}

/* --- Overprint (mix-blend-mode at overlaps) --- */
.block.overprint {
    mix-blend-mode: multiply;
}

.block.overprint::after {
    content: '';
    position: absolute;
    inset: -1px;
    border: 1px dashed var(--bone);
    border-radius: 12px;
    pointer-events: none;
    opacity: 0.3;
}

/* --- BOO Reveal in Act F --- */
.block-boo {
    display: flex;
    align-items: center;
    justify-content: center;
    grid-column: 1 / -1;
}

.boo-text {
    font-family: var(--font-display);
    font-size: clamp(6rem, 20vw, 16rem);
    color: var(--ice);
    text-shadow:
        0 0 40px rgba(72, 191, 227, 0.4),
        0 0 80px rgba(72, 191, 227, 0.2);
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 1s ease, transform 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.block-boo.visible .boo-text {
    opacity: 1;
    transform: scale(1);
}

/* --- Curtain Call --- */
.curtain-call {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 10;
}

.final-wordmark {
    display: flex;
    gap: 0.05em;
    font-family: var(--font-display);
    font-size: clamp(3rem, 12vw, 8rem);
}

.fw-letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(60px) rotate(10deg);
    transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fw-letter.visible {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
}

.fw-letter:nth-child(1) { transition-delay: 0s; }
.fw-letter:nth-child(2) { transition-delay: 0.1s; }
.fw-letter:nth-child(3) { transition-delay: 0.2s; }
.fw-letter:nth-child(4) { transition-delay: 0.3s; }
.fw-letter:nth-child(5) { transition-delay: 0.4s; }
.fw-letter:nth-child(6) { transition-delay: 0.5s; }
.fw-letter:nth-child(7) { transition-delay: 0.6s; }

.curtain-text {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 14px;
    color: var(--bone);
    opacity: 0;
    margin-top: 2rem;
    transition: opacity 1s ease;
    transition-delay: 1s;
}

.curtain-call.visible .curtain-text {
    opacity: 0.6;
}

/* --- Confetti Effect --- */
.confetti {
    position: absolute;
    width: 8px;
    height: 8px;
    pointer-events: none;
    z-index: 50;
    animation: confettiBurst 1.2s ease-out forwards;
}

.confetti.circle { border-radius: 50%; }
.confetti.triangle {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 10px solid var(--confetti-color, var(--red));
    background: transparent;
}
.confetti.square { border-radius: 2px; }

@keyframes confettiBurst {
    0% {
        opacity: 1;
        transform: translate(0, 0) rotate(0deg) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--tx, 50px), var(--ty, -80px)) rotate(var(--tr, 360deg)) scale(0.3);
    }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .alpha-rail {
        display: none;
    }

    .act-letter {
        font-size: clamp(8rem, 30vw, 20rem);
    }

    .blocks-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 1rem;
    }

    .block {
        padding: 1.5rem;
    }

    .wordmark,
    .final-wordmark {
        font-size: clamp(2rem, 10vw, 5rem);
    }
}

@media (max-width: 480px) {
    .act {
        padding: 5vh 3vw;
    }

    .block-headline {
        font-size: 1.5rem;
    }

    .block-body {
        font-size: 15px;
    }
}
