/* ============================================
   NIHONGO v7 — Design System
   ============================================ */

:root {
  /* Fond */
  --bg: #fafaf8;
  --bg-card: #ffffff;
  --bg-subtle: #f5f3ef;

  /* Texte */
  --text: #1a1a1a;
  --text-2: #6b7280;
  --text-3: #9ca3af;

  /* Accent principal — indigo japonais */
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;
  --primary-bg: #eef2ff;

  /* Sémantique */
  --success: #22c55e;
  --success-bg: #f0fdf4;
  --error: #ef4444;
  --error-bg: #fef2f2;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --xp: #f59e0b;
  --streak: #ef4444;

  /* Surfaces */
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);

  /* Typographie */
  --font: 'Inter', 'Noto Sans JP', system-ui, sans-serif;
  --font-jp: 'Noto Sans JP', 'Inter', system-ui, sans-serif;

  /* Rayons */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Taille de base 8pt grid */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Safe areas */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ============================================
   Reset & Base
   ============================================ */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Desktop: fond subtil derrière l'app centrée */
@media (min-width: 768px) {
  body {
    background: #f0f0ec;
  }
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
}

/* Tablet: centré avec ombre */
@media (min-width: 768px) {
  #app {
    max-width: 680px;
    box-shadow: 0 0 40px rgba(0,0,0,0.08);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

/* Desktop large */
@media (min-width: 1200px) {
  #app {
    max-width: 760px;
  }
}

#screen {
  flex: 1;
  padding-bottom: calc(72px + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Quand la tab bar est cachée (leçon/quiz), pas de padding bottom */
#screen.no-tabs {
  padding-bottom: 0;
  overflow: hidden; /* le lesson-screen gère son propre scroll */
}

/* ============================================
   Tab Bar
   ============================================ */

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 100%;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: var(--space-2) 0 calc(var(--space-2) + var(--safe-bottom));
  z-index: 100;
}

@media (min-width: 768px) {
  .tab-bar { max-width: 680px; }
}

@media (min-width: 1200px) {
  .tab-bar { max-width: 760px; }
}

.tab-bar.hidden {
  display: none;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-2) var(--space-4);
  background: none;
  border: none;
  color: var(--text-3);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
  min-width: 64px;
}

.tab.active {
  color: var(--primary);
}

.tab svg {
  width: 24px;
  height: 24px;
}

/* ============================================
   Typographie
   ============================================ */

.text-xs { font-size: 12px; }
.text-sm { font-size: 14px; }
.text-base { font-size: 16px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 24px; }
.text-2xl { font-size: 32px; }
.text-3xl { font-size: 40px; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.text-secondary { color: var(--text-2); }
.text-muted { color: var(--text-3); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-xp { color: var(--xp); }
.text-streak { color: var(--streak); }

.jp { font-family: var(--font-jp); }

/* ============================================
   Boutons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--primary-light);
  color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: 18px;
  border-radius: var(--radius-lg);
}

.btn-full {
  width: 100%;
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-full);
}

/* ============================================
   Cartes
   ============================================ */

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-4);
}

.card-flat {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: var(--space-4);
}

/* ============================================
   Inputs
   ============================================ */

.input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 18px;
  color: var(--text);
  background: var(--bg-card);
  outline: none;
  transition: border-color 0.2s;
}

.input:focus {
  border-color: var(--primary);
}

.input::placeholder {
  color: var(--text-3);
}

/* ============================================
   Barre de progression
   ============================================ */

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.progress-bar-fill.success {
  background: var(--success);
}

.progress-bar-sm {
  height: 4px;
}

/* ============================================
   Badges / Tags
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}

.badge-xp {
  background: var(--warning-bg);
  color: var(--xp);
}

.badge-streak {
  background: var(--error-bg);
  color: var(--streak);
}

.badge-level {
  background: var(--primary-bg);
  color: var(--primary);
}

/* ============================================
   Status bar (haut de l'écran Apprendre)
   ============================================ */

.status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  padding-top: calc(var(--space-3) + var(--safe-top));
}

/* ============================================
   Écran Onboarding
   ============================================ */

.onboard-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: var(--space-8);
  text-align: center;
}

.onboard-logo {
  font-size: 64px;
  margin-bottom: var(--space-6);
}

.onboard-title {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.onboard-subtitle {
  font-size: 16px;
  color: var(--text-2);
  margin-bottom: var(--space-10);
  max-width: 280px;
}

.onboard-form {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ============================================
   Écran Learn — Liste des topics/leçons
   ============================================ */

.learn-screen {
  padding: var(--space-4);
}

.continue-card {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-6);
  cursor: pointer;
  transition: transform 0.1s;
  box-shadow: var(--shadow-md);
}

.continue-card:active {
  transform: scale(0.98);
}

.continue-label {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-1);
}

.continue-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: var(--space-3);
}

.continue-progress {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.25);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.continue-progress-fill {
  height: 100%;
  background: #fff;
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.continue-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-2);
  font-size: 13px;
  opacity: 0.8;
}

/* Topic header */
.topic-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
  padding: 0 var(--space-1);
}

.topic-header:first-of-type {
  margin-top: var(--space-2);
}

.topic-number {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.topic-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
}

.topic-title-jp {
  font-family: var(--font-jp);
  font-size: 15px;
  color: var(--text);
}

/* Lesson card */
.lesson-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.lesson-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: transform 0.1s, border-color 0.2s, box-shadow 0.2s;
}

.lesson-card:active {
  transform: scale(0.98);
}

.lesson-card.current {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.lesson-card.completed {
  border-color: var(--success);
  background: var(--success-bg);
}

.lesson-card.locked {
  opacity: 0.5;
  cursor: default;
}

.lesson-card.locked:active {
  transform: none;
}

.lesson-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.lesson-icon.completed {
  background: var(--success);
  color: #fff;
}

.lesson-icon.current {
  background: var(--primary);
  color: #fff;
}

.lesson-icon.locked {
  background: var(--border);
  color: var(--text-3);
}

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

.lesson-number {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
}

.lesson-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lesson-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: 2px;
}

.lesson-progress-mini {
  width: 60px;
  height: 3px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.lesson-progress-mini-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.3s;
}

.lesson-card.completed .lesson-progress-mini-fill {
  background: var(--success);
}

.lesson-card.current .lesson-progress-mini-fill {
  background: var(--primary);
}

.lesson-chevron {
  color: var(--text-3);
  flex-shrink: 0;
}

/* ============================================
   Écran Practice (stub)
   ============================================ */

.practice-screen {
  padding: var(--space-4);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: var(--space-8);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--space-4);
}

.empty-state-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.empty-state-text {
  font-size: 15px;
  color: var(--text-2);
  max-width: 280px;
}

/* ============================================
   Écran Profile
   ============================================ */

.profile-screen {
  padding: var(--space-4);
}

.profile-header {
  text-align: center;
  padding: var(--space-6) 0;
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-full);
  background: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 700;
  margin: 0 auto var(--space-3);
  font-family: var(--font-jp);
}

.profile-name {
  font-size: 24px;
  font-weight: 700;
}

.profile-level {
  font-size: 14px;
  color: var(--text-2);
  margin-top: var(--space-1);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin: var(--space-6) 0;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  text-align: center;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
}

.stat-label {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 2px;
}

.badges-section {
  margin-top: var(--space-6);
}

.badges-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: var(--space-3);
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}

.badge-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  text-align: center;
  transition: opacity 0.2s;
}

.badge-card.locked {
  opacity: 0.35;
}

.badge-card-icon {
  font-size: 32px;
  margin-bottom: var(--space-2);
}

.badge-card-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}

/* ============================================
   Écran Leçon (5 étapes)
   ============================================ */

.lesson-screen {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.lesson-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  padding-top: calc(var(--space-3) + var(--safe-top));
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.lesson-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  border-radius: var(--radius-full);
}

.lesson-close:hover {
  background: var(--bg-subtle);
}

.lesson-steps-bar {
  flex: 1;
  display: flex;
  gap: 4px;
  align-items: center;
}

.lesson-step-dot {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: var(--radius-full);
  transition: background 0.3s;
}

.lesson-step-dot.done {
  background: var(--success);
}

.lesson-step-dot.active {
  background: var(--primary);
}

.lesson-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

/* Quand le quiz est actif, le body laisse le layout remplir tout */
.lesson-body.quiz-active,
.lesson-body:has(.quiz-layout) {
  padding: 0;
  justify-content: stretch;
  align-items: stretch;
  overflow: hidden;
}

/* Mode practice : même traitement */
#practice-body.quiz-active {
  padding: 0;
  justify-content: stretch;
  align-items: stretch;
  overflow: hidden;
}

.lesson-footer {
  flex-shrink: 0;
  padding: var(--space-4);
  padding-bottom: calc(var(--space-4) + var(--safe-bottom));
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}

/* ============================================
   Flashcard
   ============================================ */

.flashcard {
  width: 280px;
  height: 360px;
  perspective: 1000px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.flashcard-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
}

.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
}

.flashcard-back {
  transform: rotateY(180deg);
}

.flashcard-kana {
  font-family: var(--font-jp);
  font-size: 96px;
  font-weight: 400;
  line-height: 1;
  margin-bottom: var(--space-4);
}

.flashcard-romaji {
  font-size: 24px;
  font-weight: 600;
  color: var(--primary);
}

.flashcard-mnemonic {
  font-size: 14px;
  color: var(--text-2);
  text-align: center;
  margin-top: var(--space-4);
  line-height: 1.5;
}

.flashcard-hint {
  font-size: 12px;
  color: var(--text-3);
  margin-top: auto;
}

/* ============================================
   Quiz
   ============================================ */

.quiz-question {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  margin-bottom: var(--space-2);
}

.quiz-prompt {
  font-family: var(--font-jp);
  font-size: 64px;
  text-align: center;
  margin-bottom: var(--space-8);
}

.quiz-choices {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  max-width: 400px;
}

.quiz-choice {
  width: 100%;
  padding: var(--space-4);
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  text-align: left;
}

.quiz-choice:active {
  transform: scale(0.98);
}

.quiz-choice.correct {
  border-color: var(--success);
  background: var(--success-bg);
  color: var(--success);
}

.quiz-choice.wrong {
  border-color: var(--error);
  background: var(--error-bg);
  color: var(--error);
  animation: shake 0.4s ease;
}

.quiz-choice.disabled {
  pointer-events: none;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

@keyframes bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Legacy feedback (used in build.js etc) */
.quiz-feedback {
  text-align: center;
  padding: var(--space-3);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 15px;
  margin-top: var(--space-4);
}

.quiz-feedback.correct {
  background: var(--success-bg);
  color: var(--success);
}

.quiz-feedback.wrong {
  background: var(--error-bg);
  color: var(--error);
}

/* ============================================
   Quiz Duolingo-style layout
   ============================================ */

.quiz-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.quiz-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  overflow-y: auto;
  min-height: 0;
}

.quiz-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 500px;
  margin-bottom: var(--space-2);
}

.quiz-progress-wrap {
  width: 100%;
  max-width: 500px;
  margin-bottom: var(--space-4);
}

/* Listen drill play button */
.listen-play-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  font-size: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(79,70,229,0.3);
  transition: transform 0.1s;
}

.listen-play-btn:active {
  transform: scale(0.9);
}

/* Quiz hint button */
.quiz-hint-btn {
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg-card);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s;
}

.quiz-hint-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.quiz-speak-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 20px;
  cursor: pointer;
  margin-top: var(--space-2);
  transition: transform 0.1s;
}

.quiz-speak-btn:active {
  transform: scale(0.9);
}

/* Feedback bar — slides up from bottom */
.quiz-feedback-bar {
  flex-shrink: 0;
  padding: var(--space-4);
  padding-bottom: calc(var(--space-4) + var(--safe-bottom));
}

.quiz-feedback-bar.correct {
  background: var(--success-bg);
  border-top: 2px solid var(--success);
}

.quiz-feedback-bar.wrong {
  background: var(--error-bg);
  border-top: 2px solid var(--error);
}

.feedback-bar-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 500px;
  margin: 0 auto;
}

.feedback-bar-text {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: 16px;
}

.quiz-feedback-bar.correct .feedback-bar-text {
  color: var(--success);
}

.quiz-feedback-bar.wrong .feedback-bar-text {
  color: var(--error);
}

.feedback-bar-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.quiz-feedback-bar.correct .feedback-bar-icon {
  background: var(--success);
  color: #fff;
}

.quiz-feedback-bar.wrong .feedback-bar-icon {
  background: var(--error);
  color: #fff;
}

.btn-feedback-continue {
  width: 100%;
  padding: var(--space-3) var(--space-6);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s;
}

.btn-feedback-continue:active {
  transform: scale(0.97);
}

.quiz-feedback-bar.correct .btn-feedback-continue {
  background: var(--success);
  color: #fff;
}

.quiz-feedback-bar.wrong .btn-feedback-continue {
  background: var(--error);
  color: #fff;
}

/* ============================================
   Animations utilitaires
   ============================================ */

.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.slide-up {
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.scale-in {
  animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* ============================================
   Utilitaires layout
   ============================================ */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.w-full { width: 100%; }
.text-center { text-align: center; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
/* ============================================
   Toggle switch (iOS style)
   ============================================ */

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 28px;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  left: 23px;
}

/* ============================================
   Panda-sensei — Mascotte
   ============================================ */

.panda-container {
  position: fixed;
  bottom: 84px;
  right: 16px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
  pointer-events: none;
}

.panda-container > * {
  pointer-events: auto;
}

@media (min-width: 768px) {
  .panda-container {
    right: calc(50% - 340px + 16px);
  }
}

@media (min-width: 1200px) {
  .panda-container {
    right: calc(50% - 380px + 16px);
  }
}

.panda-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform 0.2s, border-color 0.2s;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.panda-avatar:active {
  transform: scale(0.9);
}

.panda-avatar.panda-happy {
  border-color: var(--success);
  animation: pandaBounce 0.4s ease;
}

.panda-avatar.panda-sad {
  border-color: var(--error);
}

.panda-avatar.panda-excited {
  border-color: var(--xp);
  animation: pandaBounce 0.4s ease;
}

.panda-avatar.panda-thinking {
  border-color: var(--primary);
}

@keyframes pandaBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.panda-face {
  font-size: 28px;
  line-height: 1;
}

.panda-hint-count {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-card);
}

/* Bubble */
.panda-bubble {
  max-width: 260px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-lg);
  position: relative;
  font-size: 14px;
  line-height: 1.5;
}

.panda-bubble::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 20px;
  width: 16px;
  height: 16px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transform: rotate(45deg);
}

.panda-bubble-appear {
  animation: scaleIn 0.2s ease;
}

.panda-bubble-text {
  color: var(--text);
}

.panda-bubble-action {
  margin-top: var(--space-2);
}

.panda-hint-btn {
  padding: var(--space-2) var(--space-3);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.panda-hint-btn:active {
  transform: scale(0.95);
}

.panda-hint-btn.panda-hint-cancel {
  background: var(--bg-subtle);
  color: var(--text-2);
}

/* ============================================
   Tutorial overlay
   ============================================ */

.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  padding: var(--space-6);
  animation: fadeIn 0.3s ease;
}

.tutorial-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-6);
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.3s ease;
}

.tutorial-panda {
  font-size: 64px;
  margin-bottom: var(--space-4);
}

.tutorial-text {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: var(--space-6);
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tutorial-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: var(--space-4);
}

.tutorial-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.2s;
}

.tutorial-dot.active {
  background: var(--primary);
  transform: scale(1.2);
}

.tutorial-dot.done {
  background: var(--success);
}

.hidden { display: none !important; }

/* ============================================
   Responsive — iPad & Mac
   ============================================ */

/* Tablet+ : composants plus spacieux */
@media (min-width: 768px) {
  .flashcard {
    width: 340px;
    height: 420px;
  }

  .flashcard-kana {
    font-size: 112px;
  }

  .quiz-choices {
    max-width: 500px;
  }

  .quiz-choice {
    padding: var(--space-5);
    font-size: 18px;
  }

  .onboard-screen {
    padding: var(--space-12);
  }

  .lesson-body {
    padding: var(--space-8);
  }

  .learn-screen {
    padding: var(--space-5);
  }

  .practice-screen {
    padding: var(--space-5);
  }

  .profile-screen {
    padding: var(--space-5);
  }

  /* Grilles à 2 colonnes sur tablette */
  .lesson-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
  }

  .badges-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .stats-grid {
    gap: var(--space-4);
  }
}

/* Desktop : grilles à 3 colonnes */
@media (min-width: 1024px) {
  .badges-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* Landscape : flashcard plus compacte */
@media (orientation: landscape) and (max-height: 600px) {
  .flashcard {
    width: 260px;
    height: 300px;
  }

  .flashcard-kana {
    font-size: 72px;
  }

  .lesson-body {
    padding: var(--space-4);
  }
}

/* Hover states pour desktop (pas de touch) */
@media (hover: hover) {
  .lesson-card:hover:not(.locked) {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
  }

  .continue-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(79,70,229,0.4);
  }

  .quiz-choice:hover:not(.disabled) {
    border-color: var(--primary);
    background: var(--primary-bg);
  }

  .practice-mode:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
  }

  .tab:hover {
    color: var(--primary);
  }

  .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79,70,229,0.3);
  }

  .badge-card:not(.locked):hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }
}

/* Transitions pour les hover */
.lesson-card,
.continue-card,
.practice-mode,
.badge-card {
  transition: transform 0.15s ease, border-color 0.2s, box-shadow 0.2s;
}

/* Curseur pointer sur les éléments interactifs desktop */
@media (hover: hover) {
  .card-flat[data-dlg],
  .card-flat[data-cat],
  .card-flat[style*="cursor:pointer"],
  .practice-mode {
    cursor: pointer;
  }
}

/* ============================================
   Romaji hint — tap to reveal
   ============================================ */

.romaji-hint {
  display: inline-block;
  position: relative;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.romaji-hint-text {
  font-size: 14px;
  color: var(--primary);
  font-weight: 500;
  transition: opacity 0.2s, filter 0.2s;
}

.romaji-hint-text.blurred {
  filter: blur(5px);
  opacity: 0.5;
  user-select: none;
}

.romaji-hint-text.blurred:hover,
.romaji-hint-text.blurred:active {
  filter: blur(0);
  opacity: 1;
}

.romaji-hint-label {
  font-size: 11px;
  color: var(--text-3);
  text-align: center;
  margin-top: 2px;
}

/* Auto-reveal for beginners (lessons < 5) */
.romaji-hint.auto-reveal .romaji-hint-text {
  filter: none;
  opacity: 1;
}

/* ============================================
   Quiz combo streak (Duolingo-style)
   ============================================ */

.quiz-combo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font-size: 16px;
  font-weight: 700;
  color: var(--xp);
  min-height: 28px;
  margin-bottom: var(--space-2);
  transition: transform 0.2s;
}

.quiz-combo.pulse {
  animation: comboPulse 0.3s ease;
}

@keyframes comboPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.quiz-combo.mega {
  color: var(--streak);
  font-size: 20px;
}

/* ============================================
   XP floating animation
   ============================================ */

.xp-float {
  position: fixed;
  pointer-events: none;
  font-size: 18px;
  font-weight: 700;
  color: var(--xp);
  z-index: 1000;
  animation: xpFloat 1.2s ease forwards;
}

@keyframes xpFloat {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  50% { opacity: 1; transform: translateY(-30px) scale(1.2); }
  100% { opacity: 0; transform: translateY(-60px) scale(0.8); }
}

/* ============================================
   Confetti burst
   ============================================ */

.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confettiFall 2s ease forwards;
}

@keyframes confettiFall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
  100% { opacity: 0; transform: translateY(100vh) rotate(720deg) scale(0.3); }
}

/* ============================================
   Correct answer glow
   ============================================ */

.quiz-choice.correct {
  border-color: var(--success);
  background: var(--success-bg);
  color: var(--success);
  animation: correctGlow 0.4s ease;
}

@keyframes correctGlow {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0.1); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
