/* Playground Enhancements — shared across all games */

/* ── Botti Speech Bubble ── */
.botti-bubble {
  position: fixed;
  bottom: 72px;
  left: 14px;
  background: #111827;
  color: #e2e8f0;
  font-family: 'Kanit', sans-serif;
  font-size: 0.85rem;
  line-height: 1.4;
  padding: 9px 13px 9px 38px;
  border-radius: 18px 18px 18px 4px;
  border: 1.5px solid rgba(0,212,170,0.45);
  box-shadow: 0 6px 24px rgba(0,0,0,0.35);
  max-width: 210px;
  z-index: 9000;
  opacity: 0;
  transform: translateY(10px) scale(0.92);
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.34,1.56,0.64,1);
}
.botti-bubble::before {
  content: '🤖';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  line-height: 1;
}
/* tail */
.botti-bubble::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 14px;
  border: 5px solid transparent;
  border-top-color: rgba(0,212,170,0.45);
  border-bottom: none;
}
.botti-bubble.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ── Celebration floating emojis ── */
.celeb-float {
  position: fixed;
  bottom: -50px;
  pointer-events: none;
  z-index: 9999;
  user-select: none;
  animation: pg-float-up var(--dur, 2s) ease-out var(--delay, 0s) forwards;
}
@keyframes pg-float-up {
  0%   { transform: translateY(0)      rotate(0deg)   scale(1);   opacity: 1; }
  70%  { opacity: 1; }
  100% { transform: translateY(-105vh) rotate(380deg) scale(0.7); opacity: 0; }
}

/* ── Hint slide-in animation ── */
.story-hint, .lv-hint {
  animation: pg-hint-in 0.45s ease both;
}
@keyframes pg-hint-in {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Run button press micro-animation ── */
.btn-run, .btn.btn-run, button.run-btn {
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn-run:active, .btn.btn-run:active, button.run-btn:active {
  transform: scale(0.93) !important;
}

/* ── Command chip wiggle on add ── */
@keyframes pg-chip-in {
  0%   { transform: scale(0.7) rotate(-4deg); opacity: 0; }
  70%  { transform: scale(1.1) rotate(2deg);  opacity: 1; }
  100% { transform: scale(1)   rotate(0deg);  opacity: 1; }
}
.chip-new {
  animation: pg-chip-in 0.28s cubic-bezier(0.34,1.56,0.64,1) both;
}

/* ── Win overlay star pop ── */
@keyframes pg-star-pop {
  0%   { transform: scale(0) rotate(-30deg); opacity: 0; }
  65%  { transform: scale(1.25) rotate(8deg); opacity: 1; }
  100% { transform: scale(1)    rotate(0deg); opacity: 1; }
}
.ov-stars {
  animation: pg-star-pop 0.55s cubic-bezier(0.34,1.56,0.64,1) 0.15s both;
}

/* ── Cute pulsing hint icon ── */
@keyframes pg-pulse {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.18); }
}
.hint-icon-pulse {
  display: inline-block;
  animation: pg-pulse 2s ease-in-out infinite;
}

/* ── Language toggle button ── */
.lang-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-family: 'Space Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 1px;
  padding: 0.18rem 0.48rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  flex-shrink: 0;
  /* H3: 44 × 44 px touch target */
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.lang-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ── Focus Visible (H1) ──────────────────────────────────────────────────── */
/* Game pages define their own :root variables inline, so we rely on the
   --accent value present in every game page's inline <style>. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
:focus:not(:focus-visible) { outline: none; }

/* ── H3: Touch Targets (44 × 44 px minimum) ──────────────────────────────── */
/* Toolbar back link — inline-flex so min-height applies inside flex parent   */
.toolbar-back {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
/* Player name button (each game page defines the rest of its styles inline)  */
/* min-width reserves space before auth resolves to prevent toolbar reflow     */
.player-btn {
  min-height: 44px;
  min-width: 82px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
/* Small panel buttons in Pattern Finder / AI Trainer */
.btn-sm { min-height: 44px; }
/* Pattern / AI header back arrow */
.back-btn {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── H4: Share-button loading state ──────────────────────────────────────── */
/* Add .btn-loading while an async share/export is in progress.               */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
  cursor: wait;
}
.btn-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: rgba(255,255,255,0.85);
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* ── M3: Name-input validation error ─────────────────────────────────────── */
.name-error {
  font-size: 0.8rem;
  color: #ff6b35;
  min-height: 1.2em;
  margin: -0.25rem 0 0.5rem;
  text-align: center;
}

/* ── M7: Skip navigation link ────────────────────────────────────────────── */
.skip-link {
  position: fixed;
  top: -100%;
  left: 1rem;
  z-index: 99999;
  padding: 0.5rem 1.25rem;
  background: var(--accent, #00d4aa);
  color: #0a0e1a;
  font-family: 'Kanit', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: 0 0 10px 10px;
  text-decoration: none;
  white-space: nowrap;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 0; }

/* ── Toolbar title: hide on narrow screens ───────────────────────────────── */
@media (max-width: 480px) {
  .toolbar-title { display: none; }
}

/* ── Reduced Motion (M4) ─────────────────────────────────────────────────── */
/* The universal block (animation-duration/iteration-count) handles the bulk.
   The named rules below are belt-and-suspenders for the infinite decorative
   loops defined earlier in this file, in case specificity ever becomes
   an issue as this file grows. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration:        0.01ms !important;
    animation-iteration-count: 1      !important;
    transition-duration:       0.01ms !important;
    scroll-behavior:           auto   !important;
  }

  /* Infinite decorative loops — stop completely */
  .hint-icon-pulse { animation: none !important; }
  .celeb-float     { animation: none !important; }

  /* Entry animations — show final state immediately (already handled by
     duration:0.01ms, but explicit for clarity) */
  .ov-stars,
  .chip-new,
  .story-hint,
  .lv-hint      { animation: none !important; }

  /* Botti speech bubble — skip the spring entrance, jump to final state */
  .botti-bubble { transition: none !important; }
  .botti-bubble.show { opacity: 1; transform: translateY(0) scale(1); }

  /* Share loading spinner — stop completely */
  .btn-loading::after { animation: none !important; }
  /* Skip-link — instant show/hide */
  .skip-link { transition: none !important; }
}
