/* ============================================
   a6c.xyz — Light-Academia + Neon-Electric
   Full-screen parallax narrative experience
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Palette (exact DESIGN.md hex values) */
    --electric-cyan: #00F5D4;
    --hot-magenta: #F72585;
    --violet-pulse: #7209B7;
    --aged-leather: #3C2415;
    --parchment-cream: #F5F0E8;
    --obsidian-night: #0D0A14;
    --warm-ivory: #EDE8DB;
    --deep-umber: #2C1810;

    /* Typography */
    --font-display: 'Zilla Slab', serif;
    --font-body: 'Lora', serif;
    --font-accent: 'IBM Plex Mono', monospace;

    /* Spacing */
    --section-padding: clamp(24px, 5vw, 80px);
    --text-max-width: 640px;
}

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

html {
    scroll-behavior: auto;
}

body {
    background: var(--obsidian-night);
    color: var(--warm-ivory);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.7;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Scroll Container --- */
#scroll-container {
    height: 100vh;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
}

/* --- Panel Base --- */
.panel {
    position: relative;
    width: 100%;
    height: 100vh;
    scroll-snap-align: start;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-hero {
    background: var(--obsidian-night);
}

.panel-dark {
    background: var(--obsidian-night);
}

.panel-light {
    background: var(--parchment-cream);
}

.panel-terminal {
    background: var(--obsidian-night);
}

/* --- Parallax Layers --- */
.parallax-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: transform;
}

.parallax-bg {
    z-index: 1;
}

.parallax-mid {
    z-index: 2;
}

.parallax-fg {
    z-index: 3;
    pointer-events: none;
}

.parallax-fg .text-block,
.parallax-fg .section-label,
.parallax-fg .terminal-text {
    pointer-events: auto;
}

/* --- Section Fade In/Out --- */
.panel {
    opacity: 0;
    transition: opacity 0.6s ease;
}

.panel.in-view {
    opacity: 1;
}

/* Hero always visible on load */
.panel-hero {
    opacity: 1;
}

/* --- Hero Section --- */
.leather-bg-hero {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--aged-leather);
    filter: url(#leather-noise);
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.4);
    opacity: 0.35;
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(3rem, 10vw, 8rem);
    letter-spacing: -0.02em;
    color: var(--warm-ivory);
    text-align: center;
    position: relative;
    z-index: 5;
    user-select: none;
}

.hero-title .letter {
    display: inline-block;
    opacity: 0;
}

.hero-title .letter.revealed {
    opacity: 1;
    animation: neonFlash 0.3s ease-out forwards;
}

.hero-title .letter.dot {
    width: 0.25em;
}

@keyframes neonFlash {
    0% {
        text-shadow: 0 0 20px var(--electric-cyan), 0 0 40px var(--electric-cyan), 0 0 60px rgba(0, 245, 212, 0.3);
        color: var(--electric-cyan);
    }
    50% {
        text-shadow: 0 0 10px rgba(0, 245, 212, 0.4);
        color: var(--warm-ivory);
    }
    100% {
        text-shadow: none;
        color: var(--warm-ivory);
    }
}

/* --- Crystal Wireframes --- */
.crystal {
    position: absolute;
}

.crystal-svg {
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

.crystal-icosahedron {
    width: clamp(250px, 40vw, 500px);
    height: clamp(250px, 40vw, 500px);
    animation: crystalRotate 30s linear infinite;
}

.crystal-octahedron {
    width: clamp(180px, 25vw, 350px);
    height: clamp(220px, 30vw, 420px);
    animation: crystalRotate 30s linear infinite;
}

.crystal-hexprism {
    width: clamp(180px, 25vw, 350px);
    height: clamp(240px, 32vw, 450px);
    animation: crystalRotateReverse 30s linear infinite;
}

@keyframes crystalRotate {
    from { transform: rotateY(0deg); }
    to { transform: rotateY(360deg); }
}

@keyframes crystalRotateReverse {
    from { transform: rotateY(360deg); }
    to { transform: rotateY(0deg); }
}

/* Crystal edge assembly animation (stroke-dashoffset draw-in) */
.crystal-edges line,
.crystal-edges polygon {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 1.2s ease-out, fill-opacity 0.4s ease;
}

.crystal.assembled .crystal-edges line,
.crystal.assembled .crystal-edges polygon {
    stroke-dashoffset: 0;
}

/* Crystal hover/proximity resonance */
.crystal.resonating {
    animation-duration: 10s !important;
}

.crystal.resonating .crystal-edges polygon {
    fill-opacity: 0.15 !important;
}

/* --- Decoration Positioning --- */
.decoration-right {
    right: 8%;
    left: auto;
    top: 50%;
    transform: translateY(-50%);
}

.decoration-left {
    left: 8%;
    right: auto;
    top: 50%;
    transform: translateY(-50%);
    position: absolute;
}

/* --- Leather Panels --- */
.leather-panel {
    background: var(--aged-leather);
    filter: url(#leather-noise);
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.4);
    transition: box-shadow 0.4s ease;
}

.leather-panel:hover {
    box-shadow:
        inset 0 0 60px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(0, 245, 212, 0.2),
        0 0 40px rgba(0, 245, 212, 0.08);
}

.leather-book {
    width: clamp(180px, 22vw, 320px);
    height: clamp(240px, 30vw, 430px);
    border-radius: 4px;
    position: absolute;
}

/* --- Neon Glow Halos --- */
.neon-glow-halo {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.halo-1 {
    width: 600px;
    height: 600px;
    right: 5%;
    top: 50%;
    transform: translateY(-50%);
    background: radial-gradient(
        circle,
        rgba(114, 9, 183, 0.15) 0%,
        rgba(114, 9, 183, 0.05) 40%,
        transparent 70%
    );
    animation: haloPulse 6s ease-in-out infinite alternate;
}

@keyframes haloPulse {
    0% { opacity: 0.7; transform: translateY(-50%) scale(1); }
    100% { opacity: 1; transform: translateY(-50%) scale(1.05); }
}

/* --- Neon Lattice (Dark sections) --- */
.neon-lattice {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        linear-gradient(
            rgba(114, 9, 183, 0.0) 0%,
            rgba(114, 9, 183, 0.03) 50%,
            rgba(114, 9, 183, 0.0) 100%
        );
    overflow: hidden;
}

.neon-lattice::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 79px,
            rgba(114, 9, 183, 0.15) 79px,
            rgba(114, 9, 183, 0.15) 80px
        ),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 79px,
            rgba(114, 9, 183, 0.12) 79px,
            rgba(114, 9, 183, 0.12) 80px
        );
    animation: latticePulse 4s ease-in-out infinite alternate;
    transform: perspective(800px) rotateX(25deg) scale(1.4);
    transform-origin: center center;
}

/* Neon lattice on light sections */
.neon-lattice-light {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.neon-lattice-light::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 99px,
            rgba(114, 9, 183, 0.08) 99px,
            rgba(114, 9, 183, 0.08) 100px
        ),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 99px,
            rgba(114, 9, 183, 0.06) 99px,
            rgba(114, 9, 183, 0.06) 100px
        );
    transform: perspective(900px) rotateX(20deg) scale(1.3);
    transform-origin: center center;
}

@keyframes latticePulse {
    0% { opacity: 0.3; }
    100% { opacity: 0.5; }
}

/* --- Parchment Grain Background --- */
.parchment-grain {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--parchment-cream);
    opacity: 0.5;
}

.parchment-grain::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    filter: url(#leather-noise);
    opacity: 0.04;
    background: var(--aged-leather);
}

/* --- Section Labels --- */
.section-label {
    position: absolute;
    top: var(--section-padding);
    left: var(--section-padding);
    z-index: 10;
}

.section-number {
    font-family: var(--font-accent);
    font-weight: 400;
    font-size: 12px;
    line-height: 1.5;
    color: var(--hot-magenta);
    display: inline-block;
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.section-number::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 1px;
    background: var(--hot-magenta);
    vertical-align: middle;
    margin-left: 8px;
    transition: width 0.6s ease 0.2s;
}

.section-number.visible {
    opacity: 1;
    transform: translateX(0);
}

.section-number.visible::after {
    width: 40px;
}

.section-number-dark {
    color: var(--violet-pulse);
}

.section-number-dark::after {
    background: var(--violet-pulse);
}

/* --- Text Blocks --- */
.text-block {
    max-width: var(--text-max-width);
    padding: var(--section-padding);
    position: relative;
    z-index: 5;
}

.text-left {
    position: absolute;
    left: 5%;
    top: 50%;
    transform: translateY(-50%);
}

.text-right {
    position: absolute;
    right: 5%;
    top: 50%;
    transform: translateY(-50%);
    text-align: right;
}

.section-headline {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2rem, 5vw, 3.5rem);
    letter-spacing: -0.02em;
    color: var(--warm-ivory);
    margin-bottom: 1em;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.headline-dark {
    color: var(--deep-umber);
}

.section-body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 16px;
    line-height: 1.7;
    color: var(--warm-ivory);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease 0.1s, transform 0.6s ease 0.1s;
}

.body-dark {
    color: var(--deep-umber);
}

/* Text block reveal animation */
.text-block.visible .section-headline {
    opacity: 1;
    transform: translateY(0);
}

.text-block.visible .section-body {
    opacity: 1;
    transform: translateY(0);
}

/* --- Section Dividers --- */
.section-divider {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--electric-cyan) 50%,
        transparent 100%
    );
    z-index: 10;
    clip-path: inset(0 50% 0 50%);
    transition: clip-path 0.8s ease;
}

.section-divider-dark {
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--violet-pulse) 50%,
        transparent 100%
    );
}

.panel.in-view .section-divider {
    clip-path: inset(0 0 0 0);
}

/* --- Terminal Section --- */
.terminal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.terminal-text {
    font-family: var(--font-body);
    font-weight: 600;
    font-style: italic;
    font-size: clamp(1.1rem, 3vw, 1.8rem);
    color: var(--warm-ivory);
    text-align: center;
    max-width: 600px;
    padding: 0 var(--section-padding);
    margin-bottom: 2rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.panel-terminal.in-view .terminal-text {
    opacity: 1;
    transform: translateY(0);
}

.terminal-line {
    width: 0;
    height: 1px;
    background: var(--electric-cyan);
    box-shadow: 0 0 8px var(--electric-cyan), 0 0 20px rgba(0, 245, 212, 0.3);
    transition: width 1.2s ease 0.4s;
}

.panel-terminal.in-view .terminal-line {
    width: 90vw;
}

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    .text-left,
    .text-right {
        left: 5%;
        right: 5%;
        text-align: left;
        max-width: calc(100% - 10%);
    }

    .decoration-right,
    .decoration-left {
        opacity: 0.3;
        right: 5%;
        left: auto;
    }

    .leather-book {
        width: 140px;
        height: 190px;
    }

    .crystal-icosahedron {
        width: 200px;
        height: 200px;
    }

    .crystal-octahedron,
    .crystal-hexprism {
        width: 150px;
        height: 200px;
    }

    .neon-glow-halo {
        width: 300px;
        height: 300px;
    }
}

@media (max-width: 480px) {
    .section-headline {
        font-size: clamp(1.6rem, 8vw, 2.5rem);
    }

    .hero-title {
        font-size: clamp(2.5rem, 14vw, 5rem);
    }

    .terminal-text {
        font-size: clamp(1rem, 4vw, 1.4rem);
    }
}
