/* === RESET & BASE === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-void: #06060f;
    --surface: rgba(12, 18, 42, 0.55);
    --surface-light: rgba(12, 18, 42, 0.45);
    --neon-cyan: #00f0ff;
    --neon-magenta: #ff2d8a;
    --neon-green: #00ff9d;
    --text-primary: #e8eaf0;
    --text-secondary: #8a8cb0;
    --amber: #ffaa00;
    --glass-border: rgba(0, 240, 255, 0.12);
    --glass-border-hover: rgba(0, 240, 255, 0.25);
    --ease-luxe: cubic-bezier(0.16, 1, 0.3, 1);
    --scroll: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg-void);
    color: var(--text-primary);
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 16px;
    line-height: 1.75;
    letter-spacing: 0.02em;
    overflow-x: hidden;
}

/* === GENERATIVE CANVAS === */
#generative-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

/* === SECTIONS === */
.section {
    position: relative;
    min-height: 100vh;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8rem 2rem;
}

/* === CHAPTER NUMBERS (Watermark) === */
.chapter-number {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(6rem, 15vw, 14rem);
    color: rgba(0, 240, 255, 0.06);
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1.2s ease;
}

.chapter-number.visible {
    opacity: 1;
}

/* === ATRIUM (Hero) === */
#atrium {
    justify-content: center;
    gap: 3rem;
}

.atrium-content {
    text-align: center;
    z-index: 20;
}

.hero-title {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(4rem, 12vw, 9rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-primary);
    text-shadow: 0 0 40px rgba(0, 240, 255, 0.3), 0 0 80px rgba(0, 240, 255, 0.1);
    line-height: 1;
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 1.2s var(--ease-luxe) 0.2s forwards;
}

.hero-subtitle {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    margin-top: 1.5rem;
    opacity: 0;
    animation: fadeInUp 1.2s var(--ease-luxe) 0.5s forwards;
}

/* === GLASSMORPHIC CARDS === */
.glass-card {
    position: relative;
    background: var(--surface-light);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 2.5rem 3rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
    transition: all 0.5s var(--ease-luxe);
    opacity: 0;
    transform: translateY(40px);
}

.glass-card.in-view {
    opacity: 1;
    transform: translateY(0);
}

.glass-card:hover {
    border-color: var(--glass-border-hover);
    transform: scale(1.03);
    backdrop-filter: blur(8px) saturate(160%);
    -webkit-backdrop-filter: blur(8px) saturate(160%);
}

.glass-card.sibling-hover {
    transform: scale(0.97);
    opacity: 0.6;
    backdrop-filter: blur(28px) saturate(160%);
    -webkit-backdrop-filter: blur(28px) saturate(160%);
}

/* Card ribbon */
.card-ribbon {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--neon-cyan), var(--neon-magenta));
    border-radius: 12px 12px 0 0;
}

/* Page corner fold */
.glass-card--fold::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, transparent 50%, rgba(0, 240, 255, 0.08) 50%);
    border-radius: 0 12px 0 0;
}

/* Hero card */
.glass-card--hero {
    max-width: 40vw;
    min-width: 320px;
    transform: rotate(-2deg) translateY(40px);
    z-index: 20;
    opacity: 0;
    animation: fadeInCard 1.2s var(--ease-luxe) 0.8s forwards;
}

@keyframes fadeInCard {
    to {
        opacity: 1;
        transform: rotate(-2deg) translateY(0);
    }
}

/* === TYPOGRAPHY === */
.section-heading {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--neon-cyan);
    text-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

.body-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 1rem;
    line-height: 1.75;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}

.epigraph {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    line-height: 1.6;
    letter-spacing: 0.01em;
    color: var(--text-primary);
}

.margin-note {
    position: absolute;
    right: -3rem;
    top: 50%;
    transform: rotate(90deg) translateX(-50%);
    transform-origin: right center;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    pointer-events: none;
}

/* === READING ROOM === */
.reading-room {
    padding: 8rem 2rem;
}

.reading-panels {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    grid-auto-rows: minmax(180px, auto);
    gap: 2rem;
    width: 100%;
    max-width: 1400px;
    z-index: 10;
}

.glass-card--bg {
    z-index: 10;
}

.glass-card--fg {
    z-index: 20;
}

/* Parallax via CSS custom property */
.glass-card[data-depth="bg"] {
    transform: translateY(calc(var(--scroll) * -0.03px));
}

.glass-card[data-depth="fg"] {
    transform: translateY(calc(var(--scroll) * -0.08px));
}

.glass-card[data-depth="bg"].in-view,
.glass-card[data-depth="fg"].in-view {
    /* Keep parallax but remove initial translateY(40px) */
}

/* === SECTION DIVIDERS === */
.section-divider {
    position: relative;
    z-index: 10;
    padding: 0 4rem;
    height: 2px;
}

.section-divider svg {
    width: 100%;
    height: 8px;
    overflow: visible;
}

.divider-line {
    stroke: var(--neon-cyan);
    stroke-width: 1;
    opacity: 0.3;
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: stroke-dashoffset 1.5s ease;
}

.section-divider.in-view .divider-line {
    stroke-dashoffset: 0;
}

/* === ARCHIVE STACK === */
#archive-stack {
    gap: 0;
    padding: 8rem 0;
}

.archive-bars {
    width: 100%;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
    gap: 4vh;
    z-index: 10;
    padding: 0 2rem;
}

.archive-bar {
    width: 100%;
    height: 12vh;
    min-height: 100px;
    background: var(--surface-light);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1.5rem 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: all 0.5s var(--ease-luxe);
    opacity: 0;
    transform: translateY(20px);
}

.archive-bar.in-view {
    opacity: 1;
    transform: translateY(0);
}

.archive-bar:hover {
    transform: scale(1.05);
    border-color: var(--glass-border-hover);
    backdrop-filter: blur(8px) saturate(160%);
    -webkit-backdrop-filter: blur(8px) saturate(160%);
    z-index: 20;
}

.archive-bar:hover ~ .archive-bar,
.archive-bars:has(.archive-bar:hover) .archive-bar:not(:hover) {
    opacity: 0.5;
    transform: scale(0.97);
}

.archive-title {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: clamp(1rem, 2vw, 1.5rem);
    letter-spacing: 0.06em;
    color: var(--neon-cyan);
    text-shadow: 0 0 15px rgba(0, 240, 255, 0.3);
}

.archive-desc {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.3rem;
    line-height: 1.5;
}

/* === CODEX === */
#codex {
    position: relative;
    overflow: hidden;
}

#voronoi-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.codex-ribbon {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.codex-domain {
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    text-transform: lowercase;
}

/* === ANIMATIONS === */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .reading-panels {
        grid-template-columns: 1fr;
    }

    .reading-panels .glass-card {
        grid-column: 1 / -1 !important;
        grid-row: auto !important;
    }

    .glass-card--hero {
        max-width: 90vw;
        min-width: unset;
    }

    .margin-note {
        position: static;
        transform: none;
        display: block;
        margin-top: 1rem;
    }

    .archive-bar {
        height: auto;
        min-height: 80px;
    }
}
