@import url('https://fonts.googleapis.com/css2?family=Anton&family=Oswald:wght@400;700&family=Inter:wght@400;600&display=swap');

:root {
  --retro-teal:   #127676;
  --retro-orange: #E4632E;
  --retro-jaune:  #E3A535;
  --retro-ink:    #0D1617;
  --retro-paper:  #F2EFE6;
}

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

body {
  background: var(--retro-ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--retro-ink);
  min-height: 100vh;
  line-height: 1.55;
}

.page-frame {
  background: var(--retro-paper);
  border: 4px solid var(--retro-orange);
  min-height: calc(100vh - 24px);
  margin: 12px;
  padding: 32px 28px 40px;
}

/* ---------- En-tête ---------- */
.header-band {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 3px solid var(--retro-teal);
  margin-bottom: 24px;
}
.page-title {
  font-family: 'Anton', Impact, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--retro-teal);
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1;
}
.page-subtitle {
  font-family: 'Oswald', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--retro-orange);
  font-size: 0.95rem;
  margin-top: 6px;
}
/* ---------- Onglets ---------- */
.tabs { display: flex; gap: 10px; margin-bottom: 22px; flex-wrap: wrap; }
.tab {
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.85rem;
  padding: 10px 22px;
  border: 3px solid var(--retro-teal);
  border-radius: 50px;
  background: transparent;
  color: var(--retro-teal);
  cursor: pointer;
}
.tab.is-active { background: var(--retro-teal); color: var(--retro-paper); }
.panel { display: none; }
.panel.is-active { display: block; }

/* ---------- Consignes ---------- */
.consigne {
  background: rgba(18,118,118,0.08);
  border-left: 5px solid var(--retro-teal);
  padding: 14px 18px;
  border-radius: 0 10px 10px 0;
  margin-bottom: 20px;
  font-size: 0.92rem;
}
.consigne p + p { margin-top: 6px; }
.consigne-aide { font-style: italic; color: rgba(13,22,23,0.7); font-size: 0.85rem; }

.section-label {
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--retro-teal);
  border-bottom: 1px solid var(--retro-teal);
  padding-bottom: 4px;
  margin-bottom: 10px;
}

/* ---------- Tableau de bord ---------- */
.scoreboard {
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
  background: var(--retro-ink);
  border-radius: 18px 6px 18px 6px;
  padding: 14px 22px;
  margin-bottom: 20px;
}
.score-item { display: flex; flex-direction: column; }
.score-val {
  font-family: 'Anton', sans-serif;
  font-size: 1.7rem;
  color: var(--retro-jaune);
  line-height: 1;
}
.score-lab {
  font-family: 'Oswald', sans-serif;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(242,239,230,0.72);
  margin-top: 3px;
}
.scoreboard .retro-btn-pill { margin-left: auto; }

.retro-btn-pill {
  display: inline-flex;
  border-radius: 50px;
  border: 3px solid var(--retro-teal);
  overflow: hidden;
  cursor: pointer;
  background: none;
  padding: 0;
  font: inherit;
}
.retro-btn-pill .label {
  background: var(--retro-jaune);
  color: var(--retro-ink);
  padding: 0.5rem 1.2rem;
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.8rem;
}
.retro-btn-pill .icon {
  background: var(--retro-orange);
  color: var(--retro-paper);
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

/* ---------- Pioche ---------- */
.pioche-zone { margin-bottom: 22px; }
.pioche { min-height: 132px; display: flex; align-items: flex-start; gap: 26px; flex-wrap: wrap; }

/* Le paquet : une pile d'où sort la carte, et où elle retourne si elle est refusée. */
.paquet {
  position: relative;
  width: 92px;
  height: 118px;
  flex-shrink: 0;
  border: 3px solid var(--retro-teal);
  border-radius: 18px 6px 18px 6px;
  background: var(--retro-paper);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.paquet::before,
.paquet::after {
  content: '';
  position: absolute;
  inset: -3px;
  border: 3px solid var(--retro-teal);
  border-radius: 18px 6px 18px 6px;
  background: var(--retro-paper);
  z-index: -1;
}
.paquet::before { transform: translate(5px, 5px); opacity: 0.75; }
.paquet::after  { transform: translate(10px, 10px); opacity: 0.5; }
.paquet-nb { font-family: 'Anton', sans-serif; font-size: 1.9rem; color: var(--retro-teal); line-height: 1; }
.paquet-lab {
  font-family: 'Oswald', sans-serif;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(13,22,23,0.6);
}

.carte {
  background: var(--retro-paper);
  border: 3px solid var(--retro-teal);
  border-radius: 18px 6px 18px 6px;
  box-shadow: 5px 5px 0 var(--retro-teal);
  padding: 14px 18px;
  max-width: 420px;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.carte.is-held {
  border-color: var(--retro-orange);
  box-shadow: 5px 5px 0 var(--retro-orange);
  transform: rotate(-1deg);
}
.carte.is-dragging { position: fixed; z-index: 50; pointer-events: none; opacity: 0.92; margin: 0; }

/* Carte refusée : elle s'en va sur le paquet, marque un temps, puis en ressort.
   Elle reste attrapable pendant le trajet : l'élève qui réessaie aussitôt ne doit
   pas se heurter à une carte inerte pendant sept dixièmes de seconde. */
.carte.is-retour { animation: retour-paquet 0.7s ease-in-out; }
@keyframes retour-paquet {
  0%   { transform: translateX(0) scale(1) rotate(-1deg); opacity: 1; }
  40%  { transform: translateX(var(--retour-x, calc(-100% - 26px))) scale(var(--retour-echelle, 0.72)) rotate(-8deg); opacity: 0.45; }
  55%  { transform: translateX(var(--retour-x, calc(-100% - 26px))) scale(var(--retour-echelle, 0.72)) rotate(-8deg); opacity: 0.45; }
  100% { transform: translateX(0) scale(1) rotate(-1deg); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .carte.is-retour { animation: none; }
}
.carte-titre {
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  line-height: 1.25;
}
.carte-valeur {
  font-family: 'Anton', sans-serif;
  font-size: 1.5rem;
  color: var(--retro-orange);
  margin-top: 5px;
  line-height: 1.1;
}
/* L'unité manquante, matérialisée : c'est elle que l'élève doit trouver. */
.carte-unite {
  display: inline-block;
  margin-left: 8px;
  padding: 0 10px;
  border: 2px dashed var(--retro-teal);
  border-radius: 6px;
  color: var(--retro-teal);
  font-size: 1.1rem;
  vertical-align: 2px;
}
.carte-restantes {
  font-family: 'Oswald', sans-serif;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(13,22,23,0.6);
  align-self: center;
}

.statut {
  display: inline-block;
  font-family: 'Oswald', sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 3px 9px;
  border-radius: 50px;
  margin-top: 8px;
  color: var(--retro-paper);
}
.st-mesure  { background: var(--retro-teal); }
.st-declare { background: var(--retro-orange); }
.st-estime  { background: #6B5B45; }

/* ---------- Feedback ---------- */
.feedback {
  margin-top: 14px;
  font-size: 0.92rem;
  min-height: 24px;
  padding-left: 14px;
  border-left: 4px solid transparent;
}
.feedback.ok    { border-color: var(--retro-teal); }
.feedback.rate  { border-color: var(--retro-orange); }
.feedback strong { font-family: 'Oswald', sans-serif; text-transform: uppercase; letter-spacing: 0.05em; }

/* ---------- Frise ---------- */
.frise {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}
.colonne {
  background: rgba(18,118,118,0.06);
  border: 3px dashed rgba(18,118,118,0.45);
  border-radius: 14px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  min-height: 260px;
}
.colonne.is-target { border-style: solid; border-color: var(--retro-orange); background: rgba(228,99,46,0.1); }
.colonne.is-refus { animation: refus 0.45s ease; }
@keyframes refus {
  0%, 100% { transform: translateX(0); background: rgba(18,118,118,0.06); }
  15%      { transform: translateX(-6px); background: rgba(228,99,46,0.22); }
  45%      { transform: translateX(6px);  background: rgba(228,99,46,0.22); }
  75%      { transform: translateX(-3px); background: rgba(228,99,46,0.12); }
}
@media (prefers-reduced-motion: reduce) {
  .colonne.is-refus { animation: none; background: rgba(228,99,46,0.18); }
}
.col-tete { text-align: center; padding-bottom: 8px; border-bottom: 2px solid var(--retro-teal); margin-bottom: 10px; }
.col-symbole { font-family: 'Anton', sans-serif; font-size: 1.6rem; color: var(--retro-teal); line-height: 1; }
.col-intitule {
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--retro-orange);
  margin-top: 3px;
}
.col-reperes { font-size: 0.7rem; color: rgba(13,22,23,0.7); margin-top: 6px; line-height: 1.4; }
.col-reperes li { list-style: none; margin-top: 3px; }
.col-facteur {
  font-family: 'Oswald', sans-serif;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--retro-teal);
  text-align: center;
  margin-bottom: 6px;
}
.col-contenu { display: flex; flex-direction: column; gap: 8px; }

.placee {
  background: var(--retro-paper);
  border: 2px solid var(--retro-teal);
  border-left: 6px solid var(--retro-teal);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.75rem;
}
.placee-titre { font-family: 'Oswald', sans-serif; font-weight: 700; text-transform: uppercase; font-size: 0.68rem; line-height: 1.2; }
.placee-valeur { font-family: 'Anton', sans-serif; color: var(--retro-orange); font-size: 0.95rem; margin-top: 2px; }
.placee-trad { margin-top: 4px; color: rgba(13,22,23,0.8); line-height: 1.35; }
.placee-src { margin-top: 5px; font-size: 0.66rem; font-style: italic; color: rgba(13,22,23,0.62); }
.placee-plus { margin-top: 4px; font-size: 0.64rem; color: rgba(13,22,23,0.6); line-height: 1.35; }
.placee-sans-lien {
  margin-top: 5px;
  font-size: 0.64rem;
  color: rgba(13,22,23,0.72);
  border-left: 3px solid rgba(13,22,23,0.35);
  padding-left: 6px;
  line-height: 1.35;
}
.placee-reserve {
  margin-top: 5px;
  font-size: 0.68rem;
  background: rgba(227,165,53,0.18);
  border-left: 3px solid var(--retro-jaune);
  padding: 5px 7px;
  line-height: 1.35;
}

/* ---------- Liens vers les sources ---------- */
/* Le lien doit rester attrapable au doigt alors que le texte de source est petit :
   d'où la zone cliquable étendue vers le bas et la flèche collée au texte. */
.lien-src {
  color: var(--retro-teal);
  font-style: normal;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(18,118,118,0.45);
  padding-bottom: 2px;
}
.lien-src:hover { border-bottom-color: var(--retro-orange); color: var(--retro-orange); }
.lien-src:focus-visible { outline: 3px solid var(--retro-jaune); outline-offset: 2px; border-radius: 2px; }
.lien-fleche { margin-left: 3px; font-size: 0.85em; }

/* ---------- Révélation ---------- */
.revelation {
  margin-top: 28px;
  background: var(--retro-ink);
  border-radius: 20px 6px 20px 6px;
  padding: 22px 26px;
  box-shadow: 6px 6px 0 var(--retro-orange);
  color: var(--retro-paper);
}
.revelation .section-label { color: var(--retro-jaune); border-color: var(--retro-jaune); }
.rev-titre { font-family: 'Anton', sans-serif; text-transform: uppercase; color: var(--retro-jaune); font-size: 1.3rem; letter-spacing: 0.05em; }
.rev-bornes { display: flex; gap: 30px; flex-wrap: wrap; margin: 16px 0; }
.rev-borne { display: flex; flex-direction: column; }
.rev-lab { font-family: 'Oswald', sans-serif; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em; color: rgba(242,239,230,0.7); }
.rev-val { font-family: 'Anton', sans-serif; font-size: 1.6rem; color: var(--retro-orange); line-height: 1.2; }
.rev-texte { font-size: 0.92rem; color: rgba(242,239,230,0.88); }
.rev-sources { margin-top: 14px; }
.rev-sources .placee-src,
.rev-sources .placee-plus,
.rev-sources .placee-sans-lien { color: rgba(242,239,230,0.72); font-size: 0.76rem; }
.rev-sources .placee-sans-lien { border-left-color: rgba(242,239,230,0.4); }
.rev-sources .lien-src { color: var(--retro-jaune); border-bottom-color: rgba(227,165,53,0.5); }
.rev-sources .lien-src:hover { color: var(--retro-orange); border-bottom-color: var(--retro-orange); }

/* ---------- Simulateur ---------- */
.simu { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; align-items: start; }
.curseurs { display: flex; flex-direction: column; gap: 18px; }
.curseur-bloc {
  border: 3px solid var(--retro-teal);
  border-radius: 16px 5px 16px 5px;
  padding: 12px 16px;
  background: var(--retro-paper);
}
.curseur-tete { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.curseur-label { font-family: 'Oswald', sans-serif; font-weight: 700; text-transform: uppercase; font-size: 0.78rem; letter-spacing: 0.05em; line-height: 1.25; }
.curseur-nb { font-family: 'Anton', sans-serif; font-size: 1.5rem; color: var(--retro-orange); }
.curseur-unite { font-size: 0.7rem; color: rgba(13,22,23,0.6); font-style: italic; }
input[type=range] { width: 100%; margin-top: 8px; accent-color: var(--retro-orange); }

.resultats {
  background: var(--retro-ink);
  border-radius: 20px 6px 20px 6px;
  padding: 20px 24px;
  color: var(--retro-paper);
}
.resultats .section-label { color: var(--retro-jaune); border-color: var(--retro-jaune); margin-top: 18px; }
.resultats .section-label:first-child { margin-top: 0; }
.res-bloc { display: flex; flex-direction: column; margin-bottom: 12px; }
.res-lab { font-family: 'Oswald', sans-serif; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em; color: rgba(242,239,230,0.7); }
.res-val { font-family: 'Anton', sans-serif; font-size: 1.45rem; color: var(--retro-jaune); line-height: 1.2; }
.res-bloc--fort .res-val { color: var(--retro-orange); font-size: 1.8rem; }
.res-trad { font-size: 0.85rem; color: rgba(242,239,230,0.85); margin-bottom: 6px; }
.res-trad span { font-family: 'Oswald', sans-serif; font-weight: 700; color: var(--retro-jaune); }
.res-compar { font-size: 0.85rem; color: rgba(242,239,230,0.85); margin-top: 8px; font-style: italic; }

.groupes { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.groupe-btn {
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  padding: 7px 14px;
  border-radius: 50px;
  border: 2px solid var(--retro-jaune);
  background: transparent;
  color: var(--retro-jaune);
  cursor: pointer;
}
.groupe-btn.is-active { background: var(--retro-jaune); color: var(--retro-ink); }
.groupe-nb {
  display: block;
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.68rem;
  opacity: 0.85;
  margin-top: 1px;
}
.groupes-note {
  font-size: 0.74rem;
  color: rgba(242,239,230,0.7);
  line-height: 1.45;
  margin-bottom: 10px;
}
.perso-wrap { display: block; font-size: 0.78rem; color: rgba(242,239,230,0.8); margin-bottom: 14px; }
.perso-wrap input {
  display: block;
  margin-top: 5px;
  width: 140px;
  padding: 6px 10px;
  border: 2px solid var(--retro-jaune);
  border-radius: 8px;
  background: var(--retro-paper);
  font-family: 'Oswald', sans-serif;
  font-size: 0.9rem;
}

/* ---------- Pied ---------- */
.sources-foot { margin-top: 40px; padding-top: 18px; border-top: 3px solid var(--retro-teal); }
.sources-foot ul { list-style: none; font-size: 0.78rem; color: rgba(13,22,23,0.78); }
.sources-foot li { padding: 3px 0; line-height: 1.45; }
.sources-foot .src-muette { color: rgba(13,22,23,0.5); }
.sources-foot li strong { font-family: 'Oswald', sans-serif; text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.04em; }
.foot-note { margin-top: 10px; font-size: 0.74rem; font-style: italic; color: rgba(13,22,23,0.6); }

/* ---------- Attribution (footer obligatoire de la charte) ---------- */
/* Les marges négatives rattrapent le padding du cadre : le bandeau va bord à bord. */
.retro-footer {
  background: var(--retro-ink);
  border-top: 3px solid var(--retro-teal);
  margin: 40px -28px -40px;
  padding: 24px 28px;
  color: var(--retro-paper);
  text-align: center;
}
.retro-footer-ornament { color: var(--retro-teal); font-size: 1.5rem; margin-bottom: 10px; }
.retro-footer-credit {
  font-family: 'Oswald', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.9rem;
  margin-bottom: 6px;
}
.retro-footer-licence { font-size: 0.78rem; color: rgba(242,239,230,0.6); }
.retro-footer-link {
  color: var(--retro-jaune);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.retro-footer-link:hover { border-bottom-color: var(--retro-jaune); }
.retro-footer-link:focus-visible { outline: 3px solid var(--retro-jaune); outline-offset: 3px; }

/* ---------- Écrans étroits ---------- */
@media (max-width: 900px) {
  .frise { grid-template-columns: 1fr; }
  .colonne { min-height: 0; }
  .simu { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .page-frame { margin: 6px; padding: 20px 14px 28px; }
  .header-band { flex-direction: column; align-items: flex-start; gap: 12px; }
  .carte { max-width: 100%; }
  .retro-footer { margin: 32px -14px -28px; padding: 20px 14px; }   /* suit le padding réduit du cadre */
}

/* Colonnes empilées, écran tenu debout : la frise dépasse largement l'écran. La
   pioche reste collée en haut pendant que la frise défile dessous, pour que la
   carte à placer et le message de retour ne quittent jamais le champ. Elle se
   resserre en conséquence : paquet réduit à gauche, carte à droite, sur une rangée.
   Sous 480 px de haut (téléphone couché), elle mangerait la moitié de l'écran :
   on la laisse alors à sa place. */
@media screen and (max-width: 900px) and (min-height: 480px) {
  .pioche-zone {
    position: sticky;
    top: 0;
    z-index: 20;
    margin: 0 -28px 18px;              /* va jusqu'aux bords du cadre */
    padding: 10px 28px;
    background: var(--retro-paper);
    border-bottom: 3px solid var(--retro-teal);
  }
  .pioche-zone.is-vide { position: static; }   /* plus de carte : rien à garder sous les yeux */
  /* Le titre reste lisible par un lecteur d'écran, sans coûter une ligne à l'écran. */
  .pioche-zone .section-label { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

  .pioche {
    min-height: 0;
    flex-wrap: nowrap;
    gap: 14px;
    padding-right: 5px;                /* la place de l'ombre de la carte */
    --retour-x: calc(-50% - 43px);     /* du centre de la carte au centre du paquet */
    --retour-echelle: 0.3;
  }
  .paquet { width: 58px; height: 76px; border-radius: 12px 4px 12px 4px; }
  .paquet::before,
  .paquet::after { border-radius: 12px 4px 12px 4px; }
  .paquet::before { transform: translate(3px, 3px); }
  .paquet::after  { transform: translate(6px, 6px); }
  .paquet-nb { font-size: 1.35rem; }
  .paquet-lab { font-size: 0.5rem; letter-spacing: 0.08em; line-height: 1.15; text-align: center; }

  /* Vaut aussi pour le clone qui suit le doigt : il doit rester le sosie de la carte. */
  .carte { flex: 1 1 0; min-width: 0; padding: 10px 14px; }
  .carte-titre { font-size: 0.82rem; }
  .carte-valeur { font-size: 1.3rem; margin-top: 3px; }
  .carte .statut { margin-top: 6px; }
  .feedback { margin-top: 10px; font-size: 0.86rem; line-height: 1.4; }
}
@media screen and (max-width: 600px) and (min-height: 480px) {
  .pioche-zone { margin-inline: -14px; padding-inline: 14px; }
}

@media print {
  body { background: #fff; }
  .page-frame { border: none; margin: 0; }
  .tabs, .scoreboard, .pioche-zone { display: none; }
  .panel { display: block !important; }
}
