/* ==========================================================================
   Playas de Carboneras - Estilos
   Diseño moderno, mobile-first, accesible.
   ========================================================================== */

:root {
    --color-primary: #0ea5e9;
    --color-primary-dark: #0284c7;
    --color-primary-light: #38bdf8;
    --color-accent: #f59e0b;
    --color-accent-dark: #d97706;
    --color-bg: #f1f5f9;
    --color-surface: #ffffff;
    --color-text: #1e293b;
    --color-text-soft: #475569;
    --color-muted: #64748b;
    --color-border: #e2e8f0;
    --color-success: #16a34a;
    --color-danger: #dc2626;
    --color-warning: #d97706;
    --color-info: #2563eb;
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.10);
    --shadow-lg: 0 18px 45px rgba(15, 23, 42, 0.16);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg);
    overflow-x: hidden;
    min-height: 100vh;
}

img {
    max-width: 100%;
    display: block;
}

a {
    color: var(--color-primary-dark);
    text-decoration: none;
}

/* ---------- Barra de marca ---------- */
.brand-bar {
    background: #0f172a;
    color: #94a3b8;
    text-align: center;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    padding: 0.3rem 0;
    text-transform: uppercase;
}

.brand-bar a {
    color: inherit;
    text-decoration: none;
}

.brand-bar a:hover {
    color: #cbd5e1;
}

/* ---------- Hero ---------- */
.hero {
    position: relative;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.78), rgba(2, 132, 199, 0.72));
    color: #fff;
    padding: 1.5rem 1.25rem 2.5rem;
    text-align: center;
    flex-shrink: 0;
    overflow: hidden;
}

.hero::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 60px;
    background: var(--color-surface);
    clip-path: ellipse(75% 100% at 50% 100%);
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 820px;
    margin: 0 auto;
}

.hero h1 {
    font-size: clamp(1.5rem, 5vw, 2.4rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    margin-bottom: 0.4rem;
}

.hero p {
    font-size: clamp(0.85rem, 3vw, 1.1rem);
    opacity: 0.95;
    margin-bottom: 0.8rem;
}

.hero-meta {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: #0c4a6e;
    background: rgba(186, 230, 253, 0.9);
    backdrop-filter: blur(8px);
    padding: 0.5rem 1rem;
    border-radius: 999px;
    border: 1px solid rgba(125, 211, 252, 0.8);
}

.hero-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.hero-meta .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(74, 222, 128, 0); }
    100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

/* ---------- Menú de navegación entre vistas ---------- */
.page-nav {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-nav-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1.2rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-muted);
    text-decoration: none;
    border: 2px solid transparent;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.page-nav-item:hover {
    color: var(--color-primary-dark);
    background: rgba(14, 165, 233, 0.08);
}

.page-nav-item.active {
    color: #fff;
    background: var(--color-primary);
    border-color: var(--color-primary-dark);
}

/* ---------- Controles ---------- */
.controls {
    max-width: 1200px;
    margin: 1.5rem auto 0;
    padding: 0 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
}

.search-box {
    position: relative;
    flex: 1 1 240px;
    max-width: 360px;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.6rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: 1rem;
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.search-box input:focus {
    outline: 2px solid var(--color-primary-light);
    border-color: var(--color-primary);
}

.search-box .icon {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-muted);
    font-size: 1.1rem;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chip {
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-soft);
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.chip:hover {
    border-color: var(--color-primary);
    color: var(--color-primary-dark);
}

.chip.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

/* ---------- Grid de playas ---------- */
.beaches {
    max-width: 1200px;
    margin: 1.5rem auto 3rem;
    padding: 0 1rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

@media (min-width: 640px) {
    .beaches { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1000px) {
    .beaches { grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
}

/* ---------- Tarjeta de playa ---------- */
.beach-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--color-border);
}

.beach-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.beach-card.hidden {
    display: none;
}

.beach-photo {
    position: relative;
    aspect-ratio: 16 / 10;
    background: linear-gradient(135deg, #bae6fd, #7dd3fc);
    overflow: hidden;
}

.beach-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.beach-card:hover .beach-photo img {
    transform: scale(1.05);
}

/* Logos de certificación (Q, Bandera Azul) */
.beach-badges {
    position: absolute;
    top: 0.6rem;
    left: 0.6rem;
    display: flex;
    gap: 0.35rem;
    z-index: 2;
}

.badge-logo {
    height: 28px !important;
    width: auto !important;
    max-width: 58px !important;
    object-fit: contain;
    border-radius: 3px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
    transition: var(--transition);
    display: block;
}

.beach-card:hover .badge-logo {
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.55));
}

.beach-photo .photo-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 2.5rem;
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
}

.beach-flag {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255, 255, 255, 0.95);
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(4px);
}

.beach-flag .flag-icon {
    width: 16px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}

.beach-flag.flag-green .flag-icon { background: #16a34a; }
.beach-flag.flag-yellow .flag-icon { background: #facc15; }
.beach-flag.flag-red .flag-icon { background: #dc2626; }
.beach-flag.flag-unknown .flag-icon { background: #94a3b8; }
.beach-flag.flag-none .flag-icon { background: #64748b; }

.beach-flag.flag-green {
    color: #166534;
    background: rgba(187, 247, 208, 0.95);
}
.beach-flag.flag-yellow {
    color: #854d0e;
    background: rgba(254, 240, 138, 0.95);
}
.beach-flag.flag-red {
    color: #991b1b;
    background: rgba(254, 202, 202, 0.95);
}
.beach-flag.flag-unknown {
    color: #475569;
    background: rgba(255, 255, 255, 0.95);
}
.beach-flag.flag-none {
    color: #475569;
    background: rgba(241, 245, 249, 0.95);
    font-size: 0.62rem;
}

.beach-body {
    padding: 1rem 1.1rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.beach-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.beach-title h2 {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.beach-size {
    font-size: 0.75rem;
    color: var(--color-muted);
    background: var(--color-bg);
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    white-space: nowrap;
    font-weight: 600;
}

/* ---------- Métricas meteorológicas / marinas ---------- */
.metrics {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

@media (min-width: 480px) {
    .metrics { grid-template-columns: repeat(2, 1fr); }
}

.metric {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.6rem;
    min-height: 52px;
    overflow: hidden;
    min-width: 0;
}

.metric .m-icon {
    font-size: 1.15rem;
    line-height: 1.2;
    flex-shrink: 0;
    width: 1.4rem;
    text-align: center;
}

.metric .m-body {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
    flex: 1;
}

.metric .m-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-muted);
    font-weight: 600;
}

.metric .m-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-text);
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.3;
}

.metric .m-sub {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--color-muted);
    line-height: 1.25;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.metric .m-value.loading {
    color: var(--color-muted);
    font-weight: 500;
    font-style: italic;
    font-size: 0.8rem;
}

.metric .m-value.na {
    color: var(--color-muted);
    font-weight: 500;
    font-size: 0.8rem;
}

/* ---------- Servicios ---------- */
.services {
    border-top: 1px solid var(--color-border);
    padding-top: 0.85rem;
}

.services-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    font-weight: 700;
    margin-bottom: 0.55rem;
}

.services-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.service-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-soft);
}

.service-tag.yes {
    color: #166534;
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.service-tag.no {
    color: #991b1b;
    background: #fef2f2;
    border-color: #fecaca;
}

.service-tag .s-icon {
    font-size: 0.85rem;
}

/* ---------- Más información (desplegable) ---------- */
.more-info {
    margin-top: 0.5rem;
    border-top: 1px solid var(--color-border);
    padding-top: 0.85rem;
}

.more-info summary {
    cursor: pointer;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    font-weight: 700;
    margin-bottom: 0.55rem;
    padding: 0;
    transition: var(--transition);
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.more-info summary::-webkit-details-marker {
    display: none;
}

.more-info summary::after {
    content: "▾";
    color: var(--color-primary);
    font-size: 0.7rem;
    transition: transform 0.2s ease;
}

.more-info[open] summary::after {
    transform: rotate(180deg);
}

.more-info summary:hover {
    color: var(--color-primary);
}

.more-info p {
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--color-text-soft);
    margin-top: 0.5rem;
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* ---------- Botón Cómo llegar ---------- */
.directions-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.4rem 0.8rem;
    margin-top: 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-primary);
    background: var(--color-surface);
    color: var(--color-primary-dark);
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.directions-btn:hover {
    background: var(--color-primary);
    color: #fff;
}

.directions-btn:active {
    background: var(--color-primary-dark);
    color: #fff;
}

/* ---------- Estado vacío / error ---------- */
.status-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-muted);
}

.status-message.error {
    color: var(--color-danger);
}

.status-message .spinner {
    width: 38px;
    height: 38px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------- Footer ---------- */
.footer {
    text-align: center;
    padding: 1.5rem 1rem 2rem;
    color: var(--color-muted);
    font-size: 0.82rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

.footer a {
    font-weight: 600;
}

.footer .data-source {
    margin-top: 0.4rem;
    font-size: 0.75rem;
    opacity: 0.85;
}

/* ---------- Accesibilidad ---------- */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.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;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
