/* ==========================================================================
   Planches — pages intérieures parcourues à l’horizontale.
   Molette, flèches, rail de repères ou glissé : le contenu défile de gauche
   à droite, panneau par panneau. Aucun défilement vertical de page.
   ========================================================================== */

.page-planche {
  --rail-h: 72px;
  height: 100dvh;
  overflow: hidden;
}

.track {
  position: fixed;
  inset: 0;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  padding: var(--chrome-h) 0 var(--rail-h);
  /* Pas d’aimantation CSS sur grand écran : planche.js aimante en douceur. */
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.track::-webkit-scrollbar { display: none; }
.track:focus-visible { outline: none; }

.panel {
  position: relative;
  flex: none;
  height: 100%;
  display: grid;
  align-content: center;
  gap: clamp(20px, 3.4vh, 40px);
  padding: clamp(16px, 4vh, 56px) clamp(28px, 5vw, 96px);
  scroll-snap-align: start;
  overflow-y: auto;
  scrollbar-width: thin;
  border-left: var(--rule);
}
.panel:first-child { border-left: 0; padding-left: var(--gutter); }
.panel:last-child { padding-right: max(var(--gutter), 8vw); }
.panel:focus-visible { outline: none; }

.panel > * { animation: hb-rise 1000ms var(--ease) both; }
.panel > :nth-child(2) { animation-delay: 120ms; }
.panel > :nth-child(3) { animation-delay: 200ms; }
.panel > :nth-child(4) { animation-delay: 260ms; }

.panel__head { display: grid; gap: 14px; max-width: 34rem; }

/* ---------- ouverture ---------- */

.panel--ouverture {
  width: 100vw;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  align-items: center;
  column-gap: clamp(32px, 6vw, 120px);
}
.ouverture__texte { display: grid; gap: 22px; max-width: 42rem; }
.ouverture__texte h1 { max-width: 14ch; }

.faits {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, auto));
  justify-content: start;
  gap: 14px clamp(28px, 4vw, 64px);
  margin-top: 12px;
  padding-top: 26px;
  border-top: var(--rule);
}
.faits dt { color: var(--faint); }
.faits dd { margin-top: 4px; color: var(--ink); font-size: 0.9375rem; }

.fig {
  justify-self: center;
  display: grid;
  gap: 18px;
  justify-items: center;
  color: var(--accent);
}
.fig svg {
  height: min(52dvh, 520px);
  width: auto;
  fill: currentColor;
}
.fig figcaption { color: var(--faint); }

/* Capture d’une réalisation, dans un cadre de fenêtre discret (filet, pas d’ombre). */
.fig--capture { width: 100%; max-width: 640px; }
.fig__fenetre {
  width: 100%;
  overflow: hidden;
  background: var(--surface);
  border: var(--rule);
  border-radius: var(--radius);
}
.fig__barre {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 10px;
  border-bottom: var(--rule);
}
.fig__barre span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
}
.fig__fenetre img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(46dvh, 460px);
  object-fit: cover;
  object-position: top center;
}

/* Capture en portrait : cadre plus étroit et plus haut, pour la montrer presque entière. */
.fig--portrait { max-width: 340px; }
.fig--portrait .fig__fenetre img { max-height: min(56dvh, 520px); }

/* Profondeur : la figure et les grands numéros glissent un peu moins vite que la page.
   --profondeur vaut 0 quand le panneau est calé à gauche (posé par planche.js). */
.fig,
.frise__num { translate: calc(var(--profondeur, 0) * var(--amplitude, 0px) * -1) 0; }
.fig { --amplitude: 56px; }
.frise__num { --amplitude: 20px; }
/* Couches dédiées : le déplacement se fait sans redessiner le hibou à chaque image. */
.fig,
.frise__num { will-change: transform, translate; }

.scroll-cue {
  position: absolute;
  right: var(--gutter);
  bottom: clamp(16px, 3vh, 32px);
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--faint);
}
.scroll-cue::after {
  content: "";
  width: 56px;
  height: 1px;
  background: linear-gradient(90deg, var(--accent), transparent);
  animation: cue 2400ms var(--ease) infinite;
  transform-origin: left center;
}
@keyframes cue { 0% { transform: scaleX(0); } 60%, 100% { transform: scaleX(1); opacity: 0; } }

/* ---------- liste « ce qui est inclus » ---------- */

.panel--liste { width: min(100vw, 1080px); }

.lignes { border-top: var(--rule); }
.lignes li {
  display: grid;
  grid-template-columns: 56px minmax(0, 15rem) minmax(0, 1fr);
  gap: 8px 32px;
  align-items: baseline;
  padding: clamp(12px, 2.2vh, 22px) 0;
  border-bottom: var(--rule);
  transition: background-color 300ms ease, padding 400ms var(--ease);
}
.lignes li:hover { background: var(--hover); padding-left: 12px; }
.lignes .num { color: var(--accent); }
.lignes h3 { font-size: 1.25rem; }
.lignes p { color: var(--muted); font-size: 0.9375rem; line-height: 1.7; }

/* ---------- déroulé en frise ---------- */

.panel--frise { width: auto; }

.frise {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(220px, 22vw, 300px);
  gap: 0 clamp(24px, 3vw, 48px);
  position: relative;
  padding-top: 44px;
}
.frise::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--accent), var(--line-strong) 40%, var(--line));
}
.frise li { position: relative; display: grid; gap: 10px; align-content: start; }
.frise li::before {
  content: "";
  position: absolute;
  top: -40px;
  left: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--accent);
}
.frise__num { font-family: var(--fh); font-size: 2.75rem; line-height: 1; color: var(--accent); }
.frise h3 { font-size: 1.25rem; }
.frise p { color: var(--muted); font-size: 0.9375rem; line-height: 1.75; }
.frise .meta { color: var(--faint); }

/* ---------- suite ---------- */

.panel--suite {
  width: min(100vw, 900px);
  align-content: center;
}

.appel {
  display: grid;
  gap: 18px;
  justify-items: start;
  padding: clamp(28px, 5vh, 56px);
  background: color-mix(in oklab, var(--accent) 6%, var(--panel));
  border-radius: var(--radius);
}
.appel p { color: var(--muted); max-width: 30rem; }
.appel__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }

.suivant {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 8px 24px;
  padding: 26px 0 8px;
  border-bottom: var(--rule);
}
.suivant .meta { grid-column: 1 / -1; color: var(--faint); }
.suivant__titre { font-family: var(--fh); font-size: var(--fs-h2); line-height: 1.15; }
.suivant .arrow { font-size: 1.5rem; color: var(--accent); }

/* ---------- texte courant en colonnes (mentions, artisans) ---------- */

.panel--colonnes {
  width: auto;
  align-content: stretch;
}
.colonnes {
  height: 100%;
  columns: 21rem auto;
  column-gap: clamp(40px, 5vw, 80px);
  column-rule: var(--rule);
  column-fill: auto;
}
.colonnes section { break-inside: avoid; padding-bottom: 32px; }
.colonnes h2 { font-size: 1.5rem; margin-bottom: 10px; }
.colonnes p { color: var(--muted); font-size: 0.9375rem; line-height: 1.8; }
.colonnes p + p { margin-top: 10px; }
.colonnes .kicker { display: block; margin-bottom: 6px; }
.a-completer { color: var(--accent); font-style: normal; }

/* ---------- texte court (artisans) ---------- */

.colonnes-simple { display: grid; gap: 18px; max-width: 36rem; }
.colonnes-simple em { font-style: normal; color: var(--accent); }

/* ---------- principes (artisans) ---------- */

.principes {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(2, auto);
  grid-auto-columns: clamp(240px, 24vw, 320px);
  gap: clamp(24px, 4vh, 48px) clamp(28px, 3vw, 56px);
}
.principes li { display: grid; gap: 8px; padding-top: 18px; border-top: var(--rule); }
.principes .num { color: var(--accent); }
.principes h3 { font-size: 1.25rem; }
.principes p { color: var(--muted); font-size: 0.9375rem; line-height: 1.75; }

/* ---------- rail de repères ---------- */

.rail {
  position: fixed;
  inset: auto 0 0;
  z-index: 50;
  height: var(--rail-h);
  display: grid;
  /* Précédent et suivant à leur largeur naturelle, les repères occupent le centre. */
  grid-template-columns: minmax(max-content, 1fr) minmax(min-content, 1180px) minmax(max-content, 1fr);
  align-items: center;
  gap: 24px;
  padding: 0 var(--gutter);
  /* Fond plein : un flou d’arrière-plan serait recalculé à chaque image du défilement. */
  background: var(--paper);
}
/* ---------- traces de pattes (traces.js) ----------
   La progression est marquée par des empreintes qui s’impriment une à une,
   puis pâlissent ; les deux dernières restent nettes. */

.traces {
  position: absolute;
  top: 0;
  left: var(--gutter);
  right: calc(var(--gutter) + 32px);
  height: 22px;
  pointer-events: none;
}

.patte {
  position: absolute;
  top: 50%;
  left: 0;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  color: var(--accent);
  translate: var(--x) var(--y);
  rotate: var(--r);
  /* Effacement de la trace : pleine tant qu’elle est en tête, puis pâlit lentement.
     Au retrait, on attend que le dessin se soit effacé avant de revenir à 1. */
  opacity: 1;
  transition: opacity 0s linear 260ms;
}
.patte.is-posee {
  opacity: 0.22;
  transition: opacity 2600ms ease 700ms;
}
.patte.is-posee.is-tete {
  opacity: 0.95;
  transition: opacity 300ms ease;
}

/* L’encre prend : le dessin se précise dès que l’empreinte est posée, quoi qu’il arrive
   ensuite. Séparé de l’effacement ci-dessus pour qu’aucun pas n’apparaisse en retard. */
.patte svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  opacity: 0;
  scale: 0.55;
  filter: blur(1.6px);
  transition: opacity 250ms ease, scale 250ms ease, filter 250ms ease;
}
.patte.is-posee svg {
  opacity: 1;
  scale: 1;
  filter: blur(0);
  transition: opacity 380ms ease, scale 520ms cubic-bezier(0.2, 0.8, 0.2, 1), filter 520ms ease;
}
.traces.is-instant .patte,
.traces.is-instant .patte svg { transition: none; }

/* Repères : un sautillement au passage ; une fois foulés, leur numéro prend l’encre. */
.rail .reperes .num { transition: color 700ms ease; }
.rail .reperes a.is-foule:not([aria-current="true"]) .num { color: var(--accent-2); }

@keyframes repere-saut {
  0%, 100% { translate: 0 0; }
  40% { translate: 0 -3px; }
}
.reperes a.is-saut { animation: repere-saut 560ms cubic-bezier(0.3, 0.7, 0.3, 1); }

/* Boîte aux lettres : au bout de la piste, elle reçoit une enveloppe et lève son drapeau. */
.boite {
  position: absolute;
  top: -5px;
  right: var(--gutter);
  width: 22px;
  height: 22px;
  color: var(--faint);
  transition: color 600ms ease;
}
.boite:hover,
.boite.is-arrivee { color: var(--accent); }
.boite svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.boite__drapeau {
  transform-box: view-box;
  transform-origin: 15.5px 10px;
  transition: rotate 700ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.boite.is-arrivee .boite__drapeau { rotate: -90deg; transition-delay: 550ms; }

.boite__lettre { opacity: 0; }
.boite.is-arrivee .boite__lettre { animation: boite-lettre 1100ms cubic-bezier(0.4, 0, 0.2, 1) both; }
@keyframes boite-lettre {
  0% { opacity: 0; translate: -9px -1px; }
  30% { opacity: 1; translate: -9px -1px; }
  85% { opacity: 1; translate: 1px 0; }
  100% { opacity: 0; translate: 1px 0; }
}

.rail__prev,
.rail__next { display: inline-flex; align-items: center; gap: 10px; color: var(--accent-2); }
.rail__next { justify-self: end; }
.rail__prev:hover,
.rail__next:hover { color: var(--accent); }
.rail__prev:hover .arrow { transform: translateX(-4px); }

/* Les repères eux-mêmes (.reperes) sont définis dans base.css. Dans le rail, ils s’écartent
   plus largement que dans l’en-tête, pour occuper la largeur de la page. */
.rail .reperes {
  width: 100%;
  justify-content: space-evenly;
  gap: 16px;
}

.rail__compteur { color: var(--faint); }

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .panel--ouverture { grid-template-columns: 1fr; }
  .fig { display: none; }
  .lignes li { grid-template-columns: 44px 1fr; }
  .lignes li p { grid-column: 2; }
}

@media (max-width: 760px) {
  .page-planche { --rail-h: 60px; }
  .track { scroll-snap-type: x mandatory; }
  .panel,
  .panel--liste,
  .panel--suite { width: 100vw; padding-inline: var(--gutter); border-left: 0; }
  .panel--frise,
  .panel--colonnes { width: auto; }
  .faits { grid-template-columns: 1fr 1fr; }
  .rail .reperes span:not(.num) { display: none; }
  .rail__prev span:not(.arrow),
  .rail__next span:not(.arrow) { display: none; }
  .scroll-cue { display: none; }
  .colonnes { columns: calc(100vw - 2 * var(--gutter)) auto; column-rule: none; }
}

@media (max-height: 620px) {
  .panel { align-content: start; }
  .fig svg { height: 40dvh; }
}
