/* =====================================================================
   The Analects — a reading edition.
   Hand-written CSS, no build step. Two themes (paper / ink) switched by an
   `.ink` class on <html>. Aesthetic: Song-dynasty ink-wash on rice paper,
   one cinnabar seal-red accent, generous emptiness (liúbái).
   ===================================================================== */

/* ---- theme tokens --------------------------------------------------- */
:root {
  --paper:    #f4ecd9;
  --paper-2:  #ece2cb;   /* recessed panels */
  --paper-3:  #e6dabf;   /* deeper wells */
  --ink:      #221d15;   /* primary text — warm near-black */
  --ink-soft: #4f4636;   /* secondary text */
  --ink-mute: #8b7d63;   /* captions, meta */
  --line:     #d7c8a8;   /* hairlines */
  --line-2:   #c8b692;
  --seal:     #a8322a;   /* cinnabar */
  --seal-ink: #8e2820;
  --jade:     #4f6f57;
  --gold:     #9a7530;
  --shadow:   28 22 12;  /* rgb for soft shadows */
  --paper-rgb: 244 236 217;

  --serif:   "Spectral", Georgia, "Times New Roman", serif;
  --display: "Cormorant Garamond", "Spectral", Georgia, serif;
  --cn:      "Noto Serif SC", "Spectral", serif;
  --ui:      "Hanken Grotesk", system-ui, -apple-system, sans-serif;

  --measure: 33rem;          /* reading column */
  --rail: 16.5rem;           /* gloss rail width */
  --gutter: 4.75rem;         /* left meta gutter */
  --page: 70rem;

  --r: 3px;
}

html.ink {
  --paper:    #16130d;
  --paper-2:  #1d1810;
  --paper-3:  #241e14;
  --ink:      #e9ddc4;
  --ink-soft: #c0b393;
  --ink-mute: #8c7f64;
  --line:     #322a1d;
  --line-2:   #423829;
  --seal:     #d9604f;
  --seal-ink: #c2503f;
  --jade:     #8cae8f;
  --gold:     #cba65f;
  --shadow:   0 0 0;
  --paper-rgb: 22 19 13;
}

/* ---- reset ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.06rem;
  line-height: 1.72;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(120% 80% at 50% -10%, rgba(255,255,255,.30), transparent 60%),
    radial-gradient(120% 120% at 100% 0%, rgba(var(--shadow), .05), transparent 55%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .4s ease, color .4s ease;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3 { font-weight: 600; line-height: 1.14; margin: 0; }
p { margin: 0; }
::selection { background: rgba(168,50,42,.20); }
html.ink ::selection { background: rgba(217,96,79,.28); }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 200;
  background: var(--seal); color: #fff; padding: .6rem 1rem; border-radius: 0 0 var(--r) 0;
  font-family: var(--ui); font-size: .85rem;
}
.skip-link:focus { left: 0; }
.nowrap { white-space: nowrap; }

:focus-visible { outline: 2px solid var(--seal); outline-offset: 3px; border-radius: 2px; }

/* eyebrow / section labels */
.eyebrow {
  font-family: var(--ui); font-size: .72rem; font-weight: 600;
  letter-spacing: .22em; text-transform: uppercase; color: var(--ink-mute);
  margin: 0;
}
.eyebrow a { color: var(--seal); text-decoration: none; }

/* =====================================================================
   Masthead
   ===================================================================== */
.masthead {
  position: sticky; top: 0; z-index: 100;
  background: rgba(var(--paper-rgb), .86);
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  border-bottom: 1px solid var(--line);
}
.masthead__inner {
  max-width: var(--page); margin: 0 auto; padding: .55rem 1.4rem;
  display: flex; align-items: center; gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; margin-right: auto; }
.brand__seal {
  font-family: var(--cn); font-weight: 700; font-size: 1.18rem; color: var(--paper);
  background: var(--seal); width: 2.05rem; height: 2.05rem; border-radius: var(--r);
  display: grid; place-items: center; line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18), 0 1px 4px rgba(var(--shadow), .25);
}
.brand__text { display: flex; flex-direction: column; line-height: 1.05; }
.brand__title { font-family: var(--display); font-size: 1.32rem; font-weight: 600; letter-spacing: .01em; }
.brand__sub { font-family: var(--ui); font-size: .68rem; letter-spacing: .12em; color: var(--ink-mute); }

.masthead__links { display: flex; align-items: center; gap: .25rem; }
.navlink {
  font-family: var(--ui); font-size: .86rem; font-weight: 500; letter-spacing: .02em;
  color: var(--ink-soft); text-decoration: none; padding: .45rem .6rem; border-radius: var(--r);
  position: relative; transition: color .2s;
}
.navlink:hover { color: var(--seal); }
.navlink--icon { display: grid; place-items: center; padding: .4rem; }
.navlink--icon svg { width: 1.15rem; height: 1.15rem; }

.theme-toggle, .masthead__burger {
  background: none; border: 1px solid var(--line-2); border-radius: var(--r);
  color: var(--ink-soft); cursor: pointer; padding: .4rem; display: grid; place-items: center;
  width: 2.1rem; height: 2.1rem; margin-left: .35rem;
}
.theme-toggle svg { width: 1.15rem; height: 1.15rem; }
.theme-toggle__moon { display: none; }
html.ink .theme-toggle__sun { display: none; }
html.ink .theme-toggle__moon { display: block; }

.masthead__burger { display: none; flex-direction: column; gap: 4px; }
.masthead__burger span { width: 18px; height: 2px; background: currentColor; border-radius: 2px; }

/* =====================================================================
   Generic page (leaf) + prose
   ===================================================================== */
main { display: block; }
.leaf { max-width: 52rem; margin: 0 auto; padding: 4rem 1.5rem 5rem; }
.leaf--bannered { padding-top: 2.5rem; }
.leaf-banner {
  height: clamp(11rem, 26vw, 19rem); background-image: var(--banner);
  background-size: cover; background-position: 50% 42%;
  border-bottom: 1px solid var(--line); opacity: .88;
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent);
  mask-image: linear-gradient(to bottom, #000 55%, transparent);
}
html.ink .leaf-banner { opacity: .6; filter: brightness(.85) saturate(.8); }
.leaf--wide { max-width: 60rem; }
.leaf__head { margin-bottom: 2.6rem; }
.leaf__title {
  font-family: var(--display); font-size: clamp(2.4rem, 6vw, 3.7rem);
  font-weight: 600; letter-spacing: -.01em; margin: .5rem 0 0;
}
.leaf__standfirst {
  font-size: 1.15rem; color: var(--ink-soft); line-height: 1.6; margin-top: 1.1rem;
  max-width: 40rem; font-style: italic;
}

.prose { font-size: 1.12rem; line-height: 1.76; }
.prose h2 {
  font-family: var(--display); font-size: 1.8rem; font-weight: 600;
  margin: 2.6rem 0 .8rem; padding-top: 1.4rem; border-top: 1px solid var(--line);
}
.prose h2:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.prose p { margin: 0 0 1.1rem; }
.prose ul { margin: 0 0 1.3rem; padding-left: 0; list-style: none; }
.prose li { position: relative; padding-left: 1.5rem; margin-bottom: .85rem; }
.prose li::before {
  content: "—"; position: absolute; left: 0; color: var(--seal); font-weight: 600;
}
.prose a { color: var(--seal); text-underline-offset: 3px; text-decoration-thickness: 1px; }
.prose strong { font-weight: 600; }

/* =====================================================================
   Hero
   ===================================================================== */
.hero {
  position: relative; overflow: hidden;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(130% 90% at 78% 8%, rgba(var(--shadow), .07), transparent 60%);
}
.hero__wash {
  position: absolute; inset: 0; z-index: 0;
  background-image: var(--hero);
  background-size: cover; background-position: 60% 32%;
  opacity: .26; filter: saturate(.55);
  -webkit-mask-image: linear-gradient(to bottom, #000 30%, transparent 95%);
  mask-image: linear-gradient(to bottom, #000 30%, transparent 95%);
}
html.ink .hero__wash { opacity: .30; filter: saturate(.5) brightness(.85); }
.hero__seal {
  position: absolute; z-index: 1; right: clamp(1rem, 7vw, 7rem); top: 50%;
  transform: translateY(-50%);
  font-family: var(--cn); font-weight: 700; font-size: clamp(7rem, 22vw, 17rem);
  line-height: .88; color: var(--seal); opacity: .12; text-align: center;
  letter-spacing: -.04em; pointer-events: none; user-select: none;
}
.hero__body {
  position: relative; z-index: 2;
  max-width: var(--page); margin: 0 auto; padding: clamp(4rem, 11vw, 8.5rem) 1.5rem clamp(3rem, 7vw, 5rem);
}
.hero__eyebrow {
  font-family: var(--ui); font-size: .8rem; font-weight: 600; letter-spacing: .2em;
  text-transform: uppercase; color: var(--seal); margin: 0 0 1.1rem;
}
.hero__title {
  font-family: var(--display); font-weight: 600;
  font-size: clamp(3.4rem, 12vw, 7.5rem); line-height: .92; letter-spacing: -.02em;
  margin: 0;
}
.hero__cn {
  font-family: var(--cn); font-weight: 700; color: var(--ink-soft);
  font-size: clamp(1.6rem, 5vw, 2.7rem); letter-spacing: .35em; margin: .4rem 0 0;
}
.hero__lede {
  font-size: clamp(1.1rem, 2.2vw, 1.32rem); line-height: 1.6; color: var(--ink-soft);
  max-width: 33rem; margin: 1.6rem 0 0;
}
.hero__actions { display: flex; flex-wrap: wrap; gap: .9rem; margin: 2.1rem 0 1.6rem; }
.hero__stat { font-family: var(--ui); font-size: .85rem; color: var(--ink-mute); letter-spacing: .02em; }
.hero__stat b { color: var(--seal); font-weight: 700; }

.btn {
  font-family: var(--ui); font-size: .92rem; font-weight: 600; letter-spacing: .02em;
  text-decoration: none; padding: .82rem 1.5rem; border-radius: var(--r);
  display: inline-flex; align-items: center; gap: .5rem; transition: transform .15s, background .2s, color .2s;
}
.btn:active { transform: translateY(1px); }
.btn--seal {
  background: var(--seal); color: #fbf4e6;
  box-shadow: 0 2px 0 var(--seal-ink), 0 6px 18px rgba(168,50,42,.28);
}
.btn--seal:hover { background: var(--seal-ink); }
.btn--ghost { color: var(--ink); border: 1px solid var(--line-2); }
.btn--ghost:hover { border-color: var(--seal); color: var(--seal); }

/* =====================================================================
   Home — ways in
   ===================================================================== */
.ways { max-width: var(--page); margin: 0 auto; padding: clamp(3rem, 6vw, 4.5rem) 1.5rem 0; }
.ways__grid { display: grid; gap: 1px; grid-template-columns: repeat(4, 1fr);
  background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.way {
  background: var(--paper); padding: 1.7rem 1.4rem 1.9rem; text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: .5rem; transition: background .25s;
}
.way:hover { background: var(--paper-2); }
.way__hz { font-family: var(--cn); font-size: 2rem; color: var(--seal); line-height: 1; }
.way__t { font-family: var(--display); font-size: 1.45rem; font-weight: 600; }
.way__d { font-size: .96rem; color: var(--ink-soft); line-height: 1.5; }

/* =====================================================================
   Home — featured saying
   ===================================================================== */
.featured {
  max-width: 46rem; margin: 0 auto; padding: clamp(4rem, 9vw, 7rem) 1.5rem; text-align: center;
}
.featured__rule { width: 1px; height: 3rem; background: var(--line-2); margin: 0 auto 2rem; }
.featured__ref { font-family: var(--ui); font-size: .76rem; letter-spacing: .22em; text-transform: uppercase; color: var(--seal); }
.featured__quote {
  margin: 1.4rem 0 0; font-family: var(--display); font-weight: 500;
  font-size: clamp(1.4rem, 3.5vw, 2.05rem); line-height: 1.5; font-style: italic;
}
.featured__quote p { margin: 0; }
.featured__quote p + p { margin-top: .2rem; }
.featured__by { font-family: var(--ui); font-size: .9rem; color: var(--ink-mute); margin-top: 1.4rem; }
.featured__more { display: inline-block; margin-top: 1.5rem; font-family: var(--ui); font-size: .88rem;
  font-weight: 600; color: var(--seal); text-decoration: none; }
.featured__more:hover { text-decoration: underline; text-underline-offset: 3px; }

/* section headings (home) */
.section-head { max-width: 40rem; margin: 0 auto 2.6rem; text-align: center; }
.section-title { font-family: var(--display); font-size: clamp(2rem, 5vw, 2.9rem); font-weight: 600; margin: .5rem 0 0; }
.section-intro { color: var(--ink-soft); font-size: 1.06rem; line-height: 1.6; margin-top: 1rem; }

/* =====================================================================
   Home — library
   ===================================================================== */
.library { max-width: var(--page); margin: 0 auto; padding: clamp(2rem, 5vw, 3.5rem) 1.5rem; border-top: 1px solid var(--line); }
.booklist {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
}
.bookcard__link {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto;
  gap: .1rem 1rem; align-items: start;
  text-decoration: none; color: inherit; height: 100%;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r);
  padding: 1.15rem 1.25rem; transition: border-color .2s, transform .2s, background .2s;
}
.bookcard__link:hover { border-color: var(--seal); transform: translateY(-2px); }
.bookcard__num {
  grid-row: 1 / 3; font-family: var(--display); font-weight: 600; font-size: 1.7rem;
  color: var(--seal); min-width: 2.4rem; line-height: 1;
}
.bookcard__hz {
  grid-row: 1 / 3; align-self: center; font-family: var(--cn); font-size: 1.7rem;
  color: var(--ink-mute); writing-mode: vertical-rl; letter-spacing: .04em;
  position: absolute; right: 1rem; top: 1rem; opacity: .5;
}
.bookcard__link { position: relative; }
.bookcard__body { grid-column: 2; display: flex; flex-direction: column; gap: .25rem; padding-right: 1.5rem; }
.bookcard__title { font-family: var(--display); font-size: 1.4rem; font-weight: 600; line-height: 1.1; }
.bookcard__py { font-family: var(--ui); font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-mute); }
.bookcard__blurb { font-size: .95rem; color: var(--ink-soft); line-height: 1.5; margin-top: .35rem; }

/* =====================================================================
   Home — concept seals
   ===================================================================== */
.seals { max-width: var(--page); margin: 0 auto; padding: clamp(2rem, 5vw, 3.5rem) 1.5rem clamp(4rem, 8vw, 6rem); border-top: 1px solid var(--line); }
.seal-row { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .9rem; justify-content: center; }
.seal-chip {
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  text-decoration: none; color: inherit; width: 6.2rem; padding: 1rem .4rem;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--paper-2);
  transition: border-color .2s, background .2s, transform .2s;
}
.seal-chip:hover { border-color: var(--seal); transform: translateY(-2px); }
.seal-chip__hz { font-family: var(--cn); font-size: 2rem; color: var(--seal); line-height: 1; }
.seal-chip__py { font-family: var(--ui); font-size: .76rem; color: var(--ink-mute); letter-spacing: .04em; }
.seal-chip__nm { font-size: .82rem; color: var(--ink-soft); text-align: center; line-height: 1.2; }

/* =====================================================================
   Reader — book head
   ===================================================================== */
.reading-progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 90; background: transparent; }
.reading-progress span { display: block; height: 100%; width: 0; background: var(--seal); transition: width .1s linear; }

.book { max-width: var(--page); margin: 0 auto; padding: 0 1.4rem 4rem; }
.book-head { position: relative; padding: clamp(3rem, 8vw, 6rem) 0 2rem; text-align: center; overflow: hidden; }
.book-head__ghost {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -54%);
  font-family: var(--cn); font-weight: 700; font-size: clamp(11rem, 34vw, 24rem);
  color: var(--seal); opacity: .07; line-height: .8; pointer-events: none; user-select: none; z-index: 0;
}
.book-head__inner { position: relative; z-index: 1; }
.book-head__title { font-family: var(--display); margin: .7rem 0 .2rem; display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.book-head__hz { font-family: var(--cn); font-weight: 700; font-size: clamp(2.6rem, 9vw, 4.5rem); color: var(--ink); line-height: 1; }
.book-head__en { font-size: clamp(1.5rem, 4vw, 2.2rem); font-weight: 600; font-style: italic; color: var(--ink-soft); }
.book-head__py { font-family: var(--ui); font-size: .8rem; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-mute); margin: 0; }
.book-head__blurb { max-width: 36rem; margin: 1.2rem auto 0; color: var(--ink-soft); font-size: 1.05rem; line-height: 1.55; }
.book-head__count { font-family: var(--ui); font-size: .76rem; letter-spacing: .12em; text-transform: uppercase; color: var(--seal); margin: 1rem 0 0; }

/* reader bar */
.readerbar { position: sticky; top: 3.2rem; z-index: 50; margin: 0 0 1.5rem; }
.readerbar__inner {
  display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; justify-content: center;
  background: rgba(var(--paper-rgb), .9); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 99px; padding: .4rem .55rem; max-width: max-content; margin: 0 auto;
}
.readerbar__label { font-family: var(--ui); font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-mute); padding-left: .5rem; }
.readerbar__group { display: flex; gap: .3rem; }
.pill {
  font-family: var(--ui); font-size: .8rem; font-weight: 600; color: var(--ink-soft);
  background: transparent; border: 1px solid transparent; border-radius: 99px; cursor: pointer;
  padding: .35rem .7rem; display: inline-flex; align-items: center; gap: .35rem; transition: all .2s;
}
.pill__hz { font-family: var(--cn); font-size: .95rem; color: var(--seal); }
.pill[aria-pressed="true"] { background: var(--paper-3); }
.pill[aria-pressed="false"] { color: var(--ink-mute); opacity: .6; }
.pill[aria-pressed="false"] .pill__hz { color: var(--ink-mute); }
.pill:hover { border-color: var(--line-2); }
.pill--focus { border-color: var(--line-2); }
.pill--focus[aria-pressed="true"] { background: var(--seal); color: #fbf4e6; border-color: var(--seal); }

/* jump nav */
.jump { display: flex; align-items: baseline; gap: .8rem; justify-content: center; flex-wrap: wrap;
  max-width: 44rem; margin: 0 auto 2.5rem; padding-bottom: 1.8rem; border-bottom: 1px solid var(--line); }
.jump__label { font-family: var(--display); font-size: 1.2rem; font-weight: 600; color: var(--seal); }
.jump__nums { display: flex; flex-wrap: wrap; gap: .15rem .1rem; }
.jump__nums a {
  font-family: var(--ui); font-size: .82rem; color: var(--ink-mute); text-decoration: none;
  min-width: 1.7rem; height: 1.7rem; display: grid; place-items: center; border-radius: var(--r); transition: all .15s;
}
.jump__nums a:hover, .jump__nums a.is-current { background: var(--seal); color: #fbf4e6; }

/* =====================================================================
   Reader — the sayings
   ===================================================================== */
.scroll { display: block; }
.saying {  /* mobile-first: stacked. The gutter + rail layout is a wide-screen enhancement. */
  display: grid;
  grid-template-columns: 1fr;
  row-gap: 1rem;
  padding: 2.1rem 0;
  border-top: 1px solid var(--line);
  scroll-margin-top: 6.5rem;
}
.saying:first-child { border-top: 0; }

.saying__meta { display: flex; flex-flow: row wrap; gap: .6rem 1rem; align-items: center; }
.saying__ref { text-decoration: none; display: inline-flex; flex-direction: row; align-items: baseline; gap: .35rem; line-height: 1;
  border: 1px solid var(--line-2); border-radius: var(--r); padding: .3rem .6rem; background: var(--paper-2); transition: border-color .2s; }
.saying__ref:hover { border-color: var(--seal); }
.saying__bk { font-family: var(--display); font-size: .95rem; font-weight: 600; color: var(--ink-mute); }
.saying__no { font-family: var(--display); font-size: 1.5rem; font-weight: 600; color: var(--seal); }
.saying__by { display: flex; flex-direction: column; text-decoration: none; gap: .05rem; }
.saying__by-hz { font-family: var(--cn); font-size: 1rem; color: var(--ink-soft); }
.saying__by-nm { font-family: var(--ui); font-size: .68rem; color: var(--ink-mute); letter-spacing: .03em; line-height: 1.15; }
.saying__by:hover .saying__by-nm { color: var(--seal); }
.saying__themes { display: flex; flex-flow: row wrap; gap: .25rem .8rem; }
.chip {
  font-family: var(--ui); font-size: .66rem; color: var(--ink-mute); text-decoration: none;
  display: inline-flex; align-items: center; gap: .3rem; letter-spacing: .02em;
}
.chip:hover { color: var(--seal); }
.chip__hz { font-family: var(--cn); }
.chip .chip__t { border-bottom: 1px dotted var(--line-2); padding-bottom: 1px; }

.saying__text { max-width: var(--measure); position: relative; }
.verse { font-size: 1.18rem; line-height: 1.78; margin: 0 0 .55rem; text-wrap: pretty; }
.verse:last-of-type { margin-bottom: 0; }
.verse .v {
  font-family: var(--ui); font-size: .66rem; font-weight: 700; color: var(--seal);
  vertical-align: .35em; margin-right: .45rem; letter-spacing: 0;
}
.verse .v::before { content: ""; }

/* concept terms */
.term {
  position: relative; cursor: help; color: inherit;
  background-image: linear-gradient(transparent 60%, rgba(168,50,42,.14) 0);
  border-bottom: 1px solid rgba(168,50,42,.45);
  border-radius: 1px;
}
html.ink .term { background-image: linear-gradient(transparent 60%, rgba(217,96,79,.18) 0); border-bottom-color: rgba(217,96,79,.5); }
.term:hover, .term:focus-visible { background-color: rgba(168,50,42,.10); }
.term:hover { outline: none; }
.term__pop {
  position: absolute; left: 0; top: calc(100% + .6rem); z-index: 40;
  width: min(20rem, 78vw); background: var(--paper); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: var(--r); padding: .9rem 1rem 1rem;
  box-shadow: 0 12px 34px rgba(var(--shadow), .28);
  opacity: 0; visibility: hidden; transform: translateY(-4px); transition: opacity .18s, transform .18s;
  font-family: var(--serif); pointer-events: none;
}
.term:hover .term__pop, .term:focus-within .term__pop { opacity: 1; visibility: visible; transform: translateY(0); }
.term__pop::before { content: ""; position: absolute; bottom: 100%; left: 1.2rem; border: 7px solid transparent; border-bottom-color: var(--line-2); }
.term__hz { font-family: var(--cn); font-weight: 700; font-size: 2rem; color: var(--seal); line-height: 1; display: block; float: right; margin: -.1rem 0 .2rem .7rem; }
.term__head { display: flex; flex-direction: column; }
.term__py { font-family: var(--ui); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-mute); }
.term__nm { font-family: var(--display); font-size: 1.3rem; font-weight: 600; line-height: 1.1; }
.term__df { display: block; clear: both; font-size: .92rem; line-height: 1.5; color: var(--ink-soft); margin-top: .5rem; }

/* margin glosses */
.gloss {
  font-family: var(--ui); margin: 1.1rem 0 .2rem;
  border-left: 2px solid var(--seal); padding-left: .9rem;
}
.gloss__head { display: flex; align-items: center; gap: .5rem; background: none; border: 0; padding: 0; cursor: default; }
.gloss__hz { font-family: var(--cn); font-size: 1rem; color: var(--seal); }
.gloss__who { font-size: .68rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-mute); }
.gloss__body { margin-top: .35rem; }
.gloss__body p { font-family: var(--serif); font-size: .93rem; line-height: 1.55; color: var(--ink-soft); margin: 0; }
.gloss--today { border-left-color: var(--jade); }
.gloss--today .gloss__hz, .gloss--today .gloss__who { color: var(--jade); }
.gloss--link { border-left-color: var(--gold); }
.gloss--link .gloss__hz, .gloss--link .gloss__who { color: var(--gold); }

/* voice hide / focus */
body.hide-note .gloss--note,
body.hide-today .gloss--today,
body.hide-link .gloss--link { display: none; }
body.focus-reading .gloss { display: none; }
body.focus-reading .saying__themes { display: none; }

/* book foot nav */
.booknav { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: stretch;
  margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--line); }
.booknav__side { text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: .25rem;
  padding: 1rem 1.2rem; border: 1px solid var(--line); border-radius: var(--r); transition: border-color .2s; }
.booknav__side:hover { border-color: var(--seal); }
.booknav__next { text-align: right; align-items: flex-end; }
.booknav__dir { font-family: var(--ui); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--seal); }
.booknav__name { font-family: var(--display); font-size: 1.15rem; font-weight: 600; }
.booknav__top { display: grid; place-items: center; width: 3rem; color: var(--ink-mute); text-decoration: none;
  border: 1px solid var(--line); border-radius: var(--r); }
.booknav__top:hover { color: var(--seal); border-color: var(--seal); }

/* =====================================================================
   Threads (theme pages) + cards
   ===================================================================== */
.thread-head { position: relative; text-align: center; padding: 1rem 0 2.4rem; margin-bottom: 2.4rem; border-bottom: 1px solid var(--line); overflow: hidden; }
.thread-head__ghost { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  font-family: var(--cn); font-weight: 700; font-size: clamp(8rem, 26vw, 16rem); color: var(--seal); opacity: .07; pointer-events: none; }
.thread-head__title { position: relative; font-family: var(--display); margin: .6rem 0 .3rem; display: flex; flex-direction: column; align-items: center; gap: .15rem; }
.thread-head__hz { font-family: var(--cn); font-weight: 700; font-size: clamp(2.4rem, 8vw, 3.6rem); }
.thread-head__en { font-size: clamp(1.6rem, 4vw, 2.3rem); font-weight: 600; font-style: italic; color: var(--ink-soft); }
.thread-head__blurb { position: relative; max-width: 34rem; margin: .8rem auto 0; color: var(--ink-soft); }
.thread-head__count { position: relative; font-family: var(--ui); font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--seal); margin-top: 1rem; }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr)); }
.card__link { display: block; text-decoration: none; color: inherit; height: 100%;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r);
  padding: 1.1rem 1.25rem; transition: border-color .2s, transform .2s; }
.card__link:hover { border-color: var(--seal); transform: translateY(-2px); }
.card__ref { font-family: var(--display); font-size: 1.05rem; font-weight: 600; color: var(--seal); display: block; }
.card__snip { display: block; font-size: .98rem; line-height: 1.5; margin-top: .35rem; }
.card__by { display: block; font-family: var(--ui); font-size: .72rem; color: var(--ink-mute); margin-top: .6rem; letter-spacing: .03em; }

.thread-foot { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--line); }
.thread-foot__label { font-family: var(--ui); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-mute); display: block; margin-bottom: .9rem; }
.thread-foot__links { display: flex; flex-wrap: wrap; gap: .5rem .9rem; }
.thread-foot__links a { font-family: var(--ui); font-size: .9rem; color: var(--ink-soft); text-decoration: none; }
.thread-foot__links a:hover { color: var(--seal); }

/* threads index grid */
.threadgrid { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }
.threadcard__link { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: .45rem;
  text-decoration: none; color: inherit; height: 100%; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: var(--r); padding: 1.4rem 1.4rem 1.6rem; transition: border-color .2s, transform .2s; }
.threadcard__link:hover { border-color: var(--seal); transform: translateY(-2px); }
.threadcard__hz { position: absolute; right: -.4rem; bottom: -1.2rem; font-family: var(--cn); font-weight: 700;
  font-size: 6rem; color: var(--seal); opacity: .1; line-height: 1; pointer-events: none; }
.threadcard__name { font-family: var(--display); font-size: 1.5rem; font-weight: 600; line-height: 1.1; }
.threadcard__py { font-family: var(--ui); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-mute); display: block; margin-top: .2rem; }
.threadcard__blurb { font-size: .95rem; color: var(--ink-soft); line-height: 1.5; position: relative; }

/* =====================================================================
   Concepts glossary
   ===================================================================== */
.glossary { display: grid; gap: 1.2rem; }
.entry { display: grid; grid-template-columns: 5.5rem 1fr; gap: 1.4rem; align-items: start;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r); padding: 1.5rem 1.6rem; scroll-margin-top: 6rem; }
.entry:target { border-color: var(--seal); box-shadow: 0 0 0 1px var(--seal); }
.entry__seal { width: 5.5rem; height: 5.5rem; display: grid; place-items: center; border-radius: var(--r);
  background: var(--seal); box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); }
.entry__hz { font-family: var(--cn); font-weight: 700; font-size: 2.8rem; color: #fbf4e6; line-height: 1; }
.entry__title { display: flex; flex-direction: column; gap: .1rem; margin-bottom: .55rem; }
.entry__py { font-family: var(--ui); font-size: .76rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-mute); }
.entry__nm { font-family: var(--display); font-size: 1.85rem; font-weight: 600; line-height: 1; }
.entry__legge { font-size: .94rem; color: var(--ink-soft); margin-bottom: .5rem; }
.entry__tag { font-family: var(--ui); font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--seal); margin-right: .3rem; }
.entry__gloss { line-height: 1.6; }
.entry__find { margin-top: .8rem; display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; }
.entry__find a { font-family: var(--ui); font-size: .85rem; font-weight: 600; color: var(--seal); text-decoration: none; }
.entry__find a:hover { text-decoration: underline; text-underline-offset: 3px; }
.entry__count { font-family: var(--ui); font-size: .76rem; color: var(--ink-mute); }

/* =====================================================================
   People
   ===================================================================== */
.who { margin-bottom: 3rem; }
.who__head { font-family: var(--display); font-size: 1.7rem; font-weight: 600; margin-bottom: 1.3rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line); }
.who__grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(21rem, 1fr)); }
.person { display: grid; grid-template-columns: 3.6rem 1fr; gap: 1rem; align-items: start;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r); padding: 1.1rem 1.2rem; scroll-margin-top: 6rem; }
.person:target { border-color: var(--seal); }
.person__seal { width: 3.6rem; height: 3.6rem; display: grid; place-items: center; border-radius: var(--r);
  border: 1px solid var(--line-2); background: var(--paper); }
.person__hz { font-family: var(--cn); font-weight: 700; font-size: 1.6rem; color: var(--seal); line-height: 1; }
.person__name { font-family: var(--display); font-size: 1.32rem; font-weight: 600; line-height: 1.1; display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; }
.person__also { font-family: var(--ui); font-size: .72rem; font-weight: 500; color: var(--ink-mute); letter-spacing: .02em; text-transform: none; }
.person__meta { font-family: var(--ui); font-size: .74rem; color: var(--ink-mute); letter-spacing: .03em; margin: .15rem 0 .5rem; }
.person__note { font-size: .96rem; line-height: 1.55; color: var(--ink-soft); }

/* =====================================================================
   Table of contents (read)
   ===================================================================== */
.toc { list-style: none; margin: 0; padding: 0; }
.toc__item + .toc__item { border-top: 1px solid var(--line); }
.toc__link { display: grid; grid-template-columns: 3rem 2.4rem 1fr auto; gap: 1.1rem; align-items: center;
  text-decoration: none; color: inherit; padding: 1.1rem .6rem; transition: background .2s, padding .2s; }
.toc__link:hover { background: var(--paper-2); padding-left: 1rem; }
.toc__num { font-family: var(--display); font-size: 1.4rem; font-weight: 600; color: var(--seal); text-align: center; }
.toc__hz { font-family: var(--cn); font-size: 1.5rem; color: var(--ink-mute); text-align: center; }
.toc__title { font-family: var(--display); font-size: 1.35rem; font-weight: 600; display: flex; flex-wrap: wrap; align-items: baseline; gap: .6rem; }
.toc__py { font-family: var(--ui); font-size: .72rem; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-mute); }
.toc__blurb { display: block; font-size: .94rem; color: var(--ink-soft); line-height: 1.5; margin-top: .15rem; }
.toc__count { font-family: var(--ui); font-size: .8rem; color: var(--ink-mute); min-width: 1.6rem; text-align: right; white-space: nowrap; }
.toc__count::after { content: " sayings"; opacity: .72; }

/* =====================================================================
   Search
   ===================================================================== */
.searchbox { display: flex; align-items: center; gap: .8rem; background: var(--paper-2);
  border: 1px solid var(--line-2); border-radius: 99px; padding: .3rem 1.3rem; margin-bottom: 1.2rem; }
.searchbox:focus-within { border-color: var(--seal); }
.searchbox__icon { width: 1.3rem; height: 1.3rem; color: var(--ink-mute); flex: none; }
.searchbox__input { flex: 1; background: none; border: 0; outline: none; color: var(--ink);
  font-family: var(--serif); font-size: 1.2rem; padding: .8rem 0; }
.searchbox__input::placeholder { color: var(--ink-mute); }
.searchhints { font-family: var(--ui); font-size: .86rem; color: var(--ink-mute); display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1.5rem; }
.searchhints a { color: var(--seal); text-decoration: none; border: 1px solid var(--line-2); border-radius: 99px; padding: .15rem .7rem; }
.searchhints a:hover { background: var(--paper-3); }
.searchcount { font-family: var(--ui); font-size: .84rem; color: var(--ink-mute); margin-bottom: 1rem; min-height: 1.2rem; }
.results { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; }
.result__link { display: block; text-decoration: none; color: inherit; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.2rem; transition: border-color .2s; }
.result__link:hover { border-color: var(--seal); }
.result__top { display: flex; align-items: baseline; gap: .8rem; margin-bottom: .35rem; }
.result__ref { font-family: var(--display); font-weight: 600; color: var(--seal); font-size: 1.05rem; }
.result__by { font-family: var(--ui); font-size: .72rem; color: var(--ink-mute); letter-spacing: .03em; }
.result__snip { font-size: .98rem; line-height: 1.55; }
.result__snip mark { background: rgba(168,50,42,.2); color: inherit; border-radius: 2px; padding: 0 .1em; }
html.ink .result__snip mark { background: rgba(217,96,79,.28); }
.result__empty { color: var(--ink-mute); font-style: italic; }

/* =====================================================================
   Footer
   ===================================================================== */
.colophon { border-top: 1px solid var(--line); margin-top: 0; background: var(--paper-2); }
.colophon__inner { max-width: 46rem; margin: 0 auto; padding: 3rem 1.5rem 3.5rem; text-align: center; }
.colophon__seal { font-family: var(--cn); font-weight: 700; font-size: 1.8rem; color: var(--seal); letter-spacing: .1em; display: block; margin-bottom: 1rem; }
.colophon__line { font-size: 1.02rem; line-height: 1.6; }
.colophon__meta { font-family: var(--ui); font-size: .82rem; color: var(--ink-mute); line-height: 1.6; margin-top: 1rem; }
.colophon__meta a { color: var(--seal); text-decoration: none; }
.colophon__meta a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* =====================================================================
   Wide screens — float the glosses into a right rail
   ===================================================================== */
@media (min-width: 60rem) {
  .saying { grid-template-columns: var(--gutter) minmax(0, 1fr); column-gap: 1.5rem; row-gap: 0; padding: 2.4rem 0; scroll-margin-top: 7rem; }
  .saying__meta { grid-column: 1; flex-direction: column; align-items: flex-start; gap: .7rem; padding-top: .3rem; }
  .saying__ref { flex-direction: column; align-items: center; gap: 0; width: 3.1rem; padding: .35rem .1rem .3rem; }
  .saying__themes { flex-direction: column; gap: .25rem; }
  .saying__text { grid-column: 2; padding-right: calc(var(--rail) + 1.5rem); }
  .gloss { float: right; clear: right; width: var(--rail); margin-right: calc(-1 * (var(--rail) + 1.5rem));
    margin-top: 0; margin-bottom: 1.1rem; }
  .saying__text .verse + .gloss { margin-top: -1.9rem; }
}

/* =====================================================================
   Narrow screens
   ===================================================================== */
@media (max-width: 60rem) {
  .ways__grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 48rem) {
  .masthead__burger { display: flex; }
  .masthead__links {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--paper); border-bottom: 1px solid var(--line);
    padding: .5rem 1rem 1rem; display: none;
    box-shadow: 0 16px 30px rgba(var(--shadow), .18);
  }
  .masthead__links.is-open { display: flex; }
  .navlink { padding: .8rem .5rem; border-bottom: 1px solid var(--line); }
  .navlink--icon { justify-content: flex-start; }
  .masthead__links .theme-toggle { width: auto; margin: .8rem 0 0; }

  .saying__text { max-width: 100%; }
  .entry { grid-template-columns: 1fr; }
  .entry__seal { width: 4rem; height: 4rem; }
  .entry__hz { font-size: 2.1rem; }
  .toc__link { grid-template-columns: 2.2rem 1fr auto; }
  .toc__hz { display: none; }
}
@media (max-width: 30rem) {
  .ways__grid { grid-template-columns: 1fr; }
}
