@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
  /* ---- typography (Squadix tokens) ---- */
  --font-sans: 'Space Grotesk', 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --text-xs: 12px;
  --text-sm: 15px;
  --text-md: 16px;
  --text-lg: 17px;
  --text-xl: 23px;
  --text-2xl: 25px;
  --lh-tight: 1.1;
  --lh-normal: 1.35;
  --lh-relaxed: 1.45;
  --tracking-caps: 0.08em;

  /* ---- spacing ---- */
  --sp-1: 4px;
  --sp-2: 6px;
  --sp-3: 8px;
  --sp-4: 10px;
  --sp-5: 12px;
  --sp-6: 14px;
  --sp-7: 16px;
  --sp-8: 20px;
  --sp-9: 24px;
  --sp-10: 18px;
  --sp-11: 28px;
  --sp-12: 32px;

  /* ---- radii ---- */
  --r-6: 6px;
  --r-8: 8px;
  --r-10: 10px;
  --r-12: 12px;
  --r-14: 14px;
  --r-16: 16px;
  --r-round: 999px;

  /* ---- neutral palette (Squadix) ---- */
  --black: #040405;
  --carbon-black: #202225;
  --charcoal-blue: #40444b;
  --grey-olive: #8e9297;
  --silver: #dcddde;
  --parchment: #f2f3f5;

  --c-bg: var(--black);
  --c-surface-1: var(--carbon-black);
  --c-surface-2: #2b2d31;
  --c-border: #2f3136;
  --c-border-soft: #36393f;
  --c-field-bg: var(--c-surface-2);
  --c-field-border: #4f545c;

  --c-text: var(--silver);
  --c-text-strong: var(--parchment);
  --c-text-muted: var(--grey-olive);
  --c-text-faint: #72767d;

  /* ---- accent (Squadix home-hub) ---- */
  --c-home-hub: #4a589a;
  --c-accent: var(--c-home-hub);
  --c-accent-hover: color-mix(in srgb, var(--c-home-hub) 88%, #ffffff 12%);
  --c-accent-soft: color-mix(in srgb, var(--c-home-hub) 22%, transparent);
  --c-accent-weak: color-mix(in srgb, var(--c-home-hub) 16%, transparent);
  --c-accent-border: color-mix(in srgb, var(--c-home-hub) 46%, transparent);

  /* ---- status colors (Squadix) ---- */
  --c-success: #3ba55d;
  --c-success-soft-bg: color-mix(in srgb, var(--c-success) 20%, transparent);
  --c-success-soft-border: color-mix(in srgb, var(--c-success) 40%, transparent);
  --c-success-soft-text: #bff7d2;
  --c-danger: #ed4245;
  --c-danger-soft-bg: color-mix(in srgb, var(--c-danger) 16%, transparent);
  --c-danger-soft-border: color-mix(in srgb, var(--c-danger) 32%, transparent);
  --c-danger-soft-text: #ffb4b4;
  --c-warning: #faa61a;

  --c-overlay-35: rgba(0, 0, 0, 0.35);
  --c-white-04: rgba(255, 255, 255, 0.04);
  --c-white-08: rgba(255, 255, 255, 0.08);

  /* ---- motion ---- */
  --dur-fast: 120ms;
  --dur-med: 180ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }

.btn, .station-pick, .fuel-grid button, .toggle button, details summary {
  touch-action: manipulation;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--c-bg);
  color: var(--c-text);
  padding-bottom: var(--sp-9);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

header {
  padding: calc(var(--sp-8) + env(safe-area-inset-top)) var(--sp-7) var(--sp-5);
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(20px);
}

header h1 {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: var(--fw-bold);
  letter-spacing: -0.01em;
  color: var(--c-text-strong);
}

header p {
  margin: var(--sp-1) 0 0;
  color: var(--c-text-muted);
  font-size: var(--text-xs);
}

header a {
  color: var(--c-text-muted);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}

header a:hover { color: var(--c-text); }

.activity-counter {
  display: block;
  border: none;
  background: transparent;
  padding: 0;
  font-family: var(--font-sans);
  text-align: left;
  cursor: pointer;
  margin: 0;
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  color: var(--c-warning);
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity var(--dur-med) var(--ease-out), max-height var(--dur-med) var(--ease-out),
              margin var(--dur-med) var(--ease-out);
}

.activity-counter.show {
  opacity: 1;
  max-height: 20px;
  margin-top: var(--sp-1);
}

.activity-counter.show:hover,
.activity-counter.show:active {
  color: var(--c-text-strong);
}

.feed-list {
  max-height: none;
  border-top: none;
  padding-top: 0;
}

.feed-item {
  cursor: pointer;
  padding: var(--sp-2);
  margin: 0 calc(-1 * var(--sp-2)) var(--sp-2);
  border-radius: var(--r-8);
  transition: background-color var(--dur-fast) var(--ease-out);
}

.feed-item:hover,
.feed-item:active {
  background: var(--c-white-04);
}

.feed-item-station {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: var(--fw-semibold);
  color: var(--c-text-strong);
}

.feed-item-detail {
  margin: var(--sp-1) 0 0 calc(8px + var(--sp-2));
  color: var(--c-text-muted);
  font-size: var(--text-xs);
}

main {
  padding: var(--sp-5) var(--sp-7);
  max-width: 560px;
  margin: 0 auto;
}

.actions {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-7);
  max-width: 560px;
  margin: 0 auto;
}

.btn {
  display: block;
  width: 100%;
  padding: var(--sp-5) var(--sp-7);
  border: none;
  border-radius: var(--r-8);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  color: var(--c-text-strong);
  background: var(--c-accent);
  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}

.btn:hover {
  background: var(--c-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 14px var(--c-overlay-35);
}

.btn.secondary {
  background: var(--c-surface-1);
  color: var(--c-text);
  border: 1px solid var(--c-border);
}

.btn.secondary:hover {
  background: var(--c-surface-2);
  border-color: var(--c-border-soft);
}

.btn.danger {
  background: var(--c-danger);
}

.btn.danger:hover {
  background: #c03537;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.station-card {
  background: var(--c-surface-1);
  border-radius: var(--r-14);
  padding: var(--sp-6);
  margin-bottom: var(--sp-4);
  border: 1px solid var(--c-border);
  transition: border-color var(--dur-med) var(--ease-out);
}

.station-card:hover {
  border-color: var(--c-accent-border);
}

.station-card h3 {
  margin: 0 0 2px;
  font-size: var(--text-lg);
  font-weight: var(--fw-semibold);
  color: var(--c-text-strong);
}

.station-card .address {
  color: var(--c-text-muted);
  font-size: var(--text-xs);
  margin: 0 0 var(--sp-5);
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.pill {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  padding: var(--sp-1) var(--sp-5);
  border-radius: var(--r-round);
  border: 1px solid transparent;
}

.pill.available {
  background: var(--c-success-soft-bg);
  border-color: var(--c-success-soft-border);
  color: var(--c-success-soft-text);
}

.pill.empty {
  background: var(--c-danger-soft-bg);
  border-color: var(--c-danger-soft-border);
  color: var(--c-danger-soft-text);
}

.pill.unknown {
  background: var(--c-white-04);
  border-color: var(--c-white-08);
  color: var(--c-text-muted);
}

.station-pick {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--c-surface-1);
  border: 1px solid var(--c-border);
  border-radius: var(--r-12);
  padding: var(--sp-6);
  margin-bottom: var(--sp-3);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--c-text);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}

.station-pick:hover {
  border-color: var(--c-accent-border);
  background: var(--c-surface-2);
}

.fuel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  margin-bottom: var(--sp-7);
}

.fuel-grid button {
  padding: var(--sp-7) var(--sp-3);
  border-radius: var(--r-10);
  border: 1px solid var(--c-border);
  background: var(--c-surface-1);
  color: var(--c-text);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}

.fuel-grid button:hover { border-color: var(--c-border-soft); }

.fuel-grid button.selected {
  border-color: var(--c-accent-border);
  background: var(--c-accent-weak);
  color: var(--c-text-strong);
}

.toggle {
  display: flex;
  gap: var(--sp-3);
  margin-bottom: var(--sp-7);
}

.toggle button {
  flex: 1;
  padding: var(--sp-6);
  border-radius: var(--r-10);
  border: 1px solid var(--c-border);
  background: var(--c-surface-1);
  color: var(--c-text);
  font-family: var(--font-sans);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.toggle button.selected.available {
  background: var(--c-success-soft-bg);
  color: var(--c-success-soft-text);
  border-color: var(--c-success-soft-border);
}

.toggle button.selected.empty {
  background: var(--c-danger-soft-bg);
  color: var(--c-danger-soft-text);
  border-color: var(--c-danger-soft-border);
}

.card-preview {
  width: 100%;
  border-radius: var(--r-12);
  margin-bottom: var(--sp-7);
  border: 1px solid var(--c-border);
}

.notice {
  background: color-mix(in srgb, var(--c-warning) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--c-warning) 32%, transparent);
  color: var(--c-text);
  border-radius: var(--r-10);
  padding: var(--sp-5) var(--sp-6);
  font-size: var(--text-xs);
  margin-bottom: var(--sp-5);
}

.error {
  background: var(--c-danger-soft-bg);
  border: 1px solid var(--c-danger-soft-border);
  color: var(--c-danger-soft-text);
  border-radius: var(--r-10);
  padding: var(--sp-5) var(--sp-6);
  font-size: var(--text-xs);
  margin-bottom: var(--sp-5);
}

.center-msg {
  text-align: center;
  color: var(--c-text-muted);
  padding: var(--sp-12) var(--sp-7);
  font-size: var(--text-sm);
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: var(--text-xs);
}

table th, table td {
  text-align: left;
  padding: var(--sp-3);
  border-bottom: 1px solid var(--c-border);
  color: var(--c-text);
}

table th {
  color: var(--c-text-muted);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  font-size: var(--text-xs);
}

input, select, textarea {
  width: 100%;
  padding: var(--sp-4) var(--sp-5);
  background: var(--c-field-bg);
  border: 1px solid var(--c-field-border);
  border-radius: var(--r-8);
  outline: none;
  color: var(--c-text);
  font-family: var(--font-sans);
  /* 16px, not --text-sm: iOS Safari auto-zooms on focus for inputs under 16px */
  font-size: var(--text-md);
  margin-bottom: var(--sp-4);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

textarea {
  resize: vertical;
  min-height: 64px;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--c-accent-border);
  box-shadow: 0 0 0 2px var(--c-accent-weak);
}

label {
  font-size: var(--text-xs);
  color: var(--c-text-muted);
  display: block;
  margin-bottom: var(--sp-1);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
}

h3 {
  color: var(--c-text-strong);
  font-size: var(--text-lg);
  font-weight: var(--fw-semibold);
}

details summary {
  color: var(--c-text-muted);
  cursor: pointer;
  padding: var(--sp-3) 0;
  font-size: var(--text-sm);
}

details summary:hover { color: var(--c-text); }

.copy-link {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}

.copy-link input {
  margin-bottom: 0;
  font-size: var(--text-xs);
}

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

body.map-page {
  padding-bottom: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

body.map-page header {
  flex-shrink: 0;
}

#map {
  flex: 1;
  min-height: 0;
  background: var(--c-surface-1);
}

/* ---- custom Leaflet marker ---- */

.map-pin {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: var(--r-round);
  border: 3px solid var(--c-bg);
  box-shadow: 0 2px 8px var(--c-overlay-35);
}

.map-pin-available { background: var(--c-success); }
.map-pin-empty { background: var(--c-danger); }
.map-pin-unknown { background: var(--c-text-faint); }

/* ---- Leaflet chrome theming ---- */

.leaflet-container {
  font-family: var(--font-sans);
  background: var(--c-surface-1);
}

.leaflet-touch .leaflet-bar a {
  width: 40px;
  height: 40px;
  line-height: 40px;
  font-size: 20px;
}

.leaflet-control-attribution {
  background: var(--c-overlay-35) !important;
  color: var(--c-text-faint) !important;
}

.leaflet-control-attribution a {
  color: var(--c-text-muted) !important;
}

.popup-empty {
  margin: var(--sp-5) 0 0;
  font-size: var(--text-xs);
  color: var(--c-text-faint);
}

.popup-reports {
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--c-border);
  max-height: 180px;
  overflow-y: auto;
}

.popup-report {
  margin-bottom: var(--sp-4);
}

.popup-report-line {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-xs);
  color: var(--c-text);
}

.popup-report-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--r-round);
  flex-shrink: 0;
}

.popup-report-dot-available { background: var(--c-success); }
.popup-report-dot-empty { background: var(--c-danger); }

.popup-report-time {
  margin-left: auto;
  color: var(--c-text-faint);
}

.verified-badge {
  color: var(--c-success);
  font-weight: var(--fw-semibold);
  flex-shrink: 0;
}

.popup-report-comment {
  margin: var(--sp-1) 0 0 calc(8px + var(--sp-2));
  color: var(--c-text-muted);
  font-size: var(--text-xs);
  font-style: italic;
}

/* ---- bottom sheet ---- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-med) var(--ease-out);
  z-index: 900;
}

.sheet-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 82vh;
  max-height: 82dvh;
  display: flex;
  flex-direction: column;
  background: var(--c-surface-1);
  border-top: 1px solid var(--c-border);
  border-radius: var(--r-16) var(--r-16) 0 0;
  box-shadow: 0 -12px 32px var(--c-overlay-35);
  transform: translateY(100%);
  transition: transform 260ms var(--ease-out);
  z-index: 950;
  padding-bottom: env(safe-area-inset-bottom);
}

.sheet.open {
  transform: translateY(0);
}

.sheet-handle {
  flex-shrink: 0;
  width: 36px;
  height: 4px;
  border-radius: var(--r-round);
  background: var(--c-border-soft);
  margin: var(--sp-3) auto;
}

.sheet-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--sp-8) var(--sp-7) var(--sp-7);
  position: relative;
}

.sheet-content .address {
  color: var(--c-text-muted);
  font-size: var(--text-xs);
  margin: 0 0 var(--sp-4);
}

.sheet-close {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-5);
  width: 32px;
  height: 32px;
  border-radius: var(--r-round);
  border: none;
  background: var(--c-surface-2);
  color: var(--c-text-muted);
  font-size: var(--text-md);
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.sheet-close:hover {
  background: var(--c-border-soft);
  color: var(--c-text);
}

/* ---- tap-to-report pills ---- */

.pill-hint {
  font-size: var(--text-xs);
  color: var(--c-text-muted);
  margin: 0 0 var(--sp-4);
}

.pills-tap {
  margin-bottom: var(--sp-2);
}

.pill-tap {
  font-family: var(--font-sans);
  padding: var(--sp-5) var(--sp-6);
  font-size: var(--text-sm);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: transform 150ms var(--ease-out), background-color 150ms var(--ease-out),
              border-color 150ms var(--ease-out), box-shadow 150ms var(--ease-out);
}

.pill-pressed {
  transform: scale(0.9);
}

@keyframes pillBounce {
  0% { transform: scale(0.9); }
  50% { transform: scale(1.15); }
  75% { transform: scale(0.97); }
  100% { transform: scale(1); }
}

.pill-success, .pill-fail {
  animation: pillBounce 500ms var(--ease-out);
}

.pill-success { box-shadow: 0 0 0 3px var(--c-success-soft-border); }
.pill-fail { box-shadow: 0 0 0 3px var(--c-danger-soft-border); }

/* ---- tap feedback banner ---- */

.tap-feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  max-height: 0;
  margin: 0;
  padding: 0 var(--sp-5);
  border-radius: var(--r-10);
  font-size: var(--text-xs);
  opacity: 0;
  overflow: hidden;
  transition: max-height 220ms var(--ease-out), opacity 180ms var(--ease-out),
              margin 220ms var(--ease-out), padding 220ms var(--ease-out);
}

.tap-feedback.show {
  max-height: 120px;
  margin: var(--sp-3) 0 var(--sp-5);
  padding: var(--sp-4) var(--sp-5);
  opacity: 1;
}

.tap-feedback-ok {
  background: var(--c-success-soft-bg);
  border: 1px solid var(--c-success-soft-border);
  color: var(--c-success-soft-text);
}

.tap-feedback-error {
  background: var(--c-danger-soft-bg);
  border: 1px solid var(--c-danger-soft-border);
  color: var(--c-danger-soft-text);
}

.tap-share-btn {
  width: auto;
  flex-shrink: 0;
  padding: var(--sp-2) var(--sp-5);
  font-size: var(--text-xs);
}

.tap-feedback-text {
  flex: 1;
  min-width: 0;
}

.tap-feedback-sub {
  margin-top: 2px;
  opacity: 0.75;
}

/* ---- wow-effect: particle burst on tap ---- */

.particle {
  position: fixed;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1200;
  transform: translate(-50%, -50%);
  animation: particleBurst 550ms var(--ease-out) forwards;
}

.particle-available { background: var(--c-success); box-shadow: 0 0 6px var(--c-success); }
.particle-empty { background: var(--c-danger); box-shadow: 0 0 6px var(--c-danger); }

@keyframes particleBurst {
  0% {
    transform: translate(-50%, -50%) translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) translate(var(--dx), var(--dy)) scale(0.3);
    opacity: 0;
  }
}

/* ---- wow-effect: ripple on the map marker ---- */

.map-ripple {
  position: fixed;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  margin-top: -8px;
  border-radius: 50%;
  border: 2px solid;
  pointer-events: none;
  /* Above .sheet (950) — the ripple must stay visible even if it lands
     near the sheet's edge; JS also clamps its position into the visible strip. */
  z-index: 1000;
  animation: mapRippleExpand 700ms var(--ease-out) forwards;
}

.map-ripple-available { border-color: var(--c-success); }
.map-ripple-empty { border-color: var(--c-danger); }

@keyframes mapRippleExpand {
  0% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(5); opacity: 0; }
}

/* ---- wow-effect: marker "breathe" pulse after a report ----
   Animate the inner .map-pin span, not the Leaflet wrapper div itself —
   Leaflet positions markers via an inline transform on that wrapper,
   and an animation on the same property would fight it and mis-place the pin. */

@keyframes markerBreathe {
  0%, 100% { transform: scale(1); box-shadow: 0 2px 8px var(--c-overlay-35); }
  50% { transform: scale(1.35); box-shadow: 0 0 0 8px var(--c-overlay-35), 0 2px 8px var(--c-overlay-35); }
}

.marker-breathe .map-pin {
  animation: markerBreathe 700ms ease-in-out 3;
}

/* ---- admin coordinate picker ---- */

.pick-map {
  width: 100%;
  height: 240px;
  border-radius: var(--r-8);
  border: 1px solid var(--c-field-border);
  margin-bottom: var(--sp-4);
}
