/* ==========================================================================
   HOJA DE ESTILOS MAESTRA: TEORÍA Y EJERCICIOS (matemas.com)
   Diseño Premium Dark Mode unificado, alta legibilidad y jerarquía visual
   ========================================================================== */

:root {
    --bg: #0f1117;
    --bg-surface: #16181f;
    --bg-card: #1e2130;
    --bg-card-inner: #181b28;
    --accent: #4f7dff;
    --accent-hover: #3a68e8;
    --accent-glow: rgba(79, 125, 255, 0.15);
    --title-color: #60a5fa;
    --title-gradient: linear-gradient(135deg, #60a5fa, #818cf8);
    --text: #ffffff;
    --text-muted: #94a3b8;
    --text-secondary: #94a3b8;
    --border: rgba(255, 255, 255, 0.08);
    --border-accent: rgba(79, 125, 255, 0.3);
    
    /* Estados y notas pedagógicas */
    --obs-bg: rgba(245, 158, 11, 0.08);
    --obs-border: #f59e0b;
    --obs-text: #fde68a;
    --note-bg: rgba(16, 185, 129, 0.08);
    --note-border: #10b981;
    --note-text: #a7f3d0;
    --hl: #38bdf8;
    --hl-purple: #c084fc;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --max-w: 1050px;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    background: var(--bg);
}

body, body.dark-mode {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg) !important;
    color: var(--text) !important;
    line-height: 1.75;
    font-size: 1.02rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   NAVEGACIÓN SUPERIOR
   ========================================================================== */
.nav-bar, nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(15, 17, 23, 0.95) !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    padding: 0 5%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.nav-container {
    width: 100%;
    max-width: var(--max-w);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand, .logo {
    font-size: 1.45rem;
    font-weight: 900;
    color: var(--text) !important;
    text-decoration: none;
    letter-spacing: -0.5px;
}

.nav-brand span, .logo span {
    color: var(--accent);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    list-style: none;
}

.nav-links a {
    color: var(--text-muted) !important;
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--text) !important;
}

.btn-primary-small, .nav-cta {
    background: var(--accent) !important;
    color: #ffffff !important;
    text-decoration: none;
    padding: 0.45rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(79, 125, 255, 0.25);
    transition: all 0.2s ease;
}

.btn-primary-small:hover, .nav-cta:hover {
    background: var(--accent-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(79, 125, 255, 0.4);
}

/* ==========================================================================
   BREADCRUMB / RUTA DE NAVEGACIÓN
   ========================================================================== */
.breadcrumb {
    max-width: var(--max-w);
    margin: 1.5rem auto 0;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--text-muted) !important;
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb a:hover {
    color: var(--title-color) !important;
}

.breadcrumb span {
    color: var(--text);
    opacity: 0.85;
}

/* ==========================================================================
   MAIN WRAPPER
   ========================================================================== */
.content-container, .content-wrap, main {
    width: 100%;
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 1.5rem 1.5rem 4rem;
    flex: 1;
}

/* ==========================================================================
   HERO / CABECERA DE LECCIÓN O EJERCICIOS
   ========================================================================== */
.theory-hero, .hero {
    margin: 1.5rem auto 2.5rem;
    text-align: left;
}

.badge-block, .badge-topic, .hero-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(79, 125, 255, 0.12) !important;
    border: 1px solid var(--border-accent) !important;
    border-radius: 999px;
    padding: 0.35rem 1rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--title-color) !important;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.theory-title, .hero h1 {
    font-size: clamp(2rem, 4vw, 2.75rem);
    font-weight: 900;
    letter-spacing: -0.5px;
    line-height: 1.2;
    margin-bottom: 1.2rem;
    color: var(--title-color) !important;
}

.hero-actions, .cta-canvas-box {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1.8rem 0 2.2rem;
}

.btn-hero-primary, .btn-play-canvas {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    background: var(--accent) !important;
    color: #ffffff !important;
    font-size: 0.95rem;
    font-weight: 700;
    text-decoration: none;
    padding: 0.75rem 1.4rem;
    border-radius: 10px;
    box-shadow: 0 4px 18px rgba(79, 125, 255, 0.35);
    transition: all 0.2s ease;
}

.btn-hero-primary:hover, .btn-play-canvas:hover {
    background: var(--accent-hover) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(79, 125, 255, 0.45);
}

.btn-hero-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05) !important;
    color: #ffffff !important;
    border: 1px solid var(--border) !important;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    padding: 0.75rem 1.4rem;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.btn-hero-secondary:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    transform: translateY(-1px);
}

/* ==========================================================================
   TARJETAS MODULARES Y CONTENIDO TEÓRICO
   ========================================================================== */
.theory-content, article {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.modular-card, .theory-card, .content-section {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-lg);
    padding: 2.2rem 2.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.card-title, h2 {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--title-color) !important;
    margin-bottom: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border-left: 4px solid var(--title-color);
    padding-left: 0.8rem;
    line-height: 1.3;
}

h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #93c5fd !important;
    margin: 1.8rem 0 0.8rem;
}

.card-text, p {
    margin-bottom: 1.1rem;
    color: #ffffff !important;
    font-size: 1.02rem;
}

ul, ol {
    margin: 0 0 1.3rem 1.5rem;
    color: #ffffff !important;
}

li {
    margin-bottom: 0.45rem;
    color: #ffffff !important;
}

/* PASOS Y BLOQUES ESTRUCTURADOS */
.steps-box {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    margin: 1.4rem 0;
}

.step-item {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
    background: rgba(255, 255, 255, 0.02) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: var(--radius-sm);
    padding: 1rem 1.2rem;
}

.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent) !important;
    color: #ffffff !important;
    font-weight: 800;
    font-size: 0.8rem;
    min-width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-top: 2px;
    flex-shrink: 0;
}

.step-desc {
    flex: 1;
    color: #f1f3f9 !important;
}

.step-desc strong {
    color: var(--hl) !important;
}

/* CAJAS DE EJEMPLO */
.example-box, .example-card {
    background: var(--bg-card-inner) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-left: 4px solid var(--hl-purple) !important;
    border-radius: var(--radius-md);
    padding: 1.6rem 1.8rem;
    margin: 1.4rem 0;
}

.example-title, .ex-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: #ffffff !important;
    margin-bottom: 0.8rem;
}

/* CAJA DE PASO Y EJEMPLO CONCRETO INTERCALADO (CANÓNICO 1.1.1) */
.step-box {
    background: rgba(255, 255, 255, 0.02) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: var(--radius-sm);
    padding: 1.2rem 1.4rem;
    margin: 1.2rem 0;
}

.step-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--hl) !important;
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.math-display {
    text-align: center;
    margin: 1.3rem 0;
    padding: 0.8rem 0;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    overflow-x: auto;
}


/* CAJAS DE OBSERVACIONES Y NOTAS */
.box-obs {
    background: var(--obs-bg) !important;
    border-left: 4px solid var(--obs-border) !important;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 1.2rem 1.5rem;
    margin: 1.5rem 0;
    color: #ffffff !important;
}

.box-obs-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--obs-border) !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.4rem;
}

.box-note {
    background: var(--note-bg) !important;
    border-left: 4px solid var(--note-border) !important;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 1.2rem 1.5rem;
    margin: 1.5rem 0;
    color: #ffffff !important;
}

.box-note-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--note-border) !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.4rem;
}

/* ==========================================================================
   TARJETAS DE EJERCICIOS RESUELTOS
   ========================================================================== */
.exercise-card {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-lg);
    padding: 2.2rem 2.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.exercise-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
}

.exercise-tag {
    background: rgba(96, 165, 250, 0.15) !important;
    color: var(--title-color) !important;
    border: 1px solid rgba(96, 165, 250, 0.3) !important;
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.exercise-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: #ffffff !important;
    margin: 0;
}

.exercise-body {
    color: #f1f3f9 !important;
}

.solution-box {
    background: rgba(16, 185, 129, 0.05) !important;
    border: 1px solid rgba(16, 185, 129, 0.2) !important;
    border-left: 4px solid var(--note-border) !important;
    border-radius: var(--radius-sm);
    padding: 1.4rem 1.6rem;
    margin-top: 1.4rem;
}

.solution-title {
    font-size: 0.98rem;
    font-weight: 800;
    color: var(--note-border) !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.6rem;
}

/* ==========================================================================
   MATEMÁTICAS / FÓRMULAS LATEX Y MATHJAX
   ========================================================================== */
.math-display,
.math-display mjx-container[jax="SVG"][display="true"],
div.math-display mjx-container[jax="SVG"][display="true"] {
    text-align: center;
    margin: 1.4rem auto !important;
    padding: 0.8rem 0;
    overflow-x: auto;
    overflow-y: hidden;
    display: block !important;
}

/* Fórmulas inline y fórmulas dentro de texto corrido, listas y modales */
p mjx-container[jax="SVG"][display="true"],
li mjx-container[jax="SVG"][display="true"],
td mjx-container[jax="SVG"][display="true"],
th mjx-container[jax="SVG"][display="true"],
.modal-pista-content mjx-container[jax="SVG"][display="true"],
.modal-pista-box mjx-container[jax="SVG"][display="true"],
.ex-body mjx-container[jax="SVG"][display="true"],
.box-obs mjx-container[jax="SVG"][display="true"],
.box-note mjx-container[jax="SVG"][display="true"],
.step-body mjx-container[jax="SVG"][display="true"] {
    display: inline-block !important;
    margin: 0 0.25rem !important;
    vertical-align: middle !important;
    text-align: initial !important;
    padding: 0 !important;
}

p mjx-container[jax="SVG"],
li mjx-container[jax="SVG"],
td mjx-container[jax="SVG"],
th mjx-container[jax="SVG"],
.modal-pista-content mjx-container[jax="SVG"],
.modal-pista-box mjx-container[jax="SVG"],
.ex-body mjx-container[jax="SVG"],
.box-obs mjx-container[jax="SVG"],
.box-note mjx-container[jax="SVG"] {
    vertical-align: middle !important;
}

mjx-container[jax="SVG"] svg {
    color: #ffffff !important;
}

/* ==========================================================================
   BOTONERA INFERIOR DE NAVEGACIÓN ENTRE LECCIONES
   ========================================================================== */
.theory-footer-nav, .bottom-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 3.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.nav-button, .nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--border) !important;
    color: #ffffff !important;
    text-decoration: none;
    padding: 0.75rem 1.3rem;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.nav-button:hover, .nav-btn:hover {
    background: rgba(79, 125, 255, 0.2) !important;
    border-color: var(--accent) !important;
    transform: translateY(-1px);
}

.nav-button.center, .nav-hub {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
}

.nav-button.center:hover, .nav-hub:hover {
    background: var(--accent-hover) !important;
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */
@media (max-width: 768px) {
    .nav-links {
        display: none;
    }
    .content-container, .content-wrap, main {
        padding: 1rem 1rem 3rem;
    }
    .modular-card, .theory-card, .content-section, .exercise-card {
        padding: 1.5rem 1.3rem;
    }
    .theory-title, .hero h1 {
        font-size: 1.8rem;
    }
    .theory-footer-nav, .bottom-nav {
        flex-direction: column;
        align-items: stretch;
    }
    .nav-button, .nav-btn {
        justify-content: center;
    }
}
