/* ========================================================
   MENÚ DE JUEGOS MUSICALES PLAY - PLAY ESCOLA DE MÚSICA
   ======================================================== */

:root {
  /* Movimiento */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --dur-press: 140ms;
  --dur-ui: 240ms;
  /* Tonos para texto o fondos con texto blanco: cumplen contraste WCAG AA (4.5:1) */
  --orange-ink: #bf5520;
  --theme-ink: #bf5520;
  --ok-ink: #15803d;
  --correct-ink: #15803d;
  --orange: #d8682a;
  --orange-dark: #a84a18;
  --orange-soft: #fbeee6;
  --ink: #1d1410;
  --muted: #6a564c;
  --line: #ecdcd2;
  --ok: #16a34a;
  --ko: #dc2626;
  --shadow: 0 10px 30px rgba(120, 50, 10, 0.14);
  --font: "Outfit", "Outfit Local", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  min-height: 100%;
  background: var(--orange);
  color: #ffffff;
  font-family: var(--font);
  -webkit-user-select: none;
  user-select: none;
}

.icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.menu {
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(32px + env(safe-area-inset-top, 0px)) 16px calc(36px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(24px, 5vh, 44px);
}

/* Cabecera */
.menu-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
}

.menu-logo {
  width: clamp(170px, 26vw, 260px);
  height: auto;
  display: block;
  margin-bottom: 6px;
}

.menu-title {
  font-size: clamp(34px, 6vw, 56px);
  font-weight: 900;
  letter-spacing: -1.2px;
  line-height: 1;
}

.menu-sub {
  font-size: clamp(19px, 2vw, 22px);
  font-weight: 700;
}

/* Lista de juegos */
.games {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 18px;
}

.game-card {
  min-height: 150px;
  padding: 22px;
  border-radius: 24px;
  background: #ffffff;
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: 1fr auto;
  column-gap: 18px;
  row-gap: 14px;
  align-items: center;
  transition: transform 0.15s, box-shadow 0.2s;
}

a.game-card:active { transform: scale(0.98); }

@media (hover: hover) and (pointer: fine) {
  a.game-card:hover { transform: translateY(-2px); box-shadow: 0 16px 36px rgba(120, 50, 10, 0.2); }
}

a.game-card:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.game-icon {
  grid-row: 1 / 3;
  width: 88px;
  height: 88px;
  padding: 5px; /* ≈ 6 % del azulejo (un % en padding se calcularía sobre el ancho de la tarjeta) */
  border-radius: 22%;
  background: #ffffff;
  /* azulejo blanco de los iconos: borde muy suave y sombra inferior de 5 px */
  box-shadow: 0 0 0 1px #f1e6de, 0 5px 0 rgba(120, 50, 10, 0.28);
  display: block;
  align-self: center;
}

.game-icon svg { display: block; width: 100%; height: 100%; overflow: visible; }

.game-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.game-name {
  font-size: clamp(22px, 2.6vw, 28px);
  font-weight: 900;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.game-desc {
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.35;
}

.game-for {
  align-self: flex-start;
  margin-top: 2px;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--orange-soft);
  color: var(--orange-dark);
  font-size: 13px;
  font-weight: 700;
}

.game-play {
  justify-self: end;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 14px;
  background: var(--orange-ink);
  color: #ffffff;
  font-size: 18px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.game-card.is-soon {
  background: rgba(0, 0, 0, 0.16);
  border: 2px dashed rgba(255, 255, 255, 0.55);
  color: #ffffff;
  box-shadow: none;
  grid-template-rows: 1fr;
}

.game-card.is-soon .game-icon { grid-row: 1; background: #ffffff; box-shadow: 0 5px 0 rgba(80, 30, 5, 0.3); }
.game-card.is-soon .game-desc { color: #ffffff; }

.games-error {
  max-width: 520px;
  text-align: center;
  font-weight: 700;
}

.games-error[hidden] { display: none; }

@media (max-width: 480px) {
  .game-card { padding: 18px; column-gap: 14px; }
  .game-icon { width: 68px; height: 68px; padding: 4px; }
  .game-play { justify-self: stretch; justify-content: center; grid-column: 1 / 3; }
  .game-icon { grid-row: 1; }
}

/* ---------- Juegos con código ---------- */
.lock {
  display: inline-flex;
  vertical-align: middle;
  margin-left: 4px;
  color: var(--orange-ink);
  font-size: 0.8em;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(40, 15, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal[hidden] { display: none; }

.modal-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: #ffffff;
  color: var(--ink);
  border-radius: 24px;
  padding: 28px 24px 22px;
  box-shadow: 0 20px 50px rgba(40, 15, 0, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: none;
  color: var(--muted);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.lock-badge {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--orange-soft);
  color: var(--orange-ink);
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-title { font-size: 24px; font-weight: 900; letter-spacing: -0.4px; }
.modal-sub { font-size: 16px; font-weight: 700; color: var(--muted); margin-top: -6px; }

.code-dots { display: flex; gap: 14px; padding: 6px 0; }

.code-dots .dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid var(--orange);
  transition: background-color 0.15s;
}

.code-dots .dot.on { background: var(--orange); }
.code-dots.shake { animation: shake 0.35s var(--ease-in-out); }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  50% { transform: translateX(8px); }
  75% { transform: translateX(-4px); }
}

.keypad {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.keypad button {
  height: 60px;
  border: none;
  border-radius: 14px;
  background: #f7efe9;
  color: var(--ink);
  font-family: inherit;
  font-size: 24px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.1s, background-color 0.2s;
}

.keypad button:active { transform: scale(0.95); background: var(--line); }

.code-error { min-height: 1.3em; color: var(--ko); font-weight: 700; }

/* ---------- Revisión de accesibilidad ---------- */
/* Zonas táctiles de al menos 44 × 44 px */
.pill-btn, .menu-link { min-height: 44px; }
.step-btn { min-width: 44px; min-height: 44px; }
/* Foco visible también en enlaces */
a:focus-visible { outline: 3px solid #1d1410; outline-offset: 3px; }
.pill .icon-inline { width: 1em; height: 1em; }


/* Tarjetas del menú: entrada escalonada (40 ms entre una y otra) */
.game-card { animation: rise 320ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 40ms); }

/* ---------- Movimiento ----------
   Criterios: solo transform y opacity, curvas ease-out fuertes, interfaz por debajo de 300 ms,
   las salidas más rápidas que las entradas y escalonados de 40 ms en grupos. */
.screen {
  transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out), visibility 0s linear 160ms;
}
.screen.active {
  transition: opacity var(--dur-ui) var(--ease-out), transform var(--dur-ui) var(--ease-out), visibility 0s;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes correct-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.035); }
  100% { transform: scale(1); }
}

@keyframes wrong-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

/* Entrada de la tarjeta de opciones al abrir cada pantalla */
.screen.active .setup-card > * { animation: rise 280ms var(--ease-out) both; }
.screen.active .setup-card > :nth-child(2) { animation-delay: 40ms; }
.screen.active .setup-card > :nth-child(3) { animation-delay: 80ms; }
.screen.active .setup-card > :nth-child(4) { animation-delay: 120ms; }
.screen.active .setup-card > :nth-child(5) { animation-delay: 160ms; }
.screen.active .setup-card > :nth-child(n+6) { animation-delay: 200ms; }

/* Opciones de respuesta: aparecen escalonadas en cada pregunta */
.options > *, .options-grid > *, .def-answers > .action-btn {
  animation: rise 260ms var(--ease-out) both;
}
.options > :nth-child(2), .options-grid > :nth-child(2) { animation-delay: 40ms; }
.options > :nth-child(3), .options-grid > :nth-child(3) { animation-delay: 80ms; }
.options > :nth-child(4), .options-grid > :nth-child(4), .def-answers > .action-btn { animation-delay: 120ms; }

/* Respuesta correcta o incorrecta: respuesta breve y física */
.option.is-correct, .option-btn.is-correct, .choice.is-correct { animation: correct-pop 260ms var(--ease-out); }
.option.is-wrong, .option-btn.is-wrong, .choice.is-wrong { animation: wrong-shake 300ms var(--ease-in-out); }

/* Ventanas y resultados */
.results-modal.active .results-card, .modal:not([hidden]) .modal-card { animation: card-in 280ms var(--ease-out) both; }

/* Pulsación: respuesta inmediata al tocar */
.btn, .seg-btn, .chip, .pill-btn, .listen-btn, .reveal-btn, .step-btn, .menu-link {
  transition-property: transform, background-color, color, box-shadow, opacity, filter, border-color;
  transition-duration: var(--dur-press);
  transition-timing-function: var(--ease-out);
}
.btn:not(:disabled):active, .seg-btn:not(:disabled):active, .chip:not(:disabled):active,
.pill-btn:not(:disabled):active, .listen-btn:not(:disabled):active, .reveal-btn:active,
.step-btn:not(:disabled):active, .menu-link:active { transform: scale(0.97); }

/* Accesibilidad: con «reducir movimiento» se quitan desplazamientos y se mantienen los fundidos */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
  .screen, .screen.active { transform: none !important; }
}

/* ---------- Interruptor del modo Halloween ---------- */
.hw-toggle {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 6px 10px 6px 12px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font: 700 1rem/1 var(--font);
  cursor: pointer;
  transition: background-color var(--dur-ui) var(--ease-out), border-color var(--dur-ui) var(--ease-out), transform var(--dur-press) var(--ease-out);
}
.hw-toggle:active { transform: scale(0.97); }
.hw-toggle:focus-visible { outline: 3px solid #ffffff; outline-offset: 3px; }
@media (hover: hover) and (pointer: fine) {
  .hw-toggle:hover { background: rgba(255, 255, 255, 0.22); }
}
.hw-toggle-icon { width: 30px; height: 28px; flex: none; }
.hw-t-mid { fill: #ffffff; }
.hw-t-side { fill: rgba(255, 255, 255, 0.78); }
.hw-t-stem { fill: #ffffff; }
.hw-t-face { fill: var(--orange-ink); }
.hw-switch {
  width: 44px; height: 26px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  position: relative;
  flex: none;
  transition: background-color var(--dur-ui) var(--ease-out);
}
.hw-switch span {
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform var(--dur-ui) var(--ease-out);
}
.hw-toggle[aria-pressed="true"] { border-color: #ffb35c; background: rgba(232, 116, 31, 0.22); }
.hw-toggle[aria-pressed="true"] .hw-switch { background: var(--orange); }
.hw-toggle[aria-pressed="true"] .hw-switch span { transform: translateX(18px); }
.hw-toggle[aria-pressed="true"] .hw-t-mid { fill: #e8741f; }
.hw-toggle[aria-pressed="true"] .hw-t-side { fill: #b9520f; }
.hw-toggle[aria-pressed="true"] .hw-t-stem { fill: #4d7a2a; }
.hw-toggle[aria-pressed="true"] .hw-t-face { fill: #ffd27a; }
@media (prefers-reduced-motion: reduce) {
  .hw-switch span { transition: none; }
}

.code-hint { margin-top: 6px; font-size: 13px; font-weight: 600; color: var(--muted); text-align: center; }
@media (hover: none) and (pointer: coarse) { .code-hint { display: none; } }
