@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@600;700&family=Roboto:wght@400;500&display=swap');

:root {
    /* Lila, Plomo & White Combination Tokens */
    --color-primary: #6A1B9A;       /* Lila Profundo */
    --color-primary-active: #4A148C;
    --color-secondary: #9C27B0;     /* Lila Vibrante */
    --color-accent: #454545;        /* Plomo Oscuro Professional */
    --color-bg: #F5F5F7;         /* Gris muy claro institucional */
    --color-muted: #F3E5F5;         /* Lila muy tenue para fondos */
    --color-hover-secondary: #E1BEE7;
    --color-grey-light: #F0F0F0;    /* Plomo muy claro */
    --text-strong: #212121;
    --text-body: #424242;
    --color-white: #FFFFFF;

    /* Elevation & Radios */
    --shadow-8dp: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-12dp: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius: 4px; /* More institutional, less rounded */

    /* Layout Constants */
    --gutter: 24px;
    --max-width: 1200px;
    --header-height: 80px;

    /* Motion & Animation */
    --easing: cubic-bezier(0.4, 0, 0.2, 1);
    --duration-short: 150ms;
    --duration-med: 400ms;
    --duration-long: 1000ms;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes shimmerText {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

@keyframes floatHeader {
    0% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
    100% { transform: translateY(0); }
}

.animate-text {
    display: inline-block;
    animation: floatHeader 3s ease-in-out infinite;
}

.shimmer-institutional {
    background: linear-gradient(90deg, var(--color-primary) 0%, #A020F0 50%, var(--color-primary) 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmerText 5s linear infinite;
}

/* Typewriter Effect Animation */
.typewriter {
    overflow: hidden;
    border-right: 3px solid var(--color-primary);
    white-space: nowrap;
    margin: 0 auto;
    letter-spacing: 0.1em;
    width: 0;
    /* Combine typing with optional shimmer */
    animation: 
        typing 4s steps(55, end) forwards,
        blink-caret .75s step-end infinite;
}

@keyframes typing {
    from { width: 0 }
    to { width: 100% }
}

@keyframes blink-caret {
    from, to { border-color: transparent }
    50% { border-color: var(--color-primary); }
}

.shimmer-typewriter {
    overflow: hidden;
    white-space: nowrap;
    margin: 0 auto;
    width: 0;
    
    background: linear-gradient(90deg, var(--color-primary) 0%, #A020F0 50%, var(--color-primary) 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    
    animation: 
        typing 3s steps(60, end) forwards,
        shimmerText 5s linear infinite;
}

@keyframes typing {
    from { width: 0 }
    to { width: 63ch } /* Ajustado a los caracteres exactos para evitar espacio extra */
}

.animate-fade-in-up {
    animation: fadeInUp 0.8s ease-out forwards;
}

.animate-fade-in-right {
    animation: fadeInRight 0.8s ease-out forwards;
}

.animate-fade-in-left {
    animation: fadeInLeft 0.8s ease-out forwards;
}

/* Base Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--color-bg);
    color: var(--text-body);
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('Fondoweb.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.12; /* Ajustado para que sea sutil y transparente */
    z-index: -1;
    pointer-events: none;
}

h1,
h2,
h3,
h4 {
    font-family: 'Montserrat', sans-serif;
    color: var(--color-primary);
    line-height: 1.3;
    font-weight: 700;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

section {
    padding: 80px 0;
}

/* Page Header Global Defaults */
.page-header {
    background-color: var(--color-primary); /* Fondo base sólido */
}

/* Glassmorphism Header when Scrolled */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s var(--easing);
}

.top-bar {
    background-color: var(--color-primary);
    color: var(--color-white);
    padding: 10px 0;
    font-size: 1rem;
    font-weight: 600;
    position: relative;
    z-index: 1001;
    border-bottom: 2px solid rgba(255,255,255,0.1);
}

.top-bar .container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.top-bar a {
    color: var(--color-white);
    text-decoration: none;
    transition: opacity 0.2s;
}

.top-bar a:hover {
    opacity: 0.8;
}

.brand-bar {
    padding: 15px 0;
    border-bottom: 1px solid #eee;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo img {
    height: 70px;
    /* Movimiento continuo 3D */
    animation: logoSpin3D 6s linear infinite;
    transform-style: preserve-3d;
}

@keyframes logoSpin3D {
    0% { transform: perspective(800px) rotateY(0deg); }
    100% { transform: perspective(800px) rotateY(360deg); }
}

.nav-bar {
    background-color: #F8F9FA; /* Muted plomo to keep contrast on purple text */
    border-bottom: 1px solid #EEE;
}

@media (min-width: 768px) {
    .nav-bar {
        display: block !important;
        position: relative !important;
    }
}

.nav {
    display: flex;
    justify-content: center;
    gap: 30px;
}

.nav-link {
    text-decoration: none;
    color: var(--color-primary);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    padding: 15px 0;
    position: relative;
    transition: all var(--duration-short) var(--easing);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 3px;
    background-color: var(--color-primary);
    transition: width 0.3s;
}

.nav-link:hover::after {
    width: 100%;
}

/* Fixed CTA Group (Desktop) */
.fixed-ctas {
    display: flex;
    gap: 10px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border-radius: var(--radius);
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 200ms var(--easing);
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--color-primary);
    color: var(--color-white);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(106, 27, 154, 0.3);
    background-color: var(--color-secondary);
}

.btn-secondary {
    background-color: var(--color-bg);
    color: var(--color-primary);
    border-color: var(--color-primary);
}

.btn-secondary:hover {
    background-color: var(--color-hover-secondary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(106, 27, 154, 0.15);
}

.btn-outline-white {
    background: transparent;
    color: #FFFFFF;
    border: 1px solid #FFFFFF;
}

.btn-outline-white:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Skip Link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--color-primary);
    color: var(--color-white);
    padding: 8px;
    z-index: 2000;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
}

/* Focus Visible */
*:focus {
    outline: none;
}

*:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Hero Section Slider */
.hero {
    height: 600px; /* Altura más balanceada */
    position: relative;
    display: flex;
    align-items: center;
    overflow: hidden;
    color: #FFFFFF;
    background: #000; /* Fondo negro de seguridad */
}

.hero-slider {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.hero-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 1.5s ease-in-out;
    background-size: cover;
    background-position: center;
    z-index: 1;
}

.hero-slide.active {
    opacity: 1;
    z-index: 2; /* Siempre por encima de la anterior durante la transición */
}

.hero-slide.zoom {
    animation: kenBurns 12s linear infinite alternate;
}

.hero-slide.zoom-out {
    animation: kenBurnsReverse 12s linear infinite alternate;
}

@keyframes kenBurns {
    from { transform: scale(1); }
    to { transform: scale(1.15); }
}

@keyframes kenBurnsReverse {
    from { transform: scale(1.15); }
    to { transform: scale(1); }
}

.hero-overlay {
    position: absolute;
    inset: 0;
    /* Overlay más suave para que se vean las imágenes de fondo */
    background: radial-gradient(circle at center, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.5) 100%),
                linear-gradient(90deg, rgba(106, 27, 154, 0.4) 0%, transparent 70%);
    z-index: 3;
}

.hero-content {
    position: relative;
    z-index: 10;
    max-width: 700px;
    text-shadow: 0 4px 10px rgba(0,0,0,0.6);
    transition: all 1.5s var(--easing);
}

.hero-content h2,
.hero-content p {
    color: #FFFFFF;
    transition: color 1.5s var(--easing);
}

/* Dynamic color state for bright or specific slides */
.hero-content.alt-color h2 {
    color: #FFFFFF !important;
    text-shadow: 0 0 20px rgba(106, 27, 154, 0.8), 2px 2px 4px rgba(0,0,0,0.5);
}

.hero-content.alt-color p {
    color: #F3E5F5 !important; /* Very light lilac for subtitle */
}

.hero h1 {
    font-size: 3.5rem;
    color: #FFFFFF;
    margin-bottom: 20px;
}

.hero p {
    font-size: 1.25rem;
    margin-bottom: 30px;
}

/* Cards Section */
.section-title {
    text-align: left;
    margin-bottom: 50px;
    border-left: 6px solid var(--color-primary);
    padding-left: 20px;
}

.section-title h2 {
    font-size: 2.2rem;
    color: var(--color-primary);
    text-transform: uppercase;
}

.grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--gutter);
}

/* News Card */
.news-card {
    grid-column: span 4;
    background: var(--color-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-8dp);
    transition: all var(--duration-med) var(--easing);
    border-bottom: 3px solid transparent;
}

.news-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-12dp);
    border-color: var(--color-primary);
    background: rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(8px);
}

.news-img {
    aspect-ratio: 16 / 9;
    width: 100%;
    object-fit: cover;
}

.news-body {
    padding: 20px;
}

.news-date {
    font-size: 0.8rem;
    color: var(--color-accent);
    font-weight: 500;
}

.news-title {
    margin: 10px 0;
    font-size: 1.2rem;
}

.news-summary {
    font-size: 0.95rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 20px;
}

/* Level Card */
.level-card {
    grid-column: span 6;
    background: var(--color-bg);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-8dp);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform var(--duration-med) var(--easing);
}

.level-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-12dp);
    background: rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(8px);
}

.level-icon {
    font-size: 3rem;
    color: var(--color-accent);
    margin-bottom: 20px;
}

.level-list {
    list-style: none;
    margin: 20px 0;
    text-align: left;
    width: 100%;
}

.level-list li {
    padding-left: 18px;
    position: relative;
    margin-bottom: 8px;
    font-size: 0.85rem;
    line-height: 1.2;
}

.level-list li::before {
    content: '•';
    color: var(--color-accent);
    position: absolute;
    left: 0;
    font-weight: bold;
}

/* Director Module */
.director-module {
    background: var(--color-muted);
    padding: 60px 0;
}

.director-card {
    max-width: 800px;
    margin: 0 auto;
    background: var(--color-bg);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-8dp);
    text-align: center;
}

.director-img {
    width: 256px;
    height: 256px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 20px;
    border: 3px solid var(--color-accent);
}

.director-quote {
    font-style: italic;
    font-size: 1.1rem;
    margin-bottom: 30px;
}

/* Mobile Nav */
.menu-toggle {
    display: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-primary);
}

/* Shortcut Cards */
.shortcut-card:hover {
    transform: translateY(-5px);
    background-color: rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(8px);
}

.shortcut-card:hover * {
    color: var(--color-primary) !important;
}

/* Footer */
footer {
    background-color: var(--color-primary);
    color: var(--color-white);
    padding: 60px 0 30px;
}

footer h3, footer h4 {
    color: var(--color-white) !important; /* White for better contrast on purple */
    text-transform: uppercase;
    letter-spacing: 1px;
}

footer p {
    color: rgba(255, 255, 255, 0.8) !important; /* Slightly transparent white for body text */
}

footer .fab, footer .fas {
    color: var(--color-white) !important;
}

/* Motion Reveal Animations with Staggering */
.scroll-reveal {
    opacity: 0;
    visibility: hidden;
    transition: none;
}

.scroll-reveal.visible {
    visibility: visible;
    animation: fadeInUp var(--duration-med) var(--easing) forwards;
}

.reveal-left.visible {
    animation: fadeInLeft var(--duration-med) var(--easing) forwards;
}

.reveal-right.visible {
    animation: fadeInRight var(--duration-med) var(--easing) forwards;
}

.reveal-scale.visible {
    animation: scaleUp var(--duration-med) var(--easing) forwards;
}

/* Stagger Children */
.grid > .scroll-reveal:nth-child(1) { animation-delay: 100ms; }
.grid > .scroll-reveal:nth-child(2) { animation-delay: 200ms; }
.grid > .scroll-reveal:nth-child(3) { animation-delay: 300ms; }
.grid > .scroll-reveal:nth-child(4) { animation-delay: 400ms; }
.grid > .scroll-reveal:nth-child(5) { animation-delay: 500ms; }
.grid > .scroll-reveal:nth-child(6) { animation-delay: 600ms; }

/* Stats Floating Style */
.stats-floating {
    margin-top: -60px; /* Hace que flote sobre el banner */
    position: relative;
    z-index: 20;
}

.stats-glass {
    background: rgba(106, 27, 154, 0.9);
    backdrop-filter: blur(10px);
    border-radius: var(--radius);
    padding: 30px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    text-align: center;
    color: #fff;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
}

.stats-glass .stat-item h3 {
    font-size: 2.5rem;
    color: #fff;
    margin-bottom: 5px;
}

.stats-glass .stat-item p {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.9;
}

@media (max-width: 991px) {
    .grid {
        gap: 20px;
    }

    .news-card, .level-card {
        grid-column: span 6 !important;
    }

    .header-titles h1 {
        font-size: 1rem !important;
    }
    
    .hero h1 {
        font-size: 2.8rem;
    }
    
    .stats-glass {
        padding: 20px;
    }
}

@media (max-width: 767px) {
    .top-bar {
        display: none;
    }

    .header-titles {
        display: none; /* Hide institution name on mobile to save space, logo is enough */
    }

    .nav-bar {
        display: none; /* Mobile toggle will handle this */
        background: #F8F9FA;
        box-shadow: 0 10px 15px rgba(0,0,0,0.1);
    }
    
    .nav {
        flex-direction: column;
        gap: 0;
        padding: 10px 0;
        text-align: center;
    }
    
    .nav-link {
        padding: 15px 20px;
        border-bottom: 1px solid #EEE;
        display: block;
    }

    .menu-toggle {
        display: block;
    }

    .hero {
        height: 550px;
    }

    .hero-content h2.reveal-left {
        font-size: 2rem !important;
    }
    
    .hero p {
        font-size: 1rem;
    }
    
    .hero-content {
        text-align: center;
        padding-top: 50px;
    }

    .cta-group {
        display: flex;
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }

    .grid > * {
        grid-column: span 12 !important;
    }
    
    .nosotros-grid, .nosotros-grid[style] {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    .stats-glass {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px;
        padding: 20px;
    }
    
    .stats-floating { margin-top: 0; }
    .stats-glass { border-radius: 0; }
    
    .director-img {
        width: 180px;
        height: 180px;
    }
}

@media (max-width: 480px) {
    .level-list, .level-list[style] {
        grid-template-columns: 1fr !important;
    }
    
    .stats-glass {
        grid-template-columns: 1fr !important;
    }
    
    .hero {
        height: 500px;
    }
    
    .shortcut-card span {
        font-size: 1rem !important;
    }
}