:root {
  --bord: #100000;
  --creme: #f6e9d6;
  --peche: #e3bf9a;
  --bleu: #2b72ac;
  --texte: #3a1e1a;
  --police: 'Fraunces', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bord);
  color: var(--creme);
  font-family: var(--police);
  overscroll-behavior: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
#scene.saisi { cursor: grabbing; }
#scene.sur-dent { cursor: pointer; }

/* ── intro ───────────────────────────── */
#intro {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--bord);
  transition: background 1.6s ease, opacity 1.4s ease, visibility 1.4s;
}
/* chargé : le tunnel et la dent se devinent derrière, assombris */
#intro.pret { background: rgba(16, 0, 0, 0.62); }
#intro.cache { opacity: 0; visibility: hidden; pointer-events: none; }
#entrer {
  font: inherit;
  font-size: 22px;
  font-style: italic;
  letter-spacing: 0.04em;
  color: var(--creme);
  background: rgba(16, 0, 0, 0.35);
  border: 1px solid rgba(246, 233, 214, 0.6);
  border-radius: 999px;
  padding: 12px 40px;
  cursor: pointer;
  animation: apparaitre 1.2s ease both;
  transition: background 0.3s, color 0.3s, transform 0.3s;
}
#entrer:hover, #entrer:focus-visible { background: var(--creme); color: var(--bord); transform: scale(1.05); outline: none; }
#entrer[hidden] { display: none; }
@keyframes apparaitre { from { opacity: 0; transform: scale(0.94); } }
#pourcentage {
  font-size: 15px;
  font-style: italic;
  letter-spacing: 0.08em;
  color: var(--creme);
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

/* ── indices ─────────────────────────── */
#indice {
  position: fixed;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  translate: -50% 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  font-size: 15px;
  font-style: italic;
  color: var(--creme);
  text-align: center;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.8s;
  pointer-events: none;
  white-space: nowrap;
}
#indice.visible { opacity: 0.85; }
.molette {
  width: 18px;
  height: 28px;
  border: 1.5px solid currentColor;
  border-radius: 10px;
  position: relative;
  flex: none;
}
.molette::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 5px;
  width: 2px;
  height: 6px;
  margin-left: -1px;
  border-radius: 2px;
  background: currentColor;
  animation: molette 1.6s ease-in-out infinite;
}
@keyframes molette {
  0% { transform: translateY(0); opacity: 1; }
  70% { transform: translateY(9px); opacity: 0; }
  100% { transform: translateY(0); opacity: 0; }
}

/* ── boutons-projets ─────────────────── */
#boutons {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.6s ease 0.3s;
}
#boutons.visible { opacity: 1; }
.bouton {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  pointer-events: none;
  will-change: transform;
}
#boutons.visible .bouton { pointer-events: auto; }
.bulle {
  display: grid;
  place-items: center;
  width: 150px;
  height: 150px;
  border-radius: 24px;
  overflow: hidden;
  background: rgba(255, 248, 240, 0.25);
  box-shadow: 0 0 0 3px rgba(255, 248, 240, 0.85), 0 14px 40px rgba(30, 60, 110, 0.35);
  transition: scale 0.35s cubic-bezier(.3, 1.6, .5, 1), box-shadow 0.35s;
}
.bulle img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bulle.vide {
  font-size: 64px;
  font-style: italic;
  color: #fff;
  background: radial-gradient(circle at 35% 30%, #f3d2b6, #c9a4b0 45%, #6a94bb 100%);
  animation: blob 7s ease-in-out infinite;
}
@keyframes blob {
  0%, 100% { border-radius: 42% 58% 55% 45% / 50% 44% 56% 50%; }
  50% { border-radius: 56% 44% 46% 54% / 44% 58% 42% 56%; }
}
.bouton:hover .bulle, .bouton:focus-visible .bulle {
  scale: 1.08;
  box-shadow: 0 0 0 4px #fff, 0 18px 50px rgba(30, 60, 110, 0.45);
}
.bouton:focus-visible { outline: none; }
.titre {
  font-size: 19px;
  font-style: italic;
  color: #fff;
  text-shadow: 0 1px 10px rgba(20, 40, 80, 0.55);
  white-space: nowrap;
}

/* ── aperçu ──────────────────────────── */
#apercu {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(36, 70, 120, 0.18);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.4s;
}
#apercu[hidden] { display: none; }
#apercu.ouvert { opacity: 1; }
.cadre-flottant {
  position: relative;
  width: min(560px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 14px 14px 22px;
  border-radius: 22px;
  background: rgba(255, 248, 240, 0.94);
  color: var(--texte);
  box-shadow: 0 30px 80px rgba(20, 40, 80, 0.4);
  scale: 0.9;
  transition: scale 0.5s cubic-bezier(.3, 1.4, .5, 1);
  animation: flotter 6s ease-in-out infinite;
}
#apercu.ouvert .cadre-flottant { scale: 1; }
@keyframes flotter {
  0%, 100% { translate: 0 -5px; rotate: -0.4deg; }
  50% { translate: 0 5px; rotate: 0.4deg; }
}
.fermer {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 1;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 248, 240, 0.9);
  color: var(--texte);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.media {
  aspect-ratio: 16 / 10;
  border-radius: 14px;
  overflow: hidden;
  background: #eadccb;
}
.media img, .media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-vide {
  display: grid;
  place-items: center;
  height: 100%;
  font-size: 90px;
  font-style: italic;
  color: #fff;
  background: linear-gradient(180deg, #3679b0, #849cb9 50%, #e3bf9a);
}
.cadre-flottant h2 { margin: 18px 8px 4px; font-weight: 400; font-style: italic; font-size: 30px; }
.cadre-flottant .texte { margin: 0 8px 18px; line-height: 1.5; opacity: 0.8; }
.visiter, .bientot { margin: 0 8px; display: inline-block; }
.visiter {
  padding: 11px 24px;
  border-radius: 999px;
  background: var(--bleu);
  color: #fff;
  text-decoration: none;
  transition: background 0.25s, transform 0.25s;
}
.visiter:hover { background: #1f5c8f; transform: translateX(3px); }
.visiter[hidden], .bientot[hidden] { display: none; }
.bientot { font-style: italic; opacity: 0.6; }

/* ── coin ────────────────────────────── */
#coin {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  z-index: 12;
  display: flex;
  gap: 8px;
}
#coin button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(246, 233, 214, 0.35);
  background: rgba(16, 0, 0, 0.25);
  color: var(--creme);
  font: inherit;
  font-size: 18px;
  cursor: pointer;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: background 0.25s;
}
#coin button:hover { background: rgba(16, 0, 0, 0.45); }
#coin button[hidden] { display: none; }
#son-btn.coupe { text-decoration: line-through; opacity: 0.6; }
/* le navigateur attend un clic avant de jouer du son : le bouton pulse doucement */
#son-btn.attente { animation: appel 1.8s ease-in-out infinite; }
@keyframes appel {
  0%, 100% { box-shadow: 0 0 0 0 rgba(246, 233, 214, 0.35); }
  50% { box-shadow: 0 0 0 8px rgba(246, 233, 214, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .cadre-flottant, .bulle.vide, .molette::after { animation: none; }
}
