/* Web app "vicino a te" della home (finder.js). Usa i token di site.css. */

.finder { --fd-act: #00737c; --fd-act-2: #00626a; --fd-best-fg: #0b6644; --fd-best-bg: #e2f0ea; padding: 1.5rem 0 2.5rem; background: var(--ground); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .finder { --fd-best-fg: var(--down); --fd-best-bg: color-mix(in srgb, var(--down) 16%, transparent); } }
:root[data-theme="dark"] .finder { --fd-best-fg: var(--down); --fd-best-bg: color-mix(in srgb, var(--down) 16%, transparent); }
.fd-ico { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fd-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 0.75rem 2rem; margin-bottom: 1rem; }
.fd-title { font-size: clamp(1.6rem, 1.1rem + 2.2vw, 2.6rem); line-height: 1.08; letter-spacing: -0.02em; margin: 0; font-weight: 820; }
.fd-title em { font-style: normal; color: var(--brand-ink); }
.fd-lead { margin: 0.35rem 0 0; color: var(--text-2); font-size: 1rem; }

.fd-controls { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.6rem; margin-bottom: 0.9rem; }
.fd-form { display: flex; gap: 0.5rem; position: relative; }
.fd-q { flex: 1; min-width: 0; font: inherit; font-size: 1rem; padding: 0.75rem 1.1rem; border-radius: var(--r-pill);
  border: 1px solid var(--rule); background: var(--ground-2); color: var(--text); }
.fd-q:focus { outline: 3px solid var(--brand); outline-offset: 1px; }
.fd-q::placeholder { color: var(--text-2); opacity: 1; }
.fd-locate { font: inherit; font-weight: 750; font-size: 0.95rem; border: 0; border-radius: var(--r-pill); padding: 0 1.1rem;
  background: var(--fd-act); color: var(--on-brand); cursor: pointer; white-space: nowrap; min-height: 44px; }
.fd-locate:hover { background: var(--fd-act-2); }
.fd-locate:active { transform: scale(0.97); }
.fd-sugg { position: absolute; z-index: 1200; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 0.35rem; list-style: none;
  background: var(--ground); border: 1px solid var(--rule); border-radius: 1.1rem; box-shadow: 0 14px 40px rgba(var(--shadow), 0.18); }
.fd-sugg li { padding: 0.7rem 0.8rem; border-radius: 0.75rem; cursor: pointer; }
.fd-sugg li small { color: var(--text-2); }
.fd-sugg li:hover, .fd-sugg li.is-act { background: var(--panel); }

.fd-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.fd-fuel { font: inherit; font-size: 0.9rem; font-weight: 650; padding: 0.4rem 0.9rem; border-radius: var(--r-pill);
  border: 1px solid var(--rule); background: transparent; color: var(--text-2); cursor: pointer; }
.fd-fuel[aria-pressed="true"] { background: var(--fd-act); border-color: var(--fd-act); color: var(--on-brand); }
.fd-fuel:hover:not([aria-pressed="true"]) { border-color: var(--text-2); color: var(--text); }
.fd-sel { font: inherit; font-size: 0.9rem; padding: 0.4rem 0.7rem; border-radius: var(--r-pill); border: 1px solid var(--rule);
  background: var(--ground); color: var(--text); }
.fd-row .fd-sp { flex: 1; }

.fd-app { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); border: 1px solid var(--rule);
  border-radius: 1.5rem; overflow: hidden; height: min(74vh, 720px); min-height: 520px; background: var(--ground); }
.fd-side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--rule); }
.fd-count { padding: 0.75rem 1rem 0.25rem; font-size: 0.85rem; color: var(--text-2); }
.fd-status { margin: 0.5rem 1rem; padding: 0.7rem 0.9rem; border-radius: 0.9rem; background: var(--panel); font-size: 0.92rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.8rem; }
.fd-status[hidden] { display: none; }
.fd-status > span { flex: 1 1 12rem; }
.fd-act { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; min-height: 44px; padding: 0 1.1rem;
  font: inherit; font-size: 0.92rem; font-weight: 750; text-decoration: none; border-radius: var(--r-pill); cursor: pointer;
  border: 1.5px solid var(--fd-act); background: var(--ground); color: var(--brand-ink); }
.fd-act:hover { background: var(--panel); }
.fd-retry { background: var(--fd-act); color: var(--on-brand); }
.fd-retry:hover { background: var(--fd-act-2); }
.fd-hint { margin: 0.1rem 0.4rem 0.4rem; font-size: 0.78rem; color: var(--text-2); }
.fd-sub { margin: 0.4rem 0 0.8rem; font-size: 0.88rem; }
/* Caricamento: la lista vecchia si attenua e una barra sottile scorre sulla mappa */
#finder.is-loading .fd-list { opacity: 0.5; transition: opacity var(--t-ui) ease; }
.fd-mapwrap::before { content: ""; position: absolute; z-index: 1100; left: 0; top: 0; height: 3px; width: 30%;
  background: var(--brand); opacity: 0; pointer-events: none; }
#finder.is-loading .fd-mapwrap::before { opacity: 1; animation: fd-bar 1.1s ease-in-out infinite; }
@keyframes fd-bar { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
@media (prefers-reduced-motion: reduce) { #finder.is-loading .fd-mapwrap::before { animation: none; width: 100%; opacity: 0.6; } }
.fd-list { overflow: auto; flex: 1; min-height: 0; padding: 0.25rem 0.6rem 0.8rem; }
.fd-intro { padding: 1rem; color: var(--text-2); font-size: 0.95rem; }
.fd-intro b { color: var(--text); }
.fd-empty { padding: 1rem; color: var(--text-2); }
.fd-empty > p:first-child { margin: 0; color: var(--text); font-weight: 650; }

.fd-card { display: grid; grid-template-columns: 2.6rem minmax(0, 1fr) auto; gap: 0.75rem; align-items: center; width: 100%;
  text-align: left; font: inherit; color: inherit; background: transparent; border: 1px solid transparent;
  border-radius: 1.1rem; padding: 0.7rem; cursor: pointer; }
.fd-card:hover, .fd-card.is-sel { background: var(--ground-2); border-color: var(--rule); }
.fd-card.is-sel { border-color: var(--brand); }
.fd-card.is-old .fd-v { color: var(--text-2); font-weight: 700; }
.fd-card.is-old .fd-brand { color: var(--text-2); }
.fd-brand { width: 2.6rem; height: 2.6rem; border-radius: 0.8rem; background: var(--panel); color: var(--brand-ink);
  display: grid; place-items: center; font-weight: 850; font-size: 0.78rem; }
.fd-mid { display: grid; gap: 0.1rem; min-width: 0; }
.fd-name { font-weight: 750; font-size: 0.98rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fd-meta { font-size: 0.8rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fd-warn { font-size: 0.76rem; color: var(--up); font-weight: 650; }
.fd-best { display: inline-block; margin-left: 0.4rem; font-size: 0.7rem; font-weight: 800; color: var(--fd-best-fg);
  background: var(--fd-best-bg); padding: 0.05rem 0.45rem; border-radius: var(--r-pill); vertical-align: 0.1em; }
.fd-price { text-align: right; display: grid; }
.fd-v { font-size: 1.18rem; font-weight: 850; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.fd-d { font-size: 0.74rem; font-weight: 700; color: var(--text-2); white-space: nowrap; }
.fd-d.down { color: var(--down); } .fd-d.up { color: var(--up); }

.fd-mapwrap { position: relative; min-height: 0; isolation: isolate; } /* i controlli Leaflet restano sotto la barra del sito */
.fd-map { position: absolute; inset: 0; background: var(--ground-2); }
.fd-pin-wrap { background: none; border: 0; }
.fd-pin { position: absolute; left: 0; top: 0; transform: translate(-50%, calc(-100% - 6px)); white-space: nowrap;
  font: 800 12.5px/1 var(--font); font-variant-numeric: tabular-nums; color: #fff; padding: 5px 8px; border-radius: 9px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); cursor: pointer; }
.fd-pin::after { content: ""; position: absolute; left: 50%; bottom: -5px; transform: translateX(-50%);
  border: 5px solid transparent; border-bottom: 0; border-top-color: inherit; }
.fd-pin--good { background: #0f7a52; border-color: #0f7a52; }
.fd-pin--mid { background: #9a5a00; border-color: #9a5a00; }
.fd-pin--high { background: #a8372a; border-color: #a8372a; }
.fd-pin--old { background: #5d6f72; border-color: #5d6f72; }
.fd-pin--good::after { border-top-color: #0f7a52; } .fd-pin--mid::after { border-top-color: #9a5a00; }
.fd-pin--high::after { border-top-color: #a8372a; } .fd-pin--old::after { border-top-color: #5d6f72; }
.fd-pin--best { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; padding: 6px 9px; outline: 2px solid #fff; }
.fd-pin-star { width: 13px; height: 13px; fill: #fff; stroke: none; }
.fd-pin-wrap.is-sel .fd-pin { transform: translate(-50%, calc(-100% - 6px)) scale(1.18); outline: 2.5px solid #fff; }

.fd-legend { position: absolute; z-index: 900; left: 0.6rem; bottom: 1.7rem; display: grid; gap: 0.15rem; padding: 0.45rem 0.65rem;
  background: color-mix(in srgb, var(--ground) 92%, transparent); border: 1px solid var(--rule); border-radius: 0.8rem;
  font-size: 0.72rem; font-weight: 650; color: var(--text); pointer-events: none; }
.fd-legend[hidden] { display: none; }
.fd-lg { display: flex; align-items: center; gap: 0.4rem; }
.fd-dot { width: 0.7rem; height: 0.7rem; border-radius: 0.25rem; }
.fd-dot--good { background: #0f7a52; } .fd-dot--mid { background: #9a5a00; } .fd-dot--high { background: #a8372a; } .fd-dot--old { background: #5d6f72; }
/* Zoom di Leaflet nei colori del sito (anche in tema scuro) */
.fd-mapwrap .leaflet-bar { border: 1px solid var(--rule); box-shadow: 0 2px 8px rgba(var(--shadow), 0.15); }
.fd-mapwrap .leaflet-bar a { background: var(--ground); color: var(--text); border-bottom-color: var(--rule); }
.fd-mapwrap .leaflet-bar a:hover { background: var(--ground-2); }
.fd-mapwrap .leaflet-control-attribution { background: color-mix(in srgb, var(--ground) 85%, transparent); color: var(--text-2); }
.fd-mapwrap .leaflet-control-attribution a { color: var(--text-2); }
.fd-detail { position: absolute; z-index: 1000; right: 1rem; top: 1rem; width: min(340px, calc(100% - 2rem));
  max-height: calc(100% - 2rem); overflow: auto; background: var(--ground); border: 1px solid var(--rule);
  border-radius: 1.4rem; box-shadow: 0 14px 44px rgba(var(--shadow), 0.22); padding: 1rem 1.1rem; }
.fd-x { position: absolute; right: 0.4rem; top: 0.4rem; width: 44px; height: 44px; display: grid; place-items: center; border: 0;
  border-radius: 50%; background: none; color: var(--text-2); cursor: pointer; padding: 0; }
.fd-x:hover { background: var(--ground-2); color: var(--text); }
.fd-x .fd-ico { width: 20px; height: 20px; }
.fd-dtitle { margin: 0.2rem 2.6rem 0 0; font-size: 1.1rem; }
.fd-dtitle:focus { outline: none; }
.fd-addr { margin: 0.15rem 0 0.7rem; font-size: 0.85rem; color: var(--text-2); }
.fd-fuels { display: grid; grid-template-columns: 1fr auto; gap: 0.2rem 0.8rem; margin: 0 0 0.4rem; font-size: 0.92rem; }
.fd-fuels dt { margin: 0; } .fd-fuels dd { margin: 0; font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.fd-upd { margin: 0 0 0.6rem; font-size: 0.78rem; color: var(--text-2); }
.fd-chart svg { display: block; width: 100%; height: 56px; }
.fd-line { fill: none; stroke: var(--brand); stroke-width: 2.2; stroke-linejoin: round; }
.fd-chart-l { margin: 0.15rem 0 0.8rem; font-size: 0.76rem; color: var(--text-2); }
.fd-btns { display: flex; gap: 0.5rem; }
.fd-alt { display: inline-block; margin-top: 0.6rem; padding: 0.3rem 0; font-size: 0.8rem; color: var(--text-2); text-decoration: underline; text-underline-offset: 2px; }
.fd-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; text-align: center;
  text-decoration: none; font-weight: 750; font-size: 0.92rem; padding: 0 0.6rem; border-radius: var(--r-pill); }
.fd-btn--p { background: var(--fd-act); color: var(--on-brand); }
.fd-btn--p:hover { background: var(--fd-act-2); }
.fd-btn--o { border: 1.5px solid var(--fd-act); color: var(--brand-ink); }
.fd-btn--o:hover { background: var(--panel); }
.fd-lock { margin: 0.9rem 0 0; padding: 0.7rem 0 0; border-top: 1px solid var(--rule); font-size: 0.8rem; color: var(--text-2); }
.fd-src { margin: 0.6rem 0 0; font-size: 0.78rem; color: var(--text-2); }

@media (max-width: 820px) {
  .fd-app { grid-template-columns: minmax(0, 1fr); grid-template-rows: 46vh auto; height: auto; min-height: 0; }
  .fd-mapwrap { order: -1; min-height: 46vh; }
  .fd-side { border-right: 0; border-top: 1px solid var(--rule); }
  .fd-list { overflow: visible; }
  .fd-detail { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 72vh;
    border-radius: 1.4rem 1.4rem 0 0; z-index: 2000; }
  .fd-form { flex-direction: column; }
  .fd-locate { padding: 0.8rem 1rem; }
  .fd-fuel, .fd-sel, .fd-full { min-height: 44px; }
  .fd-mapwrap .leaflet-bar a { width: 40px; height: 40px; line-height: 40px; }
  .fd-legend { display: flex; flex-wrap: wrap; gap: 0.15rem 0.6rem; left: 0.5rem; bottom: 0.5rem; max-width: calc(100% - 6.5rem);
    padding: 0.3rem 0.55rem; font-size: 0.68rem; border-radius: 0.6rem; }
  .fd-dot { width: 0.6rem; height: 0.6rem; }
}
@media (min-width: 821px) { .fd-fuel, .fd-sel, .fd-full { min-height: 38px; } }

/* ---- Web app a tutto schermo (classe .is-full su #finder, gestita da finder.js) ---- */
body.fd-noscroll { overflow: hidden; }
.fd-full { display: inline-flex; align-items: center; gap: 0.4rem; font: inherit; font-size: 0.9rem; font-weight: 750; padding: 0 1rem;
  border-radius: var(--r-pill); border: 1px solid var(--rule); background: var(--ground-2); color: var(--text); cursor: pointer; white-space: nowrap; }
.fd-full:hover { border-color: var(--text-2); }
.fd-exit { display: none; flex: none; width: 44px; height: 44px; place-items: center; padding: 0; border-radius: 50%;
  border: 1px solid var(--rule); background: var(--ground-2); color: var(--text); cursor: pointer; }
.fd-exit .fd-ico { width: 20px; height: 20px; }
#finder.is-full .fd-exit { display: grid; }
#finder.is-full .fd-full { display: none; }
.fd-full:active { transform: scale(0.97); }
.fd-l-short { display: none; }
#finder.is-full { position: fixed; inset: 0; z-index: 3000; max-width: none; width: auto; margin: 0;
  padding: max(0.6rem, env(safe-area-inset-top)) 0.6rem calc(0.6rem + env(safe-area-inset-bottom));
  background: var(--ground); display: flex; flex-direction: column; overflow: hidden; }
#finder.is-full .fd-head, #finder.is-full .fd-src { display: none; }
#finder.is-full .fd-controls { margin-bottom: 0.5rem; }
#finder.is-full .fd-app { flex: 1; height: auto; min-height: 0; border-radius: 1rem; }

@media (max-width: 820px) {
  /* Telefono: ricerca e filtri compatti in alto, mappa sopra e lista sotto,
     entrambe visibili; la lista scorre da sola. */
  #finder.is-full .fd-form { flex-direction: row; }
  #finder.is-full .fd-locate { padding: 0 0.9rem; }
  #finder.is-full .fd-l-long { display: none; }
  #finder.is-full .fd-l-short { display: inline; }
  #finder.is-full .fd-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); mask-image: linear-gradient(to right, #000 85%, transparent); padding-right: 1.5rem; }
  #finder.is-full .fd-row::-webkit-scrollbar { display: none; }
  #finder.is-full .fd-fuel, #finder.is-full .fd-sel, #finder.is-full .fd-full { flex: none; }
  #finder.is-full .fd-row .fd-sp { display: none; }
  #finder.is-full .fd-app { grid-template-rows: minmax(0, 1.1fr) minmax(0, 1fr); }
  #finder.is-full .fd-mapwrap { min-height: 0; }
  #finder.is-full .fd-side { min-height: 0; }
  #finder.is-full .fd-list { overflow: auto; }
  #finder.is-full .fd-detail { z-index: 3100; }
}

.fd-vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: -1px; padding: 0; border: 0; }
