/* Epidemic simulation – styles. Colour tokens are read by epi.js too (keep names). */
:root {
  --c-accent: #1a6fae;
  --c-accent-ink: #ffffff;
  --c-bg: #f6f6f4;
  --c-panel: #ffffff;
  --c-border: #dcdcd8;
  --c-ink: #1f1f1f;
  --c-muted: #666660;
  --c-grid: #f6f6f4;
  --c-vaccinated: #a9cce9;
  --c-unvaccinated: #e3dfd6;
  --c-infected: #e8907c;   /* softened 2026-10-10 (was #d9482b) */
  --c-convalescent: #5fae86;
  --c-dead: #7a7a74;       /* softened 2026-10-10 (was #2b2b2b) */
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--c-accent); }
h1 { font-size: 1.35rem; margin: 0; font-weight: 650; }
h2 { font-size: 1.1rem; margin: 0 0 .4rem; }
p { margin: 0 0 .75rem; }
.small { font-size: .85rem; }
.muted { color: var(--c-muted); }
output { display: inline; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

.top { background: var(--c-panel); border-bottom: 1px solid var(--c-border); }
.top-inner { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding-top: .8rem; padding-bottom: .8rem; flex-wrap: wrap; }
.top nav a { margin-left: 1rem; text-decoration: none; font-size: .92rem; }
.top nav a:first-child { margin-left: 0; }
.top nav a:hover { text-decoration: underline; }

main { padding-top: 1rem; padding-bottom: 2rem; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
@media (min-width: 880px) {
  .layout { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
  /* .wide: the grid needs the full width; the controls panel becomes a row underneath */
  .layout.wide { grid-template-columns: minmax(0, 1fr); }
  .layout.wide .controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .3rem 1.6rem; align-items: start; }
  .layout.wide .controls details, .layout.wide .controls .presets, .layout.wide .controls .share { grid-column: 1 / -1; }
  .layout.wide .controls .actions { grid-column: span 2; align-self: center; }
  .layout.wide .presets { flex-direction: row; align-items: center; gap: .4rem 1.2rem; }
  .layout.wide .adv-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .layout.wide .presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: .5rem 1.4rem; }
  .layout.wide .presets > span { grid-column: 1 / -1; }
}

.stage, .controls, .stats, .about {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: .9rem;
}
.stats, .about { margin-top: 1rem; }

.stage-head { display: flex; justify-content: space-between; gap: .75rem; align-items: baseline; margin-bottom: .6rem; flex-wrap: wrap; }
.step { font-weight: 600; }
.hint { color: var(--c-muted); font-size: .9rem; }
/* The hint text changes as the run progresses; reserve its space so the grid (and the buttons under it on
   phones) never jump when a shorter message replaces a longer one. */
.stage-head { min-height: 1.6em; }
@media (max-width: 879px) {
  .stage-head { flex-wrap: nowrap; align-items: flex-start; }
  .hint { flex: 1 1 auto; min-height: 2.6em; line-height: 1.3; }
}

.canvas-box { width: 100%; background: var(--c-grid); border-radius: 4px; overflow: hidden; }
#grid { display: block; width: 100%; cursor: pointer; touch-action: manipulation; }

.legend { list-style: none; margin: .7rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; font-size: .88rem; color: var(--c-muted); }
.legend li { display: inline-flex; align-items: center; gap: .35rem; }
.legend img { width: 18px; height: 18px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; }
.sw-vaccinated { background: var(--c-vaccinated); }
.sw-unvaccinated { background: var(--c-unvaccinated); border: 1px solid #cfcbc2; }
.sw-infected { background: var(--c-infected); }
.sw-convalescent { background: var(--c-convalescent); }
.sw-dead { background: var(--c-dead); }

/* controls */
.field { margin-bottom: .9rem; }
.field label { display: block; font-size: .92rem; margin-bottom: .25rem; }
.field output { font-weight: 600; }
input[type=range] { width: 100%; margin: 0; accent-color: var(--c-accent); }

.buttons { display: flex; gap: .5rem; margin-bottom: .9rem; }
button {
  font: inherit; font-size: .92rem;
  padding: .45rem .9rem;
  border-radius: 6px;
  border: 1px solid var(--c-border);
  background: #fafaf8;
  color: var(--c-ink);
  cursor: pointer;
}
button:hover { border-color: #b9b9b4; }
button.primary { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-accent-ink); min-width: 5.5em; }
button.primary:hover { filter: brightness(1.08); }
button.small { padding: .2rem .55rem; font-size: .8rem; }
.buttons button { flex: 1 1 0; }
.buttons button { white-space: nowrap; }
.actions .buttons { margin-bottom: 0; }
.buttons.secondary { margin-top: .4rem; }
.buttons.secondary button { font-size: .85rem; padding: .3rem .5rem; color: var(--c-muted); background: transparent; }
.buttons.secondary button:hover { color: var(--c-ink); background: #fff; }

details { border-top: 1px solid var(--c-border); padding-top: .6rem; margin-top: .4rem; }
summary { cursor: pointer; font-weight: 600; font-size: .92rem; color: var(--c-accent); }
.adv-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: .55rem 1.6rem; margin: .7rem 0 .5rem; font-size: .85rem; }
.adv label { display: block; font-weight: 600; line-height: 1.3; }
.adv .help { display: block; font-weight: 400; color: var(--c-muted); font-size: .78rem; margin: .1rem 0 .25rem; }
.adv-in { display: flex; align-items: center; gap: .6rem; }
.adv-in input[type=range] { flex: 1 1 auto; min-width: 0; margin: 0; }
.adv-in input[type=number] { flex: 0 0 5.6em; }
.adv-grid input[type=number] {
  width: 100%; font: inherit; font-size: .9rem; padding: .25rem .35rem;
  border: 1px solid var(--c-border); border-radius: 5px; background: #fff; color: var(--c-ink);
}
.adv-grid input:focus, button:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 1px; }

.presets { border-top: 1px solid var(--c-border); margin-top: .8rem; padding-top: .7rem; display: flex; flex-direction: column; gap: .35rem; }
.preset { font-size: .92rem; }
.preset-row { display: flex; flex-direction: column; }
.presets .group { margin-top: .5rem; }
.presets .group:first-child { margin-top: 0; }
.pdesc { color: var(--c-muted); font-size: .78rem; line-height: 1.3; }
.explain { padding-left: 1.1rem; margin: 0 0 .9rem; font-size: .92rem; }
.explain li { margin: .25rem 0; }

.share { border-top: 1px solid var(--c-border); margin-top: .8rem; padding-top: .7rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .92rem; }

/* stats */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .85rem; font-variant-numeric: tabular-nums; }
th, td { padding: .35rem .45rem; text-align: center; white-space: nowrap; border-bottom: 1px solid var(--c-border); }
thead th { font-weight: 500; color: var(--c-muted); vertical-align: bottom; line-height: 1.2; }
thead img { width: 18px; height: 18px; display: inline-block; }
tbody th { text-align: left; font-weight: 600; }
tbody th img { width: 18px; height: 18px; vertical-align: middle; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; font-weight: 600; }
abbr[title] { text-decoration: underline dotted; text-underline-offset: 2px; cursor: help; }
.odds { margin: .7rem 0 0; color: var(--c-muted); }

.chart { margin: 1rem 0 0; }
.chart figcaption { display: flex; flex-wrap: wrap; gap: .3rem 1rem; align-items: baseline; font-size: .85rem; margin-bottom: .3rem; }
.chart figcaption > span:first-child { font-weight: 600; }
.chart-legend { display: inline-flex; gap: .8rem; color: var(--c-muted); }
.chart-legend .sw { margin-right: .3rem; }
#chart { display: block; width: 100%; height: 140px; }

.about { font-size: .95rem; }

@media (max-width: 480px) {
  .buttons { flex-wrap: wrap; }
  .buttons button { flex-basis: calc(50% - .25rem); }
  .buttons button.primary { flex-basis: 100%; }
  .top nav a { margin-left: .75rem; }
}
