/* =============================================================
   雜阿含經讀經站 - styles
   Light + dark themes, mobile-first responsive, Chinese typography
   ============================================================= */

:root {
  /* Light theme (default) */
  --bg:               #faf7f0;     /* warm off-white, easy on the eye */
  --bg-elev:          #ffffff;
  --bg-subtle:        #f0ece2;
  --bg-tint:          #f5efe1;     /* very faint paper tone, between bg and bg-subtle */
  --text:             #1c1a14;
  --text-soft:        #4a463c;
  --text-muted:       #6e6757;     /* darkened from #7a7466 → 5.0:1 contrast on bg, AA pass */
  --border:           #e2dccd;
  --border-strong:    #c8c0aa;
  --hairline:         rgba(139, 90, 43, .14);
  --accent:           #8b5a2b;     /* warm bronze/古銅 */
  --accent-soft:      #a07e52;     /* darkened from #b8916b → 3.5:1 on bg, AA UI-component pass */
  --accent-tint:      rgba(139, 90, 43, .08);
  --accent-hover:     #6f4720;     /* darker bronze for primary-button hover */
  --accent-warning:   #715815;     /* dark gold for emphasis on warm bg, AA pass */
  --accent-warning-bg:#fbf3df;     /* cream-yellow background for disclaimers */
  --link:             #6b4a2b;
  --link-hover:       #2c1f10;
  --verse-bg:         #f5f0e3;
  --note-bg:          #f8f4ea;
  --south-bg:         #f1f5f0;     /* faint green-tinted background for southern */
  --south-border:     #c5d4c4;
  --code-bg:          #ece6d3;
  --shadow:           0 1px 3px rgba(60, 50, 30, .08);
  --shadow-md:        0 4px 14px rgba(60, 50, 30, .10);
  --shadow-lg:        0 10px 28px rgba(60, 50, 30, .14);

  --font-sans:        -apple-system, "PingFang TC", "PingFang SC", "Helvetica Neue", "Microsoft JhengHei", "微軟正黑體", sans-serif;
  --font-serif:       "Source Han Serif TC", "Noto Serif TC", "Songti TC", "STSong", "PMingLiU", "Times New Roman", serif;
  --font-mono:        "SF Mono", Menlo, Consolas, monospace;

  /* Body reading text — DEFAULT 20px (was 17→18 historically). 大/小 button
     scales ONLY this token. Section-heading + AI disclaimer are tied to
     this via calc() so they scale together with reading body. UI tokens
     below stay fixed in px so nav/meta/footer don't jump around when the
     reader adjusts size — preserves visual rhythm. */
  --reading-base:     1.25rem;
  --reading-line:     2.0;
  --reading-letter:   .02em;
  --reading-max:      720px;

  --radius:           6px;
  --radius-lg:        12px;

  /* 8pt spacing scale (Spec.fm) — fixed px so page rhythm is stable. */
  --space-1:          4px;
  --space-2:          8px;
  --space-3:          16px;
  --space-4:          24px;
  --space-5:          32px;
  --space-6:          48px;
  --space-7:          64px;
  --space-8:          96px;
  --space-9:          128px;

  /* Modular type scale, fixed px — UI text (nav, footer, meta-line,
     eyebrows, buttons, breadcrumbs) uses these. Intentionally NOT scaled
     by 大/小 so the visual hierarchy stays stable when readers adjust the
     reading body. */
  --text-xs:          13px;
  --text-sm:          14px;
  --text-base:        17px;
  --text-md:          21px;
  --text-lg:          26px;
  --text-xl:          33px;
  --text-2xl:         41px;
  --text-3xl:         51px;
  --text-4xl:         64px;

  /* Easing curves (out-quint feels natural for UI) */
  --ease-out:         cubic-bezier(.22, 1, .36, 1);
  --ease-out-soft:    cubic-bezier(.16, 1, .3, 1);
}

html[data-theme="dark"] {
  --bg:               #181612;
  --bg-elev:          #221e18;
  --bg-subtle:        #2b261e;
  --bg-tint:          #1f1c16;
  --text:             #e8dec6;
  --text-soft:        #c4b896;
  --text-muted:       #998c70;
  --border:           #3a3326;
  --border-strong:    #524833;
  --hairline:         rgba(216, 168, 107, .14);
  --accent:           #d8a86b;
  --accent-soft:      #b08a52;
  --accent-tint:      rgba(216, 168, 107, .10);
  --accent-hover:     #b08a52;
  --accent-warning:   #e8c989;
  --accent-warning-bg:#2c2517;
  --link:             #d8a86b;
  --link-hover:       #f0c98a;
  --verse-bg:         #251f17;
  --note-bg:          #221d15;
  --south-bg:         #1d2419;
  --south-border:     #3a4632;
  --code-bg:          #2a241b;
  --shadow:           0 1px 3px rgba(0, 0, 0, .4);
  --shadow-md:        0 4px 14px rgba(0, 0, 0, .35);
  --shadow-lg:        0 10px 28px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  /* Prevent iOS auto-zoom of small text fields */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* CJK baseline per W3C clreq + Bobby Tung: Chrome 123+ honors these; Safari TP gates them harmlessly.
     'palt' is intentionally NOT global — for Traditional Chinese body it collapses 全形標點. Apply
     palt only to UI strings that mix Han + Latin tightly (eyebrows, IDs, credit lines). */
  text-spacing-trim: trim-start;
  text-autospace: normal;
  hanging-punctuation: allow-end last;
}
.intro-card-eyebrow,
.vol-num,
.vol-count {
  font-feature-settings: "palt" 1;
}

body { min-height: 100vh; display: flex; flex-direction: column; }

/* Brand-tinted text selection (replaces default browser blue) */
::selection {
  background: rgba(139, 90, 43, .22);   /* var(--accent) at 22% opacity */
  color: inherit;
  text-shadow: none;
}
html[data-theme="dark"] ::selection {
  background: rgba(216, 168, 107, .28);
}

/* iOS tap defaults: kill 300ms delay + grey flash on every interactive control */
button, a, input, [role="button"], [data-action], [data-share] {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Make `<main tabindex="-1">` invisible-focused when reached via skip-link */
main:focus { outline: none; }
main:focus-visible { outline: none; }

/* Visual hint for nav link of current section */
.primary-nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* Respect users who prefer reduced motion (vestibular disorders, etc.) */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color .15s;
}
a:hover { color: var(--link-hover); text-decoration: underline; text-underline-offset: 3px; }

/* Skip-to-content link: hidden until keyboard focus, then becomes a polished pill */
.skip-link {
  position: absolute;
  top: .75rem;
  left: 50%;
  transform: translateX(-50%) translateY(-200%);
  background: var(--accent);
  color: #fff;
  padding: .55em 1.2em;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: .9rem;
  letter-spacing: .04em;
  box-shadow: 0 4px 14px rgba(60, 50, 30, .22);
  z-index: 1000;
  transition: transform .18s ease-out;
}
.skip-link:focus,
.skip-link:focus-visible {
  transform: translateX(-50%) translateY(0);
  outline: none;
  text-decoration: none;
}

/* ============ Header ============ */
.site-header {
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: saturate(1.2);
}
.header-inner {
  max-width: 1100px; margin: 0 auto;
  /* Honor notch insets so brand/nav don't get clipped on iPhone landscape */
  padding: .95rem max(1.5rem, env(safe-area-inset-right)) .95rem max(1.5rem, env(safe-area-inset-left));
  display: flex; align-items: center; gap: 1.5rem;
}
.brand {
  display: inline-flex; align-items: center; gap: .75rem;
  color: var(--text); text-decoration: none;
  font-weight: 600;
}
.brand-mark {
  display: inline-block;
  width: 2.5rem;
  height: 2.5rem;
  color: var(--accent);
  flex-shrink: 0;
}
.brand-mark svg {
  display: block;
  width: 100%;
  height: 100%;
}
.brand-text {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.2;
  letter-spacing: .04em;
}
.brand-name {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: .1em;
}
.brand-tagline {
  font-size: .82rem;
  color: var(--text-muted);
  letter-spacing: .08em;
  margin-top: 2px;
}
.primary-nav {
  display: flex; gap: 1.6rem; flex: 1;
  font-size: 1.1rem;
  font-family: var(--font-serif);
  letter-spacing: .08em;
  overflow-x: auto;
  scrollbar-width: none;
}
.primary-nav::-webkit-scrollbar { display: none; }
.primary-nav a {
  color: var(--text-soft);
  padding: .35rem .2rem;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color .15s, border-color .15s;
}
.primary-nav a:hover { color: var(--text); border-bottom-color: var(--accent); text-decoration: none; }
.header-tools { display: flex; gap: .5rem; align-items: center; }
.tool-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-soft);
  padding: .55rem .9rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1rem;
  font-family: inherit;
  min-width: 2.5rem;
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.tool-btn:hover { background: var(--bg-subtle); color: var(--text); border-color: var(--accent); }
.tool-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}
.tool-btn:disabled:hover {
  background: transparent;
  color: var(--text-soft);
  border-color: var(--border-strong);
}
/* (.tool-divider previously added extra margin to visually separate the
   theme toggle. Removed for uniform-gap rhythm — see header-tools gap.) */

@media (max-width: 880px) {
  .header-inner { gap: 1rem; padding: .8rem 1rem; }
  .brand-mark { width: 2.2rem; height: 2.2rem; }
  .brand-name { font-size: 1.2rem; letter-spacing: .08em; }
  .brand-tagline { font-size: .75rem; }
  .primary-nav { gap: 1.1rem; font-size: 1rem; }
  /* WCAG 2.5.5 — touch-target 44x44 floor on tablet */
  .tool-btn { padding: .55rem .8rem; font-size: .95rem; min-width: 2.85rem; min-height: 2.85rem; }
}
@media (max-width: 640px) {
  .header-inner { gap: .6rem; padding: .65rem .8rem; }
  .brand-tagline { display: none; }
  .brand-mark { width: 2rem; height: 2rem; }
  .brand-name { font-size: 1.1rem; letter-spacing: .06em; }
  .primary-nav { gap: .85rem; font-size: .95rem; }
  .header-tools { gap: .35rem; }
  /* WCAG 2.5.5 — touch-target 44x44 floor on phone */
  .tool-btn { padding: .55rem .65rem; font-size: .9rem; min-width: 2.85rem; min-height: 2.85rem; }
}
@media (max-width: 480px) {
  .brand-text { display: none; }
}
@media (max-width: 380px) {
  .primary-nav { gap: .65rem; font-size: .9rem; }
}

/* ============ Main ============ */
.site-main {
  flex: 1;
  padding: 2rem 1.2rem 4rem;
  max-width: var(--reading-max);
  margin: 0 auto;
  width: 100%;
}
/* Index, volume, about: wider container so the listing has room to breathe */
body.page-home .site-main { max-width: 1080px; padding-top: var(--space-3); padding-bottom: var(--space-7); }
body.page-volume .site-main,
body.page-about .site-main { max-width: 960px; }
@media (max-width: 640px) {
  .site-main { padding: 1.4rem .9rem 3rem; }
}

/* Shared focus-visible ring (a11y) */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.btn:focus-visible,
.tool-btn:focus-visible,
.float-btn:focus-visible,
.view-btn:focus-visible,
.vol-card:focus-visible,
.sutra-list a:focus-visible,
.pager-prev:focus-visible,
.pager-next:focus-visible,
.pager-random:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============ Footer ============ */
.site-footer {
  background: var(--bg-subtle);
  border-top: 1px solid var(--border);
  padding: 1.5rem 1rem;
  margin-top: auto;
  font-size: .85rem;
  color: var(--text-muted);
}
.footer-inner {
  max-width: 1100px; margin: 0 auto;
  text-align: center;
}
.footer-inner p { margin: .25rem 0; }
.footer-license {
  margin-top: .8rem;
  padding-top: .8rem;
  border-top: 1px solid var(--border);
  font-size: .78rem;
  color: var(--text-muted);
  letter-spacing: .03em;
  opacity: .85;
}
.footer-license a {
  color: var(--text-soft);
  border-bottom: 1px dotted var(--border-strong);
}
.footer-license a:hover { color: var(--text); border-bottom-style: solid; text-decoration: none; }

/* ============ Breadcrumb ============ */
.breadcrumb {
  font-size: .9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}
.breadcrumb a { color: var(--text-soft); }
.breadcrumb .sep { margin: 0 .4rem; color: var(--text-muted); }

/* ============ Hero (homepage) ============ */
.hero {
  position: relative;
  text-align: center;
  padding: var(--space-7) var(--space-3) var(--space-7);
  display: flex;
  flex-direction: column;
  align-items: center;
  isolation: isolate;
  max-width: 640px;
  margin: 0 auto;
}

.hero-title {
  font-family: var(--font-serif);
  /* Editorial restraint: 168px was too billboard-loud for a meditation
     reading site. Topped at 128px so 「如是」reads as logotype, not headline. */
  font-size: clamp(80px, 11vw, 128px);
  margin: 0;
  letter-spacing: .12em;
  text-indent: .12em;
  color: var(--text);
  font-weight: 500;
  line-height: 1.0;
}
.hero-tagline {
  font-family: var(--font-serif);
  font-size: var(--text-md);
  color: var(--text-soft);
  margin: var(--space-3) 0 0;
  letter-spacing: .12em;
  text-indent: .12em;
  font-weight: 400;
}
.hero-meta {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-muted);
  letter-spacing: .06em;
  margin: var(--space-3) auto 0;
  max-width: 36em;
  text-align: center;
  line-height: 1.7;
}
@media (max-width: 540px) {
  .hero-meta { font-size: 12.5px; padding: 0 var(--space-3); }
}
@media (max-width: 640px) {
  .hero { padding: var(--space-6) var(--space-2) var(--space-5); }
  .hero-title { font-size: clamp(72px, 22vw, 96px); letter-spacing: .12em; text-indent: .12em; }
  .hero-tagline { font-size: var(--text-base); margin: var(--space-2) 0 var(--space-4); }
  .hero-lede { font-size: var(--text-base); line-height: 1.7; margin-bottom: var(--space-5); }
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5em;
  padding: 12px 28px;
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--text);
  text-decoration: none;
  font-size: var(--text-sm);
  font-family: inherit;
  letter-spacing: .08em;
  transition: transform .2s var(--ease-out), border-color .2s var(--ease-out), background .2s var(--ease-out), color .2s var(--ease-out), box-shadow .2s var(--ease-out);
  cursor: pointer;
  font-weight: 500;
}
.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
  box-shadow: 0 6px 16px rgba(139, 90, 43, .25);
}
/* Dark-mode primary CTA: white-on-bronze fails AA (2.16:1). Use dark text on the
   lighter bronze accent instead — yields ~8.4:1, well above AA 4.5:1. */
html[data-theme="dark"] .btn-primary {
  color: #181612;
}
html[data-theme="dark"] .btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #181612;
}
html[data-theme="dark"] .entry-tile-cta-filled,
html[data-theme="dark"] .entry-tile-jump-go {
  color: #181612;
}

/* ============ Jump-to-sutra (homepage) ============ */
.jump-box {
  margin: 0 auto;
  max-width: 420px;
  width: 100%;
  display: flex; flex-direction: column; align-items: center;
  gap: var(--space-2);
}
.jump-box-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: .22em;
  text-indent: .22em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}
.jump-box-row {
  display: flex;
  align-items: stretch;
  gap: var(--space-2);
  width: 100%;
}

/* Unified search-bar group: 第 │ input │ 經 share one border */
.jump-input-group {
  display: flex;
  flex: 1;
  align-items: stretch;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elev);
  transition: border-color .2s var(--ease-out), box-shadow .2s var(--ease-out);
}
.jump-input-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 90, 43, .12);
}
html[data-theme="dark"] .jump-input-group:focus-within {
  box-shadow: 0 0 0 3px rgba(216, 168, 107, .18);
}
.jump-box-prefix,
.jump-box-suffix {
  display: inline-grid; place-items: center;
  padding: 0 .9rem;
  background: var(--bg-subtle);
  font-family: var(--font-serif);
  color: var(--text-soft);
  font-size: .95rem;
  letter-spacing: .04em;
  user-select: none;
}
.jump-box-prefix { border-right: 1px solid var(--border); }
.jump-box-suffix { border-left: 1px solid var(--border); }

#jump-input {
  flex: 1;
  padding: .65rem .9rem;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 1rem;
  /* Container shows :focus-within ring; suppress on input but restore visible
     ring for keyboard-only focus when input is reached without a parent ring. */
  outline: none;
  min-width: 0;
  text-align: center;
}
#jump-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}
#jump-input::placeholder {
  color: var(--text-muted);
  opacity: .6;
}

/* Jump-form submit: square corners to match the rectangular input group it sits next to. */
.btn-jump {
  padding: 0 1.2rem;
  font-size: var(--text-sm);
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 0;
  border-radius: var(--radius);
  letter-spacing: .08em;
}

.jump-box-hint {
  font-size: .78rem;
  color: var(--text-muted);
  letter-spacing: .04em;
}
.jump-box.is-error .jump-input-group {
  border-color: #b95a47;
  box-shadow: 0 0 0 3px rgba(185, 90, 71, .15);
}
.jump-box.is-error .jump-box-hint {
  color: #b95a47;
}

/* ============ Section heading (homepage) ============ */
.section-heading {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: 500;
  margin: 0 0 var(--space-5);
  color: var(--text);
  letter-spacing: .14em;
  text-indent: .14em;
  display: block;
  line-height: 1.25;
  text-align: center;
}
@media (max-width: 640px) {
  .section-heading { font-size: var(--text-lg); margin-bottom: var(--space-4); }
}

/* ============ Volume grid (homepage) ============ */
.volumes-grid {
  margin: 0 0 var(--space-8);
}
.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-3);
}
@media (max-width: 880px) {
  .grid { grid-template-columns: repeat(4, 1fr); gap: var(--space-3); }
}
@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .volumes-grid { margin-bottom: var(--space-7); }
}
@media (max-width: 380px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}
.vol-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: var(--space-3);
  align-items: baseline;
  padding: 14px var(--space-3) 14px;
  background: var(--bg-elev);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  transition: transform .22s var(--ease-out), border-color .22s var(--ease-out);
  overflow: hidden;
  isolation: isolate;
}
.vol-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  text-decoration: none;
}
.vol-num {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: var(--text-md);
  font-weight: 400;
  letter-spacing: -.01em;
  grid-column: 1;
  grid-row: 1 / span 2;
  align-self: center;
  line-height: 1;
  transition: color .22s var(--ease-out);
}
.vol-card:hover .vol-num { color: var(--accent); }
.vol-name {
  font-family: var(--font-serif);
  font-size: var(--text-base);
  font-weight: 500;
  letter-spacing: .06em;
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  align-self: end;
  line-height: 1.3;
}
.vol-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: .06em;
  grid-column: 2;
  grid-row: 2;
  align-self: start;
  margin-top: 3px;
}
@media (max-width: 380px) {
  .vol-card { padding: 12px 14px; column-gap: 12px; }
  .vol-num { font-size: var(--text-base); }
  .vol-name { font-size: 15px; }
}

/* ============ Reading entry grid (homepage) ============ */
/* Three equal-weight tiles side by side. Each tile is a "doorway"
   into the scripture — equal visual weight, no primary/secondary. */
.entry-grid {
  margin: 0 0 var(--space-8);
}
.entry-grid > .section-eyebrow {
  display: block;
  text-align: center;
  margin-bottom: var(--space-4);
}
.entry-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}

.entry-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  padding: var(--space-5) var(--space-4);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  transition: transform .25s var(--ease-out), border-color .25s var(--ease-out), box-shadow .25s var(--ease-out), background .25s var(--ease-out);
  isolation: isolate;
  overflow: hidden;
}
.entry-tile:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(60, 50, 30, .12);
  text-decoration: none;
  background: var(--bg-elev);
}
html[data-theme="dark"] .entry-tile:hover {
  box-shadow: 0 10px 24px rgba(0, 0, 0, .35);
}
.entry-tile-title {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 500;
  margin: 0 0 var(--space-2);
  color: var(--text);
  letter-spacing: .12em;
  text-indent: .12em;
  line-height: 1.3;
  display: block;
}
.entry-tile-desc {
  font-family: var(--font-serif);
  font-size: 15px;
  color: var(--text-soft);
  margin: 0 0 var(--space-4);
  line-height: 1.6;
  letter-spacing: .08em;
  text-indent: .08em;
  display: block;
}

/* Each tile has a distinct CTA style to convey its function */
.entry-tile-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55em;
  height: 46px;
  padding: 0 26px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 14px;
  letter-spacing: .14em;
  text-indent: .14em;
  font-weight: 500;
  white-space: nowrap;
  transition: background .25s var(--ease-out), color .25s var(--ease-out), border-color .25s var(--ease-out), transform .25s var(--ease-out), box-shadow .25s var(--ease-out);
}
.entry-tile-cta-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  transition: transform .25s var(--ease-out);
}

/* Tile 1 (linear) — filled bronze pill, signals direct forward action */
.entry-tile-cta-filled {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  box-shadow: 0 4px 14px rgba(139, 90, 43, .22);
}
.entry-tile-linear:hover .entry-tile-cta-filled {
  background: #6f4720;
  border-color: #6f4720;
  box-shadow: 0 8px 20px rgba(139, 90, 43, .32);
}
html[data-theme="dark"] .entry-tile-cta-filled {
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}
html[data-theme="dark"] .entry-tile-linear:hover .entry-tile-cta-filled {
  background: #b08a52;
  border-color: #b08a52;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .45);
}
.entry-tile-linear:hover .entry-tile-cta-filled .entry-tile-cta-icon {
  transform: translateX(3px);
}

/* Tile 2 (random) — outlined pill with shuffle icon, signals discovery */
.entry-tile-cta-outlined {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.entry-tile-random:hover .entry-tile-cta-outlined {
  background: var(--accent);
  color: #fff;
}
.entry-tile-random:hover .entry-tile-cta-outlined .entry-tile-cta-icon {
  transform: rotate(180deg);
}

/* Tile 3 (lookup) — has an embedded form, distinct interactive shape */
.entry-tile-lookup {
  cursor: default;
}
.entry-tile-lookup:hover {
  transform: none;
  border-color: var(--border);
  box-shadow: none;
}
.entry-tile-lookup:focus-within {
  border-color: var(--accent);
}
.entry-tile-lookup .entry-tile-desc { margin-bottom: var(--space-3); }
.entry-tile-hint {
  display: block;
  margin-top: var(--space-3);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: .22em;
  text-indent: .22em;
  text-transform: uppercase;
}
.entry-tile-jump {
  display: flex;
  align-items: stretch;
  justify-content: center;
  margin: var(--space-3) auto var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg);
  overflow: hidden;
  height: 52px;
  width: 100%;
  max-width: 280px;
  transition: border-color .2s var(--ease-out), box-shadow .2s var(--ease-out);
}
.entry-tile-jump:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 90, 43, .14);
}
html[data-theme="dark"] .entry-tile-jump:focus-within {
  box-shadow: 0 0 0 3px rgba(216, 168, 107, .2);
}
.entry-tile-lookup.is-error .entry-tile-jump,
.entry-tile-lookup .entry-tile-jump.is-error {
  border-color: #b95a47;
  box-shadow: 0 0 0 3px rgba(185, 90, 71, .15);
}
.entry-tile-jump-label {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  font-family: var(--font-serif);
  color: var(--text-soft);
  font-size: 14px;
  letter-spacing: .04em;
  user-select: none;
  background: var(--bg-subtle);
}
.entry-tile-jump-label:first-child { border-right: 1px solid var(--hairline); }
.entry-tile-jump-label:nth-of-type(2) { border-left: 1px solid var(--hairline); }
.entry-tile-jump #jump-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 16px;
  text-align: center;
  outline: none;
  padding: 0;
  min-width: 0;
}
.entry-tile-jump #jump-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}
.entry-tile-jump #jump-input::placeholder {
  color: var(--text-muted);
  opacity: .5;
}
.entry-tile-jump-go {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  border: none;
  border-left: 1px solid var(--hairline);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background .2s var(--ease-out), color .2s var(--ease-out);
}
.entry-tile-jump-go svg {
  width: 18px;
  height: 18px;
}
.entry-tile-jump-go:hover {
  background: #6f4720;
}
html[data-theme="dark"] .entry-tile-jump-go:hover {
  background: #b08a52;
}

/* Mobile: stack to 1 column */
@media (max-width: 640px) {
  .entry-grid { margin-bottom: var(--space-7); }
  .entry-tiles { grid-template-columns: 1fr; gap: var(--space-3); }
  .entry-tile { min-height: 200px; padding: var(--space-5) var(--space-4); }
  .entry-tile-title { font-size: 22px; margin-bottom: var(--space-2); }
  .entry-tile-desc { font-size: 14px; margin-bottom: var(--space-3); }
  .entry-tile-cta { height: 44px; padding: 0 22px; font-size: 13px; letter-spacing: .12em; }
  .entry-tile-cta-icon { width: 16px; height: 16px; }
  .entry-tile-jump { height: 50px; max-width: 260px; }
  .entry-tile-jump-label { padding: 0 12px; font-size: 14px; }
  .entry-tile-jump #jump-input { font-size: 15px; }
  .entry-tile-jump-go { width: 50px; }
  .entry-tile-jump-go svg { width: 16px; height: 16px; }
}

/* Visually hidden helper for accessibility labels */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.about-block { margin: 2.5rem 0; }
.about-list {
  list-style: none; padding: 0;
}
.about-list li {
  background: var(--bg-elev);
  border-left: 3px solid var(--accent);
  padding: .8rem 1rem;
  margin: .6rem 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  line-height: 1.75;
}
.about-list strong { color: var(--accent); }

/* ============ Volume page ============ */
.volume-header {
  margin-bottom: 2rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--border);
}
.volume-eyebrow {
  color: var(--text-muted);
  font-size: .9rem;
  margin: 0 0 .4rem;
}
.volume-title {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  margin: 0;
  letter-spacing: .15em;
  color: var(--text);
}

.volume-jump {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .7rem 1rem;
  margin-bottom: 1.5rem;
  font-size: .9rem;
  display: flex; flex-wrap: wrap; gap: .3rem .4rem;
  align-items: center;
}
.jump-label { color: var(--text-muted); margin-right: .25rem; font-size: .85rem; }
.volume-jump a {
  font-family: var(--font-mono);
  padding: .2rem .55rem;
  border-radius: 4px;
  color: var(--text-soft);
  font-size: .85rem;
  min-width: 1.6rem;
  text-align: center;
}
.volume-jump a:hover { background: var(--bg-subtle); color: var(--accent); text-decoration: none; }
.volume-jump a:target { background: var(--accent); color: #fff; }

.sutra-list {
  list-style: none; padding: 0; margin: 0;
}
.sutra-list li {
  margin-bottom: .45rem;
  scroll-margin-top: 5rem;
}
.sutra-list li:target a {
  border-color: var(--accent);
  background: var(--bg-subtle);
  box-shadow: 0 0 0 2px var(--accent-soft) inset;
}
.sutra-list a {
  display: grid;
  grid-template-columns: 5rem 5rem 1fr;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1.1rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: all .12s;
}
.sutra-list a:hover {
  border-color: var(--accent);
  background: var(--bg-subtle);
  text-decoration: none;
  transform: translateX(2px);
}
.sl-num {
  font-family: var(--font-serif);
  font-size: .92rem;
  color: var(--text-muted);
  letter-spacing: .04em;
}
.sl-id {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: .9rem;
}
.sl-preview {
  font-family: var(--font-serif);
  color: var(--text-soft);
  font-size: .98rem;
  line-height: 1.55;
  letter-spacing: .02em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.sutra-list a:hover .sl-preview { color: var(--text); }

@media (max-width: 640px) {
  .sutra-list a {
    grid-template-columns: 4.2rem 1fr;
    grid-template-rows: auto auto;
    row-gap: .3rem;
    column-gap: .8rem;
    padding: .8rem .9rem;
  }
  .sl-num { grid-column: 1; grid-row: 1; }
  .sl-id { grid-column: 2; grid-row: 1; justify-self: start; }
  .sl-preview { grid-column: 1 / -1; grid-row: 2; font-size: .92rem; }
  .volume-jump { padding: .55rem .7rem; }
  .volume-jump a { padding: .2rem .45rem; font-size: .8rem; min-width: 1.4rem; }
}

/* ============ Sutra page ============ */
.sutra-header {
  border-bottom: 2px solid var(--border-strong);
  padding-bottom: 1.2rem;
  margin-bottom: 1.8rem;
}
.sutra-eyebrow {
  margin: 0 0 .35rem;
  font-size: .9rem;
  color: var(--text-muted);
  letter-spacing: .04em;
}
.sutra-id {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: .95rem;
  letter-spacing: .05em;
  margin-bottom: .3rem;
}
.sutra-title {
  font-family: var(--font-serif);
  font-size: 2.1rem;
  margin: 0 0 .8rem;
  font-weight: 500;
  letter-spacing: .12em;
  line-height: 1.3;
  color: var(--text);
}
.sutra-subtitle {
  display: block;
  font-size: 1rem;
  color: var(--text-soft);
  font-weight: 400;
  letter-spacing: .04em;
  margin-top: .35rem;
  line-height: 1.5;
}

/* The single most-seen line on the site — eyebrow-style metadata under each
   sutra title. Was being rendered with browser default styling for far too
   long. Quiet and well-sized so it informs without competing with the title. */
.sutra-meta-line {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: 1.7;
  letter-spacing: .04em;
  color: var(--text-muted);
}
.sutra-meta-line .mono {
  font-family: var(--font-mono);
  color: var(--text-soft);
  letter-spacing: .02em;
}
.sutra-meta-line a {
  color: var(--text-soft);
  border-bottom: 1px dotted var(--hairline);
  padding-bottom: 1px;
}
.sutra-meta-line a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-decoration: none;
}
/* Multi-Taisho parenthetical: on narrow screens, drop to its own line so the
   primary "大正藏 第 N 經" reads cleanly without an inline aside. */
.sutra-meta-line .meta-aside {
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 12.5px;
}
@media (max-width: 540px) {
  .sutra-meta-line .meta-aside {
    display: block;
    margin-top: 2px;
    white-space: normal;
  }
}

/* Linkified CBETA reference — visually unchanged from a plain mono span,
   except for a hairline underline on hover. */
.sutra-meta-line .cbeta-link {
  border-bottom: none;
}
.sutra-meta-line .cbeta-link:hover {
  border-bottom: 1px dotted var(--accent);
}

/* Translator + source + revision attribution row. Sits below the meta-line
   in the sutra header. Quiet typography — academic, not decorative. */
.sutra-attribution {
  margin: 6px 0 0;
  font-family: var(--font-sans);
  font-size: 12.5px;
  line-height: 1.7;
  letter-spacing: .02em;
  color: var(--text-muted);
}
.sutra-attribution a {
  color: var(--text-soft);
  border-bottom: 1px dotted var(--hairline);
  padding-bottom: 1px;
}
.sutra-attribution a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-decoration: none;
}
.sutra-attribution-sep {
  color: var(--text-muted);
  margin: 0 .35em;
  opacity: .7;
}
@media (max-width: 540px) {
  .sutra-attribution { font-size: 11.5px; }
  /* On narrow screens stack each attribution span on its own line for
     legibility — separators hide. */
  .sutra-attribution-sep { display: none; }
  .sutra-attribution > span { display: block; margin-top: 2px; }
  .sutra-attribution > span:first-child { margin-top: 0; }
}
.sutra-meta {
  margin: 0; padding: 0;
  display: grid;
  gap: .4rem;
  font-size: .9rem;
}
.meta-row {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: .8rem;
}
.meta-row dt { color: var(--text-muted); }
.meta-row dd { margin: 0; color: var(--text-soft); }
.meta-row .mono { font-family: var(--font-mono); font-size: .85rem; }

@media (max-width: 640px) {
  .sutra-title { font-size: 1.7rem; }
  .meta-row { grid-template-columns: 6rem 1fr; gap: .5rem; font-size: .85rem; }
}

.view-controls {
  display: flex; gap: .5rem; flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding: .65rem .8rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.view-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-soft);
  padding: .35rem .8rem;
  font-size: .85rem;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.view-btn:hover { border-color: var(--accent); color: var(--text); }
.view-btn.is-on {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.view-btn:not(.is-on) {
  opacity: .6;
}
.view-btn:not(.is-on)::before { content: "+"; margin-right: .25rem; }
.view-btn.is-on::before { content: "✓"; margin-right: .25rem; font-size: .75rem; }

.text-section {
  margin: 2rem 0;
  scroll-margin-top: 5rem;
}
.text-section[hidden] { display: none; }
.text-section .section-heading {
  font-family: var(--font-serif);
  /* Tied to --reading-base × 1.2 — the 「原文」「白話」 headings are landmark
     labels of the reading sections, so they scale with body when the reader
     adjusts size. UI section-headings on home/volumes/about pages stay at
     fixed --text-xl. At default 20px reading → 24px heading. */
  font-size: calc(var(--reading-base) * 1.2);
  font-weight: 500;
  margin: 0 0 1.2rem;
  padding-bottom: .4rem;
  border-bottom: 1.5px solid var(--accent);
  display: inline-block;
  letter-spacing: .14em;
}

.prose-body {
  font-family: var(--font-serif);
  font-size: var(--reading-base);
  line-height: var(--reading-line);
  letter-spacing: var(--reading-letter);
  color: var(--text);
  /* Cap reading width to ~38 CJK characters (~37em) per clreq guidance —
     prevents over-long lines when user maxes the font-size to 2.5×. */
  max-width: 38em;
  margin-inline: auto;
}
.prose-body p {
  margin: 0 0 1.6rem;
  text-indent: 0;
  text-align: left;
}
.prose-body p:last-child { margin-bottom: 0; }
.prose-body p.verse {
  background: var(--verse-bg);
  border-left: 3px solid var(--accent-soft);
  padding: .9rem 1.2rem;
  text-indent: 0;
  text-align: left;
  margin: 1.6rem 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: calc(var(--reading-base) * .98);
  letter-spacing: .08em;
  line-height: 2.0;
  /* For Han verse, keep full-width punctuation from collapsing */
  text-spacing-trim: space-all;
}

.prose-body.cbeta-source {
  font-size: calc(var(--reading-base) * .96);
  color: var(--text-soft);
}

.prose-body.southern {
  font-size: calc(var(--reading-base) * .98);
  background: var(--south-bg);
  padding: 1rem 1.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--south-border);
}

/* ============ Vernacular (Taiwan TC) ============ */
.vernacular-section .section-heading {
  border-bottom-color: #b08a3e;
}
.prose-body.vernacular-body {
  font-family: var(--font-serif);
  font-size: var(--reading-base);
  line-height: var(--reading-line);
  background: linear-gradient(to bottom, #fdf9ee, #faf5e3);
  padding: 1.2rem 1.4rem;
  border-radius: var(--radius);
  border-left: 4px solid #b08a3e;
}
html[data-theme="dark"] .prose-body.vernacular-body {
  background: #2a2418;
  border-left-color: #d8a86b;
}
.vernacular-disclaimer {
  margin: 0 0 1.2rem;
  /* Tied to --reading-base × 0.9 — this critical AI-translation warning sits
     in the reading flow, so it scales with body when the reader adjusts size.
     At default 20px reading → 18px disclaimer (90% of body, clearly readable
     yet visually subordinate to the body text). */
  padding: 1rem 1.2rem;
  font-size: calc(var(--reading-base) * .9);
  color: var(--text-soft);
  background: var(--accent-warning-bg);
  border-radius: var(--radius);
  border-left: 4px solid var(--accent-warning);
  line-height: 1.8;
  letter-spacing: .015em;
}
.vernacular-disclaimer strong {
  display: inline-block;
  /* Uses --accent-warning (#715815 light / #e8c989 dark) — both AA pass on
     their respective bg. Same gold semantically signals translation caveat. */
  color: var(--accent-warning);
  font-weight: 600;
  margin-right: .35em;
  /* Keep the divider dot from orphaning when meta wraps narrow. */
  white-space: nowrap;
}
.vernacular-disclaimer strong::after {
  content: '・';
  margin-left: .35em;
  color: var(--text-muted);
  font-weight: 400;
}
/* Dark-mode disclaimer styling now flows from --accent-warning-bg /
   --accent-warning. Border auto-uses --accent in dark mode. */
html[data-theme="dark"] .vernacular-disclaimer {
  border-left-color: var(--accent);
  color: var(--text-soft);
}
@media (max-width: 540px) {
  .vernacular-disclaimer {
    /* Same calc relationship; .85x because mobile body needs slightly more
       breathing for narrow screens. */
    font-size: calc(var(--reading-base) * .85);
    padding: .9rem 1rem;
    line-height: 1.8;
  }
  .vernacular-disclaimer strong {
    display: block;
    margin-right: 0;
    margin-bottom: .15rem;
  }
  .vernacular-disclaimer strong::after {
    display: none;
  }
}
.vernacular-translator-note {
  margin-top: .8rem;
  padding: .6rem .9rem;
  font-size: .85rem;
  color: var(--text-soft);
  background: var(--bg-subtle);
  border-radius: var(--radius);
  border-left: 3px solid var(--accent-soft);
  line-height: 1.7;
}
.vernacular-translator-note strong {
  color: var(--accent);
}

.southern-sub { margin-bottom: 1.5rem; }
.southern-name {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 500;
  margin: 0 0 .6rem;
  color: var(--accent);
  letter-spacing: .04em;
}

.term-notes {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: .95rem;
  line-height: 1.85;
}
.term-notes li {
  background: var(--note-bg);
  padding: .7rem 1rem .7rem 3rem;
  margin: .5rem 0;
  border-radius: var(--radius);
  border-left: 3px solid var(--accent-soft);
  position: relative;
}
.note-num {
  position: absolute;
  left: .8rem;
  top: .7rem;
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: .85rem;
  font-weight: 600;
}

.sources-list {
  list-style: none; padding: 0; margin: 0;
  font-size: .9rem;
  font-family: var(--font-mono);
}
.sources-list li {
  padding: .35rem 0;
  color: var(--text-soft);
}

.sutra-pager {
  display: grid;
  grid-template-columns: 1fr minmax(8rem, .7fr) 1fr;
  gap: .8rem;
  margin: 3rem 0 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  align-items: stretch;
}
.pager-prev, .pager-next, .pager-random {
  display: block;
  padding: .8rem 1rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  transition: all .15s;
}
.pager-prev { text-align: left; }
.pager-next { text-align: right; }
.pager-random {
  text-align: center;
  background: transparent;
  border-style: dashed;
  border-color: var(--border-strong);
  color: var(--text-soft);
  align-self: stretch;
}
.pager-random:hover {
  border-style: solid;
  border-color: var(--accent);
  background: var(--bg-subtle);
  color: var(--text);
}
.pager-prev:hover, .pager-next:hover {
  border-color: var(--accent);
  background: var(--bg-subtle);
  text-decoration: none;
}
@media (max-width: 540px) {
  .sutra-pager {
    grid-template-columns: 1fr 1fr;
    gap: .55rem;
  }
  .pager-random {
    grid-column: 1 / -1;
    order: 3;
    padding: .65rem 1rem;
  }
  .pager-random .pager-label,
  .pager-random .pager-title {
    display: inline;
    font-size: .9rem;
    margin: 0;
  }
  .pager-random .pager-label::after { content: '・'; margin: 0 .15em; color: var(--text-muted); }
}
.pager-label {
  display: block;
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: .25rem;
}
.pager-title {
  display: block;
  font-family: var(--font-serif);
  font-size: 1rem;
  letter-spacing: .04em;
}

.volume-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 3rem 0 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* ============ In-volume neighbors (sutra page) ============ */
.vol-neighbors {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.vol-neighbors .section-heading {
  font-size: 1.05rem;
  border-bottom-width: 1.5px;
}
.sutra-mini-list {
  list-style: none;
  padding: 0;
  margin: .8rem 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.sutra-mini-list li {
  border-top: 1px solid var(--border);
}
.sutra-mini-list li:first-child { border-top: 0; }
.sutra-mini-list li.is-current {
  background: var(--bg-subtle);
}
.sutra-mini-list a, .sutra-mini-list li.is-current span:first-child {
  display: block;
  padding: .55rem .85rem;
  color: var(--text);
  text-decoration: none;
  transition: background .12s;
}
.sutra-mini-list a:hover {
  background: var(--bg-subtle);
  text-decoration: none;
}
.sutra-mini-list .mini-id {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: .85rem;
  margin-right: .8rem;
}
.sutra-mini-list .mini-title {
  font-family: var(--font-serif);
  font-size: .95rem;
  letter-spacing: .04em;
}
.sutra-mini-list li.is-current .mini-title {
  color: var(--accent);
  font-weight: 500;
}
.vol-neighbors-foot {
  margin: .5rem 0 0;
  font-size: .9rem;
  text-align: right;
}

/* ============ Search page ============ */
.search-header { margin-bottom: 1.5rem; }
.search-header h1 {
  font-family: var(--font-serif);
  font-size: 2rem;
  margin: 0 0 .5rem;
}
.search-hint {
  color: var(--text-soft);
  font-size: .92rem;
  margin: 0;
  line-height: 1.7;
}
.search-input-wrap {
  position: relative;
  margin: 1.5rem 0;
}
#search-input {
  width: 100%;
  font-size: 1.1rem;
  padding: .85rem 1rem .85rem 2.6rem;
  background: var(--bg-elev);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
#search-input:focus {
  border-color: var(--accent);
}
#search-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.search-input-wrap::before {
  content: "🔍";
  position: absolute;
  left: .85rem; top: 50%; transform: translateY(-50%);
  opacity: .5;
}
.search-status {
  display: block;
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: .4rem;
  min-height: 1.2em;
}
.search-filters {
  font-size: .9rem;
  color: var(--text-soft);
  margin-bottom: 1rem;
  display: flex; gap: 1rem;
}

.search-results {
  list-style: none; padding: 0;
}
.search-results li {
  margin-bottom: .6rem;
}
.search-results a {
  display: block;
  padding: .85rem 1rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: all .12s;
}
.search-results a:hover {
  border-color: var(--accent);
  background: var(--bg-subtle);
  text-decoration: none;
}
.sr-id { font-family: var(--font-mono); color: var(--accent); font-size: .85rem; margin-right: .5rem; }
.sr-title { font-family: var(--font-serif); font-size: 1rem; }
.sr-subject { color: var(--text-soft); font-size: .85rem; margin-top: .25rem; line-height: 1.5; }
.sr-snippet {
  color: var(--text-muted);
  font-size: .85rem;
  margin-top: .35rem;
  font-family: var(--font-serif);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sr-snippet em {
  color: var(--accent);
  font-style: normal;
  font-weight: 600;
  background: var(--verse-bg);
  padding: 0 .15em;
}

/* ============ About page ============ */
.about-page {
  font-family: var(--font-sans);
  line-height: 1.85;
}
.about-page h1 {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  letter-spacing: .12em;
  margin: 0 0 1.5rem;
}
.about-page h2 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  margin: 2rem 0 .8rem;
  padding-bottom: .35rem;
  border-bottom: 1.5px solid var(--accent);
  display: inline-block;
  font-weight: 500;
}
.about-page p, .about-page li { color: var(--text); }
.about-page ul { padding-left: 1.5rem; }
.about-cross-refs {
  margin: 0 0 2rem;
  padding: .85rem 1.1rem;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  border-left: 3px solid var(--accent-soft);
  font-size: .92rem;
  line-height: 1.75;
  color: var(--text-soft);
}
.about-cross-refs a {
  color: var(--accent);
  font-weight: 500;
}

/* ============ Intro cards (homepage essays: 導讀 + 緣起) ============ */
.intro-cards {
  margin: 0 0 var(--space-8);
}
.intro-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
.intro-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--space-5) var(--space-5) var(--space-4);
  background: var(--bg-elev);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
  transition: transform .25s var(--ease-out), border-color .25s var(--ease-out);
}
.intro-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  text-decoration: none;
}
.intro-card-eyebrow {
  font-family: var(--font-serif);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: .3em;
  text-indent: .3em;
  margin-bottom: var(--space-2);
  display: block;
  font-feature-settings: "palt" 1;
}
.intro-card-title {
  display: block;
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  margin: 0 0 var(--space-3);
  color: var(--text);
  font-weight: 500;
  letter-spacing: .06em;
  line-height: 1.35;
}
.intro-card-desc {
  display: block;
  color: var(--text-soft);
  font-family: var(--font-serif);
  font-size: var(--text-base);
  line-height: 1.75;
  margin: 0 0 var(--space-4);
  flex: 1;
  letter-spacing: .02em;
}
.intro-card-link {
  display: block;
  font-size: var(--text-sm);
  color: var(--accent);
  font-weight: 500;
  letter-spacing: .06em;
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--hairline);
  transition: color .22s var(--ease-out);
}
.intro-card:hover .intro-card-link { color: var(--link-hover); }
@media (max-width: 640px) {
  .intro-cards { margin: 0 0 var(--space-7); }
  .intro-cards-grid { grid-template-columns: 1fr; gap: var(--space-3); }
  .intro-card { padding: var(--space-4) var(--space-4); }
  .intro-card-title { font-size: var(--text-md); }
}

/* ============ Essay pages (origin / intro) ============ */
body.page-essay .site-main { max-width: 760px; }

.essay-page {
  font-family: var(--font-sans);
  line-height: 1.85;
  color: var(--text);
}
.essay-header {
  margin: .5rem 0 2.2rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--border);
}
.essay-eyebrow {
  margin: 0 0 .4rem;
  font-size: .85rem;
  color: var(--text-muted);
  letter-spacing: .12em;
}
.essay-title {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  letter-spacing: .15em;
  margin: 0 0 .6rem;
  font-weight: 500;
  color: var(--text);
}
.essay-lede {
  margin: .5rem 0 0;
  font-size: 1.02rem;
  color: var(--text-soft);
  line-height: 1.85;
  letter-spacing: .02em;
}

.essay-body {
  font-size: 1rem;
  line-height: 1.95;
  letter-spacing: .015em;
}
.essay-body > p {
  margin: 0 0 1.3rem;
}
.essay-body > p:first-child,
.essay-body .essay-opening {
  font-size: 1.06rem;
  color: var(--text);
  margin-bottom: 1.6rem;
}
.essay-body h2 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  margin: 2.6rem 0 1rem;
  padding-bottom: .35rem;
  border-bottom: 1.5px solid var(--accent);
  display: inline-block;
  font-weight: 500;
  letter-spacing: .04em;
  scroll-margin-top: 5rem;
}
.essay-body h3.essay-h3 {
  font-family: var(--font-serif);
  font-size: 1.12rem;
  margin: 1.6rem 0 .55rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: .03em;
}
.essay-body ul, .essay-body ol {
  margin: 1rem 0 1.4rem;
  padding-left: 1.5rem;
  line-height: 1.85;
}
.essay-body li { margin-bottom: .45rem; }

/* Pull-quote (verified scholar quotations) */
.pull-quote {
  margin: 1.6rem 0;
  padding: 1.1rem 1.3rem;
  background: var(--bg-subtle);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-family: var(--font-serif);
}
.pull-quote p {
  margin: 0;
  font-size: 1.06rem;
  line-height: 1.95;
  letter-spacing: .03em;
  color: var(--text);
}
.pull-quote cite {
  display: block;
  margin-top: .6rem;
  font-size: .85rem;
  color: var(--text-muted);
  font-style: normal;
  font-family: var(--font-sans);
  letter-spacing: .02em;
}
.pull-quote cite::before {
  content: '出自 ';
  margin-right: .15em;
}

/* AI translation warning block (essay page) */
.essay-warning {
  margin: 1.8rem 0 2rem;
  padding: 1rem 1.3rem;
  background: #fbf3df;
  border-left: 4px solid #c89938;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: .96rem;
  line-height: 1.85;
  color: var(--text);
}
.essay-warning p { margin: 0 0 .8rem; }
.essay-warning p:last-child { margin-bottom: 0; }
.essay-warning strong {
  color: #8b6f1f;
  font-weight: 600;
}
html[data-theme="dark"] .essay-warning {
  background: #2c2517;
  border-left-color: #d8a86b;
  color: var(--text-soft);
}
html[data-theme="dark"] .essay-warning strong {
  color: #e8c989;
}

/* Donation list (origin page) */
.donation-list {
  margin: 1rem 0 1.5rem;
  padding-left: 0;
  list-style: none;
}
.donation-list li {
  padding: .65rem .9rem;
  margin-bottom: .55rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  line-height: 1.75;
}
.donation-list strong { color: var(--accent); margin-right: .4em; }
.donation-list a {
  font-family: var(--font-mono);
  font-size: .85rem;
  color: var(--text-soft);
}

/* Closing line + signature (origin page) */
.essay-closing {
  margin-top: 2.2rem;
  font-size: 1.05rem;
  color: var(--text);
  line-height: 1.95;
  letter-spacing: .03em;
}
.essay-signature {
  margin: 2rem 0 .5rem;
  padding-top: 1.2rem;
  border-top: 1px dashed var(--border-strong);
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.essay-signature .sig-date {
  font-size: .88rem;
  color: var(--text-muted);
  font-family: var(--font-sans);
  letter-spacing: .04em;
}

/* Continue-reading footer */
.essay-next {
  margin: 3.5rem 0 1rem;
  padding-top: 1.8rem;
  border-top: 1px solid var(--border);
}
.essay-next-heading {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: .08em;
}
.essay-next-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .9rem;
}
.essay-next-card {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  padding: 1.05rem 1.2rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: all .15s;
}
.essay-next-card:hover {
  border-color: var(--accent);
  background: var(--bg-subtle);
  text-decoration: none;
  transform: translateY(-1px);
}
.essay-next-eyebrow {
  font-size: .78rem;
  color: var(--text-muted);
  letter-spacing: .1em;
}
.essay-next-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  color: var(--text);
  letter-spacing: .04em;
}
.essay-next-desc {
  font-size: .85rem;
  color: var(--text-soft);
  line-height: 1.6;
}

@media (max-width: 640px) {
  .essay-title { font-size: 1.9rem; }
  .essay-body { font-size: .98rem; }
  .essay-body h2 { font-size: 1.25rem; }
  .pull-quote { padding: .9rem 1.1rem; }
  .pull-quote p { font-size: 1rem; }
  .essay-next-grid { grid-template-columns: 1fr; }
}

/* ============ Share popover (all pages) ============ */
.share-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 8, .45);
  z-index: 200;
  opacity: 0;
  transition: opacity .18s;
}
.share-overlay[hidden] { display: none; }
.share-overlay.is-open { opacity: 1; }

.share-popover {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%) translateY(100%);
  width: min(440px, 100% - 1.5rem);
  max-height: calc(100vh - 4rem);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -8px 32px rgba(60, 50, 30, .18);
  z-index: 201;
  overflow-y: auto;
  transition: transform .22s cubic-bezier(.2,.8,.3,1);
  /* iPhone home-indicator clearance — pad inner content rather than offset
     position so the sheet still hugs the bottom edge visually. */
  padding-bottom: env(safe-area-inset-bottom);
}
@media (min-width: 640px) {
  .share-popover {
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%) scale(.95);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-strong);
    opacity: 0;
    transition: opacity .18s, transform .18s cubic-bezier(.2,.8,.3,1);
  }
}
.share-popover[hidden] { display: none; }
.share-popover.is-open {
  transform: translateX(-50%) translateY(0);
}
@media (min-width: 640px) {
  .share-popover.is-open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}
.share-popover-inner {
  padding: 1.2rem 1.4rem 1.4rem;
}
.share-popover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 .35rem;
}
.share-popover-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: .04em;
  color: var(--text);
}
.share-popover-close {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: .25rem .5rem;
  border-radius: var(--radius);
  font-family: inherit;
}
.share-popover-close:hover {
  color: var(--text);
  background: var(--bg-subtle);
}
.share-popover-context {
  margin: 0 0 1rem;
  font-size: .85rem;
  color: var(--text-muted);
  line-height: 1.55;
  word-break: break-all;
}
.share-popover-hint {
  margin: 1rem 0 0;
  padding: .65rem .85rem;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  font-size: .8rem;
  color: var(--text-muted);
  line-height: 1.6;
  border-left: 3px solid var(--accent-soft);
}

.share-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .55rem;
  margin-top: .65rem;
}
@media (max-width: 380px) {
  .share-grid { grid-template-columns: repeat(3, 1fr); }
}

.share-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  padding: .85rem .35rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-soft);
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.share-item:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-subtle);
  transform: translateY(-1px);
}
.share-item[hidden] { display: none; }
.share-item-wide {
  flex-direction: row;
  justify-content: center;
  gap: .5rem;
  width: 100%;
  padding: .75rem 1rem;
  font-size: .95rem;
  font-weight: 500;
}
.share-item-icon {
  display: inline-grid;
  place-items: center;
}
.share-item-icon svg {
  width: 26px;
  height: 26px;
  display: block;
}
.share-item-wide .share-item-icon svg {
  width: 20px;
  height: 20px;
}
.share-item-label {
  font-size: .78rem;
  letter-spacing: .03em;
  white-space: nowrap;
}
.share-item-wide .share-item-label {
  font-size: inherit;
}

.share-item:focus-visible,
.share-popover-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Toast (clipboard confirmation) */
.share-toast {
  position: fixed;
  left: 50%;
  bottom: 5rem;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: .65rem 1.2rem;
  border-radius: 999px;
  font-size: .9rem;
  letter-spacing: .04em;
  z-index: 250;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}
.share-toast[hidden] { display: none; }
.share-toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Inline share button on essay pages */
.essay-share-row {
  margin-top: 1.4rem;
  text-align: center;
}
.essay-share-btn {
  background: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--text-soft);
  padding: .6rem 1.4rem;
  border-radius: 999px;
  font-family: inherit;
  font-size: .9rem;
  cursor: pointer;
  transition: all .15s;
  letter-spacing: .04em;
}
.essay-share-btn:hover {
  border-style: solid;
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-subtle);
}
.essay-share-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Ghost button (homepage hero) — quiet secondary action */
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-soft);
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-subtle);
}

/* ============ Sutra page top reading-actions bar ============ */
/* Sits right under the meta-line so the TTS button is the first thing the
   user sees after the title. Calm, single-row, with a quiet hint to the
   right explaining how to stop. */
.sutra-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin: var(--space-3) 0 var(--space-5);
  padding-bottom: var(--space-3);
  /* CLS prevention: TTS button is `hidden` until JS detects support and
     removes the attribute. Reserving min-height stops the heading below
     from leaping ~20 px when the button reveals itself. */
  min-height: 56px;
  border-bottom: 1px solid var(--border);
}
html[data-theme="dark"] .sutra-actions {
  /* Hairline is barely visible in dark mode; use --border for definition. */
  border-bottom-color: var(--border);
}
.sutra-actions[hidden] {
  /* When the entire bar is hidden (no TTS support), reserve nothing. */
  display: none;
  min-height: 0;
}
.sutra-actions-hint {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--text-muted);
  letter-spacing: .04em;
}
.sutra-actions-hint .hint-full { display: inline; }
.sutra-actions-hint .hint-short { display: none; }
@media (max-width: 540px) {
  .sutra-actions { gap: .8rem; margin: var(--space-3) 0 var(--space-4); min-height: 50px; }
  .sutra-actions-hint { font-size: 11px; }
  /* Mobile: shorter hint so it doesn't fight the pill for attention */
  .sutra-actions-hint .hint-full { display: none; }
  .sutra-actions-hint .hint-short { display: inline; }
}

/* ============ Sutra page bottom tools (after pager) ============ */
.sutra-tools {
  display: flex;
  gap: .9rem;
  justify-content: center;
  flex-wrap: wrap;
  margin: 1.6rem 0 .5rem;
}
.tool-pill {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  padding: .8rem 1.5rem;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: .98rem;
  font-weight: 500;
  letter-spacing: .04em;
  transition: all .18s cubic-bezier(.2,.8,.3,1);
  box-shadow: 0 1px 2px rgba(60, 50, 30, .04);
  min-height: 44px;       /* mobile-friendly tap target */
}
.tool-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-subtle);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(60, 50, 30, .12);
  text-decoration: none;
}
.tool-pill:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(60, 50, 30, .08);
}
.tool-pill:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.tool-pill-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--accent);
  transition: color .18s;
}
.tool-pill:hover .tool-pill-icon {
  color: var(--accent);
}
.tool-pill-text {
  letter-spacing: .04em;
}
html[data-theme="dark"] .tool-pill {
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
html[data-theme="dark"] .tool-pill:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, .35);
}
@media (max-width: 480px) {
  .sutra-tools { gap: .6rem; margin-top: 1.3rem; }
  .tool-pill { padding: .7rem 1.2rem; font-size: .92rem; }
  .tool-pill-icon { width: 16px; height: 16px; }
}

/* ----- TTS (text-to-speech) reading button ----- */
/* The button has three icons: idle/play, playing/pause, paused/play.
   We toggle visibility via .is-playing / .is-paused classes set in JS. */
.tool-pill-tts .tool-pill-icon-pause { display: none; }
.tool-pill-tts.is-playing .tool-pill-icon-play { display: none; }
.tool-pill-tts.is-playing .tool-pill-icon-pause { display: block; }
.tool-pill-tts.is-paused .tool-pill-icon-pause { display: none; }
.tool-pill-tts.is-paused .tool-pill-icon-play { display: block; }
.tool-pill-tts.is-playing,
.tool-pill-tts.is-paused {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-tint);
}
.tool-pill-tts.is-playing .tool-pill-icon,
.tool-pill-tts.is-paused .tool-pill-icon {
  color: var(--accent);
}

/* Subtle pulse on the play icon while reading — calm visual signal that
   audio is happening even on a muted device. Opacity-only so an SVG element
   with display:none ↔ block toggling doesn't cause layout-thrash. */
@keyframes tts-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .55; }
}
.tool-pill-tts.is-playing .tool-pill-icon-pause {
  animation: tts-pulse 1.4s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .tool-pill-tts.is-playing .tool-pill-icon-pause { animation: none; }
}

/* Currently-spoken paragraph highlight. Uses box-shadow for the accent rule
   and a tinted background — both compositor-only, no reflow. */
.prose-body p.tts-active {
  background: linear-gradient(90deg, var(--accent-tint), transparent 70%);
  border-radius: 4px;
  /* inset shadow draws the 3px accent rule without adding layout box,
     and the second shadow gives a 6px outward halo without padding. */
  box-shadow: inset 3px 0 0 var(--accent), 0 0 0 6px var(--accent-tint);
  transition: background .25s var(--ease-out), box-shadow .25s var(--ease-out);
}
@media (prefers-reduced-motion: reduce) {
  .prose-body p.tts-active { transition: none; }
}

/* ============ Floating tools (sutra page) ============ */
.float-tools {
  position: fixed;
  /* iPhone notch/home-indicator safe-area awareness */
  right: max(1.2rem, env(safe-area-inset-right));
  bottom: max(1.2rem, calc(.6rem + env(safe-area-inset-bottom)));
  display: flex;
  flex-direction: column;
  gap: .55rem;
  z-index: 80;
  pointer-events: none;
}
.float-btn {
  pointer-events: auto;
  display: inline-grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  color: var(--text-soft);
  font-family: var(--font-serif);
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: all .15s;
}
.float-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-1px);
}
.float-btn[hidden] { display: none; }
.float-btn.float-top {
  width: 3rem;
  height: 3rem;
  font-size: 1.25rem;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(60, 50, 30, .18);
}
.float-btn.float-top:hover {
  background: var(--link-hover);
  border-color: var(--link-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(60, 50, 30, .25);
}
html[data-theme="dark"] .float-btn.float-top {
  box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
}

/* Floating TTS mini-controller — appears only while reading is active
   (state ≠ idle). The button has `hidden` removed only when state becomes
   playing or paused; the idle path never paints, so we style only the
   two visible states below. */
.float-btn.float-tts {
  width: 3rem;
  height: 3rem;
}
.float-btn.float-tts.is-playing {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(60, 50, 30, .25),
              0 0 0 0 var(--accent-tint);
  animation: float-tts-halo 2s ease-out infinite;
}
.float-btn.float-tts.is-paused {
  /* Paused: outlined + no halo, clearly NOT-playing */
  background: var(--bg-elev);
  color: var(--accent);
  border-color: var(--accent);
  animation: none;
}
.float-btn.float-tts:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: translateY(-2px);
}
.float-btn.float-tts.is-playing:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}
.float-tts-icon {
  width: 18px;
  height: 18px;
  display: block;
}
.float-tts-icon-play { display: none; }
.float-btn.float-tts.is-paused .float-tts-icon-pause { display: none; }
.float-btn.float-tts.is-paused .float-tts-icon-play { display: block; }
html[data-theme="dark"] .float-btn.float-tts.is-playing {
  color: #181612;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .45),
              0 0 0 0 var(--accent-tint);
}
html[data-theme="dark"] .float-btn.float-tts.is-playing:hover {
  color: #181612;
}
/* Soft expanding halo that signals "audio is playing" without spinning
   icons or motion that would distract reading. 10px max keeps it from
   bleeding onto adjacent footer / content. Reduced-motion disables. */
@keyframes float-tts-halo {
  0%   { box-shadow: 0 4px 14px rgba(60, 50, 30, .25), 0 0 0 0 var(--accent-tint); }
  70%  { box-shadow: 0 4px 14px rgba(60, 50, 30, .25), 0 0 0 10px transparent; }
  100% { box-shadow: 0 4px 14px rgba(60, 50, 30, .25), 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .float-btn.float-tts { animation: none; }
}
@media (max-width: 640px) {
  .float-tools {
    right: max(.8rem, env(safe-area-inset-right));
    bottom: max(.8rem, calc(.4rem + env(safe-area-inset-bottom)));
    gap: .4rem;
  }
  /* WCAG 2.5.5 — phone tap targets ≥ 44x44 */
  .float-btn { width: 2.85rem; height: 2.85rem; font-size: .95rem; }
  .float-btn.float-top { width: 2.95rem; height: 2.95rem; font-size: 1.1rem; }
  .float-btn.float-tts { width: 2.95rem; height: 2.95rem; }
}

/* ============ 404 / Error page ============ */
.error-page {
  max-width: 580px;
  margin: 0 auto;
  padding: 4rem 1.5rem 5rem;
  text-align: center;
}
.error-mark {
  width: 96px;
  height: 96px;
  margin: 0 auto 1.6rem;
  color: var(--accent-soft);
  opacity: .85;
}
.error-mark svg {
  display: block;
  width: 100%;
  height: 100%;
}
.error-eyebrow {
  font-family: var(--font-mono);
  font-size: .85rem;
  color: var(--text-muted);
  letter-spacing: .35em;
  margin-bottom: .5rem;
  padding-left: .35em;
}
.error-title {
  font-family: var(--font-serif);
  font-size: 1.85rem;
  font-weight: 500;
  color: var(--text);
  margin: 0 0 1rem;
  letter-spacing: .04em;
  line-height: 1.4;
}
.error-lede {
  font-size: 1rem;
  line-height: 1.85;
  color: var(--text-soft);
  margin: 0 auto 2rem;
  max-width: 460px;
}
.error-actions {
  display: flex;
  gap: .8rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 2.4rem;
}
.error-jump {
  margin: 0 auto 2.4rem;
  max-width: 380px;
}
.error-help {
  font-size: .9rem;
  color: var(--text-muted);
  line-height: 1.95;
  max-width: 480px;
  margin: 0 auto;
  padding-top: 1.6rem;
  border-top: 1px solid var(--border);
}
.error-help a {
  color: var(--link);
  border-bottom: 1px dotted var(--accent-soft);
  padding-bottom: 1px;
}
.error-help a:hover {
  text-decoration: none;
  border-bottom-style: solid;
}

@media (max-width: 540px) {
  .error-page { padding: 2.5rem 1.2rem 3.5rem; }
  .error-mark { width: 72px; height: 72px; margin-bottom: 1.2rem; }
  .error-title { font-size: 1.5rem; }
  .error-lede { font-size: .95rem; }
  .error-actions { gap: .55rem; }
}

/* About page callout — soft cream background, accent left rule, used to
   highlight a "good to know" technicality without screaming. */
.about-callout {
  margin: var(--space-3) 0 var(--space-4);
  padding: var(--space-3) calc(var(--space-3) + 4px);
  background: var(--bg-tint);
  border-left: 3px solid var(--accent-soft);
  border-radius: 0 8px 8px 0;
}
.about-callout p {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.85;
  color: var(--text-soft);
  letter-spacing: .02em;
}
.about-callout .mono {
  font-family: var(--font-mono);
  background: var(--bg-elev);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: .92em;
  color: var(--text);
}

/* ============ Reading-progress bar (sutra page) ============ */
/* Subtle 2px horizontal bar pinned to top-of-viewport. Width tracks scroll
   progress through the article. Pure CSS using scroll-driven animations
   where supported (Chrome 115+); JS fallback updates --p custom property. */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 99;
  pointer-events: none;
  background: transparent;
}
.reading-progress-bar {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transform-origin: left;
  /* Animate scaleX via CSS variable updated by JS — 0 collapsed, 1 full. */
  transform: scaleX(var(--reading-p, 0));
  transition: transform .12s linear;
}
@media (prefers-reduced-motion: reduce) {
  .reading-progress-bar { transition: none; }
}
/* Hide on print */
@media print { .reading-progress { display: none !important; } }

/* ============ Resume-last-read pill (homepage) ============ */
/* Quiet, restrained — visible only on the second+ visit. The point is to
   remove friction for a returning reader of a 1362-text corpus. */
.resume-pill {
  margin: var(--space-3) auto var(--space-5);
  max-width: 480px;
  padding: 0 var(--space-3);
}
.resume-pill[hidden] { display: none; }
.resume-pill-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) calc(var(--space-3) + 4px);
  background: var(--bg-elev);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  transition: background .2s var(--ease-out), border-color .2s var(--ease-out), transform .2s var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .resume-pill-link:hover {
    background: var(--bg-tint);
    border-color: var(--border-strong);
    transform: translateY(-1px);
    text-decoration: none;
  }
}
.resume-pill-eyebrow {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: .08em;
  color: var(--text-muted);
}
.resume-pill-label {
  flex: 1 1 auto;
  font-family: var(--font-serif);
  font-size: var(--text-base);
  font-weight: 500;
  letter-spacing: .04em;
}
.resume-pill-arrow {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  transition: color .2s, transform .2s;
}
.resume-pill-link:hover .resume-pill-arrow { color: var(--accent); transform: translateX(2px); }

/* ============ Search modal (站內全文搜尋) ============ */
/* A focused, distraction-free overlay that lazy-loads the search index on
   first open. Visual goal: feels like a deliberate moment — pause, look up,
   land on what you wanted — not like a noisy auto-complete. */
/* Header tool icons: keep all 4 buttons (search / 小 / 大 / ☾) same physical
   width so they read as a single, evenly-spaced quartet. The default
   .tool-btn padding handles text buttons; we only need to size the icon. */
.tool-btn-icon { width: 18px; height: 18px; display: block; }

.search-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 16, 10, .55);
  z-index: 250;
  opacity: 0;
  transition: opacity .2s var(--ease-out);
}
html[data-theme="dark"] .search-overlay { background: rgba(0, 0, 0, .7); }
.search-overlay[hidden] { display: none; }
.search-overlay.is-open { opacity: 1; }

.search-modal {
  position: fixed;
  top: 12vh;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  width: min(680px, calc(100% - 2rem));
  max-height: 76vh;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px rgba(20, 16, 10, .25);
  z-index: 251;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity .2s var(--ease-out), transform .2s var(--ease-out);
}
.search-modal[hidden] { display: none; }
.search-modal.is-open {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.search-modal-inner {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.search-modal-header {
  padding: var(--space-3) var(--space-3) 0;
  border-bottom: 1px solid var(--hairline);
}
.search-modal-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 6px 12px;
}
.search-modal-input-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.search-modal-input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 1.1rem;
  padding: .4rem 0;
  outline: none;
  min-width: 0;
}
.search-modal-input::placeholder {
  color: var(--text-muted);
  opacity: .7;
}
.search-modal-input:focus-visible {
  outline: none;
}
.search-modal-close {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  /* WCAG 2.5.5 minimum tap target 44×44 */
  width: 44px;
  height: 44px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.search-modal-close:hover {
  background: var(--bg-subtle);
  color: var(--text);
}
.search-modal-hint {
  margin: 0;
  padding: 8px 14px 12px;
  font-size: .8rem;
  color: var(--text-muted);
  letter-spacing: .02em;
}

.search-modal-results {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
  /* Smooth scroll within modal even with reduced-motion (this is a small list) */
}
.search-result {
  display: block;
  padding: 14px 22px;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--hairline);
  transition: background .12s var(--ease-out);
  cursor: pointer;
}
.search-result:last-child { border-bottom: 0; }
.search-result:hover,
.search-result.is-active,
.search-result:focus-visible {
  background: var(--bg-subtle);
  text-decoration: none;
  outline: none;
}
.search-result.is-active {
  border-left: 3px solid var(--accent);
  padding-left: 19px;
}
.search-result-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 4px;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.02rem;
  letter-spacing: .04em;
  color: var(--text);
}
.search-result-meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  letter-spacing: .04em;
  flex-shrink: 0;
}
.search-result-snippet {
  margin: 0;
  font-size: .92rem;
  line-height: 1.7;
  color: var(--text-soft);
  letter-spacing: .02em;
  /* Two-line ellipsis */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-result-snippet mark {
  background: var(--accent-tint);
  color: var(--accent);
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 500;
}
html[data-theme="dark"] .search-result-snippet mark {
  color: #f0c98a;
}
.search-empty {
  padding: 32px 22px 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: .95rem;
  letter-spacing: .04em;
}
.search-loading {
  padding: 32px 22px;
  text-align: center;
  color: var(--text-muted);
  font-size: .95rem;
}

@media (max-width: 640px) {
  .search-modal {
    top: 0;
    height: 100%;
    max-height: 100%;
    width: 100%;
    border-radius: 0;
    transform: translateX(-50%) translateY(-12px);
  }
  .search-modal-input { font-size: 1rem; }
  .search-result { padding: 12px 16px; }
  .search-result.is-active { padding-left: 13px; }
}

/* ============ Volumes index page (五十卷總覽) ============ */
/* A standalone landing page for /volumes/. Replaces the old dead-end nav
   link that always sent readers to volume-01. Visual goal: editorial,
   spacious, scannable — like a book's table-of-contents. */
.page-volumes-index .site-main { max-width: 960px; }

.volumes-index-header {
  text-align: center;
  margin: var(--space-3) 0 var(--space-7);
  padding: 0 var(--space-3);
}
.volumes-index-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: .14em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin: 0 0 var(--space-3);
}
.volumes-index-title {
  font-family: var(--font-serif);
  font-size: clamp(2.4rem, 5vw, 3.4rem);
  font-weight: 500;
  letter-spacing: .12em;
  color: var(--text);
  margin: 0 0 var(--space-3);
  line-height: 1.15;
}
.volumes-index-lede {
  max-width: 38em;
  margin: 0 auto;
  font-family: var(--font-serif);
  font-size: var(--text-base);
  line-height: 1.8;
  color: var(--text-soft);
  letter-spacing: .02em;
}

.volumes-index-grid {
  margin: var(--space-5) 0 var(--space-7);
}
.vol-cards-rich {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-3);
}

.vol-card-rich {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  column-gap: var(--space-3);
  padding: var(--space-3) calc(var(--space-3) + 4px);
  background: var(--bg-elev);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition:
    transform .25s var(--ease-out),
    border-color .25s var(--ease-out),
    box-shadow .25s var(--ease-out),
    background .25s var(--ease-out);
  overflow: hidden;
}
.vol-card-rich::before {
  /* Left accent bar — fades in on hover for a tactile signal */
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity .25s var(--ease-out);
}
/* Hover effects only fire on real pointing devices — phone/tablet taps don't
   leave a stuck hover state (which on touch screens persists until next tap
   elsewhere). */
@media (hover: hover) and (pointer: fine) {
  .vol-card-rich:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    text-decoration: none;
  }
  .vol-card-rich:hover::before { opacity: 1; }
  .vol-card-rich:hover .vol-card-rich-arrow { transform: translateX(2px); color: var(--accent); }
  .vol-card-rich:hover .vol-card-rich-num { color: var(--accent); }
}
/* On touch, `:active` still gives the press-feedback */
.vol-card-rich:active {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.vol-card-rich:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-color: var(--accent);
}

.vol-card-rich-num {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1;
  letter-spacing: -.02em;
  padding-top: 4px;
  transition: color .25s var(--ease-out);
}

.vol-card-rich-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.vol-card-rich-title {
  font-family: var(--font-serif);
  font-size: var(--text-md);
  font-weight: 500;
  letter-spacing: .06em;
  color: var(--text);
  margin: 0;
  line-height: 1.3;
}
.vol-card-rich-meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: .04em;
  color: var(--text-muted);
  margin: 0;
}
.vol-card-rich-preview {
  font-family: var(--font-serif);
  font-size: var(--text-sm);
  letter-spacing: .03em;
  line-height: 1.7;
  color: var(--text-soft);
  margin: 6px 0 0;
  /* Two-line ellipsis when preview is long */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.vol-card-rich-arrow {
  align-self: center;
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  transition: transform .25s var(--ease-out), color .25s var(--ease-out);
  flex-shrink: 0;
}
.vol-card-rich-arrow svg { display: block; width: 100%; height: 100%; }

.volumes-index-footer-note {
  margin: var(--space-7) auto 0;
  max-width: 38em;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-tint);
  border-radius: 8px;
  border-left: 3px solid var(--accent-soft);
}
.volumes-index-footer-note p {
  margin: 0;
  font-family: var(--font-serif);
  font-size: var(--text-sm);
  line-height: 1.85;
  color: var(--text-soft);
  letter-spacing: .02em;
}
.volumes-index-footer-note a {
  color: var(--link);
  border-bottom: 1px dotted var(--accent-soft);
  padding-bottom: 1px;
}
.volumes-index-footer-note a:hover {
  color: var(--link-hover);
  border-bottom-color: var(--accent);
  text-decoration: none;
}

@media (max-width: 640px) {
  .vol-card-rich { padding: var(--space-3); column-gap: 12px; }
  .vol-card-rich-num { font-size: var(--text-md); }
  .vol-card-rich-arrow { width: 18px; height: 18px; }
  .volumes-index-header { margin-bottom: var(--space-5); }
}

/* Print ============ */
@media print {
  .site-header, .site-footer, .view-controls, .sutra-pager, .volume-pager,
  .breadcrumb, .header-tools, .skip-link, .float-tools, .volume-jump,
  .jump-box, .hero-actions, .intro-cards, .essay-next,
  .sutra-actions, .sutra-tools,
  .search-overlay, .search-modal, .share-overlay, .share-popover,
  .share-toast { display: none !important; }
  body { background: white; color: black; }
  .text-section[hidden] { display: block !important; }
  a { color: black; text-decoration: none; }
  .prose-body { font-size: 12pt; line-height: 1.8; }
  .vernacular-body { background: white !important; border-left: 2px solid #888 !important; }
  .vernacular-disclaimer, .essay-warning { background: white !important; border-left: 2px solid #888 !important; }
  .pull-quote { background: white !important; border-left: 2px solid #444 !important; }
  .site-main { max-width: 100% !important; }
}
