/**
 * ============================================================================
 * HiBIT Colombia — Tema de marca (manual_hibit/hibit-tema.css)
 * ============================================================================
 * Basado en el Manual de identidad de marca y el Portafolio octubre V.2.
 *  - Paleta oficial: #250F54 · #0085FF · #0DC17A · #FFDE0A · #FD7B00 · #E30425
 *  - Tipografía oficial: Montserrat (Regular para textos, Bold para títulos)
 *  - Textura: papel cuadriculado de cuaderno
 *  - Dos temas: claro (por defecto) y oscuro (índigo, como la versión del
 *    logo sobre fondo oscuro). Se cambia con data-theme en <html>.
 * Se carga DESPUÉS de los CSS de cada página: aquí solo se redefinen las
 * variables y los detalles de marca; la estructura no cambia.
 * ============================================================================
 */

/* -------------------------------------------------------------------------
   1. Paleta y variables (tema claro)
   ------------------------------------------------------------------------- */
:root {
    color-scheme: light;

    /* Paleta oficial */
    --hb-indigo: #250F54;
    --hb-blue: #0085FF;
    --hb-green: #0DC17A;
    --hb-yellow: #FFDE0A;
    --hb-orange: #FD7B00;
    --hb-red: #E30425;
    /* Tonos de las piezas de marca */
    --hb-logo: #4B83FA;
    --hb-robot: #D6E9F0;
    --hb-lav: #C9C6F2;
    --hb-pink: #E9A4C9;

    /* Marca */
    --brand: #0085FF;
    --brand-400: #4B83FA;
    --brand-600: #0062C4;
    --brand-700: #0052A6;
    --brand-800: #250F54;
    --brand-ink: #0062C4;
    --brand-50: #EEF5FF;
    --brand-100: #DDEBFF;
    --brand-200: #B6D5FF;
    --brand-rgb: 0, 133, 255;

    /* Estados */
    --ok: #0DC17A;
    --ok-600: #0A9A61;
    --ok-700: #087A4D;
    --ok-ink: #087A4D;
    --ok-50: #E8F9F1;
    --ok-200: #A6EACF;
    --ok-rgb: 13, 193, 122;
    --warn: #FD7B00;
    --warn-700: #A85200;
    --warn-ink: #A85200;
    --warn-50: #FFF4E7;
    --warn-200: #FFD3A1;
    --warn-rgb: 253, 123, 0;
    --bad: #E30425;
    --bad-600: #C00320;
    --bad-700: #A8021C;
    --bad-ink: #B0021D;
    --bad-50: #FDECEF;
    --bad-200: #F7B3BE;
    --bad-rgb: 227, 4, 37;
    --violet: #6B4FD8;
    --violet-ink: #4A2FB0;
    --violet-50: #F1EFFD;
    --violet-200: #D8D2FA;
    --violet-rgb: 107, 79, 216;
    --pink: #D9579A;
    --gold: #FFDE0A;
    --gold-ink: #7A5F00;
    --gold-50: #FFF9D6;
    --gold-200: #FFEC85;
    --pink-50: #FCE9F3;
    --pink-ink: #9D174D;

    /* Superficies y texto */
    --bg: #F6F7FB;
    --surface: #FFFFFF;
    --surface-2: #F4F3FA;
    --surface-3: #ECEAF6;
    --line: #E5E2F0;
    --line-strong: #CFCAE2;
    --ink: #250F54;
    --ink-2: #3D2E6B;
    --muted: #5F5A7A;
    --faint: #9A95B3;
    --deep: #250F54;          /* paneles oscuros (héroes, botón oscuro) */
    --deep-2: #351B74;
    --on-deep: #FFFFFF;
    --glass: 255, 255, 255;   /* fondos translúcidos */
    --shade: 37, 15, 84;      /* sombras y velos */
    --ink-rgb: 37, 15, 84;
    --grid: rgba(37, 15, 84, 0.05);
    --grid-size: 26px;

    /* Tipografía oficial */
    --font-ui: 'Montserrat', -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Montserrat', -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-fun: 'Montserrat', -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Montserrat', ui-monospace, monospace;
    --font-script: 'Montserrat', cursive;

    --shadow-xs: 0 1px 2px rgba(var(--shade), 0.06);
    --shadow-sm: 0 2px 8px -2px rgba(var(--shade), 0.10), 0 1px 2px rgba(var(--shade), 0.05);
    --shadow-md: 0 14px 32px -14px rgba(var(--shade), 0.24), 0 2px 6px rgba(var(--shade), 0.05);
    --shadow-lg: 0 30px 60px -20px rgba(var(--shade), 0.32);

    /* Tema por defecto de los cursos (se sobreescribe por curso) */
    --c: #0085FF;
    --c-rgb: 0, 133, 255;
    --c-btn: #0062C4;
    --c-ink: #0062C4;
    --c-50: #EEF5FF;
    --c-100: #DDEBFF;
    --c-200: #B6D5FF;
    --c-300: #7DB8FF;
    --c-700: #0052A6;
    --c-900: #250F54;

    /* Inicio de sesión (inicio.css) */
    --brand-purple: #0085FF;
    --brand-purple-light: #4B83FA;
    --brand-purple-dark: #0062C4;
    --brand-purple-deep: #250F54;
    --brand-purple-glow: rgba(0, 133, 255, 0.36);
    --brand-purple-glow-soft: rgba(0, 133, 255, 0.14);
    --color-lime: #0DC17A;
    --color-yellow: #FFDE0A;
    --color-red: #E30425;
    --c-violet: #6B4FD8;
    --c-coral: #E9A4C9;
    --bg-deep: #F4F2FC;
    --bg-deep-2: #ECE9FA;
    --bg-deep-3: #DEDAF6;
    --glass-fill: rgba(255, 255, 255, 0.62);
    --glass-fill-strong: rgba(255, 255, 255, 0.84);
    --glass-border: rgba(37, 15, 84, 0.10);
    --glass-border-strong: rgba(0, 133, 255, 0.40);
    --glass-input-bg: rgba(255, 255, 255, 0.7);
    --glass-input-bg-hover: rgba(255, 255, 255, 0.86);
    --glass-input-bg-focus: rgba(255, 255, 255, 0.98);
    --c-surface: #FFFFFF;
    --c-bg-app: #F6F7FB;
    --c-border: #E5E2F0;
    --c-border-focus: #CFCAE2;
    --text-on-dark: #250F54;
    --text-on-dark-muted: rgba(37, 15, 84, 0.68);
    --text-on-dark-faint: rgba(37, 15, 84, 0.42);
    --text-main: #250F54;
    --text-muted: #5F5A7A;
    --shadow-glass: 0 30px 70px -18px rgba(37, 15, 84, 0.22), 0 0 0 1px rgba(255, 255, 255, 0.7) inset;
    --shadow-card-modal: 0 25px 50px -12px rgba(37, 15, 84, 0.18);
    --shadow-button: 0 12px 26px -8px rgba(0, 98, 196, 0.5);
    --shadow-button-hover: 0 18px 34px -8px rgba(0, 98, 196, 0.6);

    /* Acceso (acceso.css) */
    --blue: #0085FF;
    --navy: #250F54;
    --navy-2: #351B74;

    /* Alcancía del docente */
    --pig-line: #250F54;
    --pig-bg: #FFFFFF;
    --pig-empty: #ECEAF6;
}

/* -------------------------------------------------------------------------
   2. Tema oscuro (índigo de marca)
   ------------------------------------------------------------------------- */
:root[data-theme="dark"] {
    color-scheme: dark;

    --brand: #3D9BFF;
    --brand-400: #6FA8FF;
    --brand-600: #1677E8;
    --brand-700: #0F62C4;
    --brand-800: #C9D9FF;
    --brand-ink: #8CC2FF;
    --brand-50: rgba(61, 155, 255, 0.12);
    --brand-100: rgba(61, 155, 255, 0.20);
    --brand-200: rgba(61, 155, 255, 0.36);
    --brand-rgb: 61, 155, 255;

    --ok: #17D18A;
    --ok-600: #12B577;
    --ok-700: #6FE3B5;
    --ok-ink: #6FE3B5;
    --ok-50: rgba(13, 193, 122, 0.14);
    --ok-200: rgba(13, 193, 122, 0.36);
    --warn: #FF8A1F;
    --warn-700: #FFB46B;
    --warn-ink: #FFB46B;
    --warn-50: rgba(253, 123, 0, 0.14);
    --warn-200: rgba(253, 123, 0, 0.38);
    --bad: #FF3D5A;
    --bad-600: #E8213F;
    --bad-700: #FF8A9C;
    --bad-ink: #FF8A9C;
    --bad-50: rgba(227, 4, 37, 0.16);
    --bad-200: rgba(255, 61, 90, 0.40);
    --violet: #9C86FF;
    --violet-ink: #BDAEFF;
    --violet-50: rgba(156, 134, 255, 0.14);
    --violet-200: rgba(156, 134, 255, 0.36);
    --gold-ink: #FFE45C;
    --gold-50: rgba(255, 222, 10, 0.12);
    --gold-200: rgba(255, 222, 10, 0.36);
    --pink-50: rgba(233, 164, 201, 0.16);
    --pink-ink: #F3B7D6;

    --bg: #120830;
    --surface: #1C0F45;
    --surface-2: #251656;
    --surface-3: #2E1D66;
    --line: #34256C;
    --line-strong: #4B3B8A;
    --ink: #F3F1FF;
    --ink-2: #DCD7F5;
    --muted: #B3ACD3;
    --faint: #8780AE;
    --deep: #0B0524;
    --deep-2: #1A0D45;
    --glass: 28, 15, 69;
    --shade: 0, 0, 0;
    --ink-rgb: 243, 241, 255;
    --grid: rgba(255, 255, 255, 0.045);

    --c-btn: #1677E8;
    --c-ink: #8CC2FF;

    --bg-deep: #120830;
    --bg-deep-2: #170B3B;
    --bg-deep-3: #1E0F47;
    --glass-fill: rgba(28, 15, 69, 0.66);
    --glass-fill-strong: rgba(28, 15, 69, 0.88);
    --glass-border: rgba(255, 255, 255, 0.10);
    --glass-border-strong: rgba(61, 155, 255, 0.5);
    --glass-input-bg: rgba(18, 8, 48, 0.6);
    --glass-input-bg-hover: rgba(18, 8, 48, 0.8);
    --glass-input-bg-focus: rgba(18, 8, 48, 0.95);
    --c-surface: #1C0F45;
    --c-bg-app: #120830;
    --c-border: #34256C;
    --c-border-focus: #4B3B8A;
    --text-on-dark: #F3F1FF;
    --text-on-dark-muted: rgba(243, 241, 255, 0.72);
    --text-on-dark-faint: rgba(243, 241, 255, 0.45);
    --text-main: #F3F1FF;
    --text-muted: #B3ACD3;
    --shadow-glass: 0 30px 70px -18px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
    --shadow-card-modal: 0 25px 50px -12px rgba(0, 0, 0, 0.6);

    --navy: #0B0524;
    --navy-2: #1A0D45;
    --pig-line: #F3F1FF;
    --pig-bg: #1C0F45;
    --pig-empty: #2E1D66;
}

/* -------------------------------------------------------------------------
   3. Base: tipografía y papel cuadriculado
   ------------------------------------------------------------------------- */
html { background-color: var(--bg); }
body {
    font-family: var(--font-ui);
    font-variant-numeric: tabular-nums;
    background-image:
        linear-gradient(var(--grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid) 1px, transparent 1px);
    background-size: var(--grid-size) var(--grid-size);
    background-attachment: fixed;
}
.portal .ambient { background-color: transparent; }
::selection { background: var(--hb-blue); color: #fff; }
:focus-visible { outline-color: rgba(var(--brand-rgb), 0.6); }

/* Barra de desplazamiento discreta en oscuro */
:root[data-theme="dark"] ::-webkit-scrollbar { width: 11px; height: 11px; }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #3A2A78; border-radius: 99px; border: 3px solid var(--bg); }
:root[data-theme="dark"] ::-webkit-scrollbar-track { background: transparent; }

/* Transición suave al cambiar de tema */
html.hb-theme-anim, html.hb-theme-anim *, html.hb-theme-anim *::before, html.hb-theme-anim *::after {
    transition: background-color .35s ease, border-color .35s ease, color .35s ease, fill .35s ease !important;
}

/* -------------------------------------------------------------------------
   4. Logo oficial (claro / oscuro) y «LEDs» convertidos en bloques BIT
   ------------------------------------------------------------------------- */
.brand-logo { mix-blend-mode: normal !important; height: 44px; }
.brand-leds { gap: 4px !important; }
.brand-leds i { border-radius: 2px !important; box-shadow: none !important; width: 7px !important; height: 7px !important; }
.brand-leds i:nth-child(1) { background: var(--hb-green) !important; }
.brand-leds i:nth-child(2) { background: var(--hb-yellow) !important; }
.brand-leds i:nth-child(3) { background: var(--hb-red) !important; }

/* -------------------------------------------------------------------------
   5. Selector de tema (botón que agrega hibit-tema.js)
   ------------------------------------------------------------------------- */
.hb-theme {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    box-shadow: var(--shadow-xs);
    overflow: hidden;
    transition: transform .25s var(--spring, ease), border-color .2s;
}
.hb-theme:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.hb-theme svg { position: absolute; transition: transform .5s cubic-bezier(.34,1.56,.64,1), opacity .3s; }
.hb-theme .hb-sun { color: #F2A900; }
.hb-theme .hb-moon { color: var(--hb-lav); transform: translateY(26px) rotate(-40deg); opacity: 0; }
:root[data-theme="dark"] .hb-theme .hb-sun { transform: translateY(-26px) rotate(40deg); opacity: 0; }
:root[data-theme="dark"] .hb-theme .hb-moon { transform: none; opacity: 1; }
.hb-theme--float {
    position: fixed;
    top: max(14px, env(safe-area-inset-top, 0px));
    right: max(14px, env(safe-area-inset-right, 0px));
    z-index: 60;
    background: rgba(var(--glass), 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.hb-theme-menu {
    position: fixed;
    z-index: 10050;
    min-width: 200px;
    padding: 6px;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    animation: hbPop .22s cubic-bezier(.34,1.56,.64,1);
}
.hb-theme-menu button {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 10px 12px; border: 0; border-radius: 11px; background: none;
    font: 600 14px var(--font-ui); color: var(--ink); cursor: pointer; text-align: left;
}
.hb-theme-menu button:hover { background: var(--surface-2); }
.hb-theme-menu button[aria-checked="true"] { background: var(--brand-50); color: var(--brand-ink); }
.hb-theme-menu button[aria-checked="true"]::after { content: '✓'; margin-left: auto; font-weight: 800; }
@keyframes hbPop { from { transform: scale(.9) translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* -------------------------------------------------------------------------
   6. Elementos de marca reutilizables
   ------------------------------------------------------------------------- */
/* Cargador con bloques BIT */
.hb-loader { display: grid; grid-template-columns: repeat(3, 14px); gap: 4px; }
.hb-loader i { width: 14px; height: 14px; border-radius: 3px; position: relative; animation: hbBit 1.2s ease-in-out infinite; }
.hb-loader i::after { content: ''; position: absolute; inset: 4.5px; background: #fff; border-radius: 1px; }
.hb-loader i:nth-child(1) { background: var(--hb-red); }
.hb-loader i:nth-child(2) { background: var(--hb-orange); animation-delay: .1s; }
.hb-loader i:nth-child(3) { background: var(--hb-green); animation-delay: .2s; }
.hb-loader i:nth-child(4) { background: var(--hb-indigo); animation-delay: .3s; }
.hb-loader i:nth-child(5) { background: var(--hb-yellow); animation-delay: .4s; }
.hb-loader i:nth-child(6) { background: var(--hb-blue); animation-delay: .5s; }
:root[data-theme="dark"] .hb-loader i:nth-child(4) { background: #fff; }
:root[data-theme="dark"] .hb-loader i:nth-child(4)::after { background: var(--hb-indigo); }
@keyframes hbBit { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-8px); } }

/* Subrayado de pincel para títulos */
.hb-brush { position: relative; display: inline-block; }
.hb-brush::after {
    content: ''; position: absolute; left: -4px; right: -4px; bottom: -8px; height: 12px;
    background: url('elementos/wave.webp') center / 100% 100% no-repeat; opacity: .85; pointer-events: none;
}

/* Elementos de pincel flotantes (decoración) */
.hb-deco { position: absolute; pointer-events: none; user-select: none; animation: hbFloat 7s ease-in-out infinite; opacity: .9; }
@keyframes hbFloat { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-12px) rotate(6deg); } }

/* Botón amarillo de marca (para los niños) */
.btn--hb-yellow { background: var(--hb-yellow) !important; color: #250F54 !important; box-shadow: 0 10px 20px -10px rgba(201, 168, 0, 0.9) !important; }

@media (prefers-reduced-motion: reduce) {
    .hb-deco, .hb-loader i { animation: none !important; }
}

/* -------------------------------------------------------------------------
   7. Impresión: siempre en claro
   ------------------------------------------------------------------------- */
@media print {
    body { background-image: none !important; }
    .hb-theme, .hb-theme-menu { display: none !important; }
}
