/* ===================================================================
   PREMIUM LAYER — Laboratorio de Inteligencia Pública
   Ronda 1 (fundación): tipografía editorial, acento único oro,
   textura, estados interactivos y jerarquía premium.
   Capa sobre style.css: no rompe funcionalidad, mejora lo existente.
   =================================================================== */

/* ---------- Tipografía: serif display + sans body ---------- */
:root {
    --font-display: 'Fraunces', 'Georgia', serif;
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

    /* Paleta refinada: un solo acento (oro), azul marino profundo tintado */
    --navy: #0B1B2B;
    --navy-light: #122C45;
    --navy-mid: #16395C;
    --gold: #D4A843;
    --gold-light: #E8C96A;
    --gold-dark: #A97F2B;
    --blue: #2F5FA8;

    /* Superficies tintadas (frío, coherente con navy) */
    --surface: #FFFFFF;
    --surface-2: #F5F7FA;
    --surface-3: #EAEEF4;
    --surface-4: #DCE3EC;
    --bg-1: #F5F7FA;

    /* Texto */
    --text-1: #0B1B2B;
    --text-2: #51667E;
    --text-3: #8598AF;
    --text-4: #9DB8DC;

    /* Sombras tintadas con la base navy */
    --shadow-sm: 0 1px 2px rgba(11, 27, 43, 0.05), 0 2px 8px rgba(11, 27, 43, 0.04);
    --shadow-md: 0 6px 24px rgba(11, 27, 43, 0.08);
    --shadow-lg: 0 16px 48px rgba(11, 27, 43, 0.12);
    --shadow-xl: 0 28px 80px rgba(11, 27, 43, 0.18);
    --shadow-glow: 0 0 44px rgba(212, 168, 67, 0.12);

    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 26px;
    --radius-2xl: 32px;

    --duration: 0.25s;
}

/* ---------- Base ---------- */
html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--surface);
    font-feature-settings: "kern" 1, "liga" 1;
    letter-spacing: -0.005em;
}

/* Foco visible accesible (requisito, no opcional) */
:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 3px;
    border-radius: 4px;
}

/* ---------- Tipografía display ---------- */
.display-xl, .display-lg, .display-md, .display-sm,
.heading-lg, .heading-md, .heading-sm,
h1, h2, h3 {
    font-family: var(--font-display);
    font-variation-settings: "opsz" 48, "SOFT" 30, "WONK" 1;
    letter-spacing: -0.02em;
    text-wrap: balance;
}

.display-xl {
    font-size: clamp(2.75rem, 6vw, 4.75rem);
    line-height: 0.98;
    font-weight: 620;
    letter-spacing: -0.035em;
}

.display-lg {
    font-size: clamp(2.2rem, 4.5vw, 3.5rem);
    line-height: 1.04;
    font-weight: 600;
    letter-spacing: -0.03em;
}

.display-md {
    font-size: clamp(1.75rem, 3vw, 2.5rem);
    line-height: 1.1;
    font-weight: 600;
    letter-spacing: -0.025em;
}

h1, h2, h3 { text-wrap: pretty; }

/* Números con tabular figures (datos, stats, precios) */
.stat-number, .table-premium td, .font-mono,
[class*="stat"], .metric, .counter {
    font-variant-numeric: tabular-nums;
}

/* Texto de párrafos con ancho legible */
.body-lg, p {
    max-width: 65ch;
}

/* ---------- Textura: grano sutil + ambiente ---------- */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.35;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.055'/%3E%3C/svg%3E");
}

.hero, .section-dark {
    background-image:
        radial-gradient(120% 90% at 15% 0%, rgba(212, 168, 67, 0.08) 0%, transparent 45%),
        radial-gradient(100% 80% at 90% 100%, rgba(47, 95, 168, 0.12) 0%, transparent 50%),
        var(--navy);
}

.hero { position: relative; overflow: hidden; }

/* ---------- Navbar premium refinado ---------- */
.navbar-premium {
    backdrop-filter: blur(14px);
    background: rgba(11, 27, 43, 0.82);
    border-bottom: 1px solid rgba(212, 168, 67, 0.14);
    transition: background 0.25s ease, box-shadow 0.25s ease;
}

.navbar-premium.scrolled {
    background: rgba(11, 27, 43, 0.94);
    box-shadow: 0 8px 32px rgba(11, 27, 43, 0.35);
}

.navbar-premium .nav-link {
    position: relative;
    font-size: 0.9rem;
    letter-spacing: 0.01em;
    padding: 0.5rem 0.9rem;
    transition: color 0.2s ease;
}

.navbar-premium .nav-link::after {
    content: "";
    position: absolute;
    left: 0.9rem;
    right: 0.9rem;
    bottom: 0.15rem;
    height: 2px;
    background: var(--gold);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.25s var(--ease);
}

.navbar-premium .nav-link:hover::after,
.navbar-premium .nav-link.active::after {
    transform: scaleX(1);
}

/* ---------- Botones: jerarquía + estados físicos ---------- */
.btn {
    transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease),
                background-color 0.2s var(--ease), border-color 0.2s var(--ease),
                color 0.2s var(--ease);
}

.btn-gold {
    box-shadow: 0 10px 32px rgba(212, 168, 67, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn-gold:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 44px rgba(212, 168, 67, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn-gold:active,
.btn-outline:active {
    transform: scale(0.97);
}

.btn-outline:hover {
    transform: translateY(-1px);
}

/* ---------- Tarjetas: elevación tintada + lift ---------- */
.card-premium, .card-glass, .card-elevated, .step-card, .faq-item {
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.card-premium:hover, .card-elevated:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.card-glass {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
}

/* ---------- Section headers ---------- */
.section-header { text-align: left; }
.section-header .overline {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gold-dark);
}

.section-header p { margin-top: 0.25rem; }

/* ---------- FAQ ---------- */
.faq-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    background: var(--surface);
}

.faq-item.open {
    box-shadow: var(--shadow-sm);
    border-color: rgba(212, 168, 67, 0.4);
}

.faq-question {
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* ---------- Formularios ---------- */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(212, 168, 67, 0.18);
}

/* ---------- Tablas ---------- */
.table-premium th { letter-spacing: 0.06em; }
.table-premium td { font-variant-numeric: tabular-nums; }

/* ---------- Accesibilidad / navegación ---------- */
.skip-link {
    position: fixed;
    top: -100px;
    left: 16px;
    z-index: 10000;
    background: var(--gold);
    color: var(--navy);
    font-weight: 700;
    padding: 10px 18px;
    border-radius: 8px;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 16px;
}

/* ---------- Hero home: panel de datos premium ---------- */
.hero-card-data {
    border-radius: var(--radius-xl);
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
    backdrop-filter: blur(16px);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.hero-card-data .step-number {
    background: rgba(212, 168, 67, 0.16);
    color: var(--gold-light);
    border: 1px solid rgba(212, 168, 67, 0.35);
}

/* ---------- Skip js-ready animación más suave ---------- */
.js-ready .animate-on-scroll {
    transition: opacity 0.6s ease, transform 0.6s var(--ease);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===================================================================
   RONDA 2 — refinamientos compartidos de páginas públicas
   =================================================================== */

/* Badges: un solo acento (oro) — sobre navy transparente */
.hero .badge,
.hero .badge-primary,
.section-dark .badge-primary {
    background: rgba(212, 168, 67, 0.14);
    color: var(--gold-light);
    border: 1px solid rgba(212, 168, 67, 0.4);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-sm);
}

/* Badge sólido oro para secciones claras */
.badge-gold {
    background: var(--gold);
    color: var(--navy);
    font-weight: 700;
    border-radius: var(--radius-sm);
}

/* Stats: paleta navy/oro consistente */
.card-elevated .text-blue,
.card-elevated .text-green,
.card-elevated .text-purple,
.card-elevated .text-warning,
.stat-card .text-blue,
.stat-card .text-green,
.stat-card .text-purple {
    color: var(--navy) !important;
}

.card-elevated .text-gold,
.stat-card .text-gold {
    color: var(--gold-dark) !important;
}

/* Tarjetas de dashboard/charts */
.card-elevated > h3,
.card-elevated .heading-sm {
    letter-spacing: -0.015em;
}

.card-elevated {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

/* Avatar de equipo (nosotros) */
.team-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 0 auto var(--space-lg);
    border: 2px solid rgba(212, 168, 67, 0.5);
    box-shadow: var(--shadow-md), 0 0 0 6px rgba(212, 168, 67, 0.08);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
}

.team-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Enlaces dentro de cards */
.card-premium a, .card-elevated a {
    text-decoration: none;
}

/* Página nosotros: tarjetas de perfil */
.profile-card {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.profile-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

/* ===================================================================
   RONDA 3 — estados de carga, accesibilidad AA y responsive fino
   =================================================================== */

/* Skeleton shimmer (loading states) */
.skeleton {
    position: relative;
    overflow: hidden;
    background: var(--surface-3);
    border-radius: var(--radius-sm);
    color: transparent !important;
    user-select: none;
}

.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
    animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
    100% { transform: translateX(100%); }
}

.skeleton-row { height: 56px; margin-bottom: 10px; }
.skeleton-block { height: 240px; }

/* Solo-lectura para pantalla (accesibilidad) */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Tablas: captions legibles */
.table-premium caption {
    caption-side: top;
    text-align: left;
    padding: 0 0 0.5rem;
    color: var(--text-3);
    font-size: 0.8rem;
}

/* Formularios: estado inválido en línea */
.form-control.is-invalid,
.form-select.is-invalid,
.form-control[aria-invalid="true"] {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.form-error {
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* Toast/feedback */
.toast-premium { border-radius: var(--radius-md); }

/* Contraste AA: enlaces dentro de tarjetas claras */
.text-blue { color: var(--blue-dark) !important; }

/* Responsive fino: reduce display en pantallas chicas */
@media (max-width: 768px) {
    .display-xl { font-size: 2.25rem; letter-spacing: -0.03em; }
    .display-lg { font-size: 1.9rem; }
    .hero { padding: var(--space-2xl) 0; }
    body { padding-top: 64px; }
    .navbar-brand { font-size: 1.15rem; }
    .section { padding: var(--space-2xl) 0; }
    .table-premium td, .table-premium th { padding: 10px 12px; }
}

/* Botones icon-only: foco y tamaño táctil */
.btn-sm { min-height: 34px; }

@media (hover: none) {
    .btn, .nav-link, .chip, .faq-question { min-height: 44px; }
}

/* ===================================================================
   RONDA 4 — motion premium (reveal + stagger + hero entrance)
   =================================================================== */

/* Reveal con blur→nítido y easing suave */
.js-ready .animate-on-scroll {
    opacity: 0;
    transform: translateY(26px) scale(0.995);
    filter: blur(4px);
    transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1), filter 0.7s ease;
    will-change: opacity, transform, filter;
}

.js-ready .animate-on-scroll.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
}

/* Stagger: cascada sutil dentro de filas de cards */
.js-ready .row > .animate-on-scroll:nth-child(1) { transition-delay: 0.02s; }
.js-ready .row > .animate-on-scroll:nth-child(2) { transition-delay: 0.08s; }
.js-ready .row > .animate-on-scroll:nth-child(3) { transition-delay: 0.14s; }
.js-ready .row > .animate-on-scroll:nth-child(4) { transition-delay: 0.2s; }
.js-ready .row > .animate-on-scroll:nth-child(5) { transition-delay: 0.26s; }
.js-ready .row > .animate-on-scroll:nth-child(6) { transition-delay: 0.32s; }

/* Entrada del hero */
.js-ready .hero-content > * {
    opacity: 0;
    transform: translateY(16px);
    animation: heroIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.js-ready .hero-content > *:nth-child(1) { animation-delay: 0.05s; }
.js-ready .hero-content > *:nth-child(2) { animation-delay: 0.15s; }
.js-ready .hero-content > *:nth-child(3) { animation-delay: 0.25s; }
.js-ready .hero-content > *:nth-child(4) { animation-delay: 0.35s; }

@keyframes heroIn {
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .js-ready .animate-on-scroll,
    .js-ready .hero-content > * {
        opacity: 1 !important;
        transform: none !important;
        filter: none !important;
        animation: none !important;
        transition: none !important;
    }
}
