/* The public pages (home, topics, about, privacy, terms). Same colours as the app. */

:root {
  --bg: #f3f5f7;
  --card: #ffffff;
  --text: #17202b;
  --muted: #5a6573;
  --line: #d9dfe6;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e3f3f1;
  --good: #157a3b;
  --good-soft: #e5f5ea;
  --warn: #8a5300;
  --warn-soft: #fff3dc;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.06), 0 1px 3px rgb(16 24 40 / 0.08);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1418;
    --card: #182027;
    --text: #e8edf2;
    --muted: #9aa6b2;
    --line: #2c3742;
    --accent: #2bb3a3;
    --accent-ink: #062320;
    --accent-soft: #123532;
    --good: #4ccb7a;
    --good-soft: #10301c;
    --warn: #f0b44c;
    --warn-soft: #36290f;
    --bad: #ff7b6e;
    --bad-soft: #3a1714;
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.6 -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, 'Segoe UI', Roboto, sans-serif;
  overflow-wrap: break-word;
}

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  margin: 1.6em 0 0.5em;
}

h1 {
  font-size: clamp(1.9rem, 4.5vw, 2.6rem);
  margin-top: 0.8em;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.15rem;
}

h4 {
  font-size: 1rem;
}

p,
ul,
ol {
  margin: 0 0 1em;
}

li + li {
  margin-top: 0.3em;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 max(20px, env(safe-area-inset-left)) 0 max(20px, env(safe-area-inset-right));
}

.muted {
  color: var(--muted);
}

.skip {
  position: absolute;
  left: -9999px;
}

/* Read out by screen readers, not shown (the visible letter is a decoration). */
.sr-letter {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip:focus {
  left: 12px;
  top: 12px;
  z-index: 10;
  background: var(--card);
  padding: 8px 14px;
  border-radius: 8px;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- header and footer */

.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 20px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  min-height: 48px;
}

.brand img {
  border-radius: 8px;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 18px;
}

.site-nav a:not(.btn) {
  color: var(--text);
  text-decoration: none;
  padding: 10px 0;
}

.site-nav a[aria-current='page'] {
  font-weight: 700;
  text-decoration: underline;
}

.site-footer {
  margin-top: 64px;
  padding: 28px 0 max(36px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--card);
  font-size: 0.9rem;
  color: var(--muted);
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin-bottom: 12px;
}

.footer-nav a {
  padding: 8px 0;
}

.ai-notice strong {
  color: var(--text);
}

/* ---------- buttons, callouts, cards */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 24px;
  border-radius: 12px;
  font-weight: 600;
  text-decoration: none;
  border: 2px solid var(--accent);
}

.btn.small {
  min-height: 44px;
  padding: 0 16px;
  font-size: 0.95rem;
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn.secondary {
  background: transparent;
  color: var(--accent);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 24px 0;
}

.hero .lead {
  font-size: 1.2rem;
  max-width: 44em;
}

.callout {
  background: var(--warn-soft);
  border-left: 5px solid var(--warn);
  border-radius: 10px;
  padding: 16px 20px;
  margin: 24px 0;
}

.callout p:last-child {
  margin-bottom: 0;
}

.features {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.features li,
.topic-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin: 0;
}

.features h3 {
  margin-top: 0;
}

.features p {
  margin: 0;
  color: var(--muted);
}

.topics {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.topics li {
  margin: 0;
}

.topic-card {
  display: block;
  height: 100%;
  color: var(--text);
  text-decoration: none;
}

.topic-card strong {
  display: block;
  color: var(--accent);
  font-size: 1.05rem;
  margin-bottom: 4px;
}

.topic-card span {
  color: var(--muted);
  font-size: 0.95rem;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0 40px;
}

/* ---------- prose pages from Markdown */

.prose {
  max-width: 44em;
}

.prose h2 {
  border-top: 1px solid var(--line);
  padding-top: 1em;
}

.prose blockquote {
  margin: 1.2em 0;
  background: var(--warn-soft);
  border-left: 5px solid var(--warn);
  border-radius: 10px;
  padding: 14px 18px;
}

.prose blockquote p:last-child {
  margin-bottom: 0;
}

/* ---------- worked questions on topic pages */

.breadcrumb {
  font-size: 0.95rem;
  margin: 20px 0 0;
}

.question {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin: 28px 0;
}

.question > h2 {
  margin-top: 0;
  font-size: 1.25rem;
}

.question .meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.stem p {
  margin-bottom: 0.7em;
}

.exhibit {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 12px 0 16px;
  background: var(--bg);
}

.exhibit h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.exhibit th,
.exhibit td {
  padding: 5px 8px;
  font-size: 0.95rem;
}

.exhibit th {
  width: 40%;
  font-weight: 600;
}

.exhibit tr:last-child th,
.exhibit tr:last-child td {
  border-bottom: 0;
}

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.table-scroll {
  overflow-x: auto;
}

.matrix tbody th {
  font-weight: normal;
}

.matrix td {
  text-align: center;
  color: var(--muted);
  width: 8.5em;
}

.matrix td .tag {
  margin: 0;
  border-radius: 8px;
  white-space: normal;
}

.options {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}

.options li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 8px 0;
}

.letter {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--line);
  font-weight: 700;
  font-size: 0.9rem;
}

.options li.is-correct {
  border-color: var(--good);
  background: var(--good-soft);
}

.options li.is-correct .letter {
  border-color: var(--good);
  color: var(--good);
}

.option-body {
  flex: 1;
  min-width: 0;
}

.rationale {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 4px 0 0;
}

.tag {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 10px;
  margin-left: 6px;
  vertical-align: 0.1em;
}

.tag.good {
  background: var(--good-soft);
  color: var(--good);
  border: 1px solid var(--good);
}

.tag.no {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--line);
}

.instruction {
  font-weight: 600;
}

.cloze {
  font-size: 1.05rem;
}

.cloze .gap {
  display: inline-block;
  min-width: 6em;
  border-bottom: 2px solid var(--muted);
  color: var(--muted);
  text-align: center;
}

.cloze .filled {
  font-weight: 700;
  color: var(--good);
  border-bottom: 2px solid var(--good);
}

.bowtie-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0 20px;
}

.bowtie-groups h3,
.bowtie-groups h4 {
  font-size: 1rem;
  margin: 12px 0 4px;
}

details.answer {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

details.answer > summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--accent);
  min-height: 48px;
  display: flex;
  align-items: center;
}

.answer-line {
  font-size: 1.05rem;
}

.working li,
.common-errors li {
  margin-top: 0.2em;
}

.references {
  font-size: 0.92rem;
  padding-left: 1.2em;
}

.question-footer {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
  color: var(--muted);
}

/* Reference cards: /reference/<id>/ */

.ref-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px 24px 20px;
  margin: 20px 0 28px;
}

.card-category {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.card-section h2 {
  font-size: 1.3rem;
  margin-top: 1.4em;
}

.ref-table {
  font-size: 0.95rem;
  margin: 8px 0 4px;
}

.ref-table caption {
  caption-side: top;
  text-align: left;
  color: var(--muted);
  font-size: 0.9rem;
  padding-bottom: 6px;
}

.ref-table thead th {
  border-bottom: 2px solid var(--line);
}

.ref-table tbody th {
  font-weight: 600;
  min-width: 6em;
}

.card-note {
  font-size: 0.95rem;
  color: var(--muted);
  border-left: 3px solid var(--line);
  padding-left: 12px;
}

.card-meta {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 20px;
}

@media (max-width: 600px) {
  body {
    font-size: 17px;
  }

  .question {
    padding: 16px;
  }

  .ref-card {
    padding: 4px 16px 16px;
  }

  .site-nav {
    gap: 0 14px;
  }
}
