/* ===========================================
   Free Food Map · Custom styles
   Built on top of Tailwind. These are the
   "soul" of the design — the things Tailwind
   utilities alone can't do well.
   =========================================== */

:root {
  --crust: #f4a52a;
  --ember: #e84c1c;
  --ink: #0b1220;
  --cream: #fdf8f0;
  --sage: #94a89a;
}

* { -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }
body {
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Selection */
::selection { background: var(--crust); color: var(--ink); }

/* ---------- Chips (filter) ---------- */
.chip {
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.7);
  font-size: 0.8125rem;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border-color: rgba(255,255,255,0.2);
}
.chip.active {
  background: var(--crust);
  color: var(--ink);
  border-color: var(--crust);
}

/* ---------- Leaflet popup overrides ---------- */
.leaflet-popup-content-wrapper {
  background: var(--ink);
  color: #fff;
  border-radius: 0.75rem;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.leaflet-popup-tip { background: var(--ink); }
.leaflet-popup-content {
  margin: 0;
  padding: 0;
  min-width: 240px;
}
.leaflet-popup-close-button { color: rgba(255,255,255,0.5) !important; }
.leaflet-popup-close-button:hover { color: var(--crust) !important; }

.popup-inner { padding: 1rem 1.1rem 1.1rem; }
.popup-type {
  display: inline-block;
  font-size: 0.65rem;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--crust);
  margin-bottom: 0.4rem;
}
.popup-name {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.3;
  margin-bottom: 0.3rem;
}
.popup-city {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.5);
  margin-bottom: 0.6rem;
}
.popup-desc {
  font-size: 0.825rem;
  color: rgba(255,255,255,0.75);
  line-height: 1.5;
  margin-bottom: 0.75rem;
}
.popup-meta {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.55);
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 0.6rem;
  margin-top: 0.5rem;
}
.popup-meta div { margin-top: 0.25rem; }
.popup-meta a { color: var(--crust); text-decoration: underline; }
.popup-cta {
  display: inline-block;
  margin-top: 0.7rem;
  padding: 0.45rem 0.85rem;
  background: var(--crust);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 0.4rem;
  text-decoration: none;
  transition: background 0.2s;
}
.popup-cta:hover { background: #f9b13d; }

/* Custom map marker */
.food-marker {
  width: 32px; height: 32px;
  background: var(--crust);
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink); font-weight: 700; font-size: 14px;
  transition: transform 0.2s;
}
.food-marker:hover { transform: scale(1.2); z-index: 1000; }
.food-marker.story {
  background: var(--ember);
  width: 40px; height: 40px;
  font-size: 18px;
  border-width: 4px;
  animation: breathe 3s ease-in-out infinite;
}

/* Map list side panel */
.map-list-item {
  padding: 0.75rem 0.9rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 0.6rem;
  cursor: pointer;
  transition: all 0.2s;
}
.map-list-item:hover {
  background: rgba(255,255,255,0.07);
  border-color: var(--crust);
  transform: translateX(2px);
}
.map-list-item.active {
  background: rgba(244, 165, 42, 0.1);
  border-color: var(--crust);
}
.map-list-name { font-size: 0.85rem; font-weight: 600; color: #fff; line-height: 1.3; }
.map-list-city { font-size: 0.7rem; color: rgba(255,255,255,0.5); margin-top: 0.15rem; font-family: 'JetBrains Mono', monospace; }

/* ---------- Video cards ---------- */
.video-card {
  transition: transform 0.3s, box-shadow 0.3s;
  border-radius: 0.875rem;
  padding: 0.5rem;
  background: rgba(0,0,0,0.02);
}
.video-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(0,0,0,0.08);
}
.video-card iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---------- Step cards ---------- */
.step-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 1rem;
  padding: 1.5rem;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}
.step-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--crust), var(--ember));
  opacity: 0;
  transition: opacity 0.3s;
}
.step-card:hover { background: rgba(255,255,255,0.05); transform: translateY(-2px); }
.step-card:hover::before { opacity: 1; }

.tip-row {
  display: flex; gap: 1rem;
  padding: 1.1rem 1.25rem;
  background: rgba(255,255,255,0.03);
  border-left: 3px solid var(--ember);
  border-radius: 0 0.5rem 0.5rem 0;
}

/* ---------- Form ---------- */
form input[type="checkbox"] {
  accent-color: var(--crust);
  width: 1.1rem; height: 1.1rem;
}

/* ---------- Leaflet attribution small ---------- */
.leaflet-control-attribution {
  background: rgba(11, 18, 32, 0.7) !important;
  color: rgba(255,255,255,0.5) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--crust) !important; }
.leaflet-control-zoom a {
  background: var(--ink) !important;
  color: #fff !important;
  border-color: rgba(255,255,255,0.1) !important;
}
.leaflet-control-zoom a:hover { background: var(--crust) !important; color: var(--ink) !important; }

/* ---------- Scrollbar (for side panel) ---------- */
#map-list::-webkit-scrollbar { width: 6px; }
#map-list::-webkit-scrollbar-track { background: rgba(255,255,255,0.02); }
#map-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
#map-list::-webkit-scrollbar-thumb:hover { background: var(--crust); }

/* ---------- Reveal on scroll (JS opt-in) ---------- */
/* By default, content is visible. Only hide when <html> has the .js class,
   which is set by app.js on load. This way headless / no-JS users see
   the page fully rendered. */
html.js .reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
html.js .reveal.visible { opacity: 1 !important; transform: translateY(0) !important; }

/* ---------- Form success state ---------- */
.form-success {
  text-align: center;
  padding: 2rem;
  background: linear-gradient(135deg, rgba(244, 165, 42, 0.1), rgba(232, 76, 28, 0.05));
  border: 1px solid var(--crust);
  border-radius: 1rem;
}

/* ---------- Ambassador role cards (the network) ---------- */
.amb-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 1rem;
  padding: 1.5rem;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}
.amb-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, #34d399, #14b8a6);
  opacity: 0;
  transition: opacity 0.3s;
}
.amb-card:hover {
  background: rgba(255,255,255,0.05);
  border-color: rgba(52, 211, 153, 0.25);
  transform: translateY(-2px);
}
.amb-card:hover::before { opacity: 1; }

/* ---------- Ambassador person cards ---------- */
.amb-person {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 0.875rem;
  padding: 1.25rem;
  transition: all 0.3s;
}
.amb-person-filled {
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.08), rgba(20, 184, 166, 0.04));
  border-color: rgba(52, 211, 153, 0.25);
}
.amb-person-empty {
  border-style: dashed;
  background: rgba(255,255,255,0.015);
  position: relative;
}
.amb-person-empty::after {
  content: "← 你的位置";
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  font-size: 0.625rem;
  font-family: 'JetBrains Mono', monospace;
  color: rgba(52, 211, 153, 0.5);
  letter-spacing: 0.05em;
  pointer-events: none;
  text-transform: uppercase;
}
[lang="en"] .amb-person-empty::after { content: "← your slot"; }

/* ---------- Ambassador join steps ---------- */
.amb-step {
  display: flex;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  background: rgba(255,255,255,0.03);
  border-left: 3px solid #34d399;
  border-radius: 0 0.5rem 0.5rem 0;
}
.amb-step-num {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  background: rgba(52, 211, 153, 0.15);
  border: 1px solid rgba(52, 211, 153, 0.3);
  color: #6ee7b7;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  flex-shrink: 0;
}

/* ---------- Geolocation button state ---------- */
#geo-locate:disabled {
  opacity: 0.6;
  cursor: wait;
}
#geo-locate:not(:disabled):hover {
  background: rgba(244, 165, 42, 0.12);
  border-color: rgba(244, 165, 42, 0.4);
}
#geo-locate[data-located="1"] {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.35);
}

/* ---------- Popup distance line ---------- */
.popup-distance {
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px dashed rgba(11, 18, 32, 0.15);
  font-size: 0.75rem;
  color: var(--ember);
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

/* ---------- PWA install/update banners ---------- */
#pwa-install-hint, #pwa-update-hint {
  animation: slideUp 0.4s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(120%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  #pwa-install-hint, #pwa-update-hint { animation: none; }
}

/* ---------- iOS safe area (notch) ---------- */
@supports (padding: env(safe-area-inset-top)) {
  nav.fixed.top-0 { padding-top: env(safe-area-inset-top); height: calc(4rem + env(safe-area-inset-top)); }
  #pwa-install-hint, #pwa-update-hint { bottom: calc(1rem + env(safe-area-inset-bottom)); }
}

/* ---------- Print friendliness ---------- */
@media print {
  nav, footer, .video-card, #map { display: none; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
