/* The reading layout: every page except the cover and the technology chronicle.
   One column to read. The site directory waits in a drawer at every width, opened from the
   全部笔记 / All notes button in the left margin (the top bar stays exactly as on the cover); the
   page's own contents sit to the right on wide screens; the text column is 660px, about 35 Chinese
   characters or 70 Latin characters a line at the scale's body size, 19px.
   Emphasis has three levels and no more: section headings, one key point per section (.keypoint),
   and bold for a term worth remembering. Reading text is one colour, --ink-soft; weight and size
   do the rest, and ember in the text only marks where the reader is.
   Boxes are for things you use (labs, checks). Tables, folds and code sit on hairlines or a tint.
   The site's own touches stay where they mark the reader's place: the ember progress bar, the
   current section in the contents, the track's next stop. The sky and the study buddy stay on the
   cover; build.py leaves the buddy off the notes, where it sat over the text.
   Colours stay in the token blocks of style.css.
   Selectors start with `:root .page-reading` so they outrank the older layers in style.css. */

:root .page-reading {
  --page-ink: var(--ink); --page-soft: var(--ink-soft); --page-muted: var(--muted);
  --page-faint: var(--faint); --page-rule: var(--rule); --page-rule-soft: var(--rule-soft);
  --read-w: 660px; --body-lh: 1.7; --block-gap: 30px;
}
:root .page-reading:lang(zh) { --body-lh: 1.85; }

/* the top bar joins the page and leaves while reading onward (app.js sets data-bar-hidden) */
:root .page-reading .topbar {
  --ink: var(--page-ink); --ink-soft: var(--page-soft); --muted: var(--page-muted); --faint: var(--page-faint);
  --rule: var(--page-rule); --rule-soft: var(--page-rule-soft);
  background: var(--paper); border-bottom: 1px solid var(--page-rule-soft); transition: transform .2s ease;
}
:root[data-bar-hidden] .page-reading .topbar:not(:has(:focus-visible)) { transform: translateY(-100%); }

/* ---------------------------------------------------------------- the page head */
:root .page-reading article.prose { max-width: var(--read-w); margin-inline: auto; }
:root .page-reading .article-head { margin: 0 0 28px; padding: 0 0 18px; border-bottom: 1px solid var(--rule); background: none; }
:root .page-reading .article-head::before, :root .page-reading .article-head::after { content: none; }
:root .page-reading .prose .article-head h1 { max-width: none; margin: 14px 0 0; color: var(--ink); font-family: var(--display); font-size: clamp(1.85rem, 1.3rem + 1.8vw, min(var(--fs-48), 2.5rem)); line-height: 1.25; font-weight: var(--display-weight); letter-spacing: -.01em; text-wrap: pretty; overflow-wrap: anywhere; }
:root .page-reading:lang(zh) .prose .article-head h1 { line-height: 1.35; letter-spacing: 0; }
:root .page-reading .note-tools:not([hidden]) { display: inline-flex; margin: 0; vertical-align: baseline; }
:root .page-reading .note-tools button { min-height: 44px; margin-block: -12px; padding: 0; border: 0; background: none; color: var(--muted); font-size: 14px; }
:root .page-reading .note-tools button:hover { color: var(--ember); }

/* ---------------------------------------------------------------- text */
:root .page-reading .article-body { font-size: calc(var(--fs-19) * var(--text-scale, 1)); }
:root .page-reading .article-body { color: var(--ink-soft); }
/* note text only: a lab sets its own sizes and colours */
:root .page-reading .article-body :is(p, li, dd):not(.widget *) { line-height: var(--body-lh); color: var(--ink-soft); }
:root .page-reading .article-body > p { margin: 0 0 1em; text-wrap: pretty; }
:root .page-reading .article-body :is(strong, b) { font-weight: 600; color: inherit; }
:root .page-reading .article-body :is(p, li, td, dd, blockquote, figcaption) > a:not([class]) {
  color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--muted) 55%, transparent);
}
:root .page-reading .article-body :is(p, li, td, dd, blockquote, figcaption) > a:not([class]):hover { color: var(--ember); text-decoration-color: currentColor; }
:root .page-reading .prose :not(pre) > code { background: none; padding: 0; font-size: .9em; color: inherit; }
:root .page-reading .term-en { font-size: .82em; color: var(--muted); }
@media (hover: hover) {                     /* touch screens have no hover, so they keep the underline as the only sign of a gloss */
  :root .page-reading .term { border-bottom: 0; }
  :root .page-reading .term:hover, :root .page-reading .term:focus { border-bottom: 1px dotted var(--muted); }
}
/* text size from 设置 → 字号: app.js sets data-text, the head script restores it; headings and navigation keep their size.
   小 is the earlier 17px. */
:root[data-text="s"] { --text-scale: .895; }
:root[data-text="l"] { --text-scale: 1.12; }
:root[data-text="xl"] { --text-scale: 1.24; }

/* headings: the page title keeps the book face; sections use the text face, set apart by size and space */
:root .page-reading .prose :is(h2, h3, h4) { font-family: var(--body); color: var(--ink-soft); letter-spacing: 0; border-top: 0; padding-top: 0; }
:root .page-reading .prose h2 { margin: 64px 0 16px; font-size: var(--fs-24); line-height: 1.45; font-weight: 600; }
:root .page-reading .prose h2::before { content: none; }
:root .page-reading .prose h3 { margin: 40px 0 12px; font-size: var(--fs-19); line-height: 1.5; font-weight: 600; }
:root .page-reading .prose h4 { margin: 28px 0 8px; font-size: 17px; line-height: 1.6; font-weight: 600; }
:root .page-reading:lang(zh) .prose :is(h2, h3) { line-height: 1.55; }

/* the key point: one sentence per section, its label hanging in the margin. Written in a note as
   a paragraph followed by `{: .keypoint }`. */
:root .page-reading .article-body .keypoint { position: relative; margin: 26px 0; color: var(--ink-soft); font-weight: 500; }
:root .page-reading .article-body .keypoint::before {
  content: "要点"; position: absolute; right: calc(100% + 24px); top: .45em;
  color: var(--muted); font-size: 13px; font-weight: 400; line-height: 1.5; white-space: nowrap;
}
:root .page-reading:lang(en) .article-body .keypoint::before { content: "Key point"; }

/* ---------------------------------------------------------------- blocks */
:root .page-reading .article-body :is(.table-wrap, .code-wrap, figure, blockquote) { margin-block: var(--block-gap); }
/* tables: hairlines only, in the text colour */
:root .page-reading .article-body .table-wrap { max-width: 100%; margin-inline: 0; padding: 0; border: 0; border-radius: 0 !important; background: none; box-shadow: none; }
:root .page-reading .table-wrap table { margin: 0; color: var(--ink-soft); font-size: calc(var(--fs-16) * var(--text-scale, 1)); line-height: 1.65; }
:root .page-reading .prose .table-wrap :is(th, td) { padding: 12px 16px 12px 0; border: 0; border-bottom: 1px solid var(--rule-soft); background: none; vertical-align: top; }
:root .page-reading .prose .table-wrap :is(th, td):last-child { padding-right: 0; }
:root .page-reading .prose .table-wrap th { padding-block: 0 10px; border-bottom-color: var(--rule); color: var(--muted); font-size: 13px; font-weight: 400; line-height: 1.5; text-transform: none; letter-spacing: 0; white-space: normal; }
:root .page-reading .prose .table-wrap td { color: var(--ink-soft); font-weight: 400; }
:root .page-reading .prose tbody tr:nth-child(even), :root .page-reading .prose tbody tr:hover { background: none; }
/* folds: one row per question, a plus sign on the right */
:root .page-reading .article-body details:not(.atlas-chapter) { margin: 0; padding: 0; border: 0; border-bottom: 1px solid var(--rule); border-radius: 0 !important; background: none; box-shadow: none; }
:root .page-reading .article-body :not(details) + details:not(.atlas-chapter) { margin-top: 22px; border-top: 1px solid var(--rule); }
:root .page-reading .article-body details:not(.atlas-chapter):not(:has(+ details)) { margin-bottom: var(--block-gap); }
:root .page-reading .article-body details:not(.atlas-chapter) > summary {
  display: block; position: relative; min-height: 0; padding: 13px 34px 13px 0; list-style: none; cursor: pointer;
  color: var(--ink-soft); font-size: calc(17px * var(--text-scale, 1)); font-weight: 400; line-height: 1.6;
}
:root .page-reading .article-body details:not(.atlas-chapter) > summary::-webkit-details-marker { display: none; }
:root .page-reading .article-body details:not(.atlas-chapter) > summary::before { content: none; }
:root .page-reading .article-body details:not(.atlas-chapter) > summary::after {
  content: "+"; position: absolute; right: 2px; top: 12px; border: 0; transform: none;
  color: var(--muted); font: 400 20px/1.3 var(--body);
}
:root .page-reading .article-body details[open]:not(.atlas-chapter) > summary::after { content: "−"; }
:root .page-reading .article-body details:not(.atlas-chapter) > summary :is(b, strong) { font-weight: 600; }
:root .page-reading .article-body details[open]:not(.atlas-chapter) > :not(summary):last-child { margin-bottom: 18px; }
:root .page-reading .article-body details:not(.atlas-chapter) > summary:hover { color: var(--ember); }
/* the question "随机抽一题" drew: an ember rule at its left, and the line saying so on its own row above it */
:root .page-reading .article-body :is(details.qa, .qa-ask li).is-picked { padding-left: 14px; border-left: 2px solid var(--ember); }
:root .page-reading .article-body .qb-picked-label { display: block; margin-bottom: 2px; }
:root .page-reading .article-body :is(.study-route a, details > summary):focus-visible { outline: 2px solid var(--ember); outline-offset: 4px; border-radius: var(--r-2); }
/* code: a tint, no frame */
:root .page-reading .prose pre { margin: 0; padding: 16px 20px; border: 0; border-radius: var(--r-6); background: var(--code-bg); box-shadow: none;
  font-size: calc(14px * var(--text-scale, 1)); line-height: 1.75; }
:root .page-reading .prose pre code { font-size: inherit; line-height: inherit; }
:root .page-reading .article-body > pre { margin-block: var(--block-gap); }
/* quotes and formulas */
:root .page-reading .article-body blockquote { padding: 0 0 0 18px; border: 0; border-left: 2px solid var(--rule); border-radius: 0; background: none; color: var(--ink-soft); }
:root .page-reading .article-body .katex-display { margin: 26px 0; padding: .2rem 0; border-radius: 0; background: none; }
:root .page-reading :is(.article-meta, .prose figcaption) { line-height: 1.6; }
:root .page-reading .prose figcaption { color: var(--muted); font-size: 14px; }

/* cards inside notes: no boxes. They sit on the text's own plane, set apart by hairlines and a 13px
   grey label, never by a fill, a coloured bar or a shadow. */
:root .page-reading .article-body :is(.lesson-recipe, .taste-check, .bilingual-note, .lab-matrix, .curriculum-hero, .curriculum-grid) { margin-block: var(--block-gap); }
/* what this chapter takes apart: two by two under one hairline */
:root .page-reading .lesson-recipe { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; border-top: 1px solid var(--rule); }
:root .page-reading .lesson-recipe > div { padding: 14px 0; border-bottom: 1px solid var(--rule-soft); }
:root .page-reading .lesson-recipe span { display: block; color: var(--muted); font-size: 13px; line-height: 1.5; }
:root .page-reading .lesson-recipe strong { display: block; margin-top: 4px; color: var(--ink-soft); font-size: calc(var(--fs-16) * var(--text-scale, 1)); font-weight: 400; line-height: 1.65; }
/* check yourself (it sits under its own 自检 / Self-check heading), and the note on reading a page in two
   languages: hairlines above and below */
:root .page-reading .taste-check, :root .page-reading .bilingual-note { padding: 16px 0 8px; border-block: 1px solid var(--rule); }
:root .page-reading .taste-check > strong { display: block; margin: 0 0 8px; color: var(--ink-soft); font-weight: 500; line-height: var(--body-lh); }
:root .page-reading .taste-check ol { margin: 0 0 8px; padding-left: 1.4em; }
:root .page-reading .taste-check li { margin-bottom: 8px; }
:root .page-reading .taste-check li::marker { color: var(--muted); font-variant-numeric: tabular-nums; }
:root .page-reading .bilingual-note > span { display: block; color: var(--muted); font-size: 13px; line-height: 1.5; }
:root .page-reading .bilingual-note p { margin: 6px 0 8px; }
/* a section that also reads in English: an ordinary section with a text button at the right of its heading */
:root .page-reading .concept-card { position: relative; margin: 0; }
:root .page-reading .concept-face > :is(h2, h3):first-child, :root .page-reading .concept-title-en { padding-right: 6rem; }
:root .page-reading .concept-title-en { margin: 40px 0 12px; color: var(--ink-soft); font: 600 var(--fs-19)/1.5 var(--body); }
:root .page-reading .concept-title-h2 { margin-top: 64px; font-size: var(--fs-24); line-height: 1.45; }
:root .page-reading .concept-face > :last-child { margin-bottom: 0; }
:root .page-reading .concept-flip {
  position: absolute; top: calc((var(--fs-19) * 1.5 - 44px) / 2); right: 0; z-index: 1; display: inline-flex; align-items: center; height: 44px; padding: 0;
  border: 0; background: none; color: var(--muted); font: 13px/1.5 var(--body); cursor: pointer;
}
:root .page-reading .concept-flip span { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--muted) 55%, transparent); text-underline-offset: 3px; }
:root .page-reading .concept-flip:hover { color: var(--ink); }
:root .page-reading .concept-flip i { margin-left: 4px; font-style: normal; }
/* the heading's top margin falls outside the section, so the button lines up with the section's top edge */
:root .page-reading .concept-card:has(> .concept-face > :is(h2, .concept-title-h2):first-child) .concept-flip { top: calc((var(--fs-24) * 1.45 - 44px) / 2); }
/* two ways to run the labs, and the three steps of reading a chapter: columns under one hairline */
:root .page-reading :is(.lab-matrix, .curriculum-hero) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; border-top: 1px solid var(--rule); }
:root .page-reading .curriculum-hero { grid-template-columns: repeat(3, minmax(0, 1fr)); }
:root .page-reading :is(.lab-matrix, .curriculum-hero) > div { padding: 14px 0; border-bottom: 1px solid var(--rule-soft); }
:root .page-reading :is(.lab-matrix > div > span, .level-chip) { display: block; color: var(--muted); font-size: 13px; line-height: 1.5; }
:root .page-reading :is(.lab-matrix, .curriculum-hero) strong { display: block; margin-top: 4px; color: var(--ink-soft); font-size: calc(var(--fs-16) * var(--text-scale, 1)); font-weight: 600; line-height: 1.6; }
:root .page-reading .prose :is(.lab-matrix, .curriculum-hero) p { margin: 4px 0 0; color: var(--muted); font-size: calc(15px * var(--text-scale, 1)); line-height: 1.65; }
:root .page-reading .lab-matrix a { display: inline-block; margin-top: 6px; padding-block: 6px; font-size: 14px; }
/* the chapter lists on the overview pages: one row per stop, like the tracks; nothing lifts */
:root .page-reading .curriculum-grid { border-top: 1px solid var(--rule); }
:root .page-reading .curriculum-card { display: grid; grid-template-columns: minmax(0, 1fr) 1.25rem; column-gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--rule-soft); color: var(--ink-soft); text-decoration: none; }
:root .page-reading .curriculum-card .card-step { grid-column: 1; color: var(--muted); font-size: 13px; line-height: 1.5; }
:root .page-reading .prose .curriculum-card h3 { grid-column: 1; margin: 0; color: var(--ink-soft); font-size: calc(17px * var(--text-scale, 1)); line-height: 1.55; }
:root .page-reading .prose .curriculum-card p { grid-column: 1; margin: 3px 0 0; color: var(--muted); font-size: calc(15px * var(--text-scale, 1)); line-height: 1.65; }
:root .page-reading .curriculum-card b { grid-column: 2; grid-row: 2; align-self: start; color: var(--muted); font-size: 0; font-weight: 400; text-align: right; }
:root .page-reading .curriculum-card b::after { content: "→"; font-size: 15px; line-height: 1.9; }
:root .page-reading .curriculum-card:hover h3 { color: var(--ember); }
:root .page-reading .curriculum-grid.is-numbered .curriculum-card { grid-template-columns: 2.5rem minmax(0, 1fr) 1.25rem; }
:root .page-reading .curriculum-grid.is-numbered .card-step { grid-row: 1 / span 2; font: calc(15px * var(--text-scale, 1))/1.75 var(--mono); }
:root .page-reading .prose .curriculum-grid.is-numbered :is(h3, p) { grid-column: 2; }
:root .page-reading .curriculum-grid.is-numbered b { grid-column: 3; grid-row: 1; }
@media (max-width: 640px) {
  :root .page-reading :is(.lesson-recipe, .lab-matrix, .curriculum-hero) { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- the columns around the text
   shell.css (round 10) lays out the sidebar, the note and its contents. */
:root .page-reading .prose .mobile-toc { margin: 0 0 28px; border: 0; border-block: 1px solid var(--rule); border-radius: 0 !important; background: none; box-shadow: none; }
:root .page-reading .prose .article-head + .mobile-toc { margin-top: -28px; border-top: 0; }   /* the head already ends on a rule */
:root .page-reading .mobile-toc summary { padding: 12px 0; list-style: none; cursor: pointer; color: var(--ink-soft); font: 400 14px/1.5 var(--body); }
:root .page-reading .mobile-toc summary::-webkit-details-marker { display: none; }
:root .page-reading .mobile-toc summary span { float: right; color: var(--muted); }
:root .page-reading .mobile-toc nav { padding: 0 0 14px; }
:root .page-reading .mobile-toc ul { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 24px; }
:root .page-reading .mobile-toc a { display: block; padding: 4px 0; color: var(--muted); font-size: 14px; line-height: 1.5; text-decoration: none; }
@media (max-width: 1080px) {
  :root .page-reading .article-body .keypoint::before { position: static; display: block; margin-bottom: 4px; }
}
@media (max-width: 600px) {
  :root .page-reading { --block-gap: 26px; }
  :root .page-reading .article-body { font-size: calc(17px * var(--text-scale, 1)); }   /* about 19 Chinese characters a line */
  :root .page-reading .prose .article-head h1 { font-size: 30px; }
  :root .page-reading .prose h2 { margin-top: 48px; }
  :root .page-reading .prose h3 { margin-top: 32px; }
  :root .page-reading .mobile-toc ul { columns: 1; }
  :root .page-reading .prose pre { padding: 14px 16px; font-size: calc(13px * var(--text-scale, 1)); }
}

/* details */
/* contents, directory and table cells: no single character left alone on a last line */
:root .page-reading :is(.toc a, .side a, .side summary, .prose td, .prose th) { text-wrap: pretty; }
/* the glossary follows the last section: its own rule doubled the one above it */
:root .page-reading .page-glossary { border-top: 0; padding-top: 0; }
/* the footer (previous / next, feedback, links) lines up with the text column */
:root .page-reading .page-foot { max-width: var(--read-w); margin-inline: auto; }
/* previous / next are whole cards: underline the title on hover only */
:root .page-reading .page-turn :is(.page-turn-prev, .page-turn-next) { text-decoration: none; }
:root .page-reading .page-turn :is(.page-turn-prev, .page-turn-next):hover strong { text-decoration: underline; text-underline-offset: 4px; }
/* the interview home is a directory: no reading time, and its section heading keeps its own spacing */

@media (prefers-reduced-motion: reduce) {
  :root .page-reading .topbar, :root .page-reading .side { transition: none; }
}

:root .page-reading .prose .system-flow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
  padding: 1.4rem 0;
  border-block: 1px solid var(--rule);
}
:root .page-reading .prose .system-flow-lane { min-width: 0; }
:root .page-reading .prose .system-flow-lane h3 { margin: 0 0 1rem; font: 600 var(--fs-16)/1.5 var(--body); }
:root .page-reading .prose .system-flow-lane ol { margin: 0; padding-left: 1.5rem; }
:root .page-reading .prose .system-flow-lane li { padding: 0 0 .6rem .25rem; font: 400 var(--fs-16)/1.65 var(--body); overflow-wrap: anywhere; }
:root .page-reading .prose .system-flow-lane li::marker { color: var(--muted); font-variant-numeric: tabular-nums; }
:root .page-reading .prose .system-flow-lane p { margin: .7rem 0 0; color: var(--muted); font: 400 var(--fs-16)/1.65 var(--body); }

/* the shared hairline grid inside a note: no list bullets or prose spacing in the cells */
:root .page-reading .prose :is(ul.cells, ol.cells) { margin: 0; padding: 0; list-style: none; }
:root .page-reading .prose .cells > li { margin: 0; padding: 0; }
:root .page-reading .prose .cells > li::before { content: none; }
