:root {
  --green: #2f7d57;
  --green-dark: #256546;
  --green-soft: #e7f1ea;
  --bg: #f7f5f0;
  --card: #ffffff;
  --ink: #1f2a24;
  --muted: #6b7770;
  --line: #e4e0d7;
  --shadow: 0 8px 24px rgba(31, 42, 36, 0.12);
  --radius: 18px;
  /* the PWA banner/toasts render outside #home, so they can't use its --ink2 */
  --overlay-bg: #23261f;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ---------- screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  background: var(--bg);
}
.screen.active { display: flex; }

/* ---------- buttons ---------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 28px 40px;
  font-size: 24px;
  font-weight: 650;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--green);
  color: #fff;
  box-shadow: var(--shadow);
}
.btn-secondary {
  background: var(--card);
  color: var(--green-dark);
  border: 2px solid var(--green);
}

/* ---------- HOME / landing - "The Curb Gazette" ---------- */
#home {
  --paper: #f1ead9;
  --ink2: #23261f;
  --pop: #e0457b;        /* hot-pink - echoes the swan chair */
  --pop-ink: #b62f60;
}
.lp {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: var(--paper);
  /* faint newsprint dot grain */
  background-image: radial-gradient(rgba(35, 38, 31, 0.055) 1px, transparent 1.4px);
  background-size: 20px 20px;
}
.lp-inner {
  width: 100%;
  height: 100%;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) clamp(20px, 5vw, 60px) calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* hero */
.lp-hero { margin: 0 0 12px; text-align: center; }
.lp-wordmark {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: clamp(48px, 12vw, 96px);
  line-height: 0.9;
  letter-spacing: -0.02em;
  color: var(--ink2);
}
.lp-dmv {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.24em;
  font-weight: 700;
  letter-spacing: 0.14em;
  vertical-align: super;
  margin-left: 7px;
  color: var(--green);
}
.lp-lede {
  margin: 12px 0 0;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  font-size: clamp(20px, 5vw, 36px);
  line-height: 1.2;
  color: var(--ink2);
}
.lp-lede em {
  font-style: italic;
  position: relative;
  white-space: nowrap;
  z-index: 0;
}
.lp-lede em::after {   /* hand-drawn pink swash under "your" */
  content: "";
  position: absolute;
  left: -2px; right: -4px; bottom: 0;
  height: 8px;
  background: var(--pop);
  opacity: 0.85;
  border-radius: 8px 10px 7px 9px / 9px 7px 10px 8px;
  z-index: -1;
}

/* photo collage of real finds */
.lp-collage { position: relative; height: 0; margin: 0; display: none; }
.pola {
  position: absolute;
  width: 300px;
  margin: 0;
  padding: 18px 18px 60px;
  background: #fffdf8;
  border-radius: 2px;
  box-shadow: 0 12px 22px rgba(31, 33, 28, 0.18);
}
.pola img {
  display: block;
  width: 100%;
  height: 248px;
  object-fit: cover;
  background: var(--green-soft);
}
.pola figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 6px;
  text-align: center;
  font-family: "Caveat", cursive;
  font-weight: 700;
  font-size: 36px;
  color: var(--ink2);
}
.pola::before {   /* a strip of masking tape */
  content: "";
  position: absolute;
  top: -10px; left: 50%;
  width: 58px; height: 20px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(226, 214, 160, 0.6);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.pola-1 { top: 4px; left: 2px; transform: rotate(-6deg); z-index: 2; }
.pola-2 { top: 26px; right: 0; transform: rotate(5deg); z-index: 1; }
.pola-3 { top: 150px; left: 74px; transform: rotate(-3deg); z-index: 3; }

/* rubber-stamp find counter (uses #find-count) */
.lp-stamp {
  position: absolute;
  right: 0; bottom: -4px;
  z-index: 4;
  max-width: 376px;
  padding: 16px 26px;
  font-family: "Caveat", cursive;
  font-weight: 700;
  font-size: 38px;
  line-height: 1.05;
  text-align: center;
  color: var(--pop-ink);
  background: rgba(255, 253, 248, 0.88);
  border: 4px solid var(--pop);
  border-radius: 28px;
  transform: rotate(-5deg);
  box-shadow: 0 6px 14px rgba(176, 47, 96, 0.18);
}

/* CTAs - chunky zine buttons with a hard offset shadow */
.lp-cta { margin: 24px 0 0; display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 600px; }
.lp-cta .btn {
  border-radius: clamp(16px, 4vw, 20px);
  border: clamp(2px, 0.5vw, 4px) solid var(--ink2);
  box-shadow: clamp(4px, 1vw, 6px) clamp(4px, 1vw, 6px) 0 var(--ink2);
  font-weight: 700;
  font-size: clamp(18px, 4vw, 28px);
  padding: clamp(16px, 4vw, 24px) clamp(20px, 5vw, 32px);
  min-height: 48px;
}
.lp-cta .btn-primary { background: var(--green); color: #fff; }
.lp-cta .btn-secondary { background: #fffdf8; color: var(--ink2); }
.lp-cta .btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink2); }

/* temporarily switched-off CTA */
.lp-cta .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: clamp(4px, 1vw, 6px) clamp(4px, 1vw, 6px) 0 rgba(35, 38, 31, 0.35);
}
.lp-cta .btn:disabled:active { transform: none; }
.lp-cta-note {
  margin: -6px 0 0;
  text-align: center;
  font-size: 14px;
  font-style: italic;
  color: var(--ink2);
  opacity: 0.6;
}

/* ---------- PWA chrome: install button, offline banner, update toast ---------- */
.pwa-install {
  align-self: center;
  margin-top: 4px;
  padding: 10px 18px;
  background: none;
  border: 2px dashed var(--green);
  border-radius: 999px;
  color: var(--green-dark);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.pwa-install:active { transform: translateY(1px); }

.pwa-banner {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  z-index: 2000;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--overlay-bg);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

/* one stacking context for every toast, so two can never overlap */
.pwa-toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: min(92vw, 460px);
  pointer-events: none; /* the gaps shouldn't swallow taps on the page */
}
.pwa-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px 12px 18px;
  background: var(--overlay-bg);
  color: #fff;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}
.pwa-toast[hidden] { display: none; }
.pwa-toast-close {
  margin-left: auto;
  flex: none;
  background: none;
  border: none;
  color: #fff;
  opacity: 0.7;
  font-size: 15px;
  line-height: 1;
  padding: 6px;
  cursor: pointer;
}
.pwa-toast-btn {
  flex: none;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.pwa-toast-btn:disabled { opacity: 0.6; }

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  z-index: 1000;
}
.icon-btn {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}
.topbar-title { flex: 1; margin: 0; font-size: 18px; text-align: center; }
.search-wrap { flex: 1; }
.search-wrap input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 16px;
  background: var(--bg);
}

/* ---------- map ---------- */
#map { flex: 1; width: 100%; }
#map, #review-map { background: #dfe7e2; }

/* Leaflet popup */
.leaflet-popup-content { margin: 0; width: 220px !important; }
.popup img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
  border-radius: 10px 10px 0 0;
}
.popup-title { font-weight: 700; font-size: 15px; padding: 10px 12px 2px; }
.popup-desc { font-size: 13px; color: var(--muted); padding: 0 12px 6px; line-height: 1.4; }
.popup-time { font-size: 12px; color: var(--green-dark); padding: 0 12px 10px; font-weight: 600; }

/* ---------- upload ---------- */
.upload-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px calc(28px + env(safe-area-inset-bottom));
}
.step { max-width: 460px; margin: 0 auto; }

.photo-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 48px 24px;
  margin-top: 24px;
  background: var(--card);
  border: 2px dashed var(--green);
  border-radius: var(--radius);
  cursor: pointer;
}
.photo-drop-icon { font-size: 48px; }
.photo-drop-main { font-size: 18px; font-weight: 650; color: var(--green-dark); }

.preview-img {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: var(--radius);
  display: block;
  margin-bottom: 16px;
  background: var(--green-soft);
}

.review-head { font-size: 18px; font-weight: 700; margin: 4px 0 14px; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; font-weight: 650; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 16px;
  font-family: inherit;
  background: var(--card);
  resize: vertical;
}

.loc-block { margin-bottom: 18px; }
.loc-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 48px 20px;
  font-size: 15px;
  line-height: 1.6;
}
#review-map {
  height: 220px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
}

.muted { color: var(--muted); text-align: center; }

/* category chip, used on the review form and the detail sheet */
.result-cat {
  display: inline-block;
  margin: 8px 0;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 650;
  color: var(--green-dark);
  background: var(--green-soft);
  border-radius: 999px;
}

/* category chip inside map popups */
.popup-cat {
  display: inline-block;
  margin: 0 12px 6px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 650;
  color: var(--green-dark);
  background: var(--green-soft);
  border-radius: 999px;
}

/* ===================== search wizard ===================== */
.wizard-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px calc(28px + env(safe-area-inset-bottom));
}
.wiz-progress {
  display: flex;
  gap: 8px;
  justify-content: center;
  max-width: 460px;
  margin: 6px auto 22px;
}
.wiz-dot {
  width: 34px;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  transition: background 0.2s ease;
}
.wiz-dot.active { background: var(--green); }

.wiz-step { max-width: 460px; margin: 0 auto; animation: pop-in 0.3s ease both; }
.wiz-step-num {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 8px;
}
.wiz-q { margin: 0 0 6px; font-size: 25px; letter-spacing: -0.4px; color: var(--ink); }
.wiz-sub { margin: 0 0 18px; color: var(--muted); font-size: 15px; line-height: 1.5; }

.wiz-search input {
  width: 100%;
  padding: 15px 16px;
  font-size: 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  margin-bottom: 12px;
}
.wiz-search input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.wiz-place-status {
  min-height: 18px;
  margin: 8px 2px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--green-dark);
}
.wiz-actions { margin-top: 22px; display: flex; flex-direction: column; gap: 12px; }
.wiz-skip {
  display: block;
  width: 100%;
  margin: 6px auto 0;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  text-decoration: underline;
  cursor: pointer;
  padding: 8px;
}

.wiz-results { margin-top: 6px; min-height: 40px; }
.wiz-result-count { font-size: 13px; color: var(--muted); margin: 4px 2px 12px; }
.wiz-empty { text-align: center; color: var(--muted); padding: 30px 12px; font-size: 15px; line-height: 1.6; }
.wiz-results .card-go { cursor: default; }

/* ===================== home counter ===================== */
.count-pill {
  align-self: center;
  background: var(--green-soft);
  color: var(--green-dark);
  font-weight: 650;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 999px;
}

/* ===================== value tag ===================== */
.value-tag {
  display: inline-block;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: var(--green);
  border-radius: 999px;
  white-space: nowrap;
}

/* ===================== Map/List toggle + panes ===================== */
.subbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 8px 12px;
  text-align: center;
}
.segmented {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
}
.seg-btn {
  border: none;
  background: none;
  padding: 7px 18px;
  font-size: 14px;
  font-weight: 650;
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.seg-btn.active { background: var(--green); color: #fff; }

.browse-body { position: relative; flex: 1; }
#map, #list { position: absolute; top: 0; left: 0; right: 0; bottom: 0; width: 100%; }
#list { overflow-y: auto; padding: 14px; background: var(--bg); }

/* ===================== list cards ===================== */
.card {
  display: flex;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: transform 0.08s ease;
}
.card:active { transform: scale(0.99); }
.card-img {
  width: 88px; height: 88px;
  object-fit: cover;
  border-radius: 12px;
  flex: 0 0 auto;
  background: var(--green-soft);
}
.card-body { flex: 1; min-width: 0; }
.card-title { font-weight: 700; font-size: 15px; }
.card .value-tag { margin: 5px 0; font-size: 12px; padding: 3px 9px; }
.card-desc {
  font-size: 13px; color: var(--muted); margin: 2px 0 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-seen { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.card-foot { display: flex; align-items: center; gap: 8px; }
.card-dist { font-size: 12px; color: var(--green-dark); font-weight: 600; }
.card-go {
  margin-left: auto;
  font-size: 12px; font-weight: 650;
  color: var(--green-dark);
  background: var(--green-soft);
  border: none; border-radius: 999px;
  padding: 6px 10px; cursor: pointer;
}

/* ===================== route banner ===================== */
.route-banner {
  position: absolute;
  top: 12px; left: 12px; right: 12px;
  z-index: 1200;
  display: flex; align-items: center; gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}
#route-text { font-weight: 650; font-size: 14px; }
.route-maps { margin-left: auto; color: var(--green-dark); font-weight: 650; font-size: 14px; text-decoration: none; }
.route-clear { background: none; border: none; font-size: 16px; color: var(--muted); cursor: pointer; padding: 0 2px; }

/* ===================== detail bottom sheet ===================== */
.scrim {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.38);
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 2000;
}
.scrim.show { opacity: 1; }
.sheet {
  position: fixed; inset: 0;
  z-index: 2001;
  background: var(--card);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.sheet.open { transform: translateY(0); }
.sheet-close {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 14px;
  width: 40px; height: 40px;
  font-size: 24px; line-height: 1;
  background: rgba(255, 255, 255, 0.92);
  border: none; border-radius: 999px;
  color: var(--ink); cursor: pointer;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
/* photo fills all the space above the info card, whole item visible */
.d-photo {
  width: 100%;
  flex: 1;
  min-height: 0;
  object-fit: contain;
  background: #ece8df;
  display: block;
}
/* gallery: swipeable photo carousel with scroll-snap */
.d-gallery {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  background: #ece8df;
  overflow: hidden;
}
.d-gallery-track {
  display: flex;
  height: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.d-gallery-track::-webkit-scrollbar {
  display: none;
}
.d-gallery-track img {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  scroll-snap-align: start;
  background: #ece8df;
}
.d-gallery-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  display: flex;
  justify-content: center;
  gap: 6px;
  z-index: 2;
}
.d-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  border: none;
  background: rgba(0, 0, 0, 0.25);
  padding: 0;
  cursor: pointer;
}
.d-dot.active {
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
  width: 16px;
  border-radius: 5px;
}
.d-body {
  flex: 0 0 auto;
  padding: 18px 20px calc(20px + env(safe-area-inset-bottom));
  background: var(--card);
  box-shadow: 0 -8px 24px rgba(31, 42, 36, 0.08);
}
.d-row { display: flex; align-items: flex-start; gap: 12px; }
.d-title { flex: 1; margin: 0; font-size: 22px; line-height: 1.25; }
.d-meta { font-size: 13px; color: var(--muted); margin: 8px 0; }
.d-desc { font-size: 15px; line-height: 1.55; margin: 6px 0 16px; }
#d-route { margin-top: 4px; }

/* ===================== animations / polish ===================== */
@keyframes pop-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
#step-review:not([hidden]) #review-edit { animation: pop-in 0.35s ease both; }

/* freshly posted pin drops in (uses the independent `translate` property so it
   composes with Leaflet's positioning transform instead of overriding it) */
@keyframes pin-drop {
  0% { translate: 0 -260px; opacity: 0; }
  60% { translate: 0 8px; opacity: 1; }
  80% { translate: 0 -4px; }
  100% { translate: 0 0; }
}
.leaflet-marker-icon.pin-drop { animation: pin-drop 0.6s cubic-bezier(0.3, 0.7, 0.4, 1); }

/* ===================== responsive: full-page website ===================== */
/* App is now full-page, no phone frame constraints */
@media (min-width: 560px) {
  body { background: var(--bg); }

  /* Full-page, no frame limits */
  .screen,
  .sheet {
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
  }

  .scrim { background: rgba(0, 0, 0, 0.45); }
}

/* Mobile-first adjustments for small screens */
@media (max-width: 768px) {
  .lp {
    overflow-y: auto;
    min-height: 100vh;
  }

  .lp-inner {
    height: auto;
    min-height: 100vh;
    justify-content: flex-start;
    padding-top: calc(40px + env(safe-area-inset-top));
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
  }

  .lp-hero { margin: 20px 0 12px; }
}

/* tighten the landing on very short / small phones so nothing gets clipped */
@media (max-height: 640px) {
  .lp-hero { margin: 14px 0 0; }
  .lp-wordmark { font-size: clamp(46px, 16vw, 64px); }
  .lp-collage { height: 280px; margin: 18px 0 4px; }
  .pola { width: 132px; }
  .pola img { height: 108px; }
  .pola-3 { top: 132px; left: 66px; }
}
