/* ========================================
   muhan.ai — Scandinavian Art Deco
   ======================================== */

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

:root {
    --birch: #F5F0E8;
    --midnight: #1A1A2E;
    --gold: #C8A96E;
    --gold-light: #C8A96E33;
    --stone: #B8B0A4;
    --cyan: #5CE0D8;
}

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

body {
    background: var(--birch);
    color: var(--midnight);
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

/* Grain Overlay */
.grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    will-change: transform;
}

/* Typography */
.annotation {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* ========================================
   Chamber Base
   ======================================== */
.chamber {
    position: relative;
    width: 100%;
    overflow: hidden;
}

/* ========================================
   Chamber 1: The Threshold
   ======================================== */
.chamber-threshold {
    min-height: 100vh;
    background: var(--birch);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chamber-content {
    text-align: center;
}

.threshold-title {
    font-family: 'Poiret One', cursive;
    font-size: clamp(4rem, 22vw, 14rem);
    font-weight: 400;
    letter-spacing: 0.02em;
    color: var(--midnight);
    line-height: 1;
}

.threshold-title .char-mu,
.threshold-title .char-han {
    display: inline-block;
    transition: transform 1.5s ease-out, opacity 1.5s ease-out;
    will-change: transform, opacity;
}

.threshold-title.drifting .char-mu {
    transform: translateY(-80px);
    opacity: 0;
}

.threshold-title.drifting .char-han {
    transform: translateY(-50px);
    opacity: 0;
}

.threshold-subtitle {
    font-family: 'Josefin Sans', sans-serif;
    font-size: 2rem;
    font-weight: 400;
    letter-spacing: 0.5em;
    color: var(--stone);
    margin-top: 1.5rem;
}

/* ========================================
   Chamber 2: The Gallery
   ======================================== */
.chamber-gallery {
    min-height: 300vh;
}

.gallery-panel {
    min-height: 100vh;
    background: var(--birch);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 4rem 2rem;
}

.gallery-panel-dark {
    background: var(--midnight);
}

.deco-svg {
    width: min(80vw, 500px);
    height: auto;
    display: block;
    margin: 0 auto;
}

.svg-draw {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 1.2s ease-out;
}

.svg-draw.drawn {
    stroke-dashoffset: 0;
}

.svg-draw-rect {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: stroke-dashoffset 1.4s ease-out;
}

.svg-draw-rect.drawn {
    stroke-dashoffset: 0;
}

.gallery-text {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    color: var(--midnight);
    max-width: 800px;
    margin-top: 3rem;
    text-align: left;
    padding-left: 2rem;
    align-self: flex-start;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.gallery-text.visible {
    opacity: 1;
    transform: translateY(0);
}

.gallery-text-dark {
    color: var(--gold);
}

/* ========================================
   Chamber 3: The Aperture
   ======================================== */
.chamber-aperture {
    min-height: 150vh;
    background: var(--midnight);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.aperture-content {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 800px;
    padding: 2rem;
}

.aperture-heading {
    font-family: 'Poiret One', cursive;
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--gold);
    letter-spacing: 0.08em;
    margin-bottom: 1rem;
}

.glitch-text {
    position: relative;
    display: inline-block;
}

.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
}

.glitch-text::before {
    color: var(--cyan);
    animation: glitchShift1 3s steps(1) infinite;
    clip-path: inset(0 0 60% 0);
}

.glitch-text::after {
    color: var(--gold);
    animation: glitchShift2 2.5s steps(1) infinite;
    clip-path: inset(60% 0 0 0);
}

@keyframes glitchShift1 {
    0%, 90% { transform: translate(0); }
    92% { transform: translate(3px, -2px); }
    94% { transform: translate(-2px, 1px); }
    96% { transform: translate(2px, 3px); }
    98% { transform: translate(-3px, -1px); }
    100% { transform: translate(0); }
}

@keyframes glitchShift2 {
    0%, 85% { transform: translate(0); }
    87% { transform: translate(-3px, 2px); }
    89% { transform: translate(2px, -3px); }
    91% { transform: translate(4px, 1px); }
    93% { transform: translate(-2px, -2px); }
    100% { transform: translate(0); }
}

.aperture-subtext {
    color: var(--cyan);
    margin-bottom: 2rem;
}

.aperture-body {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    color: var(--gold);
    line-height: 2;
}

.glitch-word {
    position: relative;
    display: inline-block;
}

.glitch-word::after {
    content: attr(data-text);
    position: absolute;
    left: 0;
    top: 3px;
    color: var(--cyan);
    opacity: 0;
    pointer-events: none;
}

.chamber-aperture .glitch-word::after {
    animation: wordGlitch 4s steps(1) infinite;
}

@keyframes wordGlitch {
    0%, 92% { opacity: 0; }
    93% { opacity: 0.8; transform: translate(2px, 0); }
    95% { opacity: 0; }
    96% { opacity: 0.6; transform: translate(-3px, 1px); }
    98% { opacity: 0; }
}

.glitch-band {
    position: absolute;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--cyan);
    opacity: 0;
    pointer-events: none;
    z-index: 3;
}

.glitch-band-1 { animation: scanBand 4s steps(1) infinite 0s; }
.glitch-band-2 { animation: scanBand 3.5s steps(1) infinite 1.2s; }
.glitch-band-3 { animation: scanBand 5s steps(1) infinite 2.5s; }

@keyframes scanBand {
    0%, 94% { opacity: 0; }
    95% { opacity: 0.8; top: 30%; }
    96% { opacity: 0; }
    97% { opacity: 0.6; top: 65%; }
    98% { opacity: 0; }
    99% { opacity: 0.7; top: 15%; }
    100% { opacity: 0; }
}

.glitch-chevron {
    width: min(60vw, 400px);
}

.glitch-path {
    animation: flickerPath 3s steps(1) infinite;
}

@keyframes flickerPath {
    0%, 80% { stroke-dashoffset: 0; opacity: 1; }
    82% { stroke-dashoffset: 50; opacity: 0.5; }
    84% { stroke-dashoffset: 0; opacity: 1; }
    90% { stroke-dashoffset: 100; opacity: 0.3; }
    92% { stroke-dashoffset: 0; opacity: 1; }
}

.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* ========================================
   Chamber 4: The Core
   ======================================== */
.chamber-core {
    min-height: 200vh;
    background: var(--midnight);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 10vh 2rem;
}

.core-sunburst {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(90vw, 600px);
    height: auto;
    opacity: 0.15;
    animation: slowRotate 720s linear infinite;
}

@keyframes slowRotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.core-text {
    position: relative;
    z-index: 2;
    max-width: 800px;
    text-align: center;
}

.core-line {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    color: var(--gold);
    line-height: 2;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.core-line.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ========================================
   Chamber 5: The Horizon
   ======================================== */
.chamber-horizon {
    min-height: 100vh;
    background: var(--birch);
    display: flex;
    align-items: center;
    justify-content: center;
}

.horizon-content {
    text-align: center;
    max-width: 800px;
    padding: 2rem;
}

.infinity-svg {
    width: min(80vw, 700px);
    height: auto;
    margin-bottom: 4rem;
}

.infinity-path {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: stroke-dashoffset 4s ease-out;
}

.infinity-path.drawn {
    stroke-dashoffset: 0;
}

.infinity-line {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    transition: stroke-dashoffset 3s ease-out;
}

.infinity-line.drawn {
    stroke-dashoffset: 0;
}

.horizon-title {
    font-family: 'Poiret One', cursive;
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--midnight);
    letter-spacing: 0.08em;
    margin-bottom: 1.5rem;
}

.horizon-farewell {
    font-family: 'Poiret One', cursive;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--gold);
    letter-spacing: 0.02em;
    margin-bottom: 0.5rem;
}

.horizon-annotation {
    color: var(--stone);
    margin-top: 0.5rem;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 600px) {
    .threshold-subtitle {
        font-size: 1.2rem;
        letter-spacing: 0.3em;
    }

    .gallery-text {
        padding-left: 1rem;
    }
}
