/* ──────────────────────────────────────────────────────────────
   kōan · koan.ehrlich.dev
   A drop-in style.css — vanilla CSS, system fonts only.
   A typeset reading room: aged paper, serif type, one seal-red accent.
   ────────────────────────────────────────────────────────────── */

:root {
  /* palette — warm paper, soft ink, one restrained accent */
  --ink:      #2a2521;
  --ink-soft: #423b34;
  --paper:    #faf6ee;
  --paper-2:  #f3ede0;
  --muted:    #837868;
  --rule:     #e2d9c8;
  --rule-soft:#ece4d4;
  --seal:     #9e2b25;

  /* CJK serif stack — the Chinese must render in a real CJK serif */
  --cjk: "Songti SC", "Noto Serif CJK SC", "Noto Serif SC",
         "Source Han Serif SC", "Source Han Serif", "STSong",
         "Hiragino Mincho ProN", "Yu Mincho", serif;

  /* measure & layout */
  --maxw:    58rem;   /* page container — holds the facing columns        */
  --measure: 35rem;   /* prose measure ≈ 64–68 English characters         */

  /* a single deliberate spacing scale (1.5× steps) */
  --s-1: 0.375rem;
  --s-2: 0.625rem;
  --s-3: 1rem;
  --s-4: 1.5rem;
  --s-5: 2.25rem;
  --s-6: 3.5rem;
  --s-7: 5.5rem;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
               "Times New Roman", serif;
  font-size: 18px;
  line-height: 1.72;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* links — quiet by default, seal on intent */
a {
  color: var(--seal);
  text-decoration: none;
  text-underline-offset: 0.12em;
  text-decoration-thickness: 0.06em;
}
a:hover { text-decoration: underline; }
a:focus-visible {
  outline: 2px solid var(--seal);
  outline-offset: 3px;
  border-radius: 2px;
  text-decoration: none;
}

p { margin: 0 0 var(--s-3); }
p:last-child { margin-bottom: 0; }

::selection { background: #f0e2bc; color: var(--ink); }

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ── masthead & colophon ───────────────────────────────────── */
.site-head {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.site-head .wrap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.5rem;
  flex-wrap: wrap;
}
.site-head .brand {
  font-size: 1.2rem;
  letter-spacing: 0.01em;
}
.site-head .brand a { color: var(--ink); font-weight: 600; }
.site-head nav { display: flex; gap: 1.5rem; }
.site-head nav a {
  color: var(--muted);
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}
.site-head nav a:hover { color: var(--seal); }

main { padding-top: var(--s-5); padding-bottom: var(--s-4); }

.site-foot {
  border-top: 1px solid var(--rule);
  margin-top: var(--s-7);
  padding: var(--s-5) 0 var(--s-6);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.6;
}
.site-foot .wrap { max-width: var(--measure); }
.site-foot p { margin: 0 0 var(--s-1); max-width: 44rem; }

/* ── titles ────────────────────────────────────────────────── */
h1 {
  font-size: clamp(1.85rem, 1.3rem + 1.8vw, 2.5rem);
  line-height: 1.18;
  font-weight: normal;
  letter-spacing: -0.005em;
  margin: 0 0 var(--s-2);
  max-width: 28rem;
  text-wrap: balance;
}
h1 .n {
  color: var(--seal);
  font-weight: 600;
  margin-right: 0.4em;
  font-variant-numeric: lining-nums;
}
h1 .zh-title {
  font-family: var(--cjk);
  color: var(--muted);
  font-size: 0.72em;
  margin-left: 0.5em;
  font-weight: 400;
  letter-spacing: 0.02em;
}
.pinyin {
  color: var(--muted);
  font-style: italic;
  font-size: 1.02rem;
  margin: 0 0 var(--s-6);
  letter-spacing: 0.01em;
}

/* ── section labels — quiet running heads, not form fields ─── */
h2 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
  margin: var(--s-6) 0 var(--s-4);
  display: flex;
  align-items: baseline;
  gap: 0.7em;
}
h2 .zh {
  font-family: var(--cjk);
  text-transform: none;
  letter-spacing: 0.04em;
  font-size: 1.45rem;
  font-weight: 400;
  color: var(--ink-soft);
  line-height: 1;
}

/* ── the case — first thing on the page, no label, just text ─ */
.case { margin-bottom: var(--s-6); }

/* ── bilingual facing columns ──────────────────────────────── */
/* Two columns bound by a centered hairline, like facing pages.
   Both top-align; the seam keeps original↔translation legible
   even as their line counts differ. */
.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  margin: 0;
}
.pair .zh {
  font-family: var(--cjk);
  font-size: 1.2rem;
  line-height: 2;
  color: var(--ink);
  text-align: justify;
  text-justify: inter-character;
  padding-right: var(--s-5);
  hanging-punctuation: allow-end;
}
.pair .en {
  padding-left: var(--s-5);
  border-left: 1px solid var(--rule);
  line-height: 1.78;
  color: var(--ink-soft);
}
.pair .zh p,
.pair .en p { margin-bottom: var(--s-3); }
.pair .zh p:last-child,
.pair .en p:last-child { margin-bottom: 0; }

/* verse — lines correspond 1:1; equal leading keeps them in step */
.verse .pair { align-items: start; }
.verse .pair .zh,
.verse .pair .en { line-height: 1.95; }
.verse .line { display: block; }
.verse .zh .line { font-size: 1.3rem; }
.verse .en .line { font-style: italic; color: var(--ink-soft); }

/* ── the Pointer — the payoff, given presence, kept restrained ─ */
.pointer {
  max-width: var(--measure);
  margin: var(--s-7) 0 0;
  padding-top: var(--s-4);
  border-top: 2px solid var(--seal);
}
.pointer h2 {
  display: block;
  color: var(--seal);
  font-size: 0.78rem;
  letter-spacing: 0.24em;
  margin: 0 0 var(--s-3);
}
.pointer p {
  font-size: 1.12rem;
  line-height: 1.74;
  color: var(--ink);
}
.pointer p:first-of-type::first-letter {
  font-size: 1.15em;
  color: var(--seal);
}

.untranslated { color: var(--muted); font-style: italic; }

/* ── case-to-case navigation ───────────────────────────────── */
.koannav {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
  letter-spacing: 0.01em;
}
nav.koannav:first-child { margin-bottom: var(--s-6); }
main .wrap > nav.koannav:last-of-type {
  margin-top: var(--s-7);
  padding-top: var(--s-4);
  border-top: 1px solid var(--rule);
}
.koannav a { white-space: nowrap; }
.koannav a:not(.spacer) { color: var(--ink-soft); }
.koannav a:not(.spacer):hover { color: var(--seal); }
.koannav .spacer { flex: 1; text-align: center; color: var(--muted); }

/* ── intro prose ───────────────────────────────────────────── */
.lede {
  max-width: var(--measure);
  font-size: 1.1rem;
  line-height: 1.7;
  color: var(--ink-soft);
  margin: 0 0 var(--s-6);
}
.lede p { margin-bottom: var(--s-3); }

/* ── home: featured example — no card, let whitespace carry ── */
.featured {
  margin: var(--s-6) 0;
  padding: 0;
  background: none;
  border: none;
}
.featured > h2 { margin-top: 0; }
.featured-title {
  font-size: 1.5rem;
  font-weight: normal;
  line-height: 1.25;
  margin: var(--s-3) 0 var(--s-4);
}
.featured-title .n { color: var(--seal); font-weight: 600; margin-right: 0.4em; }
.featured-title .zh-title {
  font-family: var(--cjk);
  color: var(--muted);
  font-size: 0.78em;
  margin-left: 0.45em;
}
.featured .pointer { margin-top: var(--s-5); }
.featured .more { margin-bottom: 0; }

/* ── home: collections — a clean list, hairline-divided ─────── */
.collections {
  list-style: none;
  padding: 0;
  margin: var(--s-5) 0 0;
  border-top: 1px solid var(--rule);
}
.collections li {
  border: none;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  background: none;
  padding: var(--s-4) 0;
  margin: 0;
}
.collections a { display: block; color: inherit; }
.collections a:hover { text-decoration: none; }
.collections a:hover h3 { color: var(--seal); }
.collections h3 {
  margin: 0 0 0.2rem;
  font-weight: normal;
  font-size: 1.35rem;
  color: var(--ink);
  transition: color 0.12s ease;
}
.collections .meta {
  color: var(--muted);
  font-size: 0.9rem;
  letter-spacing: 0.01em;
}

/* ── collection index list ─────────────────────────────────── */
.koan-list {
  list-style: none;
  padding: 0;
  margin: var(--s-5) 0 0;
  border-top: 1px solid var(--rule);
}
.koan-list li { border-bottom: 1px solid var(--rule-soft); }
.koan-list a {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  padding: 0.7rem 0;
  color: var(--ink);
}
.koan-list a:hover { text-decoration: none; }
.koan-list a:hover .t { color: var(--seal); }
.koan-list .n {
  color: var(--seal);
  font-weight: 600;
  min-width: 1.9rem;
  text-align: right;
  font-variant-numeric: lining-nums tabular-nums;
}
.koan-list .t { transition: color 0.12s ease; }
.koan-list .zh {
  font-family: var(--cjk);
  color: var(--muted);
  margin-left: auto;
  padding-left: 1rem;
  font-size: 1.05rem;
}
.koan-list .todo {
  font-style: italic;
  color: #b3a892;
  font-size: 0.8rem;
}

/* ── search ────────────────────────────────────────────────── */
.search { max-width: var(--measure); margin: var(--s-5) 0; }
.search input {
  width: 100%;
  padding: 0.7rem 0.95rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--ink);
  background: #fffdf8;
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.search input:focus-visible {
  outline: none;
  border-color: var(--seal);
  box-shadow: 0 0 0 3px rgba(158, 43, 37, 0.12);
}
.search input::placeholder { color: var(--muted); }
#search-results { list-style: none; padding: 0; margin: var(--s-4) 0; }
#search-results li {
  border-bottom: 1px solid var(--rule-soft);
  padding: 0.6rem 0;
}
#search-results .ctx {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}
#search-results em { background: #f0e2bc; font-style: normal; }

/* ── responsive ────────────────────────────────────────────── */
@media (max-width: 760px) {
  body { font-size: 17px; }

  h1 { font-size: 1.7rem; }
  h1 .zh-title {
    display: block;
    margin: 0.3em 0 0;
    font-size: 0.85em;
  }

  /* facing columns stack: original first, then translation,
     each given its own breathing room with a soft seam between */
  .pair { grid-template-columns: 1fr; }
  .pair .zh {
    padding-right: 0;
    padding-bottom: var(--s-4);
    margin-bottom: var(--s-4);
    border-bottom: 1px solid var(--rule);
  }
  .pair .en {
    padding-left: 0;
    border-left: none;
  }
  .verse .pair .zh {
    padding-bottom: var(--s-3);
    margin-bottom: var(--s-3);
  }

  .pointer { margin-top: var(--s-6); }
  .koan-list .zh { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
