/*
 * Le rideau du premier chargement (Lumélia Tile) : sur un cercle doré, la mascotte regarde trois tuiles pareilles tomber une à une
 * dans un plateau à trois places, se rassembler et éclater (un trio, comme dans le jeu) ; elle saute de joie à chaque trio, un tour
 * avec un grand sourire, le suivant avec un clin d'œil, et les tuiles changent d'un tour à l'autre (feuille, flamme). En dessous,
 * le nom du jeu, une phrase, la barre qui suit le chargement (boot.js la remplit par --p) et son pourcentage. Quand la page est
 * prête (« is-dash », posé par boot.js), elle fait la fête et le rideau s'efface.
 * Le rideau n'existe que lorsque boot.js a posé « booting » sur <html> (une fois par visite) ; sans JavaScript, la page s'affiche
 * telle quelle. Chargé avant style.css : le rideau est dessiné dès la première image.
 */
.boot {
  display: none;
}
.booting {
  overflow: hidden;
}
.booting .boot {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  overflow: hidden;
  color: #f4f1ff;
  background:
    radial-gradient(60% 45% at 50% 40%, rgb(92 84 255 / 42%) 0%, transparent 70%),
    radial-gradient(120% 90% at 50% 45%, #172470 0%, #151050 45%, #0d0a33 85%);
  font-family: 'Fredoka', 'Nunito', system-ui, sans-serif;
  /* Filet de sécurité : si boot.js s'arrêtait en route, le rideau s'efface seul au bout de 12 s. */
  animation: boot-failsafe 0.6s 12s forwards;
}
.boot.is-out {
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.6s ease,
    visibility 0s 0.6s;
}

/* Le ciel : deux couches de petites étoiles qui scintillent à contretemps. */
.boot::before,
.boot::after {
  content: '';
  position: absolute;
  inset: -10%;
  pointer-events: none;
  background-image:
    radial-gradient(circle, #fff 0 1.5px, transparent 2px),
    radial-gradient(circle, #ffe9a0 0 1.2px, transparent 1.7px),
    radial-gradient(circle, #b9c4ff 0 1px, transparent 1.5px);
  background-size:
    173px 167px,
    241px 229px,
    97px 113px;
  background-position:
    11px 23px,
    83px 131px,
    41px 7px;
  animation: boot-twinkle 2.6s ease-in-out infinite alternate;
}
.boot::after {
  background-position:
    127px 71px,
    19px 197px,
    67px 59px;
  animation-delay: -1.3s;
}

.boot__inner {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
  animation: boot-rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  transition:
    scale 0.6s ease,
    translate 0.6s ease;
}
.is-out .boot__inner {
  scale: 1.06;
  translate: 0 -12px;
}

/* ---------- La scène : le cercle doré, la mascotte, le plateau et ses tuiles ---------- */
.boot__stage {
  --cycle: 2.4s; /* un trio */
  position: relative;
  width: 230px;
  height: 252px;
}
.boot__halo {
  position: absolute;
  left: 50%;
  bottom: 84px;
  width: 220px;
  height: auto;
  translate: -50% 0;
  animation: boot-halo 1.2s ease-in-out infinite alternate;
}
.boot__mascot {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 96px;
  width: 150px;
  height: 150px;
  margin-left: -75px;
  transform-origin: 50% 100%;
  filter: drop-shadow(0 8px 12px rgb(5 4 30 / 45%));
  animation: boot-hop var(--cycle) ease-in-out infinite;
}
.boot__mascot img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
/* Les visages : « content » dessous ; la joie (premier tour) ou le clin d'œil (second tour) apparaît par-dessus pendant le saut.
   Pendant le fondu, le visage du dessous reste plein (la mascotte n'est jamais transparente) ; une fois l'autre plein, il
   s'efface, pour qu'aucun détail de l'un ne dépasse de l'autre. */
.boot__mascot img:nth-child(1) {
  animation: boot-face-base calc(var(--cycle) * 2) linear infinite;
}
.boot__mascot img:nth-child(2) {
  opacity: 0;
  animation: boot-face-joy calc(var(--cycle) * 2) linear infinite;
}
.boot__mascot img:nth-child(3) {
  opacity: 0;
  animation: boot-face-wink calc(var(--cycle) * 2) linear infinite;
}
.boot__mascot img:nth-child(4) {
  opacity: 0;
}

/* Le plateau à trois places, comme celui du jeu. */
.boot__tray {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(3, 58px);
  gap: 8px;
  margin-left: -106px;
  padding: 8px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgb(255 255 255 / 30%), rgb(255 255 255 / 14%));
  border: 3px solid rgb(255 255 255 / 55%);
  box-shadow:
    0 5px 0 rgb(0 0 0 / 18%),
    0 14px 26px rgb(5 4 30 / 40%),
    inset 0 -3px 8px rgb(120 90 170 / 18%);
}
.boot__slot {
  height: 58px;
  border-radius: 16px;
  background: rgb(20 14 70 / 35%);
  box-shadow: inset 0 3px 5px rgb(5 4 30 / 35%);
}

/* Les tuiles : la face crème et le liseré doré du jeu. Chacune tombe dans sa place, les trois se rejoignent au milieu et éclatent. */
.boot__tile {
  --t: 58px;
  position: absolute;
  top: 8px;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 22%;
  background: linear-gradient(160deg, #fffef8, #f2e7cf);
  box-shadow:
    0 4px 0 #bfa575,
    0 6px 10px rgb(30 20 10 / 35%),
    inset 0 0 0 2px rgb(255 255 255 / 85%);
  opacity: 0;
  animation: var(--cycle) ease-in-out infinite;
}
.boot__tile:nth-of-type(1) {
  left: 8px;
  animation-name: boot-tile-1;
}
.boot__tile:nth-of-type(2) {
  left: 74px;
  animation-name: boot-tile-2;
}
.boot__tile:nth-of-type(3) {
  left: 140px;
  animation-name: boot-tile-3;
}
/* Un tour la feuille, le suivant la flamme : le changement tombe quand les tuiles sont parties. */
.boot__tile img {
  grid-area: 1 / 1;
  width: 78%;
  height: 78%;
  object-fit: contain;
  animation: calc(var(--cycle) * 2) step-end infinite;
}
.boot__tile img:nth-child(1) {
  animation-name: boot-icon-a;
}
.boot__tile img:nth-child(2) {
  opacity: 0;
  animation-name: boot-icon-b;
}

/* L'éclat du trio, au milieu du plateau : un anneau doré qui s'ouvre et deux étincelles qui s'envolent. */
.boot__burst {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 40px;
  width: 0;
  height: 0;
}
.boot__burst::before {
  content: '';
  position: absolute;
  left: -40px;
  top: -40px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 4px solid #ffd23f;
  box-shadow:
    0 0 18px rgb(255 210 63 / 70%),
    inset 0 0 14px rgb(255 210 63 / 50%);
  opacity: 0;
  animation: boot-ring var(--cycle) ease-out infinite;
}
.boot__burst img {
  position: absolute;
  width: 34px;
  height: auto;
  margin: -17px 0 0 -17px;
  opacity: 0;
  animation: var(--cycle) ease-out infinite;
}
.boot__burst img:nth-child(1) {
  animation-name: boot-spark-l;
}
.boot__burst img:nth-child(2) {
  width: 24px;
  margin: -12px 0 0 -12px;
  animation-name: boot-spark-r;
}

/* La sortie : la mascotte fait la fête (visage en fête, grand saut), les tuiles s'en vont. */
.is-dash .boot__mascot {
  animation: boot-cheer 0.5s cubic-bezier(0.3, 0, 0.3, 1) forwards;
}
.is-dash .boot__mascot img {
  animation: none;
  opacity: 0;
}
.is-dash .boot__mascot img:nth-child(4) {
  opacity: 1;
}
.is-dash .boot__tile,
.is-dash .boot__burst {
  visibility: hidden;
}

/* ---------- Le nom, la phrase, la barre, le pourcentage ---------- */
.boot__name {
  margin: 0;
  font-size: clamp(30px, 8.5vw, 42px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.01em;
  color: #ffd23f;
  background: linear-gradient(100deg, #ffb800 0%, #ffe27a 30%, #fffbe0 45%, #ffe27a 60%, #ffb800 100%) 0 0 / 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 0 #7a5200) drop-shadow(0 8px 18px rgb(255 184 0 / 35%));
  animation: boot-shine 2.4s ease-in-out infinite;
}
.boot__line {
  margin: -4px 0 6px;
  font-family: 'Nunito', system-ui, sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: #c3bdf2;
}
.boot__line::after {
  content: '';
  display: inline-block;
  width: 1.2em;
  text-align: start;
  animation: boot-dots 1.2s steps(4, end) infinite;
}
.boot__bar {
  --p: 0;
  position: relative;
  width: min(260px, 70vw);
  height: 12px;
  border-radius: 99px;
  overflow: hidden;
  background: rgb(255 255 255 / 12%);
  box-shadow: inset 0 2px 3px rgb(0 0 0 / 30%);
}
.boot__bar::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  transform: scaleX(var(--p));
  transform-origin: left center;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 45%) 0 40%, transparent 40%),
    linear-gradient(90deg, #ffb800, #ffd23f 60%, #ffe27a);
}
[data-rtl] .boot__bar::before {
  transform-origin: right center;
}
/* Le pourcentage sous la barre (boot.js l'écrit) : chiffres de même largeur, pour qu'il ne tremble pas en montant. */
.boot__pct {
  margin: -6px 0 0;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: #ffe27a;
}
/* Un reflet qui passe sur la barre. */
.boot__bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgb(255 255 255 / 55%) 50%, transparent 70%) -100% 0 / 60% 100% no-repeat;
  animation: boot-sweep 1.6s ease-in-out infinite;
}

/* ---------- Les mouvements ---------- */
/* Un trio par tour : les tuiles tombent à 0 %, 14 % et 28 %, se rejoignent à 52-60 %, éclatent vers 65 % ; la mascotte saute alors. */
@keyframes boot-tile-1 {
  0% {
    opacity: 0;
    translate: 0 -150px;
    scale: 0.7;
  }
  3% {
    opacity: 1;
  }
  9% {
    translate: 0 0;
    scale: 1.08 0.9;
  }
  13%,
  52% {
    opacity: 1;
    translate: 0 0;
    scale: 1;
  }
  60% {
    translate: 66px 0;
    scale: 1;
  }
  65% {
    opacity: 1;
    translate: 66px -6px;
    scale: 1.25;
  }
  70%,
  100% {
    opacity: 0;
    translate: 66px -6px;
    scale: 0.4;
  }
}
@keyframes boot-tile-2 {
  0%,
  14% {
    opacity: 0;
    translate: 0 -150px;
    scale: 0.7;
  }
  17% {
    opacity: 1;
  }
  23% {
    translate: 0 0;
    scale: 1.08 0.9;
  }
  27%,
  60% {
    opacity: 1;
    translate: 0 0;
    scale: 1;
  }
  65% {
    opacity: 1;
    translate: 0 -6px;
    scale: 1.25;
  }
  70%,
  100% {
    opacity: 0;
    translate: 0 -6px;
    scale: 0.4;
  }
}
@keyframes boot-tile-3 {
  0%,
  28% {
    opacity: 0;
    translate: 0 -150px;
    scale: 0.7;
  }
  31% {
    opacity: 1;
  }
  37% {
    translate: 0 0;
    scale: 1.08 0.9;
  }
  41%,
  52% {
    opacity: 1;
    translate: 0 0;
    scale: 1;
  }
  60% {
    translate: -66px 0;
    scale: 1;
  }
  65% {
    opacity: 1;
    translate: -66px -6px;
    scale: 1.25;
  }
  70%,
  100% {
    opacity: 0;
    translate: -66px -6px;
    scale: 0.4;
  }
}
@keyframes boot-icon-a {
  0% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}
@keyframes boot-icon-b {
  0% {
    opacity: 0;
  }
  50%,
  100% {
    opacity: 1;
  }
}
@keyframes boot-ring {
  0%,
  62% {
    opacity: 0;
    scale: 0.3;
  }
  68% {
    opacity: 1;
    scale: 1;
  }
  86%,
  100% {
    opacity: 0;
    scale: 1.7;
  }
}
@keyframes boot-spark-l {
  0%,
  63% {
    opacity: 0;
    translate: 0 0;
    scale: 0.3;
    rotate: 0deg;
  }
  70% {
    opacity: 1;
  }
  90%,
  100% {
    opacity: 0;
    translate: -62px -52px;
    scale: 1;
    rotate: -50deg;
  }
}
@keyframes boot-spark-r {
  0%,
  65% {
    opacity: 0;
    translate: 0 0;
    scale: 0.3;
    rotate: 0deg;
  }
  72% {
    opacity: 1;
  }
  92%,
  100% {
    opacity: 0;
    translate: 64px -44px;
    scale: 1;
    rotate: 60deg;
  }
}
/* La mascotte se balance doucement, se ramasse, saute au moment du trio et retombe en s'écrasant un peu. */
@keyframes boot-hop {
  0%,
  50% {
    translate: 0 0;
    scale: 1;
    rotate: 0deg;
  }
  25% {
    translate: 0 -4px;
    rotate: -2deg;
  }
  58% {
    translate: 0 0;
    scale: 1.07 0.93;
  }
  68% {
    translate: 0 -28px;
    scale: 0.97 1.05;
    rotate: 3deg;
  }
  78% {
    translate: 0 0;
    scale: 1.06 0.94;
    rotate: 0deg;
  }
  86%,
  100% {
    translate: 0 0;
    scale: 1;
  }
}
/* Sur deux tours : le saut du premier va de 58 à 86 % d'un tour (29-43 % de deux), celui du second de 79 à 93 %. */
@keyframes boot-face-base {
  0%,
  31% {
    opacity: 1;
  }
  31.01%,
  44.99% {
    opacity: 0;
  }
  45%,
  81% {
    opacity: 1;
  }
  81.01%,
  94.99% {
    opacity: 0;
  }
  95%,
  100% {
    opacity: 1;
  }
}
@keyframes boot-face-joy {
  0%,
  29% {
    opacity: 0;
  }
  31%,
  45% {
    opacity: 1;
  }
  47%,
  100% {
    opacity: 0;
  }
}
@keyframes boot-face-wink {
  0%,
  79% {
    opacity: 0;
  }
  81%,
  95% {
    opacity: 1;
  }
  97%,
  100% {
    opacity: 0;
  }
}
@keyframes boot-halo {
  from {
    opacity: 0.65;
    scale: 0.96;
  }
  to {
    opacity: 1;
    scale: 1.04;
  }
}
@keyframes boot-cheer {
  0% {
    translate: 0 0;
    scale: 1.08 0.9;
  }
  45% {
    translate: 0 -40px;
    scale: 0.96 1.06;
    rotate: -4deg;
  }
  100% {
    translate: 0 -30px;
    scale: 1.12;
    rotate: 0deg;
  }
}
@keyframes boot-twinkle {
  from {
    opacity: 0.25;
  }
  to {
    opacity: 0.9;
  }
}
@keyframes boot-rise {
  from {
    opacity: 0;
    translate: 0 14px;
  }
}
@keyframes boot-shine {
  0% {
    background-position: 100% 0;
  }
  60%,
  100% {
    background-position: 0% 0;
  }
}
@keyframes boot-dots {
  0% {
    content: '';
  }
  25% {
    content: '.';
  }
  50% {
    content: '..';
  }
  75%,
  100% {
    content: '...';
  }
}
@keyframes boot-sweep {
  to {
    background-position: 250% 0;
  }
}
@keyframes boot-failsafe {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

/* Moins d'animations demandées : la mascotte reste posée, les trois tuiles attendent dans le plateau, rien n'éclate ni ne
   scintille ; la barre et le pourcentage restent. */
@media (prefers-reduced-motion: reduce) {
  .boot *,
  .boot *::before,
  .boot *::after,
  .boot::before,
  .boot::after {
    animation: none !important;
  }
  .boot__tile {
    opacity: 1;
  }
  .boot__burst,
  .boot__line::after {
    display: none;
  }
}
