/* ============================================================
   screens.css — CardQuiz Design System · Screen Layouts
   ------------------------------------------------------------
   Owns: per-screen layout classes only.
   Tokens: variables.css. Shell: base.css. Components: components.css.
   Design language: "Calm Scholar" — soft, premium, learning-focused.
   Mobile-first. Tokens only (swatch preview literals are the only
   exception per spec). Keyframes (shake/fadeIn/popIn) from base.css.
   ============================================================ */

/* ════════════════════════════════════════════════════════════
   1. HOME SCREEN
   ════════════════════════════════════════════════════════════ */

.home-screen {
  padding-bottom: var(--sp-6);
}

/* ── Hero banner ────────────────────────────────────────────── */
.home-hero {
  padding: var(--sp-8) var(--sp-5) var(--sp-6);
  text-align: center;
  background: var(--grad-hero);
  position: relative;
  overflow: hidden;
  border-radius: 0 0 var(--r-2xl) var(--r-2xl);
}

.home-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 70% 30%, rgba(255, 255, 255, 0.12) 0%, transparent 60%);
  pointer-events: none;
}

.home-logo {
  font-size: 2.4rem;
  margin-bottom: var(--sp-2);
  line-height: 1;
}

.home-logo .material-symbols-rounded {
  font-size: 2.4rem;
  color: white;
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.home-title {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-extra);
  color: white;
  margin-bottom: var(--sp-1);
}

.home-subtitle {
  font-size: var(--fs-base);
  color: rgba(255, 255, 255, 0.82);
  margin-bottom: var(--sp-4);
}

.home-progress-wrap {
  max-width: 280px;
  margin: 0 auto;
}

.progress-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.28);
  border-radius: var(--r-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: white;
  border-radius: var(--r-full);
  transition: width var(--dur-slow) var(--ease-out);
}

.home-progress-label {
  font-size: var(--fs-xs);
  color: rgba(255, 255, 255, 0.75);
  margin-top: 5px;
  display: block;
}

/* ── Mode grid ──────────────────────────────────────────────── */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  padding: var(--sp-4);
}

@media (max-width: 340px) {
  .mode-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 600px) {
  .mode-grid {
    max-width: 680px;
    margin: 0 auto;
  }
}

/* ── Mode card ──────────────────────────────────────────────── */
.mode-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  cursor: pointer;
  box-shadow: var(--sh-sm);
  transition:
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.mode-card:hover {
  box-shadow: var(--sh-md);
  transform: translateY(-2px);
}

.mode-card:active {
  transform: scale(0.97);
}

.mode-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mode-card-icon .material-symbols-rounded {
  font-size: 1.4rem;
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.mode-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mode-card-title {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  color: var(--text);
}

.mode-card-desc {
  font-size: var(--fs-xs);
  color: var(--text-3);
  line-height: var(--lh-snug);
}

.mode-card-stats {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: 2px;
}

.mode-stat {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.mode-stat-hs {
  font-size: var(--fs-xs);
  color: var(--accent);
  font-weight: var(--fw-semibold);
}

.mode-progress-strip {
  height: 3px;
  background: var(--surface-sunken);
  border-radius: var(--r-full);
  overflow: hidden;
}

.mode-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--r-full);
  transition: width var(--dur-slow);
}

.mode-card-actions {
  display: flex;
  gap: var(--sp-2);
}

.mode-card-actions .btn {
  flex: 1;
  font-size: var(--fs-sm);
  padding: 8px 6px;
  gap: 3px;
}

.mode-card-actions .btn .material-symbols-rounded {
  font-size: 1rem;
}

/* ════════════════════════════════════════════════════════════
   2. LEARN SCREEN
   ════════════════════════════════════════════════════════════ */

.learn-screen {
  padding-bottom: var(--sp-10);
}

/* ── Sticky toolbar ─────────────────────────────────────────── */
.learn-toolbar {
  padding: var(--sp-3) var(--sp-4) var(--sp-2);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

/* ── Filter chips row ───────────────────────────────────────── */
.filter-chips {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  padding: var(--sp-2) var(--sp-4);
  scrollbar-width: none;
}

.filter-chips::-webkit-scrollbar {
  display: none;
}

/* ── Meta count row ─────────────────────────────────────────── */
.learn-meta {
  display: flex;
  justify-content: space-between;
  padding: 2px var(--sp-4) var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--text-3);
}

/* ── Card grids ─────────────────────────────────────────────── */
.card-grid {
  padding: 0 var(--sp-3) var(--sp-3);
}

.grid-flags {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
}

@media (min-width: 480px) {
  .grid-flags {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 768px) {
  .grid-flags {
    grid-template-columns: repeat(4, 1fr);
  }
}

.grid-text {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-2);
}

@media (min-width: 600px) {
  .grid-text {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-3);
  }
}

@media (min-width: 900px) {
  .grid-text {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-12) var(--sp-4);
  color: var(--text-3);
  text-align: center;
}

/* ════════════════════════════════════════════════════════════
   3. QUIZ CONFIG SCREEN
   ════════════════════════════════════════════════════════════ */

.quiz-config-screen {
  padding: var(--sp-4) var(--sp-4) var(--sp-10);
  max-width: 560px;
  margin: 0 auto;
}

.config-title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  margin-bottom: var(--sp-5);
  color: var(--text);
}

.config-section {
  margin-bottom: var(--sp-5);
}

.config-label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--sp-2);
}

.chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

#btn-start {
  margin-top: var(--sp-6);
}

/* ════════════════════════════════════════════════════════════
   4. QUIZ PLAY SCREEN
   ════════════════════════════════════════════════════════════ */

.quiz-play-screen {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding-bottom: var(--sp-4);
}

/* ── Sticky topbar ──────────────────────────────────────────── */
.quiz-topbar {
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
  padding: var(--sp-2) var(--sp-4) 0;
}

.quiz-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: var(--r-full);
  overflow: hidden;
  margin-bottom: var(--sp-2);
}

.quiz-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--r-full);
  transition: width var(--dur-base);
}

/* ── HUD row ────────────────────────────────────────────────── */
.quiz-hud {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px 0 6px;
}

.quiz-lives {
  display: flex;
  gap: 2px;
}

.heart {
  color: var(--danger);
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  font-size: 1.1rem;
  line-height: 1;
}

.heart.empty {
  color: var(--border-strong);
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.quiz-streak {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--text-3);
}

.quiz-streak.hot {
  color: var(--warning);
}

.quiz-streak .material-symbols-rounded {
  font-size: 1rem;
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.quiz-score {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--text);
  margin-left: auto;
}

.quiz-score .material-symbols-rounded {
  font-size: 1rem;
  color: var(--accent);
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.quiz-qnum {
  font-size: var(--fs-xs);
  color: var(--text-3);
  white-space: nowrap;
}

/* ── Timer bar ──────────────────────────────────────────────── */
.quiz-timer-bar {
  height: 3px;
  background: var(--border);
  border-radius: var(--r-full);
  overflow: hidden;
  margin-top: 4px;
}

.quiz-timer-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--r-full);
  transition: width 0.1s linear;
}

/* ── Question body ──────────────────────────────────────────── */
.quiz-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--sp-4);
  gap: var(--sp-4);
}

.quiz-question-text {
  font-size: clamp(1rem, 3vw, 1.3rem);
  font-weight: var(--fw-semibold);
  text-align: center;
  color: var(--text);
  max-width: 520px;
  line-height: var(--lh-snug);
}

.quiz-flag-wrap {
  width: 100%;
  max-width: 300px;
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--sh-md);
  border: 1px solid var(--border);
}

.quiz-flag-img {
  width: 100%;
  display: block;
  aspect-ratio: 3 / 2;
  object-fit: cover;
}

/* ── Text answer list ───────────────────────────────────────── */
.answer-list {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.answer-btn {
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  -webkit-tap-highlight-color: transparent;
}

.answer-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--surface-alt);
}

.answer-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.answer-btn.correct {
  border-color: var(--success) !important;
  background: var(--success-soft) !important;
  color: var(--success) !important;
}

.answer-btn.wrong {
  border-color: var(--danger) !important;
  background: var(--danger-soft) !important;
  animation: shake 0.35s var(--ease-out);
}

.answer-btn:disabled {
  cursor: default;
}

/* ── Flag grid answers ──────────────────────────────────────── */
.flag-grid-answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  width: 100%;
  max-width: 440px;
}

.flag-grid-btn {
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  background: none;
  padding: 0;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
  aspect-ratio: 3 / 2;
  -webkit-tap-highlight-color: transparent;
}

.flag-grid-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.flag-grid-btn:hover:not(:disabled) {
  border-color: var(--primary);
  transform: scale(1.03);
}

.flag-grid-btn.correct {
  border-color: var(--success) !important;
  box-shadow: 0 0 0 3px var(--success-soft);
}

.flag-grid-btn.wrong {
  border-color: var(--danger) !important;
  animation: shake 0.35s var(--ease-out);
}

/* ── Pause button ───────────────────────────────────────────── */
.quiz-pause-btn {
  align-self: center;
  margin-top: auto;
}

/* ════════════════════════════════════════════════════════════
   5. RESULT SCREEN
   ════════════════════════════════════════════════════════════ */

.result-screen {
  padding: var(--sp-4) var(--sp-4) var(--sp-10);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-5);
}

/* ── Banners ────────────────────────────────────────────────── */
.result-banner {
  width: 100%;
  padding: 12px;
  text-align: center;
  border-radius: var(--r-md);
  font-weight: var(--fw-bold);
  font-size: var(--fs-md);
}

.banner-gold {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
}

.banner-star {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

/* ── Score ring ─────────────────────────────────────────────── */
.result-circle-wrap {
  position: relative;
  width: 160px;
  height: 160px;
}

.score-ring {
  width: 100%;
  height: 100%;
}

.score-ring circle {
  transition: stroke-dashoffset 1.2s var(--ease-out);
}

.score-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.score-grade {
  font-size: var(--fs-xl);
  font-weight: var(--fw-extra);
  line-height: 1;
}

.score-number {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-extra);
  color: var(--text);
  line-height: 1;
}

.score-unit {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* ── Stat pills ─────────────────────────────────────────────── */
.result-stats {
  display: flex;
  gap: var(--sp-3);
  width: 100%;
  justify-content: center;
}

.stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
  max-width: 100px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-2);
}

.stat-pill .material-symbols-rounded {
  font-size: 1.2rem;
  color: var(--primary);
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.stat-pill-val {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  color: var(--text);
}

.stat-pill-lbl {
  font-size: var(--fs-xs);
  color: var(--text-3);
  text-align: center;
}

/* ── Missed section ─────────────────────────────────────────── */
.missed-section {
  width: 100%;
}

.missed-title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  color: var(--text);
  margin-bottom: var(--sp-3);
}

.missed-title .material-symbols-rounded {
  font-size: 1.1rem;
  color: var(--danger);
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.missed-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  max-height: 260px;
  overflow-y: auto;
}

.missed-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.missed-flag {
  width: 48px;
  height: 32px;
  object-fit: cover;
  border-radius: var(--r-xs);
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.missed-info {
  flex: 1;
  min-width: 0;
}

.missed-q {
  font-size: var(--fs-xs);
  color: var(--text-3);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.missed-a {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--success);
}

.missed-more {
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--text-3);
  padding: 4px;
}

/* ── Perfect message ────────────────────────────────────────── */
.perfect-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  color: var(--text-3);
  text-align: center;
}

/* ── Result actions ─────────────────────────────────────────── */
.result-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

/* ════════════════════════════════════════════════════════════
   6. SETTINGS SCREEN
   ════════════════════════════════════════════════════════════ */

.settings-screen {
  padding: var(--sp-3) var(--sp-4) var(--sp-10);
  max-width: 560px;
  margin: 0 auto;
}

/* ── Settings group ─────────────────────────────────────────── */
.settings-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
}

.settings-group-hd {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--sp-3);
}

/* ── Settings row ───────────────────────────────────────────── */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: 44px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

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

.settings-label {
  font-size: var(--fs-base);
  color: var(--text);
}

.settings-ctrl {
  flex-shrink: 0;
}

/* ── Danger zone ────────────────────────────────────────────── */
.settings-danger-zone {
  background: none;
  border: none;
  padding: 0;
  margin-bottom: var(--sp-4);
}

/* ── Theme swatches ─────────────────────────────────────────── */
.theme-swatches {
  display: flex;
  gap: var(--sp-2);
}

.swatch-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  padding: 7px 10px;
  cursor: pointer;
  font-size: var(--fs-xs);
  color: var(--text-3);
  transition:
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.swatch-btn.active {
  border-color: var(--primary);
  color: var(--primary);
}

.swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
}

/* Swatch preview — literal colors intentionally hardcoded per spec */
.swatch-white { background: #f5f6fa; }
.swatch-black { background: #000000; }
.swatch-blue  { background: #0a1628; }

/* ── Stats grid ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
}

.stat-card {
  background: var(--surface-alt);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat-icon {
  font-size: 1.2rem;
  color: var(--primary);
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.stat-label {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.stat-val {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  color: var(--text);
}

.stat-val span {
  font-size: var(--fs-sm);
  font-weight: var(--fw-normal);
  color: var(--text-3);
}

.stat-bar {
  height: 3px;
  background: var(--border);
  border-radius: var(--r-full);
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--r-full);
}

.stat-pct {
  font-size: var(--fs-xs);
  color: var(--primary);
  font-weight: var(--fw-semibold);
}
