/* =========================================================================
   EL ZAPEROCO (REVISTA DIGITAL) - VERSIÓN PRODUCCIÓN OPTIMIZADA
   ========================================================================= */

:root {
    /* PALETA ÁCIDA & Y2K */
    --acid-green: #ccff00;
    --hot-pink: #ff0055;
    --zape-purple: #9b59b6;
    --zape-yellow: #ffcf00;
    --black: #050505;
    --off-white: #f0f0f0;
    --pure-white: #ffffff;
    --gray-text: #444;

    /* FUENTES */
    --font-display: 'Syne', sans-serif;
    --font-mono: 'Space Mono', monospace;

    /* ESPACIADOS */
    --container-width: 1400px;
    --header-height: 60vh;
}

/* --- 0. RESET & BASES --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    overflow-x: hidden;
    /* Vital para evitar scroll lateral en móvil */
}

body {
    background-color: var(--off-white);
    color: var(--black);
    font-family: var(--font-mono);
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
    transition: 0.2s;
}

ul {
    list-style: none;
}

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

/* --- 1. HERO BANNER --- */
.zaperoco-hero {
    height: var(--header-height);
    min-height: 400px;
    background-image: url('https://images.unsplash.com/photo-1492684223066-81342ee5ff30?auto=format&fit=crop&w=1600&q=80');
    background-size: cover;
    background-position: center;
    position: relative;
    border-bottom: 5px solid var(--black);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.hero-overlay {
    width: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 15%, transparent 100%);
    padding: 60px 20px 40px;
    text-align: center;
}

.magazine-title {
    font-family: var(--font-display);
    font-size: clamp(3.5rem, 12vw, 9rem);
    /* Escalado fluido */
    color: var(--zape-yellow);
    text-transform: uppercase;
    line-height: 0.9;
    text-shadow: 4px 4px 0px var(--zape-purple);
    margin: 0;
    word-break: break-word;
}

.magazine-subtitle {
    font-family: var(--font-mono);
    color: var(--pure-white);
    font-size: clamp(0.8rem, 3vw, 1.2rem);
    letter-spacing: 3px;
    margin-top: 15px;
    background: var(--black);
    display: inline-block;
    padding: 6px 15px;
    text-transform: uppercase;
}

/* --- 2. NEWS TICKER (BANDA) --- */
.news-ticker-wrap {
    background: var(--hot-pink);
    color: var(--pure-white);
    border-bottom: 3px solid var(--black);
    overflow: hidden;
    white-space: nowrap;
    height: 45px;
    display: flex;
    align-items: center;
    position: relative;
    z-index: 10;
}

.news-ticker {
    display: inline-block;
    animation: ticker 30s linear infinite;
    font-weight: 700;
    font-size: 1rem;
    will-change: transform;
    /* Optimización GPU */
    padding-left: 100%;
    /* Truco para inicio suave */
}

@keyframes ticker {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-100%);
    }
}

/* --- 3. NAVBAR TEMAS (STICKY) --- */
.zaperoco-nav {
    background: var(--black);
    border-bottom: 1px solid #333;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.zaperoco-nav .container {
    display: flex;
    gap: 25px;
    overflow-x: auto;
    padding: 15px 20px;
    max-width: var(--container-width);
    margin: 0 auto;

    /* Scroll suave y oculto */
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    mask-image: linear-gradient(to right, transparent, black 20px, black 95%, transparent);
}

.zaperoco-nav .container::-webkit-scrollbar {
    display: none;
}

.zaperoco-nav a {
    color: #888;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
    text-transform: uppercase;
}

.zaperoco-nav a:hover,
.zaperoco-nav a.active {
    color: var(--acid-green);
    text-shadow: 0 0 10px rgba(204, 255, 0, 0.6);
}

/* =========================================
   4. LAYOUT PRINCIPAL
   ========================================= */
.zaperoco-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    /* Sidebar fijo | Contenido */
    gap: 40px;
    padding: 40px 20px;
    max-width: var(--container-width);
    margin: 0 auto;
    align-items: start;
}

/* --- SIDEBAR (FILTROS & ADS) --- */
.zaperoco-sidebar {
    position: sticky;
    top: 80px;
    /* Respeta el navbar sticky */
    z-index: 90;
}

.filter-box {
    background: var(--pure-white);
    border: 3px solid var(--black);
    padding: 20px;
    box-shadow: 8px 8px 0px var(--black);
    margin-bottom: 30px;
}

.filter-box h3 {
    font-size: 1.5rem;
    border-bottom: 2px solid var(--black);
    padding-bottom: 10px;
    margin-bottom: 20px;
    color: var(--black);
    font-weight: 800;
    text-transform: uppercase;
}

.filter-group {
    margin-bottom: 20px;
}

.filter-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 5px;
    font-size: 0.8rem;
    text-transform: uppercase;
}

/* Inputs Brutalistas */
.zape-input,
.zape-select-brutal {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--black);
    background: var(--pure-white);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    border-radius: 0;
    /* Cero curvas */
    outline: none;
}

.zape-input:focus,
.zape-select-brutal:focus {
    background: var(--acid-green);
}

/* Tags Cloud */
.tags-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.tag-pill {
    display: inline-block;
    background: var(--black);
    color: var(--pure-white);
    padding: 5px 10px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
}

.tag-pill:hover {
    background: var(--zape-purple);
}

/* Espacio Publicitario */
.ad-space {
    margin-top: 30px;
    height: 300px;
    background: repeating-linear-gradient(45deg, #ddd, #ddd 10px, #ccc 10px, #ccc 20px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--black);
    color: #555;
    font-weight: bold;
    text-align: center;
    padding: 20px;
}

/* =========================================
   5. FEED DE NOTICIAS (TARJETAS)
   ========================================= */
.news-card {
    background: var(--pure-white);
    border: 2px solid var(--black);
    margin-bottom: 40px;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
}

/* Hover solo en dispositivos que no son táctiles */
@media (hover: hover) {
    .news-card:hover {
        transform: translate(-4px, -4px);
        box-shadow: 8px 8px 0px var(--acid-green);
    }

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

    .news-card:hover h2,
    .news-card:hover h3 {
        color: var(--zape-purple);
        text-decoration: underline;
        text-decoration-thickness: 3px;
    }
}

.card-link-wrapper {
    text-decoration: none;
    color: inherit;
    display: block;
}

.card-img {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-bottom: 2px solid var(--black);
    background: var(--black);
    aspect-ratio: 16/9;
    /* Mantiene proporción consistente */
}

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

.cat-badge {
    position: absolute;
    top: 15px;
    left: 15px;
    background: var(--zape-yellow);
    color: var(--black);
    padding: 6px 12px;
    font-weight: 800;
    font-size: 0.75rem;
    border: 2px solid var(--black);
    text-transform: uppercase;
    z-index: 2;
}

.card-body {
    padding: 25px;
}

.news-card h2,
.news-card h3 {
    font-family: var(--font-display);
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 15px;
    text-transform: uppercase;
}

.news-card h2 {
    font-size: 1.8rem;
}

.news-card h3 {
    font-size: 1.4rem;
}

.news-card p {
    color: var(--gray-text);
    line-height: 1.6;
    margin-bottom: 20px;
    font-size: 1rem;
    /* Truncar texto a 3 líneas */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.meta {
    font-size: 0.75rem;
    color: #666;
    border-top: 1px dashed #ccc;
    padding-top: 15px;
    display: flex;
    justify-content: space-between;
    font-weight: 700;
}

/* Tarjeta Destacada (Featured) */
.news-card.featured .card-img {
    aspect-ratio: 21/9;
}

/* Más panorámica */
.news-card.featured h2 {
    font-size: clamp(2rem, 5vw, 3rem);
}

/* Grid Secundario */
.news-grid-secondary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
}

/* Botón Cargar Más */
.btn-brutal {
    background: var(--black);
    color: var(--acid-green);
    border: none;
    padding: 15px;
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 1.2rem;
    cursor: pointer;
    text-transform: uppercase;
    width: 100%;
    transition: 0.2s;
}

.btn-brutal:hover {
    background: var(--zape-purple);
    color: var(--pure-white);
}

/* =========================================
   6. VISTA DETALLE (ARTÍCULO)
   ========================================= */
.article-container {
    background: var(--pure-white);
    border: 3px solid var(--black);
    box-shadow: 10px 10px 0 var(--black);
    padding: 40px;
}

.article-header {
    margin-bottom: 30px;
}

.article-meta-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    font-size: 0.85rem;
    color: #666;
}

.article-title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 4rem);
    line-height: 1;
    font-weight: 800;
    margin-bottom: 20px;
    text-transform: uppercase;
}

.article-lead {
    font-size: 1.2rem;
    font-weight: 500;
    color: #333;
    border-left: 5px solid var(--hot-pink);
    padding-left: 20px;
    margin-bottom: 30px;
}

/* --- FICHA DE AUTOR (CORREGIDA) --- */
.author-box {
    display: flex;
    align-items: center;
    gap: 15px;
    background: #f4f4f4;
    border: 2px solid var(--black);
    padding: 15px;
    margin-bottom: 40px;
}

.author-img {
    width: 60px;
    height: 60px;
    min-width: 60px;
    /* Evita aplastamiento */
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--black);
    background: #ddd;
}

.author-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Evita óvalos */
}

.author-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.author-info .name {
    font-weight: 800;
    font-size: 1.1rem;
    text-transform: uppercase;
}

.author-info .date {
    font-size: 0.8rem;
    color: #666;
    margin-top: 4px;
}

/* --- CONTENIDO DEL ARTÍCULO --- */
.article-hero-media {
    margin: 0 -40px 40px -40px;
    /* Rompe el padding */
    border-top: 3px solid var(--black);
    border-bottom: 3px solid var(--black);
}

.article-hero-media img {
    width: 100%;
    height: auto;
}

.article-body {
    font-size: 1.1rem;
    line-height: 1.8;
    color: #222;
}

.article-body p {
    margin-bottom: 25px;
}

/* Video Embed (Responsive) */
.video-break-section {
    background: var(--black);
    padding: 20px;
    margin: 40px 0;
    color: var(--acid-green);
}

.video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 */
    height: 0;
    border: 2px solid var(--acid-green);
}

.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* =========================================
   CORRECCIÓN PANTALLAS EXTRA ESTRECHAS (< 380px)
   ========================================= */
@media (max-width: 380px) {

    /* 1. Ganar espacio lateral (Reducir padding) */
    .zaperoco-layout,
    .zaperoco-layout.detail-view,
    .hero-overlay {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    /* 2. Títulos: Ajuste agresivo para que no corten */
    .magazine-title {
        font-size: 18vw;
        /* Escala exacta al ancho del teléfono */
        line-height: 0.85;
    }

    .article-title {
        font-size: 1.8rem;
        /* Más pequeño en detalle */
        word-wrap: break-word;
        /* Romper palabras largas */
    }

    /* 3. Tarjetas: Compactar contenido */
    .card-body,
    .article-container {
        padding: 15px !important;
        /* Menos aire interno */
    }

    .news-card h2 {
        font-size: 1.3rem;
    }

    /* 4. Ficha de Autor: Apilar verticalmente siempre */
    .author-box {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .author-socials {
        margin-top: 5px;
    }
}

/* =========================================
   7. RESPONSIVIDAD (MOBILE FIRST OPTIMIZATION)
   ========================================= */

/* --- TABLETS Y MÓVILES (Menos de 992px) --- */
@media (max-width: 992px) {

    /* 1. Ajuste del Layout Principal */
    .zaperoco-layout {
        grid-template-columns: 1fr;
        /* Una sola columna */
        padding: 20px 15px;
        /* Menos padding lateral */
        gap: 40px;
    }

    /* 2. Reordenamiento del Sidebar */
    .zaperoco-sidebar {
        position: static;
        /* Ya no es sticky */
        order: 2;
        /* Se mueve al final de la página */
        margin-top: 20px;
    }

    /* 3. Ajustes del Feed de Noticias */
    .news-grid-secondary {
        grid-template-columns: 1fr;
        /* Tarjetas una debajo de otra */
        gap: 30px;
    }

    .news-card.featured .card-img {
        height: 250px;
        /* Altura reducida para móvil */
        aspect-ratio: auto;
        /* Dejar que fluya */
    }

    .news-card.featured h2 {
        font-size: 2rem;
        /* Título más controlado */
    }

    /* 4. Ajustes de la Vista Detalle (Artículo) */
    .zaperoco-layout.detail-view {
        grid-template-columns: 1fr;
        padding-top: 20px;
    }

    .article-container {
        padding: 25px 20px;
        /* Padding interno reducido */
    }

    /* Romper márgenes para que la imagen toque los bordes en móvil */
    .article-hero-media {
        margin-left: -20px;
        margin-right: -20px;
        width: calc(100% + 40px);
    }

    .article-title {
        font-size: 2.5rem;
        line-height: 0.95;
    }

    .drop-cap::first-letter {
        font-size: 3.5rem;
        /* Letra capital ajustada */
    }
}

/* --- MÓVILES PEQUEÑOS (Menos de 576px) --- */
@media (max-width: 576px) {

    /* Hero más compacto */
    .zaperoco-hero {
        height: 50vh;
        min-height: 300px;
    }

    .magazine-title {
        font-size: 15vw;
        /* Gigante pero proporcional al ancho */
    }

    .magazine-subtitle {
        font-size: 0.8rem;
        letter-spacing: 1px;
        padding: 4px 10px;
    }

    /* Ajuste de Tarjetas */
    .card-img {
        height: 200px;
    }

    .news-card h2 {
        font-size: 1.5rem;
    }

    .news-card h3 {
        font-size: 1.3rem;
    }

    /* Ajuste Ficha Autor */
    .author-box {
        flex-direction: column;
        /* Apilar verticalmente */
        text-align: center;
        gap: 10px;
    }

    .author-info {
        align-items: center;
    }

    .author-socials {
        margin-top: 5px;
    }
}

/* =========================================
   FIX: DESBORDAMIENTO DE TARJETAS EN MÓVIL
   ========================================= */
@media (max-width: 768px) {

    /* 1. Asegurar que la tarjeta no sea más ancha que la pantalla */
    .news-card,
    article {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        /* Clave para que el borde no sume al ancho */
        overflow: hidden;
        /* Corta cualquier hijo rebelde */
    }

    /* 2. Controlar el Título Gigante */
    .news-card.featured h2,
    .news-card h2 {
        font-size: 1.8rem !important;
        /* Reducimos drásticamente el tamaño */
        line-height: 1.1;
        word-wrap: break-word;
        /* Rompe palabras largas si es necesario */
        overflow-wrap: break-word;
        hyphens: auto;
        /* Agrega guiones si la palabra no cabe */
    }

    /* 3. Ganar espacio interno */
    .card-body {
        padding: 15px !important;
        /* Menos relleno interno */
    }
}

/* =========================================
   FIX: VISTA DE DETALLE (ARTÍCULO)
   ========================================= */

/* 1. ARREGLAR LAS COLUMNAS
   Sobrescribimos la grilla para que el contenido sea ancho (izquierda) 
   y el sidebar angosto (derecha). */
.zaperoco-layout.detail-view {
    display: grid;
    /* Contenido Flexible | Sidebar Fijo */
    grid-template-columns: 1fr 350px !important;
    gap: 40px;
    align-items: start;
}

/* 2. DOMAR EL TÍTULO GIGANTE
   Aseguramos que no se desborde y tenga un tamaño sensato. */
.article-title {
    /* Clamp: Mínimo 2rem, Ideal 5% del ancho, Máximo 4rem */
    font-size: clamp(2rem, 5vw, 4rem) !important;
    line-height: 1.1 !important;
    word-break: break-word;
    /* Rompe palabras largas si es necesario */
    hyphens: auto;
    /* Agrega guiones gramaticales */
    width: 100%;
}

/* 3. AJUSTE RESPONSIVE PARA EL DETALLE
   En móvil, todo a una columna. */
@media (max-width: 992px) {
    .zaperoco-layout.detail-view {
        grid-template-columns: 1fr !important;
    }

    /* El sidebar pasa abajo */
    .zaperoco-sidebar {
        order: 2;
    }

    .article-container {
        order: 1;
    }
}

/* --- ESTILOS DE TEXTO RICO (WYSIWYG) --- */
.rich-text p {
    margin-bottom: 20px;
    line-height: 1.8;
}

.rich-text strong {
    color: #000;
    /* Negrita bien negra */
    font-weight: 900;
}

.rich-text em {
    background-color: #ccff00;
    /* Itálica resaltada como marcador */
    font-style: italic;
    padding: 0 4px;
}

.rich-text ul,
.rich-text ol {
    margin-bottom: 20px;
    padding-left: 20px;
}

.rich-text li {
    margin-bottom: 10px;
}

.rich-text h2,
.rich-text h3 {
    font-family: 'Syne', sans-serif;
    margin-top: 30px;
    margin-bottom: 15px;
    text-transform: uppercase;
    font-weight: 800;
}