/* ============================================================
   MATENAUTAS · main.css
   Tokens de diseño, base compartida y componentes comunes.
   Cada pantalla inyecta sus estilos propios desde su módulo.
   Tema: espacio profundo amable. Solo transform y opacity en motion.
   ============================================================ */

:root {
  /* Fondo espacio profundo (nunca negro puro) */
  --fondo-1: #0B1026;
  --fondo-2: #141B3D;
  --fondo-tarjeta: rgba(255, 255, 255, 0.06);
  --fondo-tarjeta-2: rgba(255, 255, 255, 0.10);
  --borde-suave: rgba(255, 255, 255, 0.12);

  /* Acentos por habilidad */
  --sumas: #FFC93C;
  --restas: #FF6B57;
  --multi: #35D0BA;
  --divi: #A78BFA;
  --moneda: #FFD24A;

  /* Texto */
  --texto: #F4F6FF;
  --texto-suave: #B9C1E8;
  --texto-apagado: #7C86B8;

  /* Estados */
  --exito: #6EE7A0;
  --ambar: #FFB84D;

  /* Forma: look de juguete premium */
  --radio: 22px;
  --radio-chico: 14px;
  --sombra-brillo: 0 4px 24px rgba(120, 140, 255, 0.18);
  --sombra-profunda: 0 10px 30px rgba(4, 8, 30, 0.55);
  --brillo-interior: inset 0 1.5px 0 rgba(255, 255, 255, 0.22);
  --glow-moneda: 0 0 18px rgba(255, 210, 74, 0.35);

  /* Tipografía display juguetona con fallback tolerante a fallos */
  --fuente: 'Baloo 2', 'Fredoka', ui-rounded, system-ui, -apple-system, sans-serif;

  /* Zonas seguras iOS */
  --seguro-arriba: env(safe-area-inset-top, 0px);
  --seguro-abajo: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* El arte SVG nunca se recorta: gorros, antenas, brillos y animaciones
   pueden salirse de su caja sin quedar cortados. */
svg { overflow: visible; }

html, body {
  height: 100%;
  overflow: hidden; /* cada pantalla maneja su propio scroll vertical */
}

body {
  font-family: var(--fuente);
  background: linear-gradient(180deg, var(--fondo-1) 0%, var(--fondo-2) 100%);
  color: var(--texto);
  touch-action: manipulation;           /* mata el doble tap zoom */
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

/* Los campos de texto sí permiten selección y teclado nativo */
input, textarea {
  -webkit-user-select: text;
  user-select: text;
  font-family: inherit;
}

/* ---------- Contenedor de pantallas y transiciones del router ---------- */

#app {
  position: fixed;
  inset: 0;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

.pantalla {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding-top: var(--seguro-arriba);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.28s ease, transform 0.28s ease;
  overflow-x: hidden;
}

.pantalla.visible { opacity: 1; transform: translateY(0); }
.pantalla.saliendo { opacity: 0; transform: translateY(-10px); pointer-events: none; }

/* ---------- Botones ---------- */

button {
  font-family: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}

/* Botones estilo juguete 3D: cuerpo con gradiente + BORDE INFERIOR de
   profundidad; al presionar, el botón "se hunde" (translateY) en vez de
   solo encogerse. Cada variante define su color de canto (--canto). */
.boton {
  --canto: #10163A;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;               /* objetivo táctil mínimo */
  min-width: 56px;
  padding: 12px 24px;
  border-radius: var(--radio);
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.06));
  border: 2px solid var(--borde-suave);
  box-shadow: 0 5px 0 var(--canto), var(--sombra-brillo), var(--brillo-interior);
  transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.12s ease;
}

.boton:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--canto), var(--brillo-interior);
}

.boton-primario {
  --canto: #4034A8;
  background: linear-gradient(150deg, #6D7BFF 0%, #5B6CFF 45%, #8B5CF6 100%);
  border-color: rgba(255, 255, 255, 0.32);
  box-shadow: 0 5px 0 var(--canto), 0 8px 24px rgba(107, 92, 246, 0.4), var(--brillo-interior);
  text-shadow: 0 1px 2px rgba(20, 20, 60, 0.35);
}
.boton-primario:active { box-shadow: 0 1px 0 var(--canto), var(--brillo-interior); }

.boton-moneda {
  --canto: #7A5B08;
  background: linear-gradient(150deg, #FFD65C, #E9AE33 55%, #C98F1B);
  border-color: rgba(255, 231, 154, 0.7);
  color: #4A3405;
  box-shadow: 0 5px 0 var(--canto), var(--glow-moneda), var(--brillo-interior);
  text-shadow: 0 1px 0 rgba(255, 240, 200, 0.5);
}
.boton-moneda:active { box-shadow: 0 1px 0 var(--canto), var(--brillo-interior); }

.boton:disabled { opacity: 0.4; pointer-events: none; }

.boton-icono {
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 50%;
  font-size: 26px;
}

/* ---------- Tarjetas y chips ---------- */

.tarjeta {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.04));
  border: 2px solid var(--borde-suave);
  border-radius: var(--radio);
  padding: 16px;
  box-shadow: var(--sombra-profunda), var(--brillo-interior);
}

/* Superficie de vidrio (paneles flotantes, HUD, sheets) */
.vidrio {
  background: rgba(26, 33, 74, 0.55);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
  border: 1.5px solid rgba(255, 255, 255, 0.14);
}

/* ---------- Entradas animadas en cascada ----------
   Agrega .aparece a cualquier nodo y desfásalo con --retraso. */
.aparece {
  animation: entrada-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: var(--retraso, 0ms);
}
@keyframes entrada-pop {
  from { opacity: 0; transform: translateY(18px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Sombra de contacto: elipse suave bajo personajes e ítems para que
   se vean apoyados y terminados (nunca "flotando recortados"). */
.sombra-contacto { position: relative; }
.sombra-contacto::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 62%;
  height: 12px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(5, 8, 25, 0.45) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--fondo-tarjeta-2);
  border: 1.5px solid var(--borde-suave);
  font-size: 15px;
  font-weight: 700;
}

/* ---------- HUD compartido (monedas, título, volver) ---------- */

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  padding-top: calc(10px + var(--seguro-arriba) * 0);
}

.contador-monedas {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 210, 74, 0.18), rgba(255, 210, 74, 0.08));
  border: 2px solid rgba(255, 210, 74, 0.45);
  color: var(--moneda);
  font-size: 18px;
  font-weight: 800;
  box-shadow: var(--glow-moneda), var(--brillo-interior);
}

/* Moneda SVG chiquita reutilizable */
.icono-moneda {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFE79A, var(--moneda) 60%, #D9A400);
  border: 2px solid #B8860B;
  display: inline-block;
  flex-shrink: 0;
}

/* ---------- Estrellas ---------- */

.estrellas { color: var(--moneda); letter-spacing: 2px; }
.estrellas .apagada { color: var(--texto-apagado); }

/* ---------- Overlay de orientación / desktop ---------- */

#overlay-orientacion {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--fondo-1), var(--fondo-2));
  text-align: center;
  padding: 24px;
}

#overlay-orientacion[hidden] { display: none; }

.overlay-tarjeta h2 { font-size: 28px; margin: 12px 0 8px; }
.overlay-tarjeta p { color: var(--texto-suave); font-size: 18px; line-height: 1.5; }
.overlay-cohete { font-size: 64px; animation: flotar 2.4s ease-in-out infinite; }

@keyframes flotar {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-14px) rotate(4deg); }
}

/* ---------- Utilidades ---------- */

.centrado { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.fila { display: flex; align-items: center; gap: 10px; }
.crecer { flex: 1; }
.oculto { display: none !important; }

.scroll-vertical {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Números tabulares para preguntas, respuestas y contadores */
.numeros { font-variant-numeric: tabular-nums; }

/* ---------- Movimiento reducido ---------- */

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