/* Mapa de chiringuitos — paleta playa
   arena #f4a261 · mar #2a9d8f · acento #e76f51 · texto #264653 · crema #fffaf0
*/

/* ───────── Tipos de marcador (issues #440 y #441) ─────────
   Variables compartidas entre el badge del autocompletado y las chinchetas
   de las capas toggleables del mapa. */
:root {
    --ch-color-localidad: #264653; /* azul océano */
    --ch-color-playa: #E9C46A;     /* naranja arena */
}

/* ───────── Splash ───────── */
.ch-splash {
    position: fixed; inset: 0; z-index: 10000;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #2a9d8f 0%, #5cc1b3 50%, #f4a261 100%);
    opacity: 1; transition: opacity 400ms ease-out;
}
.ch-splash--hiding { opacity: 0; pointer-events: none; }
.ch-splash__content {
    display: flex; flex-direction: column; align-items: center;
    gap: 1.25rem; padding: 2rem; max-width: 520px; text-align: center;
}
.ch-splash__spinner {
    width: 80px; height: 80px;
    border: 4px solid rgba(255,255,255,0.25);
    border-top-color: #fff; border-radius: 50%;
    animation: ch-spin 1s linear infinite;
}
.ch-splash__title {
    color: #fff; font-size: 1.75rem; font-weight: 700; margin: 0;
    text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.ch-splash__message {
    color: #fffaf0; font-size: 1rem; min-height: 3em;
    transition: opacity 300ms ease-in-out;
}
.ch-splash__dots { display: flex; gap: 8px; }
.ch-splash__dots span {
    width: 8px; height: 8px; border-radius: 50%;
    background: rgba(255,255,255,0.7);
    animation: ch-pulse 1.4s ease-in-out infinite;
}
.ch-splash__dots span:nth-child(2) { animation-delay: 0.2s; }
.ch-splash__dots span:nth-child(3) { animation-delay: 0.4s; }
.ch-splash__skip {
    margin-top: 1rem; padding: 0.65rem 1.4rem;
    background: rgba(255,255,255,0.15); color: #fff;
    border: 1.5px solid rgba(255,255,255,0.6); border-radius: 24px;
    font-weight: 600; cursor: pointer; transition: background 200ms;
}
.ch-splash__skip:hover, .ch-splash__skip:focus-visible {
    background: rgba(255,255,255,0.28);
}
@keyframes ch-spin { to { transform: rotate(360deg); } }
@keyframes ch-pulse {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* ───────── Buscador ───────── */
.ch-search {
    position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
    z-index: 600;
    display: flex; align-items: center; gap: 6px;
    background: rgba(255, 250, 240, 0.92);
    border: 1.5px solid #2a9d8f; border-radius: 24px;
    padding: 4px 4px 4px 14px;
    width: min(92vw, 380px);
    box-shadow: 0 4px 14px rgba(38, 70, 83, 0.18);
    backdrop-filter: blur(4px);
    transition: width 300ms ease, border-radius 300ms ease, padding 300ms ease;
}
.ch-search input {
    flex: 1; border: none; outline: none;
    background: transparent; color: #264653; font-size: 0.95rem; padding: 6px 0;
    transition: opacity 200ms;
}
.ch-search input::placeholder { color: #6b7d85; }
.ch-search__btn {
    width: 34px; height: 34px; border-radius: 50%;
    background: #2a9d8f; color: #fff; border: none; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background 200ms; flex-shrink: 0;
}
.ch-search__btn:hover, .ch-search__btn:focus-visible { background: #228077; }
/* Mobile: colapsado a solo lupa en top-right, expande hacia la izquierda */
@media (max-width: 600px) {
    .ch-search {
        left: auto; right: 16px; transform: none; top: 16px;
        width: 42px; padding: 4px; border-radius: 50%; overflow: hidden;
        justify-content: flex-end;
    }
    .ch-search input { width: 0; min-width: 0; opacity: 0; padding: 0; pointer-events: none; flex: 0; }
    .ch-search.ch-search--expanded {
        /* respeta locate (left:16 + 34px ancho) + 8px gap + 16px right del buscador */
        width: calc(100vw - 74px);
        border-radius: 24px; padding: 4px 4px 4px 14px; justify-content: flex-start;
    }
    .ch-search.ch-search--expanded input {
        flex: 1; opacity: 1; padding: 6px 0; pointer-events: auto; width: auto;
    }
}

/* ───────── Dropdown de sugerencias (Issue #243) ─────────
   Reemplaza la búsqueda Nominatim por un dropdown propio (localidades + playas).
   Anclado debajo del .ch-search. */
.ch-suggest {
    position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
    z-index: 599;
    width: min(92vw, 380px);
    max-height: 320px; overflow-y: auto;
    background: rgba(255, 250, 240, 0.97);
    border: 1.5px solid #2a9d8f; border-radius: 14px;
    box-shadow: 0 6px 18px rgba(38, 70, 83, 0.22);
    list-style: none; margin: 0; padding: 4px 0;
    backdrop-filter: blur(4px);
}
.ch-suggest[hidden] { display: none; }
.ch-suggest__item {
    padding: 8px 14px; cursor: pointer; color: #264653;
    display: flex; flex-direction: column; gap: 2px;
    border-bottom: 1px solid rgba(42, 157, 143, 0.12);
}
.ch-suggest__item:last-child { border-bottom: none; }
.ch-suggest__item:hover,
.ch-suggest__item--active { background: rgba(42, 157, 143, 0.14); }
.ch-suggest__title { font-weight: 600; font-size: 0.95rem; }
.ch-suggest__subtitle { font-size: 0.8rem; color: #6b7d85; }
.ch-suggest__type {
    display: inline-block; font-size: 0.7rem; padding: 1px 6px; border-radius: 8px;
    background: var(--ch-color-localidad); color: #fff; margin-right: 6px; vertical-align: middle;
}
.ch-suggest__type--playa { background: var(--ch-color-playa); color: #264653; }
.ch-suggest__empty {
    padding: 10px 14px; color: #6b7d85; font-size: 0.88rem; text-align: center;
}
@media (max-width: 600px) {
    .ch-suggest { left: auto; right: 16px; transform: none; width: calc(100vw - 32px); }
}

/* ───────── Status efímero ───────── */
.ch-status {
    position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
    z-index: 600; background: #264653; color: #fffaf0;
    padding: 8px 16px; border-radius: 20px; font-size: 0.9rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2); display: none;
}
.ch-status--visible { display: block; animation: ch-fade-in 200ms; }
@keyframes ch-fade-in {
    from { opacity: 0; transform: translateX(-50%) translateY(6px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ───────── sr-only (no presente en theme.css) ───────── */
.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ───────── Botón flotante "Mi ubicación" — encima del +/- de Leaflet ───────── */
.ch-locate-float {
    position: fixed; top: 16px; left: 16px; z-index: 1000;
    display: inline-flex; align-items: center; gap: 7px;
    padding: 7px 14px;
    background: rgba(255, 250, 240, 0.92);
    color: #2a9d8f; border: 1.5px solid #2a9d8f; border-radius: 20px;
    font-size: 0.85rem; font-weight: 600; cursor: pointer;
    box-shadow: 0 4px 14px rgba(38, 70, 83, 0.18);
    backdrop-filter: blur(4px);
    transition: background 200ms;
    white-space: nowrap;
}
.ch-locate-float:hover { background: rgba(240, 250, 250, 0.97); }
.ch-locate-float:active { transform: scale(0.97); }
.ch-locate-float:disabled { opacity: 0.6; cursor: default; }
/* Empujar controles +/- de Leaflet hacia abajo y alinear con botón locate */
/* Desktop: zoom + filtros en fila horizontal */
.leaflet-top.leaflet-left { display: flex; flex-direction: row; align-items: flex-start; flex-wrap: nowrap; }
.leaflet-top.leaflet-left .leaflet-control-zoom { margin-top: 60px; margin-left: 16px; }
.leaflet-top.leaflet-left .leaflet-control-layers { margin-top: 60px; margin-left: 8px; }
/* Paleta chiringuito para los controles de zoom */
.leaflet-control-zoom.leaflet-bar {
    border: none;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(38, 70, 83, 0.18);
    backdrop-filter: blur(4px);
}
.leaflet-control-zoom a {
    background: rgba(255, 250, 240, 0.92) !important;
    color: #2a9d8f !important;
    border-color: rgba(42, 157, 143, 0.25) !important;
    font-weight: 700;
    width: 34px !important; height: 34px !important; line-height: 34px !important;
}
.leaflet-control-zoom a:hover {
    background: rgba(240, 250, 250, 0.97) !important;
    color: #228077 !important;
}
/* Mobile: botón circular, misma posición */
@media (max-width: 600px) {
    .ch-locate-float {
        top: 16px; left: 16px; right: auto; bottom: auto;
        width: 34px; height: 34px; padding: 0;
        border-radius: 50%; justify-content: center; gap: 0;
    }
    .ch-locate-label { display: none; }
    /* Mobile: filtros debajo del zoom (columna) */
    .leaflet-top.leaflet-left { flex-direction: column; }
    .leaflet-top.leaflet-left .leaflet-control-zoom { margin-top: 58px; }
    .leaflet-top.leaflet-left .leaflet-control-layers { margin-top: 8px; margin-left: 16px; }
}

/* ───────── Pin de ubicación actual (azul discreto) ───────── */
.ch-user-pin {
    width: 13px; height: 13px;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.75);
    border: 2px solid rgba(255,255,255,0.9);
    box-shadow: 0 1px 5px rgba(37,99,235,0.45);
}
.ch-user-tooltip.leaflet-tooltip {
    background: rgba(38, 70, 83, 0.82); color: #fffaf0;
    border: none; border-radius: 6px;
    font-size: 0.72rem; font-weight: 500;
    padding: 2px 7px; white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}
.ch-user-tooltip.leaflet-tooltip::before { border-top-color: rgba(38, 70, 83, 0.82); }

/* ───────── Chinchetas de capas toggleables (issues #440 y #441) ─────────
   `.ch-pin` es la base (gota Leaflet circular con borde blanco y sombra).
   `.ch-pin--localidad` y `.ch-pin--playa` definen el color de fondo. */
.ch-pin {
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(38, 70, 83, 0.45);
}
.ch-pin--localidad { background: var(--ch-color-localidad); }
.ch-pin--playa     { background: var(--ch-color-playa); }

/* ───────── Responsive + reduced-motion ───────── */
@media (max-width: 600px) {
    .ch-splash__title { font-size: 1.4rem; }
    .ch-splash__spinner { width: 60px; height: 60px; }
}
@media (prefers-reduced-motion: reduce) {
    .ch-search { transition: none; }
    .ch-search input { transition: none; }
}
@media (prefers-reduced-motion: reduce) {
    .ch-splash, .ch-splash--hiding, .ch-splash__message { transition: none; }
    .ch-splash__spinner, .ch-splash__dots span { animation: none; }
}

/* ───────── Carrusel inferior (SDD 241b) ─────────
   Carrusel horizontal flotante en el bottom del viewport con tarjetas de
   chiringuitos cercanos. Glassmorphism coherente con .ch-search /
   .ch-locate-float. Scroll horizontal nativo + scroll-snap (sin AutoScroll JS).
*/
.ch-carousel {
    position: fixed; left: 0; right: 0; bottom: 0;
    z-index: 500;
    background: rgba(255, 250, 240, 0.92);
    backdrop-filter: blur(4px);
    border-top: 1.5px solid #2a9d8f;
    box-shadow: 0 -4px 20px rgba(38, 70, 83, 0.12);
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    max-height: 38vh;
}
.ch-carousel[hidden] { display: none; }

.ch-carousel__track {
    display: flex; gap: 10px;
    overflow-x: auto; overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(42, 157, 143, 0.5) transparent;
    padding-bottom: 4px; /* hueco para la scrollbar visible */
}
.ch-carousel__track::-webkit-scrollbar { height: 6px; }
.ch-carousel__track::-webkit-scrollbar-track { background: transparent; }
.ch-carousel__track::-webkit-scrollbar-thumb {
    background: rgba(42, 157, 143, 0.5); border-radius: 3px;
}
.ch-carousel__track:focus-visible {
    outline: 2px solid #2a9d8f; outline-offset: 2px;
}

.ch-card {
    flex: 0 0 220px;
    scroll-snap-align: start;
    background: #fffaf0;
    border: 1px solid #2a9d8f;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    display: flex; flex-direction: column;
    transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease;
    text-decoration: none;
    color: inherit;
}
.ch-card:hover, .ch-card:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(38, 70, 83, 0.22);
    border-color: #e76f51;
    outline: none;
}
.ch-card:active { transform: translateY(0); }

.ch-card__photo {
    width: 100%;
    aspect-ratio: 16 / 10;
    background: linear-gradient(135deg, #2a9d8f 0%, #5cc1b3 50%, #f4a261 100%);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    position: relative;
}
.ch-card__photo img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.ch-card__photo-placeholder {
    font-size: 2.4rem;
    line-height: 1;
    /* drop-shadow para que el emoji destaque sobre el gradiente mar→arena */
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.18));
}

.ch-card__body {
    padding: 8px 12px 10px;
    display: flex; flex-direction: column; gap: 4px;
}
.ch-card__name {
    font-size: 0.95rem; font-weight: 600;
    color: #264653;
    margin: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ch-card__distance {
    font-size: 0.8rem; font-weight: 500;
    color: #2a9d8f;
}

/* ───────── Tarjeta CTA empty-state (SDD 241c) ─────────
   Variante de .ch-card que se muestra cuando no hay chiringuitos en la zona.
   Es un <a> real apuntando a /chiringuito/aportar; click/Enter navegan de
   forma nativa, sin listeners JS extra.
*/
.ch-card--empty {
    flex: 0 0 220px;
    align-items: center; justify-content: center;
    background: linear-gradient(135deg, #fffaf0 0%, #fff7e6 100%);
    border: 1.5px dashed #2a9d8f;
    padding: 14px 12px;
    text-align: center;
    text-decoration: none;
    color: inherit;
}
.ch-card--empty:hover, .ch-card--empty:focus-visible {
    border-color: #e76f51;
    border-style: solid;
    background: linear-gradient(135deg, #fffaf0 0%, #ffe8d6 100%);
}
.ch-card--empty__icon {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: rgba(42, 157, 143, 0.12);
    color: #2a9d8f;
    display: inline-flex; align-items: center; justify-content: center;
    margin-bottom: 6px;
}
.ch-card--empty__title {
    font-size: 0.85rem; font-weight: 600;
    color: #264653;
    margin: 0;
    line-height: 1.25;
    white-space: normal; overflow: visible; text-overflow: clip;
}
.ch-card--empty__cta {
    font-size: 0.85rem; font-weight: 600;
    color: #e76f51;
    margin-top: 4px;
}

/* Estados especiales (vacío y error) — ocupan todo el track */
.ch-carousel__empty,
.ch-carousel__error {
    flex: 1 1 100%;
    display: flex; align-items: center; justify-content: center;
    gap: 12px;
    min-height: 80px;
    padding: 12px 16px;
    color: #264653;
    font-size: 0.9rem;
    text-align: center;
}
.ch-carousel__error { color: #b04a36; }
.ch-carousel__retry {
    appearance: none;
    background: #2a9d8f; color: #fff;
    border: none; border-radius: 16px;
    padding: 6px 14px;
    font-size: 0.85rem; font-weight: 600;
    cursor: pointer;
    transition: background 200ms;
}
.ch-carousel__retry:hover,
.ch-carousel__retry:focus-visible {
    background: #228077;
    outline: none;
}

@media (max-width: 600px) {
    .ch-carousel {
        max-height: 28vh;
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    }
    .ch-card { flex-basis: 64vw; }
    .ch-card__name { font-size: 0.9rem; }
    .ch-card--empty { flex-basis: 64vw; }
}

@media (prefers-reduced-motion: reduce) {
    .ch-card { transition: none; }
    .ch-card:hover, .ch-card:focus-visible { transform: none; }
    .ch-card--empty { transition: none; }
    .ch-card--empty:hover, .ch-card--empty:focus-visible { transform: none; }
}
