/* ---- reading page ---- */

/* language switching: root carries data-lang, elements carry .lang-en / .lang-zh */
:root[data-lang="en"] .lang-zh,
:root[data-lang="zh"] .lang-en { display: none; }

.langswitch {
  display: inline-flex; border: 1px solid var(--rule); border-radius: 999px;
  overflow: hidden; font-family: ui-sans-serif, -apple-system, "Segoe UI", Helvetica, sans-serif;
  font-size: 13px;
}
.langswitch button {
  background: none; border: none; cursor: pointer; font: inherit;
  color: var(--muted); padding: 3px 12px;
}
.langswitch button[aria-pressed="true"] {
  background: var(--accent); color: var(--bg);
}
.langswitch button:not([aria-pressed="true"]):hover { color: var(--accent); }

.page-title { font-size: 30px; font-weight: 600; letter-spacing: -.018em; margin: 0 0 10px; }
.rail .lede { font-size: 14.5px; line-height: 1.55; margin-bottom: 10px; }
.railtools { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.railtools #theme { margin-top: 0; }
.lede { color: var(--muted); font-size: 16.5px; margin-bottom: 6px; max-width: 68ch; }

/* CJK text needs a slightly different stack + looser leading */
.zh-text {
  font-family: "Songti SC", "Source Han Serif SC", "Noto Serif CJK SC",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", serif;
  line-height: 1.85;
}

/* ---- excerpts: collapsed to a title, expand for the passage ---- */
.qgroup {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 30px 0 2px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
}
.qgroup:first-of-type { margin-top: 14px; }
.qgroup .n { color: var(--faint); margin-left: 8px; font-weight: 400; }
.lang-zh .qgroup, :root[data-lang="zh"] .qgroup { letter-spacing: .04em; }
.quotes { margin: 0; padding: 0; }
.quotes > details { border-bottom: 1px solid var(--rule); }
.quotes > details > summary {
  cursor: pointer; list-style: none; position: relative;
  padding: 13px 30px 13px 0;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px;
}
.quotes > details > summary::-webkit-details-marker { display: none; }
.quotes > details > summary::after {
  content: ""; position: absolute; right: 6px; top: 19px;
  width: 7px; height: 7px;
  border-right: 1.6px solid var(--faint); border-bottom: 1.6px solid var(--faint);
  transform: rotate(45deg); transition: transform .2s ease, border-color .2s ease;
}
.quotes > details[open] > summary::after { transform: rotate(-135deg); border-color: var(--accent); }
.quotes > details > summary:hover .qt { color: var(--accent); }
.quotes .qt { font-size: 16px; font-weight: 600; transition: color .18s ease; }
.quotes .qa {
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Helvetica, sans-serif;
  font-size: 13px; color: var(--muted);
}
/* provenance chip: real original text vs. an English rendering */
.quotes .prov {
  margin-left: auto;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Helvetica, sans-serif;
  font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--faint); border: 1px solid var(--rule);
  border-radius: 3px; padding: 1px 7px; white-space: nowrap;
}
.quotes .prov.orig-text { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

.quotes blockquote {
  margin: 0 0 18px; padding: 2px 0 0 20px; max-width: 72ch;
  border-left: 2px solid color-mix(in srgb, var(--accent) 40%, transparent);
  font-size: 16px;
  animation: reveal .22s ease-out;
}
.quotes blockquote p { margin: 0 0 12px; }
.quotes blockquote p:last-child { margin-bottom: 0; }

/* original-language text shown alongside a translation */
.orig {
  max-width: 72ch; font-size: 15px; color: var(--muted); font-style: italic;
  margin: 0 0 18px; padding: 10px 0 0 20px; border-top: 1px dotted var(--rule);
}
.orig em { font-style: normal; color: var(--faint); }

/* long passages: same row as a collapsed excerpt, but the title links out */
.quotes > a.qlink {
  border-bottom: 1px solid var(--rule);
  text-decoration: none; color: inherit; cursor: pointer;
  position: relative; padding: 13px 30px 13px 0;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px;
}
.quotes > a.qlink::after {
  content: ""; position: absolute; right: 6px; top: 19px;
  width: 7px; height: 7px;
  border-right: 1.6px solid var(--faint); border-bottom: 1.6px solid var(--faint);
  transform: rotate(45deg); transition: transform .2s ease, border-color .2s ease;
}
.quotes > a.qlink:hover::after { border-color: var(--accent); }
.quotes > a.qlink:hover .qt { color: var(--accent); }

/* ---- full-passage page (passages.html) ---- */
.pnav {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px;
  padding-top: 26px;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Helvetica, sans-serif;
  font-size: 14px;
}
.pnav > a { color: var(--muted); border: none; }
.pnav > a:hover { color: var(--accent); }
.pnav .spacer { flex: 1 1 auto; }
/* the full-passage page runs wide — text fills the page instead of a narrow column */
.wrap-wide { max-width: 1500px; }
.passage {
  margin-top: 46px; padding-top: 22px; border-top: 1px solid var(--rule);
  scroll-margin-top: 20px;
}
.passage:first-of-type { border-top: none; }
.ptitle {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 12px;
  font-size: 21px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 2px;
}
.pauthor {
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Helvetica, sans-serif;
  font-size: 14px; color: var(--muted); margin: 0 0 16px;
}
.ptext { max-width: none; margin: 0 0 4px; }
.ptext p { margin: 0 0 14px; }
.ptext.zh-text p { text-indent: 2em; }
.ptext .star { text-align: center; text-indent: 0; color: var(--faint); margin: 6px 0 16px; }
.pback {
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Helvetica, sans-serif;
  font-size: 13px; margin: 4px 0 0;
}
.pback a { color: var(--faint); border: none; }
.pback a:hover { color: var(--accent); }

/* ---- book list ---- */
.shelf { margin-top: 6px; }
.shelf > details {
  border-bottom: 1px solid var(--rule);
}
.shelf > details > summary {
  cursor: pointer; list-style: none; position: relative;
  padding: 13px 30px 13px 0;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Helvetica, sans-serif;
  font-size: 14px; letter-spacing: .01em; color: var(--text);
}
.shelf > details > summary::-webkit-details-marker { display: none; }
.shelf > details > summary::after {
  content: ""; position: absolute; right: 6px; top: 19px;
  width: 7px; height: 7px;
  border-right: 1.6px solid var(--faint); border-bottom: 1.6px solid var(--faint);
  transform: rotate(45deg); transition: transform .2s ease, border-color .2s ease;
}
.shelf > details[open] > summary::after { transform: rotate(-135deg); border-color: var(--accent); }
.shelf > details > summary:hover { color: var(--accent); }
.shelf > details > summary .n { color: var(--faint); margin-left: 8px; }

.books { list-style: none; margin: 0; padding: 0 0 16px; display: grid; gap: 7px; }
/* long shelves flow into columns instead of one endless strip */
@media (min-width: 860px) {
  .books { column-count: 2; column-gap: 42px; display: block; }
  .books li { break-inside: avoid; margin-bottom: 7px; }
}
@media (min-width: 1180px) {
  .books { column-count: 3; column-gap: 34px; }
}
.books li { font-size: 15px; line-height: 1.45; }
.books .t { display: block; }
.books .a { display: block; font-size: 13px; color: var(--muted); }
.books .a .nat { color: var(--faint); }

/* ---- nobel table ---- */
.medal {
  width: 15px; height: 15px; vertical-align: -2px;
  margin-right: 7px; color: var(--accent-2);
}
.nobel { width: 100%; max-width: 860px; border-collapse: collapse; font-size: 14.5px; }
.nobel th {
  text-align: left; font-family: ui-sans-serif, -apple-system, "Segoe UI", Helvetica, sans-serif;
  font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); font-weight: 600;
  border-bottom: 1px solid var(--rule); padding: 0 10px 7px 0;
}
.nobel td { padding: 7px 10px 7px 0; border-bottom: 1px dotted var(--rule); vertical-align: top; }
.nobel td.y {
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Helvetica, sans-serif;
  font-size: 13px; color: var(--muted); white-space: nowrap; width: 1%;
}
.nobel td.who { font-weight: 600; }
.nobel td.what { color: var(--muted); }
.nobel .nat { color: var(--faint); font-weight: 400; }
.table-wrap { overflow-x: auto; }

/* ---- note on naming ---- */
.caveat {
  max-width: 80ch; margin-top: 40px; padding: 15px 17px;
  background: var(--surface); border: 1px solid var(--rule);
  border-left: 2px solid color-mix(in srgb, var(--accent-2) 50%, transparent);
  border-radius: 5px; font-size: 14.5px; color: var(--muted); line-height: 1.6;
}
.caveat b { color: var(--text); }

@media (max-width: 560px) {
  .page-title { font-size: 26px; }
  .quotes blockquote, .orig { padding-left: 14px; }
  .quotes .prov { margin-left: 0; }
}
