/* ajit.be — la nuit, une lanterne, des portes */
:root {
  --nuit: #1b1446;
  --nuit-2: #251a5e;
  --nuit-3: #34277f;
  --lanterne: #ffc43d;
  --lanterne-fonce: #b9780b;
  --menthe: #3ddc97;
  --bonbon: #ff5e8a;
  --craie: #fff7e6;
  --craie-doux: #cfc6f0;
  --pierre: #0f0b2c;

  --titre: "Bagel Fat One", "Arial Rounded MT Bold", system-ui, sans-serif;
  --texte: "Atkinson Hyperlegible", system-ui, sans-serif;

  --s1: .5rem; --s2: 1rem; --s3: 1.5rem; --s4: 2.5rem; --s5: 4rem; --s6: 6.5rem;
  --largeur: 72rem;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--nuit);
  color: var(--craie);
  font: 400 1.125rem/1.6 var(--texte);
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--titre); font-weight: 400; line-height: 1.05; margin: 0; letter-spacing: .005em; }
p { margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--lanterne); outline-offset: 3px; border-radius: 6px; }

.saut { position: absolute; left: -999px; top: 0; z-index: 100; background: var(--lanterne); color: var(--nuit); padding: var(--s1) var(--s2); }
.saut:focus { left: var(--s2); top: var(--s2); }

/* ---------- Barre ---------- */
.barre {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  padding: var(--s2) clamp(1rem, 4vw, 2.5rem);
  transition: background-color .3s, box-shadow .3s;
}
.barre.est-pleine { background: rgba(27, 20, 70, .92); box-shadow: 0 1px 0 rgba(255,255,255,.06); backdrop-filter: blur(8px); }
.barre__logo { font-family: var(--titre); font-size: 1.5rem; color: var(--lanterne); text-decoration: none; }
.barre nav { display: flex; gap: clamp(.75rem, 3vw, 2rem); }
.barre nav a { color: var(--craie); text-decoration: none; font-weight: 700; font-size: 1rem; }
.barre nav a:hover { color: var(--lanterne); }

/* ---------- Accueil 3D ---------- */
.accueil { position: relative; height: 230vh; --p: 0; }
.accueil__scene {
  position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden;
  background:
    radial-gradient(60% 55% at 62% 48%, #3b2a8f 0%, transparent 70%),
    radial-gradient(90% 60% at 20% 110%, #3a1856 0%, transparent 60%),
    var(--nuit);
}
#scene { position: absolute; inset: 0; width: 100%; height: 100%; }
.accueil__texte {
  position: absolute; z-index: 2;
  left: clamp(1rem, 6vw, 5rem); bottom: clamp(5rem, 16vh, 10rem);
  max-width: 34rem;
  opacity: calc(1 - var(--p) * 2.4);
  transform: translateY(calc(var(--p) * -60px));
}
.accueil__texte p { font-size: clamp(1.1rem, 1.6vw, 1.3rem); color: var(--craie-doux); margin: var(--s3) 0 var(--s4); max-width: 30rem; }
.titre-relief {
  font-size: clamp(2.8rem, 7.2vw, 6rem);
  color: var(--lanterne);
  text-shadow:
    0 1px 0 #f0ae22, 0 2px 0 #e59f17, 0 3px 0 #d8910f, 0 4px 0 #c9830b,
    0 5px 0 #b87508, 0 6px 0 #a56706, 0 7px 0 #8f5804, 0 8px 0 #774903,
    0 10px 6px rgba(10, 5, 40, .5), 0 22px 30px rgba(10, 5, 40, .55);
}
.accueil__indice {
  position: absolute; left: 50%; bottom: var(--s3); transform: translateX(-50%); z-index: 2;
  font-size: .95rem; color: var(--craie-doux);
  opacity: calc(1 - var(--p) * 5);
  animation: flotte 2.4s ease-in-out infinite;
}
.accueil__eclat {
  position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background: radial-gradient(circle at 60% 50%, #fff3c4 0%, var(--lanterne) 45%, #ff9a5e 100%);
  opacity: clamp(0, (var(--p) - .8) * 5, 1);
}
@keyframes flotte { 50% { transform: translate(-50%, -6px); } }

html.sans-3d .accueil { height: 100vh; }
html.sans-3d .accueil__scene::after {
  content: ""; position: absolute; right: 12%; top: 22%; width: min(26vw, 220px); aspect-ratio: 3 / 5;
  border-radius: 10px; background: linear-gradient(#6b2fa0, #45196e);
  box-shadow: 0 0 0 14px #2c1f66, 0 0 80px 10px rgba(255, 196, 61, .35);
}

/* ---------- Boutons ---------- */
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  padding: .85em 1.6em; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--lanterne); color: var(--nuit);
  font-family: var(--titre); font-size: 1.2rem; text-decoration: none;
  box-shadow: 0 6px 0 var(--lanterne-fonce), 0 12px 24px rgba(0,0,0,.35);
  transition: transform .12s, box-shadow .12s;
}
.bouton:hover { transform: translateY(-2px); box-shadow: 0 8px 0 var(--lanterne-fonce), 0 16px 28px rgba(0,0,0,.35); }
.bouton:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--lanterne-fonce), 0 6px 12px rgba(0,0,0,.35); }
.bouton--sombre { background: var(--nuit); color: var(--craie); box-shadow: 0 5px 0 #0c0826; font-size: 1.05rem; padding: .7em 1.3em; }
.bouton--sombre:hover { box-shadow: 0 7px 0 #0c0826; }
.bouton--sombre:active { box-shadow: 0 1px 0 #0c0826; }

/* ---------- Blocs ---------- */
main { position: relative; z-index: 1; }
.bloc { padding: var(--s6) clamp(1rem, 5vw, 3rem); scroll-margin-top: 2rem; }
.bloc > * { max-width: var(--largeur); margin-inline: auto; }
.bloc__tete { margin-bottom: var(--s5); }
.bloc__tete h2 { font-size: clamp(2.2rem, 5vw, 3.6rem); color: var(--craie); }
.bloc__tete p { margin-top: var(--s2); color: var(--craie-doux); max-width: 36rem; }

.bloc--jeux {
  background:
    radial-gradient(70% 50% at 50% 0%, rgba(255, 196, 61, .16), transparent 70%),
    linear-gradient(var(--nuit-2), var(--nuit) 85%);
}

/* ---------- Portes 3D ---------- */
.portes {
  list-style: none; padding: 0; margin: 0 auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(0, 250px));
  gap: var(--s5) clamp(1.5rem, 4vw, 3.5rem);
}
.porte__lien {
  display: flex; flex-direction: column; width: 100%;
  background: none; border: 0; padding: 0; text-align: left;
  color: inherit; text-decoration: none; cursor: pointer;
}
.porte__cadre {
  position: relative; display: block; aspect-ratio: 3 / 5;
  perspective: 800px;
  border-radius: 12px 12px 4px 4px;
  background: var(--pierre);
  box-shadow: 0 0 0 10px #2c1f66, 0 0 0 12px #3a2c7a, 0 20px 30px rgba(0,0,0,.45);
}
.porte__interieur {
  position: absolute; inset: 0; border-radius: inherit; overflow: hidden;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 18%;
  background:
    radial-gradient(circle at 50% 40%, #fff3c4 0%, var(--lanterne) 35%, var(--c) 100%);
  background-size: cover; background-position: center;
}
.porte__jouer {
  font-family: var(--titre); font-size: 1.1rem; color: var(--nuit);
  background: var(--craie); padding: .35em 1em; border-radius: 999px;
  box-shadow: 0 4px 0 rgba(0,0,0,.25);
}
.porte__battant {
  position: absolute; inset: 0; border-radius: inherit;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform .75s cubic-bezier(.3, 1.3, .5, 1);
  background:
    linear-gradient(90deg, rgba(0,0,0,.25), transparent 12%, transparent 88%, rgba(0,0,0,.3)),
    var(--c);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.08);
}
/* panneaux moulurés */
.porte__battant::before, .porte__battant::after {
  content: ""; position: absolute; left: 16%; right: 16%;
  border-radius: 6px;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,.12), inset -2px -2px 0 rgba(0,0,0,.28);
  background: rgba(0,0,0,.08);
}
.porte__battant::before { top: 22%; height: 28%; }
.porte__battant::after { top: 56%; height: 32%; }
.porte__plaque {
  position: absolute; top: 7%; left: 50%; transform: translateX(-50%);
  min-width: 2.2em; padding: .05em .45em; text-align: center; z-index: 1;
  font-family: var(--titre); font-size: clamp(1rem, 1.8vw, 1.35rem); color: var(--nuit);
  background: var(--lanterne); border-radius: 6px;
  box-shadow: 0 3px 0 var(--lanterne-fonce);
}
.porte__poignee {
  position: absolute; right: 10%; top: 52%; width: 12%; aspect-ratio: 1; border-radius: 50%; z-index: 1;
  background: radial-gradient(circle at 35% 30%, #fff1b8, var(--lanterne) 45%, var(--lanterne-fonce));
  box-shadow: 0 2px 3px rgba(0,0,0,.5);
}
.porte__cadenas {
  position: absolute; left: 50%; top: 58%; width: 26%; aspect-ratio: 1 / 1.1; transform: translateX(-50%); z-index: 1;
  background: radial-gradient(circle at 50% 42%, var(--nuit) 0 10%, transparent 11%),
              linear-gradient(var(--lanterne), var(--lanterne-fonce));
  border-radius: 5px; margin-top: 8%;
  box-shadow: 0 3px 4px rgba(0,0,0,.4);
}
.porte__cadenas::before {
  content: ""; position: absolute; left: 20%; right: 20%; bottom: 92%; height: 55%;
  border: 4px solid var(--craie-doux); border-bottom: 0; border-radius: 99px 99px 0 0;
}
.porte__nom { display: block; margin-top: var(--s3); font-family: var(--titre); font-size: 1.25rem; line-height: 1.1; }
.porte__resume { display: block; margin-top: .35rem; font-size: .95rem; color: var(--craie-doux); line-height: 1.45; }
.porte__resume strong { color: var(--lanterne); }

.porte:not(.porte--fermee) .porte__lien:hover .porte__battant,
.porte:not(.porte--fermee) .porte__lien:focus-visible .porte__battant,
.porte__lien.est-ouverte .porte__battant { transform: rotateY(-105deg); box-shadow: 30px 0 40px rgba(0,0,0,.4); }
.porte:not(.porte--fermee) .porte__lien:hover .porte__cadre,
.porte__lien.est-ouverte .porte__cadre { box-shadow: 0 0 0 10px #2c1f66, 0 0 0 12px #3a2c7a, 0 0 60px 6px rgba(255,196,61,.45), 0 20px 30px rgba(0,0,0,.45); }
.porte--fermee .porte__lien:hover .porte__battant { transform: rotateY(-6deg); }
.porte--fermee .porte__nom { color: var(--craie-doux); }
.porte__lien.secoue .porte__battant { animation: secoue .5s; }
@keyframes secoue {
  20% { transform: rotateY(-10deg); } 40% { transform: rotateY(-2deg); }
  60% { transform: rotateY(-8deg); } 80% { transform: rotateY(-1deg); }
}

.bulle {
  position: fixed; left: 50%; bottom: 1.5rem; z-index: 60; visibility: hidden;
  transform: translate(-50%, calc(100% + 2rem)); transition: transform .35s cubic-bezier(.3, 1.4, .5, 1), visibility 0s .35s;
  background: var(--craie); color: var(--nuit); font-weight: 700;
  padding: .8em 1.3em; border-radius: 16px; max-width: calc(100vw - 2rem);
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.bulle.visible { transform: translate(-50%, 0); visibility: visible; transition-delay: 0s; }

/* ---------- Vidéos ---------- */
.bloc--videos { background: var(--nuit); }
/* Lecteur : grand écran + liste à côté */
.lecteur { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--s4); align-items: start; }
.lecteur__ecran {
  position: relative; aspect-ratio: 16 / 9; border-radius: 22px; overflow: hidden; background: #000;
  box-shadow: 0 0 0 6px var(--nuit-3), 0 0 60px rgba(255, 196, 61, .18), 0 30px 50px rgba(0,0,0,.5);
}
.lecteur__ecran iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.lecteur__titre { margin-top: var(--s3); font-size: clamp(1.4rem, 2.4vw, 1.9rem); color: var(--craie); }
.lecteur__liste {
  list-style: none; margin: 0; padding: 4px; display: grid; gap: .75rem;
  max-height: min(34rem, 70vh); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--nuit-3) transparent;
}
.lecteur__choix {
  display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); gap: .9rem; align-items: center;
  padding: .5rem; border-radius: 16px; color: var(--craie); text-decoration: none; font-weight: 700; line-height: 1.3;
  transition: background-color .15s, transform .15s;
}
.lecteur__choix img { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; background: var(--nuit-3); }
.lecteur__choix:hover { background: rgba(255, 255, 255, .06); transform: translateX(3px); }
.lecteur__choix[aria-current="true"] { background: var(--lanterne); color: var(--nuit); }
.lecteur__choix[aria-current="true"]:hover { transform: none; }
.vide { color: var(--craie-doux); font-size: 1.2rem; }

/* ---------- Apprendre ---------- */
.bloc--apprendre { background: linear-gradient(var(--nuit), var(--nuit-2)); }
.apprendre {
  display: grid; gap: var(--s3);
  grid-template-columns: 1.35fr 1fr;
  grid-template-areas: "calcul savais" "calcul mot";
}
.carte { padding: clamp(1.5rem, 3vw, 2.5rem); color: var(--nuit); }
.carte h3 { font-size: clamp(1.6rem, 2.6vw, 2.1rem); }
.carte--calcul { grid-area: calcul; background: var(--menthe); border-radius: 32px 32px 32px 8px; display: flex; flex-direction: column; }
.carte--savais { grid-area: savais; background: var(--bonbon); border-radius: 8px 32px 32px 32px; perspective: 900px; }
.carte--mot { grid-area: mot; background: var(--lanterne); border-radius: 32px 8px 32px 32px; }

.niveaux { display: flex; gap: .5rem; margin: var(--s3) 0; flex-wrap: wrap; }
.niveaux button {
  border: 2px solid var(--nuit); background: transparent; border-radius: 999px;
  padding: .35em 1em; font-weight: 700; cursor: pointer; color: var(--nuit);
}
.niveaux button[aria-checked="true"] { background: var(--nuit); color: var(--menthe); }

.calcul { perspective: 1100px; flex: 1; display: flex; min-height: 17rem; }
.calcul__carte {
  position: relative; flex: 1; transform-style: preserve-3d;
  transition: transform .7s cubic-bezier(.3, 1.25, .5, 1);
}
.calcul__carte.retournee { transform: rotateY(180deg); }
.calcul__face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s3);
  background: var(--nuit); color: var(--craie); border-radius: 24px; padding: var(--s3);
  box-shadow: 0 10px 0 #127a50, 0 20px 30px rgba(0,0,0,.2);
}
.calcul__face--dos { transform: rotateY(180deg); }
.calcul__question { font-family: var(--titre); font-size: clamp(3rem, 7vw, 5rem); color: var(--lanterne); line-height: 1; }
.calcul__choix { display: flex; gap: .75rem; flex-wrap: wrap; justify-content: center; }
.calcul__choix button {
  min-width: 4.2rem; padding: .4em .8em; border: 0; border-radius: 16px; cursor: pointer;
  font-family: var(--titre); font-size: 2rem; background: var(--craie); color: var(--nuit);
  box-shadow: 0 5px 0 var(--craie-doux); transition: transform .1s;
}
.calcul__choix button:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--craie-doux); }
.calcul__verdict { font-family: var(--titre); font-size: clamp(2rem, 4.5vw, 3rem); text-align: center; line-height: 1.1; }
.calcul__verdict.bon { color: var(--menthe); }
.calcul__verdict.rate { color: var(--bonbon); }
.calcul__verdict small { display: block; font-family: var(--texte); font-size: 1.1rem; color: var(--craie-doux); margin-top: .5rem; }
.calcul__score { display: flex; gap: var(--s3); margin-top: var(--s3); font-weight: 700; }
.calcul__score strong { font-family: var(--titre); font-weight: 400; font-size: 1.4rem; margin-left: .3rem; }

.savais {
  font-size: clamp(1.2rem, 2vw, 1.45rem); line-height: 1.4; font-weight: 700;
  margin: var(--s3) 0; min-height: 5.6em;
  transition: transform .28s ease-in, opacity .28s;
  transform-origin: center;
}
.savais.tourne { transform: rotateX(90deg); opacity: 0; }
.mot { font-family: var(--titre); font-size: clamp(2.2rem, 4.5vw, 3.2rem); margin-top: var(--s3); line-height: 1; }
.mot__def { margin: var(--s2) 0 var(--s3); font-size: 1.2rem; font-weight: 700; }

/* ---------- Pied ---------- */
.pied { padding: var(--s5) var(--s2); text-align: center; background: var(--pierre); color: var(--craie-doux); }
.pied p:first-child { font-family: var(--titre); font-size: 1.5rem; color: var(--craie); }
.pied__papa { margin-top: .4rem; font-size: 1rem; }
.pied__papa a { color: var(--lanterne); text-underline-offset: 3px; }
.pied__petit { margin-top: .5rem; font-size: .9rem; }

/* ---------- Adaptatif ---------- */
@media (max-width: 960px) {
  .lecteur { grid-template-columns: 1fr; }
  .lecteur__liste { max-height: none; overflow: visible; grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); }
}
@media (max-width: 720px) {
  .barre nav { gap: .9rem; }
  .barre nav a { font-size: .9rem; }
  .accueil__texte { bottom: 4rem; right: 1rem; }
  .accueil__scene::after {
    content: ""; position: absolute; inset: 45% 0 0 0; z-index: 1; pointer-events: none;
    background: linear-gradient(transparent, rgba(27, 20, 70, .85) 45%);
    opacity: calc(1 - var(--p) * 2.4);
  }
  /* sur téléphone : les portes défilent au doigt */
  .portes {
    display: flex; gap: var(--s4); overflow-x: auto; scroll-snap-type: x mandatory;
    margin-inline: calc(-1 * clamp(1rem, 5vw, 3rem)); padding: 16px clamp(1rem, 5vw, 3rem) var(--s2);
    scrollbar-width: none;
  }
  .portes::-webkit-scrollbar { display: none; }
  .porte { flex: 0 0 62%; scroll-snap-align: center; }
  .apprendre { grid-template-columns: 1fr; grid-template-areas: "calcul" "savais" "mot"; }
  .bloc { padding-block: var(--s5); }
}

@media (max-width: 400px) { .barre nav a:nth-child(3) { display: none; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .accueil { height: 100vh; }
}
