/* ============================================
   hangeul.day -- Neon Jamo Laboratory
   ============================================ */

/* --- Design Tokens --- */
:root {
    --void-black: #0a0a0f;
    --deep-indigo: #0f0f1a;
    --charcoal-slate: #161625;
    --electric-cyan: #00f0ff;
    --hot-magenta: #ff00aa;
    --acid-violet: #8b00ff;
    --lunar-silver: #b0b8c8;
    --slate-mist: #6a7080;
    --pure-white: #f0f0ff;
    --phosphor-green: #00ff88;
    --grid-line: #1a1a2a;
    --glow-sm: 0 0 7px;
    --glow-md: 0 0 20px;
    --glow-lg: 0 0 42px;
    --glow-xl: 0 0 82px;
    --glow-ambient: 0 0 150px;
    --grid-size: 40px;
    --split-gap: 2px;
    --timing-reveal: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --timing-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --timing-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--void-black);
    color: var(--lunar-silver);
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.4vw, 1.05rem);
    line-height: 1.75;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar {
    width: 3px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--electric-cyan);
    border-radius: 2px;
}

/* --- Grid Substrate --- */
#grid-substrate {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 600ms ease;
    background-image:
        linear-gradient(rgba(26, 26, 42, 0.4) 1px, transparent 1px),
        linear-gradient(90deg, rgba(26, 26, 42, 0.4) 1px, transparent 1px),
        radial-gradient(circle 1px, rgba(0, 240, 255, 0.08) 1px, transparent 1px);
    /* grid-line color: #1a1a2a at 0.4 opacity */
    background-size:
        var(--grid-size) var(--grid-size),
        var(--grid-size) var(--grid-size),
        120px 120px;
    background-position:
        0 0,
        0 0,
        0 0;
}

#grid-substrate.visible {
    opacity: 1;
}

/* --- Particle Canvas --- */
#particle-canvas {
    position: fixed;
    top: 0;
    left: 50%;
    width: 50%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    opacity: 0.6;
}

/* --- Navigation Indicator --- */
#nav-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    font-family: 'Black Han Sans', sans-serif;
    font-size: 16px;
    color: var(--hot-magenta);
    cursor: pointer;
    animation: pulse-attention 2s ease-in-out infinite;
    text-shadow:
        0 0 7px currentColor,
        0 0 20px rgba(255, 0, 170, 0.5);
    transition: text-shadow 300ms ease;
}

#nav-indicator:hover {
    text-shadow:
        0 0 10px currentColor,
        0 0 30px rgba(255, 0, 170, 0.7),
        0 0 60px rgba(255, 0, 170, 0.4);
}

/* --- Intro Screen --- */
#intro {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--void-black);
    z-index: 10;
    overflow: hidden;
}

#intro-svg-container {
    position: relative;
    z-index: 2;
    opacity: 0;
}

#intro-svg-container.visible {
    opacity: 1;
}

#hieut-circuit {
    width: clamp(150px, 30vw, 250px);
    height: clamp(150px, 30vw, 250px);
}

#hieut-circuit .trace {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    filter: drop-shadow(0 0 4px rgba(0, 240, 255, 0.6));
}

#hieut-circuit .trace.animate {
    animation: draw-trace 2000ms var(--timing-smooth) forwards;
}

#hieut-circuit .trace-4 {
    stroke-dasharray: 190;
    stroke-dashoffset: 190;
}

#hieut-circuit .solder-pad {
    opacity: 0;
    transform-origin: center;
}

#hieut-circuit .solder-pad.visible {
    animation: pad-appear 300ms var(--timing-bounce) forwards;
}

#hieut-circuit.pulse-glow .trace {
    filter: drop-shadow(0 0 12px rgba(0, 240, 255, 1)) drop-shadow(0 0 30px rgba(0, 240, 255, 0.6));
    transition: filter 200ms ease;
}

#hieut-circuit.settle-glow .trace {
    filter: drop-shadow(0 0 4px rgba(0, 240, 255, 0.6));
    transition: filter 400ms ease;
}

/* Intro Divider */
#intro-divider {
    position: absolute;
    left: 50%;
    top: 50%;
    width: var(--split-gap);
    height: 0;
    background: var(--electric-cyan);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
    transform: translateX(-50%);
    z-index: 3;
    opacity: 0;
}

#intro-divider.extend {
    opacity: 1;
    animation: divider-extend 600ms var(--timing-smooth) forwards;
}

/* --- Main Content --- */
#main-content {
    position: relative;
    z-index: 5;
    opacity: 0;
    transition: opacity 400ms ease;
}

#main-content.visible {
    opacity: 1;
}

/* --- Split Divider --- */
#split-divider {
    position: fixed;
    left: 50%;
    top: 0;
    width: var(--split-gap);
    height: 100vh;
    background: var(--electric-cyan);
    opacity: 0.4;
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
    transform: translateX(-50%);
    z-index: 50;
    pointer-events: none;
    display: none;
}

#split-divider.visible {
    display: block;
}

#divider-glow {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--electric-cyan);
    opacity: 0.6;
    filter: blur(4px);
    pointer-events: none;
    transition: top 50ms linear;
    top: 50%;
}

/* --- Split Section Layout --- */
.split-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 150vh;
    position: relative;
}

.col-left {
    background: var(--void-black);
    padding: 8vh 5vw 8vh 4vw;
    position: relative;
}

.col-right {
    background: var(--deep-indigo);
    padding: 8vh 4vw 8vh 5vw;
    position: relative;
    overflow: hidden;
}

/* Neon bloom behind right column content */
.col-right::before {
    content: '';
    position: absolute;
    top: 30%;
    left: 50%;
    width: 80%;
    height: 60%;
    transform: translateX(-50%);
    background: radial-gradient(ellipse at center, rgba(255, 0, 170, 0.12) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.content-block {
    position: relative;
    z-index: 1;
    opacity: 0;
    transition: opacity 500ms var(--timing-reveal), transform 500ms var(--timing-reveal);
}

.slide-reveal-left {
    transform: translateX(-20px);
}

.slide-reveal-right {
    transform: translateY(15px);
}

.content-block.revealed {
    opacity: 1;
    transform: translate(0, 0);
}

/* --- Horizontal Rule Separator --- */
.content-block + .content-block::before {
    content: '';
    display: block;
    width: 100%;
    height: 1px;
    margin-bottom: 4vh;
    background: linear-gradient(90deg, transparent, var(--electric-cyan) 20%, var(--hot-magenta) 80%, transparent);
    filter: blur(0.5px);
}

/* --- Section Labels --- */
.section-label {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: clamp(0.9rem, 2vw, 1.6rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--electric-cyan);
    margin-bottom: 3vh;
    text-shadow: 0 0 7px currentColor, 0 0 20px rgba(0, 240, 255, 0.5);
}

.merge-label {
    color: var(--hot-magenta);
    text-shadow: 0 0 7px currentColor, 0 0 20px rgba(255, 0, 170, 0.5);
}

/* --- Latin Headings --- */
.latin-heading {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 3vw, 2.4rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--pure-white);
    margin-bottom: 4vh;
    text-shadow: 0 0 7px rgba(240, 240, 255, 0.5);
}

/* --- Code Blocks --- */
.code-block {
    background: #0d0d18;
    border-left: 1px solid var(--acid-violet);
    border-radius: 0;
    padding: 2rem 1.5rem;
    margin-bottom: 3vh;
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.8rem, 1.2vw, 0.95rem);
    line-height: 1.8;
    overflow-x: auto;
}

.code-line {
    white-space: pre;
    padding: 2px 0;
    transition: background 200ms ease;
    display: flex;
    align-items: baseline;
    gap: 1em;
}

.code-line:hover {
    background: rgba(0, 240, 255, 0.05);
}

.code-line:hover .line-num {
    color: var(--electric-cyan);
}

.line-num {
    color: var(--slate-mist);
    user-select: none;
    min-width: 2ch;
    display: inline-block;
    transition: color 200ms ease;
}

.kw {
    color: var(--electric-cyan);
}

.str {
    color: var(--hot-magenta);
}

.cmt {
    color: var(--phosphor-green);
}

.fn {
    color: var(--pure-white);
}

/* --- Body Text --- */
.body-text {
    margin-bottom: 2.5vh;
    color: var(--lunar-silver);
    max-width: 55ch;
}

.hl-cyan {
    color: var(--electric-cyan);
    font-weight: 600;
}

.hl-magenta {
    color: var(--hot-magenta);
    font-weight: 600;
}

.hl-bright {
    color: var(--pure-white);
    font-weight: 600;
}

/* --- Glow Characters --- */
.glow-character {
    font-family: 'Black Han Sans', sans-serif;
    font-weight: 400;
    color: var(--electric-cyan);
    display: inline-block;
    animation: neon-flicker 4s infinite;
    transition: text-shadow 300ms ease;
    cursor: default;
}

.glow-character:hover {
    text-shadow:
        0 0 10px currentColor,
        0 0 30px rgba(0, 240, 255, 0.75),
        0 0 63px rgba(0, 240, 255, 0.45),
        0 0 123px rgba(0, 240, 255, 0.22),
        0 0 225px rgba(0, 240, 255, 0.08);
    color: var(--pure-white);
}

.glow-character[data-char="ㅎ"] {
    font-size: clamp(3rem, 10vw, 8rem);
    text-shadow:
        0 0 7px currentColor,
        0 0 20px rgba(0, 240, 255, 0.5),
        0 0 42px rgba(0, 240, 255, 0.3),
        0 0 82px rgba(0, 240, 255, 0.15),
        0 0 150px rgba(0, 240, 255, 0.05);
    margin-bottom: 3vh;
}

.glow-sm {
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    text-shadow:
        0 0 7px currentColor,
        0 0 20px rgba(0, 240, 255, 0.5),
        0 0 42px rgba(0, 240, 255, 0.3),
        0 0 82px rgba(0, 240, 255, 0.15),
        0 0 150px rgba(0, 240, 255, 0.05);
    letter-spacing: 0.04em;
}

.glow-md {
    font-size: clamp(2.5rem, 6vw, 5rem);
    text-shadow:
        0 0 7px currentColor,
        0 0 20px rgba(0, 240, 255, 0.5),
        0 0 42px rgba(0, 240, 255, 0.3),
        0 0 82px rgba(0, 240, 255, 0.15),
        0 0 150px rgba(0, 240, 255, 0.05);
}

.glow-lg {
    font-size: clamp(3.5rem, 8vw, 6.5rem);
    text-shadow:
        0 0 7px currentColor,
        0 0 20px rgba(0, 240, 255, 0.5),
        0 0 42px rgba(0, 240, 255, 0.3),
        0 0 82px rgba(0, 240, 255, 0.15),
        0 0 150px rgba(0, 240, 255, 0.05);
}

.glow-xl {
    font-size: clamp(5rem, 12vw, 10rem);
    text-shadow:
        0 0 7px currentColor,
        0 0 20px rgba(0, 240, 255, 0.5),
        0 0 42px rgba(0, 240, 255, 0.3),
        0 0 82px rgba(0, 240, 255, 0.15),
        0 0 150px rgba(0, 240, 255, 0.05);
}

/* --- Glow Character Rows --- */
.glow-character-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5vw;
    margin-bottom: 3vh;
    justify-content: center;
}

/* --- Syllable Showcase --- */
.syllable-showcase {
    display: flex;
    flex-wrap: wrap;
    gap: 2vw;
    margin-bottom: 4vh;
    justify-content: center;
    align-items: baseline;
}

/* --- Annotations --- */
.annotation {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 300;
    font-size: clamp(0.7rem, 1.1vw, 0.85rem);
    color: var(--slate-mist);
    margin-top: 3vh;
    text-align: center;
}

/* --- Circuit Jamo Grid --- */
.jamo-grid-circuit {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 4vh;
}

.circuit-jamo {
    width: 90px;
    text-align: center;
}

.circuit-jamo svg {
    width: 80px;
    height: 80px;
    display: block;
    margin: 0 auto 4px;
    background-color: rgba(22, 22, 37, 0.3);
    background-image:
        linear-gradient(#1a1a2a 1px, transparent 1px),
        linear-gradient(90deg, #1a1a2a 1px, transparent 1px);
    background-size: 10px 10px;
}

.circuit-jamo .trace {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    filter: drop-shadow(0 0 3px rgba(0, 240, 255, 0.5));
}

.circuit-jamo.drawn .trace {
    animation: draw-trace 1200ms var(--timing-smooth) forwards;
}

.circuit-jamo .solder-pad {
    opacity: 0;
}

.circuit-jamo.drawn .solder-pad {
    animation: pad-appear 200ms var(--timing-bounce) 1200ms forwards;
}

.jamo-label {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 300;
    font-size: 0.7rem;
    color: var(--slate-mist);
    display: block;
}

/* --- Merge Zones --- */
.merge-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--deep-indigo);
    position: relative;
    overflow: hidden;
    text-align: center;
}

.merge-zone::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60vw;
    height: 60vw;
    transform: translate(-50%, -50%);
    background: radial-gradient(ellipse at center, rgba(0, 240, 255, 0.15) 0%, transparent 70%);
    pointer-events: none;
}

.merge-content {
    position: relative;
    z-index: 2;
    padding: 4vh 4vw;
}

/* --- Syllable Assembly --- */
.syllable-assembly {
    display: flex;
    justify-content: center;
    gap: 3vw;
    margin-bottom: 4vh;
    min-height: 6rem;
}

.assembly-jamo {
    font-family: 'Black Han Sans', sans-serif;
    font-size: clamp(2rem, 6vw, 5rem);
    opacity: 0;
    transition: transform 800ms var(--timing-smooth), opacity 600ms ease;
}

.jamo-choseong {
    color: var(--hot-magenta);
    transform: translateX(-50px);
    text-shadow: 0 0 7px currentColor, 0 0 20px rgba(255, 0, 170, 0.5);
}

.jamo-jungseong {
    color: var(--electric-cyan);
    transform: translateX(50px);
    text-shadow: 0 0 7px currentColor, 0 0 20px rgba(0, 240, 255, 0.5);
}

.jamo-jongseong {
    color: var(--hot-magenta);
    transform: translateY(50px);
    text-shadow: 0 0 7px currentColor, 0 0 20px rgba(255, 0, 170, 0.5);
}

.syllable-assembly.assembled .assembly-jamo {
    opacity: 1;
    transform: translate(0, 0);
}

/* --- Merge Character --- */
.merge-character {
    font-family: 'Black Han Sans', sans-serif;
    font-size: clamp(30vw, 50vw, 80vw);
    color: var(--electric-cyan);
    line-height: 1;
    text-shadow:
        0 0 7px currentColor,
        0 0 20px rgba(0, 240, 255, 0.6),
        0 0 40px rgba(0, 240, 255, 0.3),
        0 0 80px rgba(0, 240, 255, 0.1);
    animation: neon-flicker 4s infinite;
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 600ms ease, transform 1000ms var(--timing-smooth);
}

.merge-character.zoom-in {
    opacity: 1;
    transform: scale(1);
}

.merge-character-final {
    font-size: clamp(20vw, 35vw, 50vw);
}

.final-char {
    display: inline-block;
}

.merge-text {
    font-family: 'IBM Plex Mono', monospace;
    color: var(--lunar-silver);
    max-width: 50ch;
    margin: 4vh auto 0;
    font-size: clamp(0.85rem, 1.4vw, 1.05rem);
    line-height: 1.75;
}

.merge-date {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: clamp(0.9rem, 2vw, 1.6rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--slate-mist);
    margin-top: 4vh;
}

/* --- Timeline (Act VI) --- */
.timeline-glow {
    display: flex;
    flex-direction: column;
    gap: 4vh;
    align-items: center;
}

.timeline-entry {
    display: flex;
    align-items: center;
    gap: 2vw;
}

.timeline-year {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: clamp(0.9rem, 1.5vw, 1.2rem);
    letter-spacing: 0.12em;
    color: var(--hot-magenta);
    text-shadow: 0 0 7px currentColor;
    min-width: 5ch;
}

.timeline-char {
    display: inline-block;
}

.timeline-desc {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.75rem, 1.2vw, 0.95rem);
    color: var(--lunar-silver);
}

/* ==============================
   ANIMATIONS
   ============================== */

@keyframes draw-trace {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes pad-appear {
    0% {
        opacity: 0;
        transform: scale(0);
    }
    60% {
        opacity: 1;
        transform: scale(1.3);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes neon-flicker {
    0% { opacity: 1; }
    5% { opacity: 0.94; }
    10% { opacity: 0.98; }
    15% { opacity: 0.92; }
    20% { opacity: 0.97; }
    30% { opacity: 1; }
    40% { opacity: 0.96; }
    50% { opacity: 0.93; }
    55% { opacity: 0.99; }
    60% { opacity: 0.95; }
    70% { opacity: 1; }
    80% { opacity: 0.97; }
    85% { opacity: 0.92; }
    90% { opacity: 0.98; }
    100% { opacity: 1; }
}

@keyframes pulse-attention {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

@keyframes divider-extend {
    0% {
        height: 0;
        top: 50%;
    }
    100% {
        height: 100vh;
        top: 0;
    }
}

/* ==============================
   MOBILE (<1024px)
   ============================== */

@media (max-width: 1024px) {
    .split-section {
        grid-template-columns: 1fr;
    }

    .col-left, .col-right {
        padding: 6vh 5vw;
    }

    /* Horizontal divider between pairs */
    .col-right::after {
        content: '';
        display: block;
        width: 100%;
        height: 2px;
        background: var(--electric-cyan);
        box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
        opacity: 0.4;
        margin-top: 4vh;
    }

    #split-divider {
        display: none !important;
    }

    #particle-canvas {
        left: 0;
        width: 100%;
        opacity: 0.3;
    }

    .merge-character {
        font-size: clamp(30vw, 60vw, 80vw);
    }

    .merge-character-final {
        font-size: clamp(25vw, 40vw, 55vw);
    }

    .syllable-assembly {
        gap: 5vw;
    }

    .jamo-grid-circuit {
        justify-content: center;
    }

    .circuit-jamo {
        width: 75px;
    }

    .circuit-jamo svg {
        width: 65px;
        height: 65px;
    }
}

@media (max-width: 600px) {
    .glow-sm {
        font-size: clamp(1.2rem, 8vw, 2.2rem);
    }

    .glow-character-row {
        gap: 3vw;
    }

    .code-block {
        padding: 1rem;
        font-size: 0.75rem;
    }

    .circuit-jamo {
        width: 65px;
    }

    .circuit-jamo svg {
        width: 55px;
        height: 55px;
    }
}
