/*
 * maps/map.css
 * Stili della pagina mappa.
 * Dipende dalle variabili CSS definite in assets/css/color.css:
 *   --orange   colore principale del sito
 *   --text     colore testo primario
 *   --subtext  colore testo secondario
 *   --white    colore sfondo
 *
 * La pagina viene inclusa sotto l'header fixed del sito (#site-header).
 * La mappa occupa tutto lo spazio verticale rimanente.
 */

/* ── Reset pagina mappa ─────────────────────────────────────── */
.map-page {
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* ── Wrapper principale ─────────────────────────────────────── */
.map-wrap {
    position: relative;
    width: 100%;
    /* L'altezza viene calcolata in JS sottraendo l'altezza reale di #site-header */
    height: calc(100vh - 90px); /* fallback — JS aggiorna con il valore reale */
    overflow: hidden;
}

/* ── Mappa Google ───────────────────────────────────────────── */
#map {
    width: 100%;
    height: 100%;
}

/* ── Pulsante apri filtri ───────────────────────────────────── */
.filters-toggle {
    position: absolute;
    top: 26px;
    left: 16px;
    z-index: 100;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--white);
    color: var(--text);
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    transition: background 0.18s, box-shadow 0.18s, transform 0.15s;
    letter-spacing: 0.02em;
}
.filters-toggle:hover {
    background: var(--orange);
    color: var(--white);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.2);
}
.filters-toggle svg {
    flex-shrink: 0;
    transition: stroke 0.18s;
}

/* ── Overlay mobile ─────────────────────────────────────────── */
.filters-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 150;
    opacity: 0;
    transition: opacity 0.25s;
}
.filters-overlay.visible {
    display: block;
    opacity: 1;
}

/* ── Pannello filtri ────────────────────────────────────────── */
.filters-panel {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 300px;
    background: var(--white);
    z-index: 200;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid rgba(0, 0, 0, 0.07);
}
.filters-panel.open {
    transform: translateX(0);
}

/* Header pannello */
.filters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 18px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}
.filters-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.01em;
}
.filters-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: var(--subtext);
    transition: background 0.15s, color 0.15s;
}
.filters-close:hover {
    background: rgba(0, 0, 0, 0.12);
    color: var(--text);
}

/* Body pannello */
.filters-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.15) transparent;
}
.filters-body::-webkit-scrollbar { width: 4px; }
.filters-body::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 4px; }

/* Sezioni filtri */
.filters-section {
    margin-bottom: 22px;
}
.filters-section-title {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-weight: 700;
    color: var(--subtext);
    margin-bottom: 10px;
}

/* Chips filtro — lista verticale con check */
.filters-chips {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.filter-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--subtext);
    transition: background 0.15s, color 0.15s;
    user-select: none;
    text-align: left;
    width: 100%;
}
.filter-chip:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text);
}
.filter-chip.active {
    color: var(--text);
}

/* Checkbox visuale */
.filter-chip .chip-check {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 2px solid rgba(0, 0, 0, 0.18);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
    background: transparent;
}
.filter-chip.active .chip-check {
    border-color: transparent;
    /* il colore di sfondo viene impostato inline via JS con il colore della categoria */
}
.filter-chip.active .chip-check i {
    color: white;
    font-size: 0.65rem;
}
.filter-chip:not(.active) .chip-check i {
    display: none;
}

/* Pallino colore categoria */
.filter-chip .chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Infobox POI ────────────────────────────────────────────── */
.map-infobox {
    position: fixed;
    width: 300px;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.16), 0 1px 4px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    z-index: 300;
    animation: infoboxIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    pointer-events: all;
}
@keyframes infoboxIn {
    from { opacity: 0; transform: scale(0.9) translateY(6px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Striscia colore in cima */
.infobox-accent {
    height: 4px;
    width: 100%;
}

/* Pulsante chiudi */
.infobox-close {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.07);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--subtext);
    transition: background 0.15s, color 0.15s;
    z-index: 1;
}
.infobox-close:hover {
    background: rgba(0, 0, 0, 0.14);
    color: var(--text);
}

/* Foto */
.infobox-photo {
    width: 100%;
    height: 140px;
    overflow: hidden;
}
.infobox-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Body */
.infobox-body {
    padding: 14px 16px 16px;
}

/* Header nome + icona */
.infobox-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
    padding-right: 20px; /* spazio per il pulsante chiudi */
}
.infobox-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    /* background e colore vengono impostati via JS in base alla categoria */
}
.infobox-icon svg {
    width: 18px;
    height: 18px;
}
.infobox-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
    margin-bottom: 2px;
}
.infobox-cat {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    color: var(--subtext);
}

/* Descrizione */
.infobox-desc {
    font-size: 0.8rem;
    color: var(--subtext);
    line-height: 1.6;
    margin-bottom: 12px;
}

/* Riquadro distanza / tempo */
.infobox-travel {
    background: rgba(0, 0, 0, 0.04);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.travel-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text);
}
.travel-icon {
    font-size: 0.95rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    color: var(--subtext);
}
.travel-label {
    font-weight: 500;
}
.travel-label.loading {
    color: var(--subtext);
    font-style: italic;
}
.travel-locate {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    padding: 0;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--orange);
    cursor: pointer;
    transition: opacity 0.15s;
}
.travel-locate:hover { opacity: 0.75; }
.travel-locate svg { flex-shrink: 0; stroke: var(--orange); }

/* Azioni */
.infobox-actions {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}
.infobox-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 13px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.76rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: filter 0.18s, background 0.18s;
    white-space: nowrap;
}
.infobox-btn--primary {
    background: var(--orange);
    color: var(--white);
}
.infobox-btn--primary:hover { filter: brightness(0.9); }
.infobox-btn--ghost {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text);
}
.infobox-btn--ghost:hover { background: rgba(0, 0, 0, 0.11); }
.infobox-btn--article {
    color: var(--orange);
    background: rgba(0,0,0,0.04);
}

/* ── Pannello percorso ──────────────────────────────────────── */
.route-panel {
    position: fixed;
    bottom: 28px;
    left: 50%;
    /* transform: translateX(-50%) rimosso — applicato via JS dopo append al body */
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.16);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    z-index: 9999;
    min-width: 280px;
    max-width: calc(100vw - 48px);
    animation: infoboxIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.route-panel__info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.route-panel__icon {
    font-size: 1.2rem;
    color: var(--orange);
    flex-shrink: 0;
}
.route-panel__details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.route-panel__name {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.route-panel__stats {
    font-size: 0.78rem;
    color: var(--subtext);
    margin-top: 2px;
}
.route-panel__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: rgba(0,0,0,0.06);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--subtext);
    font-size: 0.9rem;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}
.route-panel__close:hover {
    background: rgba(0,0,0,0.12);
    color: var(--text);
}

/* Cursore drag sull'header infobox */
.infobox-header {
    cursor: move;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 600px) {
    .filters-panel { width: 85vw; max-width: 320px; }
    .map-infobox   { width: calc(100vw - 24px); left: 12px !important; }
}