/* === Page ======================================================== */

.story-page {
  padding-bottom: 90px;
  /* Le décor vient du calque fixe de la page (base.css, body:before) */
  background: transparent;
  position: relative;
  isolation: isolate;
}
.story-page:after {
  content: "";
  position: fixed;
  z-index: 2;
  inset: 0;
  pointer-events: none;
  /* Une texture légère, sans mode de fusion (plein écran, il saccaderait le défilement) */
  opacity: 0.05;
  background: url("/theme/images/site-background-rouille.webp") center/800px;
}
@media (max-width: 700px) {
  .story-page {
    padding-bottom: 55px;
  }
}

/* === Sommaire des chapitres ====================================== */

.chapter-nav {
  position: sticky;
  z-index: 25;
  top: calc(var(--head) + var(--banner, 0px));
  background: #100e0bf5;
  border-block: 1px solid #634c31;
}
.chapter-nav .container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
.chapter-nav a {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  border-right: 1px solid #493a29;
  color: #a99c89;
  font: 900 0.8rem Roboto;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.chapter-nav a:first-child {
  border-left: 1px solid #493a29;
}
.chapter-nav a b {
  color: #d79840;
}
.chapter-nav a:after {
  content: "";
  position: absolute;
  left: 24%;
  right: 24%;
  bottom: -1px;
  height: 3px;
  background: #c63b31;
  transform: scaleX(0);
  transition: 0.3s;
}
.chapter-nav a:hover,
.chapter-nav a.active {
  color: #f0e6d6;
}
.chapter-nav a.active:after {
  transform: scaleX(1);
}
.chapter-nav a.active b {
  animation: index-pulse 1.8s ease-in-out infinite;
}

@media (max-width: 700px) {
  .chapter-nav a {
    min-height: 57px;
    font-size: 0.8rem;
    gap: 5px;
  }
  .chapter-nav a b {
    display: none;
  }
}

/* === Chapitres =================================================== */

.story-journal {
  padding-top: 42px;
}
/* Un clic sur le sommaire pose le chapitre sous l'en-tête et le sommaire collants, pas dessous */
.story-chapter {
  scroll-margin-top: calc(var(--head) + var(--banner, 0px) + 84px);
}
.story-chapter.reverse {
  grid-template-columns: minmax(520px, 1.15fr) minmax(360px, 0.85fr);
}
.reverse .chapter-copy {
  order: 2;
}
.reverse figure {
  order: 1;
}
.chapter-copy header b {
  display: block;
  color: #c53a31;
  font: 900 30px "Roboto Condensed";
}
.chapter-copy h2 {
  position: relative;
  display: inline-block;
  margin: 0 0 32px;
  color: #f0e5d3;
  font: 900 var(--fs-display)/1 "Roboto Condensed";
  text-transform: uppercase;
}
.chapter-copy h2:after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -14px;
  width: 54px;
  height: 5px;
  background: var(--red);
  transform: rotate(-3deg);
}
/* Une page qu'on lit : un corps de texte confortable, l'ouverture de chaque chapitre plus marquée */
.chapter-copy p {
  margin: 0 0 22px;
  color: #c4b8a6;
  font-size: 17px;
  line-height: 1.8;
}
.chapter-copy .lead {
  margin-bottom: 26px;
  color: #efe4d2;
  font-size: 20px;
  line-height: 1.6;
}
.chapter-copy blockquote {
  margin: 27px 0 0;
  color: #dba252;
  font: 400 20px/1.45 "Permanent Marker";
  transform: rotate(-1deg);
}
.story-chapter figure {
  position: relative;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
}
.story-chapter figure:after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #13100e, transparent 30%), linear-gradient(0deg, #0b0a08c4, transparent 38%);
}
.story-chapter.reverse figure:after {
  background: linear-gradient(270deg, #13100e, transparent 30%), linear-gradient(0deg, #0b0a08c4, transparent 38%);
}
/* L'exergue du chapitre, une phrase du texte posée sur l'image */
.story-chapter figcaption {
  position: absolute;
  z-index: 2;
  right: 30px;
  bottom: 28px;
  max-width: min(78%, 440px);
  color: #e3aa58;
  font: 400 23px/1.35 "Permanent Marker";
  text-align: right;
  text-shadow: 0 2px 10px #000;
  transform: rotate(-1.5deg);
}
.reverse figcaption {
  left: 28px;
  right: auto;
  text-align: left;
}
.story-chapter {
  display: grid;
  grid-template-columns: minmax(360px, 0.85fr) minmax(520px, 1.15fr);
  min-height: 620px;
  margin-bottom: 30px;
  border: 1px solid #604a31;
  background: linear-gradient(135deg, #181510f2, #0e0d0bed);
  box-shadow: 0 25px 75px #0007;
  overflow: hidden;
  position: relative;
  transition:
    opacity 0.75s ease,
    transform 0.75s ease;
}
.story-chapter figure img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.72);
  transform: scale(1.06) translate3d(0, var(--scroll-shift, 0px), 0);
}
.story-chapter.scene-live figure img {
  animation: image-awake 1.15s cubic-bezier(0.2, 0.75, 0.2, 1) both;
}
.chapter-copy {
  position: relative;
  z-index: 2;
  padding: 52px clamp(34px, 4vw, 68px);
  align-self: center;
}

@media (max-width: 1000px) {
  .story-chapter,
  .story-chapter.reverse {
    grid-template-columns: 1fr;
  }
  .reverse .chapter-copy {
    order: 1;
  }
  .reverse figure {
    order: 2;
  }
  .story-chapter figure {
    min-height: 470px;
  }
  .story-chapter figure:after,
  .story-chapter.reverse figure:after {
    background: linear-gradient(0deg, #0e0d0c, transparent 45%);
  }
}

@media (max-width: 700px) {
  .story-journal {
    padding-top: 22px;
  }
  .story-chapter {
    min-height: 0;
  }
  .chapter-copy {
    padding: 38px 23px;
  }
  .chapter-copy h2 {
    font-size: 32px;
  }
  .chapter-copy p {
    font-size: 16px;
  }
  .chapter-copy .lead {
    font-size: 18px;
  }
  .story-chapter figcaption {
    right: 20px;
    bottom: 20px;
    font-size: 19px;
  }
  .story-chapter figure {
    min-height: 320px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .story-chapter {
    transform: none !important;
  }
  .story-chapter figure img {
    transition: none;
    animation: none !important;
    transform: none !important;
  }
}

/* === La suite =================================================== */

.story-next {
  margin: 40px 0 0;
  text-align: center;
}
.story-next .text-link {
  font-size: 15px;
}
@media (max-width: 700px) {
  .story-next .text-link {
    font-size: 0.8rem;
  }
}

/* === Apparitions et animations =================================== */

.story-reveal {
  opacity: 0;
  transform: translateY(34px);
  transition: 0.75s ease;
}
.story-reveal.is-visible {
  opacity: 1;
  transform: none;
}
.scene .chapter-copy p,
.scene blockquote {
  opacity: 0;
  transform: translateX(-14px);
  transition:
    opacity 0.55s ease calc(120ms + var(--stagger, 0) * 80ms),
    transform 0.55s ease calc(120ms + var(--stagger, 0) * 80ms);
}
.scene.reverse .chapter-copy p {
  transform: translateX(14px);
}
.scene.scene-live .chapter-copy p,
.scene.scene-live blockquote {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .story-reveal {
    opacity: 1;
    transform: none;
  }
  .scene p,
  .scene li,
  .scene .chapter-copy p,
  .scene blockquote {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* === Keyframes =============================================== */

@keyframes image-awake {
  from {
    filter: saturate(0.3) brightness(0.55);
    clip-path: inset(8% 8%);
  }
  to {
    filter: saturate(0.72);
    clip-path: inset(0);
  }
}

@keyframes index-pulse {
  50% {
    text-shadow: 0 0 12px #d99a42;
  }
}
