/* LinguaBoost — effets visuels (relief, inclinaison, feedback des quiz, flashcards).
   À charger après styles.css. Les effets animés ne s'activent que si js/fx/core.js
   a posé html[data-fx="full" | "lite"] ; en « off » (ou sans JS), on garde la version 2D.
   La règle prefers-reduced-motion de styles.css coupe de toute façon les animations CSS. */

:root { --fx-gold: #F5B83D; --fx-gold-deep: #B7791F; --fx-glare: rgba(255,255,255,.35); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --fx-gold: #FFC857; --fx-glare: rgba(255,255,255,.10); } }
:root[data-theme="dark"] { --fx-gold: #FFC857; --fx-glare: rgba(255,255,255,.10); }

/* ---- Relief : lettres extrudées (titres clés) ---- */
:root[data-fx]:not([data-fx="off"]) :is(.hero h1 .hl-en, .hero h1 .hl-es, .hero h1 .hl-pt, #result .level),
:root[data-fx]:not([data-fx="off"]) .lang-card[data-emblem]::before {
  text-shadow:
    0 1px 0 color-mix(in srgb, currentColor 70%, #000),
    0 2px 0 color-mix(in srgb, currentColor 58%, #000),
    0 3px 0 color-mix(in srgb, currentColor 46%, #000),
    0 5px 6px rgba(28,27,34,.14);
}

/* ---- Cartes inclinables [data-tilt] (cartes de langues) ---- */
[data-tilt] { position: relative; }
/* Mot emblématique en relief, purement décoratif (« / "" » le masque aux lecteurs d'écran). */
.lang-card[data-emblem]::before {
  content: attr(data-emblem); content: attr(data-emblem) / "";
  font-family: var(--font-display); font-weight: 600; font-size: 34px; line-height: 1;
  color: var(--accent); align-self: flex-start; transform: rotate(-3deg); transform-origin: left center;
}
:root[data-fx]:not([data-fx="off"]) [data-tilt] {
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transform-style: preserve-3d; transition: transform .6s cubic-bezier(.2,.8,.2,1);
}
:root[data-fx]:not([data-fx="off"]) [data-tilt].is-tilting { transition: transform .1s linear; }
:root[data-fx]:not([data-fx="off"]) .lang-card[data-emblem]::before { transform: translateZ(50px) rotate(-3deg); }
:root[data-fx]:not([data-fx="off"]) .lang-card h3 { transform: translateZ(24px); }
/* Reflet qui suit le pointeur */
:root[data-fx]:not([data-fx="off"]) [data-tilt]::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 0%), var(--fx-glare), transparent 55%);
  opacity: 0; transition: opacity .4s;
}
:root[data-fx]:not([data-fx="off"]) [data-tilt].is-tilting::after { opacity: 1; }
/* Au doigt : pas d'inclinaison (pas de survol), juste un léger enfoncement. */
@media (pointer: coarse) {
  :root[data-fx]:not([data-fx="off"]) [data-tilt]:active { transform: scale(.985); transition-duration: .15s; }
}

/* ---- Quiz : rebond (bonne réponse), tremblement (erreur) ---- */
.option { transition: transform .12s, border-color .15s, background .15s, box-shadow .3s; }
:root[data-fx]:not([data-fx="off"]) .option:active:not(:disabled) { transform: scale(.98); }
:root[data-fx]:not([data-fx="off"]) .option.correct.fx-hit {
  animation: fx-bounce .55s cubic-bezier(.3,1.6,.5,1);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--fx-gold) 40%, transparent);
}
:root[data-fx]:not([data-fx="off"]) :is(.option.wrong, .gap-select.wrong) { animation: fx-shake .42s cubic-bezier(.36,.07,.19,.97); }
@keyframes fx-bounce {
  0% { transform: scale(1); } 35% { transform: translateY(-4px) scale(1.035); }
  65% { transform: translateY(1px) scale(.99); } 100% { transform: none; }
}
@keyframes fx-shake {
  10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-5px); } 40%, 60% { transform: translateX(5px); }
}
.fx-particles { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 70; }

/* ---- Flashcards (étape Vocabulaire) ---- */
.fc { margin-bottom: 20px; }
.vocab[hidden], .fc [hidden] { display: none; }
.fc-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.fc-count { font-size: 14px; font-weight: 600; color: var(--muted); margin: 0; }
.fc-deck { position: relative; max-width: 520px; margin: 0 auto 28px; perspective: 1200px; }
.fc-stack span {
  position: absolute; inset: 0; border-radius: var(--radius); background: var(--surface-solid, var(--surface));
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.fc-stack span:nth-child(1) { transform: translateY(16px) scale(.92); opacity: .55; }
.fc-stack span:nth-child(2) { transform: translateY(8px) scale(.96); opacity: .8; }
.fc-stack[data-left="1"] span:nth-child(1), .fc-stack[data-left="0"] span { display: none; }
.fc-card {
  position: relative; display: block; width: 100%; padding: 0; border: 0; background: none;
  cursor: pointer; text-align: center; color: inherit; border-radius: var(--radius);
  transition: transform .3s cubic-bezier(.4,0,.2,1), opacity .3s;
}
.fc-inner {
  display: grid; transform-style: preserve-3d; border-radius: var(--radius);
  transition: transform .65s cubic-bezier(.2,.8,.2,1);
}
.fc-card[aria-pressed="true"] .fc-inner { transform: rotateY(180deg); }
.fc-face {
  grid-area: 1 / 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px;
  min-height: 230px; padding: 28px 24px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); box-shadow: var(--shadow);
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
.fc-front { border-top: 5px solid var(--accent); }
.fc-back { transform: rotateY(180deg); background: var(--accent-soft); border-color: transparent; }
.fc-word { font-family: var(--font-display); font-weight: 600; font-size: clamp(24px, 5vw, 32px); line-height: 1.2; }
.fc-hint { font-size: 13px; color: var(--muted); }
.fc-tr { font-size: 20px; font-weight: 600; }
.fc-ex { font-style: italic; font-size: 15px; color: var(--muted); }
.fc-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.fc-done { text-align: center; padding: 28px 20px; }
.fc-done strong { display: block; font-family: var(--font-display); font-size: 28px; margin-bottom: 4px; }
:root[data-fx]:not([data-fx="off"]) .fc-card:hover:not(.fc-out-right):not(.fc-out-left) { transform: translateY(-3px); }
.fc-out-right { transform: translateX(60%) rotate(8deg); opacity: 0; }
.fc-out-left { transform: translateX(-60%) rotate(-8deg); opacity: 0; }
.fc-in { animation: fc-in .35s cubic-bezier(.2,.8,.2,1); }
@keyframes fc-in { from { transform: translateY(14px) scale(.96); opacity: .4; } to { transform: none; opacity: 1; } }

/* ---- Globe du hero (js/fx/globe.js) ---- */
.globe-scene { position: relative; display: grid; place-items: center; }
.hero-grid > :first-child { position: relative; z-index: 1; } /* le texte du hero reste au-dessus du globe */
.globe-scene .phone { position: relative; z-index: 1; width: 100%; }
.globe {
  position: absolute; z-index: 0; aspect-ratio: 1; width: min(620px, 125vw);
  left: 50%; top: 50%; transform: translate(-50%, -50%);
}
@media (min-width: 960px) {
  .globe { transform: translate(-70%, -48%); }
  /* bord gauche estompé : aucun point derrière le texte du hero */
  .globe canvas { -webkit-mask-image: linear-gradient(90deg, transparent 6%, #000 30%); mask-image: linear-gradient(90deg, transparent 6%, #000 30%); }
}
.globe canvas { width: 100%; height: 100%; opacity: 0; transition: opacity 1.2s ease; cursor: grab; touch-action: pan-y; }
.globe canvas.pret { opacity: 1; }
.globe canvas:active { cursor: grabbing; }
.globe-fallback { border-radius: 50%; background: radial-gradient(circle at 35% 35%, var(--brand-soft), transparent 65%); }
.globe-bulle {
  position: absolute; left: 0; top: 0; pointer-events: none; white-space: nowrap;
  margin: -46px 0 0 -10px; padding: 6px 12px; border-radius: 14px 14px 14px 4px;
  font-weight: 700; font-size: 14px; color: var(--on-accent); background: var(--accent);
  box-shadow: 0 6px 16px rgba(28,27,34,.18);
  opacity: 0; scale: .6; transform-origin: 0 100%; transition: opacity .35s, scale .35s cubic-bezier(.3,1.6,.5,1);
}
.globe-bulle[data-cle="en"] { --accent: var(--en); } .globe-bulle[data-cle="es"] { --accent: var(--es); }
.globe-bulle[data-cle="pt"] { --accent: var(--pt); } .globe-bulle[data-cle="brand"] { --accent: var(--brand); }
.globe-bulle.on { opacity: 1; scale: 1; }

/* ---- Ma progression (js/fx/progression.js, parcours.html) ---- */
.prog-card { padding: 24px; margin-top: 24px; }
.prog-card > h2 { font-size: 24px; }
.prog-h3 { font-size: 18px; margin: 28px 0 14px; }
.prog-astuce { font-size: 14px; margin: 12px 0 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { display: grid; justify-items: center; gap: 2px; padding: 16px 8px; border-radius: var(--radius-sm); background: var(--surface-2); text-align: center; }
.stat strong { font-family: var(--font-display); font-size: clamp(28px, 6vw, 38px); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat small { font-size: 13px; color: var(--muted); }
.stat-ico { font-size: 26px; line-height: 1; }
.stat.serie strong { color: var(--es); }
:root[data-fx]:not([data-fx="off"]) .stat.serie.vive .stat-ico { animation: flamme 1.6s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes flamme { 0%, 100% { transform: scale(1) rotate(-3deg); } 50% { transform: scale(1.14, 1.2) rotate(3deg); } }

/* Chemin d'aventure : îles en zigzag reliées par un sentier pointillé */
.chemin { list-style: none; margin: 0 auto; padding: 0; display: grid; gap: 6px; position: relative; max-width: 640px; }
.chemin::before {
  content: ""; position: absolute; left: 50%; top: 40px; bottom: 40px; width: 0;
  border-left: 3px dashed var(--border); transform: translateX(-50%);
}
.etape-chemin { position: relative; display: flex; justify-content: flex-start; }
.etape-chemin:nth-child(even) { justify-content: flex-end; }
.etape-chemin a {
  display: flex; align-items: center; gap: 14px; width: min(100%, 300px); padding: 8px 14px 8px 8px;
  border-radius: 999px; color: var(--text); text-decoration: none; background: var(--surface);
  border: 1px solid var(--border); position: relative; z-index: 1;
}
.etape-chemin:nth-child(even) a { flex-direction: row-reverse; text-align: right; padding: 8px 8px 8px 14px; }
.etape-chemin a:hover { border-color: var(--accent); }
.ile-txt { display: grid; min-width: 0; }
.ile-txt b { font-size: 15px; } .ile-txt small { font-size: 13px; color: var(--muted); }
.ile { position: relative; flex-shrink: 0; width: 64px; height: 64px; perspective: 400px; display: grid; place-items: center; }
.ile-sol {
  position: absolute; inset: 6px 2px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--surface-2) 60%, #fff), var(--surface-2));
  box-shadow: 0 6px 0 var(--border), 0 10px 14px rgba(28,27,34,.12);
  transform: rotateX(55deg); transition: background .6s, box-shadow .6s;
}
.ile-label { position: relative; font-weight: 800; font-size: 17px; color: var(--muted); transform: translateY(-6px); transition: color .6s; }
/* États (version 2D par défaut : déjà lisibles par la couleur et le texte) */
.etape-chemin[data-etat="fini"] .ile-sol { background: radial-gradient(circle at 35% 30%, #FFE7A8, var(--fx-gold)); box-shadow: 0 6px 0 var(--fx-gold-deep), 0 10px 18px color-mix(in srgb, var(--fx-gold) 45%, transparent); }
.etape-chemin[data-etat="fini"] .ile-label { color: #3B2A06; font-size: 24px; }
.etape-chemin[data-etat="actuel"] .ile-sol, .etape-chemin[data-etat="entame"] .ile-sol { background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--accent) 55%, #fff), var(--accent)); box-shadow: 0 6px 0 color-mix(in srgb, var(--accent) 60%, #000), 0 10px 18px color-mix(in srgb, var(--accent) 35%, transparent); }
.etape-chemin[data-etat="actuel"] .ile-label, .etape-chemin[data-etat="entame"] .ile-label { color: var(--on-accent); }
.etape-chemin[data-etat="actuel"] a, .etape-chemin[data-etat="entame"] a { border-color: var(--accent); }
/* Avec effets : les îles flottent, s'allument une à une au défilement */
:root[data-fx]:not([data-fx="off"]) .etape-chemin .ile { opacity: .35; transform: translateY(14px) scale(.85); transition: opacity .6s, transform .7s cubic-bezier(.3,1.5,.5,1); transition-delay: calc(var(--i) * 60ms); }
:root[data-fx]:not([data-fx="off"]) .etape-chemin.allume .ile { opacity: 1; transform: none; }
:root[data-fx]:not([data-fx="off"]) .etape-chemin.allume .ile-label { animation: flotte 3.2s ease-in-out infinite; animation-delay: calc(var(--i) * -0.5s); }
:root[data-fx]:not([data-fx="off"]) .etape-chemin[data-etat="actuel"].allume .ile-sol { animation: pouls 2s ease-in-out infinite; }
@keyframes flotte { 0%, 100% { transform: translateY(-6px); } 50% { transform: translateY(-11px); } }
@keyframes pouls { 0%, 100% { box-shadow: 0 6px 0 color-mix(in srgb, var(--accent) 60%, #000), 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } 50% { box-shadow: 0 6px 0 color-mix(in srgb, var(--accent) 60%, #000), 0 0 0 12px transparent; } }

/* Étagère de badges : pièces 3D (deux faces + tranche) */
.badges { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px 10px; }
@media (min-width: 640px) { .badges { grid-template-columns: repeat(6, 1fr); } }
.badge-item { display: grid; justify-items: center; gap: 8px; text-align: center; }
.badge-nom { font-size: 13px; font-weight: 600; color: var(--muted); }
.badge-item.obtenu .badge-nom { color: var(--text); }
.piece { position: relative; width: 64px; height: 64px; transform-style: preserve-3d; }
.piece .face, .piece .tranche {
  position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
.piece .face { font-size: 28px; font-weight: 800; background: var(--surface-2); color: var(--muted); border: 3px solid var(--border); }
.piece .avant { transform: translateZ(4px); }
.piece .arriere { transform: rotateY(180deg) translateZ(4px); font-size: 18px; }
.piece .tranche { background: var(--border); transform: translateZ(var(--z)); backface-visibility: visible; }
.obtenu .piece .face { background: radial-gradient(circle at 35% 30%, #FFF1C2, var(--fx-gold) 70%); border-color: var(--fx-gold-deep); color: #3B2A06; }
.obtenu .piece .tranche { background: var(--fx-gold-deep); }
.piece .arriere, .piece .tranche { display: none; }
:root[data-fx]:not([data-fx="off"]) .piece .arriere, :root[data-fx]:not([data-fx="off"]) .piece .tranche { display: grid; }
:root[data-fx]:not([data-fx="off"]) .obtenu .piece { animation: tourne 7s linear infinite; animation-delay: var(--d); }
:root[data-fx]:not([data-fx="off"]) .obtenu:hover .piece { animation-play-state: paused; }
@keyframes tourne { from { transform: rotateY(0); } to { transform: rotateY(360deg); } }

/* Badge de fin de leçon (lecon.html) : la pièce arrive en tournant */
:root[data-fx]:not([data-fx="off"]) .result .badge {
  background: radial-gradient(circle at 35% 30%, #FFF1C2, var(--fx-gold) 70%); color: #3B2A06;
  box-shadow: 0 0 0 4px var(--fx-gold-deep), 0 12px 28px color-mix(in srgb, var(--fx-gold) 45%, transparent);
  animation: arrivee 1.1s cubic-bezier(.2,.8,.2,1);
}
@keyframes arrivee { from { transform: perspective(500px) rotateY(-720deg) scale(.3); opacity: 0; } to { transform: perspective(500px) rotateY(0) scale(1); opacity: 1; } }

/* ---- Alphabets du monde en arrière-plan (js/fx/alphabets.js) ---- */
.fx-glyphes { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.fx-glyphes span { position: absolute; top: 0; color: var(--brand); font-family: Georgia, "Noto Serif", serif; line-height: 1; will-change: transform; }

/* ---- Onde audio 3D (js/fx/onde.js) ---- */
.onde {
  position: fixed; right: 16px; bottom: 92px; z-index: 55; display: grid; gap: 2px; padding: 8px 10px 6px;
  border-radius: 16px; background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(10px);
  border: 1px solid var(--border); box-shadow: var(--shadow); pointer-events: none;
  opacity: 0; transform: translateY(12px) scale(.96); transition: opacity .3s, transform .35s cubic-bezier(.3,1.4,.5,1);
}
.onde.on { opacity: 1; transform: none; }
.onde canvas { width: 200px; height: 64px; display: block; }
.onde-label { font-size: 12px; font-weight: 700; color: var(--muted); }
.onde[data-mode="micro"] .onde-label { color: var(--text); }
body:has(#composer) .onde { top: 76px; bottom: auto; } /* professeur : la zone de saisie occupe le bas */
