/* ============================================
   MAIN/MON-HISTOIRE.CSS — Portrait manifeste
   Charge sur : page slug 'mon-histoire'

   Même ligne éditoriale que Mon approche (registre manifeste, rupture
   avec les pages immersion) : ouverture SPLIT — typo alignée à gauche,
   portrait de Mélanie à droite —, récit en trois fragments + exergue,
   ponctuation encre, trois engagements en grille, réseau en vis-à-vis.
   Rythme des fonds : crème / sable / encre / crème / sable / teal.
   ============================================ */

/* base.css plafonne p/li à 640px : les éléments de mise en page en sont libérés. */
.histoire-ouverture__stat,
.histoire-valeurs__item {
  max-width: none;
}

/* ── 1. OUVERTURE — split typo / portrait ── */

.histoire-ouverture {
  min-height: 100svh;
  display: flex;
  align-items: stretch;
  background: var(--surface-default, #faf7f3);
  overflow: clip;
}

.histoire-ouverture__inner {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: clamp(32px, 5vw, 88px);
  align-items: stretch;
  padding-top: calc(var(--nav-height, 72px) + clamp(24px, 4vh, 48px));
  padding-bottom: clamp(28px, 5vh, 56px);
}

.histoire-ouverture__texte {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-lg);
  min-width: 0;
}

.histoire-ouverture__folio {
  font-family: var(--font-sans);
  font-size: var(--t-small);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--em-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  opacity: 0;
  animation: histoireFadeIn 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.25s forwards;
}

.histoire-ouverture__folio::after {
  content: '';
  flex: 1 1 auto;
  max-width: 160px;
  height: 1px;
  background: color-mix(in oklch, var(--em-primary) 38%, transparent);
  transform: scaleX(0);
  transform-origin: left center;
  animation: histoireLigne 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.7s forwards;
}

.histoire-ouverture__title {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: clamp(2.4rem, 1.1rem + 4.8vw, 4.6rem);
  line-height: 1.06;
  letter-spacing: -0.015em;
  color: var(--em-text);
  margin: 0 0 clamp(16px, 2.4vw, 28px);
  max-width: 14ch;
  text-wrap: balance;
  clip-path: inset(100% 0 0 0);
  animation: histoireReveal 1s cubic-bezier(0.22, 1, 0.36, 1) 0.5s forwards;
}

.histoire-ouverture__title em {
  font-style: italic;
  color: var(--em-primary);
}

.histoire-ouverture__lead {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.15rem, 0.95rem + 0.8vw, 1.5rem);
  line-height: 1.45;
  color: var(--em-text-light);
  margin: 0;
  max-width: 40ch;
  opacity: 0;
  animation: histoireFadeIn 0.9s cubic-bezier(0.22, 1, 0.36, 1) 1.05s forwards;
}

/* Repères — le parcours en un regard. */
.histoire-ouverture__stats {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(14px, 2.4vw, 32px);
  opacity: 0;
  animation: histoireFadeIn 0.9s cubic-bezier(0.22, 1, 0.36, 1) 1.35s forwards;
}

.histoire-ouverture__stat {
  padding-top: 14px;
  border-top: 1px solid color-mix(in oklch, var(--ivoire-900) 22%, transparent);
}

.histoire-ouverture__stat-num {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: clamp(1.9rem, 1.5rem + 1.4vw, 3rem);
  line-height: 0.95;
  color: var(--em-primary);
  margin: 0 0 6px;
  font-feature-settings: 'lnum';
}

.histoire-ouverture__stat-label {
  font-family: var(--font-sans);
  font-size: var(--t-small);
  line-height: 1.5;
  color: var(--em-text-light);
  margin: 0;
  max-width: 24ch;
}

/* Portrait — cadre plein hauteur, entrée en fondu doux. */
.histoire-ouverture__media {
  margin: 0;
  line-height: 0;
  min-height: 0;
  opacity: 0;
  animation: histoireFadeIn 1.1s cubic-bezier(0.22, 1, 0.36, 1) 0.4s forwards;
}

.histoire-ouverture__media picture,
.histoire-ouverture__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Mélanie vit au centre-droit du cadre source (paysage). */
  object-position: 62% 30%;
}

@keyframes histoireReveal {
  to { clip-path: inset(0 0 0 0); }
}

@keyframes histoireFadeIn {
  to { opacity: 1; }
}

@keyframes histoireLigne {
  to { transform: scaleX(1); }
}

/* ── 2. LE RÉCIT — fragments + exergue ── */

.histoire-recit__corps {
  margin-top: var(--space-xl);
  display: grid;
  grid-template-columns: minmax(0, 6fr) minmax(0, 6fr);
  gap: clamp(32px, 5vw, 96px);
  align-items: start;
}

.histoire-recit__fragment {
  font-family: var(--font-sans);
  font-size: var(--t-lead);
  line-height: 1.65;
  color: var(--em-text-light);
  margin: 0 0 var(--space-md);
  max-width: 52ch;
}

.histoire-recit__fragment:last-child {
  margin-bottom: 0;
}

/* Exergue — la phrase-héritage, en grand serif. */
.histoire-recit__exergue {
  margin: 0;
  padding-left: var(--space-md);
  border-left: 2px solid var(--em-accent-light);
}

.histoire-recit__exergue p {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.5rem, 1.15rem + 1.4vw, 2.2rem);
  line-height: 1.35;
  color: var(--em-text);
  margin: 0;
  max-width: 22ch;
  text-wrap: pretty;
}

/* ── 3. TROIS ENGAGEMENTS — grille scannable ── */

.histoire-valeurs__items {
  list-style: none;
  margin: var(--space-xl) 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(24px, 3.5vw, 48px);
}

.histoire-valeurs__item {
  position: relative;
  padding-top: var(--space-md);
}

.histoire-valeurs__item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: color-mix(in oklch, var(--ivoire-900) 14%, transparent);
}

.histoire-valeurs__item::after {
  /* Jalon rose : la série se lit d'un regard. */
  content: '';
  position: absolute;
  top: -3px;
  left: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--em-accent-light);
}

.histoire-valeurs__label {
  display: block;
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: clamp(1.8rem, 1.4rem + 1.2vw, 2.6rem);
  line-height: 1;
  color: color-mix(in oklch, var(--em-accent-light) 55%, transparent);
  margin-bottom: var(--space-xs);
  font-feature-settings: 'lnum';
}

.histoire-valeurs__headline {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(1.2rem, 1.05rem + 0.5vw, 1.45rem);
  line-height: 1.2;
  color: var(--em-text);
  margin: 0 0 8px;
  max-width: none;
}

.histoire-valeurs__text {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--t-body);
  line-height: 1.6;
  color: var(--em-text-light);
  max-width: none;
}

/* ── 4. LE RÉSEAU — image en vis-à-vis ── */

.histoire-reseau__layout {
  display: grid;
  gap: var(--space-lg);
  align-items: center;
}

.histoire-reseau__layout--media {
  grid-template-columns: minmax(0, 6fr) minmax(0, 6fr);
  gap: clamp(32px, 5vw, 96px);
}

.histoire-reseau__media {
  margin: 0;
  line-height: 0;
}

.histoire-reseau__media img {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
}

.histoire-reseau__contenu .section-header {
  margin-bottom: var(--space-md);
}

.histoire-reseau__text {
  font-family: var(--font-sans);
  font-size: var(--t-lead);
  line-height: 1.65;
  color: var(--em-text-light);
  margin: 0 0 var(--space-md);
  max-width: 52ch;
}

/* Lien éditorial — flèche qui glisse au survol. */
.histoire-reseau__lien {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-size: var(--t-ui);
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--em-primary);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in oklch, var(--em-primary) 40%, transparent);
  padding-bottom: 4px;
  transition:
    color 0.3s var(--ease-editorial),
    border-color 0.3s var(--ease-editorial);
}

.histoire-reseau__lien span {
  transition: transform 0.3s var(--ease-editorial);
}

.histoire-reseau__lien:hover,
.histoire-reseau__lien:focus-visible {
  color: var(--em-text);
  border-color: var(--em-accent-light);
}

.histoire-reseau__lien:hover span,
.histoire-reseau__lien:focus-visible span {
  transform: translateX(4px);
}

/* ── MOTION LUXE — scroll-driven CSS pur ── */

/* Entrée des repères : cascade individuelle (2025 → 3 → 1). */
.histoire-ouverture__stat {
  opacity: 0;
  transform: translateY(14px);
  animation: histoireStatRise 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.histoire-ouverture__stat:nth-child(1) { animation-delay: 1.35s; }
.histoire-ouverture__stat:nth-child(2) { animation-delay: 1.5s; }
.histoire-ouverture__stat:nth-child(3) { animation-delay: 1.65s; }

@keyframes histoireStatRise {
  to { opacity: 1; transform: translateY(0); }
}

/* Portrait : très léger settle d'échelle pendant l'entrée en fondu
   (scale ne touche pas le layout — zéro CLS ; le cadre clippe). */
.histoire-ouverture__media {
  overflow: clip;
}

.histoire-ouverture__media img {
  animation: histoirePortraitSettle 1.8s cubic-bezier(0.22, 1, 0.36, 1) 0.4s both;
}

@keyframes histoirePortraitSettle {
  from { scale: 1.04; }
  to { scale: 1; }
}

@supports (animation-timeline: view()) {
  /* Trois engagements : la ligne se dessine, le jalon éclot. */
  .histoire-valeurs__item::before {
    transform-origin: left center;
    animation: histoireTrace linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 70%;
  }

  .histoire-valeurs__item::after {
    animation: histoireJalon linear both;
    animation-timeline: view();
    animation-range: entry 30% entry 85%;
  }

  /* Exergue : le filet rose se trace verticalement à l'entrée. */
  .histoire-recit__exergue {
    border-left-color: transparent;
    position: relative;
  }

  .histoire-recit__exergue::before {
    content: '';
    position: absolute;
    left: -2px;
    top: 0;
    width: 2px;
    height: 100%;
    background: var(--em-accent-light);
    transform-origin: top center;
    animation: histoireExergue linear both;
    animation-timeline: view();
    animation-range: entry 10% entry 80%;
  }
}

@keyframes histoireTrace {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes histoireJalon {
  from { opacity: 0; transform: scale(0.4); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes histoireExergue {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}

/* ── MOTION — reduced-motion : tout visible immédiatement ── */

@media (prefers-reduced-motion: reduce) {
  .histoire-ouverture__folio,
  .histoire-ouverture__lead,
  .histoire-ouverture__stats,
  .histoire-ouverture__stat,
  .histoire-ouverture__media {
    opacity: 1;
    transform: none;
    animation: none;
  }

  .histoire-ouverture__media img {
    scale: none;
    animation: none;
  }

  .histoire-ouverture__title {
    clip-path: none;
    animation: none;
  }

  .histoire-ouverture__folio::after {
    transform: none;
    animation: none;
  }

  .histoire-valeurs__item::before,
  .histoire-valeurs__item::after,
  .histoire-recit__exergue::before {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .histoire-recit__exergue {
    border-left-color: var(--em-accent-light);
  }
}

/* ── RESPONSIVE ── */

@media (max-width: 1024px) {
  .histoire-ouverture__inner {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  /* Le portrait passe sous le texte, cadré 4/5. */
  .histoire-ouverture__media img {
    aspect-ratio: 4 / 5;
    height: auto;
  }

  .histoire-recit__corps {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  .histoire-valeurs__items {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .histoire-reseau__layout--media {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }
}

@media (max-width: 767px) {
  /* Rythme compact mobile (parité pages validées). */
  .main-mon-histoire .section--contenu {
    padding-block: clamp(56px, 14vw, 72px);
  }

  .histoire-ouverture {
    min-height: 0; /* split empilé : la hauteur vient du contenu */
  }

  .histoire-ouverture__inner {
    padding-top: calc(var(--nav-height, 64px) + 20px);
    padding-bottom: 0;
  }

  .histoire-ouverture__texte {
    gap: var(--space-md);
  }

  .histoire-ouverture__title {
    max-width: none;
  }

  /* Repères empilés en lignes compactes. */
  .histoire-ouverture__stats {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .histoire-ouverture__stat {
    display: flex;
    align-items: baseline;
    gap: 16px;
    padding-block: 12px;
  }

  .histoire-ouverture__stat-num {
    font-size: 1.7rem;
    min-width: 64px;
    margin: 0;
  }

  .histoire-ouverture__stat-label {
    max-width: none;
  }

  /* Portrait full-bleed sous les repères. */
  .histoire-ouverture__media {
    margin-inline: calc(-1 * clamp(var(--space-4), 4vw, var(--space-8)));
    margin-top: var(--space-md);
  }

  .histoire-recit__corps,
  .histoire-valeurs__items {
    margin-top: var(--space-lg);
  }

  .histoire-recit__exergue p {
    max-width: none;
  }
}
