/* ------------------------------------
   1. ESTILOS BASE Y VARIABLES
   ------------------------------------ */

/* Importación de fuentes */
@import url('https://fonts.googleapis.com/css2?family=Lora:wght@400;700&family=Roboto:wght@400;500&display=swap');

/* Variables de color y tipografía */
:root {
    --font-primary: 'Lora', serif;
    --font-secondary: 'Roboto', sans-serif;

    /* Modo Claro (por defecto) */
    --color-background: #fdfdfd;
    --color-text: #333;
    --color-primary: #d9534f;
    /* Un rojo suave */
    --color-header-overlay: rgba(0, 0, 0, 0.5);
    --color-nav-bg: rgba(255, 255, 255, 0.9);
    --color-border: #a0a0a0;
    --input-fill: #000000;
    --subir-fill: #000000;
    --text-shadow: ;
}

/* Variables para el Modo Oscuro */
.dark-mode {
    --color-background: #1a1a1a;
    --color-text: #f0f0f0;
    --color-primary: #ffffff;
    --color-nav-bg: rgba(26, 26, 26, 0.9);
    --color-border: #444;
    --input-fill: #d9544f;
    --subir-fill: rgba(217, 84, 79, 0.500);
    --text-shadow-principal: #ff0000 0px 0px 20px;
    --text-shadow: rgb(255, 0, 0) 0px 0px 15px;
}

/* Reset básico y estilos globales */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
    /* Ajuste para el menú fijo */
}

body {
    font-family: var(--font-secondary);
    background-color: var(--color-background);
    color: var(--color-text);
    line-height: 1.7;
    transition: background-color 0.3s, color 0.3s;
}

h1,
h2 {
    font-family: var(--font-primary);
    font-weight: 700;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

/* ------------------------------------
   2. CABECERA Y MENÚ DE NAVEGACIÓN
   ------------------------------------ */

.main-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background-color: var(--color-nav-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border);
    transition: background-color 0.3s, border-color 0.3s;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    height: 70px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo img {
    max-width: 60.571px;
    max-height: 60px;
    display: block;
    margin: 0 auto;
}

.nav-logo {
    font-family: var(--font-primary);
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--color-text);
    text-shadow: var(--text-shadow);
}

.nav-menu {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 30px;
}

.nav-menu a {
    color: var(--color-text);
    font-weight: 500;
    padding: 5px 0;
    position: relative;
    transition: color 0.3s;
}

.nav-menu a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--color-primary);
    transition: width 0.3s;
}

.nav-menu a:hover::after {
    width: 100%;
}

.nav-button {
    background-color: #d9534f;
    color: white !important;
    padding: 10px 20px;
    border-radius: 5px;
    transition: background-color 0.3s, transform 0.3s;
}

.nav-button:hover {
    background-color: #c9302c;
    transform: translateY(-2px);
}

.nav-button::after {
    display: none;
    /* Ocultar la línea de hover para el botón */
}

.hamburger {
    display: none;
    /* Oculto en escritorio */
    background: none;
    border: none;
    cursor: pointer;
    z-index: 1001;
}

.hamburger span {
    display: block;
    width: 25px;
    height: 3px;
    background-color: var(--color-text);
    margin: 5px 0;
    transition: all 0.3s;
}

.main-header {
    position: relative;
    height: clamp(100px, 100vw, 80vh);
    line-height: 1.15;
    margin-top: clamp(10px, 10vw, 40px);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: white;
    background: var(--color-header-overlay) url('https://images.unsplash.com/photo-1542051841857-5f90071e7989?q=80&w=2070') no-repeat center center/cover;
}

.header-content {
    z-index: 2;
}

.header-content h1 {
    font-size: 6rem;
    font-weight: bolder;
    margin-bottom: 10px;
    color: rgb(255, 255, 255);
    filter: brightness(2) contrast(1);
    text-shadow: var(--text-shadow-principal);
}

.social-links a {
    color: white;
    margin: 0 5px;
    font-size: 1rem;
}

.social-links svg {
    width: 30px;
    height: 30px;
    margin-top: 1.2rem;
}

.social-links svg:hover {
    transform: scale3d(1.15, 1.15, 1.4);
}

.theme-switcher {
    position: fixed;
    top: 90px;
    right: 20px;
    z-index: 2;
    cursor: pointer;
}

#theme-toggle {
    display: none;
}

.theme-switcher label {
    font-size: 1.5rem;
    cursor: pointer;
}

.theme-switcher label svg {
    width: 40px;
    height: 40px;
    margin-right: 5px;
    fill: var(--input-fill);
}

/* ------------------------------------
   3. ARTÍCULO Y CONTENIDO PRINCIPAL
   ------------------------------------ */

.main-content {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: 1fr 250px;
    align-items: start;
    gap: 50px;
}

.blog-post {
    counter-reset: h2-1;
    /* Inicia el contador */
}

.blog-post section {
    margin-bottom: 40px;

}

.blog-post section h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    padding-left: 40px;
    text-shadow: var(--text-shadow);
    position: sticky;
}

.blog-post section h2::before {
    counter-increment: h2-1;
    /* Incrementa el contador */
    content: counter(h2-1);
    /* Muestra el contador */
    position: absolute;
    left: 0;
    top: 0;
    color: var(--color-primary);
    font-size: 1.5rem;
    font-weight: bold;
}

.blog-post p {
    margin-bottom: 15px;
}

.table-of-contents {
    order: 2;
    position: sticky;
    top: 100px;
    /* 70px del nav + 30px de margen */

    background-color: var(--color-nav-bg);
    transition: background-color 0.3s, border-color 0.3s;

    box-shadow: var(--color-primary) 0px 0px 20px;
    color: var(--color-text);
    border: 1px solid var(--color-border);
    padding: 20px;
    border-radius: 5px;
    z-index: 100;
    width: fit-content;
    margin-left: auto;
}

.table-of-contents h2 {
    font-size: 1.2rem;
    margin-bottom: 15px;
}

.table-of-contents ol {
    list-style: none;
    padding-left: 0;
}

.table-of-contents li {
    margin-bottom: 10px;
}

.table-of-contents a:hover {
    color: red;
    text-decoration: none;
}


/* ------------------------------------
   4. PIE DE PÁGINA
   ------------------------------------ */
footer h4 {
    text-shadow: var(--text-shadow);
}

.main-footer {
    background-color: var(--color-text);
    color: var(--color-background);
    padding: 40px 20px 20px;
    margin-top: 50px;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    gap: 30px;
    flex-wrap: wrap;
}

.footer-column {
    flex: 1;
    min-width: 250px;
}

.footer-column h4 {
    font-family: var(--font-primary);
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.footer-column ul {
    list-style: none;
}

.footer-column ul li {
    margin-bottom: 10px;
}

.footer-column a {
    color: var(--color-background);
    opacity: 0.8;
    transition: opacity 0.3s;
}

.footer-column a:hover {
    opacity: 1;
}

.social-links-footer a {
    display: block;
    margin-bottom: 10px;
}

.social-links-footer svg {
    width: 30px;
    height: 30px;
    position: absolute;
    left: clamp(64%, 64vw, 80px);
}

.social-links-footer svg:hover {
    transform: scale3d(1.15, 1.15, 1.4);
}

.footer-bottom {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #555;
    font-size: 0.9rem;
    opacity: 0.7;
}

footer .subir {
    background-color: var(--subir-fill);
    color: var(--color-primary);
    border-radius: 50%;
    padding: 0.5rem;
    position: fixed;
    bottom: 10px;
    right: 10px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    transition: background-color 0.3s;
}

footer .subir svg {
    width: 100%;
    height: 100%;
    fill: var(--color-primary);
}

/* ------------------------------------
   5. RESPONSIVE DESIGN
   ------------------------------------ */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 992px) {
    .main-content {
        grid-template-columns: 1fr;
        /* Cambia a una sola columna */
    }

    .table-of-contents {
        position: static;
        /* Deja de ser pegajoso */
        order: -1;
        /* Mueve la tabla de contenidos al principio */
        margin-bottom: 40px;
    }
}

@media (max-width: 768px) {
    .header-content h1 {
        text-align: center;
        font-size: 2.5rem;
    }

    .nav-menu {
        position: fixed;
        top: 70px;
        /* Debajo del nav */
        left: -100%;
        /* Oculto fuera de la pantalla */
        width: 100%;
        height: calc(100vh - 70px);
        background-color: var(--color-background);
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 40px;
        transition: left 0.4s ease-in-out;
    }

    .nav-menu.active {
        left: 0;
        /* Muestra el menú */
    }

    .hamburger {
        display: block;
        /* Muestra el botón de hamburguesa */
    }

    /* Animación de la hamburguesa a una 'X' */
    .hamburger.active span:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }

    .hamburger.active span:nth-child(2) {
        opacity: 0;
    }

    .hamburger.active span:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }

    .theme-switcher {
        position: absolute;
        top: clamp(8vh, 14vw, 80px);
    }
}

/* ------------------------------------
   6. ESTILOS DE IMPRESIÓN
   ------------------------------------ */

@media print {

    /* Reset básico para impresión */
    body {
        font-family: 'Times New Roman', Times, serif;
        background-color: white !important;
        /* Forzar fondo blanco */
        color: black !important;
        /* Forzar texto negro */
        font-size: 12pt;
        /* Tamaño de fuente base legible */
        line-height: 1.5;
    }

    /* Ocultar elementos no esenciales para la impresión */
    .main-nav,
    .table-of-contents,
    .main-footer,
    .theme-switcher,
    .social-links,
    .social-links-footer,
    .hamburger,
    footer .subir {
        display: none !important;
    }

    /* Eliminar sombras de texto, colores y fondos innecesarios */
    *,
    *::before,
    *::after {
        text-shadow: none !important;
        box-shadow: none !important;
        background: none !important;
        color: black !important;
        /* Asegura que todo el texto sea negro, excepto donde se anule */
    }

    /* Estilos para la cabecera principal */
    .main-header {
        height: auto;
        padding: 20px 0;
        margin-top: 0;
        /* Eliminar margen superior */
        text-align: left;
        border-bottom: 2px solid black;
        /* Separador visual */
    }

    .header-content h1 {
        font-size: 24pt;
        font-weight: bold;
        filter: none;
        /* Resetear filtros */
    }

    /* Estilos para el contenido principal */
    .main-content {
        display: block;
        max-width: 100%;
        margin: 20px 0;
        /* Ajustar margen */
        padding: 0;
    }

    .blog-post section {
        margin-bottom: 20px;
        page-break-inside: avoid;
        /* Evitar que las secciones se corten entre páginas */
    }

    .blog-post h2,
    .table-of-contents h2 {
        font-size: 18pt;
        padding-left: 0;
        margin-bottom: 15px;
        page-break-after: avoid;
        /* Evitar salto de página justo después del título */
    }

    /* Estilos para los contadores de los títulos */
    .blog-post h2::before {
        position: static;
        padding-right: 10px;
        font-weight: bold;
    }

    /* Mostrar URL de los enlaces */
    a,
    a:visited {
        text-decoration: underline;
        color: #444 !important;
        /* Un color oscuro para los enlaces */
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 9pt;
        font-style: italic;
        color: #333 !important;
    }

    /* No mostrar URL para enlaces internos de la página o sin href */
    a[href^="#"]::after,
    a:not([href])::after {
        content: "";
    }
}