/*
 * Mascota de Dewi. Colores oficiales como respaldo: el host solo los cambia con
 * tokens --dewi-* (nunca recolorea piezas sueltas).
 *   --dewi-avatar-shell  carcasa       #002C69 (azul marino DWC)
 *   --dewi-avatar-rim    bordes, manos #0097D3 (celeste DWC)
 *   --dewi-avatar-visor  visor         #002C69
 *   --dewi-avatar-light  luces, marca  #FFFFFF
 *   --dewi-avatar-face   ojos y boca   #FFFFFF
 *   --dewi-avatar-shadow sombras       #06152C (tinta)
 *   --dewi-danger        baliza error  #C83E4D
 * --dewi-accent y --dewi-accent-2 sirven de atajo para carcasa y bordes.
 */
dewi-mascot {
  display: inline-block;
  width: var(--dewi-size, 160px);
  aspect-ratio: 1;
  vertical-align: middle;
}

/* Contenido de respaldo (sin JavaScript): se reemplaza por el SVG al conectarse. */
dewi-mascot > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.dewi-mascot {
  --_shell: var(--dewi-avatar-shell, var(--dewi-accent, #002c69));
  --_mint: var(--dewi-avatar-rim, var(--dewi-accent-2, #0097d3));
  --_ink: var(--dewi-avatar-visor, #002c69);
  --_light: var(--dewi-avatar-light, #ffffff);
  --_face: var(--dewi-avatar-face, var(--_light));
  --_shadow: var(--dewi-avatar-shadow, #06152c);
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.dewi-mascot__shell, .dewi-mascot__body, .dewi-mascot__joint { stroke: color-mix(in srgb, var(--_mint) 55%, var(--_shell)); stroke-width: 1.2; }
.dewi-mascot__joint { fill: color-mix(in srgb, var(--_shell) 65%, var(--_ink)); }
.dewi-material__pearl { stop-color: color-mix(in srgb, var(--_light) 75%, var(--_mint)); }
.dewi-material__sky { stop-color: color-mix(in srgb, var(--_light) 32%, var(--_mint)); }
.dewi-material__blue { stop-color: color-mix(in srgb, var(--_mint) 80%, var(--_shell)); }
.dewi-material__cyan { stop-color: var(--_mint); }
.dewi-material__navy { stop-color: var(--_shell); }
.dewi-material__deep { stop-color: color-mix(in srgb, var(--_shell) 80%, var(--_mint)); }
.dewi-material__night { stop-color: var(--_shadow); }
.dewi-material__white { stop-color: var(--_light); }
.dewi-mascot__head-shade { fill: var(--_shell); opacity: 0.3; }
.dewi-mascot__neck-shadow { fill: var(--_shell); opacity: 0.5; }
.dewi-mascot__body-glint { fill: var(--_light); opacity: 0.25; }
.dewi-mascot__edge-light, .dewi-mascot__glass-edge { fill: none; stroke: var(--_light); stroke-width: 2; stroke-linecap: round; opacity: 0.5; }
.dewi-mascot__glass-edge { opacity: 0.16; }
.dewi-mascot__bolt { fill: var(--_shell); opacity: 0.55; }
.dewi-mascot__chest { fill: var(--_shell); opacity: 0.65; }
.dewi-mascot__seam { fill: none; stroke: var(--_shell); stroke-width: 2; opacity: 0.3; }
.dewi-mascot__beacon { fill: color-mix(in srgb, var(--_mint) 50%, var(--_light)); }
.dewi-mascot__outline { stroke: color-mix(in srgb, var(--_mint) 70%, var(--_shell)); stroke-width: 1; }
.dewi-mascot__tablet-screen { fill: var(--_ink); }
.dewi-mascot__led { fill: var(--_mint); }
.dewi-mascot__eye, .dewi-mascot__mouth { fill: color-mix(in srgb, var(--_face) 85%, var(--_mint)); }
.dewi-mascot__cheek { fill: var(--_mint); opacity: 0.4; }
.dewi-mascot__mark, .dewi-mascot__trim, .dewi-mascot__smile, .dewi-mascot__concern, .dewi-mascot__brows, .dewi-mascot__expression-line, .dewi-mascot__ponder {
  fill: none;
  stroke: color-mix(in srgb, var(--_face) 85%, var(--_mint));
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.dewi-mascot__trim { stroke: var(--_mint); stroke-width: 4; }
.dewi-mascot__mark { stroke: var(--_light); stroke-width: 2.4; }
.dewi-mascot__tablet-name { fill: var(--_light); }
.dewi-mascot__brand-ink { flood-color: var(--_light); }
.dewi-mascot__brand-pearl-mid { stop-color: color-mix(in srgb, var(--_light) 88%, var(--_mint)); }
.dewi-mascot__brand-pearl-shade { stop-color: color-mix(in srgb, var(--_light) 58%, var(--_mint)); }
.dewi-mascot__brand-shadow { flood-color: var(--_shadow); }
.dewi-mascot__brand-bevel { flood-color: color-mix(in srgb, var(--_mint) 60%, var(--_ink)); }
.dewi-mascot__character { animation: dewi-mascot-float 4s ease-in-out infinite; }
.dewi-mascot__head { transform-origin: 120px 144px; transition: transform 420ms cubic-bezier(0.22, 1, 0.36, 1); }
.dewi-mascot__gaze, .dewi-mascot__torso { transition: transform 420ms cubic-bezier(0.22, 1, 0.36, 1); }
.dewi-mascot__blink { transform-origin: 120px 100px; animation: dewi-mascot-blink 6s infinite; }
.dewi-mascot__eyes { transition: opacity 180ms ease; }
.dewi-mascot__eyes:not(.dewi-mascot__eyes--open) { opacity: 0; }
.dewi-mascot__arm { transition: transform 220ms ease; }
.dewi-mascot__arm--left { transform-origin: 91px 167px; }
.dewi-mascot__arm--right { transform-origin: 149px 167px; }
.dewi-mascot__mouth { display: none; transform-origin: 120px 119px; transform: scaleY(var(--dewi-mouth, 0.08)); }
.dewi-mascot__concern, .dewi-mascot__brows, .dewi-mascot__ponder, .dewi-mascot__attention-brows { display: none; }
.dewi-mascot__pose, .dewi-mascot__seated-legs, .dewi-mascot__thought-bubbles, .dewi-mascot__sound-waves, .dewi-mascot__sleep { opacity: 0; transition: opacity 180ms ease; }
.dewi-mascot__neutral-arms, .dewi-mascot__standing-legs { transition: opacity 180ms ease; }
.dewi-mascot__thought-bubbles { fill: var(--_mint); }
.dewi-mascot__bubble { fill: var(--_shell); }
.dewi-mascot__thinking-dots { fill: var(--_light); }
.dewi-mascot__sound-waves, .dewi-mascot__sleep { fill: none; stroke: var(--_mint); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.dewi-mascot__tablet { transform-origin: 135px 181px; }

.dewi-mascot[data-state="conectando"] .dewi-mascot__arm--right { animation: dewi-mascot-wave 1.2s ease-in-out 2; }
.dewi-mascot[data-state="conectando"] .dewi-mascot__beacon { animation: dewi-mascot-pulse 1s ease-in-out infinite; }
.dewi-mascot[data-state="conectando"] .dewi-mascot__eyes--open { opacity: 0; }
.dewi-mascot[data-state="conectando"] .dewi-mascot__eyes--happy { opacity: 1; }

.dewi-mascot:is([data-state="inactivo"], [data-state="pensando"], [data-state="en_pausa"]) .dewi-mascot__standing-legs,
.dewi-mascot:is([data-state="inactivo"], [data-state="pensando"], [data-state="en_pausa"], [data-state="escuchando"]) .dewi-mascot__neutral-arms { opacity: 0; }
.dewi-mascot:is([data-state="inactivo"], [data-state="pensando"], [data-state="en_pausa"]) .dewi-mascot__seated-legs { opacity: 1; }
.dewi-mascot:is([data-state="inactivo"], [data-state="pensando"], [data-state="en_pausa"]) .dewi-mascot__torso { transform: translateY(8px); }
.dewi-mascot:is([data-state="inactivo"], [data-state="en_pausa"]) .dewi-mascot__pose--rest { opacity: 1; }
.dewi-mascot[data-state="inactivo"] .dewi-mascot__head { transform: translateY(8px) rotate(-3deg); }
.dewi-mascot[data-state="inactivo"] .dewi-mascot__gaze { animation: dewi-mascot-read 9s ease-in-out infinite; }
.dewi-mascot[data-state="inactivo"] .dewi-mascot__eyes--open { opacity: 0; }
.dewi-mascot[data-state="inactivo"] .dewi-mascot__eyes--happy { opacity: 1; }

.dewi-mascot[data-state="escuchando"] .dewi-mascot__pose--listening { opacity: 1; }
.dewi-mascot[data-state="escuchando"] .dewi-mascot__head { transform: translate(-4px, 2px) rotate(9deg); }
.dewi-mascot[data-state="escuchando"] .dewi-mascot__eyes--open { opacity: 0; }
.dewi-mascot[data-state="escuchando"] .dewi-mascot__eyes--attentive { opacity: 1; }
.dewi-mascot[data-state="escuchando"] .dewi-mascot__attention-brows { display: block; }
.dewi-mascot[data-state="escuchando"] .dewi-mascot__sound-waves { opacity: 1; }
.dewi-mascot[data-state="escuchando"] .dewi-mascot__sound-waves path { animation: dewi-mascot-hear 1.8s ease-out infinite; }
.dewi-mascot[data-state="escuchando"] .dewi-mascot__sound-waves path:nth-child(2) { animation-delay: 0.35s; }
.dewi-mascot[data-state="escuchando"] .dewi-mascot__smile { transform: translateY(2px) scaleX(0.6); transform-origin: 120px 120px; }

.dewi-mascot[data-state="pensando"] .dewi-mascot__pose--thinking { opacity: 1; }
.dewi-mascot[data-state="pensando"] .dewi-mascot__thought-bubbles { opacity: 1; }
.dewi-mascot[data-state="pensando"] .dewi-mascot__gaze { transform: translate(4px, -2px); }
.dewi-mascot[data-state="pensando"] .dewi-mascot__head { transform: translateY(6px) rotate(-7deg); }
.dewi-mascot[data-state="pensando"] .dewi-mascot__eyes--open { opacity: 0; }
.dewi-mascot[data-state="pensando"] .dewi-mascot__eyes--thoughtful { opacity: 1; }
.dewi-mascot[data-state="pensando"] .dewi-mascot__smile { display: none; }
.dewi-mascot[data-state="pensando"] .dewi-mascot__ponder { display: block; }
.dewi-mascot[data-state="pensando"] .dewi-mascot__thinking-dots circle { animation: dewi-mascot-pulse 1.3s ease-in-out infinite; }
.dewi-mascot__thinking-dots circle:nth-child(2) { animation-delay: 0.2s; }
.dewi-mascot__thinking-dots circle:nth-child(3) { animation-delay: 0.4s; }

.dewi-mascot[data-state="hablando"] .dewi-mascot__smile { display: none; }
.dewi-mascot[data-state="hablando"] .dewi-mascot__mouth { display: block; }
.dewi-mascot[data-state="hablando"] .dewi-mascot__head { animation: dewi-mascot-nod 4s ease-in-out infinite; }
.dewi-mascot[data-state="hablando"] .dewi-mascot__arm--left { animation: dewi-mascot-present 3.2s ease-in-out infinite; }
.dewi-mascot[data-state="hablando"] .dewi-mascot__arm--right { animation: dewi-mascot-present 3.8s ease-in-out infinite reverse; }
.dewi-mascot[data-state="en_pausa"] .dewi-mascot__character,
.dewi-mascot[data-state="error"] .dewi-mascot__character { animation: none; }
.dewi-mascot[data-state="en_pausa"] .dewi-mascot__head { transform: translateY(12px) rotate(8deg); }
.dewi-mascot[data-state="en_pausa"] .dewi-mascot__blink { animation: none; }
.dewi-mascot[data-state="en_pausa"] .dewi-mascot__eyes--open { opacity: 0; }
.dewi-mascot[data-state="en_pausa"] .dewi-mascot__eyes--closed { opacity: 1; }
.dewi-mascot[data-state="en_pausa"] .dewi-mascot__beacon { opacity: 0.4; }
.dewi-mascot[data-state="en_pausa"] .dewi-mascot__sleep { opacity: 1; animation: dewi-mascot-sleep 3s ease-in-out infinite; }
.dewi-mascot[data-state="error"] .dewi-mascot__head { transform: translateY(5px) rotate(-8deg); }
.dewi-mascot[data-state="error"] .dewi-mascot__arm--left { transform: rotate(-15deg); }
.dewi-mascot[data-state="error"] .dewi-mascot__arm--right { transform: rotate(15deg); }
.dewi-mascot[data-state="error"] .dewi-mascot__smile { display: none; }
.dewi-mascot[data-state="error"] .dewi-mascot__concern,
.dewi-mascot[data-state="error"] .dewi-mascot__brows { display: block; }
.dewi-mascot[data-state="error"] .dewi-mascot__cheek { opacity: 0.15; }
.dewi-mascot[data-state="error"] .dewi-mascot__beacon { fill: var(--dewi-danger, #c83e4d); }

@keyframes dewi-mascot-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes dewi-mascot-blink { 0%, 42%, 46%, 100% { transform: scaleY(1); } 44% { transform: scaleY(0.1); } }
@keyframes dewi-mascot-wave { 0%, 100% { transform: rotate(0); } 35%, 70% { transform: rotate(-105deg); } 50% { transform: rotate(-80deg); } }
@keyframes dewi-mascot-present { 0%, 100% { transform: rotate(0); } 35%, 55% { transform: rotate(32deg); } }
@keyframes dewi-mascot-nod { 0%, 100% { transform: rotate(-2deg); } 40%, 60% { transform: rotate(3deg); } }
@keyframes dewi-mascot-read { 0%, 60%, 100% { transform: translate(0, 3px); } 70%, 90% { transform: translate(0, 0); } }
@keyframes dewi-mascot-hear { 0%, 100% { opacity: 0.2; } 40% { opacity: 1; } }
@keyframes dewi-mascot-sleep { 0%, 100% { opacity: 0.35; transform: translateY(0); } 50% { opacity: 0.8; transform: translateY(-4px); } }
@keyframes dewi-mascot-pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .dewi-mascot *, .dewi-mascot { animation: none !important; transition: none !important; }
  .dewi-mascot[data-state="hablando"] .dewi-mascot__mouth { transform: scaleY(0.35); }
}

/* Paleta finita y escalones de cuatro unidades; sin degradados en la variante pixel. */
.dewi-pixel { shape-rendering: crispEdges; }
.dewi-pixel rect { stroke: none; }
.dewi-pixel__outline { fill: color-mix(in srgb, var(--_shell) 70%, var(--_shadow)); }
.dewi-pixel__navy { fill: var(--_shell); }
.dewi-pixel__ink { fill: var(--_shadow); }
.dewi-pixel__blue { fill: color-mix(in srgb, var(--_mint) 60%, var(--_shell)); }
.dewi-pixel__cyan { fill: var(--_mint); }
.dewi-pixel__sky { fill: color-mix(in srgb, var(--_light) 30%, var(--_mint)); }
.dewi-pixel__light { fill: color-mix(in srgb, var(--_light) 65%, var(--_mint)); }
.dewi-pixel__white { fill: var(--_light); }
.dewi-pixel__eye { fill: color-mix(in srgb, var(--_face) 85%, var(--_mint)); }
.dewi-pixel__shadow { fill: var(--_shadow); opacity: 0.4; }
.dewi-pixel .dewi-mascot__character { animation: dewi-pixel-breathe 4s steps(1, end) infinite; }
.dewi-pixel .dewi-mascot__head, .dewi-pixel .dewi-mascot__gaze, .dewi-pixel .dewi-mascot__torso { transition: none; }
.dewi-pixel .dewi-mascot__blink { animation-timing-function: steps(1, end); }
.dewi-pixel .dewi-mascot__smile, .dewi-pixel .dewi-mascot__ponder, .dewi-pixel .dewi-mascot__concern, .dewi-pixel .dewi-mascot__brows { stroke: none; }
.dewi-pixel .dewi-mascot__mouth { transform-origin: 132px 124px; }
.dewi-pixel:is([data-state="inactivo"], [data-state="en_pausa"]) .dewi-mascot__head { transform: translateY(8px); }
.dewi-pixel[data-state="inactivo"] .dewi-mascot__gaze { animation: none; }
.dewi-pixel[data-state="pensando"] .dewi-mascot__head { transform: translate(0, 4px); }
.dewi-pixel[data-state="pensando"] .dewi-mascot__gaze { transform: translate(4px, -4px); }
.dewi-pixel[data-state="escuchando"] .dewi-mascot__head { transform: translate(4px, 0); }
.dewi-pixel[data-state="escuchando"] .dewi-mascot__smile { transform: none; }
.dewi-pixel[data-state="conectando"] .dewi-mascot__pose--greeting,
.dewi-pixel[data-state="hablando"] .dewi-mascot__pose--presenting { opacity: 1; }
.dewi-pixel:is([data-state="conectando"], [data-state="hablando"]) .dewi-mascot__neutral-arms { opacity: 0; }
.dewi-pixel[data-state="hablando"] .dewi-mascot__head { animation: none; }
.dewi-pixel:is([data-state="error"], [data-state="en_pausa"]) .dewi-mascot__character { animation: none; }
.dewi-pixel[data-state="error"] .dewi-mascot__head { transform: translateY(4px); }
.dewi-pixel[data-state="error"] .dewi-mascot__arm { transform: none; }
.dewi-pixel[data-state="en_pausa"] .dewi-mascot__sleep { animation: none; }
@keyframes dewi-pixel-breathe { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* Superficies amplias: un solo degradado y un contorno por pieza. */
.dewi-soft { shape-rendering: geometricPrecision; }
.dewi-soft-material__lit { stop-color: color-mix(in srgb, var(--_light) 22%, var(--_mint)); }
.dewi-soft-material__base { stop-color: color-mix(in srgb, var(--_mint) 85%, var(--_shell)); }
.dewi-soft-material__shade { stop-color: color-mix(in srgb, var(--_mint) 60%, var(--_shell)); }
.dewi-soft-material__visor-top { stop-color: var(--_shell); }
.dewi-soft-material__visor-bottom { stop-color: color-mix(in srgb, var(--_shell) 85%, var(--_shadow)); }
.dewi-soft .dewi-mascot__shell, .dewi-soft .dewi-mascot__body {
  stroke: color-mix(in srgb, var(--_shell) 65%, var(--_shadow));
  stroke-width: 1.8;
  stroke-linejoin: round;
}
.dewi-soft .dewi-mascot__outline { stroke-width: 2; }
.dewi-soft .dewi-mascot__visor { stroke: var(--_shadow); stroke-width: 1.5; }
.dewi-soft .dewi-mascot__joint { fill: color-mix(in srgb, var(--_mint) 65%, var(--_shell)); stroke: none; }
.dewi-soft .dewi-mascot__head-glint,
.dewi-soft .dewi-mascot__head-shade,
.dewi-soft .dewi-mascot__edge-light,
.dewi-soft .dewi-mascot__glass-reflection,
.dewi-soft .dewi-mascot__glass-edge,
.dewi-soft .dewi-mascot__body-glint,
.dewi-soft .dewi-mascot__neck-shadow,
.dewi-soft .dewi-mascot__beacon,
.dewi-soft .dewi-mascot__bolt,
.dewi-soft .dewi-mascot__cheek,
.dewi-soft .dewi-mascot__seam,
.dewi-soft .dewi-mascot__trim,
.dewi-soft .dewi-mascot__chest,
.dewi-soft .dewi-mascot__head > .dewi-mascot__rim,
.dewi-soft .dewi-mascot__head > .dewi-mascot__joint { display: none; }
.dewi-soft .dewi-mascot__gaze { filter: none; }
.dewi-soft .dewi-mascot__shadow { transform: scale(0.55, 0.5); transform-origin: 120px 222px; }
