/* General VA Practice Sandbox
   Layout: one working column. Header, tabs, then one screen at a time.
   Every grid is auto-fit and every row wraps, so the base styles are the 320px layout.
   Sections: 1 tokens, 2 base, 3 layout, 4 controls, 5 components, 6 print. */

/* 1. Tokens */
:root {
  --bg: #f6f3ec;
  --surface: #fffdf8;
  --ink: #1d2420;
  --muted: #56615a;
  --line: #d9d4c7;
  --control: #7c867f;
  --accent: #1f5c45;
  --accent-ink: #ffffff;
  --accent-soft: #dcebe2;
  --good: #1c6b3f;
  --good-soft: #dff1e5;
  --warn: #7d5200;
  --warn-soft: #f8ecd0;
  --bad: #a3322b;
  --bad-soft: #f9e2df;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --fs-body: clamp(0.94rem, 0.88rem + 0.25vw, 1.02rem);
  --fs-small: clamp(0.82rem, 0.78rem + 0.15vw, 0.88rem);
  --fs-h1: clamp(1.4rem, 1.1rem + 1.3vw, 2.1rem);
  --fs-h2: clamp(1.1rem, 1rem + 0.5vw, 1.35rem);
  --fs-num: clamp(1.6rem, 1.2rem + 1.6vw, 2.4rem);
  --gap: clamp(0.8rem, 0.5rem + 1vw, 1.3rem);
  --gap-tight: clamp(0.45rem, 0.35rem + 0.5vw, 0.75rem);
  --pad: clamp(0.9rem, 0.6rem + 1.1vw, 1.4rem);
  --radius: 10px;
  --radius-small: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121714;
    --surface: #1a211d;
    --ink: #e6ebe6;
    --muted: #a3aea7;
    --line: #2f3b34;
    --control: #7d8a82;
    --accent: #7fcaa5;
    --accent-ink: #0c1f16;
    --accent-soft: #1d3329;
    --good: #74cf9b;
    --good-soft: #173323;
    --warn: #e3b964;
    --warn-soft: #3a2e14;
    --bad: #f0938a;
    --bad-soft: #40201d;
    color-scheme: dark;
  }
}

/* 2. Base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.55;
  overflow-wrap: anywhere;
}
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
h1 { font-family: var(--font-display); font-size: var(--fs-h1); font-weight: 600; line-height: 1.15; text-wrap: balance; }
h2 { font-family: var(--font-display); font-size: var(--fs-h2); font-weight: 600; line-height: 1.25; }
h3 { font-size: var(--fs-body); font-weight: 650; }
ul, ol { padding-left: 1.2rem; }
img, svg { max-width: 100%; height: auto; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.small { font-size: var(--fs-small); color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#screen:focus { outline: none; }
.kicker { font-size: var(--fs-small); font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }

/* 3. Layout */
.app {
  width: min(100%, 78rem);
  margin-inline: auto;
  padding-block: var(--pad);
  padding-left: max(1rem, env(safe-area-inset-left, 0px));
  padding-right: max(1rem, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
.row { display: flex; flex-wrap: wrap; gap: var(--gap-tight); align-items: center; }
.row > * { min-width: 0; }
.row-end { align-items: flex-end; }
.spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: var(--gap-tight); min-width: 0; }
.stack-wide { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.head { display: flex; flex-wrap: wrap; gap: var(--gap); justify-content: space-between; align-items: flex-end; }
.head-title { flex: 1 1 16rem; }
.controls { display: flex; flex-wrap: wrap; gap: var(--gap); align-items: flex-end; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: var(--gap); align-items: start; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
}
.rule { border: 0; border-top: 1px solid var(--line); margin: 0; width: 100%; }

/* 4. Controls */
.field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; flex: 1 1 11rem; }
.panel > .field, .item > .field { flex: 0 0 auto; }
.field label, .label { font-size: var(--fs-small); color: var(--muted); font-weight: 550; }
select, input[type="text"], textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--control);
  border-radius: var(--radius-small);
  padding: 0.55rem 0.7rem;
  min-height: 44px;
  width: 100%;
  max-width: 100%;
}
textarea { min-height: 7rem; resize: vertical; }
select:disabled, input:disabled, textarea:disabled { opacity: 0.75; }
button, select, input, textarea, .tick { touch-action: manipulation; }
button { font: inherit; cursor: pointer; }
.btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-small);
  border: 1px solid var(--control);
  background: var(--surface);
  color: var(--ink);
  font-weight: 550;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tick { display: flex; gap: 0.6rem; align-items: center; min-height: 44px; }
.tick input { width: 1.25rem; height: 1.25rem; flex: 0 0 auto; accent-color: var(--accent); }
.tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tab {
  min-height: 44px;
  min-width: 44px;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--control);
  background: transparent;
  color: var(--ink);
  font-weight: 550;
}
.tab:hover { border-color: var(--accent); }
.tab[aria-current="page"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tab .tab-state { font-size: var(--fs-small); font-weight: 500; opacity: 0.8; }

/* 5. Components */
.clock { display: flex; flex-direction: column; }
.clock b { font-family: var(--font-display); font-size: var(--fs-h2); font-weight: 600; line-height: 1.2; }
.notice { background: var(--accent-soft); border-radius: var(--radius); padding: 0.7rem var(--pad); }
.notice-warn { background: var(--warn-soft); }
.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-small); overflow: hidden; }
.item {
  display: flex;
  flex-direction: column;
  gap: var(--gap-tight);
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  min-width: 0;
}
.item:last-child { border-bottom: 0; }
.item-head > * { min-width: 0; }
.item-head { display: flex; flex-wrap: wrap; gap: 0.3rem 0.8rem; justify-content: space-between; align-items: baseline; }
.quote { background: var(--bg); border-radius: var(--radius-small); padding: 0.55rem 0.75rem; }
.pill {
  display: inline-block;
  font-size: var(--fs-small);
  font-weight: 650;
  padding: 0.12rem 0.6rem;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--line);
}
.pill-good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.pill-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill-bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: 0.6rem 1rem; }
.facts div { min-width: 0; }
.facts dt { font-size: var(--fs-small); color: var(--muted); }
.facts dd { font-weight: 550; }
.days { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr)); gap: var(--gap-tight); }
.slot { padding: 0.45rem 0.65rem; border: 1px solid var(--line); border-radius: var(--radius-small); background: var(--bg); }
.checks { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.check { display: flex; flex-wrap: wrap; gap: 0.3rem 0.7rem; align-items: baseline; }
.check-text { flex: 1 1 14rem; min-width: 0; }
.score { font-family: var(--font-display); font-size: var(--fs-num); font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.bar { width: 100%; height: 0.6rem; accent-color: var(--accent); }
.result-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); gap: 0.3rem 1rem; align-items: center; padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--line); }
.result-row:last-child { border-bottom: 0; }
.empty { color: var(--muted); }

/* 6. Print: the result page only */
@media print {
  /* Paper is white: use the light colours even when the device is in dark mode. */
  :root {
    --bg: #ffffff; --surface: #ffffff; --ink: #000000; --muted: #444444; --line: #999999; --control: #777777;
    --accent: #1f5c45; --accent-ink: #ffffff; --accent-soft: #dcebe2;
    --good: #1c6b3f; --good-soft: #dff1e5; --warn: #7d5200; --warn-soft: #f8ecd0; --bad: #a3322b; --bad-soft: #f9e2df;
    color-scheme: light;
  }
  .tabs, .controls, .no-print { display: none; }
  .panel { break-inside: avoid; }
}
