/* INDEX V3 — « Nos expertises », version B2 « Scène dédiée inversée » (LOTS 5B → 5D).
   Feuille propre à la section : aucune règle partagée n'est modifiée ; tout est limité à .xp et à ses enfants.

   1. Base (mobile d'abord) : liste typographique légère, un repère dessiné par expertise, aucune image chargée.
   2. Tablette et petites fenêtres (≥ 900 px) : deux colonnes, titre à gauche, liste à droite.
   3. Bureau (souris fine + largeur ≥ 1000 px) : scène 3D collante à gauche, titre et liste à droite.
      Au repos, trois fenêtres côte à côte (triptyque, éclairage bas). À la sélection (survol, focus clavier
      ou survol de la scène), la fenêtre choisie s'ouvre depuis sa case, les deux autres se replient vers
      leur bord, puis la scène « s'éveille » (passe d'éclairage). Ce n'est pas un carrousel. */

/* ---------- 1. Base ---------- */
.xp { --acc-sites: linear-gradient(90deg, #f2296f, #ff8f1a); --acc-applications: linear-gradient(90deg, #8f5bff, #f2296f); --acc-experiences: linear-gradient(90deg, #6b2bff, #f2296f 55%, #ff8f1a); }
.xp .xp-grid { display: grid; grid-template-columns: minmax(0, 1fr); row-gap: 44px; position: relative; }
.xp .xp-side { display: grid; row-gap: 44px; align-content: start; }
.xp .xp-head { display: grid; gap: 24px; align-content: start; container-type: inline-size; }
.xp .xp-head .display-l { font-size: clamp(44px, 13.4cqi, 108px); }
.xp .xp-head .lead { font-size: 17px; max-width: 26em; }

.xp-list { list-style: none; margin: 0; padding: 0; border-bottom: 1px solid var(--line); container-type: inline-size; }
.xp-item { position: relative; }
.xp-link {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; row-gap: 10px; align-items: start;
  padding-block: 28px 30px; border-top: 1px solid var(--line); position: relative; color: inherit; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
/* filet d'accent propre à chaque expertise, posé sur la ligne de séparation */
.xp-link::before {
  content: ""; position: absolute; left: 0; top: -1px; height: 1px; width: 56px; opacity: .9;
  transform-origin: left; transition: transform .9s var(--ease), opacity .6s;
}
.xp-item[data-k="sites"] .xp-link::before { background: var(--acc-sites); }
.xp-item[data-k="applications"] .xp-link::before { background: var(--acc-applications); }
.xp-item[data-k="experiences"] .xp-link::before { background: var(--acc-experiences); }
.xp-name {
  grid-column: 1 / -1; grid-row: 1; margin: 0;
  font-family: var(--f-display); font-weight: 800; font-stretch: 108%; text-transform: uppercase;
  font-size: min(calc((100cqi - 14px) / 9.2), 56px); line-height: .95; letter-spacing: -.01em; color: #d6d2cb;
  transition: color .5s, transform .7s var(--ease);
}
.xp-desc { grid-column: 1; margin: 0; color: var(--mute); font-size: 16px; line-height: 1.55; max-width: 30em; transition: color .5s; }
.xp-cta {
  grid-column: 1; justify-self: start; margin-top: 4px;
  font-family: var(--f-mono); font-size: 12px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--mute);                       /* #9a96a3 sur le fond : 6,8 : 1 */
  display: inline-flex; gap: 10px; transition: color .4s;
}
.xp-cta span { transition: transform .5s var(--ease); }

/* repère dessiné : tracé fin dans les couleurs de l'expertise, qui se dessine une fois à l'apparition */
.xp-mark { grid-column: 2; grid-row: 2 / span 2; align-self: end; width: 44px; height: 44px; margin-bottom: -2px; }
.xp-mark svg { display: block; width: 100%; height: 100%; overflow: visible; }
.xp-mark g { fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.xp-mark .m { fill: var(--ink); }
.js .xp-mark g > * { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 1.5s var(--ease) .25s; }
.js .xp-item.in .xp-mark g > * { stroke-dashoffset: 0; }
.js .xp-item.in .xp-mark g > :nth-child(n + 3) { transition-delay: .45s; }
.js .xp-item.in .xp-mark g > :nth-child(n + 5) { transition-delay: .65s; }

/* retour tactile sobre (pas d'effet de survol simulé) */
.xp-link:active .xp-name { color: var(--paper); }
.xp-link:active .xp-cta { color: var(--paper); }

/* la scène n'existe qu'en mode bureau */
.xp-stage { display: none; }

@media (max-width: 360px) {
  .xp-link { padding-block: 24px 26px; column-gap: 12px; }
  .xp-mark { width: 38px; height: 38px; }
  .xp-desc { font-size: 15.5px; }
}
/* mobile et tablette tactile : « Découvrir » affirmé (11 : 1), flèche détachée */
@media (hover: none), (max-width: 999px) {
  .xp-cta { color: #c9c5cf; font-weight: 500; }
  .xp-cta span { color: var(--paper); }
}

/* ---------- 2. Tablette et petites fenêtres : deux colonnes dès 900 px ---------- */
@media (min-width: 900px) {
  .xp .xp-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 2.4vw; }
  .xp .xp-side { display: contents; }
  .xp .xp-head { grid-column: 1 / span 5; }
  .xp .xp-list { grid-column: 7 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  .js .xp-mark g > * { stroke-dashoffset: 0; transition: none; }
}

/* ---------- 3. Bureau : scène dédiée à gauche, titre et liste à droite ---------- */
@media (hover: hover) and (pointer: fine) and (min-width: 1000px) {
  .xp { --open: 1.05s; --curve: cubic-bezier(.55, 0, .25, 1); }
  .xp .xp-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 2.4vw; row-gap: 0; align-items: start; }
  /* l'espace de fin de section devient une rangée de la grille : la scène (qui la traverse) reste collée
     jusqu'à la dernière expertise, même sur un écran de 720 px de haut. Espacement total inchangé. */
  .xp.expertises { padding-bottom: 0; }
  .xp .xp-grid::after { content: ""; grid-column: 1 / -1; grid-row: 2; height: calc(var(--sec-bottom) + 48px); }
  .xp .xp-side { display: grid; grid-column: 8 / -1; grid-row: 1; row-gap: 64px; }
  .xp .xp-head { grid-column: auto; }
  .xp .xp-list { grid-column: auto; }
  .xp .xp-mark { display: none; }
  .xp .xp-link { padding-block: clamp(22px, 3.4vh, 30px) clamp(24px, 3.6vh, 32px); grid-template-columns: minmax(0, 1fr); }
  .xp .xp-name { font-size: min(calc((100cqi - 14px) / 9.2), 56px); }
  .xp .xp-link::before { width: 100%; transform: scaleX(.1); opacity: .8; }
  .xp .xp-item.is-on .xp-link::before { transform: scaleX(1); opacity: 1; }
  .xp .xp-item.is-on .xp-name, .xp .xp-link:hover .xp-name, .xp .xp-link:focus-visible .xp-name { color: var(--paper); transform: translateX(10px); }
  .xp .xp-item.is-on .xp-desc, .xp .xp-link:hover .xp-desc { color: #c9c5cf; }
  .xp .xp-item.is-on .xp-cta, .xp .xp-link:hover .xp-cta, .xp .xp-link:focus-visible .xp-cta { color: var(--paper); }
  .xp .xp-item.is-on .xp-cta span, .xp .xp-link:hover .xp-cta span { transform: translateX(6px); }
  .xp .xp-list.has-on .xp-item:not(.is-on) .xp-name { color: #8f8b97; }

  /* la scène — marge basse : en fin de défilement, elle s'arrête à 48 px du séparateur de la section suivante.
     LOT 5D : une fois collée, elle se tient au centre optique de l'espace sous l'en-tête (74 px), un peu au-dessus
     du centre géométrique, au lieu de rester accrochée en haut : elle accompagne la liste jusqu'à la dernière
     expertise, y compris sur grand écran. --fh (hauteur de la scène) est fournie par expertises.js ;
     sans script, la valeur du LOT 5C s'applique (88 px + 4 vh). */
  .xp .xp-stage {
    display: block; grid-column: 1 / span 7; grid-row: 1 / span 2; margin-bottom: 48px; justify-self: start;
    position: sticky; top: max(calc(88px + 4vh), calc(74px + (100vh - 74px - var(--fh, 100vh)) * .45));
    width: min(100%, calc((100vh - 150px) * 4 / 3)); cursor: pointer;
  }
  .xp-frame {
    position: relative; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: #07060a; isolation: isolate;
    box-shadow: 0 70px 120px -50px rgba(0, 0, 0, .95), 0 30px 80px -40px rgba(107, 43, 255, .4), inset 0 0 0 1px rgba(238, 235, 229, .06);
  }
  .xp-art { position: absolute; inset: 0; z-index: 1; transition: clip-path var(--open) var(--curve), opacity .5s var(--ease-io) .12s; will-change: clip-path; }
  .xp-img { position: absolute; inset: 0; transition: translate var(--open) var(--curve), scale 1.3s var(--ease); }
  /* voile bas (lisibilité des légendes) — LOT 5D : resserré sur le tiers inférieur pour ne plus éteindre les téléphones */
  .xp-img::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(8, 7, 11, 0) 66%, rgba(8, 7, 11, .55)); opacity: 1; transition: opacity .9s var(--ease-io); }
  .xp-nojs { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
  .xp-p, .xp-p img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
  .xp-p img { object-fit: cover; }
  .xp-eveil { opacity: 0; transition: opacity .8s var(--ease-io); }
  .xp-label {
    position: absolute; bottom: 18px; z-index: 2; display: inline-flex; align-items: flex-start; gap: 10px;
    font-family: var(--f-mono); font-size: 11px; line-height: 1.6; letter-spacing: .16em; text-transform: uppercase; color: rgba(238, 235, 229, .86);
    text-shadow: 0 1px 12px rgba(0, 0, 0, .8); transition: translate 1s var(--ease-io), opacity .5s;
  }
  /* LOT 5D : filet calé sur la première ligne (la légende « Expériences interactives » tient sur deux lignes) */
  .xp-label::before { content: ""; flex: none; width: 18px; height: 1px; margin-top: calc(.8em - .5px); background: var(--acc); }
  .xp-art[data-k="sites"] { --acc: var(--acc-sites); }
  .xp-art[data-k="applications"] { --acc: var(--acc-applications); }
  .xp-art[data-k="experiences"] { --acc: var(--acc-experiences); }

  /* repos : triptyque */
  .xp-art[data-k="sites"] { clip-path: inset(0 calc(66.667% + 3px) 0 0 round 6px); }
  .xp-art[data-k="applications"] { clip-path: inset(0 calc(33.333% + 3px) 0 calc(33.333% + 3px) round 6px); }
  .xp-art[data-k="experiences"] { clip-path: inset(0 0 0 calc(66.667% + 3px) round 6px); }
  .xp-art[data-k="sites"] .xp-img { translate: -12% 0; }      /* cadrage de la fenêtre sur le titre du site */
  .xp-art[data-k="experiences"] .xp-img { translate: 43% 0; }      /* LOT 5D : question entière, réponses et manettes visibles au repos */
  .xp-art[data-k="sites"] .xp-label { left: 18px; }
  .xp-art[data-k="applications"] .xp-label { left: calc(33.333% + 21px); }
  .xp-art[data-k="experiences"] .xp-label { left: calc(66.667% + 21px); }
  .xp-stage.is-idle .xp-art:hover .xp-img { scale: 1.025; }
  /* fines arêtes de lumière entre les fenêtres */
  .xp-frame::before { content: ""; position: absolute; inset: 0; z-index: 29; pointer-events: none; border-radius: inherit;
    background: linear-gradient(90deg, transparent calc(33.333% - 3px), rgba(238, 235, 229, .06) calc(33.333% - 3px), rgba(238, 235, 229, .06) calc(33.333% + 3px), transparent calc(33.333% + 3px), transparent calc(66.667% - 3px), rgba(238, 235, 229, .06) calc(66.667% - 3px), rgba(238, 235, 229, .06) calc(66.667% + 3px), transparent calc(66.667% + 3px));
    opacity: 1; transition: opacity .6s var(--ease-io) .3s; }
  .xp-stage.is-active .xp-frame::before { opacity: 0; transition-delay: 0s; }

  /* sélection : la fenêtre choisie s'ouvre, les autres se replient vers leur bord */
  .xp-stage.is-active .xp-art[data-k="sites"] { clip-path: inset(0 100% 0 0 round 6px); }
  .xp-stage.is-active .xp-art[data-k="applications"] { clip-path: inset(0 50% 0 50% round 6px); }
  .xp-stage.is-active .xp-art[data-k="experiences"] { clip-path: inset(0 0 0 100% round 6px); }
  .xp-stage.is-active .xp-art:not(.on) { opacity: 0; transition: clip-path var(--open) var(--curve), opacity .35s var(--ease-io) .45s; }
  /* fenêtre précédente : elle poursuit son ouverture sous la nouvelle (même cible, aucun saut), puis s'efface */
  .xp-stage.is-active .xp-art.was { clip-path: inset(0 0 0 0 round 8px); opacity: 1; transition: clip-path var(--open) var(--curve), opacity .3s var(--ease-io) .85s; }
  .xp-stage.is-active .xp-art.was.gone { opacity: 0; }
  .xp-stage.is-active .xp-art.was .xp-img { translate: calc(var(--mx, 0) * -10px) calc(var(--my, 0) * -8px); scale: 1.035; }
  .xp-stage.is-active .xp-art.was .xp-eveil { opacity: 1; }
  /* départ d'une ouverture : la fenêtre est replacée sans transition dans sa case du triptyque */
  .xp-stage .xp-art.prep, .xp-stage .xp-art.prep .xp-img, .xp-stage .xp-art.prep .xp-label { transition: none !important; }
  .xp-stage.is-active .xp-art.prep { opacity: 0; z-index: 4; }
  .xp-stage.is-active .xp-art[data-k="sites"].prep { clip-path: inset(0 calc(66.667% + 3px) 0 0 round 6px); }
  .xp-stage.is-active .xp-art[data-k="applications"].prep { clip-path: inset(0 calc(33.333% + 3px) 0 calc(33.333% + 3px) round 6px); }
  .xp-stage.is-active .xp-art[data-k="experiences"].prep { clip-path: inset(0 0 0 calc(66.667% + 3px) round 6px); }
  .xp-stage.is-active .xp-art.on { clip-path: inset(0 0 0 0 round 8px); opacity: 1; z-index: 4; transition: clip-path var(--open) var(--curve), opacity .22s linear; }
  .xp-stage.is-active .xp-art.on .xp-img::after { opacity: .35; }
  .xp-stage.is-active .xp-art.on .xp-img { translate: calc(var(--mx, 0) * -10px) calc(var(--my, 0) * -8px); scale: 1.035; }
  .xp-stage.is-active .xp-art.on .xp-eveil { opacity: 1; transition-delay: .35s; transition-duration: 1.1s; }
  .xp-stage.is-active .xp-art[data-k="sites"].on .xp-label { translate: 4px 0; }
  .xp-stage.is-active .xp-art[data-k="applications"].on .xp-label { translate: calc(var(--fw, 0px) * -.33333 + 1px) 0; }
  .xp-stage.is-active .xp-art[data-k="experiences"].on .xp-label { translate: calc(var(--fw, 0px) * -.66667 + 1px) 0; }
  .xp-stage.is-active .xp-art.was .xp-label { opacity: 0; transition: opacity .2s; }   /* une seule légende visible pendant l'ouverture */
  .xp-stage.is-active .xp-art:not(.on) .xp-label { opacity: 0; }
  .xp-glow {
    position: absolute; inset: 0; z-index: 30; pointer-events: none; mix-blend-mode: screen; opacity: .55; transition: background 1.2s var(--ease-io);
    background: radial-gradient(70% 40% at 50% 112%, var(--glow, rgba(107, 43, 255, .28)), transparent 70%), linear-gradient(180deg, rgba(255, 255, 255, .05), transparent 16%);
  }
  .xp-stage.is-idle .xp-art { transition: clip-path var(--open) var(--curve), opacity .55s var(--ease-io) .18s; }
}
@media (hover: hover) and (pointer: fine) and (min-width: 1000px) and (prefers-reduced-motion: reduce) {
  .xp-stage.is-active .xp-art.on .xp-img { translate: 0 0; scale: 1; }
}
