/* Shared by index.html and cohort.html. A paper notebook: warm ground, aubergine ink, hairline
   rules instead of boxes. Mobile first. State is always written as text; colour only supports it.
   The palette is mirrored in src/cohort/chart-png.js for the saved chart. */
:root {
  --paper: #f6f1e7;
  --sheet: #fbf8f1;
  --ink: #2b1a2c;
  --muted: #68586a;
  --rule: #d8cdbb;
  --teal: #0f5c63;
  --plum: #8b2c6a;
  --attention: #7a4300;
  --attention-wash: #f5e9d0;
  --paused: #8c1c2e;
  --paused-wash: #f6e1df;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Avenir Next", Avenir, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 1rem/1.55 var(--sans);
  color: var(--ink);
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

.masthead, main, .page-footer {
  max-width: 74rem;
  margin: 0 auto;
  padding: 0 min(1.25rem, 5vw);
}

/* ---- type ---- */
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; }
h1 { overflow-wrap: anywhere; font-size: clamp(1.9rem, 5vw, 2.75rem); letter-spacing: -0.01em; margin: 2.25rem 0 0.75rem; }
h2 { font-size: 1.5rem; margin: 0 0 1rem; }
h3 { font-size: 1.2rem; margin: 0 0 0.5rem; }
h4, h5 { font-family: var(--sans); margin: 0 0 0.35rem; }
h4 { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
h5 { font-size: 1rem; }
p { margin: 0.5rem 0; }
ul { margin: 0.25rem 0; padding-left: 1.2rem; }
a { color: var(--teal); overflow-wrap: anywhere; }

.lede { font-size: 1.125rem; max-width: 46rem; }
.small, .note, .basis { font-size: 0.875rem; color: var(--muted); }
.note, .basis { display: block; }

/* Focus: a teal ring with a paper gap inside it, so it reads against the paper around a control
   and against a dark control or neighbour alike. A heading or message that receives focus from
   the page shows the ring only when the reader is using the keyboard. */
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; box-shadow: 0 0 0 2px var(--paper); }

.skip { position: absolute; left: -999rem; background: var(--sheet); padding: 0.5rem 0.75rem; }
.skip:focus { left: 0.5rem; top: 0.5rem; z-index: 1; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- masthead and the two-page navigation ---- */
.masthead-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0 2rem;
  padding-top: 0.75rem;
  border-bottom: 2px solid var(--ink);
}
.wordmark { margin: 0; padding: 0.5rem 0; font: 700 1.05rem/1.2 var(--serif); letter-spacing: 0.02em; }
.wordmark span { font-weight: 400; font-style: italic; color: var(--muted); }

.page-nav { display: flex; flex-wrap: wrap; gap: 0 1.75rem; }
.page-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 4px solid transparent;
}
.page-link:hover { border-bottom-color: var(--rule); }
.page-link[aria-current="page"] { font-weight: 700; border-bottom-color: var(--plum); }

.banner {
  max-width: 46rem;
  margin: 1rem 0 0;
  padding-left: 0.75rem;
  border-left: 3px solid var(--plum);
  font-size: 0.9375rem;
  font-weight: 600;
}
.notice { padding: 0.75rem; border: 2px solid var(--ink); background: var(--sheet); }

/* ---- two columns on wide screens: choices on the left, the reading on the right ---- */
.layout { display: grid; gap: 2.5rem; margin-top: 2.5rem; margin-bottom: 3rem; }
.layout > * { min-width: 0; }
.aside h2, .sheet > h2 { padding-top: 0.9rem; border-top: 1px solid var(--ink); }

@media (min-width: 62rem) {
  .layout { grid-template-columns: minmax(17rem, 21rem) minmax(0, 1fr); gap: 4rem; align-items: start; }
}

/* ---- controls ---- */
label { display: block; font-size: 0.9375rem; font-weight: 600; margin-bottom: 0.3rem; }

select {
  width: 100%;
  min-height: 44px;
  font: inherit;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--muted);
  border-radius: 2px;
  background: var(--sheet);
  color: var(--ink);
}

/* Case and task buttons: a row of tabs, the pressed one ruled in plum and set bold. */
.choices { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }
.choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  min-height: 44px;
  flex: 1 1 7rem;
  font: inherit;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--muted);
  border-top: 3px solid var(--muted);
  border-radius: 0;
  padding: 0.45rem 0.7rem 0.5rem;
  cursor: pointer;
}
.choice:hover { border-color: var(--ink); }
.choice[aria-pressed="true"] {
  font-weight: 700;
  background: var(--sheet);
  border-color: var(--ink);
  border-top-color: var(--plum);
}

.badge { font-size: 0.8125rem; font-weight: 400; color: var(--muted); }
.badge-attention { color: var(--attention); font-weight: 600; }
.badge-paused { color: var(--paused); font-weight: 600; }

/* ---- review gate ---- */
.gate {
  margin: 0 0 1.5rem;
  padding: 1rem 1.1rem;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--teal);
}
.gate h3 { font: 600 0.78rem/1.3 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.gate-paused { border-color: var(--paused); background: var(--paused-wash); }
.gate-state { font: 600 1.25rem/1.25 var(--serif); margin: 0 0 0.5rem; }
.gate-paused .gate-state { color: var(--paused); }

/* ---- task panel ---- */
.panel { padding-top: 0.5rem; }
.panel > h3 { font-size: 1.5rem; }
.block, .flags { margin-top: 1.5rem; }
.state { font-weight: 600; margin: 0 0 0.5rem; }
.state-attention { color: var(--attention); }
.state-paused { color: var(--paused); }

.flags { background: var(--attention-wash); border-left: 4px solid var(--attention); padding: 0.75rem 1rem; }
.flags h4 { color: var(--attention); }

.rows { margin: 0.25rem 0; border-top: 1px solid var(--rule); }
.row { padding: 0.55rem 0; border-bottom: 1px solid var(--rule); }
dt { font-weight: 600; }
dd { margin: 0; }

.value { margin-right: 0.6rem; font-variant-numeric: tabular-nums lining-nums; }
.row-missing .value, .row-invalid .value { font-style: italic; }
.row-invalid .value { color: var(--paused); }

/* Where a value came from: quiet text set off by a rule, not a pill. */
.chip { display: inline-block; padding-left: 0.6rem; border-left: 1px solid var(--muted); font-size: 0.8125rem; color: var(--muted); }
.chip-none { font-style: italic; }
.chip-warn { color: var(--paused); border-left-color: var(--paused); font-weight: 600; }

.evidence { padding: 1rem 0 0.25rem; border-top: 1px solid var(--ink); margin-top: 0.75rem; }

.problems { border: 2px solid var(--paused); background: var(--paused-wash); padding: 0.75rem 1rem; margin: 1rem 0; }
.problems h3 { font: 700 1rem/1.3 var(--sans); }

details { margin: 1rem 0; }
summary { cursor: pointer; font-weight: 600; padding: 0.6rem 0; }

pre {
  margin: 0.5rem 0 0;
  padding: 0.75rem;
  background: var(--sheet);
  border: 1px solid var(--rule);
  font: 0.8125rem/1.5 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.page-footer { padding-bottom: 3rem; }
.page-footer > * { max-width: 46rem; }
.page-footer::before { content: ""; display: block; border-top: 1px solid var(--ink); margin-bottom: 1rem; }

@media (min-width: 40rem) {
  .row { display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: 1rem; }
  .choice { flex: 0 1 auto; }
}

/* The left column is narrow at every width: label above value there. */
.aside .row { display: block; }

@media (prefers-reduced-motion: no-preference) {
  .choice, .page-link { transition: border-color 0.12s ease; }
}

/* With the reader's own colours, a pressed button is still told apart by more than its weight. */
@media (forced-colors: active) {
  .choice[aria-pressed="true"], .view[aria-pressed="true"] { forced-color-adjust: none; color: HighlightText; background: Highlight; border-color: Highlight; }
}
