/* Colours and sizes follow course/style-guide.md. Check contrast before changing a colour. */
:root {
  --bg: #FAF7F2; --ink: #1F2328; --muted: #57534E; --accent: #9A4A00;
  --focus: #1D4ED8; --card: #FFFFFF; --line: #DDD5CA; --error: #B42318;
  --s1: 8px; --s2: 16px; --s3: 24px; --s6: 48px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1A1714; --ink: #F2EEE8; --muted: #B8B0A6; --accent: #F0A35E;
    --focus: #8AB4FF; --card: #252019; --line: #463E35; --error: #FF8A80;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1A1714; --ink: #F2EEE8; --muted: #B8B0A6; --accent: #F0A35E;
  --focus: #8AB4FF; --card: #252019; --line: #463E35; --error: #FF8A80;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 18px/1.5 "Atkinson Hyperlegible", system-ui, sans-serif;
}
.wrap { max-width: 46rem; margin: 0 auto; padding: 0 var(--s2); }
h1 { font-size: 2rem; line-height: 1.2; margin: var(--s6) 0 var(--s2); }
h2 { font-size: 1.35rem; line-height: 1.3; margin: var(--s6) 0 var(--s1); }
.card h2, .story h2 { margin-top: 0; }
p { margin: 0 0 var(--s2); max-width: 65ch; }
.lede { font-size: 1.15rem; }
a { color: var(--accent); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
main:focus, h1[tabindex="-1"]:focus { outline: none; }
.skip { position: absolute; left: -999px; top: var(--s1); background: var(--card); color: var(--ink); padding: var(--s1) var(--s2); }
.skip:focus { left: var(--s2); }

header.site { border-bottom: 1px solid var(--line); }
header.site .wrap { display: flex; justify-content: space-between; align-items: center; min-height: 64px; }
.brand { font-weight: 700; margin: 0; }
.where { margin: 0; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: var(--s3); margin: var(--s3) 0; }
.story { display: flex; gap: var(--s3); align-items: flex-start; }
.portrait { width: 64px; height: 64px; flex: none; color: var(--accent); }

label { display: block; font-weight: 700; margin-bottom: var(--s1); }
input {
  width: 100%; min-height: 48px; font: inherit; color: var(--ink); background: var(--bg);
  border: 2px solid var(--muted); border-radius: 8px; padding: var(--s1) 12px; margin-bottom: var(--s2);
}
#code { max-width: 12rem; letter-spacing: .2em; font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; min-width: 44px;
  font: inherit; font-weight: 700; border-radius: 8px; padding: 10px var(--s3); cursor: pointer;
  border: 2px solid var(--accent);
}
.btn.primary { background: var(--accent); color: var(--bg); }
.btn.link { background: none; border: none; color: var(--accent); text-decoration: underline; padding: 10px 0; display: flex; }
.btn[disabled] { opacity: .65; cursor: progress; }

.error { color: var(--error); font-weight: 700; }
.error::before { content: "⚠ "; }
.status:empty { display: none; }
.status { background: var(--card); border-left: 6px solid var(--accent); padding: var(--s2); margin-top: var(--s3); }
.hint, .note, .session, .site-foot { color: var(--muted); }
.site-foot { margin-top: var(--s6); padding-bottom: var(--s6); border-top: 1px solid var(--line); padding-top: var(--s3); font-size: 1rem; }

.experiments { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
@media (max-width: 640px) { .experiments { grid-template-columns: 1fr; } .story { flex-direction: column; } }
.experiment { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: var(--s3); display: flex; flex-direction: column; }
.ask { font-style: italic; color: var(--muted); flex: 1; }
.experiment .btn { width: 100%; }

.result { margin-top: var(--s3); border-top: 1px solid var(--line); padding-top: var(--s2); }
.money { font-size: 2rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; margin: 0; }
.money-sub { margin: 0 0 var(--s2); }
.facts { list-style: none; padding: 0; margin: 0 0 var(--s2); }
.facts li { padding: 4px 0; border-bottom: 1px dashed var(--line); font-variant-numeric: tabular-nums; }
details summary { cursor: pointer; color: var(--accent); font-weight: 700; min-height: 44px; display: flex; align-items: center; }
details blockquote { margin: var(--s1) 0 0; padding-left: var(--s2); border-left: 4px solid var(--line); white-space: pre-wrap; }

.compare .big { font-size: 1.5rem; font-weight: 700; }
.compare li { margin-bottom: var(--s1); }
.terms { margin: 0; }
.terms dt { font-weight: 700; font-size: 1.15rem; margin-top: var(--s2); }
.terms dd { margin: 0; }
.terms .eg { display: block; color: var(--muted); }
.question { border-left: 6px solid var(--accent); padding-left: var(--s2); }
.stamp { font-weight: 700; font-size: 1.15rem; margin-top: var(--s2); }
.stamp span { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--bg); margin-right: var(--s1); }

@media (prefers-reduced-motion: no-preference) {
  .result:not([hidden]), .compare:not([hidden]) { animation: rise .25s ease-out; }
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}
