/* WhichAE — mobile first. Designed for people who feel unwell, are stressed, or have
   poor eyesight: big text, big buttons, one main action per screen, strong contrast. */
:root {
  --bg: #ffffff;
  --surface: #f3f5f4;
  --text: #111a17;
  --muted: #3f4b47;
  --line: #c9d1ce;
  --brand: #0a5c55;        /* deep teal — deliberately not NHS blue */
  --brand-ink: #ffffff;
  --brand-soft: #e1efed;
  --danger: #b3261e;
  --danger-ink: #ffffff;
  --good: #1d6b2f;  --good-bg: #e3f2e6;
  --warn: #7a4b00;  --warn-bg: #fdf0d5;
  --bad: #9a1c14;   --bad-bg: #fbe3e1;
  --focus: #ffbf47;
  --radius: 14px;
  --tap: 64px;
  font-size: 19px;
  color-scheme: light dark;
}
:root[data-size="large"] { font-size: 23px; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1513; --surface: #18211e; --text: #f1f5f3; --muted: #b9c4c0; --line: #33413c;
    --brand: #4fc2b6; --brand-ink: #062a26; --brand-soft: #173430;
    --danger: #ff6b5f; --danger-ink: #2a0402;
    --good: #8fe0a0; --good-bg: #16301d; --warn: #ffd27a; --warn-bg: #352710; --bad: #ff9c94; --bad-bg: #3a1714;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.5;
}
a { color: var(--brand); text-underline-offset: 3px; }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 2px; }
/* Headings get focus on each new check-in screen (for screen readers) — no visible ring needed. */
h1[tabindex="-1"]:focus { outline: none; }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px; }

/* Emergency strip — always first on the page */
.emergency { background: var(--danger); color: var(--danger-ink); font-weight: 600; }
.emergency .wrap { display: flex; flex-wrap: wrap; justify-content: center; text-align: center; gap: 4px 16px; padding-top: 10px; padding-bottom: 10px; font-size: .9rem; }
.hero { text-align: center; }
.emergency a { color: inherit; font-weight: 800; }

header.top { border-bottom: 1px solid var(--line); }
header.top .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 60px; gap: 12px; }
.logo { font-size: 1.35rem; font-weight: 800; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.logo span { color: var(--brand); }
.textsize { min-height: 48px; padding: 0 14px; border: 2px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--text); font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; }

main { padding: 20px 0 48px; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 8px; letter-spacing: -.015em; }
h2 { font-size: 1.25rem; line-height: 1.3; margin: 0 0 8px; }
p { margin: 0 0 12px; }
.lead { font-size: 1.05rem; color: var(--muted); }
.small { font-size: .85rem; color: var(--muted); }

/* Buttons: full width, huge tap targets */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  min-height: var(--tap); padding: 14px 20px; margin: 0 0 12px;
  border: 3px solid transparent; border-radius: var(--radius);
  font: inherit; font-size: 1.1rem; font-weight: 700; text-align: center; text-decoration: none;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-secondary { background: var(--bg); color: var(--brand); border-color: var(--brand); }
.btn-plain { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-danger { background: var(--danger); color: var(--danger-ink); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn .sub { display: block; font-size: .8rem; font-weight: 500; opacity: .9; }
.btn-col { flex-direction: column; gap: 2px; }
.btn-left { justify-content: flex-start; text-align: left; }
.linkbtn { background: none; border: 0; padding: 12px 0; min-height: 48px; color: var(--brand); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 0 0 16px; }
.card h2 { font-size: 1.1rem; }
.callout { border-left: 6px solid var(--brand); background: var(--brand-soft); border-radius: 8px; padding: 14px 16px; margin: 0 0 16px; }

/* Checked-in banner on every page */
.active-banner { background: var(--brand); color: var(--brand-ink); }
.active-banner .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; padding-bottom: 12px; }
.active-banner a { color: inherit; font-weight: 800; white-space: nowrap; min-height: 48px; display: inline-flex; align-items: center; }

/* Hospital list */
.sortbar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 16px; }
.sortbar button { min-height: 56px; border-radius: var(--radius); border: 2px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: .95rem; font-weight: 700; cursor: pointer; }
.sortbar button[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--text); }
.search { width: 100%; min-height: 60px; padding: 0 16px; border: 2px solid var(--line); border-radius: var(--radius); font: inherit; background: var(--bg); color: var(--text); margin: 0 0 12px; }
.search::placeholder { color: var(--muted); }

.list { list-style: none; margin: 0; padding: 0; }
.h-card { display: block; text-decoration: none; color: var(--text); background: var(--bg); border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 12px; }
.h-card:active { border-color: var(--brand); }
.h-name { font-size: 1.15rem; font-weight: 800; line-height: 1.25; display: flex; justify-content: space-between; gap: 8px; }
.h-name .chev { color: var(--brand); font-size: 1.4rem; line-height: 1; }
.h-meta { display: block; color: var(--muted); font-size: .9rem; margin: 2px 0 10px; }
.h-month { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.h-live { display: block; font-size: .9rem; margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--line); }

.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: .85rem; font-weight: 700; }
.b-good { color: var(--good); background: var(--good-bg); }
.b-warn { color: var(--warn); background: var(--warn-bg); }
.b-bad { color: var(--bad); background: var(--bad-bg); }
.b-none { color: var(--muted); background: var(--surface); }

.stat { font-size: 2.2rem; font-weight: 800; line-height: 1.1; margin: 4px 0; }
.stat small { font-size: 1rem; font-weight: 600; color: var(--muted); }

/* Check-in flow */
.step-count { font-size: .9rem; font-weight: 700; color: var(--muted); margin: 0 0 6px; text-transform: uppercase; letter-spacing: .04em; }
.timer { text-align: center; padding: 22px 12px; margin: 0 0 18px; background: var(--brand-soft); border-radius: var(--radius); }
.timer .label { font-weight: 700; color: var(--muted); }
.timer .big { font-size: 2.6rem; font-weight: 800; line-height: 1.1; margin: 6px 0; }
.timer-compact { padding: 14px 12px; }
.timer-compact .big { display: block; font-size: 2rem; margin: 2px 0; }
.timer-compact .label, .timer-compact .small { display: block; }
.progress { list-style: none; padding: 0; margin: 0 0 18px; }
.progress li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-weight: 600; }
.progress li .dot { width: 32px; height: 32px; flex: none; border-radius: 50%; border: 3px solid var(--line); display: grid; place-items: center; font-size: .9rem; }
.progress li.done .dot { background: var(--good); border-color: var(--good); color: var(--bg); }
.progress li.done { color: var(--text); }
.progress li:not(.done) { color: var(--muted); }

.toast { position: fixed; left: 12px; right: 12px; bottom: 16px; max-width: 616px; margin: 0 auto; background: var(--text); color: var(--bg); border-radius: var(--radius); padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 10; }
.toast button { min-height: 48px; padding: 0 16px; border-radius: 10px; border: 2px solid var(--bg); background: transparent; color: var(--bg); font: inherit; font-weight: 800; cursor: pointer; }
.offline { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 10px 14px; font-weight: 600; margin: 0 0 14px; }

footer { border-top: 1px solid var(--line); padding: 24px 0 40px; font-size: .85rem; color: var(--muted); }
footer a { color: var(--muted); }
footer nav { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0 0 12px; }
footer nav a { min-height: 44px; display: inline-flex; align-items: center; }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (min-width: 700px) { h1 { font-size: 2.1rem; } }
