/* =============================================
   Game animation player (static/game-animation.js)
   Uses the site's Material tokens from styles.css
   ============================================= */

.game-anim {
  margin: 0 0 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Without JavaScript only the numbered steps are shown, as a normal list. */
.game-anim__steps {
  margin: 0 0 24px;
  padding: 16px 16px 16px 2.2rem;
  background: var(--md-surface-container-low);
  border-radius: var(--radius-md);
  font-size: 1rem;
  line-height: 1.6;
}
.game-anim__steps li + li { margin-top: 6px; }

/* ── With JavaScript: stage + caption strip + controls ── */
.game-anim__stage {
  position: relative;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  overflow: hidden;
  border: 1px solid var(--border-card);
  border-bottom: 0;
  cursor: pointer;
}
.game-anim__canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  max-width: 100%;
}
/* Phone held upright: the tall version, never taller than most of the screen */
.game-anim--portrait .game-anim__canvas {
  aspect-ratio: 10 / 16;
  width: min(100%, calc(72vh * 10 / 16));
  width: min(100%, calc(72svh * 10 / 16));
  margin: 0 auto;
}
.game-anim__timeleft {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 6px;
  background: #1f7a52;
  transform-origin: left center;
  pointer-events: none;
  z-index: 1;
}

.game-anim.is-ready .game-anim__steps {
  list-style: none;
  margin: 0;
  padding: 12px 18px;
  min-height: 56px;
  display: flex;
  align-items: center;
  border: 1px solid var(--border-card);
  border-top: 0;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  font-weight: 500;
  font-size: 1.05rem;
  line-height: 1.4;
}
.game-anim.is-ready .game-anim__steps:empty { display: none; }
.game-anim.is-ready .game-anim__steps li { display: none; margin: 0; }
.game-anim.is-ready .game-anim__steps li.is-current {
  display: block;
  animation: game-anim-caption-in .35s ease-out;
}
@keyframes game-anim-caption-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.game-anim__controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.game-anim__btn {
  appearance: none;
  flex: none;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--radius-full);
  background: var(--md-surface);
  color: var(--md-on-surface);
  cursor: pointer;
}
.game-anim__btn:hover { background: var(--hover-primary); }
.game-anim__btn[aria-pressed="true"] { color: var(--md-primary); border-color: var(--md-primary); }
.game-anim__btn svg { width: 20px; height: 20px; fill: currentColor; }
.game-anim__btn:focus-visible,
.game-anim__scrub:focus-visible { outline: 2px solid var(--md-primary); outline-offset: 2px; }
.game-anim__scrub { flex: 1; min-width: 0; accent-color: var(--md-primary); }

@media (max-width: 520px) {
  .game-anim.is-ready .game-anim__steps { font-size: 0.95rem; }
  .game-anim__controls { gap: 6px; }
  .game-anim__btn { width: 36px; height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  .game-anim.is-ready .game-anim__steps li.is-current { animation: none; }
}

/* ── Before the animation is unlocked (static/animation-quota.js) ── */
.game-anim__gate {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 10;
  margin: 0 0 12px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  background: #CADDBF;
}
.game-anim__gate--locked { background: var(--md-surface-container-high); }
.game-anim__gate-icon {
  font-size: 48px;
  color: var(--icon-muted);
}
.game-anim__gate-play {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px 12px 16px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--md-primary);
  color: var(--md-on-primary);
  font: inherit;
  font-size: 1.0625rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.game-anim__gate-play:hover { filter: brightness(1.1); }
.game-anim__gate-play:disabled { opacity: 0.7; cursor: progress; }
.game-anim__gate-play .material-symbols-outlined { font-size: 28px; }
