:root {
    --ink-void: #0d0d12;
    --deep-indigo: #111118;
    --dim-veil: #2a2a3e;
    --electric-cyan: #00e5ff;
    --hot-magenta: #ff2d7b;
    --neon-violet: #b44aff;
    --phosphor-green: #39ff8e;
    --parchment-white: #e8e6e1;
    --warm-ash: #a09a92;
    --pale-lavender: #c4b8db;
    --amber-glow: #ffb830;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    background: var(--ink-void);
    color: var(--parchment-white);
    font-family: 'Karla', sans-serif;
    font-weight: 400;
    font-size: clamp(0.875rem, 1.2vw, 1rem);
    line-height: 1.7;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Noise texture overlay */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1000;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)' opacity='0.3'/%3E%3C/svg%3E");
    background-size: 256px 256px;
    opacity: 0.04;
    mix-blend-mode: overlay;
}

/* Progress Indicator */
.progress-dot {
    position: fixed;
    right: 16px;
    top: 20%;
    bottom: 20%;
    width: 2px;
    background: var(--dim-veil);
    z-index: 100;
}

.progress-fill {
    width: 100%;
    height: 0%;
    background: var(--electric-cyan);
    transition: height 100ms linear;
}

/* Home Glyph */
.home-glyph {
    position: fixed;
    top: 16px;
    left: 16px;
    font-family: 'Noto Serif KR', serif;
    font-size: 1.2rem;
    color: var(--dim-veil);
    text-decoration: none;
    z-index: 100;
    transition: color 300ms ease;
}

.home-glyph:hover { color: var(--electric-cyan); }

/* Ghost Jamo */
.ghost-jamo {
    position: absolute;
    font-family: 'Noto Serif KR', serif;
    font-weight: 200;
    font-size: 300px;
    color: var(--parchment-white);
    opacity: 0.03;
    pointer-events: none;
    z-index: 0;
    top: 10%;
    right: 10%;
    line-height: 1;
}

.ghost-jamo-pause {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 400px;
}

/* Scene Base */
.scene {
    min-height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(3rem, 6vw, 6rem);
    overflow: hidden;
}

/* Hero Scene */
.hero-scene {
    text-align: center;
}

.hero-content { position: relative; z-index: 2; }

.hero-title {
    font-family: 'Poiret One', sans-serif;
    font-size: clamp(4rem, 12vw, 6rem);
    letter-spacing: 0.12em;
    color: var(--electric-cyan);
    line-height: 1.2;
    visibility: hidden;
}

.hero-title.typed { visibility: visible; }

.hero-subtitle {
    font-family: 'Karla', sans-serif;
    font-size: 1rem;
    color: var(--warm-ash);
    margin-top: 1rem;
    opacity: 0;
    transition: opacity 1200ms ease;
}

.hero-subtitle.shown { opacity: 1; }

/* Flower SVGs */
.hero-flower {
    position: absolute;
    bottom: 10%;
    right: 10%;
    width: 150px;
    height: 150px;
    opacity: 0;
    transition: opacity 2000ms ease;
    z-index: 1;
}

.hero-flower.shown { opacity: 1; }

.flower-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 2s ease-out;
}

.scene.paths-drawn .flower-path {
    stroke-dashoffset: 0;
}

/* Typewriter cursor */
.typewriter-cursor {
    display: inline-block;
    width: 1px;
    height: 1em;
    background: var(--electric-cyan);
    margin-left: 2px;
    animation: cursor-blink 500ms step-end infinite;
    vertical-align: text-bottom;
}

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Typed characters */
.typed-char {
    opacity: 0;
    display: inline-block;
}

.typed-char.show { opacity: 1; }

/* Thought Grid */
.thought-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    max-width: 1000px;
    width: 100%;
    position: relative;
    z-index: 2;
}

.thought-cell {
    background: var(--deep-indigo);
    border: 1px solid var(--dim-veil);
    padding: clamp(1.2rem, 2vw, 2rem);
    transition: border-color 200ms ease, transform 300ms ease-out;
}

.thought-cell:hover {
    transform: translateY(-4px);
}

.cell-cyan:hover { border-color: var(--electric-cyan); }
.cell-magenta:hover { border-color: var(--hot-magenta); }
.cell-violet:hover { border-color: var(--neon-violet); }
.cell-green:hover { border-color: var(--phosphor-green); }

.cell-2x1 { grid-column: span 2; }
.cell-1x2 { grid-row: span 2; display: flex; flex-direction: column; justify-content: center; }

.cell-void {
    background: transparent;
    border-style: dashed;
    animation: void-pulse 4s ease-in-out infinite;
}

@keyframes void-pulse {
    0%, 100% { border-color: var(--dim-veil); }
    50% { border-color: rgba(0, 229, 255, 0.2); }
}

.cell-title {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    color: rgba(74, 124, 124, 0.8);
    margin-bottom: 0.5rem;
}

.cell-body {
    font-family: 'Karla', sans-serif;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--warm-ash);
}

.cell-body-kr {
    font-family: 'Noto Serif KR', serif;
    font-weight: 300;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    color: var(--parchment-white);
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.cell-translation {
    font-size: 0.8rem;
    color: var(--warm-ash);
    font-style: italic;
}

.cell-botanical {
    width: 80px;
    height: 80px;
    margin: 0 auto;
}

/* Cell Enter Animation */
.cell-enter {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 400ms ease-out, transform 400ms ease-out;
    transition-delay: calc(var(--enter-delay, 0) * 100ms);
}

.cell-enter.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Pause Scene */
.pause-scene {
    min-height: 40vh;
}

.pause-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

.pause-kr {
    font-family: 'Noto Serif KR', serif;
    font-weight: 300;
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    color: var(--parchment-white);
    visibility: hidden;
}

.pause-kr.typed { visibility: visible; }

.pause-en {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.75rem;
    color: rgba(74, 124, 124, 0.8);
    margin-top: 0.75rem;
    letter-spacing: 0.06em;
}

/* Lattice Window */
.lattice-window {
    position: absolute;
    width: 60%;
    max-width: 400px;
    height: auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.3;
    z-index: 0;
}

/* Closing Scene */
.closing-scene {
    min-height: 80vh;
    gap: 2rem;
    padding-bottom: 20vh;
}

.bowl-motif {
    width: 120px;
    height: 75px;
}

.closing-title {
    font-family: 'Noto Serif KR', serif;
    font-weight: 200;
    font-size: clamp(2.5rem, 6vw, 3.5rem);
    color: var(--pale-lavender);
}

.closing-flower {
    width: 200px;
    height: 80px;
}

.closing-meta {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    color: var(--warm-ash);
    letter-spacing: 0.08em;
    opacity: 0.5;
}

/* Responsive */
@media (max-width: 768px) {
    .thought-grid { grid-template-columns: 1fr; }
    .cell-2x1 { grid-column: span 1; }
    .progress-dot { display: none; }
    .ghost-jamo { font-size: 200px; }
    .ghost-jamo-pause { font-size: 250px; }
    .lattice-window { width: 80%; }
}

@media (prefers-reduced-motion: reduce) {
    .cell-void { animation: none; }

    .cell-enter {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .flower-path {
        stroke-dashoffset: 0;
        transition: none;
    }

    .hero-title {
        visibility: visible;
    }

    .hero-subtitle, .hero-flower {
        opacity: 1;
        transition: none;
    }

    .pause-kr { visibility: visible; }
    .lamp-content { opacity: 1; animation: none; }
}
