@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600&family=PT+Sans:wght@400;700&display=swap');

/* =========================================
   0. VARIABLES GLOBALES (DISEÑO Y ARQUITECTURA)
   ========================================= */
:root {
    /* Paleta de Colores */
    --primary-color: #ffffff;
    --secondary-color: #800f39; /* Vinotinto UFT */
    --secondary-color-hover: #6d1a1a;
    --text-dark: #333333;
    --text-light: #ffffff;
    --gray-light: #f5f5f5;
    --border-color: #dddddd;

    /* Tipografía */
    --font-main: 'Roboto', sans-serif;
    --font-titles: 'Montserrat', sans-serif;
    --font-accent: 'PT Sans', sans-serif;

    /* Dimensiones Estructurales Móvil */
    --header-height-mobile: 70px;
    --video-height-mobile: 250px;
    --menu-grid-height: 120px; /* Altura calculada de la botonera 3x2 */
}

/* =========================================
   1. ESTILOS GENERALES Y RESET
   ========================================= */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    color: var(--text-dark);
    overflow-x: hidden;
    background-color: var(--primary-color);
}

h1, h2, h3, h4 {
    font-family: var(--font-titles);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* =========================================
   2. HEADER Y NAVEGACIÓN (DESKTOP)
   ========================================= */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    position: relative;
    z-index: 1000;
}

.main-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 25px 3%;
    background: linear-gradient(to bottom, var(--secondary-color) 1%, rgba(150, 42, 76, 0.0) 80%);
    transition: background 0.3s ease, box-shadow 0.3s ease, padding 0.3s ease;
    z-index: 1000;
}

.main-nav.solid {
    background: var(--secondary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); 
    padding: 15px 3%;
}

.nav-logo {
    height: 70px;
    width: auto;
    margin-right: 30px;
}

.main-nav .logo { height: 80px; }
.main-nav .logo-center { height: 50px; }

.main-nav .menu-items {
    display: flex;
    gap: 70px;
    list-style: none;
    align-items: center;
}

.main-nav .menu-items a {
    color: var(--text-light);
    text-decoration: none;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.9em;
    letter-spacing: -0.5px;
    white-space: nowrap;
    position: relative;
    padding: 4px 0 2px 0;
    transition: color 0.3s ease;
}

.main-nav .menu-items a:hover {
    color: #cccccc;
}

/* Menú (Hamburguesa) - Visible en Desktop y Móvil */
.menu-toggle-top {
    display: flex; /* Restaurado a visible */
    flex-direction: column;
    justify-content: space-around;
    height: 50px;
    width: 35px;
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 1.8rem;
    cursor: pointer;
    margin-right: 20px;
    padding: 5px;
}

.top-menu-mobile {
    display: none;
    position: fixed;
    top: 90px;
    left: 0;
    width: 50%;
    background-color: rgba(54, 53, 53, 0.95);
    padding: 20px 0;
    flex-direction: column; 
    align-items: center;
    gap: 10px;
    z-index: 9999;
}

.top-menu-mobile.active { display: flex; }

.top-menu-mobile a {
    color: var(--text-light);
    text-decoration: none;
    padding: 10px 0;
    width: 90%;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.ws-link {
    white-space: nowrap;
    color: inherit;
    text-decoration: none;
    font-weight: bold;
    display: inline-block;
    margin: 2px 0;
    font-size: 0.95rem;
}

.ws-link:hover { color: var(--secondary-color); }
.ws-link i { margin-right: 6px; }

/* =========================================
   3. VIDEO SECTION
   ========================================= */
.video-section {
    width: 100%;
    height: 500px;
    position: relative;
    overflow: hidden;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    margin: 1px auto 40px auto;
    z-index: 100;
}

.responsive-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

/* =========================================
   4. BANNER INTERMEDIO Y ANIMACIÓN
   ========================================= */
.banner-intermedio-container {
    width: 100%;
    position: relative;
    z-index: 10;
    overflow: hidden; /* Corta el desborde horizontal */
}

.carousel-track {
    display: flex;
    width: 100%;
    transition: transform 0.5s ease-in-out; 
    /* Clave: Evita que Flexbox intente igualar las alturas si metes un banner distinto */
    align-items: flex-start; 
}

.carousel-slide {
    /* Clave: Obliga al elemento a ocupar el 100% exacto, ni un píxel más ni menos */
    flex: 0 0 100%; 
    width: 100%;
    display: block;
}

.carousel-slide img {
    width: 100%;
    height: auto; /* Respeta tu proporción matemática original */
    display: block; /* Mata el espacio blanco residual que dejan las imágenes web */
}

/* Flechas Flotantes */
.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(128, 15, 57, 0.7);
    color: var(--text-light);
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 20;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.3s ease, transform 0.2s;
}

.carousel-btn:hover {
    background: var(--secondary-color-hover);
    transform: translateY(-50%) scale(1.1);
}

.prev-btn { left: 20px; }
.next-btn { right: 20px; }

/* Animación inicial */
@keyframes fadeInFromBottom {
    from { opacity: 0; transform: translateY(40px); }
    to { opacity: 1; transform: translateY(0); }
}

.banner-intermedio-container.anim-bottom {
    animation: fadeInFromBottom 0.8s ease-out forwards;
}

/* =========================================
   5. SECCIÓN ACADÉMICA ESTÁTICA
   ========================================= */
.academica-estatica-section {
    padding: 40px 20px;
    background-color: var(--primary-color);
}

.academica-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
    max-width: 1200px;
    margin: 0 auto;
}

.academica-img-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.academica-img-container img {
    transition: transform 0.3s ease;
}

.academica-img-container:hover img {
    transform: scale(1.02);
}

.btn-mas-info {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background-color: var(--secondary-color); 
    color: var(--text-light);              
    padding: 12px 24px;        
    border-radius: 5px;        
    font-weight: 600;
    font-family: var(--font-titles);
    text-decoration: none;
    font-size: 0.95rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3); 
    z-index: 10;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.btn-mas-info:hover {
    background-color: var(--secondary-color-hover); 
    transform: translateY(-2px); 
}

/* =========================================
   6. CARDS SECTION
   ========================================= */
.cards-section {
    padding: 60px 20px;
    background-color: var(--gray-light);
}

.cards-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px; 
    margin: 0 auto;
}

.card {
    background-color: var(--primary-color);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
}

.card:hover { transform: translateY(-5px); }

.card-img {
    width: 100%;
    height: 230px;
    position: relative;
}

.card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.4s ease;
}

.card-img-hover { opacity: 0; }
.card:hover .card-img-default { opacity: 0; }
.card:hover .card-img-hover { opacity: 1; }

.card-overlay-title {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.4); 
    border-radius: 15px 0 15px 0; 
    transition: opacity 0.3s ease;
    z-index: 10;
}

.card-overlay-title h2 {
    color: var(--text-light);
    font-size: 1.5rem; 
    padding: 10px 15px;
    font-weight: bold;
    text-transform: uppercase;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.card:hover .card-overlay-title { opacity: 0.9; }

/* =========================================
   7. NEWS SECTION (SLIDES)
   ========================================= */
.title-section {
    text-align: center;
    padding: 20px 15px 0 15px;
}

.title-section h1 {
    font-family: var(--font-accent);
    font-size: 1.5rem;
    color: var(--text-dark);
}

.slide-cards-section {
    padding: 20px;
    margin: 0 auto;
}

.slide-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
}

.slide-card {
    background-color: var(--primary-color);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    position: relative;
}

.slide-card-img {
    height: 200px;
    overflow: hidden;
}

.slide-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.slide-card-content {
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.slide-card h3 {
    color: var(--secondary-color-hover);
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.slide-card .hidden-text {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background-color: rgba(109, 26, 26, 0.95);
    color: var(--text-light);
    padding: 20px;
    transition: left 0.3s ease;
    display: flex;
    align-items: center;
}

.slide-card:hover .hidden-text { left: 0; }

/* =========================================
   8. WIDGET WHATSAPP
   ========================================= */
.whatsapp-float {
    position: fixed;
    bottom: 25px;
    right: 30px;
    background-color: var(--secondary-color); 
    color: var(--text-light);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 35px;
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    text-decoration: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
}

.whatsapp-float:hover {
    transform: scale(1.1);
    box-shadow: 2px 2px 15px rgba(0, 0, 0, 0.3);
    background-color: var(--secondary-color-hover); 
}

/* =========================================
   9. FOOTER SECTION
   ========================================= */
.footer {
    background-color: #191919;
    color: var(--text-light);           
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    padding: 40px 5%; 
}

.footer .col {
    padding: 0 15px;
    border-right: 1px solid rgba(255, 255, 255, 0.2); 
}

.footer .col:last-child { border-right: none; }

.footer h3 {
    border-bottom: 2px solid var(--secondary-color); 
    padding-bottom: 10px;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.footer p, .footer a {
    color: var(--gray-light);
    text-decoration: none;
    display: block;
    margin-bottom: 5px;
    font-size: 0.95rem;
}

.footer a:hover { color: var(--primary-color); }

.footer .news-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 0;
}

.footer .social-intro-text { margin-bottom: 25px; }

.footer .social-icons {
    display: flex;
    gap: 15px;
    align-items: center;
}

.footer .social-icons img {
    width: 55px;
    height: 55px;
}

.footer .footer-logo {
    width: 100px; 
    margin-bottom: 10px;
}

/* =========================================
   10. RESPONSIVE Y ESTRUCTURA MÓVIL
   ========================================= */
@media (max-width: 768px) {
    
    /* 1. HEADER MÓVIL (Superior Fijo) */
    .main-nav {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%; /* Asegura que cubra toda la pantalla horizontalmente */
        height: var(--header-height-mobile);
        padding: 0 5%;
        /* Restauramos el difuminado vinotinto transparente */
        background: linear-gradient(to bottom, var(--secondary-color) 5%, rgba(150, 42, 76, 0.0) 90%);
        display: flex;
        justify-content: space-between; /* Empuja un elemento a cada extremo */
        align-items: center;
        z-index: 1001;
    }

    /* Menú desplegable en teléfonos */
    .top-menu-mobile {
        /* Magia pura: Nace matemáticamente donde termina la barra */
        top: var(--header-height-mobile); 
        width: 100%; /* (Opcional) En móvil el 100% se ve más elegante que el 50% */
        z-index: 9999; 
    }

    /* Hamburguesa anclada a la izquierda */
    .menu-toggle-top {
        display: flex;
        order: 1; 
        margin: 0;
        z-index: 1300;
    }

    /* Logo anclado a la derecha */
    .nav-logo-link { 
        order: 2; 
        margin: 0;
        display: flex;
        align-items: center;
    }
    
    .nav-logo { 
        height: 45px; 
        width: auto;
    }

    /* 2. VIDEO MÓVIL */
    .video-section {
        height: var(--video-height-mobile);
        border-radius: 0;
        box-shadow: none;
    }

    /* 3. BOTONERA 3x2 MÓVIL (Posicionada bajo el video usando variables) */
    .main-nav .menu-items {
        display: grid;
        grid-template-columns: repeat(3, 1fr); 
        gap: 8px;
        position: absolute;
        top: var(--video-height-mobile); /* Flota exactamente al terminar el video */
        left: 0;
        width: 100%;
        background-color: var(--gray-light); 
        padding: 15px;
        box-shadow: 0 4px 10px rgba(0,0,0,0.1);
        z-index: 90;
    }

    .main-nav .menu-items li:first-child { display: none; }

    .main-nav .menu-items a {
        background-color: var(--primary-color);
        color: var(--secondary-color);
        border: 1px solid var(--border-color);
        border-radius: 6px;
        padding: 12px 2px;
        font-size: 0.68rem;
        text-align: center;
        display: block;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }

    /* 4. SOLUCIÓN DE SOLAPAMIENTO DEL BANNER */
    /* Empujamos el banner usando el tamaño del grid flotante para que no choque */
    .banner-intermedio-container {
        margin-top: var(--menu-grid-height); 
        padding: 10px 0;
    }

    /* 5. AJUSTES ESTRUCTURALES GENERALES */
    .academica-container {
        grid-template-columns: 1fr;
    }

    .cards-container {
        grid-template-columns: 1fr;
    }

    .btn-mas-info {
        bottom: 15px;
        right: 15px;    
        padding: 8px 16px;
        font-size: 0.8rem;
    }

    .footer {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .footer .col {
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.2);
        padding-bottom: 20px;
    }

    .footer .logo-container {
        align-items: center;
    }
    
    .whatsapp-float {
        width: 50px;
        height: 50px;
        font-size: 30px;
        bottom: 20px;
        right: 20px;
    }
}

/* Pantallas extra pequeñas */
@media (max-width: 480px) {
    :root {
        --video-height-mobile: 200px; /* Reducimos la variable de altura */
    }
    .main-nav .menu-items a { font-size: 0.62rem; }
}

/* =========================================
   11. ADAPTACIÓN PARA PÁGINAS INTERNAS
   ========================================= */
@media (max-width: 768px) {
    .paginas-internas .main-nav {
        position: relative;
        flex-direction: column;
        height: auto;
        padding-bottom: 15px;
    }

    .paginas-internas .nav-logo-link {
        margin: 12px auto;
    }

    .paginas-internas .menu-toggle-top {
        position: absolute;
        top: 18px;
        left: 15px;
    }

    .paginas-internas .main-nav .menu-items {
        position: static;
        padding: 5px 10px 0 10px;
        background-color: transparent;
        box-shadow: none;
    }

    body.paginas-internas {
        padding-top: 0;
    }
}