/* ── Tokens ─────────────────────────────────────────── */
:root {
  --bg:           #F0EEE6;
  --sort-bg:      #E8E7DD;
  --card-bg:      #ffffff;
  --border:       #CCCBBF;
  --border-light: #E0DED6;
  --text:         #282828;
  --text-mid:     #555555;
  --text-muted:   #888888;
  --text-subtle:  #A6A597;
  --green:        #79A02E;
  --green-top:    #EBFACD;
  --red:          #F62C36;
  --blue:         #29A4FF;
  --blue-nearest: #29ABE2;
  --font:         'Inter', sans-serif;
  --mono:         'DM Mono', monospace;
  --gps-active:   #79A02E;
  --gps-inactive: #A6A597;
}

/* ── Reset ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
button { cursor: pointer; font-family: var(--font); }

/* ── App shell ──────────────────────────────────────── */
.app { display: flex; flex-direction: column; min-height: 560px; }

/* ── Header ─────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 10px;
}
.header-logo { height: 28px; width: auto; display: block; }
.settings-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.15s;
}
.settings-btn:hover { color: var(--text); }

/* ── Hero ───────────────────────────────────────────── */
.hero { padding: 8px 20px 18px; }
.hero h1 {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* ── Controls ───────────────────────────────────────── */
.controls { padding: 0 20px 16px; display: flex; flex-direction: column; gap: 14px; }

/* ── Search row ─────────────────────────────────────── */
.search-row { display: flex; align-items: center; gap: 10px; }

.search-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--sort-bg);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 0 10px 0 4px;
  transition: border-color 0.15s, background 0.15s;
}
.search-wrap:focus-within {
  border-color: var(--text);
  background: #fff;
}

/* GPS button — sits inside the pill */
.gps-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 6px;
  flex-shrink: 0;
  border-radius: 50%;
  transition: color 0.2s;
  color: var(--gps-active); /* green by default (GPS mode) */
}
.gps-btn.manual { color: var(--gps-inactive); }

.search-input {
  flex: 1;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  padding: 11px 0;
}
.search-input::placeholder { color: var(--text-muted); }

.clear-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0;
  flex-shrink: 0;
  transition: color 0.15s;
}
.clear-btn svg { width: 10px; height: 10px; }
.clear-btn:hover { color: var(--text); }

.search-btn {
  background: none;
  border: none;
  color: var(--text-mid);
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
  flex-shrink: 0;
}
.search-btn:hover { color: var(--text); }

/* ── Radius slider ──────────────────────────────────── */
.slider-wrap { display: flex; flex-direction: column; gap: 0; }

.slider-track { position: relative; padding: 20px 2px 26px; }

/* Native range — hidden track, custom thumb via CSS */
.slider {
  -webkit-appearance: none;
  width: 100%;
  height: 2px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  display: block;
}

/* Thumb: white square, 50% opacity, rounded corners, big dark dot inside */
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background-color: rgba(255,255,255,0.5);
  border: 1.5px solid var(--border);
  box-shadow: 0 1px 5px rgba(0,0,0,0.12);
  cursor: pointer;
  background-image: radial-gradient(circle, #282828 38%, transparent 39%);
  background-size: 22px 22px;
  background-repeat: no-repeat;
  background-position: center;
  transition: box-shadow 0.12s;
}
.slider::-webkit-slider-thumb:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.18); }
.slider::-moz-range-thumb {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background-color: rgba(255,255,255,0.5);
  border: 1.5px solid var(--border);
  cursor: pointer;
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 6px 2px 0;
}

.no-stations-nearby p {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
}

/* ── Results outer wrapper ──────────────────────────── */
.results-outer {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 10px 0;  /* 10px side margins → cream bg peeks either side */
}

/* ── Sort bar ───────────────────────────────────────── */
.sort-bar {
  background: var(--sort-bg);
  border-radius: 12px 12px 0 0;
  display: flex;
  align-items: stretch;
  padding: 0 4px;
  border: 1px solid var(--border-light);
  border-bottom: none;
}

.sort-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 14px 6px 11px;
  background: none;
  border: none;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-subtle);
  transition: color 0.15s;
}
.sort-btn:hover { color: var(--text-mid); }
.sort-btn.active { color: var(--text); font-weight: 700; }

.sort-icon { height: 22px; width: auto; display: block; }

.sort-divider {
  width: 1px;
  background: var(--border-light);
  margin: 10px 0;
  flex-shrink: 0;
}

/* ── Results card ───────────────────────────────────── */
.results-card {
  background: var(--card-bg);
  border-radius: 0 0 12px 12px;
  border: 1px solid var(--border-light);
  border-top: none;
  overflow: hidden;
  flex: 1;
}

/* ── States ─────────────────────────────────────────── */
.hidden { display: none !important; }

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px 44px;
  gap: 12px;
}
.state-text {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}
.state-subtext {
  font-size: 11px;
  color: var(--text-subtle);
  text-align: center;
  margin-top: -4px;
}
.error-icon { font-size: 24px; opacity: 0.5; }
.empty-icon { width: 28px; height: auto; opacity: 0.5; }

.pulse-drop {
  width: 30px;
  height: 36px;
  animation: dropPulse 1.6s ease-in-out infinite;
}
.pulse-drop svg { width: 100%; height: 100%; }
@keyframes dropPulse {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.9; }
  50%       { transform: translateY(-6px) scale(0.93); opacity: 0.4; }
}

.retry-btn {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 9px 24px;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: 999px;
  margin-top: 4px;
  transition: opacity 0.15s;
}
.retry-btn:hover { opacity: 0.8; }

/* ── Station list ───────────────────────────────────── */
.station-list {
  list-style: none;
  max-height: 340px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.station-list::-webkit-scrollbar { width: 3px; }
.station-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.station-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.1s;
  animation: fadeUp 0.18s ease both;
}
.station-item:last-child { border-bottom: none; }
.station-item:hover { background: rgba(0,0,0,0.02); }

/* Top result — green highlight */
.station-item.top-result { background: var(--green-top); }
.station-item.top-result:hover { background: #e2f5be; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.station-item:nth-child(1) { animation-delay: 0.00s; }
.station-item:nth-child(2) { animation-delay: 0.04s; }
.station-item:nth-child(3) { animation-delay: 0.07s; }
.station-item:nth-child(4) { animation-delay: 0.10s; }
.station-item:nth-child(5) { animation-delay: 0.13s; }
.station-item:nth-child(6) { animation-delay: 0.16s; }

/* Rank */
.rank {
  font-size: 13px;
  font-weight: 600;
  width: 16px;
  text-align: center;
  color: var(--text-subtle);
  flex-shrink: 0;
}
.rank.top { color: var(--text); }

/* Station info */
.station-info { flex: 1; min-width: 0; }

.station-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: nowrap;
}
.station-addr {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.station-dist {
  font-size: 12px;
  font-weight: 500;
  color: var(--green);
  margin-top: 3px;
}

/* Best badge */
.best-badge-img {
  height: 17px;
  width: auto;
  margin-left: 7px;
  vertical-align: middle;
  position: relative;
  top: -1px;
  flex-shrink: 0;
}

/* Fav button */
.fav-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  flex-shrink: 0;
  padding: 0;
  transition: transform 0.15s;
}
.fav-btn img { width: 14px; height: auto; display: block; }
.fav-btn:hover { transform: scale(1.15); }
.fav-btn.pulse { animation: favPop 0.26s cubic-bezier(0.36,0.07,0.19,0.97) both; }
@keyframes favPop {
  0%  { transform: scale(1); }
  40% { transform: scale(1.4); }
  70% { transform: scale(0.88); }
  100%{ transform: scale(1); }
}

/* Price block — both petrol + diesel stacked */
.station-price { text-align: right; flex-shrink: 0; min-width: 100px; }

.price-row {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 4px;
  line-height: 1.15;
}
.price-val {
  font-family: var(--mono);
  font-size: 21px;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.price-val.petrol { color: var(--green); }
.price-val.diesel { color: var(--text); }
.price-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  padding-bottom: 2px;
}
.no-price {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-subtle);
}

/* ── Data footer ────────────────────────────────────── */
.data-footer {
  text-align: center;
  padding: 7px 16px 9px;
  border-top: 1px solid var(--border-light);
}
.footer-link {
  font-size: 10px;
  color: var(--text-subtle);
  text-decoration: underline;
  text-underline-offset: 2px;
  background: none;
  border: none;
  letter-spacing: 0.03em;
  padding: 0;
  transition: color 0.15s;
}
.footer-link:hover { color: var(--text-muted); }

/* ── Info popup ─────────────────────────────────────── */
.info-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  background: rgba(0,0,0,0.28);
}
.info-popup {
  width: 100%;
  background: #fff;
  border-radius: 14px 14px 0 0;
  border-top: 1px solid var(--border);
  padding: 16px 18px 20px;
  animation: slideUp 0.2s ease both;
}
@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.info-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.info-title { font-size: 14px; font-weight: 700; color: var(--text); }
.info-close {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--text-muted);
  transition: color 0.15s;
}
.info-close svg { width: 12px; height: 12px; }
.info-close:hover { color: var(--text); }
.info-body { display: flex; flex-direction: column; gap: 9px; }
.info-body p { font-size: 11px; line-height: 1.6; color: var(--text-mid); }
.info-disclaimer {
  font-style: italic;
  color: var(--text-muted) !important;
  font-size: 10px !important;
  padding-top: 6px;
  border-top: 1px solid var(--border-light);
}

/* ── PWA overrides ──────────────────────────────────── */
body {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* Safe area insets for notched phones */
.header {
  padding-top: max(18px, env(safe-area-inset-top));
}
.results-outer {
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

/* Station list taller on mobile */
.station-list {
  max-height: calc(100dvh - 420px);
  min-height: 180px;
}

/* Slightly larger touch targets on mobile */
.sort-btn { padding: 16px 6px 12px; }
.fav-btn  { width: 36px; height: 36px; }
.gps-btn  { width: 40px; height: 40px; }
