/* Sistema de diseño compartido. Claro, profesional y cercano; --brand y --accent los fija la marca blanca. */
@import url("fonts.css");
[hidden] { display: none !important; } /* el atributo hidden gana siempre a display:flex/grid de los componentes */
:root {
  --brand: #2B59F0;          /* azul amable (botones, enlaces, foco) */
  --accent: #FF7A59;         /* coral: toques divertidos, ilustraciones */
  --on-brand: #FFFFFF;       /* texto sobre --brand (contraste >= 4.5:1) */
  --bg: #F6F7FB;
  --bg-2: #EEF1F7;
  --surface: #FFFFFF;
  --surface-2: #F4F6FA;
  --surface-3: #E9EDF4;
  --line: rgba(15, 23, 42, .08);
  --line-strong: rgba(15, 23, 42, .16);
  --text: #0F172A;
  --text-2: #475569;   /* contraste >= 7:1 sobre blanco */
  --text-3: #5F6B7E;   /* contraste >= 4.5:1 sobre blanco y --bg */
  --ok: #0F8A4F;
  --warn: #B45309;
  --danger: #D92D4A;
  /* Texto de estado sobre fondos tintados (insignias, botones suaves): AA >= 4.5:1 también a 12 px */
  --ok-ink: #0B6B3D;
  --warn-ink: #8A3A06;
  --danger-ink: #A8182F;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow: 0 12px 32px -12px rgba(15, 23, 42, .18);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 2px 8px -4px rgba(15, 23, 42, .08);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, .22);
  --fs-body: 1rem;
  --lh-body: 1.6;
  --glow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent);
  --grad: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 55%, var(--accent)));
  --font: "Inter", "SF Pro Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --font-display: "Poppins", "Inter", "SF Pro Display", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  /* Escala de espaciado (4/8): usar en vez de valores sueltos */
  --s-1: .25rem; --s-2: .5rem; --s-3: .75rem; --s-4: 1rem; --s-5: 1.5rem; --s-6: 2rem; --s-7: 3rem; --s-8: 4.5rem;
  /* Escala tipográfica fluida */
  --fs-xs: .78rem; --fs-sm: .875rem; --fs-md: 1rem; --fs-lg: clamp(1.1rem, 1rem + .35vw, 1.25rem);
  --fs-xl: clamp(1.35rem, 1.1rem + .9vw, 1.75rem); --fs-2xl: clamp(1.75rem, 1.3rem + 1.8vw, 2.6rem);
  --ring: 0 0 0 3px #fff, 0 0 0 6px var(--brand); /* foco visible también sobre fondos de color */
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
img, video { max-width: 100%; display: block; }
/* Iconos SVG del set propio (js/icons.js) */
.icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: -.22em; }
a { color: var(--brand); }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.02em; font-weight: 600; text-wrap: balance; }
h1 { font-weight: 700; }
::selection { background: color-mix(in srgb, var(--brand) 22%, #fff); color: var(--text); }
p { text-wrap: pretty; }
a:hover { text-decoration-thickness: 2px; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; border-radius: 6px; }
/* Sobre fondos de marca (botón primario, chips de color) el anillo lleva halo blanco para no perderse */
.btn--primary:focus-visible, .badge--brand:focus-visible { outline: none; box-shadow: var(--ring); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 1rem; top: -100px; z-index: 1000; background: var(--brand); color: var(--on-brand); padding: .6rem 1rem; border-radius: var(--radius-sm); font-weight: 700; }
.skip-link:focus { top: 1rem; }

.text-grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.muted { color: var(--text-2); }
.small { font-size: .875rem; }

/* ---------- Botones ---------- */
.btn {
  --b: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: .6rem 1.1rem;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--b); color: var(--text);
  font: inherit; font-weight: 600; font-size: .95rem; text-decoration: none;
  cursor: pointer; transition: transform .15s var(--ease), background .2s, box-shadow .2s, border-color .2s;
}
.btn:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line-strong)); background: color-mix(in srgb, var(--b) 94%, var(--brand)); }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn .icon { width: 1.15em; height: 1.15em; vertical-align: 0; }
.btn--primary { background: var(--brand); border-color: transparent; color: var(--on-brand); box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--brand) 70%, transparent); }
.btn--primary:hover { background: color-mix(in srgb, var(--brand) 86%, #000); border-color: transparent; transform: translateY(-1px); }
.btn--lg { min-height: 54px; padding: .8rem 1.6rem; font-size: 1.05rem; }
.btn--block { width: 100%; }
.btn--ghost { background: transparent; }
.btn--danger { background: color-mix(in srgb, var(--danger) 8%, #fff); color: var(--danger-ink); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn--danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn--sm { min-height: 36px; padding: .35rem .8rem; font-size: .85rem; }
/* Pantallas táctiles: todo control tiene al menos 44 px (WCAG 2.5.8 pide 24; usamos 44 por comodidad) */
@media (pointer: coarse) { .btn--sm { min-height: 44px; } .btn--icon { min-width: 44px; } }
.btn--icon { width: 44px; padding: 0; }

/* ---------- Formularios ---------- */
.field { display: grid; gap: .35rem; margin-bottom: 1rem; }
.field > label, .label { font-size: .85rem; font-weight: 600; color: var(--text-2); }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: .6rem .85rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font: inherit;
}
.input::placeholder { color: var(--text-3); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input[readonly] { color: var(--text-2); }
/* Foco visible con contraste >= 3:1 (WCAG 2.4.11/1.4.11): contorno sólido del color de marca, como los interruptores. */
.input:focus { border-color: var(--brand); outline: 3px solid var(--brand); outline-offset: 1px; box-shadow: 0 0 0 5px #fff, 0 0 0 6px #0F172A; } /* + filo oscuro por si la marca es clara */
input[type="color"].input { padding: .25rem; height: 44px; width: 64px; }
input[type="range"] { accent-color: var(--brand); width: 100%; }
.hint { font-size: .8rem; color: var(--text-3); }

/* Interruptor accesible: <label class="switch"><input type="checkbox" role="switch"><span></span> Texto</label> */
.switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { width: 46px; height: 26px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--line-strong); position: relative; transition: background .2s; flex: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, .3); transition: transform .2s var(--ease); }
.switch input:checked + span { background: var(--brand); border-color: var(--brand); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid var(--brand); outline-offset: 2px; }

/* Selector de opciones en tarjeta (asistente) */
.choice-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.choice { position: relative; display: block; padding: 1rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); cursor: pointer; transition: border-color .2s, transform .2s var(--ease); }
.choice:hover { transform: translateY(-2px); }
.choice input { position: absolute; opacity: 0; }
.choice:has(input:checked) { border-color: var(--brand); box-shadow: var(--glow); }
.choice:has(input:focus-visible) { outline: 3px solid var(--brand); outline-offset: 2px; }

/* ---------- Superficies ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: clamp(1.1rem, .9rem + .6vw, 1.5rem); box-shadow: var(--shadow-sm); transition: box-shadow .25s var(--ease), border-color .25s; }
a.card:hover, .card--hover:hover { box-shadow: var(--shadow); border-color: var(--line-strong); }
.card--glass { background: var(--surface); }
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .6rem; border-radius: 99px; font-size: .75rem; font-weight: 700; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); }
.badge[hidden] { display: none; } /* .badge fija display: sin esto, el atributo hidden no ocultaría la etiqueta */
.badge--ok { color: var(--ok-ink); background: color-mix(in srgb, var(--ok) 10%, #fff); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.badge--warn { color: var(--warn-ink); background: color-mix(in srgb, var(--warn) 10%, #fff); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.badge--danger { color: var(--danger-ink); background: color-mix(in srgb, var(--danger) 9%, #fff); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.badge--brand { color: var(--on-brand); background: var(--brand); border-color: transparent; }
.dot { width: .55rem; height: .55rem; border-radius: 50%; background: currentColor; display: inline-block; }

.alert { display: grid; gap: .25rem; padding: .8rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); }
.alert--ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: color-mix(in srgb, var(--ok) 6%, #fff); }
.alert--warn { border-color: color-mix(in srgb, var(--warn) 55%, transparent); background: color-mix(in srgb, var(--warn) 7%, #fff); }
.alert--error { border-color: color-mix(in srgb, var(--danger) 60%, transparent); background: color-mix(in srgb, var(--danger) 6%, #fff); }

/* ---------- Toasts y modal ---------- */
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 2000; }
.toast { padding: .8rem 1.1rem; border-radius: var(--radius); background: var(--text); color: #fff; border: 1px solid var(--line-strong); box-shadow: var(--shadow); animation: toast-in .35s var(--ease); max-width: 360px; }
.toast--ok { border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
.toast--error { border-color: color-mix(in srgb, var(--danger) 60%, transparent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }

dialog.modal { padding: 0; border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); width: min(640px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); box-shadow: var(--shadow); }
dialog.modal::backdrop { background: rgba(15, 23, 42, .45); }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.modal__head h2 { margin: 0; font-size: 1.15rem; }
.modal__body { padding: 1.25rem; overflow: auto; }
.modal__foot { display: flex; justify-content: flex-end; gap: .5rem; padding: 1rem 1.25rem; border-top: 1px solid var(--line); }

/* ---------- Piezas (render de medios) ---------- */
.media { position: relative; width: 100%; height: 100%; overflow: hidden; background: #000; container-type: size; }
.media > img, .media > video { width: 100%; height: 100%; object-fit: cover; }
.media--logo { background: transparent; }
.media--missing { display: grid; place-items: center; color: #C8CCD8; font-size: .8rem; text-align: center; padding: 1rem; }

.media--demo { color: #fff; } /* el tema claro pone el texto del cuerpo oscuro; las piezas demo van sobre degradados oscuros */
.media--demo .demo__bg { position: absolute; inset: 0; background: radial-gradient(120% 80% at 20% 10%, var(--c2), transparent 60%), linear-gradient(160deg, var(--c1), #000 120%); }
.media--demo .demo__glow { position: absolute; width: 80cqmax; height: 80cqmax; left: 50%; top: 55%; translate: -50% -50%; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--c2) 55%, transparent), transparent 65%); filter: blur(4cqmin); opacity: .7; }
.media--demo .demo__content { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 3cqmin; padding: 8cqmin; }
.demo__emoji { font-size: 22cqmin; line-height: 1; filter: drop-shadow(0 2cqmin 4cqmin rgba(0, 0, 0, .5)); }
.demo__title { font-size: 11cqmin; font-weight: 900; letter-spacing: -.03em; line-height: 1; text-shadow: 0 1cqmin 4cqmin rgba(0, 0, 0, .45); }
.demo__subtitle { font-size: 4.6cqmin; font-weight: 600; color: rgba(255, 255, 255, .88); max-width: 90%; }
.demo__badge { position: absolute; top: 3cqmin; left: 3cqmin; font-size: 2.6cqmin; font-weight: 800; letter-spacing: .1em; padding: .8cqmin 2cqmin; border-radius: 99px; background: rgba(0, 0, 0, .45); color: #fff; }
.demo--promo .demo__content { justify-content: flex-end; padding-bottom: 16cqmin; }
.demo--promo .demo__title { font-size: 13cqmin; }
.demo--hero .demo__title { font-size: 15cqmin; text-transform: uppercase; }
.media--logo.media--demo .demo__bg { background: linear-gradient(135deg, var(--c1), var(--c2)); border-radius: 22%; inset: 6%; }
.media--logo.media--demo .demo__glow { display: none; }
.media--logo.media--demo .demo__content { gap: 2cqmin; }
.media--logo.media--demo .demo__emoji { font-size: 34cqmin; }
.media--logo.media--demo .demo__title { font-size: 15cqmin; }
.media--video-h.media--demo .demo__emoji { font-size: 18cqmin; }
.media--video-h.media--demo .demo__title { font-size: 12cqmin; }
.media--video-h.media--demo .demo__subtitle { font-size: 5cqmin; }

.media--logo.media--missing { color: var(--text-3); }

/* Hueco "pendiente de material": neutro (gris), marco discontinuo, sin marca inventada */
.media--placeholder { background: repeating-linear-gradient(135deg, #15151c 0 18px, #1b1b24 18px 36px); }
.media--placeholder .ph__frame { position: absolute; inset: 4cqmin; border: .6cqmin dashed rgba(255, 255, 255, .28); border-radius: 3cqmin; }
.media--placeholder .ph__content { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.5cqmin; text-align: center; padding: 10cqmin; color: #E6E6EE; }
.ph__name { font-size: 14cqmin; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.ph__kind { font-size: 4.2cqmin; color: #B9B9C8; font-weight: 600; }
.ph__pending { font-size: 3.6cqmin; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; padding: 1cqmin 3cqmin; border-radius: 99px; background: rgba(255, 197, 61, .14); color: #FFD36B; border: .3cqmin solid rgba(255, 197, 61, .45); }
.ph__note { font-size: 3.4cqmin; color: #A8A8B8; max-width: 85%; }
.media--placeholder.media--logo .ph__name { font-size: 20cqmin; }
.media--placeholder.media--video-h .ph__name { font-size: 11cqmin; }

/* "Vídeo" de demo: animación solo cuando se reproduce */
.media--play.demo--motion .demo__bg { animation: demo-pan 9s ease-in-out infinite alternate; background-size: 160% 160%; }
.media--play.demo--motion .demo__glow { animation: demo-orbit 6s ease-in-out infinite; }
.media--play.demo--motion .demo__emoji { animation: demo-float 3.2s ease-in-out infinite; }
.media--play .demo__title { animation: demo-rise .9s var(--ease) both .15s; }
.media--play .demo__subtitle { animation: demo-rise .9s var(--ease) both .35s; }
@keyframes demo-pan { to { background-position: 100% 100%; filter: hue-rotate(15deg); } }
@keyframes demo-orbit { 50% { translate: -30% -65%; scale: 1.2; } }
@keyframes demo-float { 50% { transform: translateY(-3cqmin) rotate(-4deg) scale(1.05); } }
@keyframes demo-rise { from { opacity: 0; transform: translateY(4cqmin); } }

/* ---------- Estado vacío genérico (paneles) ---------- */
.empty { display: grid; justify-items: center; gap: var(--s-3); padding: var(--s-7) var(--s-5); text-align: center; border: 1.5px dashed var(--line-strong); border-radius: var(--radius-lg); background: var(--surface); }
.empty__art { width: 112px; height: 112px; object-fit: contain; }
.empty h2, .empty h3 { margin: 0; font-size: var(--fs-xl); }
.empty p { margin: 0; max-width: 46ch; color: var(--text-2); }

/* ---------- Guía Hablito (mascota oficial de Hablo, solo en contenido de Hablo y en la guía de la demo) ---------- */
.hablito { display: grid; grid-template-columns: auto 1fr; gap: var(--s-4); align-items: center; padding: var(--s-4) var(--s-5); border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #FFF6E8, #FFFFFF 60%); border: 1px solid #FFD9A0; }
.hablito__img { width: 92px; height: 92px; object-fit: contain; filter: drop-shadow(0 10px 14px rgba(13, 59, 85, .18)); }
.hablito__txt { color: #0D3B55; }
.hablito__txt strong { font-family: "Poppins", var(--font); font-size: 1.05rem; }
.hablito__txt p { margin: .25rem 0 0; color: #23465C; }
@media (prefers-reduced-motion: no-preference) { .hablito__img { animation: hablito-float 4s ease-in-out infinite; } }
@keyframes hablito-float { 50% { transform: translateY(-6px) rotate(-2deg); } }

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

/* Vincular tótem por código (panel): dispositivo vinculado, aviso de «en uso» y asistente */
.vinc { margin: .5rem 0; }
.vinc .alert { margin: .5rem 0; display: grid; gap: .5rem; }
.vinc-form { display: grid; gap: 1rem; min-width: min(30rem, 100%); }
.vinc-form__code { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 1.75rem; letter-spacing: .12em; text-transform: uppercase; text-align: center; min-height: 3.5rem; }
.vinc-form .choice { display: flex; gap: .75rem; align-items: center; min-height: 3rem; margin: 0 0 .5rem; }
.vinc-form .choice input { width: 1.4rem; height: 1.4rem; flex: none; }
@media (prefers-reduced-motion: reduce) { .vinc-form .choice { transition: none; } .vinc-form .choice:hover { transform: none; } }

/* Vincular: la dirección que se pone en la pantalla del tótem (Fully → URL de inicio) */
.vinc-url__fila { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.vinc-url__dir { flex: 1 1 14rem; min-width: 0; overflow-wrap: anywhere; user-select: all; padding: .45rem .6rem; border-radius: 6px; background: var(--surface-2, rgba(127,127,127,.12)); font-size: .95rem; }
