/* public/assets/css/components.css */

/* ── BUTTONS ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 12px var(--space-lg);
  border-radius: var(--r-pill);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--fw-bold);
  line-height: 1;
  min-height: 44px;
  min-width: 44px;
  transition: transform var(--dur-fast) var(--ease), 
              box-shadow var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease),
              opacity var(--dur-fast) var(--ease);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.btn:active:not(:disabled) { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; pointer-events: none; }

.btn-primary {
  background: var(--active);
  color: white;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--active) 35%, transparent);
}
.btn-primary:hover { background: var(--active-dark); }

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { border-color: var(--active); color: var(--active); }

.btn-ghost {
  background: transparent;
  color: var(--active);
}
.btn-ghost:hover { background: var(--active-bg); }

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-gold {
  background: linear-gradient(135deg, #F59E0B, #FBBF24);
  color: white;
  box-shadow: 0 4px 14px rgba(245,158,11,0.35);
}

.btn-lg { padding: 14px 28px; font-size: var(--text-md); min-height: 52px; }
.btn-sm { padding: 8px 14px; font-size: var(--text-sm); min-height: 36px; }
.btn-icon { padding: 10px; border-radius: var(--r-md); }

.btn-full { width: 100%; }

/* ── CARDS ──────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-pad { padding: var(--space-md); }
.card-interactive {
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.card-interactive:active { transform: scale(0.975); box-shadow: var(--shadow-xs); }

/* ── GAME CARD ──────────────────────────────────── */
.game-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1.5px solid var(--border);
  padding: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.game-card:active { transform: scale(0.975); }
.game-card__emoji {
  width: 52px;
  height: 52px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}
.game-card__info { flex: 1; min-width: 0; }
.game-card__name { font-weight: var(--fw-bold); font-size: var(--text-base); }
.game-card__meta { color: var(--muted); font-size: var(--text-xs); margin-top: 3px; }

.game-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
}
.game-card-grid .game-card {
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-md);
}
.game-card-grid .game-card__emoji { font-size: 32px; width: 48px; height: 48px; }

/* ── LEVEL CARD ─────────────────────────────────── */
.level-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.level-card:active { transform: scale(0.975); }
.level-card--locked { opacity: 0.55; cursor: default; }
.level-card__num {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: var(--active-bg);
  color: var(--active);
  font-weight: var(--fw-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  flex-shrink: 0;
}
.level-card__title { font-weight: var(--fw-bold); font-size: var(--text-sm); }
.level-card__meta  { color: var(--muted); font-size: var(--text-xs); margin-top: 2px; }
.level-card__score { 
  margin-left: auto;
  text-align: right;
  font-size: var(--text-xs);
  color: var(--muted);
  flex-shrink: 0;
}

/* ── BADGES ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  line-height: 1.2;
  white-space: nowrap;
}

.badge-free      { background: var(--success-bg); color: var(--success); }
.badge-hot       { background: #FFF1F0; color: var(--danger); }
.badge-new       { background: var(--active-bg);  color: var(--active);  }
.badge-premium   { background: var(--gold-bg);    color: var(--gold);    }
.badge-sponsored { background: #EEF2FF;            color: var(--gem);     }
.badge-easy      { background: var(--success-bg); color: var(--success); }
.badge-medium    { background: var(--warning-bg); color: var(--warning); }
.badge-hard      { background: var(--danger-bg);  color: var(--danger);  }
.badge-live      { background: var(--success-bg); color: var(--success); }
.badge-pending   { background: var(--warning-bg); color: var(--warning); }
.badge-draft     { background: var(--border);     color: var(--muted);   }
.badge-pro       { background: var(--gold-bg);    color: var(--gold);    }

/* ── INPUTS ─────────────────────────────────────── */
.input {
  width: 100%;
  padding: 12px var(--space-md);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--ink);
  background: var(--surface);
  transition: border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
  min-height: 44px;
  outline: none;
}
.input:focus {
  border-color: var(--active);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--active) 15%, transparent);
}
.input::placeholder { color: var(--muted); }

.input-group { display: flex; flex-direction: column; gap: var(--space-xs); }
.input-label { font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--ink-2); }
.input-hint  { font-size: var(--text-xs); color: var(--muted); }
.input-error { font-size: var(--text-xs); color: var(--danger); }
.input.has-error { border-color: var(--danger); }

textarea.input { min-height: 100px; resize: vertical; }

/* ── MODAL ──────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28,25,23,0.5);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fadeIn var(--dur-base) var(--ease);
}
.modal-overlay.centered { align-items: center; padding: var(--space-md); }

.modal {
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--space-lg);
  padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0));
  width: 100%;
  max-width: var(--max-width);
  max-height: 90dvh;
  overflow-y: auto;
  animation: slideUp var(--dur-slow) var(--ease-spring);
}
.modal-overlay.centered .modal {
  border-radius: var(--r-xl);
  max-height: 80dvh;
  animation: scaleIn var(--dur-base) var(--ease-spring);
}
.modal__handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: var(--r-pill);
  margin: 0 auto var(--space-md);
}
.modal__title {
  font-size: var(--text-lg);
  font-weight: var(--fw-extrabold);
  margin-bottom: var(--space-md);
}

/* ── TOAST ──────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: calc(var(--topbar-height) + var(--space-md));
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 380px;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-radius: var(--r-md);
  background: var(--ink);
  color: white;
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: fadeDown var(--dur-base) var(--ease-spring);
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger);  }
.toast.warning { background: var(--warning); }
.toast.gold    { background: linear-gradient(135deg, #D97706, #F59E0B); }

/* ── SPINNER ────────────────────────────────────── */
.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid rgba(255,255,255,0.25);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner.dark {
  border-color: var(--border);
  border-top-color: var(--active);
}

.page-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
}

/* ── EMPTY STATE ────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--space-lg);
  text-align: center;
  gap: var(--space-md);
}
.empty-state__icon { font-size: 48px; }
.empty-state__title { font-weight: var(--fw-bold); font-size: var(--text-lg); }
.empty-state__desc  { color: var(--muted); font-size: var(--text-sm); line-height: var(--lh-base); }

/* ── AVATAR ─────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  background: var(--active-bg);
  color: var(--active);
  font-weight: var(--fw-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar-sm  { width: 32px; height: 32px; font-size: var(--text-sm); }
.avatar-md  { width: 44px; height: 44px; font-size: var(--text-base); }
.avatar-lg  { width: 64px; height: 64px; font-size: var(--text-xl); }
.avatar-xl  { width: 88px; height: 88px; font-size: var(--text-2xl); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ── GEM COUNTER ────────────────────────────────── */
.gem-counter {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 5px 10px;
  background: var(--gem-bg);
  border: 1.5px solid color-mix(in srgb, var(--gem) 20%, transparent);
  border-radius: var(--r-pill);
  font-size: var(--text-sm);
  font-weight: var(--fw-bold);
  color: var(--gem);
}
.gem-counter__icon { animation: gemFloat 2s ease-in-out infinite; }

/* ── STREAK BADGE ───────────────────────────────── */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: linear-gradient(135deg, #FFF7ED, #FEF3C7);
  border: 1.5px solid #FDE68A;
  border-radius: var(--r-pill);
  font-size: var(--text-sm);
  font-weight: var(--fw-bold);
  color: var(--warning);
}
.streak-badge__flame { animation: streakFire 1s ease-in-out infinite; }

/* ── PROGRESS BAR ───────────────────────────────── */
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.progress-bar__fill {
  height: 100%;
  background: var(--active);
  border-radius: var(--r-pill);
  transition: width 0.6s var(--ease);
}

/* ── DIVIDER ────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-md) 0;
}
.divider-text {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  color: var(--muted);
  font-size: var(--text-xs);
}
.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── SECTION HEADER ─────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}
.section-title {
  font-size: var(--text-md);
  font-weight: var(--fw-extrabold);
  color: var(--ink);
}
.section-link {
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--active);
}

/* ── TABS ───────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-alt);
  border-radius: var(--r-pill);
  padding: 3px;
}
.tab-item {
  flex: 1;
  padding: 8px var(--space-sm);
  border-radius: calc(var(--r-pill) - 3px);
  font-size: var(--text-sm);
  font-weight: var(--fw-bold);
  color: var(--muted);
  text-align: center;
  transition: all var(--dur-fast) var(--ease);
  cursor: pointer;
}
.tab-item.active {
  background: var(--surface);
  color: var(--active);
  box-shadow: var(--shadow-xs);
}

/* ── CHIP / TAG ─────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  background: var(--bg-alt);
  color: var(--ink-2);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.chip:hover, .chip.active {
  background: var(--active-bg);
  color: var(--active);
  border-color: var(--active-border);
}

/* ── SCROLL ROW ─────────────────────────────────── */
.scroll-row {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding-bottom: var(--space-sm);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.scroll-row::-webkit-scrollbar { display: none; }

/* ── BANNER CARD ────────────────────────────────── */
.banner-card {
  border-radius: var(--r-xl);
  padding: var(--space-lg);
  min-height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.banner-card__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: white;
  position: relative;
  z-index: 1;
}
.banner-card__sub {
  font-size: var(--text-sm);
  color: rgba(255,255,255,0.8);
  margin-top: 4px;
  position: relative;
  z-index: 1;
}
.banner-card__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.65) 0%, transparent 60%);
}

/* ── STAT CELL ──────────────────────────────────── */
.stat-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-md);
  background: var(--bg-alt);
  border-radius: var(--r-md);
  flex: 1;
}
.stat-cell__val {
  font-size: var(--text-xl);
  font-weight: var(--fw-extrabold);
  color: var(--ink);
}
.stat-cell__label {
  font-size: var(--text-xs);
  color: var(--muted);
  text-align: center;
}

/* ── QUESTION OPTION ────────────────────────────── */
.option-btn {
  width: 100%;
  padding: var(--space-md);
  border-radius: var(--r-md);
  border: 2px solid var(--border);
  background: var(--surface);
  text-align: left;
  font-weight: var(--fw-semibold);
  font-size: var(--text-base);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  min-height: 56px;
  line-height: var(--lh-base);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.option-btn:active:not(.answered) { transform: scale(0.98); }
.option-btn.selected  { border-color: var(--active);  background: var(--active-bg); }
.option-btn.correct   { border-color: var(--success); background: var(--success-bg); color: var(--success); }
.option-btn.incorrect { border-color: var(--danger);  background: var(--danger-bg);  color: var(--danger); animation: shake 0.4s ease; }
.option-btn.answered  { cursor: default; }
.option-label {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  flex-shrink: 0;
}
.option-btn.correct   .option-label { background: var(--success); color: white; }
.option-btn.incorrect .option-label { background: var(--danger);  color: white; }

/* ── ACHIEVEMENT BADGE ──────────────────────────── */
.achievement {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm);
  text-align: center;
}
.achievement__icon {
  width: 56px;
  height: 56px;
  border-radius: var(--r-md);
  background: var(--active-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  transition: transform var(--dur-fast) var(--ease-spring);
}
.achievement--locked .achievement__icon {
  background: var(--bg-alt);
  filter: grayscale(1);
  opacity: 0.5;
}
.achievement:hover .achievement__icon { transform: scale(1.1); }
.achievement__name {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--ink-2);
}
.achievement--locked .achievement__name { color: var(--muted); }

/* ── COUNTDOWN TIMER ────────────────────────────── */
.timer-ring {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.timer-ring__svg { transform: rotate(-90deg); }
.timer-ring__bg  { fill: none; stroke: var(--border); }
.timer-ring__fg  { fill: none; stroke: var(--active); stroke-linecap: round;
                   transition: stroke-dashoffset 1s linear, stroke 0.3s; }
.timer-ring__low { stroke: var(--danger); }
.timer-ring__val {
  position: absolute;
  font-weight: var(--fw-extrabold);
  font-size: var(--text-md);
  color: var(--ink);
}

/* ── LIVES ──────────────────────────────────────── */
.lives {
  display: flex;
  gap: var(--space-xs);
}
.life { font-size: 18px; transition: transform var(--dur-fast) var(--ease); }
.life.lost { filter: grayscale(1); opacity: 0.3; }

/* ── SPIN WHEEL ─────────────────────────────────── */
.spin-wheel-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-lg) 0;
}
.spin-wheel-wrap {
  position: relative;
  width: 260px;
  height: 260px;
}
.spin-wheel-canvas {
  width: 260px;
  height: 260px;
  border-radius: 50%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15), 0 0 0 6px var(--surface), 0 0 0 8px var(--border);
}
.spin-wheel-pointer {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 28px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}
