/* ============================================================
   GLOBAL.CSS — Infera
   Estilos base compartidos por todas las páginas.
   Diseño editorial limpio, luminoso y basado en infera.es
   ============================================================ */

/* ---- CSS Custom Properties (Design Tokens) ---- */
:root {
    /* Paleta de colores oficial de Infera */
    --color-bg:          #ffffff;
    --color-bg-surface:  #f8f9fa;
    --color-bg-elevated: #ffffff;
    --color-bg-alt:      #f3f4f6;
    
    --color-text:        #333333;
    --color-text-dark:   #111111;
    --color-text-muted:  #666666;
    --color-text-light:  #888888;
    
    --color-accent:      #ff6600;        /* Naranja característico de Infera */
    --color-accent-hover:#e55a00;
    --color-primary-blue:#2ea3f2;        /* Azul corporativo Divi/Infera */
    
    --color-border:      #e5e7eb;
    --color-border-subtle: #f0f0f0;
    --color-white:       #ffffff;
    --color-black:       #000000;

    /* Tipografía */
    --font-serif: 'Roboto Serif', Georgia, 'Times New Roman', serif;
    --font-sans:  'Open Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono:  'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    --fs-xs:   0.75rem;    /* 12px */
    --fs-sm:   0.875rem;   /* 14px */
    --fs-base: 1rem;       /* 16px */
    --fs-md:   1.125rem;   /* 18px */
    --fs-lg:   1.25rem;    /* 20px */
    --fs-xl:   1.5rem;     /* 24px */
    --fs-2xl:  2rem;       /* 32px */
    --fs-3xl:  2.5rem;     /* 40px */
    --fs-4xl:  3.25rem;    /* 52px */

    --fw-regular:  400;
    --fw-medium:   500;
    --fw-semibold: 600;
    --fw-bold:     700;
    --fw-black:    900;

    --lh-tight:  1.25;
    --lh-normal: 1.65;
    --lh-loose:  1.8;

    /* Espaciado */
    --space-xs:  0.25rem;
    --space-sm:  0.5rem;
    --space-md:  1rem;
    --space-lg:  1.5rem;
    --space-xl:  2rem;
    --space-2xl: 3rem;
    --space-3xl: 4.5rem;
    --space-4xl: 6rem;

    /* Layout */
    --container-max:     1180px;
    --container-narrow:  820px;
    --container-padding: 1.5rem;

    /* Bordes y sombras */
    --radius-sm:  4px;
    --radius-md:  8px;
    --radius-lg:  12px;
    --radius-xl:  16px;

    --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md:  0 4px 14px rgba(0, 0, 0, 0.08);
    --shadow-lg:  0 10px 30px rgba(0, 0, 0, 0.12);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.25);

    /* Transiciones */
    --transition-fast:   150ms ease;
    --transition-base:   250ms ease;
    --transition-slow:   400ms ease;

    /* Z-index */
    --z-header:  100;
    --z-overlay: 200;
    --z-modal:   300;
    --z-toast:   400;
}

/* ---- Reset ---- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    font-weight: var(--fw-regular);
    line-height: var(--lh-normal);
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--color-text-dark);
    font-family: var(--font-serif);
    font-weight: var(--fw-bold);
    line-height: var(--lh-tight);
}

img,
picture,
video {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Leaflet map resets: protect Leaflet canvas & svg panes from global resets */
.leaflet-container canvas,
.leaflet-container svg,
.leaflet-pane canvas,
.leaflet-pane svg {
    max-width: none !important;
    max-height: none !important;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-accent);
}

ul,
ol {
    list-style: none;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
}

input,
textarea,
select {
    font: inherit;
}

/* Accesibilidad: Reducción de movimiento */
@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;
    }
}

/* ---- Skip Link ---- */
.skip-link {
    position: absolute;
    top: -100%;
    left: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-accent);
    color: var(--color-white);
    font-weight: var(--fw-semibold);
    border-radius: var(--radius-sm);
    z-index: var(--z-toast);
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: var(--space-md);
}

/* ---- Contenedores ---- */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin-inline: auto;
    padding-inline: var(--container-padding);
}

.container--narrow {
    max-width: var(--container-narrow);
}

/* ---- Screen Reader Only ---- */
.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;
}

/* ============================================================
   HEADER
   ============================================================ */

#site-header {
    position: sticky;
    top: 0;
    z-index: var(--z-header);
}

.site-header {
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    background-color: #ffffff;
    border-bottom: 1px solid var(--color-border);
    transition: box-shadow var(--transition-base);
}

.site-header__container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: var(--container-max);
    margin-inline: auto;
    padding: 0.75rem var(--container-padding);
}

.site-header__logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.site-header__logo img {
    height: 48px;
    width: auto;
    object-fit: contain;
}

.site-header__logo-text {
    font-family: var(--font-serif);
    font-weight: var(--fw-black);
    font-size: 1.35rem;
    letter-spacing: -0.02em;
    color: var(--color-text-dark);
}

/* Hamburger */
.site-header__toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 32px;
    height: 32px;
    padding: 4px;
}

.site-header__toggle-bar {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--color-text-dark);
    border-radius: 2px;
    transition: transform var(--transition-base), opacity var(--transition-base);
}

/* Nav */
.site-header__menu {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.site-header__link {
    font-size: 0.925rem;
    font-weight: var(--fw-semibold);
    color: #444444;
    transition: color var(--transition-fast);
    position: relative;
    padding: 0.5rem 0;
}

.site-header__link:hover,
.site-header__link[aria-current="page"] {
    color: var(--color-accent);
}

.site-header__link[aria-current="page"]::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--color-accent);
}

/* Mobile nav */
@media (max-width: 768px) {
    .site-header__toggle {
        display: flex;
        z-index: 1070; /* Botón siempre clicable y en primer plano */
    }

    /* Fondo oscurecedor al abrir menú */
    .site-header__overlay {
        position: fixed;
        inset: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(0, 0, 0, 0.45);
        z-index: 1050;
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--transition-base);
    }

    .site-header__overlay.is-visible {
        opacity: 1;
        pointer-events: auto;
    }

    /* Panel lateral desplegable del menú */
    .site-header__nav {
        position: fixed;
        top: 0;
        right: 0;
        width: 280px;
        max-width: 85vw;
        height: 100dvh;
        background-color: #ffffff;
        border-left: 1px solid var(--color-border);
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
        transform: translateX(100%);
        transition: transform var(--transition-base);
        padding: var(--space-4xl) var(--space-xl);
        z-index: 1060; /* ¡POR ENCIMA DEL OVERLAY (1050) PARA RECIBIR CLICS! */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .site-header__nav.is-open {
        transform: translateX(0);
    }

    .site-header__menu {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-md);
        width: 100%;
    }

    .site-header__menu-item {
        width: 100%;
    }

    .site-header__link {
        display: block;
        width: 100%;
        padding: 0.65rem 0;
        font-size: 1.1rem;
        color: var(--color-text-dark);
        text-decoration: none;
    }

    .site-header__toggle.is-active .site-header__toggle-bar:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }
    .site-header__toggle.is-active .site-header__toggle-bar:nth-child(2) {
        opacity: 0;
    }
    .site-header__toggle.is-active .site-header__toggle-bar:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }
}

/* ============================================================
   CONTENEDOR DE ARTÍCULOS AISLADO (Para artículos de LLM)
   ============================================================ */
.infera-article-main,
main[role="main"] {
    width: 100%;
    overflow-x: clip; /* Evita que tablas o gráficos anchos del LLM desborden la pantalla */
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
    margin-top: var(--space-4xl);
    padding: var(--space-3xl) 0 var(--space-xl);
    border-top: 1px solid var(--color-border);
    background-color: #fafafa;
}

.site-footer__container {
    max-width: var(--container-max);
    margin-inline: auto;
    padding-inline: var(--container-padding);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
    text-align: center;
}

.site-footer__brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.site-footer__logo img {
    height: 38px;
    width: auto;
}

.site-footer__tagline {
    font-size: var(--fs-sm);
    color: var(--color-text-muted);
}

.site-footer__links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-md) var(--space-xl);
}

.site-footer__links a {
    font-size: var(--fs-sm);
    color: var(--color-text-muted);
    transition: color var(--transition-fast);
}

.site-footer__links a:hover {
    color: var(--color-accent);
}

.site-footer__copy {
    font-size: var(--fs-xs);
    color: var(--color-text-light);
    margin-top: var(--space-sm);
}


/* ============================================================
   COOKIE CONSENT (RGPD, LSSI-CE & AEPD + Consent Mode v2)
   100% Gratuito, sin límites ni dependencias externas.
   ============================================================ */

/* Banner de primera capa */
.infera-consent-banner {
    position: fixed;
    bottom: 1.25rem;
    left: 1.25rem;
    right: 1.25rem;
    max-width: 1040px;
    margin: 0 auto;
    background: #ffffff;
    color: #111827;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
    padding: 1.5rem 1.75rem;
    z-index: 999999;
    font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    animation: inferaConsentSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.infera-consent-banner[hidden],
.infera-consent-modal-overlay[hidden],
.infera-consent-floating[hidden] {
    display: none !important;
}

@keyframes inferaConsentSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.infera-consent-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.infera-consent-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.infera-consent-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #111827;
    margin: 0;
    font-family: var(--font-sans);
}

.infera-consent-body {
    font-size: 0.9375rem;
    line-height: 1.55;
    color: #4b5563;
    margin: 0;
}

.infera-consent-body a {
    color: var(--color-accent, #ff6600);
    text-decoration: underline;
    text-underline-offset: 3px;
    font-weight: 500;
}

.infera-consent-body a:hover {
    color: var(--color-accent-hover, #e55a00);
}

/* Grupo de botones de primera capa (Misma prominencia según directrices AEPD) */
.infera-consent-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.infera-consent-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: var(--radius-md, 8px);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1.5px solid transparent;
    min-height: 44px;
    font-family: inherit;
    line-height: 1;
}

.infera-consent-btn:focus-visible {
    outline: 2px solid var(--color-accent, #ff6600);
    outline-offset: 2px;
}

/* Botón Aceptar todas */
.infera-consent-btn--accept {
    background-color: var(--color-accent, #ff6600);
    color: #ffffff;
    border-color: var(--color-accent, #ff6600);
}

.infera-consent-btn--accept:hover {
    background-color: var(--color-accent-hover, #e55a00);
    border-color: var(--color-accent-hover, #e55a00);
    transform: translateY(-1px);
}

/* Botón Rechazar no esenciales (Misma prominencia visual que Aceptar según AEPD) */
.infera-consent-btn--reject {
    background-color: #111827;
    color: #ffffff;
    border-color: #111827;
}

.infera-consent-btn--reject:hover {
    background-color: #374151;
    border-color: #374151;
    transform: translateY(-1px);
}

/* Botón Configurar / Personalizar */
.infera-consent-btn--config {
    background-color: #f3f4f6;
    color: #111827;
    border-color: #d1d5db;
}

.infera-consent-btn--config:hover {
    background-color: #e5e7eb;
    border-color: #9ca3af;
}

/* Segunda capa: Modal de configuración granular */
.infera-consent-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: inferaConsentFadeIn 0.2s ease;
}

@keyframes inferaConsentFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.infera-consent-modal {
    background: #ffffff;
    color: #111827;
    width: 100%;
    max-width: 620px;
    max-height: 90vh;
    border-radius: var(--radius-lg, 14px);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: inferaConsentSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.infera-consent-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.infera-consent-modal-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0;
    color: #111827;
}

.infera-consent-modal-close {
    background: transparent;
    border: none;
    font-size: 1.35rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.infera-consent-modal-close:hover {
    color: #111827;
    background: #f3f4f6;
}

.infera-consent-modal-content {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    max-height: calc(90vh - 150px);
}

.infera-consent-modal-intro {
    font-size: 0.875rem;
    color: #4b5563;
    line-height: 1.5;
    margin: 0 0 1.25rem 0;
}

/* Tarjetas de categoría */
.infera-consent-category {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-md, 8px);
    padding: 1rem 1.15rem;
    margin-bottom: 0.85rem;
}

.infera-consent-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.4rem;
}

.infera-consent-category-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.infera-consent-category-desc {
    font-size: 0.8125rem;
    color: #6b7280;
    line-height: 1.5;
    margin: 0;
}

.infera-consent-badge {
    font-size: 0.75rem;
    font-weight: 600;
    background: #e0f2fe;
    color: #0369a1;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    white-space: nowrap;
}

/* Switch toggle accesible */
.infera-consent-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.infera-consent-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.infera-consent-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #d1d5db;
    transition: 0.25s ease;
    border-radius: 24px;
}

.infera-consent-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #ffffff;
    transition: 0.25s ease;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.infera-consent-switch input:checked + .infera-consent-slider {
    background-color: var(--color-accent, #ff6600);
}

.infera-consent-switch input:focus-visible + .infera-consent-slider {
    outline: 2px solid var(--color-accent, #ff6600);
    outline-offset: 2px;
}

.infera-consent-switch input:checked + .infera-consent-slider:before {
    transform: translateX(20px);
}

.infera-consent-switch input:disabled + .infera-consent-slider {
    background-color: #10b981;
    cursor: not-allowed;
    opacity: 0.85;
}

/* Footer del modal */
.infera-consent-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.65rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    background: #fafafa;
}

/* Botón flotante permanente para revocar/cambiar preferencias */
.infera-consent-floating {
    position: fixed;
    bottom: 1.25rem;
    left: 1.25rem;
    z-index: 99990;
    background: #ffffff;
    color: #111827;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    padding: 0.45rem 0.85rem;
    font-size: 0.8125rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-sans);
}

.infera-consent-floating:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    border-color: var(--color-accent, #ff6600);
    color: var(--color-accent, #ff6600);
}

.infera-consent-floating:focus-visible {
    outline: 2px solid var(--color-accent, #ff6600);
    outline-offset: 2px;
}

/* Enlace del pie de página para abrir configuración */
.site-footer__cookie-btn {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: var(--fs-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: color var(--transition-fast);
}

.site-footer__cookie-btn:hover {
    color: var(--color-accent);
}

/* Responsividad en pantallas móviles */
@media (max-width: 640px) {
    .infera-consent-banner {
        bottom: 0.5rem;
        left: 0.5rem;
        right: 0.5rem;
        padding: 1.15rem;
        gap: 1rem;
    }

    .infera-consent-actions {
        flex-direction: column;
        width: 100%;
    }

    .infera-consent-actions .infera-consent-btn {
        width: 100%;
    }

    .infera-consent-modal-footer {
        flex-direction: column;
    }

    .infera-consent-modal-footer .infera-consent-btn {
        width: 100%;
    }

    .infera-consent-floating span.infera-consent-floating-label {
        display: none;
    }
}
