/*
Theme Name: TodoParques.es
Theme URI: https://todoparques.es
Author: Antonio Blanco
Description: Tema nativo WordPress para TodoParques.es. CPT "parque" + taxonomía "region". Fase 1: renderizado SSR de home, hubs de comunidad, fichas y actividades. Los datos en tiempo real (condiciones, eventos, servicios) llegan por crons en fase 2.
Version: 1.0.0
Requires at least: 6.0
Requires PHP: 8.0
Text Domain: todoparques
*/

/* Estilos propios del tema. La base visual se carga desde assets/css/style.css del proyecto legacy. */

:root {
    --tp-blue: #0ea5e9;
    --tp-blue-dark: #0369a1;
    --tp-ink: #0f172a;
    --tp-muted: #64748b;
    --tp-bg: #f8fafc;
    --tp-card: #ffffff;
    --tp-border: #e2e8f0;
    --tp-radius: 16px;
}

* { box-sizing: border-box; }

/* Anula el layout de pantalla fija del CSS legacy (SPA): allí body es
   height:100vh; overflow:hidden, lo que impide el scroll vertical. */
html { height: auto; overflow-y: auto; }
body.tp {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--tp-ink);
    background: var(--tp-bg);
    line-height: 1.5;
    height: auto;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
}

/* Salvaguardas anti-overflow (público mayoritariamente móvil) */
body.tp img { max-width: 100%; height: auto; }
body.tp h1, body.tp h2, body.tp h3 { overflow-wrap: break-word; }

a { color: var(--tp-blue-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.tp-container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* Header */
.tp-header {
    background: #fff;
    border-bottom: 1px solid var(--tp-border);
    position: sticky; top: 0; z-index: 50;
}
.tp-header .tp-container { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.tp-logo { font-weight: 800; font-size: 20px; color: var(--tp-blue-dark); display: inline-flex; align-items: center; gap: 8px; }
.tp-nav a { margin-left: 20px; color: var(--tp-ink); font-weight: 500; font-size: 15px; }
.tp-nav .tp-menu { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; flex-wrap: wrap; }
.tp-nav .tp-menu li { margin: 0; }
.tp-nav .tp-menu a { display: inline-block; }
.tp-nav .tp-menu .current-menu-item > a { color: var(--tp-blue-dark); font-weight: 700; }

/* Hero */
.tp-hero { background: linear-gradient(135deg, var(--tp-blue), var(--tp-blue-dark)); color: #fff; padding: 56px 0; }
.tp-hero h1 { margin: 0 0 12px; font-size: 34px; line-height: 1.15; }
.tp-hero p { margin: 0; font-size: 18px; opacity: .92; max-width: 720px; }

/* Region chips */
.tp-regions { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0; }
.tp-chip {
    background: #fff; border: 1px solid var(--tp-border); border-radius: 999px;
    padding: 8px 16px; font-size: 14px; font-weight: 600; color: var(--tp-ink);
}
.tp-chip span { color: var(--tp-muted); font-weight: 500; }
.tp-chip:hover { border-color: var(--tp-blue); text-decoration: none; }

/* Section */
.tp-section { padding: 32px 0; }
.tp-section h2 { font-size: 24px; margin: 0 0 20px; }

/* Grid of beaches */
.tp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.tp-card {
    background: var(--tp-card); border: 1px solid var(--tp-border); border-radius: var(--tp-radius);
    overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .15s, transform .15s;
}
.tp-card:hover { box-shadow: 0 8px 24px rgba(15,23,42,.08); transform: translateY(-2px); text-decoration: none; }
.tp-card-img { aspect-ratio: 16 / 10; background: #dbeafe center/cover no-repeat; }
.tp-card-body { padding: 14px 16px 18px; }
.tp-card-body h3 { margin: 0 0 4px; font-size: 17px; color: var(--tp-ink); }
.tp-card-loc { color: var(--tp-muted); font-size: 13px; margin: 0 0 10px; }
.tp-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.tp-badge { font-size: 12px; padding: 3px 8px; border-radius: 6px; background: #f1f5f9; color: #334155; }
.tp-flag { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.tp-flag.green { background: #22c55e; } .tp-flag.yellow { background: #eab308; }
.tp-flag.red { background: #ef4444; } .tp-flag.black { background: #111827; }

/* Beach single */
.tp-ficha-hero { position: relative; height: 340px; background: #0369a1 center/cover no-repeat; border-radius: 0 0 var(--tp-radius) var(--tp-radius); }
.tp-ficha-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(3,54,84,.75), transparent 60%); border-radius: inherit; }
.tp-ficha-hero .tp-container { position: relative; z-index: 2; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; padding-bottom: 24px; color: #fff; }
.tp-ficha-hero h1 { margin: 0; font-size: 34px; }
.tp-ficha-hero .loc { opacity: .9; margin-top: 6px; }

.tp-breadcrumb { font-size: 13px; color: var(--tp-muted); padding: 14px 0; }
.tp-breadcrumb a { color: var(--tp-muted); }

.tp-cols { display: grid; grid-template-columns: 2fr 1fr; gap: 32px; align-items: start; }
/* Sin esto, el carrusel horizontal fuerza el ancho de la columna (min-width:auto)
   y desborda la página, cortando el lado derecho. */
.tp-cols > * { min-width: 0; }

.tp-panel { background: #fff; border: 1px solid var(--tp-border); border-radius: var(--tp-radius); padding: 22px; margin-bottom: 20px; }
.tp-panel h2 { margin-top: 0; font-size: 20px; }

.tp-conditions { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 14px; }
.tp-metric { background: var(--tp-bg); border-radius: 12px; padding: 14px; text-align: center; }
.tp-metric .v { font-size: 24px; font-weight: 800; color: var(--tp-blue-dark); }
.tp-metric .l { font-size: 12px; color: var(--tp-muted); margin-top: 2px; }

/* Previsión AEMET */
.tp-forecast { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tp-fc-day { background: var(--tp-bg); border-radius: 12px; padding: 12px; text-align: center; }
.tp-fc-date { font-weight: 700; font-size: 14px; text-transform: capitalize; }
.tp-fc-sky { font-size: 12px; color: var(--tp-muted); margin: 4px 0 8px; min-height: 2.4em; }
.tp-fc-temps { font-size: 18px; font-weight: 800; }
.tp-fc-temps .max { color: var(--tp-ink); }
.tp-fc-temps .min { color: var(--tp-muted); margin-left: 6px; font-weight: 600; }
.tp-fc-meta { list-style: none; padding: 8px 0 0; margin: 0; font-size: 12px; color: #334155; }
.tp-fc-meta li { padding: 2px 0; }
@media (max-width: 480px) { .tp-fc-sky { display: none; } .tp-fc-day { padding: 10px 6px; } }

.tp-specs { list-style: none; padding: 0; margin: 0; }
.tp-specs li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--tp-border); font-size: 14px; }
.tp-specs li:last-child { border-bottom: 0; }
.tp-specs .k { color: var(--tp-muted); }

.tp-faq { border-bottom: 1px solid var(--tp-border); padding: 14px 0; }
.tp-faq:last-child { border-bottom: 0; }
.tp-faq summary { font-weight: 600; cursor: pointer; }
.tp-faq p { margin: 10px 0 0; color: #334155; }

.tp-btn { display: inline-block; background: var(--tp-blue); color: #fff; padding: 12px 20px; border-radius: 10px; font-weight: 600; }
.tp-btn:hover { background: var(--tp-blue-dark); text-decoration: none; }
.tp-btn-sm { padding: 8px 14px; font-size: 13px; white-space: nowrap; }
.tp-btn-outline { background: #fff; color: var(--tp-blue-dark); border: 1px solid var(--tp-border); }
.tp-btn-outline:hover { background: var(--tp-bg); color: var(--tp-blue-dark); }

/* Carruseles (dónde comer / qué hacer) */
.tp-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 16px; }
.tp-sec-head h2 { margin: 0; font-size: 20px; }
.tp-carousel { display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px 2px 14px; -webkit-overflow-scrolling: touch; }
.tp-carousel::-webkit-scrollbar { height: 8px; }
.tp-carousel::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.tp-ccard { min-width: 230px; max-width: 230px; scroll-snap-align: start; background: #fff; border: 1px solid var(--tp-border); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 6px; color: var(--tp-ink); }
a.tp-ccard:hover { border-color: var(--tp-blue); box-shadow: 0 6px 18px rgba(15,23,42,.07); text-decoration: none; }
.tp-ccard .ic { font-size: 22px; }
.tp-ccard h3 { margin: 0; font-size: 15px; line-height: 1.3; }
.tp-ccard p { margin: 0; font-size: 13px; color: var(--tp-muted); }
.tp-ccard .rate { font-size: 12px; font-weight: 700; color: #b45309; }
.tp-ccard .cta { margin-top: auto; font-size: 13px; font-weight: 600; color: var(--tp-blue-dark); }

/* Widgets del lateral de ficha */
.tp-widget-title { font-size: 15px; text-transform: uppercase; letter-spacing: .03em; color: var(--tp-muted); margin: 0 0 12px; }
.tp-widget img { max-width: 100%; height: auto; border-radius: 8px; }
.tp-widget ul { list-style: none; padding: 0; margin: 0; }
.tp-widget ul li { padding: 6px 0; border-bottom: 1px solid var(--tp-border); font-size: 14px; }
.tp-widget ul li:last-child { border-bottom: 0; }
.tp-widget .textwidget { font-size: 14px; }

/* Footer */
.tp-footer { background: #0f172a; color: #cbd5e1; padding: 40px 0; margin-top: 40px; font-size: 14px; }
.tp-footer a { color: #e2e8f0; }
.tp-footer .tp-regions { margin-top: 16px; }
.tp-footer .tp-chip { background: transparent; border-color: #334155; color: #cbd5e1; }

/* Mapa: pista "toca para activar" en móvil */
#tp-map { position: relative; }
.tp-map-locked::after {
    content: "Toca para explorar el mapa";
    position: absolute; inset: 0; z-index: 500;
    display: flex; align-items: flex-end; justify-content: center;
    padding-bottom: 14px; pointer-events: none;
    font-size: 13px; font-weight: 600; color: #fff;
    background: linear-gradient(to top, rgba(3,54,84,.35), transparent 40%);
}

/* =========================================================================
   RESPONSIVE — el 95% del tráfico es móvil
   ========================================================================= */

/* Tablet: la ficha pasa a una columna (el lateral/publi va debajo) */
@media (max-width: 860px) {
    .tp-cols { grid-template-columns: 1fr; gap: 20px; }
    .tp-hero h1 { font-size: 28px; }
}

/* Móvil */
@media (max-width: 640px) {
    .tp-container { padding: 0 16px; }

    /* Header más compacto y con buen área táctil */
    .tp-header .tp-container { height: 56px; }
    .tp-logo { font-size: 17px; }
    .tp-nav a { margin-left: 14px; font-size: 14px; padding: 8px 2px; display: inline-block; }

    /* Hero home */
    .tp-hero { padding: 36px 0; }
    .tp-hero h1 { font-size: 24px; }
    .tp-hero p { font-size: 15px; }

    /* Hero ficha: menos alto para no comerse la pantalla */
    .tp-ficha-hero { height: 220px; }
    .tp-ficha-hero h1 { font-size: 24px; }

    /* Secciones y paneles con menos aire */
    .tp-section { padding: 22px 0; }
    .tp-section h2, .tp-sec-head h2 { font-size: 19px; }
    .tp-panel { padding: 16px; margin-bottom: 16px; }

    /* Rejilla de tarjetas a una columna real */
    .tp-grid { grid-template-columns: 1fr; gap: 16px; }

    /* Métricas de condiciones/mareas: 3 por fila aprovechando el ancho */
    .tp-conditions { grid-template-columns: repeat(3, 1fr); gap: 10px; }
    .tp-metric { padding: 10px; }
    .tp-metric .v { font-size: 20px; }

    /* Cabecera de sección (título + "Ver todos") que pueda envolver */
    .tp-sec-head { flex-wrap: wrap; }

    /* Carrusel: tarjetas un pelín más estrechas y con "peek" del siguiente */
    .tp-ccard { min-width: 200px; max-width: 200px; }

    /* Mapa del home: altura contenida */
    #tp-map { height: 320px !important; }

    /* Botones cómodos para el dedo */
    .tp-btn { padding: 11px 18px; }

    .tp-footer { padding: 28px 0; }
}

/* =========================================================================
   BLOG — entradas (single.php) y archivo de categoría (category.php)
   ========================================================================= */

/* Hero de entrada con imagen destacada (reutiliza .tp-ficha-hero) */
.tp-post-hero { height: 300px; }
.tp-post-kicker { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; opacity: .95; margin-bottom: 8px; }
.tp-hero .tp-post-kicker { color: #e0f2fe; }

.tp-post-meta { color: var(--tp-muted); font-size: 14px; margin-bottom: 18px; }

/* Tipografía del contenido editorial */
.tp-article { font-size: 17px; line-height: 1.7; color: #1e293b; }
.tp-article > *:first-child { margin-top: 0; }
.tp-article p { margin: 0 0 18px; }
.tp-article h2 { font-size: 24px; line-height: 1.25; margin: 36px 0 14px; scroll-margin-top: 80px; }
.tp-article h3 { font-size: 19px; line-height: 1.3; margin: 26px 0 10px; scroll-margin-top: 80px; }
.tp-article ul, .tp-article ol { margin: 0 0 18px; padding-left: 22px; }
.tp-article li { margin: 6px 0; }
.tp-article a { color: var(--tp-blue-dark); text-decoration: underline; }
.tp-article a:hover { color: var(--tp-blue); }
.tp-article strong { color: var(--tp-ink); }
.tp-article blockquote { margin: 0 0 18px; padding: 8px 18px; border-left: 4px solid var(--tp-blue); background: var(--tp-bg); color: #334155; }
.tp-article img { border-radius: 12px; }

/* Tablas del contenido (wp-block-table) */
.tp-article .wp-block-table,
.tp-article table { width: 100%; margin: 0 0 22px; }
.tp-article table { border-collapse: collapse; font-size: 15px; }
.tp-article th, .tp-article td { border: 1px solid var(--tp-border); padding: 10px 12px; text-align: left; vertical-align: top; }
.tp-article thead th { background: var(--tp-bg); font-weight: 700; }
.tp-article tbody tr:nth-child(even) { background: #fafcff; }
.tp-article .wp-block-table { overflow-x: auto; }

/* Navegación entre entradas */
.tp-post-nav { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 8px; }
.tp-post-nav a { font-weight: 600; }

@media (max-width: 640px) {
    .tp-post-hero { height: 200px; }
    .tp-article { font-size: 16px; }
    .tp-article h2 { font-size: 21px; }
    .tp-article h3 { font-size: 18px; }
}

/* =========================================================================
   EQUIPO / AUTORES
   ========================================================================= */

/* Firma (byline) con avatar */
.tp-post-meta { display: flex; align-items: center; gap: 12px; }
.tp-byline-avatar { width: 44px; height: 44px; border-radius: 50%; flex: 0 0 auto; background: var(--tp-bg); }
.tp-byline-text { line-height: 1.4; }

.tp-kicker { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--tp-muted); }

/* Caja de autor al final del post */
.tp-author-box { display: flex; gap: 18px; align-items: flex-start; }
.tp-author-box-avatar { width: 88px; height: 88px; border-radius: 50%; flex: 0 0 auto; background: var(--tp-bg); }
.tp-author-box-body h3 { margin: 4px 0 2px; font-size: 19px; }
.tp-author-box-body h3 a { color: var(--tp-ink); text-decoration: none; }
.tp-author-box-body p { margin: 6px 0; color: #334155; }
.tp-author-box-link { font-weight: 600; }

/* Página /equipo: rejilla de tarjetas */
.tp-team { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 22px; margin: 8px 0; }
.tp-team-card { background: #fff; border: 1px solid var(--tp-border); border-radius: var(--tp-radius); padding: 24px; text-align: center; scroll-margin-top: 80px; }
.tp-team-avatar { width: 120px; height: 120px; border-radius: 50%; margin: 0 auto 12px; display: block; background: var(--tp-bg); }
.tp-team-card h3 { margin: 0 0 2px; font-size: 20px; }
.tp-team-role { color: var(--tp-blue-dark); font-weight: 600; font-size: 14px; margin: 0 0 12px; }
.tp-team-bio { color: #334155; font-size: 15px; line-height: 1.6; margin: 0 0 12px; }
.tp-team-exp { font-size: 13px; color: var(--tp-muted); margin: 0; }

@media (max-width: 640px) {
    .tp-author-box { flex-direction: column; align-items: center; text-align: center; }
    .tp-author-box-avatar { width: 96px; height: 96px; }
}

/* ── Banner ambiental: Pollen + AQI ──────────────────────────────── */
.tp-env-banner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 20px auto 0;
}
.tp-env-card {
    background: #fff;
    border: 1px solid var(--tp-border);
    border-radius: var(--tp-radius);
    padding: 20px 24px;
}
.tp-env-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--tp-muted);
    margin-bottom: 14px;
}
.tp-env-time {
    font-size: 11px;
    color: var(--tp-muted);
    margin-top: 12px;
}

/* Polen */
.tp-pollen-grid { display: flex; flex-direction: column; gap: 10px; }
.tp-pollen-item { display: grid; grid-template-columns: 24px 1fr auto; grid-template-rows: auto 4px; align-items: center; gap: 0 8px; }
.tp-pollen-ic   { font-size: 18px; grid-row: 1; grid-column: 1; }
.tp-pollen-name { font-size: 14px; color: var(--tp-ink); grid-row: 1; grid-column: 2; }
.tp-pollen-val  { font-size: 13px; grid-row: 1; grid-column: 3; white-space: nowrap; }
.tp-pollen-bar  {
    grid-row: 2; grid-column: 2 / 4;
    height: 4px;
    border-radius: 2px;
    background: var(--tp-border);
    position: relative;
    margin-top: 4px;
}
.tp-pollen-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    width: var(--pollen-w, 0%);
    background: var(--pollen-c, #6b7280);
    border-radius: 2px;
}

/* AQI */
.tp-aqi-main   { display: flex; align-items: baseline; gap: 6px; margin-bottom: 4px; }
.tp-aqi-value  { font-size: 52px; font-weight: 800; line-height: 1; }
.tp-aqi-uaqi   { font-size: 13px; color: var(--tp-muted); font-weight: 600; }
.tp-aqi-cat    { font-size: 16px; margin-bottom: 6px; }
.tp-aqi-pol    { font-size: 13px; color: var(--tp-muted); }

@media (max-width: 640px) {
    .tp-env-banner { grid-template-columns: 1fr; }
    .tp-aqi-value  { font-size: 40px; }
}

/* ── Paginación ───────────────────────────────────────────────── */
.navigation.pagination { margin: 40px 0 16px; }

.nav-links {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1.5px solid var(--tp-border, #e0e0e0);
    background: #fff;
    color: var(--tp-text, #1a1a1a);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s;
}

.page-numbers:hover {
    background: var(--tp-primary, #2E7D32);
    border-color: var(--tp-primary, #2E7D32);
    color: #fff;
}

.page-numbers.current {
    background: var(--tp-primary, #2E7D32);
    border-color: var(--tp-primary, #2E7D32);
    color: #fff;
    font-weight: 700;
    pointer-events: none;
}

.page-numbers.dots {
    border-color: transparent;
    background: transparent;
    color: #999;
    pointer-events: none;
    min-width: 24px;
    padding: 0;
}

.page-numbers.prev,
.page-numbers.next {
    padding: 0 14px;
    font-weight: 600;
    gap: 4px;
}

/* ── Nearby / geolocalización ─────────────────────────────────── */
.tp-nearby-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}
.tp-nearby-header h2 { margin-bottom: 0; }

.tp-btn-geo {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 20px;
    border: 1.5px solid var(--tp-primary, #2E7D32);
    background: #fff;
    color: var(--tp-primary, #2E7D32);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background .2s, color .2s;
}
.tp-btn-geo:hover { background: var(--tp-primary, #2E7D32); color: #fff; }
.tp-btn-geo:disabled { opacity: .6; cursor: default; }

.tp-btn-geo.tp-geo-loading svg {
    animation: tp-spin .8s linear infinite;
}
@keyframes tp-spin { to { transform: rotate(360deg); } }

.tp-btn-geo.tp-geo-active {
    background: var(--tp-primary, #2E7D32);
    color: #fff;
}

.tp-km { color: #888; font-size: 12px; }
.tp-card-excerpt { font-size: 12px; color: #666; margin: 4px 0 0; line-height: 1.4; }

