/* ============================================
   THEME - TOKENS GLOBALES DEL SISTEMA DE DISEÑO
   Fuente de verdad: CLAUDE.md
   Se carga antes que maestra.css y que el CSS de cada página.
   Todas las hojas usan estos tokens; ninguna redefine colores base.
   ============================================ */

:root {
    /* ---------- Tipografía (fuentes del sistema) ---------- */
    --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "SF Pro Display", sans-serif;
    --font-weight-regular: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --tracking-tight: -0.01em;
    --tracking-heading: -0.02em;
    --tracking-display: -0.025em;

    /* Escala tipográfica (Apple / Linear): fina, con jerarquía por peso
       y tamaño. Los títulos son fluidos: no necesitan media queries. */
    --text-xs: 0.75rem;      /* 12px: badges, etiquetas */
    --text-sm: 0.875rem;     /* 14px: metadatos, botones pequeños */
    --text-base: 1rem;       /* 16px: cuerpo */
    --text-lg: 1.125rem;     /* 18px: entradillas */
    --text-xl: 1.25rem;      /* 20px: títulos de tarjeta */
    --text-2xl: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);       /* h3 / subtítulos */
    --text-3xl: clamp(1.5rem, 1.25rem + 1vw, 2rem);           /* h2 de sección */
    --text-4xl: clamp(1.875rem, 1.35rem + 2.2vw, 2.75rem);    /* h1 de hero */
    --leading-tight: 1.15;
    --leading-snug: 1.3;
    --leading-body: 1.6;

    /* ---------- Espaciado (grid de 8px) ---------- */
    --space-half: 4px;     /* medio paso: solo gaps de íconos y badges */
    --space-1: 8px;
    --space-2: 16px;
    --space-3: 24px;
    --space-4: 32px;
    --space-6: 48px;
    --space-8: 64px;

    /* ---------- Layout ---------- */
    --navbar-height: 75px;

    /* ---------- Radios ---------- */
    --radius-sm: 8px;      /* botones, inputs, chips */
    --radius-md: 12px;     /* dropdowns, cards */
    --radius-lg: 16px;     /* modales, cards grandes */
    --radius-pill: 999px;

    /* ---------- Movimiento (Emil Kowalski) ---------- */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --duration-fast: 150ms;
    --duration-base: 200ms;
    --duration-slow: 250ms;
    --duration-reveal: 640ms;  /* entradas por scroll: más largas que un microgesto */
    --reveal-shift: 12px;      /* recorrido de la entrada por scroll (0 con movimiento reducido) */
    --duration-title: 350ms;   /* títulos: fade + subida */
    --duration-underline: 450ms;  /* barra de acento bajo el título: crece de izquierda a derecha */
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);  /* rebote corto al soltar un botón */
    --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);    /* salidas rápidas (cierre de modales) */
    --hover-lift: -2px;    /* transform: translateY(var(--hover-lift)) */
    --press-scale: 0.98;   /* transform: scale(var(--press-scale)) */
    --transition-interactive:
        transform var(--duration-base) var(--ease-out),
        background-color var(--duration-fast) var(--ease-out),
        border-color var(--duration-fast) var(--ease-out),
        color var(--duration-fast) var(--ease-out),
        box-shadow var(--duration-base) var(--ease-out),
        opacity var(--duration-fast) var(--ease-out);

    /* ---------- Vidrio ---------- */
    --blur-glass: 12px;

    /* ---------- Neutros ---------- */
    --gray-0: #ffffff;
    --gray-50: #fafafa;
    --gray-100: #f4f4f5;
    --gray-500: #666666;
    --gray-900: #111111;
    --gray-1000: #000000;

    /* ---------- Superficies sobre imágenes (iguales en ambos temas) ---------- */
    --scrim-soft: rgba(0, 0, 0, 0.16);
    --scrim: rgba(0, 0, 0, 0.32);
    --scrim-strong: rgba(0, 0, 0, 0.48);
    --scrim-gradient: linear-gradient(to top, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.24) 56%, rgba(0, 0, 0, 0) 100%);
    --border-on-media: rgba(255, 255, 255, 0.16);
    --text-on-media: #ffffff;
    --text-on-media-muted: rgba(255, 255, 255, 0.8);
    --dot-on-media: rgba(255, 255, 255, 0.48);
    --dot-on-media-hover: rgba(255, 255, 255, 0.8);

    /* ---------- Tema claro: chrome (navbar, dropdowns) ---------- */
    --surface: var(--gray-0);
    --surface-glass: rgba(255, 255, 255, 0.72);
    --surface-overlay: rgba(255, 255, 255, 0.9);

    /* ---------- Tema claro: contenido de página ---------- */
    --page-bg: var(--gray-50);
    --surface-card: var(--gray-0);
    --surface-muted: var(--gray-100);
    --surface-inverse: var(--gray-900);
    --text-strong: var(--gray-900);
    --text-muted: var(--gray-500);
    --text-inverse: var(--gray-0);
    --border-subtle: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.16);
    --state-hover: rgba(0, 0, 0, 0.04);
    --state-press: rgba(0, 0, 0, 0.08);

    /* Alias con los nombres habituales (apuntan a los tokens de arriba,
       así cambian solos con el tema) */
    --bg-primary: var(--page-bg);
    --bg-secondary: var(--surface-muted);
    --text-primary: var(--text-strong);
    --text-secondary: var(--text-muted);

    /* Texto sobre badges de color (categorías y estados) */
    --badge-ink: var(--gray-0);

    /* ---------- Sombras ---------- */
    --shadow-sm: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 16px 32px -8px rgba(0, 0, 0, 0.12);

    /* ---------- Acento único por tema: amarillo Dis-Oil ---------- */
    --accent: #FFA901;
    --accent-hover: #F5A200;
    --accent-ink: var(--gray-900);   /* texto sobre el acento */
    --accent-soft: rgba(255, 169, 1, 0.14);
    --accent-glow: rgba(255, 169, 1, 0.4);
    --focus-ring: rgba(255, 169, 1, 0.6);

    /* ---------- Marca y estados (no son acentos de interfaz) ---------- */
    --brand-blue: #0066B3;
    --brand-red: #ED1B2D;
    --success: #28A745;
    --success-soft: rgba(40, 167, 69, 0.12);
    --danger: #DC3545;
    --danger-soft: rgba(220, 53, 69, 0.12);
    --warning: #F39C12;
    --warning-soft: rgba(243, 156, 18, 0.14);

    /* ---------- Alias de compatibilidad ----------
       El JS (maestra.js, novedades.js) genera estilos inline con estos
       nombres. No usarlos en CSS nuevo. */
    --color-shadow: rgba(0, 0, 0, 0.05);
    --color-shadow-hover: rgba(0, 0, 0, 0.08);
    --color-text-light: var(--text-muted);
    --color-dark: var(--text-strong);
}

@media (max-width: 768px) {
    :root {
        --navbar-height: 65px;
    }
}

/* ---------- Tema oscuro ----------
   Contraste medido (WCAG):
     texto principal #FFFFFF → 14.6–19.2 : 1 sobre todas las superficies
     texto secundario #94A3B8 → 5.7–7.5 : 1 (AA ≥ 4.5 en todas)
     blanco sobre el acento   → 4.98 : 1 (hover 5.62 : 1)
     tinta oscura sobre badges de categoría/estado → 4.9–9.1 : 1 */
[data-theme="dark"] {
    /* Chrome (navbar, dropdowns, footer): un paso sobre el fondo */
    --surface: #0F1521;
    --surface-glass: rgba(15, 21, 33, 0.72);
    --surface-overlay: rgba(22, 31, 48, 0.94);

    /* Contenido: fondo profundo y tarjetas con elevación visible */
    --page-bg: #0B0F17;
    --surface-card: #161F30;
    --surface-muted: #1E293B;
    --surface-inverse: var(--gray-0);
    --text-strong: #FFFFFF;
    --text-muted: #94A3B8;
    --text-inverse: var(--gray-900);
    --border-subtle: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.24);
    --state-hover: rgba(255, 255, 255, 0.06);
    --state-press: rgba(255, 255, 255, 0.1);

    /* Sobre fondos tan oscuros la sombra casi no se ve: delimitan los bordes */
    --shadow-sm: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.6);

    /* Acento único por tema: rojo Dis-Oil (texto blanco encima: 4.98 : 1) */
    --accent: #D32F2F;
    --accent-hover: #C62828;
    --accent-ink: #FFFFFF;
    --accent-soft: rgba(211, 47, 47, 0.2);
    --accent-glow: rgba(211, 47, 47, 0.45);
    --focus-ring: rgba(255, 255, 255, 0.7);

    /* Los colores de categoría/estado del tema oscuro son claros:
       el texto encima va oscuro */
    --badge-ink: #0B0F17;

    --brand-blue: #4A8ECF;
    --brand-red: #E42423;
    --success: #2ECC71;
    --success-soft: rgba(46, 204, 113, 0.16);
    --danger: #E74C3C;
    --danger-soft: rgba(231, 76, 60, 0.18);
    --warning: #F39C12;
    --warning-soft: rgba(243, 156, 18, 0.18);

    --color-shadow: rgba(0, 0, 0, 0.4);
    --color-shadow-hover: rgba(0, 0, 0, 0.5);
}
