/* Atelier Douze — accueil : écran-titre (piste A), jeu en place (piste D), sections légères (piste B).
   Voir site/explore/COMPARAISON.md §3. Le premier écran, le lecteur, la visionneuse et la barre Jouer restent
   sombres dans les deux thèmes : ce sont des écrans du jeu. */

/* Jetons sombres figés pour les écrans du jeu (valeurs sombres de tokens.css) */
.stage, .lightbox, .playbar {
  --ds-color-semantic-bg: #171A2E;
  --ds-color-semantic-bg-deep: #0E1020;
  --ds-color-semantic-surface: #222640;
  --ds-color-semantic-surface-2: #2B3052;
  --ds-color-semantic-surface-3: #3A3F66;
  --ds-color-semantic-border: #4A4F7A;
  --ds-color-semantic-border-strong: #6A6F9E;
  --ds-color-semantic-border-subtle: rgba(74, 79, 122, 0.45);
  --ds-color-semantic-text: #EEECF8;
  --ds-color-semantic-text-muted: #A9A6CF;
  --ds-color-semantic-text-inverse: #10131F;
  --ds-color-semantic-title: #E8A552;
  --ds-color-semantic-primary: #2FB8A8;
  --ds-color-semantic-primary-hover: #5ED0C2;
  --ds-color-semantic-primary-pressed: #1A9C8E;
  --ds-color-semantic-primary-text: #10131F;
  --ds-color-semantic-focus: #FFD166;
  --ds-color-semantic-focus-soft: rgba(255, 209, 102, 0.25);
  --ds-color-semantic-success: #5CC05C;
  --ds-color-semantic-danger-text: #F47B66;
  --ds-color-semantic-plate: rgba(8, 9, 20, 0.72);
  --ds-color-semantic-band-strong: rgba(34, 38, 64, 0.96);
  --ds-color-semantic-blueprint: rgba(47, 184, 168, 0.18);
  --cycle: 27s;
  color-scheme: dark;
  color: var(--ds-color-semantic-text);
}

/* ---------- Scène plein écran ---------- */
.stage {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "top" "title" "hint";
  overflow: hidden;
  isolation: isolate;
  background: var(--ds-color-semantic-bg-deep);
}

/* Fond : 3 captures en fondu enchaîné + lent travelling. Les 2 dernières ne se chargent qu'après la page (.is-live). */
.reel { position: absolute; inset: 0; z-index: -2; background: var(--ds-color-semantic-bg-deep); }
.slide {
  position: absolute; inset: -4%;
  background-size: cover;
  background-position: center;
  opacity: 0;
  will-change: opacity, transform;
}
.reel.is-live .slide { animation-name: reel; animation-duration: var(--cycle); animation-timing-function: linear; animation-iteration-count: infinite; }
/* Décalage de 5 % : la première capture est déjà affichée quand le diaporama démarre (pas de fondu au noir). */
.slide--combat  { background-image: url("../img/bg-combat-1920.webp"); --x0: -1.5%; --y0: 1%;  --x1: 1.5%;  --y1: -1%; opacity: 1; transform: scale(1.04) translate(var(--x0), var(--y0)); animation-delay: calc(var(--cycle) * -0.05); }
.slide--village { --x0: 2%; --y0: -1%; --x1: -1%; --y1: 1.5%; animation-delay: calc(var(--cycle) * (-2 / 3 - 0.05)); }
.slide--foret   { --x0: 0%; --y0: 2%;  --x1: 0%;  --y1: -1.5%; animation-delay: calc(var(--cycle) * (-1 / 3 - 0.05)); }
.reel.is-live .slide--village { background-image: url("../img/bg-village-1920.webp"); }
.reel.is-live .slide--foret   { background-image: url("../img/bg-foret-1920.webp"); }
@keyframes reel {
  0%    { opacity: 0; transform: scale(1.04) translate(var(--x0), var(--y0)); }
  4%    { opacity: 1; }
  33.3% { opacity: 1; }
  37.3% { opacity: 0; transform: scale(1.12) translate(var(--x1), var(--y1)); }
  100%  { opacity: 0; transform: scale(1.12) translate(var(--x1), var(--y1)); }
}
@media (max-width: 1100px) {
  .slide--combat { background-image: url("../img/bg-combat-1024.webp"); }
  .reel.is-live .slide--village { background-image: url("../img/bg-village-1024.webp"); }
  .reel.is-live .slide--foret   { background-image: url("../img/bg-foret-1024.webp"); }
}
@media (max-aspect-ratio: 3/4) {
  .slide--combat { background-image: url("../img/bg-combat-portrait.webp"); }
  .reel.is-live .slide--village { background-image: url("../img/bg-village-portrait.webp"); }
  .reel.is-live .slide--foret   { background-image: url("../img/bg-foret-portrait.webp"); }
}

/* Voile : le jeu reste visible, le texte posé sur un fond calme */
.scrim {
  position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 70% 60% at 50% 46%, rgba(8, 9, 20, 0.62) 0%, rgba(8, 9, 20, 0.25) 60%, rgba(8, 9, 20, 0) 100%),
    linear-gradient(to bottom, rgba(14, 16, 32, 0.55) 0%, rgba(14, 16, 32, 0) 18%, rgba(14, 16, 32, 0) 60%, rgba(14, 16, 32, 0.85) 88%, #0E1020 100%);
}

/* ---------- Barre du haut ---------- */
.topbar {
  grid-area: top;
  display: flex; align-items: center; justify-content: space-between; gap: var(--ds-space-4);
  padding: var(--ds-space-4) clamp(16px, 3vw, 40px);
  font-size: var(--ds-font-size-md);
}
.topbar__fan {
  font-size: var(--ds-font-size-2xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ds-color-semantic-text-muted);
  background: var(--ds-color-semantic-plate);
  border: 1px solid var(--ds-color-semantic-border-subtle);
  border-radius: var(--ds-radius-pill);
  padding: 3px 10px;
  white-space: nowrap;
}
.topbar__nav { display: flex; align-items: center; gap: var(--ds-space-2); margin-left: auto; }
.topbar__nav a {
  text-decoration: none;
  color: var(--ds-color-semantic-text);
  padding: 6px 12px;
  border-radius: var(--ds-radius-md);
  background: var(--ds-color-semantic-plate);
  transition: background var(--ds-motion-duration-fast) var(--ds-motion-easing-out);
}
.topbar__nav a:hover { background: var(--ds-color-semantic-surface-2); color: var(--ds-color-semantic-text); }
.topbar__theme { --b-bg: var(--ds-color-semantic-plate); --b-fg: var(--ds-color-semantic-text); min-height: 36px; width: 36px; min-width: 36px; }

/* ---------- Bloc titre ---------- */
.title {
  grid-area: title;
  align-self: center; justify-self: center;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: var(--ds-space-5) 16px var(--ds-space-6);
  max-width: 100%;
}
.title__plate {
  background: var(--ds-color-semantic-band-strong);
  border: 1px solid var(--ds-color-semantic-border);
  border-radius: var(--ds-radius-lg);
  padding: 14px 22px 12px;
  box-shadow: var(--ds-elevation-lg);
  color: var(--ds-color-semantic-text);
}
.title__logo { display: block; width: clamp(200px, 22vw, 300px); height: auto; --brand-accent: var(--ds-color-semantic-title); }
.title h1 {
  margin: var(--ds-space-6) 0 0;
  font-weight: 700;
  font-size: clamp(2.25rem, 6vw, 5.25rem);
  color: var(--ds-color-core-white);
  text-shadow: 0 3px 0 rgba(8, 9, 20, 0.55), 0 10px 32px rgba(8, 9, 20, 0.7);
  text-wrap: balance;
}
.title__sub {
  margin: var(--ds-space-4) 0 0;
  max-width: 44ch;
  font-size: clamp(1rem, 1.4vw, 1.25rem);
  text-shadow: 0 2px 10px rgba(8, 9, 20, 0.9);
  text-wrap: balance;
}
.title__sub strong { color: var(--ds-color-semantic-title); font-weight: 700; }

/* Le bouton Jouer : l'élément dominant */
.play {
  position: relative;
  margin-top: var(--ds-space-7);
  display: inline-flex; align-items: center; justify-content: center; gap: 14px;
  min-width: min(360px, 100%);
  height: 84px;
  padding: 0 56px 0 44px;
  border-radius: var(--ds-radius-xl);
  background: var(--ds-color-semantic-primary);
  color: var(--ds-color-semantic-primary-text);
  border: 2px solid var(--ds-color-semantic-primary-pressed);
  text-decoration: none;
  font-family: var(--ds-font-family-display);
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  box-shadow: 0 6px 0 var(--ds-color-semantic-primary-pressed), 0 18px 40px rgba(47, 184, 168, 0.35), var(--ds-elevation-lg);
  transition: transform var(--ds-motion-duration-fast) var(--ds-motion-easing-out),
              background var(--ds-motion-duration-fast) var(--ds-motion-easing-out),
              box-shadow var(--ds-motion-duration-fast) var(--ds-motion-easing-out);
}
.play::after {
  content: ""; position: absolute; inset: -6px;
  border-radius: 12px;
  border: 2px solid var(--ds-color-semantic-focus);
  opacity: 0;
  animation: pulse var(--ds-motion-duration-pulse) var(--ds-motion-easing-out) infinite 1.2s;
  pointer-events: none;
}
@keyframes pulse { 0% { opacity: 0.9; transform: scale(0.98); } 100% { opacity: 0; transform: scale(1.08); } }
/* L'anneau de focus global (site.css) est écrasé par l'ombre du bouton : on le remet devant l'ombre. */
.play:focus-visible { box-shadow: var(--ring), 0 6px 0 var(--ds-color-semantic-primary-pressed), 0 18px 40px rgba(47, 184, 168, 0.35), var(--ds-elevation-lg); }
.play:focus-visible::after { opacity: 0; animation: none; }
.play:hover { background: var(--ds-color-semantic-primary-hover); color: var(--ds-color-semantic-primary-text); transform: translateY(-2px) scale(1.02); }
.play:active { background: var(--ds-color-semantic-primary-pressed); transform: translateY(4px) scale(0.98); box-shadow: 0 2px 0 var(--ds-color-semantic-primary-pressed), var(--ds-elevation-md); }
.play__icon { width: 34px; height: 34px; fill: currentColor; flex: none; }
.play__key {
  position: absolute; top: -10px; right: -10px;
  min-width: 0;
  font-size: var(--ds-font-size-2xs);
  line-height: 1;
  padding: 5px 7px;
  border-width: 1px;
  border-color: var(--ds-color-semantic-border-strong);
}
.title__meta {
  margin: var(--ds-space-6) 0 0;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px;
  font-size: var(--ds-font-size-sm);
  color: var(--ds-color-semantic-text-muted);
  text-shadow: 0 1px 6px rgba(8, 9, 20, 0.9);
}
.title__meta span::before { content: "\2713"; color: var(--ds-color-semantic-primary); font-weight: 700; margin-right: 6px; }

.scroll-hint {
  grid-area: hint; justify-self: center;
  display: grid; place-items: center;
  width: 44px; height: 44px; margin-bottom: var(--ds-space-4);
  border-radius: 50%;
  color: var(--ds-color-semantic-text-muted);
  animation: nudge 2.4s var(--ds-motion-easing-in-out) infinite;
}
.scroll-hint svg { width: 28px; height: 28px; fill: currentColor; }
.scroll-hint:hover { color: var(--ds-color-semantic-text); }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(5px); } }

/* ---------- Le jeu en place ---------- */
.game {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column;
  background: var(--ds-color-semantic-bg-deep);
}
.stage.is-playing .topbar, .stage.is-playing .title, .stage.is-playing .scroll-hint { visibility: hidden; }
.stage.is-playing .reel .slide { animation-play-state: paused; }
html.is-playing, html.is-playing body { overflow: hidden; }
.game__bar {
  display: flex; align-items: center; gap: var(--ds-space-4);
  min-height: 52px;
  padding: 6px clamp(8px, 2vw, 24px);
  background: var(--ds-color-semantic-surface);
  border-bottom: 1px solid var(--ds-color-semantic-border-subtle);
  font-size: var(--ds-font-size-sm);
}
.game__btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 12px;
  font: 700 var(--ds-font-size-md) var(--ds-font-family-text);
  color: var(--ds-color-semantic-text);
  background: var(--ds-color-semantic-surface-2);
  border: 1px solid var(--ds-color-semantic-border);
  border-radius: var(--ds-radius-md);
  cursor: pointer;
}
.game__btn:hover { background: var(--ds-color-semantic-surface-3); }
.game__btn svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.game__btn--icon { width: 40px; padding: 0; justify-content: center; margin-left: auto; }
.game__btn kbd { font-size: var(--ds-font-size-2xs); }
.game.is-running .game__esc { display: none; } /* en jeu, Échap ouvre le menu du jeu */
.game__name { font-family: var(--ds-font-family-display); font-size: var(--ds-font-size-lg); color: var(--ds-color-semantic-title); white-space: nowrap; }
.game__keys { margin: 0 0 0 auto; display: flex; gap: var(--ds-space-4); color: var(--ds-color-semantic-text-muted); white-space: nowrap; }
.game__keys + .game__btn--icon { margin-left: 0; }
.game__frame { position: relative; flex: 1; min-height: 0; }
.game__frame canvas { width: 100%; height: 100%; background: #000; }
.game__alt { justify-content: center; }
.stage:fullscreen { min-height: 100vh; }

/* ---------- Sections sous l'écran-titre ---------- */
.home-section { padding: var(--ds-space-8) 0 0; }
@media (min-width: 720px) { .home-section { padding-top: var(--ds-space-9); } }
.hub { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--ds-space-5); }
@media (min-width: 720px) { .hub { grid-template-columns: repeat(3, 1fr); } }
.hub__item {
  background: var(--ds-color-semantic-surface);
  border: 1px solid var(--ds-color-semantic-border-subtle);
  border-radius: var(--ds-radius-xl);
  overflow: hidden;
}
.hub__img { aspect-ratio: 16 / 10; background: #0E1020; overflow: hidden; }
.hub__img img { width: 100%; height: 100%; object-fit: cover; }
.hub__item:not(:first-child) .hub__img img { filter: saturate(0.6) brightness(0.85); }
.hub__body { padding: var(--ds-space-4) var(--ds-space-5) var(--ds-space-5); }
.hub__top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--ds-space-2) var(--ds-space-3); }
.hub__top h3 { margin: 0; font-family: var(--ds-font-family-display); color: var(--ds-color-semantic-title); }
.hub__body p { margin: var(--ds-space-2) 0 0; color: var(--ds-color-semantic-text-muted); font-size: var(--ds-font-size-md); }
@media (max-width: 719px) {
  .hub__item { display: grid; grid-template-columns: 40% 1fr; align-items: stretch; }
  .hub__img { aspect-ratio: auto; min-height: 104px; }
  .hub__body { padding: var(--ds-space-3) var(--ds-space-4); align-self: center; }
  .hub__top h3 { font-size: var(--ds-font-size-lg); }
}

.gallery { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 720px) { .gallery { grid-template-columns: repeat(3, 1fr); } }
.gallery button {
  position: relative; padding: 0; border: 0;
  border-radius: var(--ds-radius-lg); overflow: hidden;
  background: #0E1020; aspect-ratio: 16 / 9; cursor: zoom-in;
}
.gallery button:first-child { grid-column: span 2; grid-row: span 2; aspect-ratio: auto; }
.gallery img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--ds-motion-duration-slow) var(--ds-motion-easing-out); }
.gallery button:hover img { transform: scale(1.04); }
.gallery span {
  position: absolute; left: 8px; bottom: 8px; padding: 3px 8px;
  border-radius: var(--ds-radius-sm);
  background: rgba(8, 9, 20, 0.72); color: #EEECF8;
  font-size: var(--ds-font-size-xs); font-weight: 700;
}
@media (max-width: 719px) {
  .gallery button:first-child, .gallery button:last-child { grid-column: span 2; grid-row: auto; aspect-ratio: 16 / 9; }
}

.cta {
  margin-top: var(--ds-space-8);
  padding: var(--ds-space-8) 0;
  text-align: center;
  background: var(--ds-color-semantic-bg-deep);
  border-top: 1px solid var(--ds-color-semantic-border-subtle);
}
.cta h2 { margin-bottom: var(--ds-space-5); }
.cta__btn { gap: var(--ds-space-3); padding: 0 var(--ds-space-7); font-size: var(--ds-font-size-xl); min-height: 60px; }
.cta__btn svg { width: 22px; height: 22px; fill: currentColor; }
.home .site-footer { margin-top: 0; }

/* ---------- Barre Jouer (téléphone) ---------- */
.playbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(14, 16, 32, 0.94);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-top: 1px solid var(--ds-color-semantic-border-subtle);
  transform: translateY(110%);
  visibility: hidden;
  transition: transform var(--ds-motion-duration-slow) var(--ds-motion-easing-out), visibility 0s linear var(--ds-motion-duration-slow);
}
.playbar.is-on { transform: none; visibility: visible; transition-delay: 0s; }
.playbar__txt { min-width: 0; line-height: 1.25; }
.playbar__txt b { display: block; font-family: var(--ds-font-family-display); font-weight: 400; color: var(--ds-color-semantic-title); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.playbar__txt small { color: var(--ds-color-semantic-text-muted); font-size: var(--ds-font-size-xs); }
.playbar .ds-button { margin-left: auto; min-height: 44px; padding: 0 24px; flex: none; }
@media (min-width: 720px) { .playbar { display: none; } }

/* ---------- Visionneuse ---------- */
.lightbox { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(5, 6, 14, 0.92); }
.lightbox img { max-width: min(1600px, 100%); max-height: 86vh; border-radius: var(--ds-radius-lg); box-shadow: var(--ds-elevation-lg); }
.lightbox button {
  position: absolute; width: 44px; height: 44px; border-radius: 50%; border: 0;
  display: grid; place-items: center; cursor: pointer;
  background: var(--ds-color-semantic-surface-3); color: #EEECF8;
}
.lightbox button svg { width: 22px; height: 22px; fill: currentColor; }
.lb-close { top: 16px; right: 16px; }
.lb-prev { left: 16px; top: 50%; translate: 0 -50%; }
.lb-next { right: 16px; top: 50%; translate: 0 -50%; }
.lightbox p { position: absolute; bottom: 16px; left: 0; right: 0; margin: 0; text-align: center; color: #EEECF8; font-weight: 700; }

/* ---------- Téléphone ---------- */
@media (max-width: 720px) {
  .topbar { padding-top: var(--ds-space-3); padding-bottom: var(--ds-space-3); }
  .topbar__nav a { padding: 6px 10px; }
  .title { padding-top: var(--ds-space-3); padding-bottom: var(--ds-space-4); }
  .title__plate { padding: 10px 16px 8px; }
  .title__logo { width: 190px; }
  .title h1 { margin-top: var(--ds-space-5); font-size: 2.5rem; }
  .title__sub { font-size: var(--ds-font-size-lg); max-width: 32ch; }
  .play { width: 100%; max-width: 358px; min-width: 0; height: 72px; font-size: 2.125rem; padding: 0 40px; margin-top: var(--ds-space-6); }
  .play__icon { width: 28px; height: 28px; }
  .play__key { display: none; }
  .title__meta { gap: 4px 12px; font-size: var(--ds-font-size-xs); margin-top: var(--ds-space-5); }
  .scroll-hint { margin-bottom: var(--ds-space-2); }
  .game__keys, .game__name, .game__btn kbd { display: none; }
  .game__keys + .game__btn--icon { margin-left: auto; }
  .scrim {
    background:
      radial-gradient(ellipse 95% 55% at 50% 46%, rgba(8, 9, 20, 0.72) 0%, rgba(8, 9, 20, 0.3) 70%, rgba(8, 9, 20, 0) 100%),
      linear-gradient(to bottom, rgba(14, 16, 32, 0.6) 0%, rgba(14, 16, 32, 0) 14%, rgba(14, 16, 32, 0) 60%, rgba(14, 16, 32, 0.9) 88%, #0E1020 100%);
  }
  .home .site-footer { padding-bottom: 72px; }
}
@media (max-width: 380px) { .topbar__fan { display: none; } }
@media (max-height: 640px) and (min-width: 721px) {
  .title h1 { font-size: clamp(2rem, 5vw, 3.5rem); margin-top: var(--ds-space-5); }
  .play { height: 68px; font-size: 2rem; margin-top: var(--ds-space-6); }
}
@media (max-height: 700px) and (max-width: 720px) {
  .title h1 { font-size: 2.125rem; margin-top: var(--ds-space-4); }
  .title__sub { font-size: var(--ds-font-size-md); }
  .play { height: 64px; font-size: 1.875rem; margin-top: var(--ds-space-5); }
  .scroll-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .reel.is-live .slide { animation: none; }
  .slide--village, .slide--foret { display: none; }
  .play::after, .scroll-hint { animation: none; }
}
