/* ══════════════════════════════════════════════════════════════════════
   COMPONENT: lives.css — las vidas (sql/198)

   - .lives-wrap / .lives-badge / .lives-card: contador junto a la racha
     (barra del celular y fila de la columna derecha del computador) y su
     tarjeta al tocarlo. js/components/lives-badge.js
   - .quiz-lives / .lives-heart: los corazones del encabezado del quiz y su
     animación al perder uno (salta, gira y cae; el último late).
   - .nolives*: la pantalla de "Te quedaste sin vidas". js/controllers/quiz.js

   Rojo de las vidas: #FF4B4B. Sobre blanco da 3,3:1, así que nunca lleva
   texto encima: el número va en --text-primary al lado del corazón.
   ══════════════════════════════════════════════════════════════════════ */

:root { --lives-red: #FF4B4B; --lives-ease: cubic-bezier(0.23, 1, 0.32, 1); --lives-muted: #5B5868; }
[data-theme="dark"] { --lives-muted: #B3B0C2; }

/* ── Contador ──────────────────────────────────────────────────────── */
.lives-wrap { position: relative; display: inline-flex; }
.lives-wrap[hidden] { display: none; }

.lives-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 1.25rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms var(--lives-ease);
}
.lives-badge:active { transform: scale(0.95); }
@media (hover: hover) {
  .lives-badge:hover { background: var(--bg-hover); }
}
.lives-badge-icon {
  font-size: 28px;
  color: var(--lives-red);
  font-variation-settings: 'FILL' 1;
}
.lives-badge--empty .lives-badge-icon { color: var(--text-secondary); font-variation-settings: 'FILL' 0; }

.lives-card {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1100;
  width: 260px;
  padding: 16px;
  background: var(--bg-white);
  color: var(--text-primary);
  border: 2px solid var(--bg-secondary);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  text-align: left;
  transform-origin: top right;
  animation: lives-card-in 180ms var(--lives-ease);
}
.lives-card[hidden] { display: none; }
@keyframes lives-card-in { from { opacity: 0; transform: translateY(-4px) scale(0.97); } }
.lives-card-title { margin: 0; font-size: 1.0625rem; font-weight: 800; }
.lives-card-hearts { display: flex; gap: 2px; margin: 8px 0; }
.lives-card-hearts .lives-heart { font-size: 26px; }
.lives-card-next { margin: 0; font-size: 0.875rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.lives-card-rule { margin: 6px 0 12px; font-size: 0.8125rem; line-height: 1.4; color: var(--lives-muted); }
.lives-card-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  background: var(--violet);
  color: #FFFFFF;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 800;
  text-decoration: none;
}
.lives-card-cta .material-symbols-outlined { font-size: 18px; }

/* Computador: el contador está al borde derecho de la columna y la tarjeta
   abre hacia la izquierda. Celular: está a la izquierda de la barra y abre
   hacia la derecha. En los dos casos no se sale de la pantalla. */
@media (max-width: 768px) {
  .lives-card { right: auto; left: -8px; transform-origin: top left; }
}

/* ── Corazones ─────────────────────────────────────────────────────── */
.lives-heart {
  display: inline-block;
  color: var(--lives-red);
  font-variation-settings: 'FILL' 1;
  transition: color 240ms var(--lives-ease);
}
.lives-heart--off { color: var(--bg-secondary); }
.lives-heart--lose { animation: lives-lose 620ms var(--lives-ease); }
.lives-heart--last { animation: lives-beat 1100ms ease-in-out infinite; }
.lives-heart--gain { animation: lives-gain 520ms var(--lives-ease); }

@keyframes lives-lose {
  0%   { transform: scale(1); color: var(--lives-red); }
  22%  { transform: scale(1.55) rotate(-14deg); color: var(--lives-red); }
  55%  { transform: scale(0.75) translateY(7px) rotate(16deg); }
  100% { transform: scale(1); }
}
@keyframes lives-beat {
  0%, 100% { transform: scale(1); }
  14%      { transform: scale(1.22); }
  28%      { transform: scale(1); }
  42%      { transform: scale(1.14); }
}
@keyframes lives-gain {
  0%   { transform: scale(0.4); }
  60%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* ── Encabezado del quiz ───────────────────────────────────────────── */
.quiz-lives { display: inline-flex; align-items: center; gap: 1px; margin-right: 4px; }
.quiz-lives[hidden] { display: none; }
.quiz-lives .lives-heart { font-size: 22px; }
.quiz-lives-count { margin-left: 4px; font-size: 1rem; font-weight: 800; color: var(--text-primary); font-variant-numeric: tabular-nums; }
@media (max-width: 480px) {
  /* En el teléfono no caben cinco corazones junto al título: uno y el número. */
  .quiz-lives .lives-heart:not(:first-child) { display: none; }
  /* El que se pierde puede ser uno de los ocultos: aquí salta el visible. */
  .quiz-lives--hit .lives-heart:first-child { animation: lives-lose 620ms var(--lives-ease); }
}

/* ── Sin vidas ───────────────────────────────────────────────────────
   Capa propia sobre todo el quiz (#quiz-layout ya mide 100dvh y no hace
   scroll): nada de columnas detrás ni barra de scroll. Una sola cosa se
   mueve: el corazón, que se llena a medida que se acerca la próxima vida.
   Un solo acento, el violeta del botón; el rojo es solo del corazón. */
.nolives {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: safe center;  /* safe: si no cabe, arranca arriba en vez de cortarse */
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  background: var(--bg-primary);
  /* Cabe sin scroll en cualquier celular de pie; solo en pantallas muy bajas
     se puede desplazar, sin barra visible, antes que cortar los botones. */
  overflow-y: auto;
  scrollbar-width: none;
  animation: nolives-in 260ms var(--lives-ease);
}
@keyframes nolives-in { from { opacity: 0; } }

.nolives-close {
  position: absolute;
  top: calc(8px + env(safe-area-inset-top, 0px));
  left: 8px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: var(--text-primary);
  text-decoration: none;
}
@media (hover: hover) {
  .nolives-close:hover { background: var(--bg-hover); }
}

.nolives-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.nolives-heart {
  position: relative;
  width: 132px;
  height: 132px;
  margin-bottom: 20px;
  animation: nolives-heart-in 520ms var(--lives-ease) both;
}
@keyframes nolives-heart-in { from { opacity: 0; transform: translateY(8px) scale(0.92); } }
.nolives-heart-shell,
.nolives-heart-fill {
  position: absolute;
  inset: 0;
  font-size: 132px;
  line-height: 1;
}
.nolives-heart-shell { color: var(--bg-secondary); font-variation-settings: 'FILL' 1; }
.nolives-heart-fill {
  --nolives-fill: 0%;
  color: var(--lives-red);
  font-variation-settings: 'FILL' 1;
  clip-path: inset(calc(100% - var(--nolives-fill)) 0 0 0);
  transition: clip-path 900ms var(--lives-ease);
}
.nolives--ready .nolives-heart { animation: lives-gain 520ms var(--lives-ease); }

.nolives-title {
  margin: 0;
  font-size: 1.625rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text-primary);
  text-wrap: balance;
}

/* Cómo iba en este intento: un punto por pregunta. Verde/rojo son los del
   quiz (aciertos y errores), no un acento nuevo. */
.nolives-score { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 14px; }
.nolives-score-line { margin: 0; font-size: 0.9375rem; color: var(--lives-muted); }
.nolives-score-line strong { color: var(--text-primary); }
.nolives-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 0; padding: 0; list-style: none; }
.nolives-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bg-secondary); }
.nolives-dot--right { background: #22C55E; }
.nolives-dot--wrong { background: var(--lives-red); }
.nolives-review {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 6px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.nolives-review .material-symbols-outlined { font-size: 18px; text-decoration: none; }
@media (hover: hover) {
  .nolives-review:hover { background: var(--bg-hover); }
}

.nolives-wait { margin: 16px 0 28px; }
.nolives-label { margin: 0; font-size: 0.9375rem; color: var(--lives-muted); }
.nolives-clock {
  margin: 2px 0 0;
  font-size: 2.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.nolives-wait .nolives-continue { margin-top: 12px; }

.nolives-actions { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.nolives-primary { width: 100%; }
.nolives-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 16px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--violet);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms var(--lives-ease);
}
.nolives-secondary:active { transform: scale(0.97); }
@media (hover: hover) {
  .nolives-secondary:hover { background: var(--violet-light, rgba(108, 43, 255, 0.08)); }
}
[data-theme="dark"] .nolives-secondary { color: #B69CFF; }

/* Pantallas bajas (celular acostado): todo más compacto, sigue sin scroll. */
@media (max-height: 560px) {
  .nolives-score { margin-top: 8px; gap: 4px; }
  .nolives-heart { width: 88px; height: 88px; margin-bottom: 10px; }
  .nolives-heart-shell, .nolives-heart-fill { font-size: 88px; }
  .nolives-wait { margin: 8px 0 16px; }
  .nolives-clock { font-size: 2.125rem; }
}

@media (prefers-reduced-motion: reduce) {
  .lives-heart--lose, .lives-heart--last, .lives-heart--gain, .lives-card,
  .nolives, .nolives-heart, .nolives--ready .nolives-heart { animation: none; }
  .nolives-heart-fill { transition: none; }
}
.nolives::-webkit-scrollbar { display: none; }

/* Corazón pequeño dentro de textos: línea de datos del quiz y chip de Quices. */
.quiz-prestart-heart,
.quizzes-quota-chip .lives-heart { font-size: 1.1em; vertical-align: -0.2em; margin-right: 2px; }
.quizzes-quota-chip--empty .lives-heart { color: var(--text-secondary); font-variation-settings: 'FILL' 0; }

/* La barra del celular queda debajo de la tarjeta de materia (sticky, más
   adelante en el DOM). Mientras la tarjeta de vidas está abierta, la barra
   sube por encima. El contenedor tiene pointer-events: none: la tarjeta los
   recupera para poder tocar su enlace. */
.mobile-topbar--default:has(.lives-card:not([hidden])) { z-index: 1200 !important; }
.lives-card { pointer-events: auto; }

/* Tabla de Súper (views/upgrade.html): en la columna gratis, las 5 vidas. */
.skora-super-lives-free { font-weight: 800; font-variant-numeric: tabular-nums; }
