/* ═══════════════════════════════════════════════════════════════════════════
   ThaïGuide — Design Tokens centralisés
   Fichier partagé entre le plugin wp-language-v6-premium et le thème thaiguide.
   Lot 5 — Cohérence visuelle + UX gamifiée
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* ── Échelle spacing 4/8 ────────────────────────────────────────────────── */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;

  /* ── Échelle border-radius ──────────────────────────────────────────────── */
  --r-xs: 6px;  --r-sm: 10px; --r-md: 14px; --r-lg: 18px; --r-xl: 24px;
  --r-pill: 999px;

  /* ── Échelle ombres ─────────────────────────────────────────────────────── */
  --sh-1: 0 1px 2px rgba(0,0,0,.10);
  --sh-2: 0 2px 8px rgba(0,0,0,.15);
  --sh-3: 0 4px 16px rgba(0,0,0,.20);
  --sh-4: 0 8px 32px rgba(0,0,0,.30);
  --sh-glow-primary: 0 0 0 3px rgba(var(--c-p-rgb),0.18), 0 4px 16px rgba(var(--c-p-rgb),0.35);
  --sh-glow-gold: 0 0 0 3px rgba(var(--c-gold-rgb),0.18), 0 4px 16px rgba(var(--c-gold-rgb),0.35);

  /* ── Durées de transition ──────────────────────────────────────────────── */
  --dur-instant: .1s;   --dur-fast: .15s;  --dur-base: .25s;
  --dur-slow: .4s;      --dur-xslow: .6s;

  /* ── Easings ───────────────────────────────────────────────────────────── */
  --ease-out: cubic-bezier(0, 0, .2, 1);
  --ease-bounce: cubic-bezier(.34, 1.56, .64, 1);
  --ease-spring: cubic-bezier(.175, .885, .32, 1.275);

  /* ── z-index scale strict (NE PAS dépasser INT32_MAX) ──────────────────── */
  --z-base: 1;
  --z-sticky: 100;
  --z-dropdown: 1000;
  --z-overlay: 9000;
  --z-modal: 9999;
  --z-toast: 10000;
  --z-max: 99999;

  /* ── Palette app dark (existante, centralisée) ──────────────────────────── */
  --tg-bg: var(--c-bg);
  --tg-surface: var(--c-surface);
  --tg-text: var(--c-text);
  --tg-muted: rgba(var(--c-ink-rgb),.55);
  --tg-primary: var(--c-p);
  --tg-primary-dk: var(--c-p-strong);
  --tg-primary-bg: var(--c-p-light);
  --tg-green: var(--c-success);
  --tg-red: var(--c-danger);
  --tg-gold: var(--c-gold);
  --tg-purple: var(--c-violet);

  /* ── Palette modules unifiée (1 couleur = 1 module, partout) ────────────── */
  --mod-vocab: var(--c-p);       /* bleu sky-400 */
  --mod-lessons: var(--c-success);     /* vert green-400 */
  --mod-dialogues: var(--c-violet-light);   /* violet violet-400 */
  --mod-alphabet: var(--c-pink);    /* rose pink-400 */
  --mod-review: var(--c-orange);      /* orange orange-400 */
  --mod-stats: var(--c-gold);       /* jaune yellow-400 */
  --mod-stories: var(--c-gold);     /* ambre amber-400 */
  --mod-niveau: var(--c-violet-light);      /* violet — examens de niveau */
  --mod-revision: var(--c-orange);    /* orange — révision SRS */

  /* ── Palette médailles HARMONISÉE ──────────────────────────────────────── */
  /* Référence : gradients SVG du plugin tg-tarifs (seule source de vérité)   */
  --medal-bronze: #cd7f32;    --medal-bronze-2: #8b4513;
  --medal-silver: #a8a9ad;    --medal-silver-2: #777;
  --medal-gold: #ffd700;      --medal-gold-2: #c8860a;
  --medal-platinum: #a0c4ff;  --medal-platinum-2: #5a8fbe;
  --grad-bronze:   linear-gradient(135deg, #e8a060, #cd7f32 50%, #8b4513);
  --grad-silver:   linear-gradient(135deg, #e8e8e8, #aaaaaa 50%, #777);
  --grad-gold:     linear-gradient(135deg, #ffe44d, #ffd700 50%, #c8860a);
  --grad-platinum: linear-gradient(135deg, #d4eeff, #90bfe0 50%, #5a8fbe);

  /* ── Polices ───────────────────────────────────────────────────────────── */
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'DM Mono', ui-monospace, monospace;
}

/* ═══════════════════════════════════════════════════════════════════════════
   prefers-reduced-motion — WCAG 2.3.3 (a11y critique pour vestibulaire)
   Désactive toutes les animations pour les utilisateurs sensibles au mouvement.
   ═══════════════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   MICRO-ANIMATIONS GAMIFIÉES
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Ripple au clic bouton (Material-style) ──────────────────────────────── */
.wplc6p-btn, .demo-btn {
  position: relative;
  overflow: hidden;
  transition: transform var(--dur-instant) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.wplc6p-btn:active, .demo-btn:active {
  transform: translateY(2px) scale(.97);
  border-bottom-width: 1px;
}
.wplc6p-btn::after, .demo-btn::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 0; height: 0;
  border-radius: 50%;
  background: rgba(var(--c-ink-rgb),0.4);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.wplc6p-btn.is-rippling::after, .demo-btn.is-rippling::after {
  animation: tg-ripple .5s var(--ease-out);
}
@keyframes tg-ripple {
  0%   { width: 0; height: 0; opacity: .5; }
  100% { width: 320px; height: 320px; opacity: 0; }
}

/* ── Quiz : retours haptiques visuels ────────────────────────────────────── */
@keyframes tg-quiz-correct {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}
@keyframes tg-quiz-shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-8px); }
  40%      { transform: translateX(8px); }
  60%      { transform: translateX(-6px); }
  80%      { transform: translateX(4px); }
}
.wplc6p-answer-btn.correct,
.wplc6p-tone-choice.correct,
.wplc6p-choice.correct {
  animation: tg-quiz-correct var(--dur-base) var(--ease-bounce);
}
.wplc6p-answer-btn.wrong,
.wplc6p-tone-choice.wrong,
.wplc6p-choice.wrong {
  animation: tg-quiz-shake var(--dur-base) var(--ease-out);
}

/* ── Gain XP : burst doré qui s'envole ───────────────────────────────────── */
@keyframes tg-xp-burst {
  0%   { transform: translateY(0) scale(.8); opacity: 0; }
  20%  { transform: translateY(-10px) scale(1.3); opacity: 1; }
  100% { transform: translateY(-60px) scale(1); opacity: 0; }
}
.tg-xp-pop {
  position: fixed;
  z-index: var(--z-toast);
  font-family: var(--font-sans);
  font-weight: 900;
  font-size: 1.2rem;
  color: var(--medal-gold);
  text-shadow: 0 2px 8px rgba(0,0,0,.4);
  pointer-events: none;
  animation: tg-xp-burst 1s var(--ease-bounce) forwards;
}

/* ── Transitions entre écrans (slide directionnel) ───────────────────────── */
@keyframes tg-screen-enter-right {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes tg-screen-enter-left {
  from { opacity: 0; transform: translateX(-24px); }
  to   { opacity: 1; transform: translateX(0); }
}
.wplc6p-body > * {
  animation: tg-screen-enter-right var(--dur-base) var(--ease-out);
}
.wplc6p-body[data-dir="back"] > * {
  animation: tg-screen-enter-left var(--dur-base) var(--ease-out);
}

/* ── Streak jour validé : check-pop ──────────────────────────────────────── */
@keyframes tg-check-pop {
  0%   { transform: scale(0) rotate(-30deg); }
  60%  { transform: scale(1.3) rotate(8deg); }
  100% { transform: scale(1) rotate(0); }
}
.tg-wk-day.tg-wk-active.tg-wk-just-validated .tg-wk-dot {
  animation: tg-check-pop var(--dur-slow) var(--ease-bounce);
}

/* ── Bottom-nav : pulse du bouton central ────────────────────────────────── */
@keyframes tg-bnav-pulse {
  0%, 100% { box-shadow: 0 6px 20px rgba(var(--c-p-rgb),0.55), 0 0 0 0 rgba(var(--c-p-rgb),0.6); }
  50%      { box-shadow: 0 6px 20px rgba(var(--c-p-rgb),0.55), 0 0 0 12px rgba(var(--c-p-rgb),0); }
}
.wplc6p-bnav-c4 .wplc6p-bnav-icon.tg-pulsing {
  animation: tg-bnav-pulse 2.4s var(--ease-out) infinite;
}
@media (prefers-reduced-motion: reduce) {
  .wplc6p-bnav-c4 .wplc6p-bnav-icon.tg-pulsing { animation: none; }
}
