/* ================================================================
   Shared UI Components — Toasts, Modals, Utilities
   ================================================================ */

/* ── Skip to Content (Accessibility) ─────────────────────────── */
.skip-to-content {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent, #a259ff);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 0 0 8px 8px;
  font-weight: 600;
  font-size: 0.95rem;
  z-index: 10000;
  text-decoration: none;
  transition: top 0.2s ease;
}
.skip-to-content:focus {
  top: 0;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ── Toast Notifications ─────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-sm);
  pointer-events: none;
  max-width: 400px;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  background: rgba(26, 10, 46, 0.95);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  font-size: 0.85rem;
  color: var(--text-primary);
  pointer-events: auto;
  transform: translateX(120%);
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast--visible {
  transform: translateX(0);
  opacity: 1;
}

.toast--exit {
  transform: translateX(120%);
  opacity: 0;
}

.toast--success { border-color: rgba(178, 212, 48, 0.5); }
.toast--error   { border-color: rgba(230, 57, 70, 0.5); }
.toast--warning { border-color: rgba(247, 147, 30, 0.5); }
.toast--snack   { border-color: rgba(247, 147, 30, 0.5); }
.toast--info    { border-color: rgba(107, 63, 160, 0.5); }

.toast-icon { font-size: 1rem; flex-shrink: 0; }
.toast-msg  { flex: 1; line-height: 1.4; }

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 var(--space-xs);
  line-height: 1;
  flex-shrink: 0;
  transition: color var(--transition-fast);
}

.toast-close:hover { color: var(--text-primary); }

/* ── Keyboard Shortcut Modal ─────────────────────────────────── */
.shortcut-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.shortcut-modal--visible { opacity: 1; }

.shortcut-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.shortcut-modal-content {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  max-width: 480px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  animation: fadeInUp 0.3s ease both;
}

.shortcut-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--border-color);
}

.shortcut-modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.shortcut-modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--space-xs);
  line-height: 1;
  transition: color var(--transition-fast);
}

.shortcut-modal-close:hover { color: var(--text-primary); }

.shortcut-modal-body {
  padding: var(--space-md) var(--space-xl);
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid rgba(107, 63, 160, 0.1);
}

.shortcut-row:last-child { border-bottom: none; }

.shortcut-row kbd {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  background: rgba(107, 63, 160, 0.15);
  border: 1px solid rgba(107, 63, 160, 0.3);
  border-radius: 4px;
  color: var(--color-lime);
  min-width: 2rem;
  text-align: center;
}

.shortcut-row span {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.shortcut-modal-footer {
  padding: var(--space-md) var(--space-xl);
  border-top: 1px solid var(--border-color);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

.shortcut-modal-footer kbd {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  background: rgba(107, 63, 160, 0.15);
  border: 1px solid rgba(107, 63, 160, 0.3);
  border-radius: 3px;
  color: var(--color-lime);
}

/* ── Code Block Enhancements ─────────────────────────────────── */
.code-block {
  position: relative;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(107, 63, 160, 0.3);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  padding-right: 3rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
  margin: var(--space-sm) 0;
}

.code-block::before {
  content: attr(data-lang);
  position: absolute;
  top: var(--space-xs);
  right: 2.5rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.6;
  letter-spacing: 0.05em;
}

.code-copy-btn {
  position: absolute;
  top: var(--space-xs);
  right: var(--space-xs);
  background: rgba(107, 63, 160, 0.2);
  border: 1px solid rgba(107, 63, 160, 0.3);
  border-radius: 4px;
  padding: 0.2rem 0.4rem;
  cursor: pointer;
  font-size: 0.75rem;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.code-block:hover .code-copy-btn { opacity: 1; }

.inline-code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: rgba(107, 63, 160, 0.15);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  color: var(--color-lime);
}

/* ── Loading Skeleton ────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg,
    rgba(107, 63, 160, 0.1) 25%,
    rgba(107, 63, 160, 0.2) 50%,
    rgba(107, 63, 160, 0.1) 75%
  );
  background-size: 200% 100%;
  animation: skeletonPulse 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeletonPulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Scroll-to-Top Button ────────────────────────────────────── */
.scroll-top-btn {
  position: fixed;
  bottom: var(--space-xl);
  left: var(--space-lg);
  z-index: 900;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--color-lime);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(20px);
  transition: all var(--transition-med);
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.scroll-top-btn.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.scroll-top-btn:hover {
  background: var(--color-purple);
  border-color: var(--color-lime);
  box-shadow: 0 0 20px rgba(178, 212, 48, 0.3);
}

/* ── Status Indicator Enhancements ───────────────────────────── */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot--ready {
  background: var(--color-lime);
  box-shadow: 0 0 8px rgba(178, 212, 48, 0.6);
  animation: statusPulse 2s ease-in-out infinite;
}

.status-dot--error {
  background: var(--color-red);
  box-shadow: 0 0 8px rgba(230, 57, 70, 0.6);
}

.status-dot--loading {
  background: var(--color-orange);
  animation: statusPulse 1s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Budget Meter ────────────────────────────────────────────── */
.budget-meter {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: rgba(26, 10, 46, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 100px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.budget-bar {
  width: 60px;
  height: 6px;
  background: rgba(107, 63, 160, 0.2);
  border-radius: 3px;
  overflow: hidden;
}

.budget-fill {
  height: 100%;
  width: 100%;
  border-radius: 3px;
  background: var(--color-lime);
  transition: width 0.5s ease;
}

.budget-fill.low     { background: var(--color-orange); }
.budget-fill.critical { background: var(--color-red); }

/* ── Responsive Toasts ───────────────────────────────────────── */
@media (max-width: 768px) {
  .toast-container {
    left: var(--space-md);
    right: var(--space-md);
    bottom: var(--space-md);
    max-width: none;
  }

  .toast {
    transform: translateY(100%);
  }

  .toast--visible {
    transform: translateY(0);
  }

  .toast--exit {
    transform: translateY(100%);
  }
}

/* ── Screen Reader Only ──────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Games CTA (homepage) ────────────────────────────────────── */
.games-cta-wrap {
  text-align: center;
  margin-top: 1rem;
}

.games-cta-btn {
  display: inline-block;
  text-decoration: none;
  padding: 0.5rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #000;
  background: var(--color-lime, #B2D430);
  border-radius: var(--radius-full, 999px);
  transition: all 0.2s;
}

.games-cta-btn:hover {
  background: #00ff64;
  box-shadow: 0 0 16px rgba(0, 255, 100, 0.4);
  transform: translateY(-2px);
}

/* ── Game Instructions Panel ─────────────────────────────────── */
.game-instructions {
  margin-top: var(--space-md, 1rem);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color, rgba(255,255,255,.1));
  border-radius: var(--radius-md, 8px);
  overflow: hidden;
}

.game-instructions-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: none;
  border: none;
  color: var(--text-secondary, #aaa);
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.2s;
}

.game-instructions-toggle:hover { color: var(--text-primary, #fff); }

.game-instructions-toggle .gi-arrow {
  transition: transform 0.2s;
}

.game-instructions.open .gi-arrow {
  transform: rotate(180deg);
}

.game-instructions-body {
  display: none;
  padding: 0 1rem 0.8rem;
  font-size: 0.82rem;
  color: var(--text-muted, #888);
  line-height: 1.6;
}

.game-instructions.open .game-instructions-body { display: block; }

.game-instructions-body kbd {
  display: inline-block;
  padding: 1px 6px;
  font-size: 0.78rem;
  font-family: monospace;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 3px;
  margin: 0 2px;
}

.game-instructions-body ul {
  margin: 0.4rem 0;
  padding-left: 1.2rem;
}

.game-instructions-body li { margin-bottom: 0.25rem; }

/* ── Leaderboard Panel ───────────────────────────────────────── */
.game-leaderboard {
  margin-top: var(--space-md, 1rem);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color, rgba(255,255,255,.1));
  border-radius: var(--radius-md, 8px);
  overflow: hidden;
}

.game-lb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary, #aaa);
  border-bottom: 1px solid var(--border-color, rgba(255,255,255,.1));
}

.game-lb-header strong { color: var(--text-primary, #fff); }

.game-lb-clear {
  background: none;
  border: none;
  color: var(--text-muted, #888);
  font-size: 0.7rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.game-lb-clear:hover { color: #ef5350; }

.game-lb-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.game-lb-list li {
  display: flex;
  align-items: center;
  padding: 0.35rem 1rem;
  font-size: 0.82rem;
  border-bottom: 1px solid rgba(255,255,255,.03);
}

.game-lb-list li:last-child { border-bottom: none; }

.game-lb-rank {
  width: 1.6rem;
  font-weight: 700;
  color: var(--text-muted, #888);
}

.game-lb-list li:nth-child(1) .game-lb-rank { color: #ffc107; }
.game-lb-list li:nth-child(2) .game-lb-rank { color: #90a4ae; }
.game-lb-list li:nth-child(3) .game-lb-rank { color: #ff8a65; }

.game-lb-name {
  flex: 1;
  color: var(--text-secondary, #aaa);
}

.game-lb-score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-lime, #B2D430);
}

.game-lb-empty {
  padding: 0.8rem 1rem;
  font-size: 0.8rem;
  color: var(--text-muted, #888);
  text-align: center;
}
