/* Faux-Pas : la nuit du manoir. Une seule chose brille, la lumière (torche, cristaux, éclair) ; tout le reste se tait. */

:root {
  --nuit: #05080b;       /* le noir bleuté du manoir, fond de toute la page */
  --ardoise: #10181e;    /* surfaces : panneau, cadres des portraits */
  --pierre: #d3dcd9;     /* texte, la pierre pâle du logo */
  --brume: #8a9ba2;      /* texte secondaire */
  --cristal: #5fe3e0;    /* les cristaux : liens, focus, fil du déroulé */
  --torche: #ffd98a;     /* la lumière chaude de la torche */
  --sang: #8e1b1b;       /* le liseré de sang du logo : l'action principale */
  --sang-vif: #c94a3a;

  --serif: 'IM Fell English', 'Iowan Old Style', Georgia, serif;
  --sans: 'Karla', system-ui, sans-serif;
  --marge: clamp(16px, 5vw, 72px);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--nuit); }
body {
  margin: 0;
  background: var(--nuit);
  color: var(--pierre);
  font: 400 1.125rem/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
a { color: var(--cristal); }
:focus-visible { outline: 2px solid var(--cristal); outline-offset: 3px; }
h2, h3 { font-weight: 400; margin: 0; }
h2 { font: 400 clamp(2.1rem, 4.4vw, 3.4rem)/1.1 var(--serif); letter-spacing: -0.005em; }
h3 { font: 700 1.05rem/1.3 var(--sans); }
.pixel, .ados img, .monstre img, .deroule img, .niveau img { image-rendering: pixelated; }

/* ---------- Boutons ---------- */
.actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-block;
  padding: 0.8em 1.4em;
  font: 700 1rem/1 var(--sans);
  text-decoration: none;
  border: 2px solid;
  border-radius: 3px;
}
.btn-sang { background: var(--sang); border-color: var(--sang-vif); color: #fff; box-shadow: 0 0 24px #8e1b1b66; }
.btn-sang:hover { background: #a42222; box-shadow: 0 0 32px #c94a3a88; }
.btn-ombre { background: #0b1116cc; border-color: #34444d; color: var(--brume); }
.btn-ombre[aria-disabled="true"] { cursor: default; }
/* les magasins, pas encore ouverts : logo, « Bientôt sur » en petit au-dessus du nom */
.btn-magasin { display: inline-flex; align-items: center; gap: 0.6em; text-align: left; line-height: 1.1; opacity: 0.85; }
.btn-magasin svg { width: 1.5em; height: 1.5em; flex: none; }
.btn-magasin small { display: block; font-size: 0.68em; letter-spacing: 0.04em; text-transform: uppercase; color: var(--brume); opacity: 0.8; }

/* ---------- Accueil : la scène ---------- */
.accueil {
  position: relative;
  height: 100svh;
  min-height: 560px;
  overflow: hidden;
  container-type: size;
  background: var(--nuit);
  touch-action: pan-y;
}
.toile {
  position: absolute;
  left: 50%; top: 50%;
  width: max(100cqw, calc(100cqh * 1376 / 768));
  aspect-ratio: 1376 / 768;
  transform: translate(-50%, -50%);
}
.toile canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
/* L'entrée : rien n'est visible tant que la scène n'est pas prête ; puis le manoir sort du noir, le titre se précise,
   la phrase et les boutons arrivent (classe « prete » posée par main.js) */
.accueil .toile { opacity: 0; transition: opacity 1.2s ease-out; }
.accueil-titre { opacity: 0; filter: blur(8px); transform: translateY(10px);
  transition: opacity 0.8s ease-out 0.35s, filter 0.8s ease-out 0.35s, transform 0.8s ease-out 0.35s; }
.accueil-bas, .accueil .son { opacity: 0; transition: opacity 0.6s ease-out 0.85s; }
.accueil.prete .toile, .accueil.prete .accueil-bas, .accueil.prete .son { opacity: 1; }
.accueil.prete .accueil-titre { opacity: 1; filter: none; transform: none; }
.accueil.sans-webgl .toile { background: url(../img/fond.webp) center / cover; filter: brightness(0.55); }
.accueil::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0; height: 22%;
  background: linear-gradient(transparent, var(--nuit));
  pointer-events: none;
}
.accueil-titre {
  position: absolute; top: 5%; left: 0; right: 0;
  margin: 0;
  text-align: center;
  pointer-events: none;
}
.accueil-titre img { width: min(40vw, 560px); height: auto; filter: drop-shadow(0 6px 18px #000); }
.accueil-bas {
  position: absolute; left: 0; right: 0; bottom: max(5%, 28px);
  z-index: 1;
  display: grid; justify-items: center; gap: 18px;
  padding: 0 var(--marge);
  text-align: center;
}
.accroche {
  margin: 0;
  font: italic 400 clamp(1.3rem, 2.4vw, 1.9rem)/1.2 var(--serif);
  text-shadow: 0 2px 8px #000;
}
.son {
  position: absolute; top: 18px; right: var(--marge);
  z-index: 1;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: #05080b99; color: var(--brume);
  border: 1px solid #2a3840; border-radius: 3px;
  font: 600 0.85rem/1 var(--sans);
  cursor: pointer;
}
.son svg { width: 16px; height: 16px; }
.son[aria-pressed="true"] { color: var(--torche); border-color: #6b5a3a; }
.bulle {
  position: absolute;
  transform: translate(-50%, 0);
  font: 600 0.85rem/1 var(--sans);
  color: var(--torche);
  text-shadow: 0 1px 4px #000;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.6s;
}
.bulle.cachee { opacity: 0; }
.bulle .souris {
  display: inline-block; position: relative;
  width: 12px; height: 18px; margin-right: 7px; vertical-align: -4px;
  border: 2px solid var(--torche); border-radius: 7px;
}
.bulle .souris::after {
  content: ''; position: absolute; left: 3px; top: 3px;
  width: 2px; height: 4px; background: var(--torche); border-radius: 1px;
  animation: molette 1.2s infinite;
}
@keyframes molette { from { transform: translateY(0); opacity: 1; } to { transform: translateY(6px); opacity: 0; } }
@media (hover: none) { .bulle .souris { display: none; } }

/* ---------- Sections ---------- */
main section { padding: clamp(72px, 12vw, 160px) var(--marge); }
.colonne { max-width: 40rem; }
.chapeau { margin: 20px 0 0; font-size: 1.25rem; color: var(--brume); max-width: 34rem; }

/* Une partie : texte et ados à gauche, déroulé de la partie à droite, relié par le fil des cristaux */
.partie {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(40px, 7vw, 120px);
  align-items: start;
}
.ados { list-style: none; display: flex; gap: 4px; margin: 40px 0 0; padding: 0; }
.ados img { width: 112px; height: 112px; display: block; }
.deroule { list-style: none; margin: 0; padding: 0; position: relative; }
.deroule::before {
  content: ''; position: absolute; left: 15px; top: 20px; bottom: 30px; width: 2px;
  background: linear-gradient(var(--cristal), #5fe3e000);
  opacity: 0.35;
}
.deroule li { display: grid; grid-template-columns: 32px 1fr; gap: 22px; padding-bottom: 36px; position: relative; }
.deroule li > img { justify-self: center; height: 34px; width: auto; filter: drop-shadow(0 0 6px #5fe3e055); background: var(--nuit); padding: 4px 0; }
.deroule p { margin: 6px 0 0; color: var(--brume); max-width: 30rem; }

/* Bestiaire : les monstres dans le noir, révélés par la lampe */
.bestiaire { border-top: 1px solid #ffffff0d; }
.monstres {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(20px, 3vw, 40px);
  margin-top: 56px;
}
.portrait {
  position: relative;
  aspect-ratio: 1;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 60%, #121c22 0%, var(--nuit) 70%);
  border: 1px solid #1c2830;
  overflow: hidden;
  cursor: none;
}
.portrait img { width: 92%; height: auto; }
.portrait::after {
  content: '';
  position: absolute; inset: 0;
  background: var(--nuit);
  -webkit-mask-image: radial-gradient(circle 150px at var(--x, -999px) var(--y, -999px), transparent 0, transparent 35%, #000 100%);
          mask-image: radial-gradient(circle 150px at var(--x, -999px) var(--y, -999px), transparent 0, transparent 35%, #000 100%);
  opacity: 0.96;
}
.monstre h3 { font: 400 1.6rem/1.2 var(--serif); margin-top: 18px; }
.niveau { display: flex; align-items: center; gap: 4px; margin: 6px 0 0; font-size: 0.9rem; color: var(--brume); }
.niveau img { height: 16px; width: auto; }
.niveau img.eteint { filter: grayscale(1) brightness(0.35); }
.niveau img:last-of-type { margin-right: 6px; }
.monstre p:last-child { margin: 10px 0 0; color: var(--brume); font-size: 1rem; }
@media (hover: none) { .portrait::after { display: none; } .portrait { cursor: auto; } }

/* Le couloir : la scène reste à l'écran pendant que la page défile, et le défilement fait avancer l'histoire */
main .couloir { height: 405vh; padding: 0; position: relative; border-top: 1px solid #ffffff0d; }
main .couloir.jouee { height: 100svh; } /* une fois jouée, elle ne retient plus le défilement */
.couloir-scene { position: sticky; top: 0; height: 100svh; overflow: hidden; }
.couloir-toile { position: absolute; inset: 0; width: 100%; height: 100%; }
.couloir-texte { position: absolute; top: clamp(32px, 7vh, 80px); left: var(--marge); right: var(--marge); max-width: 40rem; }
.couloir-legendes { position: relative; min-height: 4.5em; margin-top: 18px; }
.couloir-legendes p {
  position: absolute; inset: 0 auto auto 0; margin: 0;
  font: italic 400 clamp(1.25rem, 2.2vw, 1.7rem)/1.3 var(--serif);
  color: var(--pierre);
  opacity: 0; transition: opacity 0.5s;
}
.couloir-legendes p.visible { opacity: 1; }
.couloir .son-couloir { position: relative; top: auto; right: auto; margin-top: 4px; }
.couloir-indice { position: absolute; bottom: 24px; left: 0; right: 0; margin: 0; text-align: center; font-size: 0.85rem; color: var(--brume); }

/* Appel final */
.appel { border-top: 1px solid #ffffff0d; }
.appel p { color: var(--brume); margin: 20px 0 32px; max-width: 34rem; }

/* Pied de page */
.pied { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 32px var(--marge); border-top: 1px solid #ffffff0d; color: var(--brume); font-size: 0.9rem; }
.pied img { width: 140px; height: auto; opacity: 0.7; }
.pied p { margin: 0; }

/* ---------- Réglages de la scène (pour le porteur) ---------- */
.reglages-bouton {
  position: fixed; left: 16px; bottom: 16px; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--ardoise); color: var(--brume);
  border: 1px solid #2a3840; border-radius: 3px;
  font: 600 0.8rem/1 var(--sans);
  cursor: pointer;
}
.reglages-bouton svg { width: 14px; height: 14px; }
.reglages-bouton[aria-expanded="true"] { color: var(--torche); }
.reglages-panneau {
  position: fixed; left: 16px; bottom: 60px; z-index: 20;
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  padding: 16px 18px 18px;
  background: var(--ardoise);
  border: 1px solid #2a3840; border-radius: 4px;
  box-shadow: 0 12px 40px #000c;
  font-size: 0.85rem;
}
.reglages-tete { display: flex; justify-content: space-between; align-items: center; }
.reglages-tete h2 { font: 700 0.95rem/1 var(--sans); }
.reglages-fermer { background: none; border: 0; color: var(--brume); font-size: 1.4rem; line-height: 1; cursor: pointer; padding: 2px 6px; }
.reglages-panneau fieldset { border: 0; border-top: 1px solid #ffffff14; margin: 12px 0 0; padding: 10px 0 0; }
.reglages-panneau legend { font-weight: 700; color: var(--pierre); padding: 0; }
.reglage { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; margin-top: 8px; color: var(--brume); }
.reglage input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--cristal); }
.reglage output { color: var(--pierre); font-variant-numeric: tabular-nums; }
.reglage.case { display: flex; align-items: center; gap: 8px; }
.reglage select { grid-column: 1 / -1; background: #1b2730; color: var(--pierre); border: 1px solid #34444d; border-radius: 3px; padding: 5px 6px; font: inherit; }
.reglages-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.reglages-actions button { background: #1b2730; color: var(--pierre); border: 1px solid #34444d; border-radius: 3px; padding: 7px 10px; font: 600 0.8rem/1 var(--sans); cursor: pointer; }
.reglages-etat { margin: 10px 0 0; color: var(--cristal); white-space: pre-wrap; word-break: break-word; }
.reglages-etat:empty { display: none; }

/* ---------- Petits écrans ---------- */
@media (max-width: 900px) {
  .partie { grid-template-columns: 1fr; }
  .monstres { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ados img { width: 76px; height: 76px; }
}
@media (max-width: 600px) {
  body { font-size: 1.05rem; }
  .accueil-titre { top: 64px; }
  .accueil-titre img { width: 82vw; }
  .accueil-bas { bottom: 76px; }
  .accueil-bas .btn { font-size: 0.9rem; padding: 0.75em 1.1em; }
  .pied { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .accueil .toile, .accueil-bas, .accueil .son { transition: opacity 0.4s ease-out; }
  .accueil-titre { transition: opacity 0.4s ease-out; filter: none; transform: none; }
  .bulle .souris::after { animation: none; }
  .bulle { transition: none; }
  .couloir-legendes p { transition: none; }
}
