/* =========================================
   1. VARIABLES Y RESET GENERAL
   ========================================= */
:root {
    --primary: #1a237e;
    --accent: #d32f2f;
    --dark: #222;
    --light-bg: #f8f9fa;
    --border: #e0e0e0;
    --font-heading: 'Playfair Display', serif;
    --font-body: 'Georgia', serif;
    --font-sans: 'Roboto', sans-serif;
}

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

html, body {
    width: 100%;
    overflow-x: hidden; /* Evita scroll lateral */
    -webkit-font-smoothing: antialiased;
    background-color: var(--light-bg);
    font-family: var(--font-body);
    color: #333;
    line-height: 1.6;
}

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

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

/* =========================================
   2. ESTRUCTURA (LAYOUT)
   ========================================= */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px; /* Margen de seguridad lateral */
}

/* =========================================
   3. HEADER Y NAVEGACIÓN
   ========================================= */
header {
    background: var(--primary);
    color: #fff;
    padding: 40px 0;
    text-align: center;
    border-bottom: 4px solid var(--accent);
}

.site-title {
    font-family: var(--font-heading);
    font-size: 3.5rem;
    font-weight: 900;
    margin: 0;
    text-transform: uppercase;
}

.tagline {
    font-style: italic;
    opacity: 0.9;
    margin-top: 5px;
    font-family: var(--font-sans);
}

.main-nav {
    background: #fff;
    border-bottom: 1px solid #ddd;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.main-nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    margin: 0;
    padding: 0;
}

.main-nav li a {
    display: block;
    padding: 15px 20px;
    color: var(--dark);
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.main-nav li a:hover {
    color: var(--accent);
    background: #f4f4f4;
}

/* =========================================
   4. PORTADA (GRID DE TARJETAS)
   ========================================= */
.section-category {
    margin: 50px 0;
    position: relative;
}

.cat-title {
    font-family: var(--font-sans);
    font-size: 1.2rem;
    font-weight: 900;
    background: var(--dark);
    color: #fff;
    padding: 8px 20px;
    display: inline-block;
    margin-bottom: 25px;
    text-transform: uppercase;
    position: relative;
}

.cat-title::after {
    content: '';
    position: absolute;
    bottom: 50%;
    left: 100%;
    width: 2000px;
    height: 2px;
    background: #ccc;
    z-index: -1;
}

.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 30px;
}

.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.1);
    border-color: #ccc;
}

.card img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    border-bottom: 1px solid #f4f4f4;
}

.card-content {
    padding: 25px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.card .meta {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #999;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.card h3 {
    margin: 0 0 15px 0;
    font-family: var(--font-heading);
    font-size: 1.4rem;
    line-height: 1.3;
    color: #222;
}

.card h3 a:hover { color: var(--primary); }

.card p {
    font-size: 0.95rem;
    color: #555;
    line-height: 1.6;
}

.btn-view-all {
    display: inline-block;
    padding: 12px 30px;
    background: var(--primary);
    color: white !important;
    text-transform: uppercase;
    font-weight: bold;
    font-size: 0.9rem;
    border-radius: 4px;
    margin-top: 10px;
}

.btn-view-all:hover {
    background: var(--accent);
    transform: scale(1.05);
}

/* =========================================
   5. ARTÍCULO INDIVIDUAL
   ========================================= */
.article-layout {
    display: grid;
    grid-template-columns: 2.5fr 1fr;
    gap: 40px;
    margin-top: 30px;
    align-items: start;
}

.main-article {
    background: #fff;
    padding: 40px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.cat-badge {
    background-color: var(--accent);
    color: white;
    padding: 4px 8px;
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: bold;
    border-radius: 3px;
    display: inline-block;
    margin-bottom: 15px;
    font-family: var(--font-sans);
}

.main-article h1 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    line-height: 1.2;
    margin-bottom: 20px;
}

.main-article img {
    width: 100%;
    border-radius: 4px;
    margin-bottom: 30px;
}

/* Typography dentro del artículo */
.body-text {
    font-size: 1.15rem;
    line-height: 1.8;
    color: #333;
}

.body-text a {
    color: var(--primary);
    text-decoration: underline;
    font-weight: 600;
}

.body-text a:hover {
    color: var(--accent);
    background-color: rgba(26, 35, 126, 0.05);
}

.body-text h2 { margin-top: 40px; font-size: 1.8rem; border-bottom: 2px solid var(--border); padding-bottom: 10px; font-family: var(--font-heading); }
.body-text h3 { margin-top: 30px; font-size: 1.5rem; font-family: var(--font-heading); }
.body-text p { margin-bottom: 20px; }
.body-text blockquote {
    border-left: 4px solid var(--accent);
    margin: 20px 0;
    padding: 10px 20px;
    background: #f9f9f9;
    font-style: italic;
}

/* =========================================
   6. FAQS (ACORDEÓN)
   ========================================= */
.faq-section {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-left: 5px solid var(--primary);
    padding: 25px;
    margin-top: 50px;
    border-radius: 4px;
}

.faq-item {
    margin-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.faq-item details { padding: 15px 0; cursor: pointer; }

.faq-item summary {
    font-weight: bold;
    font-size: 1.1rem;
    list-style: none;
    position: relative;
    padding-right: 30px;
}

.faq-item summary::after {
    content: '+';
    position: absolute;
    right: 0;
    font-size: 1.5rem;
    color: var(--accent);
}

.faq-item details[open] summary::after { content: '-'; }

/* =========================================
   7. SIDEBAR (CONTENIDO RELACIONADO)
   ========================================= */
.sidebar {
    background: #fff;
    padding: 20px;
    border: 1px solid var(--border);
    position: sticky;
    top: 90px; /* Debajo del nav sticky */
}

.sidebar h3 {
    font-family: var(--font-sans);
    font-size: 1.1rem;
    text-transform: uppercase;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.related-item {
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}

.related-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    margin-bottom: 10px;
}

.related-item h4 {
    font-size: 1rem;
    line-height: 1.4;
    font-family: var(--font-body);
}

/* =========================================
   8. RESPONSIVE DESIGN (FIX TOTAL MÓVIL)
   ========================================= */

/* =========================================
   8. RESPONSIVE DESIGN (FIX TOTAL MÓVIL)
   ========================================= */

/* Tablets (Ancho intermedio) */
@media (max-width: 900px) {
    .article-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .sidebar {
        position: static;
        margin-top: 30px;
    }
}

/* MÓVILES (Ancho < 768px) */
/* =========================================
   8. RESPONSIVE DESIGN (SOLUCIÓN DEFINITIVA)
   ========================================= */

@media (max-width: 768px) {
    
    /* 1. Forzamos el contenedor al 92% y centrado */
    .container {
        width: 92% !important;
        max-width: 92% !important;
        margin: 0 auto !important;
        padding: 0 !important;
        display: block !important; /* Evitamos comportamientos de flex/grid del padre */
    }

    /* 2. Reseteamos el Layout del artículo (IMPORTANTE) */
    .article-layout {
        display: block !important; /* Desactivamos el Grid en móviles */
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* 3. Limpiamos la caja del artículo */
    .main-article {
        display: block !important;
        width: 100% !important;
        padding: 10px 0 !important; /* Solo espacio arriba y abajo */
        margin: 0 !important;
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
    }

    /* 4. Título: controlamos que no empuje el diseño */
    .main-article h1 {
        font-size: 1.7rem !important;
        line-height: 1.3 !important;
        margin: 15px 0 !important;
        width: 100% !important;
        text-align: left !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    /* 5. Imagen destacada: perfecta y centrada */
    .main-article img {
        width: 100% !important;
        height: auto !important;
        display: block !important;
        margin: 0 0 20px 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
        border-radius: 4px;
    }

    /* 6. Cuerpo del texto */
    .body-text {
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        font-size: 1.1rem !important;
        line-height: 1.7 !important;
    }

    /* 7. Sidebar: se va al final */
    .sidebar {
        width: 100% !important;
        margin: 40px 0 0 0 !important;
        padding: 20px 0 !important;
        border-left: none !important;
        border-top: 1px solid #ddd !important;
        position: static !important;
    }

    /* 8. Menú de navegación móvil */
    .main-nav ul {
        justify-content: flex-start !important;
        overflow-x: auto !important;
        padding: 10px 0 !important;
    }
}

/* RESET GLOBAL OBLIGATORIO */
* {
    box-sizing: border-box !important;
}

html, body {
    width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* Esto evita que puedas mover la web hacia los lados */
}