/* =============================================================================
   Poiteau Story — bloc Gutenberg (front + éditeur)
   Direction artistique : botanique moderne et distingué (planche XIXe, papier crème).
   Toutes les classes sont préfixées .poiteau-story__ — aucun sélecteur global.
   Équivalent de prototype/style.css (sans les styles de la page de démo).
   ========================================================================== */

/* =============================================================================
   1. Jetons (tokens)
   ========================================================================== */
.poiteau-story {
  --ps-cream:        #f4efe1;
  --ps-paper:        #faf6ec;
  --ps-ink:          #322d24;
  --ps-ink-soft:     #6c6455;
  --ps-line:         rgba(51, 45, 36, .16);
  --ps-wash:         rgba(51, 45, 36, .05);

  --ps-teal:         #2f6f68;
  --ps-teal-strong:  #234f4a;
  --ps-amber:        #bd8630;
  --ps-amber-strong: #9a6a1e;
  --ps-green:        #5b7346;
  --ps-green-strong: #435838;
  --ps-stem:         #7f8a5b;

  --ps-accent:       var(--ps-teal-strong);
  --ps-focus:        #1f5551;

  --ps-rail-w:       clamp(3.5rem, 9vw, 5.5rem);
  --ps-font:         "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --ps-maxw:         62rem;
  --ps-progress:     4;

  position: relative;
  margin-left: auto;
  margin-right: auto;
  max-width: var(--ps-maxw);
  padding: clamp(1.5rem, 4vw, 3rem) 0 clamp(2rem, 5vw, 4rem);
  background: var(--ps-cream);
  color: var(--ps-ink);
  font-family: var(--ps-font);
  border-radius: 4px;
}
.poiteau-story.alignfull { max-width: none; border-radius: 0; }

/* Ton sémantique par étape : porté par un attribut de donnée (pas par une clé
   d'étape fixe) pour rester valable quel que soit le nombre d'étapes. */
.poiteau-story__step[data-tone="teal"]  { --ps-tone: var(--ps-teal); }
.poiteau-story__step[data-tone="amber"] { --ps-tone: var(--ps-amber); }
.poiteau-story__step[data-tone="green"] { --ps-tone: var(--ps-green); }

/* =============================================================================
   2. En-tête éditorial
   ========================================================================== */
.poiteau-story__intro {
  max-width: 42rem;
  margin: 0 auto clamp(1rem, 3vw, 2rem);
  padding: 0 clamp(1rem, 4vw, 2rem);
  text-align: center;
}
.poiteau-story__kicker {
  margin: 0 0 .75rem;
  font-size: .8rem;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--ps-green-strong);
}
.poiteau-story__heading {
  margin: 0 0 .6rem;
  font-family: var(--ps-font);
  font-weight: 500;
  font-size: clamp(1.5rem, 1.1rem + 1.8vw, 2.3rem);
  line-height: 1.2;
  color: var(--ps-ink);
}
.poiteau-story__lede {
  margin: 0 auto;
  max-width: 34rem;
  font-style: italic;
  font-size: clamp(.95rem, .9rem + .3vw, 1.1rem);
  line-height: 1.55;
  color: var(--ps-ink-soft);
}
.poiteau-story__note {
  margin: 1rem 0 0;
  font-size: .8rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  /* Toujours foncé, pas lié à --ps-accent (même raison que .poiteau-story__nav-btn). */
  color: var(--ps-ink-soft);
  display: none;
}
.poiteau-story.is-enhanced .poiteau-story__note { display: block; }

/* =============================================================================
   3. Diagramme : couche décorative + rail
   ========================================================================== */
.poiteau-story__diagram {
  position: relative;
  padding: 0 clamp(1rem, 4vw, 2rem);
}
.poiteau-story__flora {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  color: var(--ps-green);
  opacity: .16;
  pointer-events: none;
}
.poiteau-story__flora-leaves use { fill: currentColor; }
.poiteau-story__flora-flower path { fill: none; stroke: var(--ps-green); stroke-width: 1.4; }
.poiteau-story__flora-heart { fill: var(--ps-amber); stroke: none; opacity: .9; }

.poiteau-story__track {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr var(--ps-rail-w) 1fr;
  grid-auto-rows: minmax(9.5rem, auto);
  column-gap: clamp(1rem, 4vw, 3rem);
  row-gap: 0;
  align-items: start;
}
/* Colonne fixe par côté ; la ligne (grid-row) est fournie en style inline par
   le gabarit (PHP/JS), calculée à partir de la position dans la séquence —
   fonctionne pour N étapes, aucune limite codée en dur. */
.poiteau-story__step-wrap[data-side="left"]  { grid-column: 1; }
.poiteau-story__step-wrap[data-side="right"] { grid-column: 3; }
.poiteau-story__rail { grid-column: 2; }

.poiteau-story__step-wrap {
  align-self: center;
  max-width: 30rem;
}
.poiteau-story__step-wrap[data-side="left"]  { justify-self: end; }
.poiteau-story__step-wrap[data-side="right"] { justify-self: start; }

.poiteau-story__rail {
  position: relative;
  align-self: stretch;
  justify-self: center;
  width: var(--ps-rail-w);
  display: flex;
  justify-content: center;
  min-height: 5rem;
}
.poiteau-story__seg {
  width: 1.4rem;
  height: 100%;
  display: block;
  overflow: visible;
}
.poiteau-story__seg-track {
  fill: none;
  stroke: var(--ps-line);
  stroke-width: 2.5;
  vector-effect: non-scaling-stroke;
}
.poiteau-story__seg-grow {
  fill: none;
  stroke: var(--ps-stem);
  stroke-width: 3;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset .85s ease;
}
.poiteau-story__rail.is-grown .poiteau-story__seg-grow { stroke-dashoffset: 0; }
.poiteau-story__rail[data-ps-rail="2"] .poiteau-story__seg-grow { transition-delay: .10s; }
.poiteau-story__rail[data-ps-rail="3"] .poiteau-story__seg-grow { transition-delay: .20s; }
.poiteau-story__rail[data-ps-rail="4"] .poiteau-story__seg-grow { transition-delay: .30s; }

/* La portion de tige de l'étape active prend son ton (ambre pour la révélation). */
.poiteau-story__rail.is-active .poiteau-story__seg-grow { stroke: var(--ps-tone, var(--ps-stem)); }

.poiteau-story:not(.is-enhanced) .poiteau-story__seg-grow { stroke-dashoffset: 0; }

.poiteau-story__node {
  position: absolute;
  left: 50%;
  top: -.5rem;
  width: .95rem;
  height: .95rem;
  translate: -50% 0;
  border-radius: 50%;
  background: var(--ps-paper);
  border: 2.5px solid var(--ps-stem);
  box-shadow: 0 0 0 5px var(--ps-cream);
  transition: transform .35s ease, border-color .35s ease, background-color .35s ease;
  z-index: 2;
}
/* Premier nœud de la tige : petite pousse, plus discrète. */
.poiteau-story__rail[data-ps-rail="1"] .poiteau-story__node {
  top: -.35rem;
  width: .7rem;
  height: .7rem;
}
.poiteau-story__rail.is-reached .poiteau-story__node { border-color: var(--ps-stem); }
.poiteau-story__rail.is-active .poiteau-story__node {
  transform: scale(1.45);
  border-color: var(--ps-tone, var(--ps-stem));
  background: var(--ps-tone, var(--ps-stem));
}

/* =============================================================================
   5. Étape (bouton) + contenu
   ========================================================================== */
.poiteau-story__step {
  display: grid;
  gap: .55rem;
  margin: 0;
  padding: .9rem 1rem;
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: background-color .25s ease, box-shadow .25s ease;
}
.poiteau-story:not(.is-enhanced) .poiteau-story__step { cursor: default; }

.poiteau-story__step-wrap[data-side="left"]  .poiteau-story__step { justify-items: end; text-align: right; }
.poiteau-story__step-wrap[data-side="right"] .poiteau-story__step { justify-items: start; text-align: left; }

.poiteau-story__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--ps-tone, var(--ps-stem));
  color: var(--ps-paper);
  font-family: var(--ps-font);
  font-size: .85rem;
  letter-spacing: .02em;
  transition: transform .25s ease;
}
.poiteau-story__step-text { display: grid; gap: .35rem; }
.poiteau-story__step-wrap[data-side="left"] .poiteau-story__step-text { justify-items: end; }

.poiteau-story__step-title {
  font-size: clamp(1.1rem, 1rem + .55vw, 1.4rem);
  font-weight: 500;
  line-height: 1.22;
  color: var(--ps-ink);
}
.poiteau-story__step-subtitle {
  font-weight: 600;
  font-size: clamp(.88rem, .84rem + .2vw, .98rem);
  line-height: 1.35;
  color: var(--ps-tone, var(--ps-teal-strong));
}
.poiteau-story__step-intro {
  max-width: 32ch;
  font-style: italic;
  font-size: clamp(.9rem, .86rem + .25vw, 1rem);
  line-height: 1.5;
  color: var(--ps-ink-soft);
}
.poiteau-story__step-meta {
  font-size: .72rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ps-tone, var(--ps-teal-strong));
}
.poiteau-story__hint {
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 600;
  /* Aussi foncé que le titre de l'étape (retour utilisateur : trop discret en
     `--ps-ink-soft`, des testeurs ne le remarquaient pas). */
  color: var(--ps-ink);
  opacity: 0;
  transform: translateY(2px);
  transition: opacity .22s ease, transform .22s ease;
}
.poiteau-story__hint::before { content: "+ "; }
.poiteau-story:not(.is-enhanced) .poiteau-story__hint { display: none; }

.poiteau-story__step-detail {
  margin: .5rem 0 0;
  font-size: .9rem;
  line-height: 1.55;
  color: var(--ps-ink-soft);
}
.poiteau-story__step-detail p { margin: 0 0 .5em; }
.poiteau-story__step-detail p:last-child { margin-bottom: 0; }
.poiteau-story__step-detail a {
  color: var(--ps-ink-soft);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.poiteau-story.is-enhanced .poiteau-story__step-detail { display: none; }

.poiteau-story__step-detail .poiteau-story__image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 0 0 .6em;
}
.poiteau-story__image-caption {
  font-size: .78em;
  font-style: italic;
  color: var(--ps-ink-soft);
  margin: -.3em 0 .7em;
}
.poiteau-story__credit,
.poiteau-story__rights-note {
  font-size: .82em;
  color: var(--ps-ink-soft);
  border-top: 1px solid var(--ps-line);
  padding-top: .6em;
  margin-top: .8em;
}

@media (hover: hover) {
  .poiteau-story.is-enhanced .poiteau-story__step:hover { background: var(--ps-wash); }
  .poiteau-story.is-enhanced .poiteau-story__step:hover .poiteau-story__num { transform: scale(1.08); }
  .poiteau-story.is-enhanced .poiteau-story__step:hover .poiteau-story__hint { opacity: 1; transform: none; }
}
.poiteau-story.is-enhanced .poiteau-story__step:focus-visible {
  outline: 2px solid var(--ps-focus);
  outline-offset: 3px;
}
.poiteau-story.is-enhanced .poiteau-story__step:focus-visible .poiteau-story__hint { opacity: 1; transform: none; }

.poiteau-story__step[aria-expanded="true"] {
  background: var(--ps-wash);
  box-shadow: inset 0 0 0 1px var(--ps-line);
}
.poiteau-story__step[aria-expanded="true"] .poiteau-story__num {
  transform: scale(1.08);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ps-tone, var(--ps-stem)) 22%, transparent);
}

/* =============================================================================
   6. Panneau de détail (StoryDetailPanel)
   ========================================================================== */
.poiteau-story__panel {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  justify-content: flex-end;
}
.poiteau-story__panel[hidden] { display: none; }

.poiteau-story__overlay {
  position: absolute;
  inset: 0;
  background: rgba(28, 24, 16, .4);
  opacity: 0;
  transition: opacity .3s ease;
}
.poiteau-story__panel.is-open .poiteau-story__overlay { opacity: 1; }

.poiteau-story__sheet {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  width: min(28rem, 92vw);
  height: 100%;
  overflow-y: auto;
  padding: clamp(1.5rem, 3vw, 2.6rem);
  background: var(--ps-paper);
  color: var(--ps-ink);
  border-left: 1px solid var(--ps-line);
  box-shadow: -2px 0 34px rgba(38, 32, 20, .16);
  transform: translateX(100%);
  transition: transform .38s cubic-bezier(.22, .61, .36, 1);
}
.poiteau-story__panel.is-open .poiteau-story__sheet { transform: none; }
.poiteau-story__sheet:focus { outline: none; }
.poiteau-story__sheet:focus-visible { outline: 2px solid var(--ps-focus); outline-offset: -4px; }

.poiteau-story__sheet-handle { display: none; }

.poiteau-story__close {
  position: absolute;
  z-index: 2; /* rester lisible au-dessus d'un visuel sombre (.poiteau-story__panel-media) */
  top: .75rem;
  right: .75rem;
  width: 2.5rem;
  height: 2.5rem;
  /* Bordure sombre + fond clair permanent : un test utilisateur a montré que
     la croix passait inaperçue (quelqu'un a utilisé le retour du navigateur
     au lieu de fermer le panneau) — il faut un contraste fort dans tous les
     cas, y compris posée sur une photo sombre. */
  border: 1.5px solid var(--ps-ink);
  border-radius: 50%;
  background: var(--ps-paper);
  box-shadow: 0 1px 4px rgba(40, 34, 22, .2);
  cursor: pointer;
  transition: background-color .2s ease, box-shadow .2s ease;
}
.poiteau-story__close:hover { background: var(--ps-cream); box-shadow: 0 2px 6px rgba(40, 34, 22, .26); }
.poiteau-story__close:focus-visible { outline: 2px solid var(--ps-focus); outline-offset: 2px; }
.poiteau-story__close-icon { position: absolute; inset: 0; }
.poiteau-story__close-icon::before,
.poiteau-story__close-icon::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1.05rem;
  height: 1.5px;
  background: var(--ps-ink);
  transform-origin: center;
}
.poiteau-story__close-icon::before { transform: translate(-50%, -50%) rotate(45deg); }
.poiteau-story__close-icon::after  { transform: translate(-50%, -50%) rotate(-45deg); }

.poiteau-story__panel-media {
  margin: -0.5rem -0.1rem .5rem;
}
.poiteau-story__panel-media[hidden] { display: none; }
.poiteau-story__panel-media img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
}
.poiteau-story__panel-media .poiteau-story__image-caption { margin: .4em 0 0; }

.poiteau-story__panel-num {
  margin: 0;
  font-size: .8rem;
  letter-spacing: .1em;
  color: var(--ps-ink-soft);
}
.poiteau-story__panel-title {
  margin: 0;
  font-family: var(--ps-font);
  font-weight: 500;
  font-size: clamp(1.4rem, 1.2rem + 1vw, 1.9rem);
  line-height: 1.2;
  color: var(--ps-ink);
}
.poiteau-story__panel-subtitle {
  margin: 0;
  font-weight: 600;
  font-size: 1rem;
  color: var(--ps-panel-tone, var(--ps-teal-strong));
}
.poiteau-story__panel-subtitle[hidden] { display: none; }
.poiteau-story__panel-meta {
  margin: 0 0 .5rem;
  font-size: .75rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ps-panel-tone, var(--ps-teal-strong));
}
.poiteau-story__panel-meta:empty { display: none; }
.poiteau-story__panel-credit {
  font-size: .82rem;
  color: var(--ps-ink-soft);
  border-top: 1px solid var(--ps-line);
  padding-top: .7em;
  margin: .8em 0 0;
}
.poiteau-story__panel-credit[hidden] { display: none; }
.poiteau-story__panel-body {
  font-size: .98rem;
  line-height: 1.62;
  color: var(--ps-ink);
}
.poiteau-story__panel-body p { margin: 0 0 .9em; }
.poiteau-story__panel-body p:last-child { margin-bottom: 0; }
.poiteau-story__panel-body em,
.poiteau-story__step-detail em { font-style: italic; }
.poiteau-story__lineage {
  margin-top: 1em;
  padding-top: .9em;
  border-top: 1px solid var(--ps-line);
  font-style: italic;
  font-size: .85em;
  color: var(--ps-ink-soft);
}

.poiteau-story__action {
  margin-top: 1rem;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  align-self: flex-start;
  padding: .7rem 1.15rem;
  border-radius: 999px;
  background: var(--ps-panel-tone, var(--ps-green));
  color: var(--ps-paper);
  font-size: .9rem;
  letter-spacing: .02em;
  text-decoration: none;
  transition: filter .2s ease;
}
.poiteau-story__action::after { content: "\2192"; }
.poiteau-story__action:hover { filter: brightness(1.08); color: var(--ps-paper); }
.poiteau-story__action:focus-visible { outline: 2px solid var(--ps-focus); outline-offset: 3px; }
.poiteau-story__action[hidden] { display: none; }

.poiteau-story__nav {
  margin-top: auto;
  padding-top: 1rem;
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  border-top: 1px solid var(--ps-line);
}
.poiteau-story__nav-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem .5rem;
  max-width: 48%;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: .82rem;
  /* Toujours foncé, jamais lié à --ps-accent : la navigation précédent/suivant
     doit rester lisible quelle que soit la couleur d'accent configurée sur le
     bloc (un accent clair y rendait le texte quasi invisible). */
  color: var(--ps-ink);
  cursor: pointer;
  border-radius: 6px;
}
.poiteau-story__nav-btn:hover { background: var(--ps-wash); }
.poiteau-story__nav-btn:focus-visible { outline: 2px solid var(--ps-focus); outline-offset: 2px; }
.poiteau-story__nav-btn[disabled] { opacity: .35; cursor: default; }
.poiteau-story__nav-btn[disabled]:hover { background: transparent; }
.poiteau-story__nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.poiteau-story__nav-btn[data-ps-nav="next"] { text-align: right; }

/* =============================================================================
   7. Utilitaires
   ========================================================================== */
.poiteau-story__sr {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.poiteau-story__empty {
  max-width: 34rem;
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2rem);
  text-align: center;
  font-style: italic;
  color: var(--ps-ink-soft);
}

.poiteau-story__closing {
  max-width: 36rem;
  margin: clamp(2rem, 6vw, 4rem) auto 0;
  padding: clamp(1.5rem, 4vw, 2.5rem) clamp(1rem, 4vw, 2rem) 0;
  border-top: 1px solid var(--ps-line);
  text-align: center;
}
.poiteau-story__closing-title {
  margin: 0 0 .75rem;
  font-family: var(--ps-font);
  font-weight: 500;
  font-size: clamp(1.2rem, 1rem + 1vw, 1.6rem);
  color: var(--ps-ink);
}
.poiteau-story__closing-text {
  font-size: .98rem;
  line-height: 1.65;
  color: var(--ps-ink-soft);
}
.poiteau-story__closing-text p { margin: 0 0 .7em; }
.poiteau-story__closing-text p:last-child { margin-bottom: 0; }
.poiteau-story__closing-text strong { color: var(--ps-ink); }

/* =============================================================================
   8. Responsive
   ========================================================================== */
@media (max-width: 820px) {
  .poiteau-story__diagram { padding: 0 1rem; }

  .poiteau-story__track {
    grid-template-columns: minmax(0, 22rem);
    justify-content: center;
    grid-auto-rows: auto;
  }
  .poiteau-story__track > .poiteau-story__step-wrap,
  .poiteau-story__track > .poiteau-story__rail {
    grid-row: auto !important;
    grid-column: 1 !important;
  }

  .poiteau-story__step-wrap,
  .poiteau-story__step-wrap[data-side="left"],
  .poiteau-story__step-wrap[data-side="right"] {
    justify-self: stretch;
    max-width: none;
  }
  .poiteau-story__step,
  .poiteau-story__step-wrap[data-side="left"] .poiteau-story__step,
  .poiteau-story__step-wrap[data-side="right"] .poiteau-story__step {
    justify-items: center;
    text-align: center;
    padding: .8rem .5rem;
  }
  .poiteau-story__step-wrap[data-side="left"] .poiteau-story__step-text,
  .poiteau-story__step-text { justify-items: center; }
  .poiteau-story__step-intro { max-width: 30ch; }
  .poiteau-story__hint { opacity: 1; transform: none; }

  .poiteau-story__rail { width: 100%; min-height: 3.25rem; }
  .poiteau-story__rail[data-ps-rail] { align-self: stretch; }

  .poiteau-story__panel { justify-content: center; align-items: flex-end; }
  .poiteau-story__sheet {
    width: 100%;
    height: auto;
    max-height: 86vh;
    padding-top: 1.75rem;
    border-left: 0;
    border-top: 1px solid var(--ps-line);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -2px 34px rgba(38, 32, 20, .18);
    transform: translateY(100%);
  }
  .poiteau-story__panel.is-open .poiteau-story__sheet { transform: none; }
  .poiteau-story__sheet-handle {
    display: block;
    position: absolute;
    top: .6rem;
    left: 50%;
    translate: -50% 0;
    width: 2.5rem;
    height: .25rem;
    border-radius: 999px;
    background: var(--ps-line);
  }
}

@media (min-width: 1200px) {
  .poiteau-story { --ps-rail-w: 6.5rem; }
  .poiteau-story__track { grid-auto-rows: minmax(11rem, auto); }
}

/* =============================================================================
   9. Mouvement réduit
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .poiteau-story *,
  .poiteau-story *::before,
  .poiteau-story *::after {
    transition-duration: .001ms !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
  }
  .poiteau-story__seg-grow { stroke-dashoffset: 0 !important; }
}
