/* ==========================================================================
   hangul.dev - Styles
   Monastic minimalism meets developer rigor
   ========================================================================== */

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    color: #111827;
    background-color: #f9fafb;
    background-image:
        linear-gradient(#f3f4f6 1px, transparent 1px),
        linear-gradient(90deg, #f3f4f6 1px, transparent 1px);
    background-size: 24px 24px;
    line-height: 1.75;
    letter-spacing: 0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Graph paper texture at reduced opacity */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(#f3f4f6 1px, transparent 1px),
        linear-gradient(90deg, #f3f4f6 1px, transparent 1px);
    background-size: 24px 24px;
    opacity: 0.5;
    pointer-events: none;
    z-index: -1;
}

/* Remove the duplicate background on body since we use the pseudo-element */
body {
    background-image: none;
}

/* --- Scroll Progress Indicator --- */
#scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 2px;
    height: 0%;
    background-color: #3b82f6;
    z-index: 1000;
    transition: height 50ms linear;
}

/* --- Fixed Navigation --- */
#site-nav {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 100;
}

.nav-domain {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 14px;
    font-weight: 400;
    color: #9ca3af;
    letter-spacing: 0.02em;
}

/* --- Hero Section --- */
#hero {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
}

.hero-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

#hero-circle {
    opacity: 0;
}

#hero-circle circle {
    stroke-dasharray: 377;
    stroke-dashoffset: 377;
}

#hero-circle.animate circle {
    animation: drawCircle 1200ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

#hero-circle.fade-gray circle {
    transition: stroke 400ms ease;
    stroke: #d1d5db;
}

@keyframes drawCircle {
    from {
        stroke-dashoffset: 377;
    }
    to {
        stroke-dashoffset: 0;
    }
}

#hero-title {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: clamp(1.2rem, 2.5vw, 1.6rem);
    color: #111827;
    letter-spacing: 0.05em;
    opacity: 0;
    transform: translateY(16px);
}

#hero-title.animate {
    animation: fadeUp 600ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-inner.slide-up {
    animation: heroSlideUp 800ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes heroSlideUp {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(-30vh);
    }
}

/* --- Content Sections --- */
.content-section {
    max-width: 640px;
    margin: 0 auto;
    padding: 8vh 24px;
}

.content-section[data-reveal] {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 500ms cubic-bezier(0.4, 0, 0.2, 1),
                transform 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

.content-section[data-reveal].revealed {
    opacity: 1;
    transform: translateY(0);
}

/* --- Choseong Mode (Text-dominant) --- */
.choseong-mode h2 {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: clamp(1.6rem, 3.5vw, 2.4rem);
    color: #111827;
    letter-spacing: -0.02em;
    margin-bottom: 2rem;
    line-height: 1.3;
}

.choseong-mode h3 {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: clamp(1.2rem, 2.5vw, 1.6rem);
    color: #111827;
    letter-spacing: -0.02em;
    margin-bottom: 1.5rem;
    line-height: 1.4;
}

.choseong-mode p {
    font-size: 1rem;
    line-height: 1.75;
    color: #111827;
    margin-bottom: 1.5rem;
}

/* --- Jungseong Mode (Visual-accent) --- */
.jungseong-mode {
    text-align: center;
}

/* --- Jamo Dividers --- */
.jamo-divider {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 6vh 0;
}

.jamo-divider svg line,
.jamo-divider svg circle {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    transition: stroke-dashoffset 600ms cubic-bezier(0.4, 0, 0.2, 1);
}

.jamo-divider.revealed svg line,
.jamo-divider.revealed svg circle {
    stroke-dashoffset: 0;
}

/* --- Syllable Decomposition Demo --- */
#syllable-demo {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4vh 0;
}

#syllable-block {
    position: relative;
    width: clamp(120px, 20vw, 200px);
    height: clamp(120px, 20vw, 200px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.jamo {
    position: absolute;
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 300;
    font-size: clamp(2.5rem, 8vw, 5rem);
    color: #111827;
    opacity: 0;
    transition: transform 800ms cubic-bezier(0.4, 0, 0.2, 1),
                opacity 600ms cubic-bezier(0.4, 0, 0.2, 1);
}

.jamo-choseong {
    top: 0;
    left: 10%;
}

.jamo-jungseong {
    top: 15%;
    right: 5%;
}

.jamo-jongseong {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

.jamo-composite {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 300;
    font-size: clamp(6rem, 20vw, 14rem);
    color: #111827;
    transition: opacity 600ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Decomposed state */
#syllable-block.decomposed .jamo-composite {
    opacity: 0;
}

#syllable-block.decomposed .jamo-choseong {
    opacity: 1;
    transform: translate(-20px, -20px);
}

#syllable-block.decomposed .jamo-jungseong {
    opacity: 1;
    transform: translate(20px, 0);
}

#syllable-block.decomposed .jamo-jongseong {
    opacity: 1;
    transform: translate(-50%, 16px);
}

/* Reassembled state */
#syllable-block.reassembled .jamo-composite {
    opacity: 1;
}

#syllable-block.reassembled .jamo {
    opacity: 0;
    transform: translate(0, 0);
}

.demo-caption {
    font-size: 0.875rem;
    color: #6b7280;
    margin-top: 2rem;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

/* --- Korean Display Text --- */
.text-korean-display {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 300;
    font-size: clamp(4rem, 12vw, 10rem);
    color: #111827;
    letter-spacing: 0.15em;
    text-align: center;
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

/* --- Code Blocks --- */
.code-block {
    background-color: #1f2937;
    border-left: 2px solid #3b82f6;
    border-radius: 4px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.code-block pre {
    margin: 0;
}

.code-block code {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: 0.875rem;
    line-height: 1.6;
    color: #e5e7eb;
    white-space: pre;
}

/* Inline code */
code {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: 0.875rem;
    background-color: #1f2937;
    color: #e5e7eb;
    padding: 2px 6px;
    border-radius: 2px;
}

/* --- Links --- */
a, .accent-link {
    color: #3b82f6;
    text-decoration: none;
    transition: color 200ms ease;
}

a:hover, .accent-link:hover {
    color: #60a5fa;
}

/* --- Footer --- */
footer {
    text-align: center;
    padding-bottom: 12vh;
}

.footer-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: 1rem;
    color: #111827;
    margin-bottom: 0.75rem;
}

.footer-sub {
    font-size: 0.875rem;
    color: #9ca3af;
}

/* ==========================================================================
   Dark Mode
   ========================================================================== */
@media (prefers-color-scheme: dark) {
    body {
        color: #e5e7eb;
        background-color: #0f172a;
    }

    body::before {
        background-image:
            linear-gradient(rgba(30, 41, 59, 0.4) 1px, transparent 1px),
            linear-gradient(90deg, rgba(30, 41, 59, 0.4) 1px, transparent 1px);
        background-size: 24px 24px;
        opacity: 0.5;
    }

    #hero-title {
        color: #e5e7eb;
    }

    #hero-circle.fade-gray circle {
        stroke: #374151;
    }

    .nav-domain {
        color: #9ca3af;
    }

    .choseong-mode h2,
    .choseong-mode h3,
    .choseong-mode p {
        color: #e5e7eb;
    }

    .jamo-divider svg line,
    .jamo-divider svg circle {
        stroke: #374151;
    }

    .jamo,
    .jamo-composite {
        color: #e5e7eb;
    }

    .text-korean-display {
        color: #e5e7eb;
    }

    .demo-caption {
        color: #9ca3af;
    }

    .code-block {
        background-color: #1e293b;
    }

    .code-block code {
        color: #e5e7eb;
    }

    code {
        background-color: #1e293b;
        color: #e5e7eb;
    }

    .footer-text {
        color: #e5e7eb;
    }

    .footer-sub {
        color: #9ca3af;
    }

    a, .accent-link {
        color: #3b82f6;
    }

    a:hover, .accent-link:hover {
        color: #60a5fa;
    }
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */
@media (max-width: 640px) {
    .content-section {
        padding: 6vh 20px;
    }

    #site-nav {
        top: 16px;
        left: 16px;
    }

    .nav-domain {
        font-size: 12px;
    }

    .jamo-divider {
        padding: 4vh 0;
    }
}
