
/* VARIABLES & TOKENS */
:root {
    /* DEMO LAYER INVARIANTS (NO TOCAR) */
    --demo-accent: #22c55e;
    --demo-topbar-text: #ffffff;
    --demo-link: #86efac;
    --demo-link-shadow: 0 0 10px rgba(34,197,94,.35);
    --demo-glow: 0 0 0 3px rgba(34,197,94,.25), 0 0 12px rgba(34,197,94,.6);
    --demo-topbar-bg: rgba(6,24,14,.92); /* Fondo oscuro por defecto */
    --demo-note-bg: rgba(34,197,94,.12);
    --demo-note-border: rgba(34,197,94,.35);
    --demo-note-text: #0f172a; /* JS actualizará esto si el fondo es oscuro */
    --demo-shadow: 0 10px 30px rgba(0,0,0,.35);
    --demo-radius: 12px;
    --demo-font: 'Inter', ui-sans-serif, system-ui, sans-serif;
    --demo-z: 9999;
    --demo-topbar-h: 0px; 
    --site-nav-h: 0px; 
    --demo-safe-top: env(safe-area-inset-top, 0px);
    --demo-topbar-offset: calc(var(--demo-topbar-h) + var(--demo-safe-top));
    
    /* SITE PALETTE */
    --primary: #2563eb;
    --secondary: #facc15;
    --surface: #f8fafc;
    --surface-dark: #1e293b;
    --text-main: #334155;
    --text-head: #0f172a;
    --text-light: #f1f5f9;
    --border: #e2e8f0;
    --radius: 8px;
    --radius-lg: 16px;
    
    --font-main: 'Inter', sans-serif;
    --font-head: 'Playfair Display', serif;
    
    --container-w: 1120px;
    --header-h: 70px;
}

/* RESET & BASE */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font-main);
    color: var(--text-main);
    line-height: 1.6;
    background-color: #ffffff;
    padding-top: var(--demo-topbar-offset); /* Critical for Fixed Topbar */
}
img, video { max-width: 100%; height: auto; display: block; }
a { text-decoration: none; color: inherit; transition: .3s; }
ul { list-style: none; }
h1,h2,h3,h4 { font-family: var(--font-head); color: var(--text-head); line-height: 1.2; margin-bottom: 1rem; }
p { margin-bottom: 1rem; }

/* FOCUS ACCESSIBILITY */
:focus-visible { outline: 3px solid var(--demo-accent); outline-offset: 3px; }

/* LAYOUT UTILS */
.container { max-width: var(--container-w); margin: 0 auto; padding-inline: 20px; }
.small-container { max-width: 800px; margin: 0 auto; padding-inline: 20px; }
.section-py { padding-block: 60px; }
.text-center { text-align: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 2rem; }
.mt-5 { margin-top: 3rem; }
.bg-surface { background-color: var(--surface); }
.section-dark { background-color: var(--surface-dark); color: var(--text-light); }
.section-dark h2, .section-dark p { color: var(--text-light); }

/* 5) DEMO LAYER STYLES (EXACTOS) */
#demo-layer .demo-topbar {
    position: fixed; top: 0; left: 0; right: 0;
    z-index: var(--demo-z);
    background: var(--demo-topbar-bg);
    color: var(--demo-topbar-text);
    box-shadow: var(--demo-shadow);
    font-family: var(--demo-font);
    backdrop-filter: blur(8px);
    font-size: 14px;
    line-height: 1.4;
}
.demo-container {
    display: flex; justify-content: space-between; align-items: center;
    max-width: 100%; padding: 10px 20px;
}
#demo-layer .demo-dot {
    width: 10px; height: 10px; border-radius: 999px; display: inline-block;
    box-shadow: var(--demo-glow); background: var(--demo-accent);
    margin-right: 8px; flex-shrink: 0;
}
#demo-layer .demo-right a {
    color: var(--demo-link); text-shadow: var(--demo-link-shadow); font-weight: 600;
}
/* Demo Note Styles */
#demo-layer .demo-note, .demo-note {
    margin-top: 24px; padding: 16px;
    border-radius: var(--demo-radius);
    border: 1px solid var(--demo-note-border);
    background: var(--demo-note-bg);
    color: var(--demo-note-text);
    box-shadow: 0 0 0 1px rgba(0,0,0,.05) inset;
    backdrop-filter: blur(6px);
    font-size: 0.95rem;
    font-family: var(--demo-font);
    max-width: 800px;
    margin-inline: auto; /* Center by default */
}
.demo-note-prefix { color: var(--primary); font-weight: 800; margin-right: 6px; }

/* NAVBAR STICKY */
.navbar {
    position: sticky;
    top: var(--demo-topbar-offset);
    z-index: 1000;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    height: var(--header-h);
    display: flex; align-items: center;
}
.nav-container { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.brand-logo { font-weight: 800; font-size: 1.5rem; color: var(--primary); font-family: var(--font-head); }
.nav-list { display: flex; gap: 24px; align-items: center; }
.nav-link { font-weight: 500; font-size: 0.95rem; }
.nav-link:hover { color: var(--primary); }
.btn-cta-nav { background: var(--primary); color: white; padding: 8px 16px; border-radius: 50px; }
.btn-cta-nav:hover { background: #1d4ed8; color: white; }
.mobile-toggle { display: none; background: none; border: none; cursor: pointer; }

/* HERO */
.hero-section { position: relative; min-height: 85vh; display: flex; align-items: center; justify-content: center; overflow: hidden; color: white; }
.video-bg-container { position: absolute; inset: 0; z-index: -1; }
.hero-video { width: 100%; height: 100%; object-fit: cover; }
.hero-overlay { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.65); } /* Scrim */
.hero-content { position: relative; z-index: 2; text-align: center; max-width: 800px; }
.hero-content h1 { font-size: clamp(2.5rem, 5vw, 4.5rem); color: white; text-shadow: 0 2px 10px rgba(0,0,0,0.3); margin-bottom: 24px; }
.hero-content p { font-size: clamp(1.1rem, 2vw, 1.3rem); margin-bottom: 32px; color: #e2e8f0; }
.hero-badge { background: var(--secondary); color: #000; padding: 6px 16px; border-radius: 50px; font-weight: 700; font-size: 0.85rem; display: inline-block; margin-bottom: 16px; }
.hero-actions { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

/* COMPONENTS */
.btn { display: inline-block; padding: 12px 28px; border-radius: 8px; font-weight: 600; cursor: pointer; border: none; font-size: 1rem; text-align: center; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(37,99,235,0.3); }
.btn-outline { background: transparent; border: 2px solid white; color: white; }
.btn-outline:hover { background: white; color: var(--text-head); }
.btn-block { width: 100%; }

/* Features Cards */
.feature-card { padding: 30px; background: white; border-radius: var(--radius); border: 1px solid var(--border); transition: .3s; position: relative; overflow: hidden; }
.feature-card:hover, .feature-card:focus { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.08); border-color: var(--primary); }
.icon-box { font-size: 2.5rem; margin-bottom: 16px; }

/* Stats */
.stats-row { display: flex; justify-content: space-around; background: white; padding: 30px; border-radius: var(--radius-lg); box-shadow: 0 4px 20px rgba(0,0,0,0.05); }
.stat-number { font-size: 2.5rem; font-weight: 800; color: var(--primary); display: block; }
.stat-label { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; color: #64748b; }

/* Tabs */
.tabs-container { background: white; border-radius: var(--radius); overflow: hidden; box-shadow: 0 4px 20px rgba(0,0,0,0.05); }
.tabs-header { display: flex; background: #f1f5f9; }
.tab-btn { flex: 1; padding: 16px; border: none; background: transparent; font-weight: 600; cursor: pointer; border-bottom: 3px solid transparent; }
.tab-btn.active { background: white; border-bottom-color: var(--primary); color: var(--primary); }
.tab-pane { display: none; padding: 40px; animation: fadeIn .4s ease; }
.tab-pane.active { display: block; }
.course-detail { display: flex; gap: 30px; align-items: center; }
.course-img { width: 200px; height: 150px; object-fit: cover; border-radius: 8px; }
.check-list li { padding-left: 24px; position: relative; margin-bottom: 8px; }
.check-list li::before { content: '✓'; color: var(--demo-accent); position: absolute; left: 0; font-weight: bold; }

/* Gallery Grid & Lightbox */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
.gallery-item { position: relative; cursor: pointer; overflow: hidden; border-radius: 8px; height: 250px; margin: 0; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
.gallery-item:hover img { transform: scale(1.05); }
.gallery-caption { 
    position: absolute; bottom: 0; left: 0; right: 0; 
    background: rgba(0,0,0,0.7); color: white; padding: 10px; 
    transform: translateY(100%); transition: .3s; font-size: 0.9rem;
}
.gallery-item:hover .gallery-caption, .gallery-item:focus .gallery-caption { transform: translateY(0); }

/* Stepper */
.stepper { display: flex; justify-content: space-between; position: relative; margin-top: 40px; }
.stepper::before { content: ''; position: absolute; top: 20px; left: 0; right: 0; height: 2px; background: var(--border); z-index: 0; }
.step { position: relative; z-index: 1; flex: 1; text-align: center; padding-inline: 10px; }
.step-number { width: 40px; height: 40px; background: var(--surface); border: 2px solid var(--primary); color: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; font-weight: 700; background: white; }
.step:hover .step-number { background: var(--primary); color: white; transition: .3s; }
.step-content h4 { font-size: 1.1rem; margin-bottom: 8px; }
.step-content p { font-size: 0.9rem; color: #64748b; }

/* Accordion */
.accordion-item { border-bottom: 1px solid var(--border); }
.accordion-header { width: 100%; text-align: left; padding: 20px 0; background: none; border: none; font-size: 1.1rem; font-weight: 600; cursor: pointer; display: flex; justify-content: space-between; }
.accordion-content { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.accordion-content p { padding-bottom: 20px; color: #64748b; }
.accordion-header[aria-expanded="true"] .accordion-icon { transform: rotate(45deg); }
.accordion-icon { transition: .3s; font-size: 1.5rem; color: var(--primary); }

/* Forms */
.form-group { position: relative; margin-bottom: 24px; }
.form-input { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 6px; outline: none; transition: .3s; background: white; }
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.form-label { position: absolute; left: 12px; top: 12px; color: #94a3b8; pointer-events: none; transition: .2s; background: white; padding: 0 4px; }
.form-input:focus ~ .form-label, .form-input:not(:placeholder-shown) ~ .form-label, .active-label { top: -10px; font-size: 0.8rem; color: var(--primary); }
.error-msg { display: none; color: #ef4444; font-size: 0.8rem; margin-top: 4px; }
.form-input.invalid { border-color: #ef4444; }
.form-input.invalid ~ .error-msg { display: block; }

/* Footer */
.site-footer { background: #0f172a; color: #94a3b8; padding: 40px 0 20px; }
.footer-content { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.footer-brand h4 { color: white; margin: 0; }
.footer-links a { color: #cbd5e1; margin-left: 20px; }
.footer-links a:hover { color: white; }
.footer-bottom { text-align: center; margin-top: 20px; font-size: 0.9rem; }
.demo-disclaimer { opacity: 0.5; display: block; margin-top: 8px; }

/* Floating & Extras */
.whatsapp-float { position: fixed; bottom: 20px; right: 20px; background: #25D366; width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 14px rgba(0,0,0,0.25); z-index: 990; transition: .3s; }
.whatsapp-float:hover { transform: scale(1.1); }
#back-to-top { position: fixed; bottom: 90px; right: 30px; background: var(--surface-dark); color: white; width: 40px; height: 40px; border: none; border-radius: 50%; cursor: pointer; opacity: 0; pointer-events: none; transition: .3s; z-index: 980; }
#back-to-top.visible { opacity: 1; pointer-events: auto; }

/* Lightbox Styles */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.95); z-index: 10000; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: .3s; }
.lightbox[aria-hidden="false"] { opacity: 1; pointer-events: auto; }
.lightbox-content { position: relative; max-width: 90%; max-height: 90%; }
.lightbox img { max-height: 80vh; border-radius: 4px; }
.lightbox-caption { color: white; text-align: center; margin-top: 10px; font-family: var(--font-main); }
.lightbox-close, .lightbox-prev, .lightbox-next { position: absolute; background: none; border: none; color: white; font-size: 3rem; cursor: pointer; padding: 20px; }
.lightbox-close { top: 10px; right: 10px; font-size: 2rem; }
.lightbox-prev { left: 10px; }
.lightbox-next { right: 10px; }

/* ANIMATIONS */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.fade-in-up { animation: fadeInUp 0.8s ease forwards; opacity: 0; }
.delay-1 { animation-delay: 0.2s; }
.delay-2 { animation-delay: 0.4s; }
.delay-3 { animation-delay: 0.6s; }

/* ========================================== */
/* RESPONSIVE & MOBILE FIRST RULES (<768px) */
/* ========================================== */
@media (max-width: 768px) {
    :root { --header-h: 60px; }
    
    /* STACK EVERYTHING VERTICAL */
    .grid-2, .grid-3, .stepper, .course-detail, .stats-row, .footer-content { 
        display: flex; flex-direction: column; 
    }
    .gallery-grid { grid-template-columns: 1fr; }
    
    /* NO OVERFLOW-X GUARANTEE */
    body, html { overflow-x: hidden; width: 100%; }
    .container { width: 100%; padding-inline: 16px; }
    
    /* HAMBURGER & MENU */
    .mobile-toggle { display: block; position: relative; z-index: 1002; width: 30px; height: 20px; }
    .hamburger, .hamburger::before, .hamburger::after { content: ''; display: block; width: 100%; height: 2px; background: var(--text-head); position: absolute; transition: .3s; }
    .hamburger { top: 9px; }
    .hamburger::before { top: -9px; }
    .hamburger::after { top: 9px; }
    
    .mobile-toggle[aria-expanded="true"] .hamburger { background: transparent; }
    .mobile-toggle[aria-expanded="true"] .hamburger::before { transform: rotate(45deg); top: 0; }
    .mobile-toggle[aria-expanded="true"] .hamburger::after { transform: rotate(-45deg); top: 0; }

    .nav-menu { 
        position: fixed; 
        top: calc(var(--demo-topbar-offset) + var(--header-h));
        left: 0; right: 0;
        height: calc(100vh - (var(--demo-topbar-offset) + var(--header-h)));
        background: white;
        padding: 40px 20px;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        border-top: 1px solid var(--border);
    }
    .nav-menu.active { transform: translateX(0); }
    .nav-list { flex-direction: column; align-items: flex-start; gap: 20px; }
    .nav-link { font-size: 1.2rem; display: block; width: 100%; padding: 10px 0; }

    /* ADAPTIVE COMPONENTS */
    .tabs-header { display: none; } /* Hide tabs on mobile */
    .tab-pane { display: block !important; margin-bottom: 40px; border-bottom: 1px solid var(--border); padding: 0 0 20px 0; }
    .course-detail { gap: 16px; }
    .course-img { width: 100%; height: 200px; }
    
    .stepper::before { display: none; } /* Remove stepper line */
    .step { margin-bottom: 30px; display: flex; text-align: left; gap: 16px; padding: 0; }
    .step-number { margin: 0; flex-shrink: 0; }
    
    .hero-content h1 { font-size: 2.2rem; }
    .demo-container { flex-direction: column; gap: 8px; align-items: flex-start; }
    .demo-right { font-size: 0.85rem; align-self: flex-end; }
    
    .stats-row { gap: 24px; text-align: center; }
    .footer-links { margin: 20px 0 0 0; display: flex; flex-direction: column; gap: 12px; }
    .footer-links a { margin: 0; }
    
    /* DEMO NOTE MOBILE ORDER */
    .demo-note { order: 99; margin-top: 30px; }
}
