/* =========================================================================
   Yau Awards Archive — Book reader (the Whitepaper, web edition)
   Loads on top of tian2.css + site.css. Accent: coral.
   ========================================================================= */

/* ---------- Book main column ---------- */

.book-main { padding: 56px 0 96px; }
@media (max-width: 720px) { .book-main { padding: 36px 0 64px; } }

/* ---------- Chapter head ---------- */

.chapter-head {
  margin: 12px 0 28px;
}

.chapter-eyebrow {
  font-family: var(--font-label);
  font-size: 14px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--coral);
  margin: 0 0 16px;
  line-height: 1;
}

.chapter-title {
  font-family: var(--font-display-en);
  font-weight: 800;
  font-size: 56px;
  line-height: 1.06;
  letter-spacing: -0.015em;
  margin: 0 0 18px;
  color: var(--ink);
}

.chapter-title .zh {
  display: block;
  font-family: var(--font-serif-zh);
  font-weight: 800;
  font-size: 1em;
  letter-spacing: 0;
  line-height: 1.1;
}

.chapter-title .en {
  display: block;
  font-family: var(--font-display-en);
  font-weight: 600;
  font-style: italic;
  font-size: 0.45em;
  color: var(--ink-2);
  margin-top: 18px;
  letter-spacing: 0;
  text-wrap: balance;
}

.chapter-meta {
  font-family: var(--font-label);
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0;
  line-height: 1;
}

.chapter-meta .folio {
  font-family: var(--font-display-en);
  font-weight: 800;
  font-size: 24px;
  letter-spacing: 0;
  color: var(--ink);
  margin-right: 8px;
  vertical-align: -3px;
}

.chapter-meta .dot { margin: 0 8px; color: var(--ink-3); }

@media (max-width: 720px) {
  .chapter-title { font-size: 38px; }
  .chapter-title .en { font-size: 0.55em; }
}

/* ---------- Reading layout: body + sticky TOC ---------- */

.book-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 48px;
  margin: 36px 0 24px;
  align-items: start;
}

@media (max-width: 920px) {
  .book-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

.book-body {
  max-width: 720px;
  min-width: 0;
  font-family: var(--font-body-zh);
  font-size: 17px;
  line-height: 1.75;
  color: var(--ink);
}

.book-body p {
  font-family: var(--font-body-zh);
  font-size: 17px;
  line-height: 1.85;
  color: var(--ink);
  margin: 0 0 1.1em;
  text-wrap: pretty;
}

.book-body p:first-of-type {
  font-size: 18px;
}

.book-body strong,
.book-body b {
  font-family: var(--font-body-zh);
  font-weight: 700;
  color: var(--ink);
}

.book-body em,
.book-body i {
  font-family: var(--font-serif-zh);
  font-style: italic;
  color: var(--ink-2);
}

/* ---------- Headings inside the chapter body ---------- */

.book-body section.level1 > h1,
.book-body section.level2 > h2,
.book-body section.level3 > h3,
.book-body section.level4 > h4 {
  scroll-margin-top: 24px;
}

.book-body h1 {
  font-family: var(--font-serif-zh);
  font-weight: 800;
  font-size: 32px;
  line-height: 1.25;
  margin: 48px 0 18px;
  color: var(--ink);
  letter-spacing: 0;
  padding-top: 24px;
  border-top: var(--stroke) solid var(--ink);
}

.book-body h2 {
  font-family: var(--font-serif-zh);
  font-weight: 700;
  font-size: 25px;
  line-height: 1.3;
  margin: 40px 0 14px;
  color: var(--ink);
  letter-spacing: 0;
  padding-top: 16px;
  border-top: 1px solid var(--ink);
}

.book-body h3 {
  font-family: var(--font-serif-zh);
  font-weight: 700;
  font-size: 20px;
  line-height: 1.35;
  margin: 32px 0 12px;
  color: var(--ink);
  letter-spacing: 0;
}

.book-body h4 {
  font-family: var(--font-body-zh);
  font-weight: 700;
  font-size: 17px;
  line-height: 1.4;
  margin: 24px 0 10px;
  color: var(--ink-2);
  letter-spacing: 0.02em;
}

/* The first heading sits flush with the chapter rule above. */
.book-body > section.level1:first-child > h1,
.book-body > section:first-child > h1,
.book-body > h1:first-child {
  margin-top: 0;
  border-top: 0;
  padding-top: 0;
}

/* ---------- Lists ---------- */

.book-body ol,
.book-body ul {
  margin: 0 0 1.2em 1.5em;
  padding: 0;
  font-family: var(--font-body-zh);
  font-size: 17px;
  line-height: 1.8;
  color: var(--ink);
}

.book-body li {
  margin: 0 0 0.6em;
  padding-left: 4px;
}

.book-body li > p { margin: 0 0 0.4em; }

.book-body ol > li::marker {
  font-family: var(--font-display-en);
  font-weight: 700;
  color: var(--ink-2);
}

.book-body ul > li::marker { color: var(--ink-3); }

/* ---------- Figures ---------- */

.book-body figure {
  margin: 32px 0;
  text-align: center;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  padding: 24px 0 18px;
}

.book-body figure img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto 16px;
  border: 1px solid var(--ink-3);
  background: var(--cream-2);
}

.book-body figcaption {
  font-family: var(--font-serif-zh);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 32em;
  margin: 0 auto;
  font-style: normal;
}

/* ---------- Tables ---------- */

.table-scroll {
  overflow-x: auto;
  margin: 28px 0;
  border: var(--stroke) solid var(--ink);
  background: var(--cream);
  -webkit-overflow-scrolling: touch;
}

.table-scroll table {
  border-collapse: collapse;
  width: 100%;
  min-width: 540px;
  font-family: var(--font-body-zh);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
}

.table-scroll caption {
  font-family: var(--font-display-en);
  font-style: italic;
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  text-align: left;
  padding: 14px 18px 4px;
  caption-side: top;
}

.table-scroll thead th {
  font-family: var(--font-body-zh);
  font-weight: 700;
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: var(--cream-2);
  text-align: left;
  padding: 10px 14px;
  border-bottom: var(--stroke) solid var(--ink);
  vertical-align: top;
}

.table-scroll tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--ink-3);
  vertical-align: top;
}

.table-scroll tbody tr:last-child td { border-bottom: 0; }

.table-scroll tbody tr:nth-child(even) td { background: rgba(239, 228, 205, 0.45); }

/* ---------- Code blocks & quotes ---------- */

.book-body pre {
  margin: 22px 0;
  padding: 16px 18px;
  background: var(--ink);
  color: var(--cream);
  border: var(--stroke) solid var(--ink);
  font-family: 'IBM Plex Mono', ui-monospace, 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  border-radius: 0;
}

.book-body pre code {
  background: transparent;
  color: var(--cream);
  border: 0;
  padding: 0;
  font-size: inherit;
}

.book-body code {
  background: var(--cream-2);
  border: 1px solid var(--ink-3);
  border-radius: var(--radius-1);
  padding: 0.05em 0.32em;
  font-size: 0.92em;
}

.book-body blockquote {
  margin: 28px 0;
  padding: 16px 22px;
  border-left: var(--stroke) solid var(--coral);
  background: var(--cream-2);
  font-family: var(--font-serif-zh);
  font-style: italic;
  font-size: 16.5px;
  line-height: 1.7;
  color: var(--ink-2);
}

.book-body blockquote p { margin: 0 0 0.6em; }
.book-body blockquote p:last-child { margin: 0; }

/* ---------- Footnotes ---------- */

.book-body .footnote-ref a,
.book-body a.footnote-ref {
  text-decoration: none;
  font-size: 0.82em;
  vertical-align: super;
  color: var(--coral);
  padding: 0 2px;
}

.book-body section.footnotes {
  margin-top: 56px;
  padding-top: 24px;
  border-top: var(--stroke) solid var(--ink);
  font-size: 14px;
  color: var(--ink-2);
}

.book-body section.footnotes ol { font-size: 14px; line-height: 1.7; }
.book-body section.footnotes a { word-break: break-all; }
.book-body section.footnotes hr { display: none; }

/* ---------- Color chip from \ccr{} ---------- */

.ccr-chip {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 1px solid var(--ink);
  vertical-align: -2px;
  margin: 0 2px;
}

/* ---------- Chinese type-style spans ---------- */

.ti-hei { font-family: var(--font-body-zh); font-weight: 700; }
.ti-kai { font-family: var(--font-serif-zh); font-style: italic; }
.ti-song { font-family: var(--font-serif-zh); }
.ti-fang { font-family: var(--font-serif-zh); font-weight: 500; }

/* ---------- Math (MathML) ---------- */

.book-body math {
  font-size: 1em;
  font-family: var(--font-display-en);
}

/* ---------- Section TOC (sticky on desktop) ---------- */

.book-toc {
  position: sticky;
  top: 24px;
  border-left: var(--stroke) solid var(--ink);
  padding: 4px 0 4px 20px;
  align-self: start;
}

.book-toc__label {
  font-family: var(--font-label);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--coral);
  margin: 0 0 14px;
  line-height: 1;
}

.book-toc__list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--font-body-zh);
  font-size: 14px;
  line-height: 1.5;
}

.book-toc__item {
  margin: 0 0 10px;
}

.book-toc__item--sub {
  margin-left: 12px;
  font-size: 13px;
  color: var(--ink-2);
}

.book-toc__item a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color var(--dur) var(--ease-standard),
              border-color var(--dur) var(--ease-standard);
}

.book-toc__item a:hover {
  color: var(--coral);
  border-bottom-color: var(--coral);
}

.book-toc__empty {
  font-family: var(--font-body-zh);
  font-size: 13px;
  color: var(--ink-3);
  font-style: italic;
}

@media (max-width: 920px) {
  .book-toc {
    position: static;
    border-left: 0;
    border-top: 1px solid var(--ink);
    padding: 18px 0 0;
    margin-top: 24px;
  }
  .book-toc__list { columns: 2; column-gap: 24px; }
  .book-toc__item { break-inside: avoid; }
}

@media (max-width: 480px) {
  .book-toc__list { columns: 1; }
}

/* ---------- Chapter pagination ---------- */

.chapter-pagination {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 24px;
  align-items: center;
  margin: 32px 0 0;
}

.chapter-pagination a {
  text-decoration: none;
  color: var(--ink);
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border: var(--stroke) solid var(--ink);
  background: var(--cream);
  transition: background var(--dur) var(--ease-standard);
}

.chapter-pagination a:hover { background: var(--cream-2); }

.pag-prev { text-align: left; }
.pag-next { text-align: right; }

.pag-prev .pag-cap,
.pag-next .pag-cap {
  font-family: var(--font-label);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--coral);
  line-height: 1;
}

.pag-prev .pag-name,
.pag-next .pag-name {
  font-family: var(--font-display-en);
  font-weight: 700;
  font-size: 16px;
  line-height: 1.2;
  color: var(--ink);
}

.pag-up {
  font-family: var(--font-label);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-2);
  padding: 14px 16px;
  border: 1px solid var(--ink);
  background: var(--cream);
  transition: background var(--dur) var(--ease-standard);
}

.pag-up:hover { background: var(--cream-2); color: var(--ink); }

.pag-edge {
  font-family: var(--font-label);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 14px 16px;
}

.pag-prev { justify-self: start; }
.pag-next { justify-self: end; }

@media (max-width: 640px) {
  .chapter-pagination {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .pag-prev, .pag-next, .pag-up, .pag-edge {
    justify-self: stretch;
    text-align: center;
  }
}

/* =========================================================================
   Chapter index (the landing page)
   ========================================================================= */

.book-cta-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin: 24px 0 12px;
}

.chapter-shelf {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
}

.chapter-card {
  border-top: 1px solid var(--ink);
  margin: 0;
}

.chapter-card:last-child {
  border-bottom: 1px solid var(--ink);
}

.chapter-card__link {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  padding: 28px 0;
  text-decoration: none;
  color: var(--ink);
  transition: background var(--dur) var(--ease-standard);
}

.chapter-card__link:hover { background: var(--cream-2); }

.chapter-card__folio {
  font-family: var(--font-display-en);
  font-weight: 800;
  font-size: 56px;
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.chapter-card__body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.chapter-card__label {
  font-family: var(--font-label);
  font-size: 12px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--coral);
  line-height: 1;
}

.chapter-card__title-en {
  font-family: var(--font-display-en);
  font-weight: 700;
  font-size: 26px;
  line-height: 1.18;
  color: var(--ink);
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.chapter-card__title-zh {
  font-family: var(--font-serif-zh);
  font-weight: 700;
  font-size: 18px;
  line-height: 1.3;
  color: var(--ink-2);
}

.chapter-card__opening {
  font-family: var(--font-body-zh);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 38em;
  margin-top: 4px;
}

.chapter-card__cta {
  font-family: var(--font-label);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink);
  margin-top: 4px;
}

@media (max-width: 640px) {
  .chapter-card__link {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .chapter-card__folio { font-size: 44px; }
  .chapter-card__title-en { font-size: 22px; }
  .chapter-card__title-zh { font-size: 16px; }
}

/* =========================================================================
   Library/book.html — chooser layout (two-card)
   ========================================================================= */

.format-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 28px;
  margin: 36px 0 8px;
}

@media (max-width: 720px) {
  .format-grid { grid-template-columns: 1fr; gap: 18px; }
}

.format-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  border: var(--stroke) solid var(--ink);
  background: var(--cream);
  padding: 28px 28px 24px;
  text-decoration: none;
  color: var(--ink);
  transition: background var(--dur) var(--ease-standard);
}

.format-card:hover { background: var(--cream-2); }

.format-card__eyebrow {
  font-family: var(--font-label);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--coral);
  line-height: 1;
}

.format-card__title {
  font-family: var(--font-display-en);
  font-weight: 700;
  font-size: 28px;
  line-height: 1.18;
  color: var(--ink);
  margin: 0;
}

.format-card__meta {
  font-family: var(--font-body-en);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-2);
  margin: 0;
}

.format-card__cta {
  margin-top: 8px;
  font-family: var(--font-label);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink);
}

/* =========================================================================
   Bilingual (EN / 中文) support for the book pages.
   The chapter title and chapter-card title now use `.tr` EN/中文 pairs
   instead of the old .chapter-title .zh/.en and .chapter-card__title-en/zh.
   site.css hides the inactive variant; here we restore block display and the
   typography the old (now-removed) class selectors used to provide.
   ========================================================================= */

/* Chapter <h1> title: the visible variant fills the line as a block. */
.chapter-title .tr { display: block; }
html[lang="zh"] .chapter-title .tr[lang="zh"] {
  font-family: var(--font-serif-zh);
  font-weight: 800;
  font-size: 1em;
  letter-spacing: 0;
  line-height: 1.1;
}
html[lang="en"] .chapter-title .tr[lang="en"] {
  font-family: var(--font-display-en);
  font-weight: 700;
  font-size: 0.9em;
  font-style: normal;
  letter-spacing: -0.01em;
  line-height: 1.08;
  text-wrap: balance;
}

/* Chapter-card title: one .tr pair, shown variant is a block heading. */
.chapter-card__title .tr { display: block; }
.chapter-card__title .tr[lang="en"] {
  font-family: var(--font-display-en);
  font-weight: 700;
  font-size: 26px;
  line-height: 1.18;
  color: var(--ink);
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.chapter-card__title .tr[lang="zh"] {
  font-family: var(--font-serif-zh);
  font-weight: 700;
  font-size: 24px;
  line-height: 1.25;
  color: var(--ink);
}

/* In-chapter TOC: anchors are .tr pairs; the shown one is the list link. */
.book-toc__list .tr { display: inline; }

/* Placeholder shown when an English fragment has not been authored yet. */
.en-missing {
  padding: 24px;
  border: 1px dashed var(--ink-3, #b9b2a6);
  border-radius: 6px;
  color: var(--ink-2);
  font-style: italic;
}

@media (max-width: 640px) {
  .chapter-card__title .tr[lang="en"] { font-size: 22px; }
  .chapter-card__title .tr[lang="zh"] { font-size: 19px; }
}
