/* ============================================================================
   LivePLC — Accueil en chapitres (page d'accroche, 2026-10-04)
   Fichier PROPRE à index.html : ne touche jamais liveplc.css/liveplc.js
   (un autre chantier y travaille en parallèle). Variables réutilisées telles
   quelles : --accent, --accent-2, --accent-soft, --bg/--bg2/--bg3, --card,
   --border, --text/--text2/--text3, --radius, --shadow(-lg), --mono, --font,
   --nav-h, --green, --red.
   ============================================================================ */

/* ---------- Rail de progression (desktop) ---------- */
.ch-rail {
  position: fixed; right: 20px; top: 50%; transform: translateY(-50%); z-index: 70;
  display: flex; flex-direction: column; gap: 15px;
}
.ch-rail a {
  position: relative; width: 11px; height: 11px; border-radius: 50%;
  background: var(--border); display: block; transition: background .2s, transform .2s;
}
.ch-rail a:hover, .ch-rail a:focus-visible { transform: scale(1.25); }
.ch-rail a.active { background: var(--accent); transform: scale(1.35); }
.ch-rail .rl-label {
  position: absolute; right: 22px; top: 50%; transform: translateY(-50%);
  white-space: nowrap; background: var(--card); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 8px; font-size: .76rem; font-weight: 600;
  color: var(--text2); opacity: 0; pointer-events: none; transition: opacity .15s;
  box-shadow: var(--shadow);
}
.ch-rail a:hover .rl-label, .ch-rail a:focus-visible .rl-label { opacity: 1; }
@media (max-width: 920px) { .ch-rail { display: none; } }

/* ---------- Barre de progression (mobile) ---------- */
.ch-progress-mobile { display: none; }
@media (max-width: 920px) {
  .ch-progress-mobile {
    display: block; position: sticky; top: var(--nav-h); height: 3px;
    background: var(--border); z-index: 69;
  }
  .ch-progress-mobile i {
    display: block; height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    transition: width .12s linear;
  }
}

/* ---------- Structure générale des chapitres ---------- */
.chapter {
  position: relative; overflow: hidden;
  padding: 90px 0;
}
.chapter.hero { padding: 86px 0 64px; } /* l'accroche garde le padding du hero existant */
@media (min-width: 900px) {
  .chapter:not(.hero) { min-height: 100svh; display: flex; align-items: center; }
}
.chapter--alt { background: var(--bg2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

.chapter-bg-grid {
  content: ""; position: absolute; inset: 0; z-index: 0; opacity: .35; pointer-events: none;
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 46px 46px; mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
}
@supports (animation-timeline: view()) {
  .chapter-bg-grid { animation: ch-parallax linear; animation-timeline: view(); animation-range: entry 0% cover 60%; }
  @keyframes ch-parallax { from { transform: translateY(-14px); } to { transform: translateY(6px); } }
}

.chapter-inner {
  display: grid; grid-template-columns: 1fr 1fr; gap: 50px; align-items: center;
  position: relative; z-index: 1;
}
.chapter--media-right .chapter-inner { grid-template-areas: "text media"; }
.chapter--media-right .chapter-text { grid-area: text; }
.chapter--media-right .chapter-media { grid-area: media; }
.chapter--media-left .chapter-inner { grid-template-areas: "media text"; }
.chapter--media-left .chapter-text { grid-area: text; }
.chapter--media-left .chapter-media { grid-area: media; }
@media (max-width: 900px) {
  .chapter-inner { grid-template-columns: 1fr; grid-template-areas: "media" "text" !important; gap: 28px; }
}

.chapter-text h2 { font-size: clamp(1.6rem, 3vw, 2.3rem); margin-bottom: 14px; }
.chapter-text > p { color: var(--text2); font-size: 1.04rem; max-width: 520px; }
.ch-points { list-style: none; margin: 18px 0 20px; padding: 0; display: grid; gap: 10px; }
.ch-points li {
  position: relative; padding-left: 26px; color: var(--text2); font-size: .94rem;
}
.ch-points li::before {
  content: "✓"; position: absolute; left: 0; top: 0; font-weight: 800; font-size: .68rem;
  color: var(--accent); width: 17px; height: 17px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft);
}

/* ---------- Révélation au scroll (générique chapitres) ---------- */
.ch-reveal {
  opacity: 0; transform: translateY(26px); filter: blur(2px);
  transition: opacity .7s ease, transform .7s ease, filter .7s ease;
}
.ch-reveal.is-in { opacity: 1; transform: none; filter: blur(0); }
.chapter-media.ch-reveal { transition-delay: .08s; }

/* ---------- Titre révélé mot à mot (accroche) ---------- */
.title-split .word {
  display: inline-block; opacity: 0; transform: translateY(14px); filter: blur(3px);
  transition: opacity .5s ease, transform .5s ease, filter .5s ease;
  transition-delay: calc(var(--i, 0) * 45ms);
}
.title-split.is-in .word { opacity: 1; transform: none; filter: blur(0); }
/* Mots du texte en DÉGRADÉ (`.grad`) : un bloc animé (inline-block + transform) ne reçoit plus le
   `background-clip: text` de son parent — il restait transparent, donc INVISIBLE (constaté sur
   mobile : la 2ᵉ ligne du titre avait disparu). Chaque mot porte donc son propre dégradé. */
.title-split .grad .word {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- Maquette d'appareil (accroche) ---------- */
.accroche-device {
  margin-top: 52px; border-radius: 16px; overflow: hidden; border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); background: var(--card);
  transform: perspective(1000px) rotateX(26deg) translateY(14px); opacity: 0;
  transform-origin: center bottom;
  transition: transform 1s cubic-bezier(.22,1,.36,1), opacity 1s ease;
}
.accroche-device.is-in { transform: perspective(1000px) rotateX(0deg) translateY(0); opacity: 1; }
/* Le carrousel des cas d'usage (14/10) a son propre cadre : la maquette ne garde que l'animation d'entrée. */
.accroche-device.accroche-cas { border: 0; background: transparent; box-shadow: none; overflow: visible; text-align: left; }

/* ---------- Indice de défilement ---------- */
.scroll-hint {
  display: flex; flex-direction: column; align-items: center; gap: 7px; margin: 46px auto 0;
  width: fit-content; font-size: .7rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text3); font-weight: 700;
}
.sh-arrow { width: 18px; height: 28px; border: 2px solid var(--text3); border-radius: 10px; position: relative; }
.sh-arrow::after {
  content: ""; position: absolute; top: 6px; left: 50%; width: 4px; height: 4px;
  background: var(--text3); border-radius: 50%; transform: translateX(-50%);
  animation: sh-bounce 1.6s infinite;
}
@keyframes sh-bounce { 0%,100% { top: 6px; opacity: 1; } 50% { top: 14px; opacity: .25; } }

/* ============================================================================
   Emplacements média (data-media) — chargement paresseux via accueil.js,
   cadre de remplacement si le fichier n'existe pas encore.
   ============================================================================ */
.media-slot {
  position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--border);
  background: var(--bg2); aspect-ratio: 16/10; margin: 0;
}
.media-slot video, .media-slot img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.media-fallback {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; text-align: center; padding: 24px;
  border: 2px dashed var(--border); border-radius: 14px; box-sizing: border-box;
  background: repeating-linear-gradient(45deg, var(--bg2), var(--bg2) 14px, var(--bg3) 14px, var(--bg3) 28px);
  color: var(--text3);
}
.media-fallback .mf-ico {
  font-size: 1.9rem; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.media-fallback .mf-label { font-size: .86rem; color: var(--text2); max-width: 340px; }
.media-fallback .mf-path { font-family: var(--mono); font-size: .72rem; color: var(--text3); word-break: break-all; max-width: 340px; }
.media-slot .mf-playbtn {
  position: absolute; inset: 0; display: grid; place-items: center; border: 0; background: rgba(0,0,0,.28);
  cursor: pointer; color: #fff; font-size: 1.8rem;
}
.media-slot .mf-playbtn span {
  width: 60px; height: 60px; border-radius: 50%; background: rgba(255,255,255,.18);
  backdrop-filter: blur(3px); display: grid; place-items: center;
}

/* ---------- Média sticky / colonne (connecter, temps-réel) ---------- */
.chapter-media { position: relative; }
.rt-mini-row { display: flex; align-items: center; gap: 22px; margin-top: 18px; }

/* ---------- Schéma SVG : connexion automate → serveur → écrans ---------- */
.connect-schema { width: 100%; height: auto; margin-top: 18px; max-width: 460px; }
.cs-node rect { fill: var(--card); stroke: var(--border); stroke-width: 2; }
.cs-node text { fill: var(--text2); font-family: var(--font); font-size: 11px; font-weight: 700; }
.cs-line { stroke: var(--border); stroke-width: 2; stroke-dasharray: 100; stroke-dashoffset: 100; transition: stroke-dashoffset 1.1s ease, stroke .3s ease; }
.ch-reveal.is-in .cs-line { stroke-dashoffset: 0; stroke: var(--accent); }
.ch-reveal.is-in .cs-line-b { transition-delay: .3s; }
.cs-packet circle { fill: var(--accent-2); }
.cs-packet { opacity: 0; }
.ch-reveal.is-in .cs-packet-a { animation: cs-flow-a 2.2s 1.3s linear infinite; }
.ch-reveal.is-in .cs-packet-b { animation: cs-flow-b 2.2s 1.6s linear infinite; }
@keyframes cs-flow-a { 0% { transform: translate(112px,60px); opacity: 0; } 8% { opacity: 1; } 92% { opacity: 1; } 100% { transform: translate(208px,60px); opacity: 0; } }
@keyframes cs-flow-b { 0% { transform: translate(312px,60px); opacity: 0; } 8% { opacity: 1; } 92% { opacity: 1; } 100% { transform: translate(408px,60px); opacity: 0; } }

/* ---------- Chapitre 2 : défilement narratif (média fixé, étapes qui défilent) ---------- */
.chapter--narrative .chapter-inner, .narr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 50px; position: relative; z-index: 1; }
.narr-media-wrap { position: relative; }
.narr-sticky { position: sticky; top: calc(var(--nav-h) + 50px); }
.narr-steps .section-label { margin-top: 2px; }
.narr-steps h2 { margin-bottom: 26px; }
.narr-step {
  padding: 26px 0 26px 22px; border-left: 3px solid var(--border);
  opacity: .4; filter: blur(.4px); transform: translateX(0);
  transition: opacity .35s ease, filter .35s ease, border-color .35s ease, transform .35s ease;
}
.narr-step.is-active { opacity: 1; filter: none; border-left-color: var(--accent); transform: translateX(4px); }
.narr-step h3 { font-size: 1.08rem; margin-bottom: 6px; }
.narr-step p { color: var(--text2); font-size: .92rem; margin: 0; }
@media (max-width: 900px) {
  .narr-grid, .chapter--narrative .chapter-inner { grid-template-columns: 1fr; }
  .narr-sticky { position: relative; top: 0; margin-bottom: 24px; }
}

/* ---------- Chapitre 3 : compteurs ---------- */
.ch-counters { display: flex; gap: 30px; margin: 20px 0 6px; flex-wrap: wrap; }
.counter-num { display: block; font-size: 2.1rem; font-weight: 900; color: var(--accent); font-family: var(--mono); }
.counter-lbl { font-size: .8rem; color: var(--text2); }

/* courbe qui se trace */
.trend-mini { width: 140px; height: 40px; flex: none; }
.trend-path { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 420; stroke-dashoffset: 420; transition: stroke-dashoffset 1.6s ease; }
.ch-reveal.is-in .trend-path { stroke-dashoffset: 0; }

/* jauge animée */
.mini-gauge { position: relative; width: 70px; height: 70px; flex: none; }
.mini-gauge svg { width: 100%; height: 100%; }
.mg-bg { fill: none; stroke: var(--border); stroke-width: 8; }
.mg-fg {
  fill: none; stroke: var(--accent-2); stroke-width: 8; stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: 40px 40px;
  stroke-dasharray: 213; stroke-dashoffset: 213; transition: stroke-dashoffset 1.3s ease .15s;
}
.ch-reveal.is-in .mg-fg { stroke-dashoffset: calc(213 - (213 * var(--pct, 0) / 100)); }
.mg-val { position: absolute; inset: 0; display: grid; place-items: center; font-size: .74rem; font-weight: 800; color: var(--text); }

/* ---------- Chapitre 4 : bandeau d'alarme animé ---------- */
.alarm-demo {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 12px; margin-top: 18px;
  background: color-mix(in srgb, var(--red) 10%, var(--card));
  border: 1px solid color-mix(in srgb, var(--red) 35%, transparent);
  transition: background .6s ease, border-color .6s ease;
}
.al-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--red); flex: none; }
.ch-reveal.is-in .alarm-demo:not(.ack) .al-dot { animation: al-pulse 1s ease-in-out infinite; }
@keyframes al-pulse { 0% { box-shadow: 0 0 0 0 rgba(220,38,38,.55); } 70% { box-shadow: 0 0 0 10px rgba(220,38,38,0); } 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); } }
.alarm-demo.ack { background: color-mix(in srgb, var(--green) 10%, var(--card)); border-color: color-mix(in srgb, var(--green) 35%, transparent); }
.alarm-demo.ack .al-dot { background: var(--green); animation: none; box-shadow: none; }
.al-body { display: flex; flex-direction: column; gap: 2px; }
.al-title { font-size: .92rem; }
.al-state { font-size: .78rem; color: var(--text2); }
.al-ack { margin-left: auto; font-size: .76rem; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text2); flex: none; }
.alarm-demo.ack .al-ack { color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, transparent); }

/* ---------- Chapitre 5 : cadre téléphone ---------- */
.phone-frame {
  max-width: 230px; margin: 0 auto; border-radius: 28px; padding: 10px; border: 1px solid var(--border);
  background: var(--card); box-shadow: var(--shadow-lg);
  transform: perspective(900px) rotateY(50deg) translateX(34px); opacity: 0;
  transition: transform .9s cubic-bezier(.16,1,.3,1), opacity .9s ease;
}
.ch-reveal.is-in .phone-frame { transform: perspective(900px) rotateY(0deg) translateX(0); opacity: 1; }
.phone-frame .media-slot { aspect-ratio: 9/18; border-radius: 20px; }

/* ---------- Chapitre 6 : bascule serveur de secours ---------- */
.failover-schema { width: 100%; max-width: 320px; height: auto; margin-top: 18px; }
.fs-server rect { fill: var(--card); stroke: var(--border); stroke-width: 2; }
.fs-server text { fill: var(--text2); font-family: var(--font); font-size: 11px; font-weight: 700; }
.fs-primary .fs-dot { fill: var(--green); transition: fill .5s ease; }
.fs-secondary .fs-dot { fill: var(--text3); transition: fill .5s ease; }
.fs-arrow { stroke: var(--border); stroke-width: 2; fill: none; opacity: .4; transition: opacity .5s ease, stroke .5s ease; }
.failover-schema.switching .fs-primary .fs-dot { fill: var(--text3); }
.failover-schema.switching .fs-arrow { opacity: 1; stroke: var(--accent); }
.failover-schema.switching .fs-secondary .fs-dot { fill: var(--green); }

/* ---------- Bande de renvois avant l'appel final ---------- */
.crosslinks-band { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--bg2); padding: 20px 0; }
.crosslinks-inner { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; }
.cl-lbl { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text3); }
.crosslinks-inner a {
  font-size: .86rem; font-weight: 700; padding: 6px 13px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border); color: var(--text2); transition: .15s;
}
.crosslinks-inner a:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Chapitre 7 : fond qui s'illumine ---------- */
#contact.chapter { position: relative; }
.contact-glow {
  position: absolute; inset: -20%; z-index: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 30%, var(--accent-soft), transparent 62%);
  opacity: 0; transform: scale(.6); transition: opacity 1.2s ease, transform 1.2s ease;
}
.contact-glow.is-in { opacity: 1; transform: scale(1); }

/* ---------- Accessibilité : mouvement réduit ---------- */
@media (prefers-reduced-motion: reduce) {
  .chapter-bg-grid { animation: none !important; }
  .cs-packet, .al-dot, .sh-arrow::after { animation: none !important; }
  .ch-reveal, .title-split .word, .accroche-device, .phone-frame, .contact-glow,
  .cs-line, .trend-path, .mg-fg, .narr-step, .fs-arrow, .fs-primary .fs-dot, .fs-secondary .fs-dot {
    transition: opacity .4s ease !important; transform: none !important; filter: none !important;
  }
}
