/* =========================================================
   ipjosim.com — 입조심 — a quiet practice of guarding the mouth
   palette : burgundy-cream (1% rarity)
   register: japanese-minimal · scholarly · ma-negative-space
   ========================================================= */

:root {
    --jangji-cream: #F4ECDB;     /* primary page ground */
    --hanji-deep:   #EFE4CD;     /* foregrounded card paper */
    --meok-burgundy:#3C121C;     /* deepest ink-burgundy */
    --seokryu:      #7A2838;     /* pomegranate burgundy */
    --muted-rose:   #9B6B72;     /* marginalia, captions */
    --night-ink:    #1D1214;     /* warm body-text */
    --old-brass:    #C8AE8A;     /* single muted gold */

    --rule-soft: rgba(60, 18, 28, 0.06);
    --rule-mid:  rgba(60, 18, 28, 0.18);
    --rule-strong: rgba(60, 18, 28, 0.32);

    --gutter: clamp(28px, 4vw, 72px);
    --max-width: 1440px;
    --rail-offset: clamp(28px, 4vw, 64px);

    --serif-cjk: "Noto Serif KR", "Shippori Mincho", serif;
    --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

    --reveal-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--jangji-cream);
    color: var(--night-ink);
    font-family: var(--mono);
    font-weight: 400;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: geometricPrecision;
    overflow-x: hidden;
    cursor: none;
}

body {
    min-height: 100vh;
    position: relative;
}

/* ---------- Paper-tooth grain (1.5% over body) ---------- */

.grain-filter {
    position: fixed;
    width: 0;
    height: 0;
    pointer-events: none;
    visibility: hidden;
}

.grain-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.045;
    mix-blend-mode: multiply;
    background:
        radial-gradient(circle at 13% 17%, rgba(60,18,28,0.12), transparent 38%),
        radial-gradient(circle at 87% 83%, rgba(60,18,28,0.08), transparent 42%);
    filter: url(#paper-grain);
}

/* ---------- Custom cursor (1px hairline kūhaku ring) ---------- */

.cursor-ring {
    position: fixed;
    top: 0;
    left: 0;
    width: 12px;
    height: 12px;
    border: 1px solid var(--seokryu);
    border-radius: 50%;
    pointer-events: none;
    z-index: 1100;
    transform: translate(-50%, -50%);
    transition: opacity 220ms var(--reveal-ease);
    opacity: 0;
    background: transparent;
}

.cursor-ring.is-visible {
    opacity: 1;
}

@media (hover: none), (pointer: coarse) {
    html, body { cursor: auto; }
    .cursor-ring { display: none; }
}

/* ---------- The vertical breath rail ---------- */

.breath-rail {
    position: fixed;
    top: 0;
    left: var(--rail-offset);
    height: 100vh;
    width: 24px;
    z-index: 5;
    pointer-events: none;
}

.breath-rail .rail-line {
    position: absolute;
    top: 8vh;
    bottom: 8vh;
    left: 11px;
    width: 1px;
    background: var(--seokryu);
    opacity: 0.55;
}

.breath-rail .rail-numeral {
    position: fixed;
    left: var(--rail-offset);
    width: 24px;
    text-align: center;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--muted-rose);
    letter-spacing: 0.10em;
    transform: translateX(-2px);
    opacity: 0;
    transition: opacity 600ms var(--reveal-ease), color 800ms var(--reveal-ease);
}

.breath-rail .rail-numeral.is-active {
    opacity: 0.95;
    color: var(--seokryu);
}

@media (max-width: 720px) {
    .breath-rail { display: none; }
}

/* ---------- Page wrapper ---------- */

.page {
    position: relative;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 clamp(40px, 7vw, 120px);
    z-index: 2;
}

@media (min-width: 720px) {
    .page {
        padding-left: clamp(96px, 11vw, 180px);
    }
}

/* ---------- §01 — The Threshold ---------- */

.threshold {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 38vh;
    padding-bottom: 8vh;
}

.threshold-inner {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    max-width: 920px;
}

.threshold-hanja {
    font-family: var(--serif-cjk);
    font-weight: 900;
    color: var(--meok-burgundy);
    font-size: clamp(7rem, 14vw, 12rem);
    line-height: 1;
    letter-spacing: -0.04em;
    margin: 0 0 clamp(28px, 4vw, 56px) 0;
    user-select: none;
}

.threshold-mono {
    font-family: var(--mono);
    font-size: clamp(1.0rem, 1.25vw, 1.15rem);
    font-weight: 500;
    color: var(--night-ink);
    letter-spacing: 0.06em;
    line-height: 1.55;
    text-transform: lowercase;
    margin: 0;
    max-width: 56ch;
}

.threshold-spacer {
    display: block;
    height: 200px;
}

.threshold-numeral {
    font-family: var(--mono);
    font-size: 0.92rem;
    color: var(--seokryu);
    letter-spacing: 0.12em;
    margin-top: 8px;
}

/* ---------- §02 — Masonry ---------- */

.masonry {
    position: relative;
    column-count: 3;
    column-gap: var(--gutter);
    padding-top: clamp(40px, 6vw, 96px);
    padding-bottom: clamp(80px, 10vw, 160px);
    /* progressive enhancement for masonry where supported */
}

@supports (grid-template-rows: masonry) {
    .masonry {
        column-count: unset;
        display: grid;
        grid-template-columns: repeat(12, 1fr);
        grid-template-rows: masonry;
        gap: var(--gutter);
    }
}

@media (max-width: 1180px) {
    .masonry { column-count: 2; }
}

@media (max-width: 720px) {
    .masonry { column-count: 1; }
}

/* irregular column-spans (only meaningful when masonry grid is supported) */

@supports (grid-template-rows: masonry) {
    .card-span-3 { grid-column: span 4; }
    .card-span-4 { grid-column: span 5; }
    .card-span-5 { grid-column: span 6; }
    .card-span-6 { grid-column: span 8; }

    /* hand-tuned offsets so adjacent cards never share the same start column */
    .card-chapter[data-chapter="1"] { grid-column: 1 / span 8; }
    .card-chapter[data-chapter="2"] { grid-column: 4 / span 8; }
    .card-chapter[data-chapter="3"] { grid-column: 1 / span 8; }
    .card-chapter[data-chapter="4"] { grid-column: 4 / span 8; }
    .card-chapter[data-chapter="5"] { grid-column: 2 / span 8; }
    .card-empty                    { grid-column: 3 / span 8; }
}

/* ---------- Cards: the shared base ---------- */

.card {
    position: relative;
    margin: 0 0 var(--gutter) 0;
    break-inside: avoid;
    background: transparent;
    color: var(--night-ink);
    /* fade-reveal initial state */
    opacity: 0;
    transform: translateY(12px);
    transition:
        opacity 600ms var(--reveal-ease),
        transform 600ms var(--reveal-ease);
}

.card.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.card-inner {
    position: relative;
    padding: clamp(20px, 2.4vw, 36px) clamp(20px, 2.6vw, 40px);
    min-height: 220px;
    max-height: 640px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: clamp(14px, 1.6vw, 22px);
}

/* ground cards: flush with page tone */
.card-illu .card-inner,
.card-quote .card-inner {
    background: transparent;
}

/* mid cards: 1px hairline + whisper shadow */
.card-quote .card-inner {
    border-top: 1px solid var(--rule-mid);
    box-shadow: 0 1px 0 var(--rule-soft);
    padding-top: clamp(24px, 2.6vw, 38px);
}

/* foreground cards: kakomi frame + cooler paper */
.card-foreground .card-inner {
    background: var(--hanji-deep);
    border: 1px solid var(--seokryu);
    box-shadow:
        0 1px 0 var(--rule-soft),
        inset 0 0 0 4px var(--hanji-deep),
        inset 0 0 0 5px rgba(122, 40, 56, 0.18);
    padding: clamp(28px, 3vw, 48px);
}

.card-empty .card-inner {
    padding: clamp(28px, 3vw, 44px) clamp(28px, 3vw, 44px) clamp(20px, 2vw, 32px);
}

/* ---------- Card content: chapter ---------- */

.chapter-hanja {
    font-family: var(--serif-cjk);
    font-weight: 900;
    color: var(--meok-burgundy);
    font-size: clamp(6rem, 12vw, 11rem);
    line-height: 1;
    letter-spacing: -0.04em;
    margin: 0;
    user-select: none;
}

.chapter-subhead {
    font-family: var(--mono);
    font-weight: 500;
    color: var(--night-ink);
    font-size: clamp(1.05rem, 1.6vw, 1.4rem);
    letter-spacing: 0.06em;
    line-height: 1.45;
    text-transform: lowercase;
    margin: 0;
}

.chapter-meta {
    font-family: var(--mono);
    font-weight: 400;
    color: var(--old-brass);
    font-size: 0.78rem;
    letter-spacing: 0.10em;
    margin: 0;
    text-transform: lowercase;
}

/* ---------- Card content: illustration ---------- */

.illu-wrap {
    width: clamp(72px, 9vw, 128px);
    aspect-ratio: 1 / 1;
    align-self: flex-start;
}

.illu-wrap.illu-tr  { align-self: flex-end; }
.illu-wrap.illu-bl  { align-self: flex-start; margin-top: auto; }

.illu {
    width: 100%;
    height: 100%;
    overflow: visible;
    color: var(--seokryu);
}

/* monoline burgundy strokes: the entire SVG inherits color via stroke="currentColor" */
.illu path,
.illu rect,
.illu ellipse,
.illu circle,
.illu line {
    stroke: currentColor;
    transition: stroke 800ms var(--reveal-ease);
}

.card-illu:hover .illu {
    color: var(--meok-burgundy);
}

.card-caption {
    font-family: var(--mono);
    font-weight: 400;
    color: var(--muted-rose);
    font-size: 0.82rem;
    letter-spacing: 0.10em;
    line-height: 1.6;
    text-transform: lowercase;
    margin: 0;
    max-width: 28ch;
}

/* ---------- Card content: quote ---------- */

.quote-cjk {
    font-family: var(--serif-cjk);
    font-weight: 400;
    color: var(--night-ink);
    font-size: clamp(1.1rem, 1.6vw, 1.45rem);
    line-height: 1.95;
    margin: 0;
    padding: 0;
    border: none;
    max-width: 32ch;
}

.quote-gloss {
    font-family: var(--mono);
    font-weight: 400;
    color: var(--muted-rose);
    font-size: 0.78rem;
    letter-spacing: 0.10em;
    line-height: 1.6;
    text-transform: lowercase;
    margin: 0;
}

.quote-trans {
    font-family: var(--mono);
    font-weight: 500;
    color: var(--night-ink);
    font-size: clamp(0.95rem, 1.1vw, 1.05rem);
    letter-spacing: 0.04em;
    line-height: 1.55;
    text-transform: lowercase;
    margin: 0;
    max-width: 36ch;
}

/* generic mono lines used inside small quote-cards */

.card-mono-line {
    font-family: var(--mono);
    font-weight: 500;
    color: var(--night-ink);
    font-size: clamp(0.98rem, 1.15vw, 1.1rem);
    letter-spacing: 0.04em;
    line-height: 1.7;
    text-transform: lowercase;
    margin: 0;
    max-width: 34ch;
}

.card-mono-line.large {
    font-size: clamp(1.1rem, 1.4vw, 1.3rem);
    letter-spacing: 0.02em;
    line-height: 1.55;
}

.card-mono-line.muted {
    color: var(--muted-rose);
    font-weight: 400;
}

.card-mono-line.small {
    font-size: 0.78rem;
    letter-spacing: 0.10em;
    margin-top: clamp(8px, 1vw, 16px);
}

/* ---------- Card content: foreground essay ---------- */

.essay-mark {
    font-family: var(--mono);
    font-weight: 500;
    color: var(--seokryu);
    font-size: 0.86rem;
    letter-spacing: 0.14em;
    margin: 0 0 8px 0;
    text-transform: lowercase;
}

.essay-body {
    font-family: var(--serif-cjk);
    font-weight: 400;
    color: var(--night-ink);
    font-size: clamp(1.0rem, 1.18vw, 1.12rem);
    line-height: 1.95;
    margin: 0;
    max-width: 38ch;
}

.essay-body em {
    font-style: italic;
    color: var(--meok-burgundy);
}

.essay-attrib {
    font-family: var(--mono);
    font-weight: 400;
    color: var(--muted-rose);
    font-size: 0.78rem;
    letter-spacing: 0.10em;
    line-height: 1.5;
    margin-top: clamp(20px, 2vw, 32px);
    text-transform: lowercase;
}

/* ---------- Card content: the closing empty card ---------- */

.empty-frame {
    border: 1px solid var(--seokryu);
    background: transparent;
    width: 100%;
    height: clamp(240px, 28vw, 360px);
}

.empty-caption {
    font-family: var(--mono);
    font-weight: 400;
    color: var(--muted-rose);
    font-size: 0.82rem;
    letter-spacing: 0.16em;
    line-height: 1.6;
    text-transform: lowercase;
    margin: clamp(18px, 2vw, 30px) 0 0 0;
    text-align: left;
}

/* ---------- Kūhaku dots (seven 4px burgundy circles) ---------- */

.kuhaku-dot {
    display: block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--seokryu);
    margin: clamp(40px, 5vw, 80px) auto;
    opacity: 0.85;
    break-inside: avoid;
}

@supports (grid-template-rows: masonry) {
    .kuhaku-dot {
        margin: 0;
        align-self: center;
        justify-self: center;
        grid-column: span 12;
        height: 4px;
    }
    .kuhaku-dot[data-dot="1"] { justify-self: end;    grid-column: 9 / span 1; }
    .kuhaku-dot[data-dot="2"] { justify-self: start;  grid-column: 4 / span 1; }
    .kuhaku-dot[data-dot="3"] { justify-self: center; grid-column: 7 / span 1; }
    .kuhaku-dot[data-dot="4"] { justify-self: end;    grid-column: 11 / span 1; }
    .kuhaku-dot[data-dot="5"] { justify-self: start;  grid-column: 2 / span 1; }
    .kuhaku-dot[data-dot="6"] { justify-self: center; grid-column: 6 / span 1; }
    .kuhaku-dot[data-dot="7"] { justify-self: end;    grid-column: 10 / span 1; }
}

/* ---------- §07 end emptiness (60vh of cream) ---------- */

.end-emptiness {
    height: 60vh;
    width: 100%;
}

/* ---------- §08 footer ---------- */

.page-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(24px, 4vw, 64px);
    padding: clamp(24px, 4vw, 64px) 0 clamp(40px, 5vw, 80px) 0;
    border-top: 1px solid var(--rule-mid);
    margin-top: 0;
}

.footer-line {
    font-family: var(--mono);
    font-weight: 400;
    color: var(--muted-rose);
    font-size: 0.78rem;
    letter-spacing: 0.18em;
    line-height: 1.6;
    text-transform: lowercase;
    margin: 0;
}

.footer-seal {
    width: clamp(56px, 6vw, 80px);
    height: clamp(56px, 6vw, 80px);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.footer-seal svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

@media (max-width: 720px) {
    .page-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: clamp(20px, 4vw, 36px);
    }
}

/* ---------- Inline link underline (the only path-draw moment) ---------- */

a {
    color: var(--seokryu);
    text-decoration: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 6' preserveAspectRatio='none'><path d='M 0 3 Q 25 0 50 3 T 100 3' fill='none' stroke='%237A2838' stroke-width='1.5' stroke-linecap='round'/></svg>");
    background-repeat: repeat-x;
    background-size: 80px 6px;
    background-position: 0 100%;
    padding-bottom: 4px;
    transition: color 350ms var(--reveal-ease);
}

a:hover {
    color: var(--meok-burgundy);
}

/* ---------- Respect reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    .card { transition: none; opacity: 1; transform: none; }
    .breath-rail .rail-numeral { transition: none; }
    .cursor-ring { display: none; }
    html, body { cursor: auto; }
}
