/* Quest Sprout — app-specific styles. Uses tokens.css vars only. */

body { padding: 0; overflow-x: hidden; }

.app-shell {
  max-width: 560px;
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-4) calc(var(--sp-12) + 72px);
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
  min-height: 100dvh;
}

/* THEME accent — overridden by data-theme on <body> */
body { --theme-a: var(--primary); --theme-b: var(--accent); }
body[data-theme="forest"] { --theme-a: #37d67a; --theme-b: #1a6b5c; }
body[data-theme="sunset"] { --theme-a: #ff8a5c; --theme-b: #ff5470; }
body[data-theme="galaxy"] { --theme-a: #7c6cff; --theme-b: #37d6d0; }
body[data-theme="candy"] { --theme-a: #ff8fd6; --theme-b: #7c6cff; }
body[data-theme="gold"] { --theme-a: #f4b640; --theme-b: #ffb020; }

h1, h2, h3 { font-family: 'Fredoka', var(--font-display); }

/* ---------- Profile bar ---------- */
.profile-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  position: sticky;
  top: var(--sp-4);
  z-index: 20;
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
}
.avatar-wrap { position: relative; flex-shrink: 0; }
.avatar {
  width: 56px; height: 56px; border-radius: var(--r-full);
  background: linear-gradient(135deg, var(--theme-a), var(--theme-b));
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; box-shadow: var(--shadow-md);
}
.avatar-lg { width: 88px; height: 88px; font-size: 44px; margin: 0 auto var(--sp-3); }
.level-pill {
  position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  color: var(--text); font-size: var(--fs-xs); font-weight: 800;
  padding: 1px var(--sp-2); border-radius: var(--r-full); white-space: nowrap;
}
.profile-mid { flex: 1; min-width: 0; }
.profile-name-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-2); flex-wrap: wrap; }
.profile-name { font-weight: 800; font-size: var(--fs-md); }
.streak-chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs);
  color: var(--warn); font-weight: 700; background: rgba(255,176,32,.12);
  padding: 2px var(--sp-2); border-radius: var(--r-full);
}
.streak-flame::before { content: "\1F525"; }
.xp-track {
  height: 10px; border-radius: var(--r-full); background: var(--surface-2);
  border: 1px solid var(--border); overflow: hidden;
}
.xp-fill {
  height: 100%; width: 0%; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--theme-a), var(--theme-b));
  transition: width .5s var(--ease);
}
.xp-label { font-size: var(--fs-xs); color: var(--muted); margin-top: 4px; }
.coin-badge {
  display: flex; align-items: center; gap: 4px; font-weight: 800;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  padding: var(--sp-1) var(--sp-3); border-radius: var(--r-full); flex-shrink: 0;
}
.coin-icon { font-size: var(--fs-md); }

/* ---------- Tab bar ---------- */
.tabbar {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-2);
  position: sticky; top: 0; z-index: 19;
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: var(--sp-2); font-size: var(--fs-xs); font-weight: 700; color: var(--muted);
  background: var(--surface); border-radius: var(--r-md); min-height: 56px;
}
.tab.active { color: var(--text); background: var(--surface-2); border-color: var(--theme-a); box-shadow: var(--shadow-glow); }
.tab-icon { display: inline-flex; }
.tab .tab-icon svg { width: 20px; height: 20px; }

/* ---------- Views ---------- */
.view { display: none; flex-direction: column; gap: var(--sp-6); animation: fadeIn .25s var(--ease); }
.view.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.section-heading-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.section-heading { margin: 0; font-size: var(--fs-lg); }
.muted-note { color: var(--muted); font-size: var(--fs-sm); }

/* ---------- Daily quest card ---------- */
.daily-card {
  background: linear-gradient(160deg, color-mix(in srgb, var(--theme-a) 20%, var(--surface)), var(--surface));
  border-color: color-mix(in srgb, var(--theme-a) 40%, var(--border-strong));
}
.daily-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-2); }
.daily-badge {
  font-size: var(--fs-xs); font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  color: var(--theme-a); background: color-mix(in srgb, var(--theme-a) 18%, transparent);
  padding: 2px var(--sp-2); border-radius: var(--r-full);
}
.daily-timer { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.daily-desc { color: var(--muted); margin: 0 0 var(--sp-3); }
.quest-meta { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.chip {
  font-size: var(--fs-xs); font-weight: 700; padding: 4px var(--sp-3); border-radius: var(--r-full);
  background: var(--surface-2); border: 1px solid var(--border); text-transform: capitalize;
}
.diff-chip.easy { color: var(--success); }
.diff-chip.medium { color: var(--warn); }
.diff-chip.hard { color: var(--danger); }
.reward-chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 800;
  background: var(--surface-2); border: 1px solid var(--border); padding: 4px var(--sp-3); border-radius: var(--r-full);
}
.reward-chip .tab-icon svg { width: 12px; height: 12px; }
.daily-actions { display: flex; }
.btn-complete { width: 100%; min-height: 52px; font-size: var(--fs-md); display: flex; align-items: center; justify-content: center; gap: var(--sp-2); }
.daily-card.done .btn-complete { opacity: .5; pointer-events: none; }

/* ---------- Category grid ---------- */
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--sp-3); }
.cat-btn {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-2); min-height: 84px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); font-size: var(--fs-xs); font-weight: 700;
}
.cat-btn .cat-emoji { font-size: 24px; }
.cat-btn.active { border-color: var(--theme-a); background: var(--surface-2); box-shadow: var(--shadow-glow); color: var(--text); }

/* ---------- Quest stage ---------- */
.quest-stage { display: flex; flex-direction: column; gap: var(--sp-4); }
.quest-card {
  display: flex; flex-direction: column; gap: var(--sp-3);
  animation: popIn .3s var(--ease);
}
@keyframes popIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.quest-card h3 { margin-bottom: 0; }
.quest-desc { color: var(--muted); margin: 0; }
.quest-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); margin-top: var(--sp-2); }
.quest-actions button { min-height: 48px; display: flex; align-items: center; justify-content: center; gap: var(--sp-2); font-weight: 700; }
.btn-skip { background: var(--surface-2); color: var(--muted); }
.btn-timer {
  width: 100%; min-height: 44px; margin-top: var(--sp-1); background: transparent;
  border: 1px dashed var(--border-strong); color: var(--muted); display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
}

.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--sp-3); padding: var(--sp-8) var(--sp-4); color: var(--muted);
  border: 1px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--surface);
}
.empty-state .empty-icon {
  width: 48px; height: 48px; border-radius: var(--r-full); background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; color: var(--theme-a);
}
.empty-state .empty-icon svg { width: 24px; height: 24px; }
.empty-state p { margin: 0; font-weight: 600; color: var(--text); }
.empty-state span.hint { font-size: var(--fs-sm); color: var(--muted); }
.empty-state button { margin-top: var(--sp-2); }

/* skeleton shimmer */
.skeleton { border-radius: var(--r-md); background: linear-gradient(90deg, var(--surface-2) 25%, var(--border-strong) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.skeleton-card { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-6); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); }
.skeleton-line { height: 14px; }
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-90 { width: 90%; }
.skeleton-line.h-40 { height: 40px; width: 100%; border-radius: var(--r-md); }

/* ---------- History ---------- */
.history-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }
.stat-tile { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); padding: var(--sp-4); text-align: center; }
.stat-tile .stat-icon { color: var(--theme-a); }
.stat-tile .stat-icon svg { width: 20px; height: 20px; }
.stat-tile strong { display: block; font-size: var(--fs-lg); }
.stat-tile span { font-size: var(--fs-xs); color: var(--muted); }

.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.history-item {
  display: flex; align-items: center; gap: var(--sp-3); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); animation: popIn .25s var(--ease);
}
.history-item .h-icon {
  width: 36px; height: 36px; border-radius: var(--r-full); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.history-item.completed .h-icon { background: color-mix(in srgb, var(--success) 20%, transparent); color: var(--success); }
.history-item.skipped .h-icon { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.history-item .h-icon svg { width: 18px; height: 18px; }
.history-item .h-mid { flex: 1; min-width: 0; }
.history-item .h-title { font-weight: 700; font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item .h-sub { font-size: var(--fs-xs); color: var(--muted); }
.history-item .h-reward { font-size: var(--fs-xs); font-weight: 800; color: var(--theme-a); text-align: right; white-space: nowrap; }
.btn-icon-only {
  flex-shrink: 0; width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border); color: var(--muted); border-radius: var(--r-sm);
}
.btn-icon-only:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn-icon-only svg { width: 14px; height: 14px; }

/* ---------- Shop ---------- */
.shop-sub { color: var(--muted); margin: -8px 0 0; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--sp-4); }
.theme-card { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-4); align-items: center; text-align: center; }
.theme-swatch { width: 100%; height: 56px; border-radius: var(--r-md); box-shadow: var(--shadow-sm); }
.theme-card h3 { font-size: var(--fs-sm); margin: 0; }
.theme-price { font-size: var(--fs-xs); color: var(--muted); display: flex; align-items: center; gap: 4px; justify-content: center; }
.theme-card button { width: 100%; min-height: 40px; font-size: var(--fs-sm); font-weight: 700; }
.theme-card button.owned { background: var(--surface-2); color: var(--muted); }
.theme-card button.active-theme { background: var(--success); color: #06251a; border-color: transparent; }

/* ---------- Profile view ---------- */
.profile-grid { display: flex; flex-direction: column; gap: var(--sp-4); }
.profile-card-big { text-align: center; }
.profile-stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); margin-top: var(--sp-4); }
.profile-stat-row strong { display: block; font-size: var(--fs-lg); }
.profile-stat-row span { font-size: var(--fs-xs); color: var(--muted); }
.cat-breakdown { display: flex; flex-direction: column; gap: var(--sp-3); }
.cat-row { display: flex; align-items: center; gap: var(--sp-3); }
.cat-row .cat-label { width: 100px; font-size: var(--fs-sm); font-weight: 700; text-transform: capitalize; flex-shrink: 0; }
.cat-row .cat-bar-track { flex: 1; height: 8px; border-radius: var(--r-full); background: var(--surface-2); overflow: hidden; }
.cat-row .cat-bar-fill { height: 100%; background: linear-gradient(90deg, var(--theme-a), var(--theme-b)); border-radius: var(--r-full); }
.cat-row .cat-count { font-size: var(--fs-xs); color: var(--muted); width: 28px; text-align: right; flex-shrink: 0; }
.btn-danger { background: color-mix(in srgb, var(--danger) 16%, var(--surface-2)); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); display: flex; align-items: center; gap: var(--sp-2); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 26%, var(--surface-2)); }

.btn-ghost { background: transparent; border: 1px solid var(--border-strong); color: var(--text); display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); }

/* ---------- Timer overlay ---------- */
.timer-overlay, .levelup-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: var(--sp-4);
}
.timer-card, .levelup-card { width: 100%; max-width: 340px; display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); text-align: center; }
.timer-ring-wrap { position: relative; width: 120px; height: 120px; margin: var(--sp-2) 0; }
.timer-ring { width: 120px; height: 120px; transform: rotate(-90deg); }
.timer-ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 8; }
.timer-ring-fg { fill: none; stroke: var(--theme-a); stroke-width: 8; stroke-linecap: round; stroke-dasharray: 326.7; stroke-dashoffset: 0; transition: stroke-dashoffset 1s linear; }
.timer-time { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: var(--fs-lg); font-weight: 800; font-variant-numeric: tabular-nums; }
.timer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); width: 100%; }
.timer-actions button { min-height: 48px; display: flex; align-items: center; justify-content: center; gap: var(--sp-2); }

.levelup-burst { font-size: 48px; }

/* toast icon inline */
#toast { display: flex; align-items: center; gap: var(--sp-2); max-width: 90vw; }
#toast svg { width: 16px; height: 16px; flex-shrink: 0; }

@media (min-width: 640px) {
  .app-shell { padding-top: var(--sp-6); }
}
