/* ==========================================================================
   1. VARIABLES Y CONFIGURACIÓN DE TEMA (Medidas estrictas en REM)
   ========================================================================== */
:root {
    --bg: #101412;
    --surface: rgba(255, 255, 255, 0.05);
    --surface-strong: rgba(255, 255, 255, 0.12);
    --text: #f5f7f2;
    --muted: #b9c2b7;
    --accent: #f59e0b;
    --accent-green: #4ade80;
    --danger: #ef4444;
    --navbar-bg: rgba(16, 20, 18, 0.75);
    
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-serif: 'Lora', Georgia, serif;
    --transition-smooth: all 0.42s cubic-bezier(.22, .61, .36, 1);
}

body.light-mode {
    --bg: #f8faf7;
    --surface: rgba(16, 20, 18, 0.04);
    --surface-strong: rgba(16, 20, 18, 0.09);
    --text: #171d1a;
    --muted: #5c645e;
    --accent: #d97706;
    --accent-green: #16a34a;
    --navbar-bg: rgba(248, 250, 247, 0.85);
}

/* Base Overrides */
html {
    font-size: 100%; /* 1rem = 16px */
}
body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Contenedores de Flujo Libre (Estilo MSN Comercial) */
.max-container {
    max-width: 100%; 
    padding-left: 2rem;
    padding-right: 2rem;
    width: 100%;
}

@media (min-width: 1400px) {
    .max-container {
        padding-left: 4rem;
        padding-right: 4rem;
    }
}

.max-w-readable {
    max-width: 53.125rem; /* 850px para óptima lectura */
}

/* Headers de Sección */
.section-header {
    margin-top: 7rem;
    margin-bottom: 2.5rem;
    text-align: left !important;
    border-bottom: 0.0625rem solid var(--surface-strong);
    padding-bottom: 1rem;
}
.text-gradient {
    background: linear-gradient(135deg, var(--text) 30%, var(--muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ==========================================================================
   2. NAVBAR INTEGRADO CON BOOTSTRAP 5 (Glassmorphism)
   ========================================================================== */
.custom-navbar {
    background-color: var(--navbar-bg) !important;
    backdrop-filter: blur(0.75rem);
    -webkit-backdrop-filter: blur(0.75rem);
    border-bottom: 0.0625rem solid var(--surface);
    padding: 0.8rem 0;
    transition: var(--transition-smooth);
}

body.light-mode .custom-navbar {
    border-bottom: 0.0625rem solid rgba(16, 20, 18, 0.08);
}

.custom-navbar .navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: 0.05rem;
    color: var(--text) !important;
}

.custom-navbar .logo-dot {
    width: 0.55rem;
    height: 0.55rem;
    background-color: var(--accent-green);
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.5rem;
}

.custom-navbar .nav-link {
    color: var(--muted) !important;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.5rem 1.25rem !important;
    border-radius: 0.5rem;
    transition: var(--transition-smooth);
}

.custom-navbar .nav-link:hover, 
.custom-navbar .nav-link.active {
    color: var(--text) !important;
    background-color: var(--surface);
}

@media (max-width: 991.98px) {
    .custom-navbar .navbar-collapse {
        background: var(--bg);
        border-radius: 0.75rem;
        padding: 1rem;
        margin-top: 0.75rem;
        border: 0.0625rem solid var(--surface);
        box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.2);
    }
    .custom-navbar .nav-link {
        padding: 0.75rem 1rem !important;
        margin-bottom: 0.25rem;
    }
}

.theme-btn {
    color: var(--text) !important;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Botón de navegación estilo iPhone Chevron */
.back-navigation-btn {
    position: fixed;
    top: 1rem;
    left: 1.25rem;
    width: 3.125rem;
    height: 3.125rem;
    border-radius: 50%;
    background-color: var(--surface-strong);
    color: var(--text);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    cursor: pointer;
    backdrop-filter: blur(0.3125rem);
    -webkit-backdrop-filter: blur(0.3125rem);
    transition: var(--transition-smooth);
    box-shadow: 0 0.25rem 0.75rem rgba(0,0,0,0.1);
}
.back-navigation-btn:hover {
    transform: scale(1.05);
    background-color: var(--text);
    color: var(--bg);
}

/* ==========================================================================
   3. GRID DINÁMICO DE NOTICIAS (Distribución Avanzada)
   ========================================================================== */
.msn-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    padding: 0 0 5rem 0;
    grid-auto-flow: dense; /* Fuerza el rellenado inteligente de espacios */
}

.news-card {
    border-radius: 0.5rem;
    overflow: hidden;
    position: relative;
    background: var(--surface);
    border: 0.0625rem solid var(--surface);
    transition: var(--transition-smooth);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 100%;
}
.news-card:hover {
    transform: translateY(-0.1875rem);
    box-shadow: 0 0.75rem 1.5rem rgba(0,0,0,0.12);
    border-color: var(--surface-strong);
}

/* DISEÑO A: Rectángulo Grande (Ocupa 2 columnas) */
.card-design-a {
    grid-column: span 1; 
    min-height: 22rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}
.card-design-a .card-bg-img {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    object-fit: cover;
    z-index: 1;
}
.card-design-a .card-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.2) 70%, transparent 100%);
    z-index: 2;
}
.card-design-a .card-body-content {
    position: relative;
    z-index: 3;
    padding: 1.5rem;
    color: #f5f7f2 !important;
}
.card-design-a .card-title {
    font-family: var(--font-serif);
    font-size: 1.45rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 0;
}

/* DISEÑO B: Cuadrado / Compacto Chico (Ocupa 1 columna) */
.card-design-b {
    grid-column: span 1;
}
.card-design-b .card-thumb-wrap {
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}
.card-design-b .card-thumb-wrap img {
    width: 100%; height: 100%; object-fit: cover;
    transition: var(--transition-smooth);
}
.card-design-b:hover .card-thumb-wrap img {
    transform: scale(1.03);
}
.card-design-b .card-body-content {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}
.card-design-b .card-title {
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 0.5rem;
}
.card-summary {
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.4;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.news-meta-inline {
    font-size: 0.85rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ==========================================================================
   4. MEDIAS QUERIES ADAPTABLES PARA EL GRID
   ========================================================================== */
@media (min-width: 768px) {
    .msn-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    .card-design-a {
        grid-column: span 2;
    }
}

@media (min-width: 1200px) {
    .msn-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1.5rem;
    }
    .card-design-a {
        grid-column: span 2; /* Ocupa el espacio de 2 chicas */
        min-height: 26rem;
    }
    .card-design-b {
        grid-column: span 1; /* Caben 4 en una sola línea limpia */
    }
}

/* ==========================================================================
   5. VISTA LECTOR DE CONTENIDOS
   ========================================================================== */
.reader-wrap {
    padding: 6.5rem 1rem 4rem 1rem;
}
.reader-hero-img {
    width: 100%;
    max-height: 28rem;
    object-fit: cover;
    border-radius: 1rem;
    margin-bottom: 2rem;
}
.reader-category {
    color: var(--accent);
    text-transform: uppercase;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.05rem;
}
.reader-title {
    font-family: var(--font-serif);
    font-size: 2.3rem;
    font-weight: 600;
    margin-top: 0.5rem;
}
.reader-sub {
    font-size: 1.25rem;
    color: var(--muted);
    line-height: 1.5;
    margin-bottom: 1.5rem;
}
.reader-body {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    line-height: 1.85;
}
.reader-body p {
    margin-bottom: 1.5rem;
}

/* ==========================================================================
   6. CATALOGO DE LIBROS Y FORMULARIOS
   ========================================================================== */
.book-card {
    background: var(--surface);
    border: 0.0625rem solid var(--surface);
    border-radius: 1rem;
    overflow: hidden;
    transition: var(--transition-smooth);
}
.book-img-box {
    width: 100%;
    aspect-ratio: 3 / 4;
    overflow: hidden;
}
.book-img-box img {
    width: 100%; height: 100%; object-fit: cover;
}
@media (min-width: 576px) {
    .book-img-box { width: 12.5rem; }
}
.badge-stock {
    font-size: 0.75rem;
    padding: 0.35rem 0.65rem;
    border-radius: 0.25rem;
}
.custom-pagination .page-link {
    background: var(--surface);
    color: var(--text);
    border: 0.0625rem solid var(--surface);
    padding: 0.5rem 1rem;
    margin: 0 0.25rem;
    border-radius: 0.375rem;
    transition: var(--transition-smooth);
}
.custom-pagination .page-item.active .page-link {
    background: var(--accent-green);
    border-color: var(--accent-green);
    color: #101412;
}
.static-card {
    background: var(--surface);
    border: 0.0625rem solid var(--surface);
}
.custom-input {
    background: var(--bg);
    border: 0.0625rem solid var(--surface-strong);
    color: var(--text);
}
.custom-input:focus {
    background: var(--bg);
    color: var(--text);
    border-color: var(--accent-green);
    box-shadow: none;
}
.btn-accent {
    background: var(--accent-green);
    color: #101412;
    font-weight: 600;
}

/* ==========================================================================
   7. PARALLAX FOOTER SYSTEM
   ========================================================================== */
.parallax-footer {
    position: relative;
    min-height: 22rem;
    margin-top: auto;
    overflow: hidden;
    display: flex;
    align-items: center;
}
.parallax-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 120%;
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    z-index: 1;
}
.footer-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to bottom, var(--bg) 0%, rgba(16,20,18,0.88) 50%, var(--bg) 100%);
    z-index: 2;
}
.footer-content {
    position: relative;
    z-index: 3;
    padding: 3rem 1rem;
}
.mision-text {
    max-width: 35rem;
    font-size: 0.95rem;
    line-height: 1.6;
}
.footer-links a {
    color: var(--muted);
    text-decoration: none;
    transition: var(--transition-smooth);
    display: inline-block;
    padding: 0.25rem 0;
}
.footer-links a:hover { color: var(--text); }
.legal-text { font-size: 0.8rem; color: var(--muted); }

/* ==========================================================================
   8. MOTOR DE ANIMACIÓN SLIDER (SPA)
   ========================================================================== */
.slider-container {
    width: 100%;
    position: relative;
    overflow-x: hidden;
    overflow-y: visible;
    min-height: calc(100vh - 4.5rem);
}
.slide-item {
    position: absolute;
    top: 0; left: 0; width: 100%;
    transition: opacity 0.5s ease;
    visibility: hidden;
    opacity: 0;
    z-index: 1;
}
.slide-item.active {
    position: relative;
    visibility: visible;
    opacity: 1;
    z-index: 2;
    height: auto;
}

@keyframes slideInRight {
    from { transform: translateX(100%); visibility: visible; opacity: 1; }
    to { transform: translateX(0); visibility: visible; opacity: 1; }
}
@keyframes slideOutLeft {
    from { transform: translateX(0); visibility: visible; opacity: 1; }
    to { transform: translateX(-100%); visibility: visible; opacity: 1; }
}
@keyframes slideInLeft {
    from { transform: translateX(-100%); visibility: visible; opacity: 1; }
    to { transform: translateX(0); visibility: visible; opacity: 1; }
}
@keyframes slideOutRight {
    from { transform: translateX(0); visibility: visible; opacity: 1; }
    to { transform: translateX(100%); visibility: visible; opacity: 1; }
}

.slide-in-right { animation: slideInRight 0.5s cubic-bezier(.22, .61, .36, 1) forwards; z-index: 3; }
.slide-out-left { animation: slideOutLeft 0.5s cubic-bezier(.22, .61, .36, 1) forwards; z-index: 2; }
.slide-in-left { animation: slideInLeft 0.5s cubic-bezier(.22, .61, .36, 1) forwards; z-index: 3; }
.slide-out-right { animation: slideOutRight 0.5s cubic-bezier(.22, .61, .36, 1) forwards; z-index: 2; }

.header-fade-out { opacity: 0; transition: opacity 0.3s ease; }
