/* ---------------------------------------------------------------
   Fuel Finder Local
   --------------------------------------------------------------- */

:root {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-2: #f7faf8;
  --ink: #0f231d;
  --ink-soft: #344a43;
  --muted: #61736c;
  --line: #e2e9e5;
  --line-strong: #cfdad4;
  --brand: #0b3d2e;
  --brand-2: #12523d;
  --accent: #0f7b5f;
  --accent-soft: #e6f4ee;
  --accent-line: #bfe3d4;
  --warn: #9a5308;
  --warn-soft: #fdf2e4;
  --warn-line: #f2d7b3;
  --danger: #a02323;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 35, 29, .06), 0 8px 24px rgba(15, 35, 29, .06);
  --shadow-lg: 0 2px 6px rgba(15, 35, 29, .08), 0 18px 40px rgba(15, 35, 29, .10);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.015em; }
p { margin: 0; }
a { color: var(--accent); }
svg { display: block; }

.wrap {
  width: min(1080px, 100% - 2rem);
  margin-inline: auto;
}

.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-link {
  position: absolute; left: 1rem; top: -100px; z-index: 100;
  background: #fff; color: var(--ink); padding: .6rem 1rem;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: var(--shadow); text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 0; }

:focus-visible {
  outline: 3px solid #45c79f;
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- header ---------- */

.site-head {
  position: relative;
  background:
    radial-gradient(1100px 260px at 15% -40%, rgba(69, 199, 159, .30), transparent 70%),
    linear-gradient(160deg, var(--brand) 0%, #08281f 100%);
  color: #eaf6f1;
  padding: 2.1rem 0 4.4rem;
}

.head-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.brand { display: flex; gap: .9rem; align-items: flex-start; }

.brand-mark {
  display: grid; place-items: center;
  width: 42px; height: 42px; flex: 0 0 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .10);
  border: 1px solid rgba(255, 255, 255, .18);
  color: #8fe3c6;
}

.site-head h1 {
  font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.05rem);
  font-weight: 700;
  color: #fff;
}

.tagline {
  margin-top: .3rem;
  font-size: .92rem;
  color: rgba(234, 246, 241, .78);
  max-width: 46ch;
}

.head-meta { display: flex; gap: .5rem; align-items: center; padding-top: .25rem; }

.pill {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .78rem; font-weight: 600;
  padding: .34rem .7rem;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.pill-muted {
  background: rgba(255, 255, 255, .10);
  border-color: rgba(255, 255, 255, .16);
  color: rgba(240, 250, 246, .92);
}

.pill-ok {
  background: rgba(69, 199, 159, .16);
  border-color: rgba(69, 199, 159, .35);
  color: #b6f2dd;
}

.pill-warn {
  background: rgba(255, 190, 92, .16);
  border-color: rgba(255, 190, 92, .38);
  color: #ffdba8;
}

.pill-dot {
  width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 auto;
}

/* ---------- search card ---------- */

main { padding-bottom: 3rem; }

.search-card {
  position: relative;
  margin-top: -2.9rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
  padding: 1.15rem 1.15rem 1rem;
}

.search-form {
  display: flex;
  align-items: flex-end;
  gap: .8rem;
  flex-wrap: wrap;
}

.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field-grow { flex: 1 1 320px; }

.field > label {
  font-size: .78rem;
  font-weight: 650;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--muted);
}

.input-wrap { position: relative; display: flex; align-items: center; }

.input-icon {
  position: absolute;
  left: .8rem;
  color: var(--muted);
  pointer-events: none;
}

input[type="text"], select {
  font: inherit;
  font-size: .95rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: .62rem .75rem;
  min-height: 44px;
  width: 100%;
}

input[type="text"] { padding-left: 2.35rem; }

select {
  appearance: none;
  padding-right: 2rem;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%2361736c' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .8rem center;
  cursor: pointer;
}

input[type="text"]:hover, select:hover { border-color: #b9c8c1; }

input[type="text"]:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 123, 95, .14);
  outline: none;
}

.hint { font-size: .78rem; color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  font: inherit;
  font-weight: 650;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: .62rem 1.1rem;
  min-height: 44px;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(15, 123, 95, .35);
}
.btn-primary:hover { background: #0c6a51; }

.btn-ghost {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
}
.btn-ghost:hover { background: var(--surface-2); border-color: #b9c8c1; }

/* ---------- fuels + filters ---------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem 1.25rem;
  margin-top: 1.05rem;
  padding-top: .95rem;
  border-top: 1px dashed var(--line);
}

.fuel-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  background: var(--surface-2);
  padding: .25rem;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.fuel-tab {
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: .42rem .9rem;
  cursor: pointer;
  min-height: 38px;
  transition: background .15s ease, color .15s ease;
}

.fuel-tab:hover { background: #eaf1ed; }

.fuel-tab[aria-pressed="true"] {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 1px 3px rgba(11, 61, 46, .28);
}

.toggles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem .55rem;
  margin-left: auto;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .85rem;
  font-weight: 550;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: .32rem .7rem;
  cursor: pointer;
  user-select: none;
  min-height: 36px;
}

.toggle:hover { border-color: #b9c8c1; }

.toggle input {
  appearance: none;
  width: 15px; height: 15px;
  margin: 0;
  border: 1.5px solid #a8b8b1;
  border-radius: 4px;
  background: #fff;
  display: grid;
  place-content: center;
  cursor: pointer;
}

.toggle input::after {
  content: "";
  width: 8px; height: 8px;
  transform: scale(0);
  transition: transform .12s ease;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
  background: #fff;
}

.toggle input:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle input:checked::after { transform: scale(1); }

.toggle:has(input:checked) {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: #0a5c46;
}

.toggle-select { padding: .2rem .2rem .2rem .55rem; border: 0; background: transparent; }

.toggle-select select {
  min-height: 34px;
  border-radius: 999px;
  font-size: .85rem;
  padding: .25rem 2rem .25rem .7rem;
}

/* ---------- summary ---------- */

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: stretch;
  gap: .8rem;
  margin-top: 1.4rem;
}

.stat {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: .74rem;
  font-weight: 650;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  display: flex;
  align-items: baseline;
  gap: .18rem;
  margin-top: .2rem;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.stat-value .unit { font-size: .8rem; font-weight: 600; color: var(--muted); }

.stat-sub { font-size: .8rem; color: var(--muted); margin-top: .1rem; }

.stat-best .stat-value { color: var(--accent); }

.notice {
  font-size: .85rem;
  color: var(--warn);
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius-sm);
  padding: .55rem .75rem;
  margin-top: .8rem;
}

.notice strong { color: #7a4002; }

/* ---------- toolbar ---------- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.5rem 0 .75rem;
  flex-wrap: wrap;
}

.result-count { font-size: .9rem; color: var(--muted); }
.result-count strong { color: var(--ink); }

.view-toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: .2rem;
  gap: .15rem;
}

.view-btn {
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: .35rem .95rem;
  cursor: pointer;
  min-height: 34px;
}

.view-btn.is-active { background: var(--brand); color: #fff; }

/* ---------- results ---------- */

.results { min-height: 220px; }

.rows { display: flex; flex-direction: column; gap: .6rem; }

.row {
  display: grid;
  grid-template-columns: 2.1rem minmax(0, 1fr) 8.2rem 5.2rem 9rem auto;
  align-items: center;
  gap: .9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .8rem .95rem;
  box-shadow: var(--shadow);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.row:hover { border-color: var(--accent-line); box-shadow: var(--shadow-lg); }

.row.is-cheapest {
  border-color: var(--accent-line);
  background: linear-gradient(90deg, #f2fbf7 0%, #fff 55%);
  box-shadow: 0 0 0 1px var(--accent-line), var(--shadow);
}

.row.is-highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 123, 95, .18);
}

.rank {
  display: grid;
  place-items: center;
  width: 2.1rem; height: 2.1rem;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: .8rem;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.row.is-cheapest .rank {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.where { min-width: 0; }

.name {
  font-size: 1rem;
  font-weight: 660;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.addr {
  font-size: .84rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: .1rem;
}

.tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem; }

.tag {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--ink-soft);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .1rem .45rem;
  white-space: nowrap;
}

.tag-accent { background: var(--accent-soft); border-color: var(--accent-line); color: #0a5c46; }
.tag-warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }

.price { text-align: right; }

.ppl {
  display: inline-flex;
  align-items: baseline;
  gap: .05rem;
  font-size: 1.42rem;
  font-weight: 720;
  letter-spacing: -.025em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.row.is-cheapest .ppl { color: var(--accent); }

.ppl .p { font-size: .82rem; font-weight: 650; color: var(--muted); }

.age { font-size: .74rem; color: var(--muted); margin-top: .05rem; }
.age.is-stale { color: var(--warn); font-weight: 600; }

.dist {
  text-align: right;
  font-size: .85rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dist strong { font-size: 1.02rem; font-weight: 680; color: var(--ink); }

.status { font-size: .82rem; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: .32rem;
  font-size: .76rem;
  font-weight: 650;
  padding: .18rem .5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-open { background: var(--accent-soft); color: #0a5c46; border: 1px solid var(--accent-line); }
.badge-closed { background: #f4f4f5; color: #65656a; border: 1px solid #e4e4e7; }
.badge-unknown { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.hours { display: block; font-size: .74rem; color: var(--muted); margin-top: .2rem; }

.go {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .82rem;
  font-weight: 650;
  color: var(--accent);
  text-decoration: none;
  padding: .45rem .6rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.go:hover { background: var(--accent-soft); }

/* ---------- states ---------- */

.state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.state h3 { font-size: 1.1rem; margin-bottom: .35rem; }
.state p { color: var(--muted); font-size: .92rem; max-width: 52ch; margin-inline: auto; }
.state .btn { margin-top: 1rem; }

.state-icon {
  display: grid; place-items: center;
  width: 46px; height: 46px; margin: 0 auto .8rem;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
}

.code {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .85em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .1rem .4rem;
}

/* skeleton */

.skeleton {
  height: 76px;
  border-radius: var(--radius);
  background: linear-gradient(100deg, #eef2f0 30%, #f7faf8 50%, #eef2f0 70%);
  background-size: 220% 100%;
  animation: shimmer 1.25s infinite linear;
  border: 1px solid var(--line);
}

@keyframes shimmer {
  from { background-position: 120% 0; }
  to { background-position: -80% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  * { scroll-behavior: auto !important; }
}

/* ---------- map ---------- */

.map-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .55rem;
  box-shadow: var(--shadow);
}

.map { height: min(62vh, 560px); min-height: 340px; border-radius: 10px; z-index: 1; }

.map-note { font-size: .78rem; color: var(--muted); padding: .5rem .4rem 0; }

.leaflet-container { font-family: var(--font); background: #e8efeb; }

.price-pin {
  display: grid;
  place-items: center;
  min-width: 46px;
  height: 26px;
  padding: 0 .4rem;
  border-radius: 999px;
  background: #123f31;
  color: #fff;
  font-size: .74rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(15, 35, 29, .35);
  white-space: nowrap;
}

.price-pin.is-cheapest { background: var(--accent); transform: scale(1.12); z-index: 5; }
.price-pin.is-origin { background: #1d4ed8; }

.leaflet-popup-content { margin: .75rem .85rem; font-size: .88rem; line-height: 1.45; }
.leaflet-popup-content strong { display: block; font-size: .95rem; margin-bottom: .15rem; }
.leaflet-popup-content .pop-price { font-weight: 700; color: var(--accent); }

/* ---------- about / footer ---------- */

.about {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .88rem;
  max-width: 78ch;
}

.about h2 { font-size: 1rem; color: var(--ink); margin-bottom: .5rem; }
.about h2 + h3 { margin-top: 1.1rem; }
.about h3 { font-size: .9rem; color: var(--ink); margin-bottom: .25rem; }
.about p + p { margin-top: .6rem; }

/* Server-rendered first paint: replaced by app.js as soon as it runs. */
.snap-lead { color: var(--ink-soft); font-size: .9rem; margin-bottom: .75rem; }
.snap { list-style: none; display: grid; gap: .5rem; }
.snap li {
  display: grid;
  grid-template-columns: 1.6rem minmax(0, 1fr) auto;
  gap: .75rem;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .7rem .9rem;
}
.snap-rank {
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--line);
  color: var(--ink-soft);
  font-size: .78rem;
  font-weight: 600;
}
.snap-main { min-width: 0; display: grid; gap: .1rem; }
.snap-main strong { font-size: .92rem; color: var(--ink); }
.snap-meta { font-size: .78rem; color: var(--muted); }
.snap-price { font-weight: 700; font-size: 1.05rem; color: #0b6b4a; white-space: nowrap; }
.snap-price::after { content: ' /l'; font-size: .7rem; color: var(--muted); font-weight: 500; }

.site-foot {
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 1.4rem 0;
  color: var(--muted);
  font-size: .82rem;
}

.foot-inner { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.foot-fine { color: #8a9a94; }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .row {
    grid-template-columns: 2.1rem minmax(0, 1fr) auto;
    grid-template-areas:
      "rank where price"
      "rank where dist"
      "rank status go";
    row-gap: .35rem;
    align-items: start;
    padding: .85rem .9rem;
  }

  .rank { grid-area: rank; align-self: start; margin-top: .1rem; }
  .where { grid-area: where; }
  .price { grid-area: price; text-align: right; align-self: start; }
  .dist { grid-area: dist; text-align: right; font-size: .8rem; }
  .status { grid-area: status; display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
  .hours { margin-top: 0; }
  .go { grid-area: go; justify-self: end; }

  .toggles { margin-left: 0; }
  .search-card { padding: 1rem; }
}

@media (max-width: 560px) {
  body { font-size: 15px; }
  .site-head { padding: 1.6rem 0 3.6rem; }
  .search-card { margin-top: -2.4rem; }
  .field-grow { flex-basis: 100%; }
  .search-form { gap: .65rem; }
  .search-form .field:not(.field-grow) { flex: 1 1 44%; }
  .search-form .btn { flex: 1 1 100%; }
  .fuel-tabs { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .fuel-tab { flex: 0 0 auto; }
  .stat-value { font-size: 1.3rem; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .name { white-space: normal; }
  .addr { white-space: normal; }
}

@media (prefers-color-scheme: dark) {
  /* Keep the light design: forecourt prices are easier to read on white. */
}
