/* =============================================================
   hangeul.day — A typographic garden of Korean letterforms
   Palette: Obangsaek-derived natural dyes
   ============================================================= */

:root {
    /* Palette */
    --hanji:        #F5F0E8;   /* hanji warm white */
    --indigo:       #1B2838;   /* fermented jjok */
    --ink:          #1A1A1A;   /* meomul black */
    --ash:          #6B6459;   /* warm ash */
    --persimmon:    #C85A32;   /* persimmon tannin */
    --mulberry:     #8B6B7B;   /* faded mulberry */
    --celadon:      #7BA68C;   /* weathered celadon */
    --sky:          #A8BCC8;   /* post-rain sky */

    /* Atmospheric (animated by JS) */
    --bg:     var(--hanji);
    --fg:     var(--ink);
    --accent: var(--persimmon);

    /* Type scale */
    --display: clamp(15rem, 25vw, 40rem);
    --body:    clamp(1rem, 1.1vw, 1.25rem);
    --leading: 1.9;
}

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

html {
    scroll-behavior: smooth;
    scroll-snap-type: y proximity;
}

body {
    background: var(--bg);
    color: var(--fg);
    font-family: 'Noto Sans KR', system-ui, sans-serif;
    font-weight: 300;
    font-size: var(--body);
    line-height: var(--leading);
    overflow-x: hidden;
    transition: background-color 200ms ease, color 200ms ease;
    min-height: 100vh;
}

/* ============== Hanji paper texture ============== */

.hanji-texture {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    opacity: 0.045;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='320'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.42  0 0 0 0 0.39  0 0 0 0 0.34  0 0 0 1 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
    background-size: 320px 320px;
    will-change: background-position;
}

body[data-active-zone="4"] .hanji-texture {
    opacity: 0.085;
    mix-blend-mode: screen;
}

.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ============== Ambient vowel geometry ============== */

.ambient-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    overflow: hidden;
}

.ambient-line {
    position: absolute;
    background: var(--ash);
    opacity: 0.18;
    height: 1px;
    width: 12vw;
    animation: drift 24s linear infinite;
}

.ambient-line--vert {
    width: 1px;
    height: 18vh;
    animation-name: drift-vert;
}

.ambient-line--1 { top: 18%; left: -10%; animation-duration: 38s; }
.ambient-line--2 { top: 64%; left: -10%; animation-duration: 52s; animation-delay: -12s; }
.ambient-line--3 { top: 32%; left: -10%; animation-duration: 46s; animation-delay: -28s; width: 8vw; }
.ambient-line--4 { top: 82%; left: -10%; animation-duration: 60s; animation-delay: -8s; }
.ambient-line--5 { top: -20%; left: 72%; animation-duration: 44s; }

@keyframes drift {
    0%   { transform: translateX(0); opacity: 0; }
    10%  { opacity: 0.18; }
    90%  { opacity: 0.18; }
    100% { transform: translateX(120vw); opacity: 0; }
}

@keyframes drift-vert {
    0%   { transform: translateY(0); opacity: 0; }
    10%  { opacity: 0.16; }
    90%  { opacity: 0.16; }
    100% { transform: translateY(140vh); opacity: 0; }
}

.ambient-dot {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--celadon);
    opacity: 0.3;
}

.ambient-dot--1 { top: 22%; left: 18%; animation: pulse 2.7s ease-in-out infinite; }
.ambient-dot--2 { top: 58%; left: 76%; animation: pulse 3.8s ease-in-out infinite; }
.ambient-dot--3 { top: 76%; left: 28%; animation: pulse 5.1s ease-in-out infinite; }
.ambient-dot--4 { top: 12%; left: 64%; animation: pulse 3.3s ease-in-out infinite; }
.ambient-dot--5 { top: 88%; left: 52%; animation: pulse 4.5s ease-in-out infinite; }

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50%      { transform: scale(1.6); opacity: 0.7; }
}

/* ============== Site mark ============== */

.site-mark {
    position: fixed;
    top: clamp(1.5rem, 3vh, 2.5rem);
    left: clamp(1.5rem, 4vw, 3rem);
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: 'Gowun Batang', 'Noto Serif KR', serif;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    color: var(--fg);
    transition: color 200ms ease;
    mix-blend-mode: difference;
    color: #888;
}

.site-mark__dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--persimmon);
}

/* ============== Jamo navigation ============== */

.jamo-nav {
    position: fixed;
    top: 50%;
    right: clamp(1.25rem, 3vw, 2.5rem);
    transform: translateY(-50%);
    z-index: 50;
}

.jamo-nav ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: clamp(1rem, 2.5vh, 1.75rem);
}

.jamo-nav__item {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--fg);
    font-family: 'Noto Serif KR', serif;
    font-size: 1.4rem;
    font-weight: 700;
    opacity: 0.4;
    transition: opacity 300ms ease, color 200ms ease;
    cursor: pointer;
    position: relative;
}

.jamo-nav__char {
    display: inline-block;
    width: 1.4rem;
    text-align: center;
    line-height: 1;
}

.jamo-nav__line {
    display: inline-block;
    height: 1px;
    width: 0;
    background: var(--accent);
    transition: width 250ms ease;
    order: -1;
}

.jamo-nav__item:hover .jamo-nav__line {
    width: 2rem;
}

.jamo-nav__item.is-active {
    opacity: 1;
    animation: jamo-pulse 2s ease-in-out infinite;
    color: var(--accent);
}

@keyframes jamo-pulse {
    0%, 100% { opacity: 0.55; }
    50%      { opacity: 1; }
}

/* ============== Scroll container & zones ============== */

.scroll-container {
    position: relative;
    z-index: 5;
}

.zone {
    position: relative;
    min-height: 100vh;
    padding: clamp(4rem, 10vh, 8rem) clamp(1.5rem, 6vw, 6rem);
    display: flex;
    align-items: center;
    scroll-snap-align: center;
    overflow: hidden;
}

.zone__eyebrow {
    font-family: 'Gowun Batang', 'Noto Serif KR', serif;
    font-size: 0.85rem;
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ash);
    margin-bottom: 1.25rem;
}

.zone--siot .zone__eyebrow {
    color: var(--sky);
}

.zone__title {
    font-family: 'Noto Serif KR', serif;
    font-weight: 900;
    font-size: clamp(2.6rem, 5vw, 4.5rem);
    line-height: 1.05;
    letter-spacing: -0.01em;
    margin-bottom: 0.4rem;
}

.zone__subtitle {
    font-family: 'Gowun Batang', 'Noto Serif KR', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.4vw, 1.35rem);
    color: var(--ash);
    margin-bottom: 2rem;
    letter-spacing: 0.04em;
}

.zone--siot .zone__subtitle { color: var(--sky); }

.zone__body {
    font-size: var(--body);
    line-height: var(--leading);
    margin-bottom: 1.4rem;
    max-width: 38ch;
}

.zone__body em {
    font-style: normal;
    font-family: 'Noto Serif KR', serif;
    font-weight: 700;
    color: var(--accent);
    transition: transform 150ms ease;
    display: inline-block;
}

.zone__body em:hover {
    transform: scale(1.03);
    text-decoration: underline;
    text-decoration-color: var(--persimmon);
    text-underline-offset: 4px;
}

.zone__caption {
    font-family: 'Gowun Batang', 'Noto Serif KR', serif;
    font-size: 0.85rem;
    color: var(--ash);
    letter-spacing: 0.04em;
    margin-top: 2rem;
    line-height: 1.6;
}

.zone--siot .zone__caption {
    color: var(--sky);
    font-style: italic;
}

/* ---- Hero jamo positioning per zone ---- */

.zone__hero-jamo {
    position: absolute;
    pointer-events: none;
    z-index: 1;
}

.hero-char {
    font-family: 'Noto Serif KR', serif;
    font-weight: 900;
    font-size: var(--display);
    line-height: 0.85;
    color: var(--ink);
    opacity: 0.06;
    user-select: none;
}

/* ---- Brush stroke SVG ---- */

.brush-stroke {
    width: 100%;
    height: 100%;
    display: block;
    filter: blur(0.5px);
    overflow: visible;
}

.brush-path {
    stroke-dasharray: 1500;
    stroke-dashoffset: 1500;
    transition: stroke-dashoffset 0s;
}

.brush-path--shadow {
    stroke-dashoffset: 0;
}

.zone.is-active .brush-path,
.zone.has-drawn .brush-path {
    transition: stroke-dashoffset 1.8s cubic-bezier(0.65, 0, 0.35, 1), opacity 200ms ease-out 1.8s;
    stroke-dashoffset: 0;
}

.zone.has-drawn .brush-path:not(.brush-path--shadow) {
    opacity: 0.85;
}

/* Stagger for multi-stroke chars */
.zone.is-active .brush-path--mieum-1,
.zone.has-drawn .brush-path--mieum-1 { transition-delay: 0s, 1.8s; }
.zone.is-active .brush-path--mieum-2,
.zone.has-drawn .brush-path--mieum-2 { transition-delay: 0.4s, 2.2s; }
.zone.is-active .brush-path--mieum-3,
.zone.has-drawn .brush-path--mieum-3 { transition-delay: 0.8s, 2.6s; }
.zone.is-active .brush-path--mieum-4,
.zone.has-drawn .brush-path--mieum-4 { transition-delay: 1.2s, 3.0s; }

.zone.is-active .brush-path--siot-1,
.zone.has-drawn .brush-path--siot-1 { transition-delay: 0s, 1.8s; }
.zone.is-active .brush-path--siot-2,
.zone.has-drawn .brush-path--siot-2 { transition-delay: 0.4s, 2.2s; }

.zone.is-active .brush-path--ring,
.zone.has-drawn .brush-path--ring {
    transition: stroke-dashoffset 8s linear, opacity 200ms ease-out 8s;
    stroke-dasharray: 1600;
    stroke-dashoffset: 0;
}
.brush-path--ring {
    stroke-dasharray: 1600;
    stroke-dashoffset: 1600;
}

/* Ink bloom radial */

.ink-bloom {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
}

.zone.is-active .ink-bloom,
.zone.has-drawn .ink-bloom {
    animation: ink-bloom 3s ease-out forwards;
}

@keyframes ink-bloom {
    0% {
        background: radial-gradient(circle at 50% 50%, rgba(26,26,26,0.18) 0px, transparent 1px);
        opacity: 1;
    }
    100% {
        background: radial-gradient(circle at 50% 50%, rgba(26,26,26,0.03) 300px, transparent 360px);
        opacity: 1;
    }
}

/* ---- ZONE 1: ㄱ giyeok ---- */

.zone--giyeok .zone__hero-jamo--left {
    left: -8vw;
    top: 50%;
    transform: translateY(-50%);
    width: clamp(28rem, 55vw, 60rem);
    height: clamp(28rem, 55vw, 60rem);
}

.zone--giyeok .zone__hero-jamo--left .hero-char {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zone--giyeok .zone__hero-jamo--left .brush-stroke {
    position: absolute;
    inset: 0;
}

.zone__content--right {
    margin-left: clamp(20vw, 25vw, 35vw);
    max-width: 38ch;
    position: relative;
    z-index: 3;
    padding-right: 5vw;
}

/* ---- ZONE 2: ㄴ nieun ---- */

.zone--nieun {
    justify-content: center;
    text-align: center;
}

.zone--nieun .zone__hero-jamo--drift {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.06;
    animation: slow-rotate 720s linear infinite;
}

.zone--nieun .zone__hero-jamo--drift .brush-stroke {
    width: clamp(32rem, 70vh, 60rem);
    height: clamp(32rem, 70vh, 60rem);
}

@keyframes slow-rotate {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.zone__content--center {
    max-width: 38ch;
    margin: 0 auto;
    text-align: left;
    position: relative;
    z-index: 3;
}

.zone--nieun .zone__title,
.zone--nieun .zone__subtitle,
.zone--nieun .zone__eyebrow {
    text-align: center;
}

/* ---- ZONE 3: ㅁ mieum bento ---- */

.zone--mieum {
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
}

.zone__header {
    max-width: 1100px;
    margin: 0 auto clamp(2rem, 4vh, 3.5rem);
    width: 100%;
    padding: 0 clamp(0rem, 2vw, 2rem);
}

.bento {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 2vmin;
    width: min(1100px, 100%);
    margin: 0 auto;
    aspect-ratio: 16 / 11;
    max-height: 70vh;
}

.bento__cell {
    background: rgba(26, 26, 26, 0.025);
    border-radius: 2px;
    padding: clamp(1rem, 2.5vw, 2.25rem);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(26, 26, 26, 0.06);
}

.bento__cell--char {
    background: rgba(123, 166, 140, 0.08);
    align-items: center;
    justify-content: center;
}

.bento__cell--char .brush-stroke {
    width: 70%;
    height: 70%;
}

.bento__cell-label {
    position: absolute;
    bottom: 0.9rem;
    right: 1rem;
    font-family: 'Gowun Batang', serif;
    font-size: 0.78rem;
    color: var(--ash);
    letter-spacing: 0.06em;
}

.bento__cell-eyebrow {
    font-family: 'Gowun Batang', serif;
    font-size: 0.78rem;
    color: var(--ash);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.bento__cell-body {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--fg);
}

.bento__cell-body em {
    font-family: 'Noto Serif KR', serif;
    font-style: italic;
    font-weight: 400;
    color: var(--ash);
}

.bento__cell-note {
    margin-top: auto;
    font-family: 'Gowun Batang', serif;
    font-size: 0.78rem;
    color: var(--ash);
    letter-spacing: 0.04em;
}

.vowel-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem;
    font-family: 'Noto Serif KR', serif;
    font-weight: 700;
    font-size: clamp(1.1rem, 1.6vw, 1.6rem);
    color: var(--ink);
    margin-bottom: 1rem;
    flex: 1;
    align-content: center;
    text-align: center;
}

.vowel-grid span {
    display: inline-block;
    transition: transform 150ms ease, color 150ms ease;
    cursor: default;
}

.vowel-grid span:hover {
    transform: scale(1.15);
    color: var(--persimmon);
}

.swatch-stack {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.4rem;
    flex: 1;
    align-content: center;
    margin: 0.5rem 0;
}

.swatch {
    aspect-ratio: 1;
    background: var(--c);
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06) inset;
}

/* ---- ZONE 4: ㅅ siot diagonal indigo ---- */

.zone--siot {
    align-items: center;
}

.zone--siot .zone__hero-jamo--skew {
    position: absolute;
    right: -4vw;
    top: 50%;
    transform: translateY(-50%) skew(-3deg);
    width: clamp(26rem, 45vw, 50rem);
    height: clamp(26rem, 45vw, 50rem);
    opacity: 0.85;
}

.zone__content--diagonal {
    position: relative;
    z-index: 3;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1.618fr;
    gap: clamp(2rem, 5vw, 5rem);
    transform: skewY(-3deg);
}

.zone__content--diagonal > * {
    transform: skewY(3deg);
}

.zone__col--narrow {
    padding-top: 4rem;
}

.zone__col--wide .zone__body {
    max-width: 48ch;
}

.zone--siot .zone__body em {
    color: var(--sky);
}

/* ---- ZONE 5: ㅇ ieung radial ---- */

.zone--ieung {
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.radial {
    position: relative;
    width: min(720px, 86vmin);
    height: min(720px, 86vmin);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.radial .brush-stroke {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.radial__center {
    position: relative;
    z-index: 3;
    text-align: center;
    max-width: 38ch;
    padding: 0 clamp(1rem, 4vw, 3rem);
}

.zone__title--quiet {
    font-size: clamp(2rem, 3.5vw, 3rem);
    font-weight: 700;
}

.quote {
    margin-top: 2rem;
    font-family: 'Noto Serif KR', serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.85;
    color: var(--ink);
    font-style: italic;
}

.quote p {
    margin-bottom: 1.2rem;
}

.quote__attr {
    font-family: 'Gowun Batang', serif;
    font-style: normal;
    font-size: 0.85rem;
    color: var(--ash);
    letter-spacing: 0.04em;
}

.radial__node {
    position: absolute;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Noto Serif KR', serif;
    font-weight: 700;
    font-size: 1.6rem;
    color: var(--ash);
    opacity: 0.4;
    animation: jamo-pulse 4s ease-in-out infinite;
}

.radial__node--n1 { top: 4%;  left: 50%; transform: translateX(-50%); }
.radial__node--n2 { top: 28%; right: 4%; }
.radial__node--n3 { bottom: 10%; right: 14%; animation-delay: -1s; }
.radial__node--n4 { bottom: 10%; left: 14%; animation-delay: -2s; }
.radial__node--n5 { top: 28%; left: 4%; animation-delay: -3s; }

.site-foot {
    margin-top: clamp(2rem, 5vh, 4rem);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    font-family: 'Gowun Batang', serif;
    font-size: 0.78rem;
    color: var(--ash);
    letter-spacing: 0.1em;
    text-align: center;
}

.site-foot__mark {
    color: var(--persimmon);
}

/* ---- Bojagi seam dividers ---- */

.bojagi-seam {
    height: 130px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 1rem 0;
    position: relative;
    z-index: 4;
}

.patch {
    display: inline-block;
    width: var(--w);
    height: var(--h);
    background: var(--c);
    opacity: var(--o);
    transform: rotate(var(--r));
    border-radius: 1px;
    margin: 0 -8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

/* ---- Click ripple ---- */

.ripple {
    position: fixed;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(123, 166, 140, 0.3);
    pointer-events: none;
    transform: translate(-50%, -50%) scale(1);
    animation: ripple 600ms ease-out forwards;
    z-index: 100;
}

@keyframes ripple {
    0%   { transform: translate(-50%, -50%) scale(1); opacity: 0.5; }
    100% { transform: translate(-50%, -50%) scale(20); opacity: 0; }
}

/* ---- Body theming when indigo zone is active ---- */

body[data-active-zone="4"] {
    background: var(--indigo);
    color: var(--hanji);
}

body[data-active-zone="4"] .site-mark {
    color: var(--sky);
}

body[data-active-zone="4"] .jamo-nav__item {
    color: var(--hanji);
}

body[data-active-zone="4"] .jamo-nav__item.is-active {
    color: var(--sky);
}

body[data-active-zone="4"] .ambient-line {
    background: var(--sky);
    opacity: 0.22;
}

body[data-active-zone="4"] .ambient-dot {
    background: var(--sky);
}

/* ---- Responsive ---- */

@media (max-width: 768px) {
    .zone {
        padding: 4rem 1.25rem;
    }

    .zone__content--right {
        margin-left: 0;
        padding-right: 0;
        padding-top: 30vh;
    }

    .zone--giyeok .zone__hero-jamo--left {
        left: -20vw;
        width: 28rem;
        height: 28rem;
    }

    .bento {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(4, minmax(180px, auto));
        aspect-ratio: auto;
        max-height: none;
    }

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

    .swatch-stack {
        grid-template-columns: repeat(6, 1fr);
    }

    .zone__content--diagonal {
        grid-template-columns: 1fr;
    }

    .jamo-nav {
        right: 0.75rem;
    }

    .jamo-nav__item {
        font-size: 1.1rem;
    }

    .radial__node {
        font-size: 1.1rem;
        width: 2rem;
        height: 2rem;
    }
}
