/* Where They Care — shared stylesheet.
 *
 * Previously this lived inline in every template, which put ~6.6 KB on each of
 * 14,693 facility pages and ~2.8 KB on each of 8,844 ZIP pages — about 122 MB
 * of the 445 MB build, none of it cacheable across pages.
 *
 * Served from a content-hashed filename, so it can be cached immutably and
 * still change the instant its contents do.
 *
 * Page-specific rules are scoped by the body class set in base.html
 * (`facility`, `zip`, `ziplist`, `prose`). Where the two original templates
 * disagreed on a value — .wrap width, .card padding, cell padding — both are
 * preserved under their own scope rather than one silently winning.
 */

/* ---- tokens ------------------------------------------------------------ */
:root{
  color-scheme: light;
  /* --surface / --ink2 are aliases: the ZIP templates used those names and
     there is no benefit to churning their markup to match. */
  --surface-1:#fcfcfb; --surface:#fcfcfb;
  --plane:#f9f9f7;
  --ink:#0b0b0b;
  --ink-2:#52514e; --ink2:#52514e;
  /* WCAG AA. Was #898781 (3.50:1) — too faint for the source notes, state
     averages and methodology text it carries. Dark theme overrides it below,
     because the two themes pull in opposite directions. */
  --muted:#6f6e69;
  /* Unfilled stars need their own token: --grid is a border colour at 1.29:1,
     which made a 1-star and a 4-star rating near-identical to a low-vision
     reader. */
  --star-off:#84837a;
  --grid:#e1e0d9; --rule:#c3c2b7; --border:rgba(11,11,11,.10);
  --weekday:#2a78d6; --weekend:#5598e7;
  /* --warning was #fab219 (1.79:1) and --serious #ec835a (2.57:1); both fell
     below the 3:1 required of graphics, on the icons that carry the safety
     meaning. These values clear 3:1 in BOTH themes, so no override is needed. */
  --good:#0ca30c; --warning:#b07800; --serious:#d15f2e; --critical:#d03b3b;
  --radius:10px;
  --sans:system-ui,-apple-system,"Segoe UI",sans-serif;
}
@media (prefers-color-scheme: dark){
  :root:where(:not([data-theme="light"])){
    color-scheme: dark;
    --surface-1:#1a1a19; --surface:#1a1a19;
    --plane:#0d0d0d;
    --ink:#fff;
    --ink-2:#c3c2b7; --ink2:#c3c2b7;
    --muted:#898781;              /* 4.85:1 on the dark surface */
    --star-off:#6d6c64;
    --grid:#2c2c2a; --rule:#383835; --border:rgba(255,255,255,.10);
    --weekday:#3987e5; --weekend:#6da7ec;
  }
}
:root[data-theme="dark"]{
  color-scheme: dark;
  --surface-1:#1a1a19; --surface:#1a1a19;
  --plane:#0d0d0d;
  --ink:#fff;
  --ink-2:#c3c2b7; --ink2:#c3c2b7;
  --muted:#898781; --star-off:#6d6c64;
  --grid:#2c2c2a; --rule:#383835; --border:rgba(255,255,255,.10);
  --weekday:#3987e5; --weekend:#6da7ec;
}

/* ---- chrome ------------------------------------------------------------ */
*{box-sizing:border-box}
body{margin:0;background:var(--plane);color:var(--ink);font-family:var(--sans);
     line-height:1.6;-webkit-font-smoothing:antialiased}
.wrap{max-width:900px;margin:0 auto;padding:0 20px}
body.facility .wrap{max-width:820px}
body.prose .wrap{max-width:720px}
a{color:inherit}
main{display:block;padding-bottom:10px}

header.site{border-bottom:1px solid var(--border);background:var(--surface-1)}
header.site .wrap{display:flex;align-items:center;justify-content:space-between;
     padding-top:14px;padding-bottom:14px}
.brand{font-weight:650;letter-spacing:-.01em;text-decoration:none;font-size:1.05rem}
.brand span{color:var(--muted);font-weight:400}

.crumbs{font-size:.85rem;color:var(--ink-2);padding:14px 0 0}
.crumbs a{color:var(--ink-2)}

h1{font-size:1.9rem;line-height:1.25;letter-spacing:-.02em;margin:.3em 0 .15em}
h2{font-size:1.22rem;letter-spacing:-.01em;margin:2.4rem 0 .2rem}
h3{font-size:1rem;margin:1.5rem 0 .35rem}
body.zip h2{margin:2.2rem 0 .3rem}
body.ziplist h1{margin:.4rem 0 .2rem}
body.ziplist h2{font-size:1.1rem;margin:2rem 0 .5rem}

.sub{color:var(--ink-2);margin:0 0 1.4rem;font-size:1.02rem}
body.zip .sub,body.ziplist .sub{margin:0 0 1.25rem;font-size:1rem}
body.ziplist .sub{color:var(--muted)}
.lede{font-size:1.06rem}
section{margin-bottom:.5rem}

.card{background:var(--surface-1);border:1px solid var(--border);
      border-radius:var(--radius);margin:1rem 0;padding:20px 22px}
body.zip .card{padding:12px 18px;overflow-x:auto}

footer.site{border-top:1px solid var(--border);margin-top:3rem;padding:26px 0 50px;
            font-size:.84rem;color:var(--muted);background:var(--surface-1)}
footer.site a{color:var(--ink-2)}

/* ---- takeaway ---------------------------------------------------------- */
.takeaway{border-left:3px solid var(--rule);padding-left:18px;margin:1.4rem 0}
.takeaway p{margin:.5rem 0}

/* ---- KPI row of stat tiles --------------------------------------------- */
.kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px;margin:1.2rem 0}
.tile{background:var(--surface-1);border:1px solid var(--border);
      border-radius:var(--radius);padding:14px 16px}
/* Two lines' worth of room whether or not the label needs it, so the values
   stay on one baseline across the row. "All nursing staff, hours / resident"
   wraps where the other three labels don't, and without this its value sat a
   line lower than its neighbours. The label cannot be shortened back — see the
   QC P1-7 note in facility.html. */
.tile .label{font-size:.76rem;color:var(--ink-2);letter-spacing:.02em;
  margin-bottom:5px;min-height:2.4em}
.tile .value{font-size:1.62rem;font-weight:620;letter-spacing:-.02em;line-height:1.15}
.tile .note{font-size:.78rem;color:var(--muted);margin-top:3px}

/* ---- stars ------------------------------------------------------------- */
.stars{font-size:1.05rem;letter-spacing:.06em;color:var(--ink)}
.stars .off{color:var(--star-off)}

/* ---- staffing bars: one hue, two ordinal steps, direct-labelled -------- */
.bars{margin:.9rem 0 .4rem}
.barrow{display:grid;grid-template-columns:92px 1fr;align-items:center;
        gap:12px;margin-bottom:10px}
.barrow .k{font-size:.83rem;color:var(--ink-2)}
.track{display:flex;align-items:center;gap:9px}
.bar{height:22px;border-radius:0 4px 4px 0;flex:none}
.v{font-size:.79rem;font-weight:600;color:var(--ink);
   font-variant-numeric:tabular-nums;white-space:nowrap}
.v.ref{font-weight:500;color:var(--muted)}
.bar.wd{background:var(--weekday)}
.bar.we{background:var(--weekend)}
.bar.ref{background:var(--rule)}
.axisnote{font-size:.76rem;color:var(--muted);margin-top:.1rem}

/* ---- callout flags: icon + label + fact, never colour alone ------------ */
.flags{display:grid;gap:8px;margin:1.2rem 0}
.flag{display:grid;grid-template-columns:20px 1fr;gap:11px;align-items:start;
      background:var(--surface-1);border:1px solid var(--border);
      border-left:3px solid var(--rule);border-radius:var(--radius);
      padding:12px 15px}
.flag svg{width:18px;height:18px;margin-top:2px}
.flag .fl{font-weight:600;font-size:.93rem;line-height:1.35}
.flag .fd{font-size:.84rem;color:var(--ink-2);margin-top:2px}
.flag.critical{border-left-color:var(--critical)} .flag.critical svg{color:var(--critical)}
.flag.serious{border-left-color:var(--serious)}   .flag.serious svg{color:var(--serious)}
.flag.warning{border-left-color:var(--warning)}   .flag.warning svg{color:var(--warning)}
.flag.good{border-left-color:var(--good)}         .flag.good svg{color:var(--good)}
.flagnote{font-size:.79rem;color:var(--muted);margin:.1rem 0 0}

/* ---- status chips: icon + label, never colour alone -------------------- */
.chip{display:inline-flex;align-items:center;gap:6px;font-size:.8rem;
      font-weight:560;padding:3px 10px 3px 8px;border-radius:999px;
      border:1px solid var(--border);background:var(--surface-1);color:var(--ink)}
.chip .dot{width:9px;height:9px;border-radius:50%;flex:none}
.chip.good .dot{background:var(--good)}
.chip.warning .dot{background:var(--warning)}
.chip.serious .dot{background:var(--serious)}
.chip.critical .dot{background:var(--critical)}

/* ---- tables ------------------------------------------------------------ */
table{width:100%;border-collapse:collapse;font-size:.9rem;margin:.7rem 0}
th{text-align:left;font-weight:600;font-size:.78rem;color:var(--ink-2);
   border-bottom:1px solid var(--rule);padding:7px 10px 7px 0;white-space:nowrap}
td{padding:9px 10px 9px 0;border-bottom:1px solid var(--grid);vertical-align:top}
td.num,th.num{text-align:right;font-variant-numeric:tabular-nums;padding-right:0}
tr:last-child td{border-bottom:none}
body.zip th{padding:8px 12px 8px 0}
body.zip td{padding:10px 12px 10px 0}
.facname{font-weight:560;text-decoration:none}
body.zip .facname{font-weight:600}
.facname:hover{text-decoration:underline}

/* ---- questions list ---------------------------------------------------- */
ol.ask{padding-left:1.1rem;margin:.6rem 0}
ol.ask li{margin-bottom:.55rem;padding-left:.2rem}

/* ---- meta / sources ---------------------------------------------------- */
.meta{font-size:.82rem;color:var(--muted)}
.meta dl{display:grid;grid-template-columns:auto 1fr;gap:2px 14px;margin:.5rem 0}
.meta dt{color:var(--ink-2)}
.meta dd{margin:0;font-variant-numeric:tabular-nums}

/* ---- ZIP pages --------------------------------------------------------- */
.callout{background:var(--surface-1);border:1px solid var(--border);
  border-left:3px solid var(--rule);border-radius:var(--radius);
  padding:14px 17px;margin:1.2rem 0}
.callout p{margin:.25rem 0}
.ziplinks{display:flex;flex-wrap:wrap;gap:8px;margin:1rem 0}
.ziplinks a{background:var(--surface-1);border:1px solid var(--border);border-radius:999px;
  padding:5px 11px;text-decoration:none;font-variant-numeric:tabular-nums}
.ziplinks a:hover{text-decoration:underline}

/* ---- ZIP directory ----------------------------------------------------- */
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(76px,1fr));gap:7px}
.grid a{background:var(--surface-1);border:1px solid var(--border);border-radius:7px;
  padding:6px 8px;text-align:center;text-decoration:none;font-variant-numeric:tabular-nums}
.grid a:hover{text-decoration:underline}

/* ---- home, state and city index pages ---------------------------------- */
/* The state list on / and the city list on a state page are the crawl spine,
   so they are plain anchors in a plain list. Multi-column via CSS columns
   rather than a grid: a grid would reorder them across the reading axis, and
   these lists are alphabetical for a reason. */
.statelist,.placelist{list-style:none;padding:0;margin:1rem 0;
  columns:2;column-gap:26px}
.statelist li,.placelist li{display:flex;justify-content:space-between;gap:10px;
  break-inside:avoid;padding:5px 0;border-bottom:1px solid var(--border)}
.statelist li span,.placelist li span{color:var(--muted);font-size:.82rem;
  font-variant-numeric:tabular-nums;flex:none}
@media (min-width:700px){.statelist{columns:3}.placelist{columns:3}}

.zipbox{margin:1.6rem 0}
.zipbox h2{margin-top:0}
.zipbox form{display:flex;flex-wrap:wrap;gap:10px;align-items:center;margin:.6rem 0}
/* Visually hidden, not removed: the input still needs a programmatic label,
   and the placeholder is not one. */
.zipbox label{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
/* 12ch, not 9ch: at 9ch the "e.g. 32714" placeholder truncated to "e.g. 327",
   which reads as a 3-digit example. */
.zipbox input{font:inherit;padding:9px 12px;border-radius:8px;
  border:1px solid var(--rule);background:var(--plane);color:var(--ink);
  width:12ch;font-variant-numeric:tabular-nums}
.zipbox button{font:inherit;padding:9px 16px;border-radius:8px;cursor:pointer;
  border:1px solid var(--weekday);background:var(--weekday);color:#fff}
.zipbox button:hover{filter:brightness(1.08)}

body.place table{width:100%;border-collapse:collapse}
body.place th,body.place td{padding:9px 10px;border-bottom:1px solid var(--grid);
  text-align:left;vertical-align:top}
body.place th{font-size:.78rem;color:var(--ink-2);font-weight:600}
body.place .num{text-align:right;font-variant-numeric:tabular-nums}

/* ---- prose pages (about, corrections, privacy, methodology) ------------ */
body.prose main p,body.prose main li{font-size:1.02rem}
body.prose main h2{margin-top:2.6rem}
body.prose main ul,body.prose main ol{padding-left:1.15rem}
body.prose main li{margin-bottom:.5rem}
body.prose .updated{font-size:.82rem;color:var(--muted);margin-top:.2rem}
body.prose .qa{border-left:3px solid var(--rule);padding-left:18px;margin:1.4rem 0}
body.prose .qa h3{margin-top:0}

/* ---- ad slots ---------------------------------------------------------- */
.ad{margin:1.6rem 0;min-height:90px;border:1px dashed var(--grid);border-radius:var(--radius);
    display:flex;align-items:center;justify-content:center;color:var(--muted);
    font-size:.75rem;letter-spacing:.06em}

.demo{background:#fff8e6;border:1px solid var(--warning);color:#5c4300;
      border-radius:var(--radius);padding:12px 16px;font-size:.86rem;margin:16px 0 0}
:root[data-theme="dark"] .demo,
:root:where(:not([data-theme="light"])) .demo{background:#2a2413;color:#f0dfae}

/* ---- responsive -------------------------------------------------------- */
@media (max-width:620px){
  body.zip .optional,body.place .optional{display:none}
  .statelist,.placelist{columns:1}
}
@media (max-width:560px){
  h1{font-size:1.55rem}
  .barrow{grid-template-columns:74px 1fr}
}
