:root {
  /* Mercado palette */
  --terracotta:      #C4533A;
  --marigold:        #E6A832;
  --sage:            #5B8C5A;

  --fg:              #2B2118;
  --muted:           #8B7A6B;
  --app-bg:          #FBF7F1;
  --content-surface: #FFFDF7;
  --border:          #EDE6DB;

  --shadow:    0 2px 10px rgba(0, 0, 0, 0.08);
  --radius:    12px;
  --tap:       44px;
  --font:      system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --map-gap:   10px;
  --vp-bottom: 0px;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  height: 100dvh;
}

body {
  height: 100%;
  margin: 0;
  font-family: var(--font);
  background: var(--app-bg);
  color: var(--fg);
}

/* ========================
   APP SHELL
   ======================== */

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Decorative top stripe */
.app::before,
.app::after {
  content: "";
  height: 6px;
  flex-shrink: 0;
  background: repeating-linear-gradient(
    90deg,
    #C4533A 0px, #C4533A 18px,
    #E6A832 18px, #E6A832 36px,
    #5B8C5A 36px, #5B8C5A 54px
  );
}

/* ========================
   4-TAB BAR
   ======================== */

.tab-bar {
  display: flex;
  background: var(--app-bg);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
  flex-shrink: 0;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px 6px;
  gap: 2px;
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: #BBA98E;
  min-height: 52px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 120ms ease, border-color 120ms ease;
}

.tab.is-active {
  color: var(--terracotta);
  border-bottom-color: var(--terracotta);
}

.tab:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: -2px;
}

.tab:active {
  opacity: 0.75;
}

.tab-icon {
  font-size: 18px;
  line-height: 1;
}

.tab-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

/* ========================
   MAIN + VIEWS
   ======================== */

.app-main {
  flex: 1;
  min-height: 0;
  position: relative;
}

.view {
  height: 100%;
  width: 100%;
}

.view[hidden] {
  display: none !important;
}

/* ========================
   MAP VIEW
   ======================== */

#view-map {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--map-gap);
}

/* Soft card map frame */
.map-card {
  flex: 1;
  background: var(--content-surface);
  border: 1px solid rgba(43, 33, 24, 0.10);
  border-radius: var(--radius);
  overflow: hidden;
}

/* Leaflet container */
#map {
  height: 100%;
  width: 100%;
}

/* Locate button */
.locate-btn {
  position: absolute;
  top: calc(var(--map-gap) + 10px + env(safe-area-inset-top));
  right: calc(var(--map-gap) + 10px + env(safe-area-inset-right));
  z-index: 1000;
}

.locate-btn:disabled {
  opacity: 0.6;
}

/* Toast */
.map-toast {
  position: absolute;
  top: calc(var(--map-gap) + 10px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(43, 33, 24, 0.92);
  color: #fff;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
  max-width: calc(100% - 24px);
  text-align: center;
}

.map-toast.is-visible {
  opacity: 1;
}

/* ========================
   LIST VIEW
   ======================== */

#view-list {
  padding: var(--map-gap);
  overflow: hidden;
}

.list {
  height: 100%;
  overflow: auto;
  padding: 0 0 90px;
  background: transparent;
}

.list-item {
  padding: 0;
  margin: 8px 6px;
  background: transparent;
  border: 0;
  cursor: pointer;
}

/* Selected list item — rule moved below :has() so selected wins the cascade */

.list-item.is-selected .vendor-name {
  text-decoration: none;
}

.list-item .vendor-card {
  padding: 12px;
}

/* ========================
   FILTERS VIEW
   ======================== */

#view-filters {
  overflow-y: auto;
  background: var(--app-bg);
}

.filters-view-body {
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}

.filters-view-title {
  font-weight: 800;
  font-size: 20px;
  color: var(--fg);
  margin: 0 0 18px;
}

.filter-block {
  margin: 0 0 16px;
}

.filter-label {
  font-weight: 800;
  font-size: 13px;
  color: var(--fg);
  margin: 0 0 8px;
  display: block;
}

.filter-input {
  width: 100%;
  height: 44px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  padding: 0 12px;
  font-size: 14px;
  background: var(--content-surface);
  color: var(--fg);
}

.filter-input:focus {
  outline: 2px solid var(--sage);
  outline-offset: 0;
  border-color: var(--sage);
}

.filter-hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Diet filter chips — sage-bordered, filled when checked */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid var(--sage);
  border-radius: 999px;
  padding: 8px 14px;
  background: transparent;
  color: var(--sage);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 120ms ease, color 120ms ease;
}

.chip input[type="checkbox"] {
  display: none;
}

.chip:has(input:checked) {
  background: var(--sage);
  color: #fff;
}

/* Favorites toggle */
.filter-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--fg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--content-surface);
  cursor: pointer;
}

.filter-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--terracotta);
  cursor: pointer;
}

/* Clear button row (single button, no Done) */
.filter-actions-single {
  margin-top: 8px;
}

.filter-actions-single .secondary-btn {
  max-width: 200px;
}

/* ========================
   INFO VIEW
   ======================== */

#view-info {
  overflow-y: auto;
  background: var(--app-bg);
}

.info-view-body {
  padding: 20px 18px calc(32px + env(safe-area-inset-bottom));
}

.info-hero {
  text-align: center;
  padding: 16px 0 20px;
}

.info-hero-emoji {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 8px;
}

.info-hero-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--fg);
  line-height: 1.15;
  margin-bottom: 8px;
}

.info-unofficial-badge {
  display: inline-block;
  border: 1.5px solid var(--terracotta);
  color: var(--terracotta);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.info-desc {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  margin: 0 0 16px;
}

.info-disclaimer {
  background: #FEF3E2;
  border: 1px solid var(--marigold);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 20px;
}

.info-footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* About section styles (reused in info view) */
.about-section + .about-section {
  margin-top: 20px;
}

.about-section h2 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 800;
  color: var(--fg);
  line-height: 1.25;
}

.about-section p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.about-section p + p {
  margin-top: 10px;
}

.about-section ul {
  margin: 8px 0 0;
  padding-left: 20px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

.about-section li + li {
  margin-top: 6px;
}

.about-section a {
  color: var(--terracotta);
}

/* ========================
   CONTACT FORM
   ======================== */

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.contact-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.contact-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
}

.contact-required {
  color: var(--terracotta);
}

.contact-input {
  width: 100%;
  box-sizing: border-box;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  background: #FAFAF5;
  color: var(--fg);
  outline: none;
  transition: border-color 120ms ease;
  -webkit-appearance: none;
}

.contact-input:focus {
  border-color: var(--terracotta);
}

.contact-textarea {
  resize: vertical;
  min-height: 100px;
}

.contact-submit {
  width: 100%;
  height: 44px;
  background: var(--terracotta);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.contact-submit:active {
  background: #A03829;
}

.contact-submit:disabled {
  opacity: 0.6;
  cursor: default;
}

.contact-error {
  font-size: 13px;
  color: var(--terracotta);
}

.contact-success {
  font-size: 15px;
  font-weight: 700;
  color: var(--sage);
  background: #EBF3EB;
  border: 1.5px solid var(--sage);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

/* ========================
   VENDOR CARD (shared: map overlay + list)
   ======================== */

.vendor-card {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

/* Specificity overrides so [hidden] beats display rules above */
.vendor-url[hidden]   { display: none; }
.vendor-about[hidden] { display: none; }

/* List vendor layout: left rail (fav) + content */
.vendor-row {
  display: grid;
  grid-template-columns: var(--tap) 1fr;
  gap: 10px;
  align-items: stretch;
}

.vendor-row .fav-btn {
  align-self: center;
}

.vendor-content {
  min-width: 0;
}

/* Name + chips on one line, wrap allowed */
.vendor-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Map card top row */
.vendor-topline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.vendor-topline .vendor-title {
  flex: 1;
  min-width: 0;
}

.vendor-topline .vendor-close {
  flex: 0 0 auto;
}

.list-item .vendor-desc {
  margin-top: 6px;
}

.vendor-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.vendor-name {
  font-weight: 700;
  font-size: 17px;
  line-height: 1.15;
  color: var(--fg);
}

.vendor-desc {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  white-space: normal;
}

.vendor-about {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--fg);
  line-height: 1.45;
  white-space: normal;
}

.vendor-url {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--terracotta);
  text-decoration: none;
}
.vendor-url:hover { text-decoration: underline; }

.vendor-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* Tag chips — sage green, white text */
.tag-chip {
  background: var(--sage);
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.3;
}

.tag-chip--category {
  background: var(--muted);
}

/* Favorite-only: subtle left accent; filled heart already signals the state */
.list-item:has(.fav-btn.is-fav) .vendor-card {
  border-left: 4px solid var(--marigold);
}

/* Selected wins over favorite (comes after in cascade, same specificity) */
.list-item.is-selected .vendor-card {
  border: 4px solid rgba(43, 33, 24, 0.75);
  background: #efe2cf;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.18);
}

/* Selected+favorited: specificity (0,5,0) beats fav-only (0,4,0) — explicitly
   restore the dark left border so the marigold stripe doesn't bleed through */
.list-item.is-selected:has(.fav-btn.is-fav) .vendor-card {
  border-left: 4px solid rgba(43, 33, 24, 0.75);
}


/* Map overlay card (floating, fixed position) */
#card.vendor-card--map {
  position: fixed;
  left: calc(var(--map-gap) + env(safe-area-inset-left));
  right: calc(var(--map-gap) + env(safe-area-inset-right));
  bottom: calc(4px + env(safe-area-inset-bottom) + var(--vp-bottom));
  padding: 12px;
  display: none;
  z-index: 1100;
  max-height: 45vh;
  max-height: 45dvh;
  overflow: auto;
}

/* Map card close button */
.vendor-close--map {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  z-index: 2;
}

/* Prevent title/chips from flowing under the close button */
#card.vendor-card--map .vendor-content {
  padding-right: calc(var(--tap) + 12px);
}

#card.vendor-card--map .vendor-topline {
  align-items: flex-start;
}

.vendor-close {
  flex: 0 0 auto;
}

/* ========================
   FAVORITES (unified Map + List)
   ======================== */

.fav-btn {
  color: var(--muted);
  transition: transform 120ms ease;
}

.fav-btn svg {
  width: 20px;
  height: 20px;
}

.fav-btn svg path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}

.fav-btn.is-fav {
  color: var(--terracotta);
}

.fav-btn.is-fav svg path {
  fill: currentColor;
  stroke: none;
}

/* Optical centering: heart */
.fav-btn svg {
  transform: scale(1.8);
}

/* Optical centering: close X */
.vendor-close svg {
  transform: translate(2px, 0) scale(1.5);
}

@keyframes favPop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.fav-btn.fav-pop {
  animation: favPop 140ms ease-out;
}

/* ========================
   ICON BUTTONS
   ======================== */

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--content-surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:active {
  background: rgba(43, 33, 24, 0.06);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.icon-btn:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 2px;
}

/* ========================
   BUTTONS
   ======================== */

.primary-btn {
  width: 100%;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--terracotta);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.secondary-btn {
  width: 100%;
  height: 44px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--content-surface);
  color: var(--fg);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.secondary-btn:active {
  background: rgba(43, 33, 24, 0.06);
}

/* ========================
   UTILITY
   ======================== */

.muted {
  color: var(--muted);
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

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

/* ========================
   TACO MARKERS (Leaflet divIcon)
   ======================== */

.leaflet-div-icon.taco-marker {
  background: transparent;
  border: 0;
  overflow: visible !important;
}

/* Promote each marker to its own compositor layer so the browser doesn't
   re-rasterize them during pan/zoom transforms */
.leaflet-marker-icon {
  will-change: transform;
}

/* SVG circle markers (all categories without custom images) */
.marker-circle {
  width: 38px;
  height: 38px;
  position: absolute;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-circle svg {
  width: 56%;
  height: 56%;
  display: block;
}

.marker-circle--selected {
  width: 44px;
  height: 44px;
  top: 4px;
  left: 4px;
  border: 3px solid #E6A832;
  outline: 2px solid #C4533A;
  outline-offset: -1px;
}

/* Custom logo markers (sponsors etc. with downloaded images) */
.marker-logo {
  width: 40px;
  height: 40px;
  position: absolute;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid #E6A832;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.marker-logo--selected {
  width: 48px;
  height: 48px;
  top: 2px;
  left: 2px;
  border: 3px solid #E6A832;
  outline: 2px solid #C4533A;
  outline-offset: -1px;
}

/* ========================
   WELCOME POPUP (first visit)
   ======================== */

.welcome-backdrop {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: welcome-fade 200ms ease-out;
}

.welcome-backdrop[hidden] {
  display: none !important;
}

@keyframes welcome-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.welcome-card {
  background: #fff;
  border-radius: 20px;
  max-width: 340px;
  width: 100%;
  padding: 28px 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  animation: welcome-card-in 200ms ease-out;
}

@keyframes welcome-card-in {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.welcome-emoji {
  font-size: 36px;
  text-align: center;
  margin-bottom: 8px;
}

.welcome-title {
  font-size: 20px;
  font-weight: 800;
  color: #2B2118;
  text-align: center;
  margin-bottom: 6px;
}

.welcome-subtitle {
  font-size: 13px;
  color: #8B7A6B;
  text-align: center;
  line-height: 1.5;
  margin-bottom: 18px;
}

.welcome-tabs-guide {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.welcome-tab-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: #2B2118;
  line-height: 1.4;
}

.welcome-tab-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 1px;
  line-height: 1;
}

.welcome-dismiss-btn {
  width: 100%;
  height: 44px;
  border-radius: 999px;
  border: none;
  background: #C4533A;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.welcome-dismiss-btn:active {
  opacity: 0.85;
}
