/* ============================================
   hangeul.day — Retro-Futuristic Hangul Observatory
   ============================================ */

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

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

body {
    background: #0a0e1a;
    color: #c8d8e8;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: clamp(0.9rem, 1.2vw, 1.15rem);
    line-height: 1.85;
    letter-spacing: 0.03em;
    overflow-x: hidden;
}

/* --- Wongoji Grid Texture --- */
.wongoji-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0.04;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 39px,
            #4a5a7a 39px,
            #4a5a7a 40px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 39px,
            #4a5a7a 39px,
            #4a5a7a 40px
        );
}

/* --- Oscilloscope Lines --- */
.oscilloscope-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.osc-line {
    position: absolute;
    background: #2a3a5a;
    opacity: 0.3;
}

.osc-h {
    height: 1px;
    width: 100%;
    left: 0;
}

.osc-v {
    width: 1px;
    height: 100%;
    top: 0;
}

.osc-h1 {
    animation: oscSweepH1 60s linear infinite;
}

.osc-h2 {
    animation: oscSweepH2 45s linear infinite;
}

.osc-v1 {
    animation: oscSweepV1 50s linear infinite;
}

.osc-v2 {
    animation: oscSweepV2 70s linear infinite;
}

@keyframes oscSweepH1 {
    0% { top: -1px; }
    100% { top: 100%; }
}

@keyframes oscSweepH2 {
    0% { top: 100%; }
    100% { top: -1px; }
}

@keyframes oscSweepV1 {
    0% { left: -1px; }
    100% { left: 100%; }
}

@keyframes oscSweepV2 {
    0% { left: 100%; }
    100% { left: -1px; }
}

/* --- Section Base --- */
.section {
    position: relative;
    min-height: 100vh;
    padding: clamp(2rem, 4vw, 6rem);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.section .syllable-grid,
.section .gradient-mesh,
.section .ghost-jamo {
    transition: opacity 400ms ease, transform 400ms ease;
}

.section.section-hidden .syllable-grid {
    opacity: 0;
    transform: scale(0.92);
}

.section.section-visible .syllable-grid {
    opacity: 1;
    transform: scale(1);
}

/* --- Gradient Meshes --- */
.gradient-mesh {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    will-change: opacity;
}

.mesh-1 {
    background:
        radial-gradient(ellipse at 50% 10%, rgba(90, 184, 196, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(196, 154, 90, 0.05) 0%, transparent 40%),
        radial-gradient(ellipse at 50% 50%, rgba(42, 58, 106, 0.12) 0%, transparent 60%),
        radial-gradient(ellipse at 60% 40%, #2a3a6a05 0%, transparent 70%),
        #0a0e1a;
    animation: breathe1 20s ease-in-out infinite;
}

.mesh-2 {
    background:
        radial-gradient(ellipse at 15% 50%, rgba(90, 184, 196, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 30%, rgba(196, 154, 90, 0.05) 0%, transparent 40%),
        radial-gradient(ellipse at 40% 60%, rgba(42, 58, 106, 0.12) 0%, transparent 60%),
        #0a0e1a;
    animation: breathe2 20s ease-in-out infinite;
}

.mesh-3 {
    background:
        radial-gradient(ellipse at 50% 50%, rgba(90, 184, 196, 0.10) 0%, transparent 45%),
        radial-gradient(ellipse at 30% 30%, rgba(196, 154, 90, 0.06) 0%, transparent 40%),
        radial-gradient(ellipse at 70% 70%, rgba(42, 58, 106, 0.12) 0%, transparent 55%),
        #0a0e1a;
    animation: breathe3 20s ease-in-out infinite;
}

.mesh-4 {
    background:
        radial-gradient(ellipse at 85% 50%, rgba(90, 184, 196, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 20% 70%, rgba(196, 154, 90, 0.05) 0%, transparent 40%),
        radial-gradient(ellipse at 60% 40%, rgba(42, 58, 106, 0.12) 0%, transparent 60%),
        #0a0e1a;
    animation: breathe4 20s ease-in-out infinite;
}

.mesh-5 {
    background:
        radial-gradient(ellipse at 50% 90%, rgba(90, 184, 196, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 30% 20%, rgba(196, 154, 90, 0.05) 0%, transparent 40%),
        radial-gradient(ellipse at 60% 50%, rgba(42, 58, 106, 0.12) 0%, transparent 60%),
        #0a0e1a;
    animation: breathe5 20s ease-in-out infinite;
}

@keyframes breathe1 {
    0%, 100% { background-position: 0% 0%; opacity: 1; }
    50% { background-position: 2% -3%; opacity: 0.92; }
}

@keyframes breathe2 {
    0%, 100% { background-position: 0% 0%; opacity: 1; }
    50% { background-position: -3% 2%; opacity: 0.92; }
}

@keyframes breathe3 {
    0%, 100% { background-position: 0% 0%; opacity: 1; }
    50% { background-position: 2% 2%; opacity: 0.92; }
}

@keyframes breathe4 {
    0%, 100% { background-position: 0% 0%; opacity: 1; }
    50% { background-position: -2% -2%; opacity: 0.92; }
}

@keyframes breathe5 {
    0%, 100% { background-position: 0% 0%; opacity: 1; }
    50% { background-position: 3% 3%; opacity: 0.92; }
}

/* --- Ghost Jamo Watermarks --- */
.ghost-jamo {
    position: absolute;
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 900;
    color: #1a2540;
    z-index: 1;
    pointer-events: none;
    line-height: 1;
    user-select: none;
}

.ghost-jamo-1 {
    font-size: clamp(15rem, 20vw, 22rem);
    top: 10%;
    right: 10%;
    transform: rotate(5deg);
}

.ghost-jamo-2 {
    font-size: clamp(12rem, 18vw, 20rem);
    bottom: 5%;
    left: 5%;
    transform: rotate(-3deg);
}

.ghost-jamo-3 {
    font-size: clamp(18rem, 22vw, 26rem);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(0deg);
}

.ghost-jamo-4 {
    font-size: clamp(14rem, 18vw, 22rem);
    top: 15%;
    left: 60%;
    transform: rotate(8deg);
}

.ghost-jamo-5 {
    font-size: clamp(14rem, 18vw, 22rem);
    bottom: 10%;
    right: 15%;
    transform: rotate(-5deg);
}

/* --- Syllable Block Grid --- */
.syllable-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    min-height: calc(100vh - clamp(4rem, 8vw, 12rem));
    width: 100%;
    max-width: 1400px;
    gap: 1px;
    position: relative;
    z-index: 2;
}

/* Grid cell base with phantom border */
.grid-cell {
    background: #111828;
    position: relative;
    padding: clamp(0.8rem, 1.5vw, 2rem);
    display: flex;
    flex-direction: column;
    justify-content: center;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.grid-cell.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Phantom grid lines on empty cells - simulated via grid gap */
.syllable-grid::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent calc(20% - 0.5px),
            #1a2040 calc(20% - 0.5px),
            #1a2040 calc(20% + 0.5px),
            transparent calc(20% + 0.5px)
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent calc(20% - 0.5px),
            #1a2040 calc(20% - 0.5px),
            #1a2040 calc(20% + 0.5px),
            transparent calc(20% + 0.5px)
        );
    z-index: -1;
    opacity: 0.6;
}

/* --- Typography --- */
.headline-en {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 5.5rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #c8d8e8;
    line-height: 1.1;
    margin-bottom: 0.3em;
}

.headline-kr {
    font-family: 'Noto Sans KR', sans-serif;
    font-size: clamp(1.8rem, 4vw, 4.5rem);
    line-height: 1.2;
    color: #c8d8e8;
}

.kr-display {
    font-weight: 100;
    transition: font-weight 1.5s ease;
}

.kr-display.solidified {
    font-weight: 400;
}

.body-en {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: clamp(0.9rem, 1.2vw, 1.15rem);
    line-height: 1.85;
    letter-spacing: 0.03em;
    color: #c8d8e8;
    margin-bottom: 1em;
    max-width: 48ch;
}

.emphasis-coral {
    color: #c47a6a;
}

.body-en.final-statement {
    font-weight: 700;
    font-size: clamp(1.1rem, 1.8vw, 1.5rem);
    color: #c49a5a;
    letter-spacing: 0.06em;
    line-height: 1.6;
    font-style: italic;
}

.text-secondary {
    color: #6a7a9a;
}

.mono-label {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    color: #4a5a7a;
    line-height: 1.8;
}

/* --- Consonant Grid --- */
.consonant-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
}

.consonant-char {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 400;
    font-size: clamp(1.2rem, 2vw, 2rem);
    color: #5ab8c4;
    text-align: center;
    padding: 0.4rem;
    border: 1px solid #1a2040;
    transition: color 0.3s ease, border-color 0.3s ease;
}

.consonant-char:hover {
    color: #c49a5a;
    border-color: #c49a5a;
}

/* --- SVG Jamo Strokes --- */
.jamo-svg {
    width: 100%;
    max-height: 100%;
    overflow: visible;
}

.jamo-stroke {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.65, 0, 0.35, 1);
}

.jamo-circle {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
}

.section.stroke-animated .jamo-stroke {
    stroke-dashoffset: 0;
}

.vertical-stroke-container {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vertical-stroke-container .jamo-svg {
    height: 80%;
    width: auto;
}

.jamo-svg-horizontal {
    width: 100%;
    height: 40px;
}

.jamo-svg-dot {
    width: 80px;
    height: 80px;
    margin: 0 auto;
}

.jamo-svg-branch {
    width: 80px;
    height: 100%;
}

.jamo-svg-descent {
    width: 160px;
    height: 100px;
    margin: 0 auto;
}

/* --- Navigation Dots --- */
.section-nav {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 100;
}

.nav-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid #2a3a5a;
    background: transparent;
    cursor: pointer;
    padding: 0;
    position: relative;
    transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
}

.nav-dot:hover {
    border-color: #5ab8c4;
    transform: scale(1.3);
}

.nav-dot.active {
    background: #5ab8c4;
    border-color: #5ab8c4;
}

.nav-dot-label {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 0.7rem;
    color: #4a5a7a;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.nav-dot:hover .nav-dot-label {
    opacity: 1;
}

/* --- Responsive: Tablet --- */
@media (max-width: 1024px) {
    .syllable-grid {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: auto;
    }

    .ghost-jamo {
        font-size: 8vw !important;
    }

    .oscilloscope-lines {
        display: none;
    }

    .grid-cell {
        grid-column: auto !important;
        grid-row: auto !important;
    }
}

/* --- Responsive: Mobile --- */
@media (max-width: 768px) {
    .syllable-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        gap: 0;
    }

    .syllable-grid::before {
        display: none;
    }

    .grid-cell {
        grid-column: auto !important;
        grid-row: auto !important;
        padding: 1.5rem 1rem;
    }

    .section {
        padding: clamp(1.5rem, 3vw, 3rem);
    }

    .section-nav {
        bottom: 1rem;
        right: 50%;
        transform: translateX(50%);
        flex-direction: row;
    }

    .nav-dot-label {
        display: none;
    }

    .ghost-jamo {
        font-size: 30vw !important;
        opacity: 0.3;
    }

    .headline-en {
        font-size: clamp(1.8rem, 8vw, 3rem);
    }

    .consonant-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .osc-line,
    .gradient-mesh,
    .grid-cell,
    .jamo-stroke,
    .kr-display,
    .section .syllable-grid {
        animation: none !important;
        transition: none !important;
    }

    .grid-cell {
        opacity: 1;
        transform: none;
    }

    .jamo-stroke {
        stroke-dashoffset: 0;
    }

    .section .syllable-grid {
        opacity: 1;
        transform: none;
    }

    .kr-display {
        font-weight: 400;
    }
}
