/* ============================================================
   jeongchi.boo — wabi-sabi political séance
   Colors: navy field + silver text + burnished gold accents
   ============================================================ */

:root {
    /* Palette (from DESIGN.md) */
    --deep-navy: #0a0e1a;
    --midnight-blue: #131b2e;
    --tarnished-silver: #c4c9d4;
    --oxidized-silver: #8a8a9a;
    --burnished-gold: #b8945f;
    --pewter: #6b7280;
    --porcelain: #e8e4dd;
    --spectral-cerulean: #2d5a7b;

    /* Soft layered shadow */
    --shadow-card: 0 8px 32px rgba(10, 14, 26, 0.6);
    --shadow-card-soft: 0 4px 18px rgba(10, 14, 26, 0.55);

    /* Font families — Caveat (handwritten display),
       Noto Serif KR (body), Nanum Pen Script (annotation),
       IBM Plex Mono (metadata). All Google Fonts. */
    --font-display: "Caveat", "Noto Serif KR", serif;
    --font-body: "Noto Serif KR", "Inter", serif;
    --font-hand: "Nanum Pen Script", "Caveat", cursive;
    --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

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

html {
    scroll-behavior: smooth;
    background: var(--deep-navy);
}

body {
    background: var(--deep-navy);
    color: var(--tarnished-silver);
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(1rem, 1.6vw, 1.25rem);
    line-height: 1.85;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    min-height: 100vh;
    position: relative;
}

/* ============================================================
   BACKGROUND PLANE — hanji paper texture
   ============================================================ */
.hanji-texture {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    background-color: var(--deep-navy);
    background-image:
        radial-gradient(circle at 12% 20%, rgba(196, 201, 212, 0.025) 0, transparent 2px),
        radial-gradient(circle at 78% 65%, rgba(196, 201, 212, 0.02) 0, transparent 1.5px),
        radial-gradient(circle at 44% 88%, rgba(196, 201, 212, 0.025) 0, transparent 2px),
        radial-gradient(circle at 30% 40%, rgba(196, 201, 212, 0.015) 0, transparent 1px),
        radial-gradient(circle at 92% 12%, rgba(196, 201, 212, 0.02) 0, transparent 1.5px),
        radial-gradient(circle at 8% 72%, rgba(196, 201, 212, 0.018) 0, transparent 1px),
        radial-gradient(1200px 900px at 70% 15%, rgba(19, 27, 46, 0.65) 0%, transparent 70%),
        radial-gradient(900px 700px at 15% 85%, rgba(19, 27, 46, 0.55) 0%, transparent 70%);
    background-size: 180px 180px, 240px 240px, 300px 300px, 120px 120px, 220px 220px, 160px 160px, 100% 100%, 100% 100%;
    transition: opacity 800ms ease-out;
}

body.loaded .hanji-texture {
    opacity: 1;
}

/* A secondary fibrous overlay for extra hanji grain */
.hanji-texture::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(
            102deg,
            transparent 0,
            transparent 3px,
            rgba(196, 201, 212, 0.012) 3px,
            rgba(196, 201, 212, 0.012) 4px
        ),
        repeating-linear-gradient(
            15deg,
            transparent 0,
            transparent 5px,
            rgba(138, 138, 154, 0.008) 5px,
            rgba(138, 138, 154, 0.008) 6px
        );
    mix-blend-mode: screen;
}

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

/* ============================================================
   PROGRESS INK BRUSH (left edge)
   ============================================================ */
.progress-track {
    position: fixed;
    left: 0;
    top: 0;
    width: 2px;
    height: 100vh;
    background: rgba(138, 138, 154, 0.1);
    z-index: 40;
    pointer-events: none;
}

.progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 0%;
    background: linear-gradient(180deg, var(--burnished-gold) 0%, rgba(184, 148, 95, 0.45) 100%);
    box-shadow: 0 0 6px rgba(184, 148, 95, 0.35);
    transition: height 80ms linear;
}

/* ============================================================
   HOME ANCHOR — brushstroke 政
   ============================================================ */
.home-anchor {
    position: fixed;
    top: 32px;
    left: 36px;
    width: 64px;
    height: 64px;
    z-index: 50;
    text-decoration: none;
    color: var(--burnished-gold);
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
    opacity: 0;
    transition: opacity 600ms ease-out;
}

body.loaded .home-anchor {
    opacity: 1;
}

.brush-char {
    fill: none;
    stroke: var(--burnished-gold);
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    animation: drawBrush 2s ease-in-out 1s forwards;
}

@keyframes drawBrush {
    to {
        stroke-dashoffset: 0;
    }
}

/* ============================================================
   GHOST PLANE (z: 2) — parallax line illustrations
   ============================================================ */
.ghost-plane {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
    width: 100%;
    height: 100%;
}

.ghost {
    position: absolute;
    will-change: transform, opacity;
    opacity: 0.1;
    transition: opacity 1200ms ease;
    filter: url(#inkWobble);
}

.ghost--peninsula {
    top: 18vh;
    right: 6vw;
    width: clamp(200px, 22vw, 360px);
    opacity: 0.12;
}

.ghost--bluehouse {
    top: 130vh;
    left: 8vw;
    width: clamp(260px, 32vw, 480px);
    opacity: 0.1;
}

.ghost--hanja-min {
    top: 220vh;
    right: 10vw;
    width: clamp(180px, 20vw, 280px);
    opacity: 0.1;
}

.ghost--hanja-ui {
    top: 360vh;
    left: 52vw;
    width: clamp(140px, 16vw, 220px);
    opacity: 0.09;
}

.ghost--seal {
    top: 470vh;
    right: 14vw;
    width: clamp(160px, 18vw, 260px);
    opacity: 0.13;
}

.ghost--gwanghwa {
    top: 540vh;
    left: 6vw;
    width: clamp(280px, 34vw, 500px);
    opacity: 0.1;
}

.ghost--hanja-beop {
    top: 300vh;
    left: 6vw;
    width: clamp(160px, 18vw, 240px);
    opacity: 0.09;
}

/* ============================================================
   SCROLL ROOT & SCENES (z: 1 — content plane)
   ============================================================ */
.scroll-root {
    position: relative;
    z-index: 10;
    padding-left: clamp(80px, 8vw, 140px);
    padding-right: clamp(24px, 4vw, 60px);
}

.scene {
    position: relative;
    min-height: 100vh;
    padding: clamp(90px, 14vh, 160px) 0 clamp(60px, 10vh, 120px) 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.7fr);
    grid-template-rows: auto auto auto;
    grid-template-areas:
        "head head"
        "body anno"
        "card card";
    column-gap: clamp(24px, 4vw, 80px);
    row-gap: clamp(32px, 5vh, 64px);
    align-items: start;
    background:
        linear-gradient(180deg,
            rgba(10, 14, 26, 0) 0%,
            rgba(19, 27, 46, 0.25) 50%,
            rgba(10, 14, 26, 0) 100%
        );
}

/* f-pattern brow (20% from top) — headline spans left */
.scene-head {
    grid-area: head;
    max-width: 80%;
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: relative;
    padding-top: 6vh;
}

.scene-index {
    font-family: var(--font-mono);
    font-weight: 300;
    font-size: 0.82rem;
    letter-spacing: 0.18em;
    color: var(--pewter);
    text-transform: uppercase;
    display: inline-block;
    padding-left: 4px;
}

.scene-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.5rem, 6vw, 5.5rem);
    line-height: 1.08;
    letter-spacing: 0.02em;
    color: var(--porcelain);
    position: relative;
    max-width: 60vw;
}

.scene-title .title-text {
    display: inline-block;
    position: relative;
}

.scene-title .title-text br {
    line-height: 1.15;
}

/* Gentle irregular baseline for the handwritten title */
.scene-title .title-text::first-letter {
    margin-left: -0.02em;
}

.scene-date {
    font-family: var(--font-hand);
    font-size: clamp(1rem, 1.4vw, 1.3rem);
    color: var(--oxidized-silver);
    letter-spacing: 0.02em;
    padding-left: 6px;
}

/* f-pattern shoulder (55%) — body text, left column 45% */
.scene-body {
    grid-area: body;
    max-width: 38em;
    width: 100%;
}

.body-text {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(1rem, 1.6vw, 1.25rem);
    line-height: 1.85;
    letter-spacing: 0.01em;
    color: var(--tarnished-silver);
    margin-bottom: 1.4em;
    max-width: 38em;
}

.body-text em {
    color: var(--porcelain);
    font-style: italic;
    font-weight: 400;
}

.body-text-sm {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.95rem, 1.3vw, 1.08rem);
    line-height: 1.75;
    color: var(--tarnished-silver);
}

.body-text-sm em {
    color: var(--porcelain);
    font-style: italic;
}

/* Right-margin annotation */
.annotation {
    grid-area: anno;
    font-family: var(--font-hand);
    font-size: clamp(0.95rem, 1.25vw, 1.15rem);
    color: var(--oxidized-silver);
    line-height: 1.5;
    position: relative;
    padding: 20px 18px 20px 20px;
    border-left: 1px solid rgba(184, 148, 95, 0.3);
    margin-top: 8vh;
    max-width: 26em;
}

.anno-crack {
    display: block;
    width: 100%;
    height: 30px;
    margin-bottom: 10px;
    opacity: 0.85;
}

.anno-text {
    display: block;
}

/* Content card (z: 1, floats above background) */
.content-card {
    grid-area: card;
    position: relative;
    background: var(--midnight-blue);
    border: 1px solid rgba(138, 138, 154, 0.2);
    border-radius: 4px;
    padding: clamp(28px, 4vw, 44px) clamp(28px, 4vw, 52px);
    box-shadow: var(--shadow-card);
    max-width: 820px;
    margin-top: 3vh;
    margin-left: 0;
    margin-right: auto;
    width: min(100%, 820px);
    transition: transform 600ms ease, box-shadow 600ms ease;
    overflow: hidden;
}

.content-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 42px rgba(10, 14, 26, 0.7);
}

.card-label {
    font-family: var(--font-mono);
    font-weight: 300;
    font-size: 0.78rem;
    letter-spacing: 0.2em;
    color: var(--pewter);
    text-transform: uppercase;
    margin-bottom: 1em;
}

.card-body {
    position: relative;
    z-index: 2;
}

.meta-line {
    margin-top: 1.2em;
    padding-top: 0.8em;
    border-top: 1px solid rgba(138, 138, 154, 0.15);
    display: flex;
    gap: 14px;
    align-items: baseline;
    flex-wrap: wrap;
}

.meta-label {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.14em;
    color: var(--pewter);
    text-transform: uppercase;
}

.meta-value {
    font-family: var(--font-mono);
    font-size: 0.88rem;
    letter-spacing: 0.08em;
    color: var(--burnished-gold);
}

/* ============================================================
   KINTSUGI CRACKS (SVG paths along card edges)
   ============================================================ */
.crack {
    position: absolute;
    pointer-events: none;
    overflow: visible;
}

.crack--top {
    top: -6px;
    left: 0;
    width: 100%;
    height: 30px;
}

.crack--bottom {
    bottom: -6px;
    left: 0;
    width: 100%;
    height: 30px;
}

.crack--left {
    top: 0;
    left: -6px;
    width: 30px;
    height: 100%;
}

.crack--right {
    top: 0;
    right: -6px;
    width: 30px;
    height: 100%;
}

.kintsugi-path {
    fill: none;
    stroke: var(--burnished-gold);
    stroke-width: 1.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.7;
}

/* When cracks are in the draw state — set by JS */
.crack .kintsugi-path,
.anno-crack .kintsugi-path,
.kintsugi-bridge-path,
.colophon-crack .kintsugi-path {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    transition: stroke-dashoffset 2000ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.crack.is-drawing .kintsugi-path,
.anno-crack.is-drawing .kintsugi-path,
.kintsugi-bridge-path.is-drawing,
.colophon-crack.is-drawing .kintsugi-path {
    stroke-dashoffset: 0;
    animation: kintsugiPulse 4s ease-in-out 2.2s infinite;
}

@keyframes kintsugiPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.78; }
}

/* ============================================================
   BREATHING ZONE — between scenes, with seal & bridge
   ============================================================ */
.breathing-zone {
    position: relative;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    background:
        radial-gradient(ellipse at 50% 50%, rgba(19, 27, 46, 0.55) 0%, transparent 70%);
}

.seal-impression {
    position: absolute;
    top: 50%;
    left: 50%;
    width: clamp(80px, 9vw, 130px);
    height: clamp(80px, 9vw, 130px);
    transform: translate(-50%, -50%) scale(0.82) rotate(-2deg);
    opacity: 0.55;
    transition: transform 900ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 900ms ease;
}

.seal-impression.is-active {
    transform: translate(-50%, -50%) scale(1) rotate(1deg);
    opacity: 0.9;
}

.kintsugi-bridge {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 20px;
    transform: translateY(-50%);
    pointer-events: none;
    overflow: visible;
}

/* ============================================================
   SKELETON SHIMMER
   ============================================================ */
.skeleton {
    position: absolute;
    inset: 0;
    background: var(--midnight-blue);
    border-radius: 4px;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
}

.skeleton::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(45, 90, 123, 0.1) 50%,
        transparent 100%
    );
    background-size: 200% 100%;
    background-position: -150% 0;
    animation: shimmer 1.5s linear infinite;
}

@keyframes shimmer {
    0% { background-position: -150% 0; }
    100% { background-position: 250% 0; }
}

.skeleton.fade-out {
    opacity: 0;
    transition: opacity 500ms ease-out;
}

/* Scene-title skeleton shell */
.scene-title .skeleton {
    position: absolute;
    top: 10%;
    left: 0;
    width: 70%;
    height: 80%;
    display: block;
}

.scene-title .title-text {
    opacity: 0;
    transition: opacity 700ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                filter 700ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
    filter: blur(3px);
    position: relative;
    z-index: 2;
}

.scene-title.is-revealed .title-text {
    opacity: 1;
    filter: blur(0);
}

.scene-title.is-revealed .skeleton {
    opacity: 0;
    pointer-events: none;
}

/* ============================================================
   REVEAL ANIMATIONS (Intersection Observer)
   ============================================================ */
.reveal,
.reveal-blur {
    opacity: 0;
    transition: opacity 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                filter 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.reveal-blur {
    filter: blur(3px);
}

.reveal.is-in,
.reveal-blur.is-in {
    opacity: 1;
    filter: blur(0);
}

/* Stagger child body texts */
.scene-body .body-text.reveal-blur {
    transition-delay: 0ms;
}

.scene-body .body-text.reveal-blur:nth-child(2) {
    transition-delay: 120ms;
}

.scene-body .body-text.reveal-blur:nth-child(3) {
    transition-delay: 240ms;
}

/* ============================================================
   COLOPHON (closing)
   ============================================================ */
.colophon {
    position: relative;
    z-index: 10;
    padding: clamp(80px, 12vh, 140px) clamp(80px, 8vw, 140px) clamp(60px, 10vh, 100px);
    text-align: left;
    border-top: 1px solid rgba(138, 138, 154, 0.1);
    background:
        linear-gradient(180deg,
            rgba(10, 14, 26, 0) 0%,
            rgba(19, 27, 46, 0.3) 100%
        );
}

.colophon-line {
    margin-bottom: 2em;
}

.colophon-crack {
    display: block;
    width: 100%;
    max-width: 800px;
    height: 20px;
}

.colophon-text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.4rem);
    line-height: 1.3;
    color: var(--porcelain);
    letter-spacing: 0.02em;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 14px;
    margin-bottom: 1em;
}

.colophon-char {
    font-family: var(--font-body);
    font-weight: 500;
    color: var(--burnished-gold);
    font-size: 1.2em;
    padding: 0 0.1em;
}

.colophon-domain {
    font-family: var(--font-display);
    color: var(--porcelain);
}

.colophon-tag {
    font-family: var(--font-body);
    font-size: 0.5em;
    color: var(--oxidized-silver);
    letter-spacing: 0.05em;
    font-weight: 300;
    line-height: 1.6;
    max-width: 40em;
}

.colophon-meta {
    font-family: var(--font-hand);
    font-size: clamp(0.95rem, 1.2vw, 1.15rem);
    color: var(--oxidized-silver);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.colophon-meta .divider {
    color: var(--burnished-gold);
    opacity: 0.6;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .scene {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "head"
            "body"
            "anno"
            "card";
        row-gap: 32px;
    }

    .scene-head {
        max-width: 100%;
    }

    .scene-title {
        max-width: 100%;
    }

    .annotation {
        margin-top: 0;
        border-left: 1px solid rgba(184, 148, 95, 0.3);
    }
}

@media (max-width: 768px) {
    .scroll-root {
        padding-left: clamp(40px, 8vw, 70px);
        padding-right: clamp(20px, 5vw, 40px);
    }

    .home-anchor {
        top: 20px;
        left: 18px;
        width: 48px;
        height: 48px;
    }

    .home-anchor svg {
        width: 48px;
        height: 48px;
    }

    .scene {
        padding: 80px 0 60px 0;
    }

    .ghost--peninsula,
    .ghost--hanja-min,
    .ghost--hanja-beop,
    .ghost--gwanghwa {
        opacity: 0.06;
    }

    .ghost--bluehouse,
    .ghost--hanja-ui,
    .ghost--seal {
        display: none;
    }

    .content-card {
        padding: 24px 22px;
    }

    .colophon {
        padding: 80px 30px 60px 60px;
    }

    .colophon-text {
        font-size: clamp(1.3rem, 6vw, 2rem);
    }
}

/* ============================================================
   Misc: small wobble on handwritten titles
   ============================================================ */
.scene-title.is-revealed .title-text {
    animation: baselineWobble 12s ease-in-out infinite;
}

@keyframes baselineWobble {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-0.5px) rotate(-0.15deg); }
    50% { transform: translateY(0.3px) rotate(0.1deg); }
    75% { transform: translateY(-0.2px) rotate(-0.08deg); }
}
