/* Mobile first: base rules are for a phone (sized on an iPhone 17 Pro Max, 440pt
   wide); min-width queries add the desktop layout. One LED price sign is the hero. */
:root {
  color-scheme: light;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --page: #edefec;
  --surface: #ffffff;
  --ink: #1c1f23;
  --ink-2: #4a4f55;
  --muted: #747a81;
  --grid: #e3e5e2;
  --axis: #c4c8c4;
  --border: rgba(28, 31, 35, 0.12);
    --series-1: #2a78d6;      /* cheapest */
  --series-2: #eb6834;      /* over-wholesale */
  --series-3: #1baf7a;      /* same-price share */
  --band: rgba(116, 122, 129, 0.18);
  --median: #747a81;
  --marker: #6250d6;        /* restoration lines */
  --good: #0a6b0a;          /* savings: the map's green pins */
  --good-wash: rgba(10, 107, 10, 0.08);
  --warning: #b86e00;
  --up: #b42318;            /* text for price above median */
  --down: #006300;          /* text for price below median */
  --accent-wash: rgba(42, 120, 214, 0.10);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #15171a;
    --surface: #1f2226;
    --ink: #eef0ee;
    --ink-2: #c2c6c2;
    --muted: #8d939a;
    --grid: #2d3135;
    --axis: #3b4045;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --band: rgba(194, 198, 194, 0.14);
    --median: #8d939a;
    --marker: #9085e9;
    --good: #2fa52f;
    --good-wash: rgba(47, 165, 47, 0.12);
    --warning: #f0a83a;
    --up: #e66767;
    --down: #3cbf3c;
    --accent-wash: rgba(57, 135, 229, 0.16);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #15171a;
  --surface: #1f2226;
  --ink: #eef0ee;
  --ink-2: #c2c6c2;
  --muted: #8d939a;
  --grid: #2d3135;
  --axis: #3b4045;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --band: rgba(194, 198, 194, 0.14);
  --median: #8d939a;
  --marker: #9085e9;
  --good: #2fa52f;
  --good-wash: rgba(47, 165, 47, 0.12);
  --warning: #f0a83a;
  --up: #e66767;
  --down: #3cbf3c;
  --accent-wash: rgba(57, 135, 229, 0.16);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--page); }
body {
  margin: 0 auto;
  max-width: 1200px;
  padding: 12px max(16px, env(safe-area-inset-right)) 16px max(16px, env(safe-area-inset-left));
  background: var(--page);
  color: var(--ink);
  font: 16px/1.5 var(--font-body);
  font-variant-numeric: tabular-nums;
}
@media (min-width: 761px) { body { padding: 20px 24px; } }
h1, h2, h3 { font-weight: 700; line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 22px; letter-spacing: -0.02em; }
h2 { font-size: 21px; }
h3 { font-size: 17px; font-weight: 650; }
.card h2, .card h3 { margin-bottom: 2px; }
.sub, .note { color: var(--ink-2); margin: 2px 0 0; font-size: 14px; }
.note { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 16px; margin-bottom: 12px; }
.top .sub { font-size: 13px; color: var(--muted); }

/* Selects and inputs stay at 16px or more: iOS zooms the page into anything smaller. */
select, input { font: inherit; font-size: 16px; }
select:focus-visible, input:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.controls label { font-size: 13px; font-weight: 500; color: var(--ink-2); display: grid; gap: 4px; min-width: 0; }
.controls select {
  width: 100%; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-height: 44px;
}
.scope { margin-top: 10px; }

.seg { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: nowrap; flex: none; gap: 0; }
.seg legend { width: 100%; margin-bottom: 6px; padding: 0; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.seg label { display: block; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: grid; place-items: center; padding: 8px 14px; min-height: 44px; cursor: pointer; font-size: 15px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border); margin-left: -1px; white-space: nowrap;
}
.seg label:first-of-type span { border-radius: 8px 0 0 8px; margin-left: 0; }
.seg label:last-of-type span { border-radius: 0 8px 8px 0; }
.seg input:checked + span { background: var(--ink); color: var(--surface); border-color: var(--ink); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--series-1); outline-offset: 1px; }
.seg input:disabled + span { color: var(--muted); background: var(--page); cursor: default; }
#range { margin-top: 14px; }
#range label { flex: 1; }
@media (min-width: 761px) { #range label { flex: none; } }

main.loading { opacity: 0.55; transition: opacity 0.15s; }
@media (prefers-reduced-motion: reduce) { main.loading { transition: none; } }

/* ---------- right now: the sign and the verdict ---------- */
.now { display: grid; gap: 24px; margin-bottom: 24px; }
/* Desktop: the sign on the left; the verdict, stats and filters stacked beside it. */
@media (min-width: 761px) {
  .now {
    grid-template-columns: minmax(0, 440px) 1fr; grid-template-rows: auto auto 1fr; grid-template-areas: "sign side" "sign controls" "sign scope";
    column-gap: 32px; row-gap: 16px; align-items: start;
  }
  .now > .filters { display: contents; }
  .sign { grid-area: sign; }
  .side { grid-area: side; }
  .controls { grid-area: controls; margin-top: 0; grid-template-columns: repeat(2, minmax(0, 240px)); }
  .scope { grid-area: scope; margin-top: 0; }
}

/* A pump's price sign: brushed frame, black LED module, a colored grade plate.
   Red, green, blue and amber follow the usual pump color code. The LED red leans
   warm, as real red LEDs do; it reads as a sign on the black panel, not an error. */
.sign {
  --led: #ff4a2e; --led-glow: rgba(255, 74, 46, 0.55); --plate: #c42018; --plate-ink: #fff;
  background: #0a0a0b; border-radius: 12px; padding: 10px;
  border: 4px solid #3a3e44; box-shadow: inset 0 0 0 1px #000, 0 1px 2px rgba(0, 0, 0, 0.25);
  background-image: linear-gradient(#0d0d0f, #060607);
}
.sign[data-fuel="diesel"] { --led: #2ee86e; --led-glow: rgba(46, 232, 110, 0.5); --plate: #0f7a37; }
.sign[data-fuel="xethanol"] { --led: #4fb4ff; --led-glow: rgba(79, 180, 255, 0.55); --plate: #1b5cc8; }
.sign[data-fuel="e85"] { --led: #ffc21a; --led-glow: rgba(255, 194, 26, 0.5); --plate: #f2b705; --plate-ink: #141414; }

.plate { display: block; position: relative; color: var(--plate-ink); }
.plate select {
  appearance: none; -webkit-appearance: none; width: 100%; cursor: pointer;
  background: var(--plate); color: inherit; border: 0; border-radius: 6px;
  font-size: 19px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 10px 44px 10px 14px; min-height: 48px;
}
.plate::after {
  content: ""; position: absolute; right: 18px; top: 50%; width: 9px; height: 9px; pointer-events: none;
  border-right: 3px solid; border-bottom: 3px solid; transform: translateY(-70%) rotate(45deg);
}
.plate select:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

.led { display: flex; justify-content: center; padding: 18px 4px 12px; filter: drop-shadow(0 0 7px var(--led-glow)); }
.led svg {
  display: block; width: 100%; max-width: 380px; height: auto; color: var(--led);
  /* Each lit bar is a grid of LEDs. */
  -webkit-mask: radial-gradient(circle, #000 1.6px, transparent 2px) 0 0 / 4.5px 4.5px;
  mask: radial-gradient(circle, #000 1.6px, transparent 2px) 0 0 / 4.5px 4.5px;
}
.led polygon, .led circle { fill: currentColor; opacity: 0.045; }
.led .on { opacity: 1; }

.sign-foot { display: flex; align-items: center; gap: 12px; padding: 12px 6px 4px; border-top: 1px solid #26292d; }
.sign-where { margin: 0; flex: 1; min-width: 0; font-size: 15px; line-height: 1.4; color: #d5d8dc; }
.sign-where > * { display: block; }
.sign-label { color: #9aa0a6; font-size: 14px; }
.sign-where strong { color: #fff; font-size: 17px; font-weight: 650; }
.sign-dist { color: #9aa0a6; font-size: 14px; margin-top: 2px; }
.sign-go {
  flex: none; display: grid; place-items: center; min-height: 44px; padding: 0 16px; border-radius: 8px;
  background: #fff; color: #111; font-weight: 650; text-decoration: none;
}
.sign-go:focus-visible, .sign-btn:focus-visible { outline: 3px solid var(--led); outline-offset: 2px; }
/* Where the radius is measured from, when it isn't the visitor. */
.sign-locate {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0 0; padding: 10px 6px 4px;
  border-top: 1px solid #26292d; color: #c3c7cc; font-size: 15px; line-height: 1.35;
}
.sign-locate:has(#where-text:empty):has(#use-location[hidden]) { display: none; }
.sign-btn {
  flex: none; font: inherit; font-weight: 650; min-height: 44px; padding: 0 14px; border-radius: 8px; cursor: pointer;
  background: transparent; color: #fff; border: 1.5px solid #8b9096;
}
.sign-btn:hover { border-color: #fff; }

.verdict-head { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
@media (min-width: 761px) { .verdict-head { font-size: 34px; } .verdict { padding-top: 8px; } }
.verdict[data-level="buy"] .verdict-head { color: var(--good); }
.verdict[data-level="wait"] .verdict-head { color: var(--warning); }
/* No advice yet, only what prices are doing: a quieter headline. */
.verdict[data-level="info"] .verdict-head { font-size: 22px; font-weight: 700; }
.verdict[data-level="info"] .verdict-text { font-size: 16px; margin-bottom: 0; }
.verdict-text { margin: 6px 0 16px; font-size: 17px; color: var(--ink-2); max-width: 36em; }
.meter { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; height: 14px; }
.meter[hidden] { display: none; }
.meter span {
  border-radius: 2px; background: var(--axis);
  background-image: linear-gradient(to right, var(--ink) calc(var(--fill) * 100%), transparent 0);
}
.meter.overdue span { background-image: linear-gradient(var(--good), var(--good)); }
.meter-ends { display: grid; gap: 4px; margin-top: 8px; font-size: 14px; }
.meter-ends p { margin: 0; }
@media (min-width: 1000px) { .meter-ends { display: flex; justify-content: space-between; gap: 24px; } .meter-ends .end { text-align: right; } }
.meter-val { font-weight: 650; }

.side { display: grid; gap: 24px; align-content: start; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; margin: 0; padding: 16px 0; border-block: 1px solid var(--border); }
.stats .wide { grid-column: 1 / -1; }
.stats dt { font-size: 14px; color: var(--ink-2); }
.stats dd { margin: 0; }
.stats .val { font-size: 22px; font-weight: 700; line-height: 1.25; }
.stats .wide .val { font-size: 28px; letter-spacing: -0.01em; }
@media (min-width: 761px) {
  .stats { grid-template-columns: 1.6fr 1fr 1fr; gap: 0; padding: 14px 0; }
  .stats .wide { grid-column: auto; }
  .stats > div { padding: 0 20px; border-left: 1px solid var(--border); }
  .stats > div:first-child { padding-left: 0; border-left: 0; }
}

/* ---------- panels ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 16px; min-width: 0; }
.pair { display: grid; grid-template-columns: 1fr; }
@media (min-width: 761px) { .card { padding: 16px 18px; } .pair { grid-template-columns: 1fr 1fr; gap: 16px; } }

.chapter { margin: 36px 0 16px; max-width: 46em; }
.chapter p { margin: 6px 0 0; color: var(--ink-2); }

.chart { position: relative; height: 200px; margin-top: 10px; }
.chart.tall { height: 280px; }
.chart.short { height: 160px; }
@media (min-width: 761px) { .chart.tall { height: 340px; } }
.chart[data-empty] canvas { visibility: hidden; }
.chart.short[data-empty] { height: 56px; }
.chart[data-empty]::after {
  content: attr(data-empty);
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: 14px; text-align: center; padding: 0 16px;
}

.scroll { overflow-x: auto; margin-top: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { font-size: 13px; font-weight: 600; color: var(--ink-2); }
td.num, th.num { text-align: right; }
tr.best td { background: var(--good-wash); }
td.price { font-weight: 650; }
td.station { white-space: normal; min-width: 220px; }
td a { color: var(--series-1); }

td.meta { display: none; }
.go-icon {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; vertical-align: middle;
  color: var(--series-1); border: 1px solid var(--border); background: var(--surface);
}
.go-icon svg { width: 17px; height: 17px; fill: currentColor; }
.go-icon:hover { background: var(--accent-wash); }
.go-icon:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }
td.go { padding-block: 3px; }

/* Phones: each station is a short block instead of a wide table.
     $3.799   Wawa                                  (➤)
              10115 Bloomingdale Ave, Riverview
              8.4 mi  save $3.00  changed 3h ago      */
@media (max-width: 760px) {
  #stores thead { display: none; }
  #stores, #stores tbody { display: block; }
  #stores tr {
    display: grid; grid-template-columns: 4.4em 1fr 44px; column-gap: 12px; row-gap: 4px; align-items: baseline;
    grid-template-areas: "price station go" "price meta go";
    padding: 12px 8px; border-bottom: 1px solid var(--grid);
  }
  #stores tr.best { background: var(--good-wash); }
  #stores td { padding: 0; border: 0; background: none; white-space: normal; min-width: 0; text-align: left; }
  #stores :is(.rank, .vs, .per-tank, .mi, .changed) { display: none; }
  #stores .price { grid-area: price; font-size: 18px; }
  #stores .station { grid-area: station; }
  #stores .station :is(.linkish, strong, .addr) { display: block; }
  #stores .meta { grid-area: meta; display: flex; flex-wrap: wrap; gap: 0 12px; font-size: 14px; }
  #stores .go { grid-area: go; align-self: center; }
  #stores .go-icon { width: 44px; height: 44px; }
  #events :is(th, td):nth-child(5) { display: none; }
  #events td:last-child { white-space: normal; min-width: 9em; }
}
.linkish { font: inherit; color: inherit; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; }
.linkish:hover { text-decoration: underline; }
.linkish:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }
.linkish.link { color: var(--series-1); text-decoration: underline; min-height: 0; }
.btn.more { margin-top: 12px; width: 100%; }
@media (min-width: 761px) { .btn.more { width: auto; } }
.up { color: var(--up); }
.down { color: var(--down); }
.dim { color: var(--muted); }

.prose ol { padding-left: 22px; margin: 10px 0; }
.prose li { margin-bottom: 8px; }
.prose p { margin: 10px 0; }
.prose > * { max-width: 46em; }
.foot { color: var(--muted); font-size: 13px; text-align: center; padding: 12px 0 max(28px, env(safe-area-inset-bottom)); }

.map-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.btn {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--surface); cursor: pointer;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; min-height: 44px; white-space: nowrap;
}
.btn:hover { background: var(--page); }
.btn:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }
.map-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: end; }
.tank { font-size: 16px; color: var(--ink-2); display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.tank input {
  font: inherit; color: var(--ink); background: var(--surface); width: 4.5em;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px; min-height: 44px;
}
.map-head { flex-wrap: wrap; }
/* Phones: Savings | All prices across the top, then Tank and Near me. */
.map-tools { display: grid; grid-template-columns: 1fr auto; width: 100%; }
.map-tools #map-view { grid-column: 1 / -1; }
#map-view label { flex: 1; }
@media (min-width: 761px) {
  .map-head { flex-wrap: nowrap; }
  .map-tools { display: flex; flex-wrap: nowrap; flex: none; width: auto; }
  #map-view label { flex: none; }
}
.map-wrap { position: relative; margin-top: 12px; }
.map-float { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 500; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); }
.map-near {
  position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 500; width: max-content; max-width: calc(100% - 20px);
  margin: 0; padding: 8px 12px; border-radius: 8px; font-size: 15px; text-align: center;
  background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.map-near:empty { display: none; }
#map { height: 420px; border-radius: 8px; border: 1px solid var(--border); background: var(--grid); z-index: 0; }
@media (min-width: 761px) { #map { height: 480px; } }
/* Phones: shown while one finger drags across the map, which scrolls the page instead. */
#map.hint::after {
  content: "Use two fingers to move the map"; position: absolute; inset: 0; z-index: 1000;
  display: grid; place-items: center; pointer-events: none;
  background: rgba(0, 0, 0, 0.45); color: #fff; font-size: 17px; font-weight: 600;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9); }
}
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9); }
.leaflet-container { font: inherit; }
#map .leaflet-bar a, #map .leaflet-bar a:hover { background: var(--surface); color: var(--ink); border-bottom-color: var(--border); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 80%, transparent) !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--ink-2); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); }
.leaflet-popup-content { margin: 12px 16px; font-size: 15px; line-height: 1.45; }
.leaflet-popup-content a { display: inline-block; padding: 6px 0; font-weight: 600; }
.leaflet-popup-content b { font-size: 16px; }

/* Font set here, not inherited: leaflet.css loads later and would set Helvetica,
   while measure() sizes labels outside the map in the page font. */
.pin {
  transform: translate(-50%, -50%); width: max-content; font-family: var(--font-body);
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1;
  padding: 4px 7px; border-radius: 999px; white-space: nowrap;
  background: var(--surface); color: var(--ink-2); border: 1px solid var(--axis);
}
.pin.best { background: #0a6b0a; color: #fff; border-color: #fff; font-size: 14px; padding: 5px 9px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35); }
.pin .rank { opacity: 0.85; margin-right: 4px; }
.pin .brand { font-size: 0.8em; font-weight: 500; opacity: 0.7; margin-right: 3px; }
.pin.dot { width: 10px; height: 10px; padding: 0; background: var(--muted); border: 1.5px solid var(--surface); }
.pin .save { margin-left: 6px; padding-left: 6px; border-left: 1px solid rgba(255, 255, 255, 0.5); }
.pin.you { background: var(--series-1); border-color: #fff; width: 14px; height: 14px; padding: 0; }
