/* ------------------------------------------------------------------- */
/* 0. VARIABLES Y RESET BÁSICO */
/* ------------------------------------------------------------------- */

:root {
    /* Paleta de colores (Rojo Oscuro) */
    --color-primary: #9A031E;      /* Rojo Ladrillo Oscuro para acentos */
    --color-secondary: #E36414;    /* Naranja oscuro, como color secundario */
    --color-text-light: #F5F5F5;   /* Texto claro/blanco roto */
    --color-background-light: #FFFFFF; /* Fondo principal claro */
    --color-background-dark: #1F2024;  /* Fondo principal oscuro (para Modo Oscuro) */
    --color-card-background: #F0F0F0; /* Fondo de tarjetas en modo claro */
    
    /* Configuración de Smooth Scroll (Paso 5) */
    scroll-behavior: smooth;
    
    /* Fuente */
    --font-family-primary: 'Montserrat', sans-serif;
}

/* Reset básico */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family-primary);
    line-height: 1.6;
    color: #333; /* Texto oscuro por defecto */
    background-color: var(--color-background-light);
    transition: background-color 0.4s, color 0.4s; /* Transición para Modo Oscuro */
}

/* ------------------------------------------------------------------- */
/* 1. ESTILOS GENERALES Y TIPOGRAFÍA */
/* ------------------------------------------------------------------- */

h1, h2, h3, h4 {
    font-weight: 700;
    margin-bottom: 0.5em;
    color: var(--color-primary);
}

h2 { font-size: 2.5em; }

h3 {
    font-size: 1.8em;
    margin-bottom: 1.5em;
    text-align: center;
}

a {
    text-decoration: none;
    color: var(--color-primary);
    transition: color 0.3s;
}

a:hover {
    color: var(--color-secondary);
}

section {
    padding: 60px 5%;
    max-width: 1200px;
    margin: 0 auto;
}

/* Botón CTA (Call To Action) */
.cta-button {
    display: inline-block;
    background-color: var(--color-primary);
    color: var(--color-text-light);
    padding: 10px 25px;
    margin-top: 20px;
    border-radius: 5px;
    font-weight: 700;
    text-transform: uppercase;
    transition: background-color 0.3s;
}

.cta-button:hover {
    background-color: var(--color-secondary);
    color: var(--color-text-light);
}

/* ------------------------------------------------------------------- */
/* 2. ENCABEZADO Y NAVEGACIÓN */
/* ------------------------------------------------------------------- */

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 5%;
    background-color: var(--color-background-light);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.main-header h1 {
    margin: 0;
    font-size: 1.5em;
    color: var(--color-primary);
}

.main-nav ul {
    list-style: none;
    display: flex;
}

.main-nav li {
    margin-left: 25px;
}

.main-nav a {
    text-transform: uppercase;
    font-size: 0.9em;
    padding: 5px 0;
    position: relative;
}

.main-nav a::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--color-secondary);
    transition: width 0.3s ease-in-out;
}

.main-nav a:hover::after {
    width: 100%;
}

.menu-toggle, .dark-mode-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5em;
    padding: 5px;
    color: #333;
    display: none; /* Oculto por defecto en desktop */
    margin-left: 10px;
    transition: color 0.3s;
}

.header-controls {
    display: flex;
    align-items: center;
}

/* ------------------------------------------------------------------- */
/* 3. SECCIONES Y ANIMACIONES (Paso 7) */
/* ------------------------------------------------------------------- */

/* Sección Hero */
.hero-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 80vh;
    gap: 40px;
    padding-top: 100px;
}

.hero-content {
    max-width: 50%;
}

.hero-content h2 {
    font-size: 3.5em;
    margin-bottom: 0.2em;
    color: #222;
}

/* --- ESTILOS PARA HACER LA IMAGEN CIRCULAR Y ANIMADA --- */

.hero-image-placeholder {
    /* Define el tamaño del contenedor si es necesario */
    width: 250px; /* Tamaño que desees para el círculo */
    height: 250px;
    border-radius: 50%; /* ¡ESTO HACE LA FORMA CIRCULAR! */
    overflow: hidden; /* Esto asegura que la imagen interna se corte a la forma */
    margin: 30px auto; /* Centra el contenedor */
    border: 5px solid var(--color-primary); /* Borde decorativo */
    box-shadow: 0 0 0 10px rgba(var(--color-primary), 0.1); /* Sombra exterior */
    animation: bounceIn 1.5s ease-out; /* Animación de entrada */
    /* Asegúrate de que los colores primarios estén definidos en :root y .dark-mode */
}

.profile-img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Asegura que la imagen cubra todo el círculo */
    display: block;
    transition: transform 0.4s ease;
}

.profile-img:hover {
    transform: scale(1.05); /* Efecto zoom al pasar el mouse */
}

/* Define la animación si no la tienes */
@keyframes bounceIn {
    0% { opacity: 0; transform: scale(0.3); }
    50% { opacity: 1; transform: scale(1.1); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); }
}
/* ---------------------------------------------------- */

@keyframes spinIn {
    from {
        opacity: 0;
        transform: rotate(-180deg) scale(0.5);
    }
    to {
        opacity: 1;
        transform: rotate(0deg) scale(1);
    }
}

/* Sección Sobre Mí */
.about-section {
    background-color: var(--color-card-background);
}

.key-skills ul {
    list-style: none;
    padding-left: 0;
    margin-top: 15px;
}

.key-skills li {
    padding-left: 1.2em;
    position: relative;
    margin-bottom: 8px;
}

.key-skills li::before {
    content: '▶';
    position: absolute;
    left: 0;
    color: var(--color-secondary);
}

/* Sección Servicios */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    text-align: center;
}

.service-card {
    background-color: var(--color-background-light);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border-top: 4px solid var(--color-primary);
    transition: transform 0.3s, box-shadow 0.3s;
}

.service-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

/* Sección Portafolio (Galería de Imágenes) */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.gallery-item {
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 5px;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    opacity: 0; /* Oculto para el Intersection Observer en JS */
    animation: fadeIn 0.8s forwards; /* La animación se activa y corre en JS */
    animation-play-state: paused; /* DETENIDA hasta que JS la active */
}

/* Estilos de la Imagen dentro del link */
.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Asegura que la imagen cubra el contenedor */
    display: block;
    transition: transform 0.3s;
}

.gallery-item img:hover {
    transform: scale(1.05);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Sección Contacto */
.contact-section {
    text-align: center;
}

.contact-section address {
    margin-top: 20px;
    font-style: normal;
}

/* ------------------------------------------------------------------- */
/* 4. PIE DE PÁGINA */
/* ------------------------------------------------------------------- */

footer {
    text-align: center;
    padding: 20px 5%;
    background-color: #333;
    color: var(--color-text-light);
    font-size: 0.9em;
}

/* ------------------------------------------------------------------- */
/* 5. DISEÑO RESPONSIVE (Paso 3: Menú Hamburguesa - Estilos) */
/* ------------------------------------------------------------------- */

@media (max-width: 768px) {
    
    .hero-section {
        flex-direction: column;
        text-align: center;
        padding-top: 80px;
        min-height: 60vh;
    }

    .hero-content {
        max-width: 100%;
        order: 2;
    }

    .hero-image-placeholder {
        width: 200px;
        height: 200px;
        order: 1;
        margin-bottom: 20px;
    }

    /* Ocultar la navegación normal y mostrar el toggle */
    .main-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background-color: var(--color-background-light);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        padding: 10px 0;
    }

    .main-nav.active {
        display: block;
    }
    
    .main-nav ul {
        flex-direction: column;
        text-align: center;
    }

    .main-nav li {
        margin: 10px 0;
        border-bottom: 1px solid #eee;
        padding-bottom: 5px;
    }

    .menu-toggle, .dark-mode-toggle {
        display: block;
    }

    /* Estilos del Menú Hamburguesa (las 3 barras) */
    .menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        width: 30px;
        height: 25px;
    }

    .menu-toggle .bar {
        display: block;
        width: 100%;
        height: 3px;
        background-color: var(--color-primary);
        border-radius: 1px;
        transition: all 0.3s;
    }

    /* Estado 'activo' del menú toggle (para la "X") */
    .menu-toggle.is-active .bar:nth-child(2) {
        opacity: 0;
    }

    .menu-toggle.is-active .bar:nth-child(1) {
        transform: translateY(11px) rotate(45deg);
    }

    .menu-toggle.is-active .bar:nth-child(3) {
        transform: translateY(-11px) rotate(-45deg);
    }
}

/* ------------------------------------------------------------------- */
/* 6. MODO OSCURO (Paso 4: Estilos) */
/* ------------------------------------------------------------------- */

body.dark-mode {
    color: var(--color-text-light);
    background-color: var(--color-background-dark);
}

body.dark-mode .main-header {
    background-color: #2D2E32;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

body.dark-mode h1,
body.dark-mode h2, 
body.dark-mode h3, 
body.dark-mode h4 {
    color: var(--color-secondary);
}

body.dark-mode a {
    color: var(--color-secondary);
}

body.dark-mode .hero-content h2 {
    color: var(--color-text-light);
}

body.dark-mode .about-section {
    background-color: #2D2E32;
}

body.dark-mode .service-card {
    background-color: #3C3E44;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border-top-color: var(--color-primary);
}

body.dark-mode .gallery-item {
    box-shadow: 0 4px 8px rgba(255, 255, 255, 0.1);
}

body.dark-mode .menu-toggle .bar {
    background-color: var(--color-secondary);
}

body.dark-mode .dark-mode-toggle {
    color: var(--color-secondary);
}

/* ------------------------------------------------------------------- */
/* 7. ESTILOS LIGHTBOX / MODAL DE IMAGEN */
/* ------------------------------------------------------------------- */

.modal {
    display: none; /* Oculto por defecto */
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.9); /* Fondo negro semi-transparente */
    padding-top: 60px;
}

/* Contenido del Modal (la imagen) */
.modal-content {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 900px;
    max-height: 80vh;
    object-fit: contain;
}

/* Botón de Cerrar (la X) */
.close-button {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: var(--color-secondary);
    text-decoration: none;
    cursor: pointer;
}

/* Texto o título de la imagen (Caption) */
#caption {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 900px;
    text-align: center;
    color: #ccc;
    padding: 10px 0;
}

/* Animación de entrada para la imagen */
.modal-content, #caption {  
    animation-name: zoom;
    animation-duration: 0.6s;
}

@keyframes zoom {
    from {transform:scale(0)} 
    to {transform:scale(1)}
}

/* Estilos de Lightbox en Modo Oscuro */
body.dark-mode .modal {
    background-color: rgba(0, 0, 0, 0.95);
}

body.dark-mode .close-button {
    color: var(--color-secondary);
}

body.dark-mode #caption {
    color: var(--color-text-light);
}