/* =====================================================================
   gabs.cx — paper-aged price-ledger broadsheet
   Palette: #F2EAD3 #D4C4A0 #E8DCC0 #5C5447 #9B2D1F #A8896B #2A1E0F #3D5A7A
   Fonts:   Cormorant Garamond, Noto Serif KR, IBM Plex Mono, Nanum Pen Script
   ===================================================================== */

:root {
    --aged-cream:    #F2EAD3;
    --foxed-edge:    #E8DCC0;
    --iron-gall:     #2A1E0F;
    --pencil:        #5C5447;
    --indigo-rule:   #3D5A7A;
    --red-stamp:     #9B2D1F;
    --crease:        #D4C4A0;
    --foxing:        #A8896B;

    --line: 22.4px;
    --body-size: 16.8px;
    --max: 960px;
    --rail: 14%;
    --margin: clamp(2.5rem, 6vw, 7rem);

    --serif:    "Noto Serif KR", "Cormorant Garamond", Georgia, serif;
    --display:  "Cormorant Garamond", "Noto Serif KR", Georgia, serif;
    --mono:     "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
    --pencil-script: "Nanum Pen Script", "Noto Serif KR", cursive;
}

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

* { cursor: text; }                         /* the manifesto: a reading-position cursor */
a, button, [data-tick], .torn-paper, .botanical, .colophon, .price-value {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><circle cx='2' cy='10' r='1.2' fill='%235C5447'/><circle cx='5' cy='7' r='0.8' fill='%235C5447'/><circle cx='8' cy='4' r='0.6' fill='%235C5447'/><circle cx='10' cy='2' r='0.5' fill='%235C5447'/></svg>") 2 10, text;
}

html, body { width: 100%; }

body {
    font-family: var(--serif);
    font-size: var(--body-size);
    line-height: var(--line);
    color: var(--iron-gall);
    background:
        radial-gradient(ellipse at 50% 30%, var(--aged-cream) 0%, var(--aged-cream) 60%, var(--foxed-edge) 100%);
    min-height: 100vh;
    overflow-x: hidden;
    font-feature-settings: "kern", "liga";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- Paper noise overlay ---------- */
.paper-noise {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    opacity: 0.18;
    pointer-events: none;
    z-index: 1;
    mix-blend-mode: multiply;
}

/* ---------- Foxing static layer ---------- */
.foxing-layer {
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: var(--max);
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

/* ---------- The single red thread ---------- */
.red-thread {
    position: absolute;
    top: 12vh; left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: calc(100% - 12vh);
    pointer-events: none;
    z-index: 3;
}
.red-thread #thread-path {
    stroke-dasharray: 4400;
    stroke-dashoffset: 4400;
    transition: stroke-dashoffset 1400ms cubic-bezier(0.42, 0.08, 0.58, 0.95);
}
.red-thread.draw #thread-path {
    stroke-dashoffset: 0;
}

/* ---------- Page container ---------- */
.ledger {
    position: relative;
    z-index: 4;
    max-width: var(--max);
    margin: 0 auto;
    padding: clamp(2rem, 5vh, 5rem) var(--margin) clamp(3rem, 7vh, 7rem);
}

/* central gutter crease (>1280px) */
@media (min-width: 1281px) {
    .ledger::before {
        content: "";
        position: absolute;
        top: 0; left: 50%;
        transform: translateX(-50%);
        width: 38px;
        height: 100%;
        background: linear-gradient(90deg,
            transparent 0%,
            var(--crease) 30%,
            var(--crease) 70%,
            transparent 100%);
        opacity: 0.45;
        box-shadow: inset 0 0 60px -20px rgba(74, 52, 38, 0.18);
        pointer-events: none;
        z-index: -1;
    }
}

/* horizontal ledger ruling — pale indigo at every line */
.ledger {
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent calc(var(--line) - 1px),
        rgba(61, 90, 122, 0.08) calc(var(--line) - 1px),
        rgba(61, 90, 122, 0.08) var(--line)
    );
    background-position: 0 0;
}

/* ===================================================================
   MASTHEAD
   =================================================================== */
.masthead {
    position: relative;
    text-align: center;
    padding: var(--line) 0 calc(var(--line) * 2);
    margin-bottom: calc(var(--line) * 2);
}

.masthead-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-family: var(--mono);
    font-size: 12.5px;
    letter-spacing: 0.04em;
    color: var(--pencil);
    text-transform: uppercase;
    padding-bottom: var(--line);
}
.masthead-meta { display: flex; flex-direction: column; gap: 2px; }
.masthead-meta--right { text-align: right; }
.meta-label { font-weight: 600; opacity: 0.7; font-size: 10.5px; }
.meta-value { font-weight: 400; color: var(--iron-gall); font-feature-settings: "tnum"; }

.masthead-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6em;
    margin: 0.4em 0 0.2em;
}
.title-bullet {
    color: var(--red-stamp);
    font-size: 1.4rem;
    line-height: 1;
}
.site-name {
    font-family: var(--display);
    font-weight: 700;
    font-size: clamp(2.4rem, 5vw, 4.6rem);
    letter-spacing: -0.012em;
    color: var(--iron-gall);
    line-height: 1;
}
.site-dot { color: var(--red-stamp); }

.masthead-rule {
    border: none;
    border-top: 1px solid var(--iron-gall);
    width: 70%;
    margin: 0.8em auto;
    opacity: 0.75;
}
.masthead-rule::after {
    content: "";
    display: block;
    width: 100%;
    border-top: 1px solid var(--iron-gall);
    margin-top: 2px;
    opacity: 0.4;
}

.masthead-subtitle {
    font-family: var(--display);
    font-style: italic;
    font-size: 1.1rem;
    color: var(--pencil);
    margin-bottom: 0.6em;
}
.masthead-subtitle .hangul {
    font-family: var(--serif);
    font-style: normal;
    font-size: 1.14rem;          /* 1.04× optical balance */
    color: var(--iron-gall);
    margin: 0 0.16em;
}
.masthead-colophon {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--pencil);
    text-transform: uppercase;
    opacity: 0.85;
}

/* ===================================================================
   SECTION MARKERS
   =================================================================== */
.section-marker {
    display: flex;
    align-items: center;
    gap: 0.7em;
    margin: calc(var(--line) * 3) 0 calc(var(--line) * 1.5);
}
.marker-bullet {
    color: var(--red-stamp);
    font-size: 1rem;
    line-height: 1;
}
.marker-rule {
    flex: 1;
    border: none;
    border-top: 1px solid var(--iron-gall);
    opacity: 0.6;
}
.marker-caption {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    color: var(--pencil);
    text-transform: uppercase;
}
.hangul-mini { font-family: var(--serif); font-size: 12px; }

/* ===================================================================
   ENTRY (generic)
   =================================================================== */
.entry {
    position: relative;
    margin-bottom: calc(var(--line) * 3);
}

.entry-head {
    font-family: var(--display);
    font-weight: 700;
    font-size: clamp(2.4rem, 5vw, 4.6rem);
    letter-spacing: -0.012em;
    color: var(--iron-gall);
    line-height: 1.05;
    margin-bottom: 0.2em;
    text-align: center;
}
.entry-head .latin-tail {
    font-family: var(--display);
    font-weight: 400;
    font-style: italic;
    font-size: 0.6em;
    color: var(--pencil);
    letter-spacing: 0;
}
.entry-deck {
    text-align: center;
    font-family: var(--display);
    font-style: italic;
    font-size: 1.05rem;
    color: var(--pencil);
    margin-bottom: calc(var(--line) * 1.5);
}

/* ---- Five-column layout: rail | narrow | wide | narrow | rail ---- */
.columns {
    display: grid;
    grid-template-columns: var(--rail) 1fr 2.2fr 1fr var(--rail);
    gap: clamp(0.8rem, 2vw, 1.6rem);
    align-items: start;
}
.columns--single {
    grid-template-columns: 1fr minmax(0, 28rem) 1fr;
}
.columns--single .col--center { grid-column: 2; }

.rail {
    display: flex;
    flex-direction: column;
    gap: var(--line);
    padding-top: 8px;
}
.rail--left  { grid-column: 1; }
.rail--right { grid-column: 5; }

.col--center { grid-column: 3; }

/* When narrowed, the layout collapses */
@media (max-width: 800px) {
    .columns,
    .columns--single {
        grid-template-columns: 1fr;
    }
    .rail--left, .rail--right { grid-column: 1; flex-direction: row; flex-wrap: wrap; gap: 1em; }
    .col--center { grid-column: 1; }
}

/* ---- Marginalia (in the rails) ---- */
.marginalia {
    display: block;
    font-family: var(--mono);
    font-size: 10.5px;
    letter-spacing: 0.04em;
    color: var(--pencil);
    line-height: 1.4;
    /* Deliberate baseline-violation jitter */
    transform: translateY(5px);
}
.rail .marginalia:nth-child(2) { transform: translateY(-3px); }
.rail .marginalia:nth-child(3) { transform: translateY(7px); }
.rail .marginalia:nth-child(4) { transform: translateY(-5px); }

.marginalia.pencil {
    font-family: var(--pencil-script);
    font-size: 1.1rem;
    color: var(--pencil);
    letter-spacing: 0;
}
.marginalia.indent-1 { padding-left: 1em; }

/* small dojang in rail */
.dojang { display: inline-block; transform: rotate(-4deg); opacity: 0.85; margin-top: 8px; }
.dojang svg { width: 38px; height: 38px; }

/* ---- Body type ---- */
.body {
    font-family: var(--serif);
    font-size: var(--body-size);
    line-height: var(--line);
    color: var(--iron-gall);
    margin-bottom: var(--line);
    opacity: 0;
    transition: opacity 600ms cubic-bezier(0.42, 0.08, 0.58, 0.95);
}
.body.in-view { opacity: 1; }

.body--lead { text-indent: 0; }
.body em { font-family: var(--display); font-style: italic; color: var(--pencil); }
.body .hangul { font-size: 1.04em; color: var(--iron-gall); }

/* ---- Drop cap ---- */
.dropcap {
    float: left;
    font-family: var(--display);
    font-weight: 600;
    font-size: 5em;
    line-height: 0.85;
    margin: 0.05em 0.08em 0 -0.04em;
    color: var(--iron-gall);
    text-shadow: 2px 2px 0 rgba(155, 45, 31, 0.18);
    font-feature-settings: "kern";
}
.afterdrop {
    /* the comma after the dropcap inherits inline */
}

/* ===================================================================
   BOTANICALS
   =================================================================== */
.botanical {
    position: absolute;
    width: 120px;
    pointer-events: auto;
    opacity: 0;
    transition: opacity 1000ms ease-out;
}
.botanical.in-view { opacity: 0.85; }

.botanical svg {
    width: 100%;
    height: auto;
    overflow: visible;
}
.botanical svg path,
.botanical svg ellipse,
.botanical svg circle {
    stroke-dasharray: 380;
    stroke-dashoffset: 380;
    transition: stroke-dashoffset 1100ms cubic-bezier(0.42, 0.08, 0.58, 0.95);
}
.botanical.in-view svg path,
.botanical.in-view svg ellipse,
.botanical.in-view svg circle {
    stroke-dashoffset: 0;
}

.botanical--one   { top: -10px;  right: -8%; }
.botanical--two   { top: 20px;   left: -8%; transform: rotate(4deg); }
.botanical--three { top: 60px;   right: -6%; transform: rotate(-3deg); }

@media (max-width: 800px) {
    .botanical { position: relative; right: auto !important; left: auto !important; margin: var(--line) auto; transform: none; }
}

/* ===================================================================
   LEDGER TABLE
   =================================================================== */
.ledger-frame {
    position: relative;
    border-top: 1.5px solid var(--iron-gall);
    border-bottom: 1.5px solid var(--iron-gall);
    padding: var(--line) 0;
    margin-bottom: var(--line);
}
.ledger-frame::before,
.ledger-frame::after {
    content: "";
    position: absolute;
    left: 0; right: 0;
    height: 1px;
    background: var(--iron-gall);
    opacity: 0.35;
}
.ledger-frame::before { top: 4px; }
.ledger-frame::after  { bottom: 4px; }

.ledger-table {
    width: 100%;
    border-collapse: collapse;
    font-feature-settings: "tnum";
}

.ledger-table thead th {
    font-family: var(--mono);
    font-weight: 600;
    font-size: 10.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--pencil);
    text-align: left;
    padding: 4px 8px var(--line);
    border-bottom: 1px solid var(--iron-gall);
}
.ledger-table thead th.col-price,
.ledger-table thead th.col-mark { text-align: right; }

.ledger-table tbody tr {
    border-bottom: 1px dotted rgba(42, 30, 15, 0.25);
    transition: background 220ms ease;
}
.ledger-table tbody tr:hover {
    background: rgba(212, 196, 160, 0.35);
}

.ledger-table td {
    padding: calc(var(--line) * 0.45) 8px;
    font-family: var(--serif);
    font-size: 15px;
    line-height: 1.45;
    color: var(--iron-gall);
    vertical-align: baseline;
}
.ledger-table td.mono {
    font-family: var(--mono);
    font-size: 13px;
    letter-spacing: 0.02em;
}
.ledger-table td.price,
.ledger-table td.mark { text-align: right; white-space: nowrap; }

.ledger-table .hangul { font-size: 1.04em; }

.col-date  { width: 18%; }
.col-item  { width: 52%; }
.col-price { width: 22%; }
.col-mark  { width: 8%; }

/* Price values — the only red text */
.price-value {
    color: var(--red-stamp);
    font-weight: 600;
    position: relative;
    display: inline-block;
    padding: 0 2px;
    transition: color 300ms;
}
.price-value.strike {
    text-decoration: line-through;
    text-decoration-color: var(--pencil);
    text-decoration-thickness: 1.2px;
    color: var(--pencil);
    font-weight: 400;
}
.price-value::after {
    /* the wavering pencil tick — drawn as inset SVG via mask, simple rendering */
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -3px;
    height: 4px;
    background:
        radial-gradient(ellipse at 10% 50%, var(--pencil) 1px, transparent 1.4px) 0 0/6px 4px repeat-x,
        radial-gradient(ellipse at 50% 50%, var(--pencil) 0.8px, transparent 1.2px) 3px 1px/6px 4px repeat-x;
    opacity: 0;
    transform: scaleX(0.4);
    transform-origin: left;
    transition: transform 480ms cubic-bezier(0.6, 0.04, 0.4, 1.05),
                opacity 320ms ease-out;
}
.price-value[data-tick="1"]::after { opacity: 0.55; transform: scaleX(1); }
.price-value:hover::after { opacity: 0.95; transform: scaleX(1); }
.price-value:hover { color: var(--red-stamp); }

.correction {
    color: var(--pencil);
    font-family: var(--pencil-script);
    font-size: 1.2rem;
    margin-left: 4px;
    transform: rotate(-2deg);
    display: inline-block;
}

.mark { color: var(--pencil); font-size: 13px; }

.ledger-foot {
    margin-top: var(--line);
    text-align: right;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--pencil);
    text-transform: uppercase;
}
.ledger-foot em.cormorant {
    font-family: var(--display);
    font-style: italic;
    text-transform: none;
    letter-spacing: 0;
    color: var(--iron-gall);
}

/* ---- Hover marginalia balloon (right rail) ---- */
.row-marginalia {
    position: absolute;
    top: 0;
    right: -16%;
    width: 14%;
    min-width: 110px;
    font-family: var(--pencil-script);
    font-size: 1.1rem;
    color: var(--pencil);
    line-height: 1.3;
    opacity: 0;
    transform: translateY(8px) rotate(-1.5deg);
    transition: opacity 260ms ease, transform 260ms ease;
    pointer-events: none;
}
.row-marginalia.show {
    opacity: 1;
    transform: translateY(0) rotate(-1.5deg);
}
@media (max-width: 800px) {
    .row-marginalia { display: none; }
}

/* ===================================================================
   TORN PAPER (entry III)
   =================================================================== */
.torn-paper {
    position: relative;
    margin: calc(var(--line) * 1.5) auto;
    padding: calc(var(--line) * 1.4) 1.6rem var(--line);
    background: var(--foxed-edge);
    color: var(--pencil);
    width: 88%;
    transform: rotate(-1.4deg);
    box-shadow:
        2px 4px 8px rgba(42, 30, 15, 0.12),
        inset 0 0 20px rgba(168, 137, 107, 0.18);
    /* jagged torn edge via clip-path */
    clip-path: polygon(
        2% 6%,  6% 2%, 14% 5%, 22% 3%, 33% 6%, 45% 2%, 56% 5%, 68% 3%, 79% 6%, 88% 2%, 96% 5%, 100% 8%,
        99% 22%, 100% 38%, 98% 55%, 100% 72%, 97% 88%, 100% 98%,
        92% 100%, 80% 97%, 68% 100%, 55% 98%, 42% 100%, 30% 97%, 18% 100%, 8% 96%, 2% 99%,
        0% 88%, 2% 72%, 0% 55%, 3% 38%, 0% 22%, 2% 10%
    );
}
.torn-handwriting {
    display: block;
    font-family: var(--pencil-script);
    font-size: 1.85rem;
    line-height: 1.3;
    color: var(--iron-gall);
    text-align: center;
}
.torn-en {
    display: block;
    font-family: var(--display);
    font-style: italic;
    font-size: 1.1rem;
    color: var(--pencil);
    margin-top: 0.4em;
}
.torn-sub {
    display: block;
    margin-top: var(--line);
    text-align: right;
    font-size: 10.5px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pencil);
    opacity: 0.7;
}

.torn-paper:hover { transform: rotate(-1.1deg) translateY(-2px); transition: transform 260ms ease; }

/* ---- Large dojang stamp ---- */
.dojang-large {
    position: absolute;
    bottom: -10px;
    right: 4%;
    width: 110px;
    height: 110px;
    transform: rotate(-7deg);
    opacity: 0;
    transition: opacity 800ms cubic-bezier(0.42, 0.08, 0.58, 0.95);
    z-index: 5;
}
.dojang-large.struck {
    opacity: 0.9;
}
.dojang-large svg {
    width: 100%; height: 100%;
}
.dojang-large svg rect[fill="none"],
.dojang-large svg text {
    transition: fill 800ms, stroke 800ms;
}
.dojang-large:not(.struck) svg text { fill: rgba(155, 45, 31, 0.18); }
.dojang-large:not(.struck) svg rect { stroke: rgba(155, 45, 31, 0.18); }

/* ===================================================================
   COLOPHON
   =================================================================== */
.colophon {
    margin-top: calc(var(--line) * 4);
    text-align: center;
    padding-top: var(--line);
}

.colophon-block {
    display: inline-block;
    text-align: left;
    font-family: var(--mono);
    font-size: 11.5px;
    line-height: 1.7;
    letter-spacing: 0.04em;
    color: var(--pencil);
    background: transparent;
    margin: var(--line) auto;
    padding: var(--line) 1.4rem;
    border-top: 1px solid var(--iron-gall);
    border-bottom: 1px solid var(--iron-gall);
    white-space: pre;
    overflow-x: auto;
}

.colophon-thread {
    margin-top: calc(var(--line) * 1.5);
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--pencil);
}
.thread-end { padding: 0 0.6em; }

/* ===================================================================
   Utility: hangul / mono / cormorant inline
   =================================================================== */
.hangul { font-family: var(--serif); font-size: 1.04em; }
.mono   { font-family: var(--mono); font-feature-settings: "tnum"; }
.pencil { color: var(--pencil); }
.cormorant { font-family: var(--display); }
