/* ═══════════════════════════════════════════════════════════════════════════
   AR — feuille de style globale
   Mobile-first : les étudiants travaillent majoritairement sur téléphone.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --fond:        #f6f7fb;
  --surface:     #ffffff;
  --surface-2:   #f0f2f8;
  --bordure:     #e2e5ee;
  --bordure-fort:#cdd2e0;
  --texte:       #1a1d29;
  --texte-doux:  #5c6379;
  --texte-faible:#8a90a3;

  --primaire:      #5b4bdb;
  --primaire-fort: #4636c4;
  --primaire-doux: #eeebfd;
  --accent:        #00b3a4;
  --accent-doux:   #e0f7f4;

  --succes: #12915f;  --succes-doux: #e2f5ec;
  --alerte: #b8730a;  --alerte-doux: #fdf1dd;
  --danger: #c8382f;  --danger-doux: #fce9e8;

  --r-s: 8px;  --r-m: 12px;  --r-l: 18px;  --r-xl: 26px;
  --ombre-1: 0 1px 2px rgba(20,22,40,.06), 0 1px 3px rgba(20,22,40,.05);
  --ombre-2: 0 4px 12px rgba(20,22,40,.08), 0 2px 4px rgba(20,22,40,.04);
  --ombre-3: 0 12px 32px rgba(20,22,40,.14);
  --nav-h: 60px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond:        #12141c;
    --surface:     #1b1e28;
    --surface-2:   #232733;
    --bordure:     #2e3341;
    --bordure-fort:#404657;
    --texte:       #e9ebf2;
    --texte-doux:  #a3aabd;
    --texte-faible:#767d92;
    --primaire:      #8478f0;
    --primaire-fort: #9b91f5;
    --primaire-doux: #262247;
    --accent:        #2ad4c3;
    --accent-doux:   #10322f;
    --succes: #3fc98d;  --succes-doux: #12301f;
    --alerte: #e0a034;  --alerte-doux: #33260e;
    --danger: #f0736a;  --danger-doux: #34191a;
    --ombre-1: 0 1px 2px rgba(0,0,0,.35);
    --ombre-2: 0 4px 12px rgba(0,0,0,.4);
    --ombre-3: 0 12px 32px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--texte);
  background: var(--fond);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 650; letter-spacing: -.015em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p  { margin: 0 0 1em; }
a  { color: var(--primaire); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Barre de navigation ──────────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--bordure);
}
.nav-marque {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 1.02rem; color: var(--texte);
  letter-spacing: -.02em; white-space: nowrap;
}
.nav-marque:hover { text-decoration: none; }
.nav-logo {
  width: 30px; height: 30px; flex: 0 0 auto;
  display: grid; place-items: center;
}
.nav-logo svg { display: block; }
.nav-liens { display: flex; gap: 2px; margin-left: 10px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav-liens::-webkit-scrollbar { display: none; }
.nav-lien {
  padding: 7px 12px; border-radius: var(--r-s);
  color: var(--texte-doux); font-weight: 500; font-size: .92rem; white-space: nowrap;
}
.nav-lien:hover { background: var(--surface-2); color: var(--texte); text-decoration: none; }
.nav-lien.actif { background: var(--primaire-doux); color: var(--primaire-fort); font-weight: 600; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--primaire-doux); color: var(--primaire-fort);
  font-weight: 700; font-size: .78rem; letter-spacing: .02em;
  border: none; cursor: pointer;
}
.avatar.sm { width: 26px; height: 26px; font-size: .65rem; }

/* Menu déroulant */
.menu { position: relative; }
.menu-panneau {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px;
  background: var(--surface); border: 1px solid var(--bordure);
  border-radius: var(--r-m); box-shadow: var(--ombre-3);
  padding: 6px; display: none; z-index: 60;
}
.menu.ouvert .menu-panneau { display: block; }
.menu-panneau a, .menu-panneau button {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 9px 11px; border: 0; background: none; border-radius: var(--r-s);
  color: var(--texte); font: inherit; font-size: .92rem; text-align: left; cursor: pointer;
}
.menu-panneau a:hover, .menu-panneau button:hover { background: var(--surface-2); text-decoration: none; }
.menu-entete { padding: 10px 11px; border-bottom: 1px solid var(--bordure); margin-bottom: 6px; }
.menu-entete strong { display: block; font-size: .93rem; }
.menu-entete span { font-size: .8rem; color: var(--texte-faible); }

/* ── Mise en page ─────────────────────────────────────────────────────────── */
.page { max-width: 1180px; margin: 0 auto; padding: 24px 16px 80px; }
.page.etroite { max-width: 780px; }

.entete-page {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}
.entete-page h1 { margin: 0; }
.entete-page .sous { color: var(--texte-doux); font-size: .93rem; margin: 4px 0 0; }

.grille { display: grid; gap: 16px; }
.grille.c2 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grille.c3 { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.grille.c4 { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

/* ── Cartes ───────────────────────────────────────────────────────────────── */
.carte {
  background: var(--surface); border: 1px solid var(--bordure);
  border-radius: var(--r-l); padding: 18px; box-shadow: var(--ombre-1);
}
.carte.compacte { padding: 14px; }
a.carte { color: inherit; display: block; transition: box-shadow .16s, transform .16s, border-color .16s; }
a.carte:hover {
  text-decoration: none; box-shadow: var(--ombre-2);
  transform: translateY(-2px); border-color: var(--bordure-fort);
}
.carte-titre { font-weight: 650; font-size: 1.02rem; margin: 0 0 4px; }
.carte-meta { font-size: .85rem; color: var(--texte-faible); }

/* ── Boutons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; min-height: 40px;
  border: 1px solid var(--bordure-fort); border-radius: var(--r-s);
  background: var(--surface); color: var(--texte);
  font: inherit; font-size: .92rem; font-weight: 550;
  cursor: pointer; white-space: nowrap; transition: background .14s, border-color .14s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primaire { background: var(--primaire); border-color: var(--primaire); color: #fff; }
.btn-primaire:hover { background: var(--primaire-fort); border-color: var(--primaire-fort); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); background: var(--danger); }
.btn-discret { border-color: transparent; background: transparent; color: var(--texte-doux); }
.btn-discret:hover { background: var(--surface-2); }
.btn-bloc { width: 100%; }
.btn-sm { padding: 5px 11px; min-height: 32px; font-size: .85rem; }
.btn-lg { padding: 13px 24px; min-height: 50px; font-size: 1rem; }

/* ── Formulaires ──────────────────────────────────────────────────────────── */
.champ { margin-bottom: 16px; }
.champ label, .label {
  display: block; margin-bottom: 6px;
  font-size: .87rem; font-weight: 600; color: var(--texte-doux);
}
.champ .aide { font-size: .82rem; color: var(--texte-faible); margin-top: 5px; }
/* `input:not([type])` est indispensable : un <input> sans attribut type explicite
   ne correspond PAS à input[type=text] — les sélecteurs d'attribut lisent
   l'attribut écrit, pas le type par défaut. */
input:not([type]),
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], input[type=search],
input[type=url], input[type=tel], select, textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--bordure-fort); border-radius: var(--r-s);
  background: var(--surface); color: var(--texte);
  font: inherit; font-size: 16px; /* 16px : empêche le zoom auto sur iOS */
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
input:not([type=checkbox]):not([type=radio]):focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primaire);
  box-shadow: 0 0 0 3px var(--primaire-doux);
}
.ligne-champs { display: flex; gap: 12px; flex-wrap: wrap; }
.ligne-champs > * { flex: 1 1 180px; }

.case { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 9px; cursor: pointer; }
.case input { width: auto; margin: 3px 0 0; flex: 0 0 auto; accent-color: var(--primaire); }
.case span { font-size: .93rem; }

/* ── Étiquettes / badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 99px;
  font-size: .76rem; font-weight: 650; letter-spacing: .01em;
  background: var(--surface-2); color: var(--texte-doux);
}
.badge.primaire { background: var(--primaire-doux); color: var(--primaire-fort); }
.badge.succes   { background: var(--succes-doux);   color: var(--succes); }
.badge.alerte   { background: var(--alerte-doux);   color: var(--alerte); }
.badge.danger   { background: var(--danger-doux);   color: var(--danger); }
.badge.accent   { background: var(--accent-doux);   color: var(--accent); }

/* ── Messages ─────────────────────────────────────────────────────────────── */
.message {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 13px 15px; border-radius: var(--r-m); margin-bottom: 18px;
  font-size: .92rem; border: 1px solid transparent;
}
.message.info    { background: var(--primaire-doux); color: var(--primaire-fort); }
.message.succes  { background: var(--succes-doux);   color: var(--succes); }
.message.alerte  { background: var(--alerte-doux);   color: var(--alerte); }
.message.danger  { background: var(--danger-doux);   color: var(--danger); }
.message strong  { font-weight: 700; }
.message a { color: inherit; text-decoration: underline; }

/* ── État vide ────────────────────────────────────────────────────────────── */
.vide {
  text-align: center; padding: 56px 24px; color: var(--texte-faible);
  border: 1.5px dashed var(--bordure-fort); border-radius: var(--r-l);
  background: var(--surface);
}
.vide .icone { font-size: 2.6rem; display: block; margin-bottom: 12px; opacity: .55; }
.vide h3 { color: var(--texte-doux); margin-bottom: 6px; }
.vide p { margin-bottom: 18px; font-size: .92rem; }

/* ── Tableaux ─────────────────────────────────────────────────────────────── */
.tableau-conteneur { overflow-x: auto; border: 1px solid var(--bordure); border-radius: var(--r-m); background: var(--surface); }
table.tableau { width: 100%; border-collapse: collapse; font-size: .91rem; }
table.tableau th {
  text-align: left; padding: 11px 14px; font-size: .78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: var(--texte-faible);
  background: var(--surface-2); border-bottom: 1px solid var(--bordure); white-space: nowrap;
}
table.tableau td { padding: 11px 14px; border-bottom: 1px solid var(--bordure); vertical-align: middle; }
table.tableau tr:last-child td { border-bottom: 0; }
table.tableau tbody tr:hover { background: var(--surface-2); }

/* ── Statistiques ─────────────────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--r-m); padding: 14px 16px; }
.stat .valeur { font-size: 1.75rem; font-weight: 700; line-height: 1.1; letter-spacing: -.03em; }
.stat .libelle { font-size: .8rem; color: var(--texte-faible); margin-top: 2px; }

/* ── Code d'inscription ───────────────────────────────────────────────────── */
.code-classe {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 1.5rem; font-weight: 700; letter-spacing: .22em;
  padding: 10px 18px; border-radius: var(--r-m);
  background: var(--primaire-doux); color: var(--primaire-fort);
  display: inline-block;
}

/* ── Utilitaires ──────────────────────────────────────────────────────────── */
.rangee { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rangee.entre { justify-content: space-between; }
.pousse { margin-left: auto; }
.doux   { color: var(--texte-doux); }
.faible { color: var(--texte-faible); font-size: .86rem; }
.centre { text-align: center; }
.mt-0{margin-top:0}.mt-1{margin-top:8px}.mt-2{margin-top:16px}.mt-3{margin-top:24px}.mt-4{margin-top:32px}
.mb-0{margin-bottom:0}.mb-1{margin-bottom:8px}.mb-2{margin-bottom:16px}.mb-3{margin-bottom:24px}
.sr { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }

@media (max-width: 640px) {
  .page { padding: 18px 13px 90px; }
  h1 { font-size: 1.35rem; }
  .nav-marque span { display: none; }
  .entete-page { margin-bottom: 18px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Formes et animations des éléments de scène
   Partagées par l'éditeur, le player et la simulation : une seule
   définition, donc un rendu identique partout.
   ═══════════════════════════════════════════════════════════════════════════ */

.forme-rect     { border-radius: 10px; }
.forme-cercle   { border-radius: 50%; }
.forme-barre    { border-radius: 999px; }
.forme-fleche   { clip-path: polygon(0% 28%, 62% 28%, 62% 2%, 100% 50%, 62% 98%, 62% 72%, 0% 72%); }
/* Flèches « à trait » : une tige fine, terminée par une pointe pleine ou par un chevron. */
.forme-fleche_fine    { clip-path: polygon(0% 42%, 78% 42%, 78% 14%, 100% 50%, 78% 86%, 78% 58%, 0% 58%); }
.forme-fleche_ouverte { clip-path: polygon(0% 45%, 86% 45%, 70% 12%, 79% 4%, 100% 50%, 79% 96%, 70% 88%, 86% 55%, 0% 55%); }
.forme-triangle { clip-path: polygon(50% 2%, 98% 98%, 2% 98%); }
.forme-etoile   { clip-path: polygon(50% 2%, 61% 35%, 97% 35%, 68% 57%, 79% 92%, 50% 71%, 21% 92%, 32% 57%, 3% 35%, 39% 35%); }
.forme-bulle    { clip-path: polygon(0% 0%, 100% 0%, 100% 76%, 40% 76%, 24% 100%, 22% 76%, 0% 76%); }

/* Les animations portent sur le contenu, jamais sur la boîte : celle-ci est
   déjà positionnée par un transform (translate + rotate) qu'il ne faut pas écraser. */
@keyframes raApparition { from { opacity:0; transform:scale(var(--anim-apparition,.88)); } to { opacity:1; transform:scale(1); } }
@keyframes raPulsation { 0%,100% { transform:scale(1); } 50% { transform:scale(var(--anim-echelle,1.07)); } }
@keyframes raFlottement { 0%,100% { transform:translateY(calc(-1 * var(--anim-distance,3%))); } 50% { transform:translateY(var(--anim-distance,3%)); } }
@keyframes raClignotement { 0%,100% { opacity:1; } 50% { opacity:var(--anim-opacite,.4); } }
@keyframes raGlissement { from { transform:translateX(var(--anim-entree,-24%)); } to { transform:translateX(0); } }
@keyframes raRebond { 0%,100% { transform:translateY(0); } 50% { transform:translateY(var(--anim-rebond,-12%)); } }
@keyframes raBalancement { 0%,100% { transform:rotate(calc(-1 * var(--anim-angle,6deg))); } 50% { transform:rotate(var(--anim-angle,6deg)); } }
@keyframes raZoom { from { transform:scale(var(--anim-zoom,.6)); } to { transform:scale(1); } }
.contenu.anim-apparition { animation:raApparition .6s ease-out both; }
.contenu.anim-pulsation { animation:raPulsation 1.6s ease-in-out infinite both; }
.contenu.anim-flottement { animation:raFlottement 2.8s ease-in-out infinite both; }
.contenu.anim-clignotement { animation:raClignotement 1.4s ease-in-out infinite both; }
.contenu.anim-glissement { animation:raGlissement .7s ease-out both; }
.contenu.anim-rebond { animation:raRebond 1.4s ease-out infinite both; }
.contenu.anim-balancement { animation:raBalancement 2.4s ease-in-out infinite both; }
.contenu.anim-zoom { animation:raZoom .7s cubic-bezier(.34,1.56,.64,1) both; }

/* Respecte le réglage système : une animation permanente peut gêner. */
@media (prefers-reduced-motion: reduce) {
  .contenu[class*="anim-"], [class*="anim-"] > .contenu { animation: none !important; }
}

/* ── Carte à gratter ──────────────────────────────────────────────────────── */
/* Pas de padding ici : le couvercle est positionné en inset:0 sur cette boîte,
   une marge intérieure le décalerait. Le rognage est levé pour qu'un contenu
   trop long déborde visiblement au lieu de disparaître. */
.contenu.gratter { position: relative; overflow: visible; }
.gratter-fond {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: .35em .6em; border-radius: 10px; text-align: center;
  word-break: break-word; white-space: pre-wrap; line-height: 1.2;
  overflow: visible;   /* jamais de texte coupé en silence */
}
.gratter-couvercle {
  position: absolute; inset: 0; border-radius: 10px;
  touch-action: none; cursor: crosshair;
}
.gratter-consigne {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none; color: rgba(255,255,255,.92); font-weight: 650;
  text-shadow: 0 1px 3px rgba(0,0,0,.45); letter-spacing: .02em;
}
.gratter-revele .gratter-couvercle,
.gratter-revele .gratter-consigne { display: none; }

/* Masque opaque et contenu borné : rien ne dépasse avant d’être gratté. */
.contenu.gratter { overflow:hidden; border-radius:10px; }
.gratter-fond { overflow:hidden; }
canvas.gratter-couvercle { width:100%; height:100%; display:block; }
.contenu.forme > img { width:100%; height:100%; object-fit:fill; display:block; }
.forme-losange { clip-path:polygon(50% 0,100% 50%,50% 100%,0 50%); }
.forme-hexagone { clip-path:polygon(25% 0,75% 0,100% 50%,75% 100%,25% 100%,0 50%); }
.forme-coeur { clip-path:polygon(50% 20%,30% 0,10% 0,0 25%,5% 50%,50% 100%,95% 50%,100% 25%,90% 0,70% 0); }
.forme-croix { clip-path:polygon(32% 0,68% 0,68% 32%,100% 32%,100% 68%,68% 68%,68% 100%,32% 100%,32% 68%,0 68%,0 32%,32% 32%); }
