/* ═══════════════════════════════════════════════════════════════════════
 * archeo-search.css — v313.154.213
 * Barra ricerca ArcheoMap a 2 livelli (turista + appassionato).
 * Mobile-first, scoped al container #archeoSearchShell.
 * ═══════════════════════════════════════════════════════════════════════ */

/* Container principale — fixed in alto, sopra la mappa.
   v1.5.0: z-index 8900 (sopra #am-tier-filter-bar a 8500) così la
   dropdown suggerimenti non viene bucata dal chip-bar tier sotto. */
#archeoSearchShell {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top, 0px));
  left: 8px;
  right: 8px;
  z-index: 8900;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  pointer-events: none; /* trasparente al click di default; i figli lo riattivano */
}
#archeoSearchShell > * { pointer-events: auto; }

/* Quando attivo, nascondi la search bar legacy del bundle */
body.archeo-search-on #suBar,
body.archeo-search-on #suDrop,
body.archeo-search-on .aef-search,
body.archeo-search-on .aef-feed-on .aef-search-bar {
  display: none !important;
}

/* v1.8.0 — Tier-filter-bar legacy (Tutti/Famosi/Dimenticati/Gemme) è ora
   ridondante: i suoi chip sono assorbiti dalla nuova search (data-chip
   famoso/dimenticato/gemma). Hide via CSS, una sola fila di chip visibile. */
body.archeo-search-on #am-tier-filter-bar {
  display: none !important;
}

/* v1.5.0 — Quando la dropdown suggerimenti è aperta, spegniamo il
   chip-bar tier-filter (z-index 8500) altrimenti buca visivamente
   la dropdown. Stessa filosofia di body.detail-open in exp-tier-filter. */
body:has(#archeoSearchShell #amSuggestions:not([hidden])) #am-tier-filter-bar {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

#archeoSearchShell.am-search-shell {
  width: 100%;
  padding: 4px;
  box-sizing: border-box;
}

/* v1.9.9 — Layout della search-row:
   [📍 Vicino a me]  [🔍 cerca... ⚙Filtri]
   Stessa altezza (44px), stesso stile pillola, gap 10px.
   Tutto vetro/blur, ombra elegante, brand color attivo. */
.am-search-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

/* Pillola "Vicino a me" — sinistra, standalone */
.am-nearby-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
  height: 44px;
  padding: 0 18px;
  border: 1px solid rgba(20, 20, 20, 0.08);
  background: rgba(255, 255, 255, 0.97);
  color: #2a1810;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(10px);
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  line-height: 0;
}
.am-nearby-pill .am-nearby-label { line-height: 1; }
.am-nearby-pill svg { display: block; }
.am-nearby-pill:hover { background: #fff; }
.am-nearby-pill:active { transform: scale(0.97); }
.am-nearby-pill:focus-visible { outline: 2px solid #6b3f1a; outline-offset: 2px; }
.am-nearby-pill.is-active {
  background: #2a1810;
  color: #fff;
  border-color: #2a1810;
}

/* Search box principale — flex:1 */
.am-search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(20, 20, 20, 0.08);
  border-radius: 999px;
  padding: 0 6px 0 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(10px);
  box-sizing: border-box;
  min-width: 0;
}

.am-search-icon {
  font-size: 15px;
  opacity: 0.55;
  flex-shrink: 0;
  line-height: 1;
}

#amSearchInput {
  flex: 1;
  border: none;
  outline: none;
  min-width: 0;
  height: 100%;
  font-size: 15px;
  background: transparent;
  color: #1f1f1f;
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
}
#amSearchInput::-webkit-search-cancel-button { -webkit-appearance: none; }
#amSearchInput::placeholder { color: #6b6b6b; }

/* v1.9.9 — Filtri come icona circolare DENTRO la search-box (a destra).
   Tonda 36×36, sfondo brand-tinted leggero, hover più scuro, badge
   counter giallo in top-right quando ci sono filtri attivi. Niente
   border-left: la separazione visiva è data dal pill rotondo dell'icona. */
.am-filter-icon-btn {
  position: relative;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(42, 24, 16, 0.06);
  color: #2a1810;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  margin-left: auto;
  font-family: inherit;
  line-height: 0;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}
.am-filter-icon-btn:hover { background: rgba(42, 24, 16, 0.12); }
.am-filter-icon-btn:active { transform: scale(0.92); }
.am-filter-icon-btn:focus-visible { outline: 2px solid #6b3f1a; outline-offset: 2px; }
.am-filter-icon-btn svg { display: block; }
.am-filter-icon-btn .am-filter-count {
  position: absolute;
  top: -3px;
  right: -3px;
  background: #e8b454;
  color: #2a1810;
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.3;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}
.am-filter-icon-btn .am-filter-count:empty { display: none; }
/* Quando ci sono filtri attivi: highlight col colore brand */
.am-filter-icon-btn:has(.am-filter-count:not(:empty)) { background: #2a1810; color: #fff; }

/* Mobile sotto 480px: nascondi label "Vicino a me", solo icona tonda */
@media (max-width: 480px) {
  .am-nearby-pill .am-nearby-label { display: none; }
  .am-nearby-pill {
    width: 44px;
    padding: 0;
    justify-content: center;
  }
  .am-search-row { gap: 8px; }
}

/* DEPRECATED v1.9.7 — vecchio bottone "Filtri" pillola nera al top-right.
   Mantenuto SOLO per compatibilità in caso di vecchi shell rimasti in DOM. */
.am-filter-btn {
  border: none;
  border-radius: 999px;
  padding: 11px 15px;
  font-weight: 700;
  font-size: 13.5px;
  background: #2a1810;
  color: #fff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-family: inherit;
}
.am-filter-btn:active { transform: scale(0.96); }
.am-filter-btn .am-filter-count {
  background: #e8b454;
  color: #2a1810;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 800;
}
.am-filter-btn .am-filter-count:empty { display: none; }

/* Quick chips */
.am-quick-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0 2px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.am-quick-chips::-webkit-scrollbar { display: none; }

.am-chip {
  white-space: nowrap;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.95);
  color: #2a1810;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.am-chip.is-active {
  background: #2a1810;
  color: #fff;
  border-color: #2a1810;
}

/* Suggerimenti live */
.am-suggestions {
  position: absolute;
  left: 4px;
  right: 4px;
  top: 60px;
  background: #fff;
  border-radius: 18px;
  padding: 8px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.18);
  max-height: 320px;
  overflow-y: auto;
  z-index: 100;
  border: 1px solid rgba(0, 0, 0, 0.06);
}
.am-suggestion-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 14px;
  color: #2a1810;
  cursor: pointer;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
}
.am-suggestion-item:hover,
.am-suggestion-item:focus { background: #f5f0e8; }
.am-suggestion-item .am-sg-icon { font-size: 16px; flex-shrink: 0; opacity: 0.7; }

.am-suggestion-empty {
  padding: 14px;
  text-align: center;
  color: #8b6f5e;
  font-size: 13px;
}

/* v1.9.1 — Result counter in flow (NON absolute) sotto al chip-row,
   così non maschera più il chip "Vicino a me" né si sovrappone al
   bottone "Filtri". Stessa pillola scura, ma in posizione naturale. */
.am-result-counter {
  display: none;
  margin: 8px auto 0;
  width: fit-content;
  max-width: 100%;
  background: rgba(42, 24, 16, 0.92);
  color: #fff;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  text-align: center;
}
#archeoSearchShell.has-results .am-result-counter { display: block; }

/* Filter sheet (bottom on mobile, side panel on desktop) */
.am-filter-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.am-filter-overlay.is-shown {
  opacity: 1;
  pointer-events: auto;
}

.am-filter-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 86vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 24px 24px 0 0;
  padding: 10px 16px 18px;
  z-index: 1999;
  transform: translateY(105%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.22);
  -webkit-overflow-scrolling: touch;
}
.am-filter-sheet.is-open { transform: translateY(0); }

.am-sheet-handle {
  width: 46px;
  height: 5px;
  background: #d1d5db;
  border-radius: 999px;
  margin: 6px auto 12px;
}
.am-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.am-sheet-header h3 {
  margin: 0;
  font-size: 19px;
  font-family: Georgia, serif;
  color: #2a1810;
}
#amCloseFilters {
  border: none;
  background: #f3f4f6;
  border-radius: 999px;
  width: 36px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
  touch-action: manipulation;
  font-family: inherit;
}
.am-filter-section { margin: 18px 0; }
.am-filter-section h4 {
  margin: 0 0 10px;
  font-size: 13px;
  color: #6b3f1a;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 700;
}
.am-filter-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.am-filter-grid button {
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #2a1810;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.am-filter-grid button.is-active {
  background: #2a1810;
  color: #fff;
  border-color: #2a1810;
}
.am-filter-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  padding: 14px 0 6px;
  background: linear-gradient(to top, #fff 80%, rgba(255, 255, 255, 0));
}
.am-secondary-btn,
.am-primary-btn {
  flex: 1;
  border: none;
  border-radius: 14px;
  padding: 14px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  touch-action: manipulation;
  font-family: inherit;
}
.am-secondary-btn {
  background: #f3f4f6;
  color: #2a1810;
}
.am-primary-btn {
  background: #2a1810;
  color: #fff;
}
.am-primary-btn:active { transform: scale(0.98); }

/* Toggle pill (admin only) */
#__archeo_search_toggle_ui {
  position: fixed;
  top: 14px;
  right: 490px;
  z-index: 9600;
  background: rgba(26, 31, 46, 0.92);
  color: #fff;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  user-select: none;
  font-family: system-ui, -apple-system, sans-serif;
}

/* Empty state */
.am-empty-state {
  background: #fff8e8;
  border: 1px solid #e8b454;
  border-radius: 12px;
  padding: 16px;
  margin: 12px 0;
  text-align: center;
  color: #6b3f1a;
  font-size: 13px;
  line-height: 1.5;
}

/* Desktop adjustments */
@media (min-width: 768px) {
  /* v1.9.13 — Posizione FISSA dello shell (non si muove più con
     l'explore-feed). Ancorato a `left:440px max-width:520px` → shell
     occupa 440-960, sempre nella stessa zona indipendentemente dal
     panel state. Quando explore-feed è chiuso lascia spazio vuoto
     a sinistra (logo brand visibile a 8-168), quando è aperto
     parte subito dopo la X di chiusura del panel. Zero movimento. */
  #archeoSearchShell {
    left: 440px;
    right: auto;
    max-width: 520px;
    transform: none;
  }
  /* Niente regola override per body.aef-feed-on: la barra resta stabile. */
  /* v1.9.12 — Bundle's #expNearbyBtn RIPRISTINATO. Apre il bottom-sheet
     "Siti vicini" con drag-from-widget stile omino Street View, slider
     distanza, lista siti con distanze. Era stato erroneamente nascosto
     in v1.9.11 pensando fosse un duplicato — non lo è, è la feature ricca. */
  .am-filter-sheet {
    left: auto;
    right: 24px;
    bottom: 24px;
    width: 460px;
    border-radius: 20px;
    max-height: 80vh;
  }
  .am-filter-overlay { background: rgba(0, 0, 0, 0.25); }
}

/* Schermi molto larghi (≥1280px): un filo più di breathing room, stesso
   anchor (440px) per coerenza. */
@media (min-width: 1280px) {
  #archeoSearchShell { max-width: 540px; }
}

/* Schermi tra 768-1099px (tablet): comprimo per non toccare #expNearbyBtn.
   Anchor ancora left:440 perché su tablet l'explore-feed può essere
   ridotto, ma manteniamo posizione stabile per coerenza UX. */
@media (min-width: 768px) and (max-width: 1099px) {
  #archeoSearchShell {
    left: 440px;
    max-width: 380px;
  }
}
