/* NHIA provider directory — Phase 1 vertical slice.
   Mobile-first. Colours from brand/NHIA-PowerBI-Theme-v1-Light.json.
   Full brand UX is Phase 3; this is deliberately restrained but not unstyled,
   and accessibility (focus, contrast, targets) is treated as baseline, not polish
   — patients use this page. */

:root {
  --navy:      #0B2546;
  --blue:      #006FBA;
  --blue-dark: #005A96;
  --teal:      #157375;
  --sky:       #B8D8EE;
  --ink:       #0B2546;
  --ink-soft:  #48566B;
  --line:      #D8E1EA;
  --surface:   #FFFFFF;
  --page:      #F4F7FA;
  --focus:     #B8560F;

  --pad: clamp(16px, 4vw, 32px);
  --radius: 10px;
  --shadow: 0 1px 2px rgba(11,37,70,.06), 0 4px 14px rgba(11,37,70,.06);
}

* { box-sizing: border-box; }

/* ⚠ MUST come before any rule that sets `display` on an element that can be
   [hidden]. A bare `display: inline-flex` on .switch outranks the browser's
   default `[hidden] { display: none }`, so the feature-flagged infusion-suite
   control rendered anyway while its filter stayed inert — it looked broken
   rather than absent. Same trap previously hit in the dashboard app. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  /* The page body must never scroll sideways. Wide content scrolls inside its
     own container instead. */
  overflow-x: hidden;
}

/* Long unbroken strings (a URL, a 40-character company name) are the other way
   a card blows out its column. */
h1, h2, h3, p, address, a { overflow-wrap: break-word; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 var(--pad); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 20;
  background: var(--navy); color: #fff; padding: 10px 16px;
}
.skip:focus { left: 8px; top: 8px; }

/* Visible focus everywhere — never removed. */
:where(a, button, input, select, [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ------------------------------------------------------------------ header
   Values measured from the live nhia.org header rather than eyeballed —
   see the note in index.html. */
:root {
  --util-bg:  #003478;   /* utility bar */
  --nav-bg:   #D6EAF7;   /* main nav band */
  --teal-btn: #1E9496;   /* "NHIA Member Home" */
  --sticky-h: 72px;      /* condensed bar height, same as theirs */
}

.site-header { background: #fff; }

/* --- band 1: utility --- */
.util { background: var(--util-bg); color: #fff; }
.util-in {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; min-height: 32px;
}
.util ul { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; }
.util-social { gap: 14px; }
.util-social svg { width: 15px; height: 15px; fill: #fff; display: block; }
.util-social a { display: block; padding: 4px 0; }
.util-links { gap: 0; flex-wrap: wrap; justify-content: flex-end; }
.util-links li + li { border-left: 1px solid rgba(255,255,255,.35); }
.util-links a {
  color: #fff; text-decoration: none; font-size: .84rem; font-weight: 600;
  padding: 6px 14px; display: inline-block; white-space: nowrap;
}
.util-links a:hover, .util-social a:hover { text-decoration: underline; }

/* --- band 2: logo + actions --- */
.logobar-in {
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; flex-wrap: wrap;
  /* padding-BLOCK, not the shorthand: `padding: 12px 0` would zero the
     horizontal padding .wrap supplies and slam the logo against the edge. */
  padding-block: 12px;
}
.logo-link { display: block; flex: 0 0 auto; }
.logo-link img { width: clamp(128px, 17vw, 172px); height: auto; display: block; }
.logobar-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hbtn {
  display: inline-flex; align-items: center; min-height: 40px;
  padding: 8px 18px; border-radius: 4px;
  font-size: .9rem; font-weight: 700; text-decoration: none; color: #fff;
}
.hbtn-teal { background: var(--teal-btn); }
.hbtn-blue { background: var(--blue); }
.hbtn:hover { filter: brightness(.93); }

/* --- band 3: section nav --- */
.mainnav { background: var(--nav-bg); }
.mainnav-in {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  min-height: 46px;
}
.mainnav a {
  color: var(--navy); text-decoration: none; font-weight: 600; font-size: .92rem;
  padding: 12px 14px; white-space: nowrap;
}
.mainnav a:hover { text-decoration: underline; }

/* --- condensed bar revealed on scroll (nhia.org's .bottom-header) --- */
.stickybar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  height: var(--sticky-h); background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(11,37,70,.10);
  transform: translateY(-100%);          /* parked off-screen, as theirs is */
  visibility: hidden;
}
.stickybar.on { transform: translateY(0); visibility: visible; }
@media (prefers-reduced-motion: no-preference) {
  .stickybar { transition: transform .22s ease, visibility .22s; }
}
/* Wider than the page's 1120 content column — nhia.org's condensed bar runs
   nearly full width, and the six nav labels do not fit in 1120 alongside the
   logo. */
.stickybar-in {
  display: flex; align-items: center; gap: 18px; height: var(--sticky-h);
  max-width: 1340px;
}
.stickybar .logo-link img { width: clamp(104px, 12vw, 132px); }
.stickynav { display: flex; gap: 2px; flex: 1 1 auto; min-width: 0; }
.stickynav a {
  color: var(--navy); text-decoration: none; font-weight: 600; font-size: .85rem;
  padding: 10px 9px; white-space: nowrap;
}
.stickynav a:hover { text-decoration: underline; }

/* Drop WHOLE items as space runs out. Letting the row clip instead truncates a
   label mid-word ("Membership & Caree"), which reads as a broken page rather
   than a deliberately shortened menu. Last-listed items go first. */
@media (max-width: 1320px) { .stickynav a:nth-child(6) { display: none; } }
@media (max-width: 1180px) { .stickynav a:nth-child(5) { display: none; } }
@media (max-width: 1050px) { .stickynav a:nth-child(4) { display: none; } }
@media (max-width:  960px) { .stickynav a:nth-child(3) { display: none; } }
.sticky-top {
  flex: 0 0 auto; color: var(--blue-dark); font-weight: 700; font-size: .86rem;
  text-decoration: none; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 6px;
}
.sticky-top:hover { background: var(--page); }

/* Below this the condensed nav cannot fit; keep the logo and the way back. */
@media (max-width: 900px) { .stickynav { display: none; } }

/* --- hamburger + mobile menu (desktop: hidden) --- */
.hamburger {
  display: none; background: none; border: 0; cursor: pointer;
  width: 46px; height: 46px; padding: 9px; margin-left: auto;
  color: var(--navy);
}
.hamburger svg { width: 100%; height: 100%; fill: none; stroke: currentColor;
                 stroke-width: 2.2; stroke-linecap: round; }
.hamburger .ic-close { display: none; }
.hamburger[aria-expanded="true"] .ic-open { display: none; }
.hamburger[aria-expanded="true"] .ic-close { display: block; }

.mobilenav { display: none; background: #fff; border-top: 1px solid var(--line); }
.mobilenav .wrap { display: flex; flex-direction: column; padding-top: 6px; padding-bottom: 14px; }
.mobilenav a {
  color: var(--navy); text-decoration: none; font-weight: 600; font-size: 1rem;
  padding: 13px 4px; text-align: center;          /* centred, as nhia.org's is */
  border-bottom: 1px solid #EEF2F6;
}
.mobilenav a:hover { background: var(--page); }
.mobilenav hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }

/* ---------------------------------------------------------------- MOBILE
   Scott's direction: one simple treatment in ALL states — white bar, logo,
   hamburger. So below this width the navy utility bar and the light-blue
   section nav are dropped entirely, the logo bar itself becomes the sticky
   header, and the separate condensed bar is switched off (it would be a second
   sticky bar competing with this one). Nothing is lost: the utility links move
   into the menu panel. */
@media (max-width: 900px) {
  .util, .mainnav { display: none; }
  .logobar-actions { display: none; }
  .hamburger { display: block; }

  /* ⚠ Sticky must go on .site-header, NOT on .logobar. A sticky element can
     only travel inside its PARENT's box, and with the utility and nav bands
     hidden the header collapses to the logo bar's own height — leaving it
     nowhere to stick, so it scrolled away. Pinning the header also carries the
     open menu panel with it, which is what you want. */
  .site-header {
    position: sticky; top: 0; z-index: 60;
    background: #fff; border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 6px rgba(11,37,70,.08);
  }
  .logobar-in { padding-block: 8px; flex-wrap: nowrap; }
  .logo-link img { width: clamp(116px, 34vw, 150px); }

  .mobilenav {
    display: block;
    max-height: calc(100vh - 70px); overflow-y: auto;
    box-shadow: 0 8px 18px rgba(11,37,70,.12);
  }
  .mobilenav[hidden] { display: none; }

  /* One sticky header only. */
  .stickybar { display: none !important; }
}

/* --- page title --- */
.pagetitle { background: var(--navy); color: #fff; padding: 22px 0 20px; }
.pagetitle h1 { margin: 0; font-size: clamp(1.35rem, 3.6vw, 1.9rem); line-height: 1.2; }
.pagetitle p { margin: 6px 0 0; color: var(--sky); font-size: .95rem; }

/* ------------------------------------------------------------------ panel */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: var(--pad); margin: 20px 0;
}

.searchrow, .filterrow {
  display: flex; flex-wrap: wrap; gap: 14px 16px; align-items: flex-end;
}
.filterrow { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }

/* min-width:0 is load-bearing: a flex item defaults to min-content width, which
   is what pushes a row wider than the viewport and makes the whole page scroll
   sideways. Everything here must be allowed to shrink. */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1 1 140px; }
.field.grow { flex: 1 1 100%; }
.field.compact { flex: 0 1 150px; }
.field.field-btn { justify-content: flex-end; flex: 0 0 auto; }

@media (min-width: 620px) {
  .field.grow { flex: 1 1 260px; }
}

label, legend {
  font-size: .8rem; font-weight: 600; color: var(--ink-soft);
  letter-spacing: .01em;
}

input[type="search"], input[type="text"], select {
  font: inherit; color: var(--ink);
  padding: 10px 12px; min-height: 44px;           /* touch target */
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); width: 100%;
}
input:focus, select:focus { border-color: var(--blue); }

/* ------------------------------------------------------------------ chips */
.chips { border: 0; padding: 0; margin: 0; min-width: 0; }
.chips legend { margin-bottom: 6px; }
.chip { display: inline-block; margin: 0 6px 0 0; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip span {
  display: inline-block; padding: 9px 14px; min-height: 40px; line-height: 22px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); cursor: pointer;
  font-size: .9rem; font-weight: 500; color: var(--ink-soft);
}
.chip input:checked + span {
  background: var(--navy); border-color: var(--navy); color: #fff;
}
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.toggles {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-left: auto;            /* right-aligned only when there is room */
}
/* Below this, `margin-left:auto` would fight the wrap and push content out of
   the viewport, so the group becomes its own full-width row instead. Cannot be
   verified in Edge headless (it floors at ~461px), so it is written to be
   correct by construction down to 320px rather than confirmed by screenshot. */
@media (max-width: 560px) {
  .toggles { margin-left: 0; width: 100%; justify-content: space-between; }
  .chips { width: 100%; }
  .resultshead { align-items: flex-start; }
}
.switch { display: inline-flex; align-items: center; gap: 8px; font-weight: 500;
          color: var(--ink); font-size: .92rem; cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--blue); }
.info {
  width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--page); color: var(--ink-soft); font-size: .75rem;
  cursor: help; line-height: 1; padding: 0;
}

/* ------------------------------------------------------------------ btns */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 11px 16px; min-height: 44px;
  border-radius: 8px; border: 1px solid var(--blue);
  background: var(--blue); color: #fff;
}
.btn:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-ghost { background: var(--surface); color: var(--blue-dark); }
.btn-ghost:hover { background: var(--page); }
.btn-link {
  background: none; border: 0; color: var(--blue-dark);
  text-decoration: underline; padding: 8px 4px; min-height: 40px;
}

.status { margin: 14px 0 0; font-size: .9rem; color: var(--ink-soft); }
.status.err { color: #98351B; font-weight: 600; }

/* ---------------------------------------------------------------- results */
.resultshead {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  justify-content: space-between; margin: 26px 0 12px;
}
.resultshead h2 { margin: 0; font-size: 1.05rem; }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
@media (min-width: 780px) { .cards { grid-template-columns: 1fr 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 8px;
}
.card.nursing { border-left-color: var(--teal); }

/* Logo is OPTIONAL by design — 42% of locations have none, so a card must look
   deliberate without one rather than showing a broken/placeholder box. The title
   simply takes the full width. */
.card-head { display: flex; align-items: flex-start; gap: 12px; }
.card-head > div { min-width: 0; flex: 1 1 auto; }
.card .logo {
  flex: 0 0 auto;
  max-width: 96px; max-height: 40px;
  width: auto; height: auto;
  object-fit: contain; object-position: right top;
}

.card h3 { margin: 0; font-size: 1.02rem; line-height: 1.3; }
.card .parent { margin: 0; font-size: .84rem; color: var(--ink-soft); }
.card .addr { margin: 0; font-size: .9rem; color: var(--ink-soft); font-style: normal; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 0; }
.badge {
  font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 4px;
  background: #E8F1F9; color: var(--blue-dark);
}
.badge.nursing { background: #E2F1F0; color: #0F5C5E; }
.badge.suite   { background: #F2ECFA; color: #4C3480; }
.badge.dist    { background: var(--navy); color: #fff; }

.card .links { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 2px; }
.card .links a { color: var(--blue-dark); font-weight: 600; font-size: .9rem; }
.card .locs { font-size: .84rem; color: var(--ink-soft); }

/* ------------------------------------------------------------------- map */
.head-controls { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }

.map-panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 10px; margin: 0 0 18px;
}
#map {
  height: clamp(320px, 52vh, 560px); width: 100%;
  border-radius: 8px; background: var(--page);
}
/* Leaflet sets its own z-index stack; keep it below any future sticky header. */
.leaflet-pane, .leaflet-top, .leaflet-bottom { z-index: 1; }
.leaflet-container { font: inherit; }
.leaflet-popup-content { margin: 12px 14px; font-size: .9rem; line-height: 1.45; }
.leaflet-popup-content strong { display: block; font-size: .96rem; margin-bottom: 3px; }
.leaflet-popup-content .pp-links { margin-top: 7px; display: flex; gap: 12px; flex-wrap: wrap; }
.leaflet-popup-content a { color: var(--blue-dark); font-weight: 600; }

.note {
  margin: 10px 0 0; font-size: .84rem; color: var(--ink-soft);
  background: #F7F3E8; border-left: 3px solid #C08A2E;
  padding: 8px 12px; border-radius: 0 6px 6px 0;
}
.map-note { background: none; border: 0; padding: 4px 2px 0; }

.empty {
  background: var(--surface); border: 1px dashed var(--line);
  border-radius: var(--radius); padding: 28px; text-align: center; color: var(--ink-soft);
}
.more { text-align: center; margin: 20px 0; }

/* ------------------------------------------------------------------- foot */
.foot { margin: 34px auto; padding-bottom: 40px; color: var(--ink-soft); font-size: .9rem; }
.foot a { color: var(--blue-dark); font-weight: 600; }
.foot .fine { font-size: .8rem; line-height: 1.5; }

/* Card <-> map link. `.is-linked` is set both on card hover/focus and when the
   matching map dot is hovered, so the relationship reads in both directions. */
.card.is-linked {
  border-color: var(--navy);
  box-shadow: 0 0 0 2px rgba(11,37,70,.20),
              0 2px 4px rgba(11,37,70,.08), 0 8px 22px rgba(11,37,70,.12);
}
.card.is-linked::before {
  content: ""; position: absolute; inset: 0;
  border-left: 4px solid var(--navy); border-radius: var(--radius) 0 0 var(--radius);
  pointer-events: none;
}
.card { position: relative; }
.card:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.leaflet-tooltip {
  font-weight: 600; font-size: .82rem; color: var(--ink);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}

@media (prefers-reduced-motion: no-preference) {
  .card { transition: box-shadow .15s ease, border-color .15s ease; }
  .card:hover { box-shadow: 0 2px 4px rgba(11,37,70,.08), 0 8px 22px rgba(11,37,70,.10); }
}
