/* Estilo gaming (spec 015, inc. C: RF-007 a RF-014). Solo tokens semánticos (ADR-0005).

   Regla de la casa (RNF-001): TODO lo que se mueve va dentro del bloque
   @media (prefers-reduced-motion: no-preference) del final; fuera solo hay aspecto estático
   (insignias, brillos, colores). Lo comprueba config/tests/test_estilo_gaming.py. Y nada
   parpadea más de 5 s (WCAG 2.2.2): los cursores parpadean unas veces y se quedan fijos. */

/* RF-008 — Barra de XP de lectura, arriba del todo. efectos.js pone --progreso (0 a 1) */
.barra-xp {
  position: fixed;
  inset: 0 0 auto;
  z-index: 30;
  height: 4px;
  pointer-events: none;
  background: color-mix(in srgb, var(--color-glow) 15%, transparent);
}
.barra-xp span {
  display: block;
  width: calc(var(--progreso, 0) * 100%);
  height: 100%;
  background: linear-gradient(90deg, var(--color-accent), var(--color-glow));
  box-shadow: 0 0 8px var(--color-glow);
}
.aviso-xp {
  position: fixed;
  right: var(--space);
  bottom: var(--space);
  z-index: 30;
  margin: 0;
  padding: 0.6rem 1rem;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-action-text);
  background: var(--color-action);
  border-radius: var(--radius);
  box-shadow: 0 0 0 2px var(--color-glow), 0 0 18px var(--color-glow);
}
.aviso-xp[hidden] { display: none; }

/* RF-009 y RF-013 — Cursores: «▌» en el menú al pasar o con el foco, «_» en los títulos */
.menu-elemento > a, .submenu-lista a { position: relative; }
.menu-elemento > a:is(:hover, :focus-visible)::before,
.submenu-lista a:is(:hover, :focus-visible)::before {
  position: absolute;
  left: -0.8em;
  content: "▌";
  content: "▌" / "";
  color: var(--color-accent);
}
/* Menú en botones (v0.5): el cursor, dentro del botón; y se hunde al pulsarlo */
.menu-horizontal .menu-elemento > a:is(:hover, :focus-visible)::before { left: 0.2em; }
.menu-horizontal .menu-elemento > :is(a, .menu-grupo):active { box-shadow: 0 0 0 transparent; }
.portada__seccion-titulo::after, .listado__cabecera h1::after {
  content: "_";
  content: "_" / "";
  margin-left: 0.1em;
  color: var(--color-accent);
}

/* RF-010 — Tarjetas: brillo, imagen con zoom y destello, título con barra de vida */
.tarjeta { position: relative; }
.tarjeta:is(:hover, :focus-within) {
  border-color: var(--color-glow);
  box-shadow: 0 0 0 1px var(--color-glow), 0 10px 28px color-mix(in srgb, var(--color-glow) 35%, transparent);
}
.tarjeta__imagen { position: relative; overflow: hidden; }
.tarjeta__imagen::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background: linear-gradient(115deg, transparent 35%,
              color-mix(in srgb, var(--color-surface-raised) 55%, transparent) 50%, transparent 65%);
  opacity: 0;
}
.tarjeta__titulo a {
  background-image: linear-gradient(90deg, var(--color-accent), var(--color-glow));
  background-position: 0 100%;
  background-repeat: no-repeat;
  background-size: 0% 3px;
  padding-bottom: 2px;
}
.tarjeta__titulo a:hover, .tarjeta:is(:hover, :focus-within) .tarjeta__titulo a {
  text-decoration: none;
  background-size: 100% 3px;
}

/* RF-011 — Categorías como insignias arcade (sombra dura); etiquetas como cromos */
.etiqueta {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 2px solid var(--color-text);
  border-radius: 2px;
  box-shadow: 3px 3px 0 var(--color-accent);
}
.etiqueta--cromo {
  text-transform: none;
  letter-spacing: 0;
  border-width: 1px;
  border-color: var(--color-border-control);
  border-radius: var(--radius);
  box-shadow: 2px 2px 0 var(--color-border);
}
a.etiqueta--cromo:hover { box-shadow: 3px 3px 0 var(--color-glow); }

/* RF-012 — Botones como teclas: sombra inferior que desaparece al pulsar */
.boton--primario, .boton--secundario {
  box-shadow: 0 4px 0 color-mix(in srgb, var(--color-text) 35%, transparent);
}
.boton--primario:active, .boton--secundario:active { box-shadow: 0 0 0 transparent; }

/* RF-014 — Código Konami: el logo cambia de color hasta recargar; confeti de emojis */
.konami .brand-logo, .konami .brand-texto { filter: hue-rotate(150deg) saturate(1.4); }
.confeti {
  position: fixed;
  inset: 0;
  z-index: 40;
  overflow: hidden;
  pointer-events: none;
}
.confeti span { position: absolute; top: -2rem; left: var(--x); font-size: var(--tam, 1.5rem); }

/* RF-019 — 404 «Game Over» (v0.6): pantalla de fin de partida con la paleta de la marca */
.error--game-over { display: grid; justify-items: center; gap: 0.5rem; }
.error--game-over p { margin: 0; }
.error__codigo {
  font-family: var(--font-display);
  font-size: clamp(4rem, 3rem + 6vw, 8rem);
  font-weight: 700;
  line-height: 1;
  color: var(--color-accent);
  text-shadow: 4px 4px 0 var(--color-glow);
}
.error__titulo {
  margin: 0;
  font-size: var(--text-h1);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.error__subtitulo {
  display: block;
  font-size: var(--text-h4);
  letter-spacing: 0;
  text-transform: none;
  color: var(--color-text-muted);
}
.error__continuar { font-family: var(--font-display); font-size: var(--text-h3); font-weight: 700; }
.error__continuar::after { content: "_"; content: "_" / ""; margin-left: 0.1em; color: var(--color-accent); }
.error__moneda {
  font-family: var(--font-display);
  font-size: var(--text-label);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* ---------------------------------------------------------------------------------------- */
/* Movimiento: solo si el visitante no ha pedido reducirlo                                   */
@media (prefers-reduced-motion: no-preference) {
  @keyframes parpadeo { 50% { opacity: 0; } }
  @keyframes entrada { from { opacity: 0; translate: 0 0.75rem; } }
  @keyframes destello { from { opacity: 1; translate: -100% 0; } to { opacity: 1; translate: 100% 0; } }
  @keyframes caida { to { translate: var(--deriva, 0) 110vh; rotate: var(--giro, 360deg); } }
  @keyframes aparece { from { opacity: 0; translate: 0 1rem; } }

  .barra-xp span { transition: width 0.1s linear; }
  .aviso-xp { animation: aparece 0.3s ease-out; }

  /* Cursores: 4 parpadeos de 1 s y se quedan fijos (WCAG 2.2.2) */
  .menu-elemento > a:is(:hover, :focus-visible)::before,
  .submenu-lista a:is(:hover, :focus-visible)::before { animation: parpadeo 1s steps(1) 4; }
  .portada__seccion-titulo::after, .listado__cabecera h1::after { animation: parpadeo 1.2s steps(1) 4; }

  /* RF-007 — Entrada escalonada: una sola vez, al cargar (--i lo pone la plantilla) */
  /* backwards: al terminar deja de aplicarse y no interfiere con el efecto al pasar */
  .tarjeta { animation: entrada 0.4s ease-out backwards; animation-delay: calc(min(var(--i, 0), 8) * 60ms); }

  .tarjeta { transition: translate 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease; }
  .tarjeta:is(:hover, :focus-within) { translate: 0 -4px; }
  .tarjeta__imagen img { transition: scale 0.4s ease; }
  .tarjeta:is(:hover, :focus-within) .tarjeta__imagen img { scale: 1.06; }
  .tarjeta:is(:hover, :focus-within) .tarjeta__imagen::after { animation: destello 0.7s ease-out 1; }
  .tarjeta__titulo a { transition: background-size 0.35s ease-out; }

  .etiqueta--cromo { transition: rotate 0.2s ease, scale 0.2s ease, box-shadow 0.2s ease; }
  a.etiqueta--cromo:hover { rotate: -4deg; scale: 1.06; }
  li:nth-child(even) > a.etiqueta--cromo:hover { rotate: 4deg; }

  .boton--primario, .boton--secundario { transition: translate 0.08s ease, box-shadow 0.08s ease; }
  .boton--primario:active, .boton--secundario:active { translate: 0 4px; }
  .menu-horizontal .menu-elemento > :is(a, .menu-grupo) { transition: translate 0.08s ease, box-shadow 0.08s ease; }
  .menu-horizontal .menu-elemento > :is(a, .menu-grupo):active { translate: 0 3px; }

  .brand-logo, .brand-texto { transition: filter 0.6s ease; }

  /* 404: el código cae y rebota una vez al cargar; «¿Continuar?» y la moneda parpadean unas
     veces y se quedan fijos (WCAG 2.2.2) */
  @keyframes rebote { 0% { translate: 0 -2rem; opacity: 0; } 60% { translate: 0 0.4rem; opacity: 1; } 100% { translate: 0 0; } }
  .error__codigo { animation: rebote 0.6s ease-out 1 backwards; }
  .error__continuar::after { animation: parpadeo 1s steps(1) 4; }
  .error__moneda { animation: parpadeo 1.2s steps(1) 4; }
  .confeti span { animation: caida var(--duracion, 3s) ease-in var(--retraso, 0s) both; }
}
