/* Reviewer demo site for ReadableSTEM. Two stylesheets (tokens.css, copied from the web app by
   build.py with its fonts, then this one), no scripts, no outside requests. DESIGN.md at the
   repository root says how the tokens are used. Text is at least 7:1 on its background in light
   and in dark; nothing is under 14px. The site reflows to 320 CSS pixels and works at 200% text
   size. The converted output and the PDF pages stay on white paper in both themes. */

:root {
  --soft: var(--surface);
  --line: var(--border-control);
  --muted: var(--ink-muted);
  --accent-soft: var(--accent-tint);
  --flag: var(--warn);
  --flag-soft: var(--warn-tint);
  --ok-soft: var(--ok-tint);
  --measure: var(--prose-max);
  --wide: var(--page-max);
  --serif: var(--font-display);
  --sans: var(--font-sans);
  --mono: var(--font-mono);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1.125rem/1.6 var(--sans);
  overflow-wrap: break-word;
}

a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:visited { color: var(--visited); }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus-outline); outline-offset: 2px; box-shadow: 0 0 0 5px var(--focus-halo); }
::selection { background: var(--accent); color: var(--on-accent); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.skip-link {
  position: absolute; left: var(--space-2); top: -10rem; z-index: 10;
  background: var(--bg); color: var(--accent); padding: var(--space-2) var(--space-3);
  border: 2px solid var(--focus-outline); border-radius: var(--radius-control);
}
.skip-link:focus { top: var(--space-2); }

/* ----- frame */
.site-header { border-bottom: 1px solid var(--border-subtle); background: var(--bg); }
.bar, main, .site-footer > div { max-width: var(--wide); margin: 0 auto; padding-left: var(--space-5); padding-right: var(--space-5); }
.bar { min-height: 4rem; padding-top: var(--space-2); padding-bottom: var(--space-2); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-5); }
.brand { display: inline-flex; align-items: center; gap: var(--space-2); font: 700 1.125rem/1.2 var(--sans); color: var(--ink); text-decoration: none; }
.brand:visited, .brand:hover { color: var(--ink); }
.brand svg { width: 1.5rem; height: 1.5rem; flex: none; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-5); }
.site-nav a { color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; min-height: 2.75rem; font-size: 1rem; }
.site-nav a:visited { color: var(--ink); }
.site-nav a:hover, .site-nav a:focus-visible { text-decoration: underline; text-decoration-thickness: 2px; }
.site-nav a[aria-current="page"] { font-weight: 700; text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 0.3em; }

main { padding-top: var(--space-5); padding-bottom: var(--space-8); }
.prose, .measure { max-width: var(--measure); }

h1, h2, h3, h4 { font-family: var(--sans); font-weight: 700; line-height: var(--lh-head); text-wrap: balance; }
h1 { font-family: var(--font-display); font-weight: 600; font-size: var(--step-4); margin: var(--space-2) 0 var(--space-4); }
h2 { font-family: var(--font-display); font-weight: 600; font-size: var(--step-3); margin: var(--space-7) 0 var(--space-3); padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); }
h3 { font-size: var(--step-2); margin: var(--space-6) 0 var(--space-2); }
h4 { font-size: var(--step-1); margin: var(--space-5) 0 var(--space-2); }
h2:first-of-type { border-top: 0; padding-top: 0; }
p { margin: 0 0 1em; }
ul, ol { padding-left: 1.4rem; margin: 0 0 1em; }
li { margin-bottom: 0.35em; }
code, kbd, .mono { font-family: var(--mono); font-size: max(0.875rem, 0.9em); }
cite { font-style: italic; }
.lede { font-size: var(--step-2); line-height: 1.5; color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: var(--step--1); }
.eyebrow { font: 400 1rem/1.3 var(--sans); color: var(--muted); margin: 0; }

/* ----- callouts and cards */
.callout { border: 1px solid var(--border-subtle); border-radius: var(--radius-frame); background: var(--accent-soft); padding: var(--space-3) var(--space-4); margin: var(--space-4) 0 var(--space-5); max-width: var(--measure); }
.callout > :last-child { margin-bottom: 0; }
.callout.flag { border: 2px solid var(--flag); background: var(--flag-soft); }
.callout h2, .callout h3 { margin-top: 0; border: 0; padding-top: 0; font-family: var(--sans); font-size: var(--step-1); }
.tag { display: inline-block; border: 1px solid var(--ink); border-radius: var(--radius-control); padding: 0 0.5em; font: 700 0.875rem/1.5 var(--sans); background: var(--bg); }
.tag.dev { border-color: var(--flag); color: var(--flag); }

.grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); margin: var(--space-4) 0 var(--space-5); padding: 0; list-style: none; }
.card { border: 1px solid var(--border-subtle); border-radius: var(--radius-frame); padding: var(--space-4); background: var(--bg); margin: 0; }
.card h2, .card h3 { margin: 0 0 var(--space-2); padding: 0; border: 0; font-family: var(--sans); font-size: var(--step-1); }
.card > :last-child { margin-bottom: 0; }

/* ----- tables */
.table-scroll { overflow-x: auto; max-width: 100%; margin: 0 0 var(--space-5); }
.table-scroll:focus-visible { outline: 3px solid var(--focus-outline); }
table { border-collapse: collapse; width: 100%; font-size: 1rem; }
caption { text-align: left; font-weight: 700; padding: 0 0 var(--space-2); }
th, td { border: 1px solid var(--border-control); padding: var(--space-2) var(--space-3); text-align: left; vertical-align: top; }
thead th { background: var(--surface); }
tbody th { font-weight: 700; }
td.num { font-variant-numeric: tabular-nums; }

/* ----- definition lists */
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-1) var(--space-4); margin: 0 0 var(--space-5); }
dl.facts dt { font-weight: 700; }
dl.facts dd { margin: 0; }
@media (max-width: 30rem) { dl.facts { grid-template-columns: 1fr; gap: 0; } dl.facts dd { margin-bottom: var(--space-2); } }

/* ----- the pairs: PDF page beside converted output */
.pair { display: grid; gap: var(--space-4); grid-template-columns: 1fr; margin: 0 0 var(--space-6); }
@media (min-width: 58rem) { .pair { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
.pair > * { min-width: 0; }
.pdf-page { margin: 0; border: 1px solid var(--border-subtle); border-radius: var(--radius-frame); background: var(--surface); padding: var(--space-2); }
.pdf-page img { display: block; width: 100%; height: auto; background: var(--paper); }
.pdf-page figcaption { font-size: var(--step--1); margin-top: var(--space-1); color: var(--muted); }
.out-label, .part-label { font: 700 1rem/1.3 var(--sans); color: var(--muted); margin: 0 0 var(--space-1); }

/* The converted output, shown as the tool wrote it. The rules below the marker are the
   tool's own stylesheet, copied and scoped by build.py. It is a picture of a document, so it
   stays white paper in dark mode. */
.converted { color-scheme: light; border: 1px solid var(--border-subtle); border-radius: var(--radius-control); padding: var(--space-3) var(--space-4); background: var(--paper); color: var(--paper-ink); overflow-wrap: break-word; font-size: 1rem; line-height: 1.6; }
.converted a { color: #1c46ad; }
.converted math { font-family: "Latin Modern Math", "STIX Two Math", "Cambria Math", "Noto Sans Math", math; }
math { font-family: "Latin Modern Math", "STIX Two Math", "Cambria Math", "Noto Sans Math", math; }
.converted img { max-width: 100%; height: auto; }
.converted .scroll-region { overflow-x: auto; }

/* ----- decision cards (a static view of the review screen) */
.decisions { list-style: none; padding: 0; margin: 0 0 var(--space-5); display: grid; gap: var(--space-4); grid-template-columns: minmax(0, 1fr); }
.decision { min-width: 0; overflow-wrap: anywhere; }
.decision { border: 2px solid var(--flag); border-radius: var(--radius-frame); padding: var(--space-3) var(--space-4) var(--space-4); background: var(--bg); }
.decision.optional { border-color: var(--accent); }
.decision h3 { margin: 0 0 var(--space-2); font-size: var(--step-1); }
.decision .meta { color: var(--muted); font-size: var(--step--1); margin: 0 0 var(--space-2); }
img.framed { max-width: 100%; height: auto; border: 1px solid var(--border-subtle); }
.decision .crop { display: block; max-width: 100%; height: auto; border: 1px solid var(--border-subtle); background: var(--paper); }
.proposal { border: 1px dashed var(--border-control); border-radius: var(--radius-control); background: var(--paper); color: var(--paper-ink); padding: var(--space-2) var(--space-3); margin: var(--space-2) 0 var(--space-3); overflow-x: auto; }
.proposal math { font-size: 1.25em; }
.said { margin: 0 0 var(--space-2); }
.said .lab { font-weight: 700; }
mark.said-diff { background: var(--tint-required); color: var(--ink); font-weight: 700; padding: 0 0.15em; text-decoration: underline 2px var(--flag); text-underline-offset: 0.2em; }
.choices { margin: var(--space-2) 0 0; padding-left: 1.2rem; }
.choices li { margin-bottom: 0.25em; }

/* ----- before and after */
.ba { display: grid; gap: var(--space-4); grid-template-columns: 1fr; margin: 0 0 var(--space-6); }
@media (min-width: 58rem) { .ba { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.ba > section { border: 1px solid var(--border-subtle); border-radius: var(--radius-frame); background: var(--surface); padding: var(--space-3) var(--space-4); min-width: 0; }
.ba > section h4 { margin-top: 0; }
.ba .before { border: 2px solid var(--flag); }
.ba .after { border: 2px solid var(--accent); }
.readout { font-family: var(--sans); font-size: var(--step-1); }
.quote { border: 1px solid var(--border-subtle); border-radius: var(--radius-control); background: var(--surface); margin: var(--space-1) 0 var(--space-3); padding: var(--space-2) var(--space-3); }

/* ----- footer: the same four columns as the app, then the licence text */
.site-footer { margin-top: var(--space-7); border-top: 1px solid var(--border-subtle); background: var(--surface); padding-top: var(--space-6); padding-bottom: var(--space-6); font-size: 1rem; }
.footer-cols { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-5); margin-bottom: var(--space-5); }
.footer-cols h2 { font: 700 1rem/1.4 var(--sans); margin: 0 0 var(--space-3); padding: 0; border: 0; }
.footer-cols ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-1); }
.footer-cols li { margin: 0; }
.footer-legal { border-top: 1px solid var(--border-subtle); padding-top: var(--space-4); color: var(--muted); }
.footer-legal p { margin-bottom: 0.5em; max-width: 60rem; }
@media (max-width: 52rem) { .footer-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 30rem) { .footer-cols { grid-template-columns: minmax(0, 1fr); } }

.btn { display: inline-flex; align-items: center; min-height: 2.75rem; border: 2px solid var(--accent); border-radius: var(--radius-control); padding: 0 var(--space-4); text-decoration: none; font-weight: 700; background: var(--accent); color: var(--on-accent); margin: 0 var(--space-2) var(--space-2) 0; }
.btn:visited, .btn:hover { color: var(--on-accent); }
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; }
.btn.secondary, .btn.secondary:visited { background: var(--bg); color: var(--accent); }
.btn.secondary:hover { background: var(--accent-tint); color: var(--accent-hover); }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
@media (prefers-reduced-motion: no-preference) { a, .btn { transition: color 120ms, background-color 120ms; } }
@media print { .site-nav, .skip-link { display: none; } a { color: inherit; } }

@media (forced-colors: active) {
  :focus-visible { box-shadow: none; outline: 3px solid Highlight; }
  .btn { border-color: ButtonText; }
  .callout, .card, .decision, .ba > section, .pdf-page, .quote, .tag { border-color: CanvasText; }
  .converted, .proposal { forced-color-adjust: none; border-color: CanvasText; }
}

/* Converted headings keep their original size class (lvN) after the level shift. */
.converted :is(h1, h2, h3, h4, h5, h6) { font-family: inherit; border: 0; padding: 0; }
.converted .lv1 { font-size: 1.45rem; }
.converted .lv2 { font-size: 1.25rem; }
.converted .lv3 { font-size: 1.1rem; }
.converted .lv4, .converted .lv5, .converted .lv6 { font-size: 1rem; }
.converted { max-width: none; margin: 0; }
