/* Shared base, loaded before each site's /site.css.
 * Look: every rule is inside :where(), so it has zero specificity and any site rule wins.
 * Widget visibility (bottom) has normal specificity: it hides the parts that do not apply to the
 * widget's data-state. Style the parts freely, but do not force them visible in other states. */
:where(:root) {
  --bg: #ffffff;
  --ink: #1f2328;
  --muted: #59636e;
  --accent: #3d5a80;
  --accent-ink: #ffffff;
  --surface: #f4f5f7;
  --line: #d0d7de;
  --radius: 10px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}
:where(*, *::before, *::after) { box-sizing: border-box; }
:where(body) { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
:where(a) { color: var(--accent); }
:where(:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
:where(.skip-link) { position: absolute; left: -9999px; }
:where(.skip-link:focus) { left: 8px; top: 8px; background: var(--bg); padding: 8px; z-index: 10; }

:where(.site-header, .site-main, .site-footer) { width: 100%; max-width: 760px; margin: 0 auto; padding: 16px; }
:where(.site-main) { flex: 1; }
:where(.site-brand) { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.25rem; }
:where(.site-tagline) { margin: 4px 0 0; color: var(--muted); }
:where(.site-footer) { color: var(--muted); font-size: 0.85rem; }

:where(.widget) { background: var(--surface); border-radius: var(--radius); padding: 20px; text-align: center; margin: 16px 0; }
:where(.widget-qrbox svg) { width: min(280px, 70vw); height: auto; display: block; margin: 8px auto 16px; }
:where(.widget-hint, .widget-msg) { color: var(--muted); }
:where(.widget-result) { text-align: left; }
:where(.widget-detail) { display: block; font-size: 0.8em; opacity: 0.8; } /* dev only: the technical reason */
:where(.widget-link, .widget-again, .btn) {
  display: inline-block; border: 0; border-radius: 999px; padding: 12px 22px; font: inherit; font-weight: 600;
  background: var(--accent); color: var(--accent-ink); text-decoration: none; cursor: pointer;
}

:where(.site-grid, .report-list, .test-list) { list-style: none; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
:where(.site-card a, .report-card, .test-item a) {
  display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 14px; border-radius: var(--radius);
  background: var(--surface); color: var(--ink); text-decoration: none;
}
:where(.site-card span, .report-card-tagline, .test-genes) { color: var(--muted); font-size: 0.9rem; }

:where(.cr-table) { border-collapse: collapse; width: 100%; }
:where(.cr-table th, .cr-table td) { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
:where(.cr-notice) { border: 1px solid var(--line); padding: 8px 12px; border-radius: var(--radius); }

@media print {
  :where(.skip-link, .widget-qr, .widget-msg, .widget-again, .site-footer a) { display: none; }
  :where(.widget) { background: none; padding: 0; }
}

/* Widget visibility by state (driven by /app.js). */
.widget:not([data-state='waiting']) .widget-qr,
.widget:not([data-state='ready']) .widget-result,
.widget:is([data-state='idle'], [data-state='starting'], [data-state='waiting'], [data-state='granted'], [data-state='working']) .widget-again,
.widget:not([data-state='starting']) .widget-msg[data-for='starting'],
.widget:not([data-state='waiting']) .widget-msg[data-for='waiting'],
.widget:not([data-state='granted']) .widget-msg[data-for='granted'],
.widget:not([data-state='working']) .widget-msg[data-for='working'],
.widget:not([data-state='declined']) .widget-msg[data-for='declined'],
.widget:not([data-state='expired']) .widget-msg[data-for='expired'],
.widget:not([data-state='error']) .widget-msg[data-for='error'],
[hidden] { display: none; }
