/* The pages around the chapters inside the app shell (spec 2026-10-21-desktop-polish §5): content
   pages (How to read, Laozi, Privacy, About), the full text, the key terms index, a term page and
   settings. Loaded on every app page, because the router swaps pages without reloading the styles.
   The shell's own text sizes (app.css: html.js body.app .zh, .tr) are for chapter lines; these
   pages set theirs here. */

/* Phones and tablets: one readable column */
html.js body.app main > .page, html.js body.app main > .terms-index, html.js body.app main > .term,
html.js body.app .ft-head, html.js body.app .ft { max-width: 44rem; margin-inline: auto; }
.pg-sec h2 { margin: var(--space-5) 0 var(--space-2); }
.pg-sec > :last-child { margin-bottom: 0; }

body.app.page-full-text .ft-chapter h2 { margin: var(--space-5) 0 var(--space-2); }
body.app.page-full-text .ft-line .zh { font-size: calc(1.35rem * var(--user-scale, 1)); line-height: 1.9; }
body.app.page-full-text .ft-line .tr { margin: 0 0 var(--space-2); font-size: calc(1rem * var(--user-scale, 1)); }

body.app.page-term .occ-lines .zh { font-size: calc(1.5rem * var(--user-scale, 1)); line-height: 1.9; }
body.app.page-term .occ-lines .tr { margin: 0; font-size: calc(1rem * var(--user-scale, 1)); }
body.app.page-term .term-side { margin: var(--space-4) 0; }
body.app.page-term .term-facts { margin-top: 0; }

/* Desktop: the width of the reading area, larger type, sections side by side */
@media (min-width: 64rem) {
  html.js body.app main > .page, html.js body.app main > .terms-index, html.js body.app main > .term,
  html.js body.app .ft-head, html.js body.app .ft { max-width: 78rem; margin-inline: 0; }
  html.js body.app main > .settings-page { max-width: 36rem; }
  html.js body.app:not(.page-chapter, .page-home) main h1 { margin-bottom: var(--space-3); font-size: 2.5rem; line-height: 1.2; }
  html.js body.app:not(.page-chapter, .page-home) main .lead { max-width: 52rem; font-size: 1.3rem; }

  /* Content pages: the answer full width, then each section as a card, in columns */
  body.app.page-content .page { font-size: 1.0625rem; line-height: 1.7; }
  body.app.page-content .page > p { max-width: 52rem; color: var(--text-muted); font-size: 1.3rem; line-height: 1.55; }
  .pg-secs { columns: 2 26rem; column-gap: var(--space-4); margin-top: var(--space-4); }
  .pg-sec { break-inside: avoid; margin: 0 0 var(--space-4); padding: var(--space-4) var(--space-5) var(--space-4) var(--space-4); border-radius: var(--radius); background: var(--surface); }
  .pg-sec h2 { margin: 0 0 var(--space-3); font-size: 1.35rem; }
  .pg-sec ul { padding-left: 1.2rem; }
  .pg-sec li + li { margin-top: var(--space-2); }

  /* Full text: the chapter heading in its own column (it stays in view), the translation beside the Chinese */
  body.app.page-full-text .ft-chapter { display: grid; grid-template-columns: 9rem minmax(0, 1fr); column-gap: var(--space-5); padding: var(--space-3) 0; }
  body.app.page-full-text .ft-chapter h2 { position: sticky; top: 0; align-self: start; margin: 0; padding-top: 0.6rem; font-size: var(--step-1); }
  body.app.page-full-text .ft-chapter h2 a { color: var(--text); text-decoration: none; }
  body.app.page-full-text .ft-chapter h2 a:hover { color: var(--red-text); }
  body.app.page-full-text .ft-line { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); column-gap: var(--space-5); align-items: center; }
  body.app.page-full-text .ft-line .zh { font-size: calc(1.6rem * var(--user-scale, 1)); }
  body.app.page-full-text .ft-line .tr { margin: 0; font-size: calc(1.1rem * var(--user-scale, 1)); }
  /* Chinese pages have no translation: the chapters flow in two columns instead. */
  body.app.page-full-text.lang-zh .ft { columns: 2; column-gap: var(--space-5); }
  body.app.page-full-text.lang-zh .ft-chapter { display: block; break-inside: avoid; }
  body.app.page-full-text.lang-zh .ft-chapter h2 { position: static; }
  body.app.page-full-text.lang-zh .ft-line { display: block; }

  /* Key terms: the table as a grid of cards (the template's roles keep it a table for screen readers) */
  body.app.page-terms .terms-table { display: block; margin-top: var(--space-5); }
  body.app.page-terms .terms-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  body.app.page-terms .terms-table tbody { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--space-3); }
  body.app.page-terms .terms-table tr { position: relative; display: grid; align-content: start; gap: var(--space-1); padding: var(--space-4); border-radius: var(--radius); background: var(--surface); }
  body.app.page-terms .terms-table tr:hover { background: var(--surface-2); }
  body.app.page-terms .terms-table th, body.app.page-terms .terms-table td { padding: 0; border: 0; }
  body.app.page-terms .terms-table tbody th a { display: flex; align-items: baseline; gap: var(--space-3); color: var(--text); }
  body.app.page-terms .terms-table tbody th a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }   /* the whole card opens the term */
  body.app.page-terms .terms-table .t-zh { font-size: 2.4rem; line-height: 1.3; }
  body.app.page-terms .terms-table .t-py { font-size: var(--step-0); }
  body.app.page-terms .terms-table td { font-size: var(--step-1); }
  body.app.page-terms .terms-table .t-count { font: var(--step--1) var(--font-ui); }

  /* A term page: the reading on the left, the facts and related terms in a column that stays in view */
  body.app.page-term .term { display: grid; grid-template-columns: minmax(0, 1fr) 22rem; column-gap: var(--space-5); align-items: start; font-size: 1.0625rem; line-height: 1.7; }
  body.app.page-term .term > * { grid-column: 1; }
  body.app.page-term .term > .crumbs, body.app.page-term .term > h1, body.app.page-term .term > .lead { grid-column: 1 / -1; }
  body.app.page-term .term-side { position: sticky; top: 0; grid-column: 2; grid-row: 4 / span 3; margin: 0; padding: var(--space-4); border-radius: var(--radius); background: var(--surface); font-size: var(--step--1); }
  body.app.page-term .term-related h2 { margin: var(--space-4) 0 var(--space-2); font-size: var(--step-0); }
  body.app.page-term .term-related p { margin: 0 0 var(--space-2); color: var(--text-muted); }
  body.app.page-term .term-occ > h2 { margin-top: var(--space-4); }
  body.app.page-term .occ-lines li { display: grid; grid-template-columns: 4.5rem minmax(0, 1.15fr) minmax(0, 1fr); column-gap: var(--space-4); align-items: center; padding: var(--space-2) 0; }
  body.app.page-term .occ-lines .zh { margin: 0; font-size: calc(1.7rem * var(--user-scale, 1)); }
  body.app.page-term .occ-lines .tr { font-size: calc(1.05rem * var(--user-scale, 1)); }
  body.app.page-term.lang-zh .occ-lines li { grid-template-columns: 4.5rem minmax(0, 1fr); }
}
@media (min-width: 100rem) {
  .pg-secs { columns: 3 24rem; }
}
