/* ============================================================
   TripsBack — Pagina risultati ricerca (design "Executive")
   Costruita sui token --tb-* di executive.css: qui NON si ridefiniscono
   i token, si compongono solo i pezzi specifici della pagina.
   Il gate prezzi (visibile/lucchetto) è deciso lato server: la CSS
   stilizza soltanto ciò che il PHP ha già scelto di stampare.
   ============================================================ */

.page-search {
    --sr-filter-h: 61px;
    --sr-sticky-top: calc(var(--tb-header-h) + var(--sr-filter-h) + 16px);
    background: var(--tb-bg);
}

.sr-main {
    padding-bottom: 56px;
}

/* --- Barra filtri + ordinamento --------------------------------------- */
.sr-filterbar {
    position: sticky;
    top: var(--tb-header-h);
    z-index: 80;
    background: color-mix(in srgb, var(--tb-bg) 95%, transparent);
    -webkit-backdrop-filter: saturate(1.3) blur(8px);
    backdrop-filter: saturate(1.3) blur(8px);
    border-bottom: 1px solid var(--tb-line);
}
.sr-filterbar-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: var(--sr-filter-h);
    padding-block: 11px;
}
.sr-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: thin;
    flex: 1;
    min-width: 0;
    padding-bottom: 2px;
}
.sr-chips::-webkit-scrollbar { height: 5px; }
.sr-chips::-webkit-scrollbar-thumb { background: var(--tb-line); border-radius: 999px; }
.sr-chip {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
    cursor: pointer;
    background: var(--tb-bg);
    border: 1px solid var(--tb-line);
    color: var(--tb-ink);
    font: inherit;
    font-weight: 600;
    font-size: var(--tb-fs-sm);
    padding: 9px 14px;
    border-radius: var(--tb-r-btn);
    text-decoration: none;
    transition: border-color .15s, background .15s, color .15s;
}
.sr-chip svg { width: 15px; height: 15px; color: var(--tb-ink-soft); }
.sr-chip:hover { border-color: #B9C2D6; background: var(--tb-panel); }
.sr-chip[aria-pressed="true"] { background: var(--tb-ink); color: #fff; border-color: var(--tb-ink); }
.sr-chip[aria-pressed="true"] svg { color: #fff; }
.sr-chip-locked { color: var(--tb-ink-soft); background: var(--tb-panel); }
.sr-chip-locked svg { color: var(--tb-ink-soft); }

.sr-sort {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: var(--tb-fs-sm);
    color: var(--tb-ink-soft);
    font-weight: 600;
}
.sr-sort label { white-space: nowrap; }
.sr-sort select {
    font: inherit;
    font-weight: 600;
    font-size: var(--tb-fs-sm);
    color: var(--tb-ink);
    background: var(--tb-bg);
    border: 1px solid var(--tb-line);
    border-radius: var(--tb-r-btn);
    padding: 9px 30px 9px 12px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23566079' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
}
.sr-sort select:hover { border-color: #B9C2D6; }
/* Il select fa submit da solo (onchange in search.js): il bottone e' solo
   fallback per no-JS. Selettore piu' specifico di .tb-btn per nasconderlo. */
.sr-sort .sr-sort-go { display: none; }

.sr-mobile-controls { display: none; }

/* --- Shell / stati vuoti ---------------------------------------------- */
.sr-shell { padding-top: 20px; }

.sr-gate { margin-bottom: 4px; }
.sr-gate-ic {
    width: 38px; height: 38px; flex: none;
    border-radius: 10px;
    background: var(--tb-bg);
    border: 1px solid var(--tb-line);
    display: grid; place-items: center;
}
.sr-gate-ic svg { width: 19px; height: 19px; color: var(--tb-blue-deep); }

.sr-empty {
    text-align: center;
    max-width: 46ch;
    margin: 48px auto;
    color: var(--tb-ink-soft);
}
.sr-empty h2 { color: var(--tb-ink); margin-bottom: 8px; }
.sr-empty p { font-size: var(--tb-fs-sm); }

/* --- Testata risultati ------------------------------------------------- */
.sr-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 18px 0 6px;
}
.sr-head h1 { font-size: clamp(1.4rem, 2.4vw, 1.9rem); font-weight: 800; margin: 0; }
.sr-head-sub { color: var(--tb-ink-soft); font-size: var(--tb-fs-sm); margin: 5px 0 0; }
.sr-cashhint {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--tb-emerald-soft);
    color: var(--tb-emerald-ink);
    border: 1px solid color-mix(in srgb, var(--tb-emerald) 22%, transparent);
    border-radius: var(--tb-r-pill);
    padding: 7px 14px;
    font-size: var(--tb-fs-sm);
    font-weight: 700;
}
.sr-cashhint svg { width: 15px; height: 15px; }

/* --- Layout split ------------------------------------------------------ */
.sr-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 440px;
    gap: 24px;
    align-items: start;
    padding: 16px 0 8px;
}
.sr-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

/* --- Card hotel -------------------------------------------------------- */
.sr-card {
    display: grid;
    grid-template-columns: 232px 1fr;
    background: var(--tb-bg);
    border: 1px solid var(--tb-line);
    border-radius: var(--tb-r-card);
    overflow: hidden;
    cursor: pointer;
    transition: border-color .16s ease-out, box-shadow .16s ease-out, transform .16s ease-out;
}
.sr-card:hover, .sr-card:focus-visible {
    border-color: #CDD6E6;
    box-shadow: var(--tb-shadow);
    outline: none;
}
.sr-card.is-active {
    border-color: var(--tb-blue);
    box-shadow: 0 0 0 2px var(--tb-blue), var(--tb-shadow);
}
.sr-media { position: relative; min-height: 100%; background: var(--tb-panel); }
.sr-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sr-cash {
    position: absolute;
    left: 10px; bottom: 10px; z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    /* emerald-ink: bianco su --tb-emerald sta a 3.42:1, sotto 4.5:1. Qui 5.07:1. */
    background: var(--tb-emerald-ink);
    color: #fff;
    font-weight: 700;
    font-size: var(--tb-fs-xs);
    padding: 5px 10px;
    border-radius: var(--tb-r-pill);
    box-shadow: 0 4px 12px rgb(14 158 110 / 35%);
}
.sr-cash svg { width: 13px; height: 13px; }

.sr-body {
    padding: 15px 17px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.sr-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.sr-name { min-width: 0; }
.sr-name h2 { font-size: var(--tb-fs-lg); font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.sr-zone { font-size: var(--tb-fs-sm); color: var(--tb-ink-soft); margin-top: 3px; }
/* Il perche' del colore sta su --tb-star (executive.css). Qui basta sapere che e'
   l'unico posto in cui si legge la categoria: la pillola accanto dice "Comfort",
   non "3 stelle". */
.sr-stars { color: var(--tb-star); font-weight: 700; margin-left: 6px; letter-spacing: 1px; }
.sr-class {
    flex: none;
    display: inline-flex;
    align-items: center;
    height: 26px;
    padding: 0 10px;
    background: var(--tb-ink);
    color: #fff;
    border-radius: 8px;
    font-size: var(--tb-fs-xs);
    font-weight: 700;
    white-space: nowrap;
}

.sr-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 11px;
}
.sr-tags .tb-tag {
    border: 1px solid var(--tb-line);
    font-weight: 600;
}

.sr-foot {
    margin-top: auto;
    padding-top: 13px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}
.sr-policy {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--tb-fs-xs);
    font-weight: 600;
    color: var(--tb-emerald-ink);
}
.sr-policy.is-strict { color: var(--tb-ink-soft); }
.sr-policy svg { width: 14px; height: 14px; flex: none; }
.sr-policy span { white-space: nowrap; }

/* Prezzo sopra, CTA sotto, allineati a destra. In riga servirebbero 459px in
   una colonna da 420: la CTA uscirebbe dalla card o spezzerebbe le cifre. */
.sr-priceblock {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    text-align: right;
    flex: none;
}
.sr-price { display: flex; flex-direction: column; align-items: flex-end; }
.sr-price .tb-price-real { margin-bottom: 1px; }
.sr-price .tb-price { line-height: 1.1; }
.sr-price .tb-price + small,
.sr-price small { font-size: var(--tb-fs-xs); color: var(--tb-ink-soft); font-weight: 500; }
.sr-cta { flex: none; padding: 10px 15px; }

/* Prezzo bloccato (anonimo): allineato a destra come il prezzo reale.
   Le cifre mostrate sono un segnaposto inerte ("000"), mai il prezzo reale:
   la sfocatura di executive.css le rende una forma di prezzo, non un numero. */
.sr-price.tb-price-locked { align-items: flex-end; gap: 5px; }
.sr-price.tb-price-locked .tb-price-blur { font-size: var(--tb-fs-xl); flex-wrap: nowrap; }
.sr-price.tb-price-locked .tb-price-blur .tb-blur { white-space: nowrap; }
.sr-price.tb-price-locked .tb-price-blur small { letter-spacing: normal; margin-left: 4px; white-space: nowrap; }
.sr-price.tb-price-locked .tb-price-cta { white-space: nowrap; }
.sr-price.tb-price-locked .tb-price-cta { display: inline-flex; align-items: center; gap: 5px; }
.sr-price.tb-price-locked .tb-lock { width: 13px; height: 13px; }

/* --- Colonna mappa ----------------------------------------------------- */
.sr-map-col {
    position: sticky;
    top: var(--sr-sticky-top);
    height: calc(100vh - var(--sr-sticky-top) - 20px);
    min-height: 420px;
    border-radius: var(--tb-r-card);
    overflow: hidden;
    border: 1px solid var(--tb-line);
}
.sr-map { width: 100%; height: 100%; background: var(--tb-panel); }
.sr-map-fallback {
    width: 100%; height: 100%;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 6px; text-align: center; padding: 24px;
    color: var(--tb-ink-soft);
}
.leaflet-container .sr-map-fallback { display: none; }
.sr-map-close { display: none; }

/* --- Pin mappa (composti sui token) ----------------------------------- */
.sr-marker { background: transparent; border: 0; }
.leaflet-marker-icon.sr-marker * { pointer-events: none; }
.sr-pin {
    transform: translate(-50%, -50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--tb-blue);
    color: #fff;
    font-weight: 700;
    font-size: var(--tb-fs-xs);
    padding: 5px 10px;
    border-radius: var(--tb-r-pill);
    border: 2px solid #fff;
    box-shadow: 0 4px 12px rgb(36 85 255 / 40%);
    white-space: nowrap;
    cursor: pointer;
    font-variant-numeric: tabular-nums;
    transition: transform .15s ease-out, background .15s ease-out;
}
.sr-pin:hover, .sr-pin.is-hover { background: var(--tb-blue-deep); transform: translate(-50%, -50%) scale(1.08); z-index: 2; }
.sr-pin.is-active { background: var(--tb-ink); transform: translate(-50%, -50%) scale(1.12); box-shadow: 0 6px 16px rgb(14 26 51 / 45%); z-index: 3; }
.sr-pin.is-lock { background: var(--tb-ink); padding: 6px 8px; box-shadow: 0 4px 12px rgb(14 26 51 / 38%); }
/* flex:none obbligatorio: il wrapper Leaflet del divIcon è largo 1px, quindi
   un <svg> senza width intrinseca (min-width:auto -> 0) verrebbe schiacciato. */
.sr-pin.is-lock svg { width: 14px; height: 14px; color: #fff; display: block; flex: none; }

.sr-cluster {
    transform: translate(-50%, -50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 44px;
    height: 34px;
    padding: 0 12px;
    border-radius: var(--tb-r-pill);
    border: 1px solid rgb(15 40 70 / 45%);
    background: var(--tb-bg);
    color: var(--tb-ink);
    font-size: var(--tb-fs-xs);
    font-weight: 700;
    white-space: nowrap;
    box-shadow: var(--tb-shadow);
}
.sr-cluster svg { width: 13px; height: 13px; color: var(--tb-ink-soft); flex: none; }

.leaflet-tooltip.sr-tip {
    background: var(--tb-ink);
    color: #fff;
    border: none;
    font-weight: 700;
    font-size: var(--tb-fs-xs);
    padding: 5px 9px;
    border-radius: 7px;
    box-shadow: var(--tb-shadow);
}
.leaflet-tooltip.sr-tip::before { border-top-color: var(--tb-ink); }

/* --- Popup mappa ------------------------------------------------------- */
.leaflet-popup.sr-popup .leaflet-popup-content-wrapper {
    padding: 0; border-radius: var(--tb-r-card); overflow: hidden;
    border: 1px solid var(--tb-line); box-shadow: var(--tb-shadow);
}
.leaflet-popup.sr-popup .leaflet-popup-content { margin: 0; width: 240px !important; }
.sr-pop { background: var(--tb-bg); }
.sr-pop-media { height: 108px; background: var(--tb-panel); }
.sr-pop-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sr-pop-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.sr-pop-title { margin: 0; font-size: var(--tb-fs-md); font-weight: 700; color: var(--tb-ink); }
.sr-pop-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.sr-pop-price { font-size: var(--tb-fs-lg); font-weight: 800; color: var(--tb-ink); }
.sr-pop-price small { font-size: var(--tb-fs-xs); font-weight: 500; color: var(--tb-ink-soft); }
.sr-pop-lock { display: inline-flex; align-items: center; gap: 5px; font-size: var(--tb-fs-xs); font-weight: 700; color: var(--tb-blue-deep); }
.sr-pop-lock svg { width: 13px; height: 13px; }
.sr-pop-cta {
    flex: none;
    display: inline-flex; align-items: center;
    padding: 8px 12px; border-radius: var(--tb-r-btn);
    background: var(--tb-blue); color: #fff;
    font-size: var(--tb-fs-xs); font-weight: 600; text-decoration: none;
}
.sr-pop-cta:hover { background: var(--tb-blue-deep); color: #fff; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1080px) {
    .sr-layout { grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; }
    /* header cresce (barra ricerca su riga propria): sticky non affidabile */
    .sr-filterbar { position: static; }
    .sr-map-col { top: 12px; }
}

@media (max-width: 820px) {
    .sr-chips, .sr-sort { display: none; }
    .sr-mobile-controls { display: flex; align-items: center; gap: 10px; width: 100%; }
    .sr-mobile-controls.filters-open ~ .sr-chips { display: flex; }
    .sr-mobile-controls .tb-btn { flex: 1; }
    .sr-layout { grid-template-columns: 1fr; }
    .sr-map-col {
        position: fixed; inset: 0; top: 0; z-index: 2000;
        height: 100%; border-radius: 0; border: none; display: none;
    }
    body.sr-map-open { overflow: hidden; }
    body.sr-map-open .sr-map-col { display: block; }
    .sr-map-close {
        display: inline-flex; align-items: center; gap: 7px;
        position: absolute; z-index: 2100; top: 14px; right: 14px;
        background: var(--tb-bg); border: 1px solid var(--tb-line);
        border-radius: var(--tb-r-btn); padding: 10px 15px;
        font: inherit; font-weight: 700; font-size: var(--tb-fs-sm); cursor: pointer;
        box-shadow: var(--tb-shadow); color: var(--tb-ink);
    }
    .sr-map-close svg { width: 16px; height: 16px; }
    /* Filtri rivelabili su mobile via bottone (contenitore visibile) */
    .sr-filterbar.filters-open .sr-chips {
        display: flex; flex-wrap: wrap; width: 100%; order: 3; padding-top: 10px;
    }
    .sr-filterbar.filters-open .sr-sort {
        display: inline-flex; order: 4; padding-top: 6px;
    }
    .sr-filterbar-inner { flex-wrap: wrap; }
}

@media (max-width: 560px) {
    .sr-card { grid-template-columns: 1fr; }
    .sr-media { min-height: 180px; height: 190px; }
    .sr-top { flex-direction: row; }
    .sr-foot { flex-wrap: wrap; }
    .sr-priceblock { width: 100%; justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
    .sr-card, .sr-pin { transition: none !important; }
}

/* ============================================================
   Stati della ricerca: scheletro, attesa, errore, destinazione mancante.
   La chiamata al fornitore puo' durare fino a 30 secondi. Prima la pagina
   intera aspettava dietro un velo grigio; adesso il guscio c'e' subito e
   l'attesa e' coperta da uno scheletro, che dice DOVE arrivera' la roba.
   ============================================================ */

/* Lo scheletro riusa .sr-card, quindi eredita griglia, bordo e raggio: quando le
   card vere lo sostituiscono la pagina non salta, perche' l'ingombro e' lo stesso. */
.sr-card-skeleton {
    cursor: default;
    pointer-events: none;
    /* Non deve sollevarsi in hover: non c'e' niente sotto da guardare. */
    transition: none;
}
.sr-card-skeleton:hover { border-color: var(--tb-line); box-shadow: none; }
.sr-card-skeleton .sr-media { min-height: 168px; }
.sr-card-skeleton .sr-media .tb-skeleton { position: absolute; inset: 0; border-radius: 0; }
.sr-card-skeleton .sr-body { gap: 10px; justify-content: center; }
.sr-skeleton-row  { display: flex; gap: 8px; }
.sr-skeleton-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: auto; padding-top: 6px; }

.sr-head-skeleton { align-items: flex-start; }
.sr-skeleton-hint { width: 176px; height: 32px; border-radius: var(--tb-r-pill); }

/* Nessuna destinazione: la pagina fa la domanda invece di sceglierne una da se'.
   Prima il server ripiegava su "Paris" e il JavaScript su "Milan" — due default
   diversi, e nessuno dei due detto a chi stava cercando. */
.sr-ask { margin: 48px 0; }
.sr-ask h1 { font: var(--tb-t-page-title); letter-spacing: var(--tb-tr-tight); }

.sr-nojs { margin-bottom: 16px; }
.sr-nojs a { color: var(--tb-blue-deep); font-weight: 600; }

/* Le card entrano a scaglioni: 45ms l'una, e il ritardo si ferma alla sesta.
   Oltre, l'ultima card arriverebbe dopo che l'utente ha gia' letto la prima —
   e uno scaglionamento che si fa aspettare non e' ritmo, e' attrito. */
@media (prefers-reduced-motion: no-preference) {
    .sr-list .sr-card {
        animation: sr-card-in 320ms var(--tb-ease) both;
        animation-delay: calc(min(var(--i, 0), 5) * 45ms);
    }
}
@keyframes sr-card-in {
    from { opacity: 0; transform: translateY(8px); }
}
