/* Dia design set: tokens and components shared by the About page (landing.css) and the family app (app.css).
   Those two files hold layout only. A new colour, size or component goes here first. */
:root {
  /* light is the design; dark only when a page opts in with data-theme="dark", never from the OS setting */
  color-scheme: light;
  /* surfaces and ink */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #16191d;
  --muted: #646b75;
  --line: #e3e6ea;
  --accent: #2457c5;
  --accent-ink: #ffffff;
  /* glucose ranges, validated with dataviz validate_palette.js on #ffffff (light) and #1a1e24 (dark):
     CVD-safe red vs teal, high vs very high by lightness. Every use has a text label or table next to it. */
  --vlow: #a52a3c;
  --low: #e65b5b;
  --ok: #1a9a88;
  --high: #d9a019;
  --vhigh: #a94a0c;
  --ok-soft: #dff1ed;  /* band-soft: the target band and the strip in the logo */
  /* status messages */
  --warn-bg: #fff4e0;
  --warn: #8a5300;
  --done-bg: #e8f6ee;
  /* type: system fonts only, a public page must not send visitors' IPs to a font CDN */
  --display: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* shape */
  --r-s: 8px;
  --r-m: 12px;
  --r-l: 16px;
  --shadow: 0 12px 32px -20px rgba(22, 25, 29, .3);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111418; --surface: #1a1e24; --ink: #e7eaee; --muted: #9aa3ae; --line: #2a3038;
  --accent: #7da2ff; --accent-ink: #111418;
  --vlow: #b8336a; --low: #e2685a; --ok: #249fa6; --high: #ad8c2b; --vhigh: #a8501f; --ok-soft: #16302f;
  --warn-bg: #3a2c12; --warn: #ffcf80; --done-bg: #16302b;
  --shadow: 0 18px 40px -24px rgba(0, 0, 0, .7);
}

/* base */
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); }
a { color: var(--accent); }
a:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); text-wrap: balance; }
.muted { color: var(--muted); }
.eyebrow { font: 600 .78rem/1.2 var(--body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* card */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); }

/* buttons */
.button { display: inline-block; font: inherit; font-weight: 650; border: 1px solid transparent; border-radius: var(--r-m);
  padding: 10px 18px; background: var(--accent); color: var(--accent-ink); text-decoration: none; cursor: pointer; }
.button.ghost { background: transparent; color: var(--accent); border-color: var(--line); }
.button.danger { background: transparent; color: var(--low); border-color: var(--line); padding: 6px 12px; font-weight: 500; }
.button.link { background: none; border: 0; color: var(--accent); padding: 0; font-weight: 500; }

/* pill (statement) and chip (range of one value) */
.pill { display: inline-flex; gap: 8px; align-items: center; font: 600 .85rem/1.2 var(--body); padding: 8px 12px;
  border-radius: 999px; background: var(--ok-soft); color: var(--ink); width: max-content; max-width: 100%; }
.pill b { color: var(--ok); }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 600; padding: 3px 10px 3px 8px;
  border: 1px solid var(--line); border-radius: 999px; width: max-content; }
.chip i, i.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }

/* range swatches: the same five colours everywhere, always next to a label */
.b-vlow { fill: var(--vlow); background: var(--vlow); }
.b-low { fill: var(--low); background: var(--low); }
.b-ok { fill: var(--ok); background: var(--ok); }
.b-high { fill: var(--high); background: var(--high); }
.b-vhigh { fill: var(--vhigh); background: var(--vhigh); }
.legend { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .85rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }

/* KPI tile: label, big number, plain-language target */
.kpi { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 0; }
@media (min-width: 560px) { .kpi { grid-template-columns: repeat(4, 1fr); } }
.kpi > div { border: 1px solid var(--line); border-radius: var(--r-m); padding: 8px 10px; min-width: 0; }
.kpi dt { font-size: .8rem; color: var(--muted); }
.kpi dd { margin: 2px 0; font: 700 1.3rem/1.2 var(--body); font-variant-numeric: tabular-nums; }
.kpi .target { font-size: .75rem; color: var(--muted); }
.kpi .met { border-color: var(--muted); }
.kpi .met .target::before { content: "✓ "; color: var(--ink); font-weight: 700; }
.kpi .delta { display: block; font-size: .72rem; color: var(--muted); margin-top: 2px; }

/* messages */
.warn { background: var(--warn-bg); color: var(--warn); padding: 10px 14px; border-radius: var(--r-m); font-weight: 600; }
.ok { background: var(--done-bg); padding: 10px 14px; border-radius: var(--r-m); }

/* term: a word with a plain-language explanation one tap away (HTML popover, no script) */
button.term { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: help; text-align: inherit; }
button.term::after { content: "i"; display: inline-grid; place-items: center; width: 1.05em; height: 1.05em; margin-left: .3em;
  border: 1px solid var(--line); border-radius: 50%; font: 600 .62em/1 var(--body); color: var(--muted); vertical-align: .12em; }
button.term:hover::after, button.term:focus-visible::after { border-color: var(--accent); color: var(--accent); }
button.term.plain::after { content: none; }
.term-pop { max-width: min(24rem, calc(100vw - 32px)); padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r-l);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font: 1rem/1.5 var(--body); }
.term-pop::backdrop { background: rgba(15, 23, 27, .35); }
.term-pop .term-title { margin: 0 0 6px; font: 650 1.05rem/1.3 var(--body); }
.term-pop p { margin: 0 0 12px; }
.term-pop .button { padding: 6px 14px; }

/* glossary: every term on one list, same texts as the popovers */
.glossary summary { cursor: pointer; font-weight: 600; }
.glossary dl, .terms { display: grid; gap: 10px 32px; margin: 12px 0 0; }
.glossary dl > div, .terms > div { border-top: 1px solid var(--line); padding-top: 8px; }
.glossary dt, .terms dt { font-weight: 650; margin-bottom: 2px; }
.glossary dd, .terms dd { margin: 0; color: var(--muted); }
.terms { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px 32px; margin-top: 28px; }

@media print {
  :root { --bg: #fff; --surface: #fff; --ink: #000; --muted: #444; --line: #bbb; }
  .noprint, .term-pop { display: none !important; }
  button.term::after { content: none; }
}

/* identity: the wordmark (i's dot in the target band) and the app icon, inline SVG */
.brand svg { display: block; height: 24px; width: auto; }
.entry-mark svg { display: block; width: 56px; height: 56px; }
.printonly { display: none; }
@media print {
  .printonly { display: flex; }
  .brandline { align-items: center; gap: 12px; margin: 0 0 12pt; font-size: 10pt; }
  .brandline svg { height: 18px; width: auto; }
  .brandline .muted { margin-left: auto; }
}
