/* mackforge.dev's own styles (the same values as the site's style sheet): Inter for text, Anton for titles, flat panels with 1 px rules and a
   4 px radius, no shadows, one accent. Map data colors (shading, dots, payer bar) are not site colors. */
:root { --bg: #eef1f5; --panel: #ffffff; --text: #0d1117; --muted: #45525f; --line: #c9d1da; --accent: #b85a14;
  --radius: 4px; --font-ui: "Inter", system-ui, sans-serif; --font-display: "Anton", Impact, sans-serif; }
html, body { margin: 0; height: 100%; overflow: hidden; font: 15px/1.45 "Inter", system-ui, sans-serif; color: var(--text); }
a { color: var(--text); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
#map { position: absolute; inset: 0; }
/* on a phone the panel is a compact top bar: the search line, with the other panels behind one Layers button */
#panel { position: absolute; top: 8px; left: 8px; right: 8px; max-height: calc(100vh - 16px);
  overflow-y: auto; box-sizing: border-box; background: var(--panel); padding: 8px 10px; border-radius: var(--radius);
  border: 1px solid var(--line); z-index: 2; }
#panel label { display: block; cursor: pointer; padding: 2px 0; }
#search label[for="q"] { font: 400 18px/1.1 var(--font-display); text-transform: uppercase; letter-spacing: .01em;
  padding: 0; cursor: default; }
#search .row { display: flex; gap: 6px; margin-top: 4px; }
#q { flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 8px; border: 1px solid var(--muted); border-radius: var(--radius);
  color: var(--text); background: var(--panel); }
#search button { font: inherit; font-weight: 600; min-height: 40px; padding: 8px 12px; border: 0; border-radius: var(--radius);
  background: var(--text); color: var(--panel); cursor: pointer; }
#search #menu-btn { padding: 8px 10px; border: 1px solid var(--text); background: var(--panel); color: var(--text); }
#search #menu-btn[aria-expanded="true"] { background: var(--text); color: var(--panel); }
#search .hint { margin: 2px 0 0; color: var(--muted); font-size: 13px; line-height: 1.3; }
/* "Use my location" (over HTTPS only) reads as a link in the hint line; the padding widens the tap area, the margin keeps
   the line's height */
#search #locate { min-height: 0; padding: 6px 0; margin: -6px 0; border: 0; background: none; color: var(--text);
  font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
#menu-sheet { display: none; }
body.menu-open #menu-sheet { display: block; }
/* the zoom buttons sit just under the top bar (lookup.js keeps --bar-bottom up to date) */
.maplibregl-ctrl-top-right { top: var(--bar-bottom, 110px); }
#status { margin: 4px 0 0; font-size: 14px; color: #8a1c14; }
#status:empty { display: none; }
#choices[hidden] { display: none; }
#choices { margin-top: 6px; }
#choices .choices-head { margin: 0 0 4px; font-weight: 600; font-size: 14px; }
#choices ul { list-style: none; margin: 0; padding: 0; }
#choices .choice { display: block; width: 100%; min-height: 44px; text-align: left; font: inherit; font-size: 15px;
  padding: 6px 8px; margin: 0 0 4px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--text); cursor: pointer; }
#choices .choice:hover { border-color: var(--muted); }
#choices .choice .sub { display: block; font-size: 13px; color: var(--muted); }
#choices .choices-foot { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
#panel details { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 4px; }
#panel summary { cursor: pointer; padding: 4px 0; font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted); }
#banner { position: sticky; top: -8px; margin: -8px -10px 6px; padding: 8px 10px; background: #fff4d6;
  border-bottom: 1px solid #e0b84a; font-weight: 600; z-index: 1; }
#banner[hidden] { display: none; }

.legend { margin: 2px 0 6px 24px; font-size: 13px; --key-line: 17px; --key-icon: 20px; }
.legend > div { margin: 2px 0; }
/* a key line: its mark in one fixed column (every mark's left edge the same), centered on the label's first line;
   a label that wraps keeps its own column. Marks are drawn at the map's own dot sizes (app.js legendFor). */
.legend .key-row { display: grid; grid-template-columns: var(--key-icon) 1fr; column-gap: 6px; align-items: start;
  line-height: var(--key-line); }
.legend .key-icon { display: flex; align-items: center; justify-content: flex-start; height: var(--key-line); }
.legend .legend-note { padding-left: calc(var(--key-icon) + 6px); }
.legend .legend-ramp .legend-note { padding-left: 0; }
.line-swatch { display: block; width: 16px; height: 0; border-top-style: solid; }
.legend .swatch { display: block; flex: none; box-sizing: border-box; border-style: solid; border-radius: 50%; margin: 0; }
.legend .area-swatch { display: block; flex: none; width: 16px; height: 12px; box-sizing: border-box; border-radius: 2px;
  border: 1px solid rgba(0,0,0,.15); }
.legend .swatch.light-ring { outline: 1px solid rgba(0,0,0,.28); outline-offset: -1px; }
.legend-ramp { position: relative; padding-bottom: 2px; }
.ramp-bar { display: flex; height: 10px; border-radius: 2px; overflow: hidden; border: 1px solid rgba(0,0,0,.15); }
.ramp-bar span { flex: 1; }
.ramp-ticks { position: relative; height: 14px; font-size: 11.5px; color: var(--text); }
.ramp-ticks span { position: absolute; top: 0; transform: translateX(-50%); }
.variants { margin: 0 0 2px 24px; font-size: 13.5px; }
.variants .variant { padding: 1px 0; }

/* the on-map key: what the colors and dots mean, readable without opening anything */
/* On a phone it starts closed: one small button ("Map key", with a sliver of the color ramp) above the map credits.
   A tap opens the key above the button; a tap on the button or the map closes it. A wide screen starts it open. */
#map-key { position: absolute; left: 8px; bottom: 60px; /* clear of the map credits, which must stay readable */ z-index: 2; max-width: min(320px, calc(100vw - 16px));
  display: flex; flex-direction: column-reverse; align-items: flex-start; gap: 4px; font-size: 12.5px; line-height: 1.3;
  pointer-events: none; /* only the button takes a tap: the rest of the key lets it through to the map and the dot under it */ }
#map-key[hidden], #map-key .key-section[hidden] { display: none; }
#key-btn { pointer-events: auto; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 10px;
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--text); background: var(--panel); border: 1px solid var(--muted);
  border-radius: var(--radius); cursor: pointer; }
#key-btn .key-chip-ramp { display: inline-block; width: 26px; height: 10px; border-radius: 2px; border: 1px solid rgba(0,0,0,.15); }
#map-key[data-open="true"] #key-btn .key-chip-ramp { display: none; }
#key-body { background: rgba(255,255,255,.94); border-radius: var(--radius); border: 1px solid var(--line); padding: 6px 9px 4px; }
#map-key[data-open="false"] #key-body { display: none; }
#map-key .key-title { font-weight: 600; font-size: 12.5px; margin: 0 0 2px; }
#map-key .key-section + .key-section { margin-top: 5px; padding-top: 4px; border-top: 1px solid var(--line); }
#map-key .legend { margin: 0; font-size: 12px; }
#map-key .legend-note { color: var(--muted); font-size: 11.5px; }
body.card-open #map-key { display: none; }
@media (min-width: 768px) {
  #map-key { left: auto; right: 10px; bottom: 34px; max-width: 280px; align-items: flex-end; }
  body.card-open #map-key { display: flex; }
  body.card-open #map-key[hidden] { display: none; }
}
/* in the closure view the panel keeps only the banner and the search box, so the shaded area has room */
body.closure-on #search .hint { display: none; }
@media (min-width: 768px) { body.closure-on #panel details { display: none; } }
.closure-legend .legend-ramp { margin: 4px 0 2px; max-width: 300px; }
.dest h3 { margin: 6px 0 2px; }
.dest-list { margin: 0 0 4px; padding-left: 18px; }
.dest-list li { margin: 2px 0; }
.closure-legend .swatch, .pay-key .k { display: inline-block; width: 11px; height: 11px; border-radius: 50%;
  vertical-align: -1px; margin-right: 4px; }
.legend-note { color: var(--muted); }
.out-list, .source-list { margin: 0; padding-left: 18px; font-size: 14px; }
.out-list li, .source-list li { margin: 3px 0; }

#hospital-list { display: flex; flex-direction: column; max-height: 40vh; overflow-y: auto; }
.list-item { font: inherit; font-size: 14px; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line);
  padding: 7px 2px; cursor: pointer; color: var(--text); }
.list-item:hover, .list-item:focus { background: var(--bg); }
#sources { font-size: 14px; }

/* the card: a bottom sheet on a phone, a panel section on a wide screen */
/* On a phone it opens at a peek height (the first line of the answer) and is dragged or tapped up to full (at most half
   the screen) and back; lookup.js sets the height. At peek the whole card is a drag surface; at full its body scrolls. */
#card { position: fixed; left: 0; right: 0; bottom: 0; max-height: 50vh; overflow: hidden; box-sizing: border-box;
  background: var(--panel); padding: 0 14px 12px; border-radius: var(--radius) var(--radius) 0 0; border-top: 1px solid var(--line);
  z-index: 3; touch-action: none; }
#card[data-sheet="full"] { overflow-y: auto; touch-action: pan-y; }
#card[data-sheet="peek"]::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 16px;
  background: linear-gradient(rgba(255,255,255,0), #fff); pointer-events: none; }
#card[hidden] { display: none; }
/* the top row takes no height of its own: the grip (a button: "Show more" / "Show less") is centered on the card's top
   edge and Close sits in the top right corner; the first lines of the answer wrap around Close */
.card-top { position: sticky; top: 0; height: 0; z-index: 1; touch-action: none; }
#card-size { position: absolute; top: 0; left: 50%; width: 120px; height: 22px; margin-left: -60px; padding: 0; border: 0;
  background: none; cursor: grab; touch-action: none; }
#card-size::before { content: ''; display: block; width: 40px; height: 4px; margin: 6px auto 0; border-radius: 2px; background: var(--muted); }
#card-size[hidden] { display: none; }
#card-close { position: absolute; top: 16px; right: 0; font: inherit; font-size: 14px; min-width: 64px; min-height: 36px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); cursor: pointer; }
#card-close:hover { border-color: var(--muted); }
#card-body { padding-top: 16px; }
#card-body::before { content: ''; float: right; width: 72px; height: 40px; }
/* card titles keep their own letters (no text-transform): a hospital's name is read back as written */
#card h2 { font: 400 21px/1.15 var(--font-display); letter-spacing: .01em; margin: 0 0 4px; }
#card h3 { font-size: 14px; font-weight: 600; color: var(--muted); margin: 0 0 4px; }
#card p { margin: 0 0 4px; }
#card .lead { font-weight: 600; font-size: 16px; }
#card .lost { font-weight: 600; color: #8a1c14; }
#card .note { color: var(--muted); font-style: italic; }
.blk { padding: 8px 0; border-bottom: 1px solid var(--line); }
.blk:last-of-type { border-bottom: 0; }
.src { font-size: 12.5px; color: var(--muted); }
.src a { color: var(--muted); }
.foot { font-size: 12.5px; color: var(--muted); margin-top: 6px !important; }
a.action { display: inline-block; margin: 4px 0; font-weight: 600; color: var(--text); }
.links a { color: var(--text); }
.rank-bar { position: relative; height: 6px; margin: 8px 6px 2px; border-radius: 2px;
  background: linear-gradient(90deg, #b30000, #fdbb84 50%, #cfe3f3); }
.rank-dot { position: absolute; top: -5px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%;
  background: var(--text); border: 2px solid #fff; box-sizing: border-box; }
.rank-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.chip { font: inherit; font-size: 13.5px; padding: 5px 10px; min-height: 32px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--panel); color: var(--text); cursor: pointer; }
.chip:hover { border-color: var(--muted); }
.chip[aria-expanded="true"] { background: var(--text); color: var(--panel); border-color: var(--text); }
.explainer { background: var(--bg); border-radius: var(--radius); padding: 6px 8px; margin: 4px 0; }
.reh-note { font-size: 13.5px; color: var(--muted); margin-top: 6px; }
.pay-bar { display: flex; height: 12px; border-radius: 2px; overflow: hidden; margin: 4px 0; }
.pay-medicare { background: #1f3a5f; }
.pay-medicaid { background: #4f9fd6; }
.pay-other { background: #d3d3d3; }
.pay-key { font-size: 13.5px; }
.pay-key .k { border-radius: 2px; margin-left: 6px; }
.pay-key .k:first-child { margin-left: 0; }
.whatif, .back { display: block; font: inherit; font-weight: 600; margin: 8px 0 2px; padding: 8px 12px; border-radius: var(--radius);
  border: 1px solid #8a1c14; background: var(--panel); color: #8a1c14; cursor: pointer; }
.back { border-color: var(--text); color: var(--text); }
/* on the hospital card the what-if button sits under the place line and ends the card's opening height, so it is
   kept compact (36 px tall, the Close button's height) to leave the map 70% of a phone screen */
.blk-name .whatif { margin: 2px 0 0; padding: 6px 10px; line-height: 22px; }
/* the map's two ways on, floating on the map just under the top bar, opposite the zoom buttons (lookup.js keeps
   --bar-bottom up to date), so the top bar keeps its height (no jump when a card opens) and an open card keeps the map
   70% of a phone screen: "What if hospitals closed?" (filled, like the Search button, so it reads as a button) and the
   funding chart (outlined, like the Layers button). Both 44 px tall, a phone's tap size. Stacked on a phone, side by
   side on a wide screen. */
#map-actions { position: absolute; left: 8px; right: 56px; /* 56px: the zoom buttons' column (29px wide, 10px in) and a gap, so the
   buttons wrap onto a second line instead of running under the zoom buttons */
  top: var(--bar-bottom, 110px); z-index: 2; display: flex; flex-direction: column;
  align-items: flex-start; gap: 6px; pointer-events: none; }
#whatif-btn, #chart-link { pointer-events: auto; box-sizing: border-box; display: inline-flex; align-items: center;
  min-height: 44px; padding: 10px 14px; font: inherit; font-weight: 600; line-height: 22px; border-radius: var(--radius);
  cursor: pointer; }
#whatif-btn { border: 1px solid #8a1c14; background: #8a1c14; color: #fff; }
#whatif-btn:hover { background: #6e1610; border-color: #6e1610; }
#chart-link { border: 1px solid var(--text); background: var(--panel); color: var(--text); text-decoration: none; }
#chart-link:hover { background: var(--text); color: var(--panel); }
#whatif-btn[hidden], #chart-link[hidden] { display: none; }
/* while a what-if is on its card and the banner take over; on a phone an open card or the menu has the screen */
body.closure-on #whatif-btn { display: none; }
@media (max-width: 767px) { body.card-open #map-actions, body.menu-open #map-actions { display: none; } }
@media (min-width: 768px) { #map-actions { left: 392px; top: 10px; flex-direction: row; flex-wrap: wrap; } }
/* the what-if cards: scenario buttons, stop buttons and the checklists reuse .list-item, .chip and .blk */
.wi .list-item { display: block; width: 100%; padding: 6px 2px; line-height: 1.3; }
/* a scenario's first sentence, two lines at most here: the whole of it is on the scenario's own card */
.wi .list-item .sub { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  font-size: 12.5px; color: var(--muted); }
.wi h3 { margin: 2px 0; font-size: 15px; }
.wi .chip[aria-pressed="true"] { background: var(--text); color: var(--panel); border-color: var(--text); }
#card .wi .pick { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; cursor: pointer; }
.wi .pick input { margin-top: 4px; flex: none; }
.wi .pick-list { max-height: 40vh; overflow-y: auto; }
.wi input[type="search"] { width: 100%; box-sizing: border-box; font: inherit; font-size: 16px; padding: 6px 8px;
  border: 1px solid var(--muted); border-radius: var(--radius); }
.wi .row-btns { display: flex; flex-wrap: wrap; gap: 8px; }
#card.peek-btn[data-sheet="peek"]::after { display: none; }
.closure-legend { font-size: 13px; margin: 6px 0; }
.closure-legend .lg { display: inline-flex; align-items: center; margin: 0 10px 2px 0; }
.closure-legend .lg .swatch { flex: none; vertical-align: 0; }
.closure-legend .swatch { border: 1px solid #5a2a00; box-sizing: border-box; }
.quote { font-style: italic; }

/* on a phone the card slides up from the bottom; the panel above it never changes size */
@media (max-width: 767px) {
  #card { transform: translateY(0); transition: transform 250ms ease-out, height 200ms ease-out; }
  #card.enter { transform: translateY(100%); transition: none; }
  #card.dragging { transition: none; }
}
@media (prefers-reduced-motion: reduce) {
  #card, #card.enter { transition: none; transform: none; }
}

@media (min-width: 768px) {
  #panel { top: 10px; left: 10px; right: auto; width: 370px; max-height: calc(100vh - 20px); padding: 10px 12px; }
  #banner { top: -10px; margin: -10px -12px 8px; padding: 8px 12px; }
  #search label[for="q"] { font-size: 20px; }
  #search .hint { font-size: 14px; }
  #search #menu-btn { display: none; }
  #menu-sheet { display: block; }
  .maplibregl-ctrl-top-right { top: 0; }
  #card { position: static; max-height: none; overflow: visible; border-radius: 0; padding: 0;
    border-top: 1px solid var(--line); margin-top: 6px; touch-action: auto; }
  .card-top { display: flex; justify-content: flex-end; height: auto; background: var(--panel); padding: 8px 0 2px; touch-action: auto; }
  #card-close { position: static; }
  #card-body { padding-top: 0; }
  #card-body::before, #card-size { display: none; }
}

#error { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--panel); font-size: 18px; z-index: 5; }
#error[hidden] { display: none; }
