@font-face { font-family: "Bodoni Moda"; font-style: normal; font-weight: 400 700; font-display: swap; src: url(fonts/bodoni.woff2) format("woff2"); }
@font-face { font-family: "Bodoni Moda"; font-style: italic; font-weight: 400 700; font-display: swap; src: url(fonts/bodoni-italic.woff2) format("woff2"); }
@font-face { font-family: "Spectral"; font-style: normal; font-weight: 300; font-display: swap; src: url(fonts/spectral-300.woff2) format("woff2"); }
@font-face { font-family: "Spectral"; font-style: italic; font-weight: 300; font-display: swap; src: url(fonts/spectral-300i.woff2) format("woff2"); }
@font-face { font-family: "Spectral"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/spectral-400.woff2) format("woff2"); }

:root {
  --nuit: #05070f;
  --lune: #e9eef8;
  --lueur: 157, 182, 232; /* la couleur du monde traversé, changée par le script */
  --titre: "Bodoni Moda", "Didot", "Bodoni MT", serif;
  --texte: "Spectral", "Iowan Old Style", Georgia, serif;
  --marge: clamp(1.5rem, 7vw, 8rem);
}

* { box-sizing: border-box; }

html { background: var(--nuit); }

body {
  margin: 0;
  color: var(--lune);
  font-family: var(--texte);
  font-weight: 300;
  font-size: clamp(1.125rem, 0.95rem + 0.6vw, 1.5rem);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ——— Le décor ——— */

#decor { position: fixed; inset: 0; overflow: hidden; background: var(--nuit); }

.plan {
  position: absolute;
  left: 0; top: 0;
  transform-origin: 0 0;
  will-change: transform, opacity;
  visibility: hidden;
}
.plan img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
}
/* L'image du dessus garde la brume peinte dans la porte ; elle s'efface quand on s'approche. */
.plan .plein { will-change: opacity; }

.brume {
  position: absolute;
  inset: -10% -50%;
  pointer-events: none;
  background:
    radial-gradient(40% 30% at 20% 78%, rgba(var(--lueur), 0.16), transparent 70%),
    radial-gradient(35% 26% at 62% 86%, rgba(var(--lueur), 0.13), transparent 70%),
    radial-gradient(30% 22% at 88% 70%, rgba(var(--lueur), 0.10), transparent 70%);
  filter: blur(30px);
  animation: derive 38s ease-in-out infinite alternate;
  transition: background 1.2s;
}
@keyframes derive { from { transform: translate3d(-9%, 0, 0); } to { transform: translate3d(9%, -3%, 0); } }

#poussiere { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.voile {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(3, 4, 10, 0.86) 0%, rgba(3, 4, 10, 0.5) 30%, rgba(3, 4, 10, 0) 52%),
    radial-gradient(120% 90% at 50% 50%, rgba(3, 4, 10, 0) 55%, rgba(3, 4, 10, 0.75) 100%);
}

/* ——— Les textes : un bloc par monde, fixe, qui apparaît quand on y arrive ——— */

.monde {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  padding: 10vh var(--marge);
  pointer-events: none;
  visibility: hidden;
}
.monde.vu { visibility: visible; }
.monde.vu .bloc { pointer-events: auto; }

.bloc { max-width: 30rem; }
.seuil .bloc { max-width: none; }

h1, h2 {
  font-family: var(--titre);
  font-weight: 400;
  margin: 0;
  text-wrap: balance;
}

.titre {
  font-size: clamp(4.2rem, 11vw, 10.5rem);
  line-height: 0.8;
  letter-spacing: -0.035em;
  font-variation-settings: "opsz" 96;
  text-shadow: 0 0 70px rgba(var(--lueur), 0.45);
}
.titre > span { display: block; white-space: nowrap; }
.titre > span + span { margin-left: 0.42em; }

.auteur { margin: 2.2rem 0 0; font-style: italic; font-size: 1.25em; }

.invite {
  margin: 4rem 0 0;
  font-size: 0.8em;
  color: rgb(var(--lueur));
  display: flex;
  align-items: center;
  gap: 0.9rem;
}
.fil {
  width: 1px; height: 3.2rem;
  background: linear-gradient(rgba(var(--lueur), 0), rgb(var(--lueur)));
  transform-origin: top;
  animation: couler 2.4s ease-in-out infinite;
}
@keyframes couler { 0% { transform: scaleY(0); opacity: 0; } 40% { transform: scaleY(1); opacity: 1; } 100% { transform: scaleY(1) translateY(1.2rem); opacity: 0; } }

h2 {
  font-size: clamp(2.1rem, 1.3rem + 3.2vw, 4.3rem);
  line-height: 1.02;
  letter-spacing: -0.015em;
  margin-bottom: 1.6rem;
  font-variation-settings: "opsz" 60;
  text-shadow: 0 0 50px rgba(var(--lueur), 0.35), 0 2px 20px rgba(3, 4, 10, 0.9);
}

p {
  margin: 0 0 1.1em;
  text-wrap: pretty;
  text-shadow: 0 1px 14px rgba(3, 4, 10, 0.95), 0 0 2px rgba(3, 4, 10, 0.8);
}
.bloc p:last-child { margin-bottom: 0; }
.chute { font-style: italic; color: rgb(var(--lueur)); }

/* Chaque mot sort de la brume, l'un après l'autre. */
.mot, .lettre {
  display: inline-block;
  opacity: 0;
  filter: blur(10px);
  transform: translateY(0.35em);
  transition: opacity 0.5s ease, filter 0.5s ease, transform 0.5s ease;
}
.lettre { transform: translateY(0.18em) scale(1.08); }
.vu .mot, .vu .lettre {
  opacity: 1;
  filter: blur(0);
  transform: none;
  transition: opacity 1.1s ease var(--d, 0s), filter 1.3s ease var(--d, 0s), transform 1.3s cubic-bezier(0.2, 0.7, 0.2, 1) var(--d, 0s);
}
.apparait { opacity: 0; transition: opacity 0.5s ease; }
.vu .apparait { opacity: 1; transition: opacity 1.4s ease var(--d, 0s); }

/* ——— Le livre ——— */

.livre .bloc {
  max-width: 56rem;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 19rem) minmax(0, 26rem);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: center;
}

.couverture { margin: 0; perspective: 1400px; }
.volume {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 2px 5px 5px 2px;
  overflow: hidden;
  transform: rotateY(var(--ry, -12deg)) rotateX(var(--rx, 2deg));
  transform-origin: center;
  transition: transform 0.25s ease-out;
  box-shadow:
    inset 6px 0 10px -6px rgba(255, 255, 255, 0.3),
    0 40px 80px -20px rgba(0, 0, 0, 0.95),
    0 0 110px -10px rgba(var(--lueur), 0.45);
  animation: flotter 7s ease-in-out infinite;
}
@keyframes flotter { 50% { translate: 0 -10px; } }
.volume img { width: 100%; height: 100%; object-fit: cover; display: block; }
.volume figcaption {
  position: absolute;
  inset: 0;
  padding: 9% 8%;
  display: flex;
  flex-direction: column;
  text-align: center;
  font-family: var(--titre);
  background: linear-gradient(180deg, rgba(5, 8, 22, 0.55) 0%, rgba(5, 8, 22, 0) 45%, rgba(5, 8, 22, 0) 80%, rgba(5, 8, 22, 0.5) 100%);
}
.c-auteur { font-size: 1rem; letter-spacing: 0.04em; }
.c-titre {
  margin-top: 0.5rem;
  font-size: clamp(2.4rem, 5.6vw, 3.5rem);
  line-height: 0.9;
  letter-spacing: -0.03em;
  text-shadow: 0 0 30px rgba(190, 210, 245, 0.55);
}
.c-genre { margin-top: auto; font-style: italic; font-size: 0.9rem; }
.reflet {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, rgba(255, 255, 255, 0) 35%, rgba(255, 255, 255, 0.16) 50%, rgba(255, 255, 255, 0) 65%);
  background-size: 250% 100%;
  background-position: var(--reflet, 120%) 0;
  mix-blend-mode: screen;
}

.notice h2 { margin-bottom: 0.4rem; }
.signature { font-style: italic; font-size: 1.2em; color: rgb(var(--lueur)); margin-bottom: 1.6rem; }
.livre .chute { margin-top: 2rem; }

/* ——— Les repères : une petite porte par monde ——— */

.reperes {
  position: fixed;
  right: clamp(0.6rem, 2vw, 1.8rem);
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.reperes button {
  width: 44px; height: 44px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.reperes button::before {
  content: "";
  width: 9px; height: 16px;
  border: 1px solid rgba(233, 238, 248, 0.55);
  border-radius: 5px 5px 0 0;
  transition: background 0.5s, box-shadow 0.5s, height 0.5s, border-color 0.5s;
}
.reperes button:hover::before { border-color: #fff; }
.reperes button[aria-current="true"]::before {
  height: 24px;
  background: rgb(var(--lueur));
  border-color: rgb(var(--lueur));
  box-shadow: 0 0 18px rgba(var(--lueur), 0.9);
}

:focus-visible { outline: 2px solid rgb(var(--lueur)); outline-offset: 2px; }

#chemin { position: relative; z-index: 0; width: 1px; pointer-events: none; }

/* ——— Téléphone ——— */

@media (max-width: 760px) {
  .voile {
    background:
      linear-gradient(0deg, rgba(3, 4, 10, 0.92) 0%, rgba(3, 4, 10, 0.6) 38%, rgba(3, 4, 10, 0) 62%),
      linear-gradient(180deg, rgba(3, 4, 10, 0.55) 0%, rgba(3, 4, 10, 0) 26%);
  }
  .monde { align-items: flex-end; padding: 0 1.4rem 7vh; padding-right: 3.6rem; }
  .seuil { align-items: flex-start; padding-top: 9vh; }
  .seuil .invite { position: fixed; left: 1.4rem; bottom: 6vh; margin: 0; }
  .titre > span + span { margin-left: 0.2em; }
  .livre { align-items: center; padding-bottom: 0; }
  .livre .bloc { grid-template-columns: 1fr; gap: 1.6rem; }
  .couverture { max-width: 9.5rem; }
  .c-auteur { font-size: 0.6rem; }
  .c-titre { font-size: 1.55rem; }
  .c-genre { font-size: 0.6rem; }
  .signature { margin-bottom: 1rem; }
  .livre .chute { margin-top: 1.2rem; }
  .reperes { right: 0.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .brume, .fil, .volume { animation: none; }
  .mot, .lettre, .apparait, .vu .mot, .vu .lettre, .vu .apparait { transition: opacity 0.3s; filter: none; transform: none; }
}
