/*
 * Socle premium · styles communs des démos « qui en jettent » (ADR-015).
 * Source unique : outils/socle-premium/. Copié dans clients/{slug}/socle/ par
 * installer.mjs : NE PAS modifier la copie, modifier ici et réinstaller.
 *
 * Chaque site définit ses tokens sur :root (--fond, --texte, --texte-doux,
 * --accent, --surface, --filigrane-*) et ses polices (--titre, --corps).
 * Ce fichier ne pose AUCUNE couleur en dur hors des valeurs de repli.
 */

*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* clip et non hidden : hidden casse position: sticky (leçon Passyfloral). */
  overflow-x: clip;
  scroll-behavior: smooth;
}
body {
  margin: 0;
  overflow-x: clip;
  background: var(--fond, #fff);
  color: var(--texte, #111);
  font: 400 var(--t-corps, 1.0625rem)/1.6 var(--corps, system-ui, sans-serif);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent, currentColor); outline-offset: 3px; }

/* Lien d'évitement : premier élément tabulable de chaque page. */
.evitement {
  position: absolute; left: 1rem; top: -4rem; z-index: 2147483001;
  padding: .7rem 1rem; border-radius: .5rem;
  background: var(--texte, #111); color: var(--fond, #fff); text-decoration: none;
}
.evitement:focus { top: 1rem; }

/* Garde un mot et sa ponctuation ensemble : <span class="insecable"><em>ici</em>,</span> */
.insecable { white-space: nowrap; }

.visuellement-cache {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ------------------------------------------------------------------------ */
/* Apparitions au défilement (socle.js pose .est-visible)                    */
/* Sans JS : tout est visible, la classe .socle-actif n'est jamais posée.    */
/* ------------------------------------------------------------------------ */
.socle-actif [data-revele] {
  opacity: 0;
  transform: translate3d(0, var(--revele-y, 2.2rem), 0) scale(var(--revele-s, 1));
  filter: blur(var(--revele-flou, 6px));
  transition:
    opacity .9s cubic-bezier(.16, 1, .3, 1),
    transform 1.1s cubic-bezier(.16, 1, .3, 1),
    filter .9s cubic-bezier(.16, 1, .3, 1);
  transition-delay: calc(var(--i, 0) * 90ms);
}
.socle-actif [data-revele].est-visible { opacity: 1; transform: none; filter: none; }

/* Mots qui montent un à un (socle.js découpe [data-mots]). */
.socle-actif [data-mots] .mot {
  display: inline-block;
  opacity: 0;
  transform: translate3d(0, .45em, 0) rotate(2deg);
  filter: blur(8px);
  transition: opacity .8s cubic-bezier(.16, 1, .3, 1), transform 1s cubic-bezier(.16, 1, .3, 1), filter .8s;
  transition-delay: calc(var(--m, 0) * 55ms + var(--decalage-mots, 0ms));
}
.socle-actif [data-mots].est-visible .mot { opacity: 1; transform: none; filter: none; }

/* ------------------------------------------------------------------------ */
/* Scènes pilotées par le défilement                                         */
/* La longueur est réservée en CSS (--longueur) : rien ne saute au chargement */
/* ------------------------------------------------------------------------ */
.scene { position: relative; height: var(--longueur, 260svh); }
.scene__collant {
  position: sticky; top: 0;
  height: 100svh; overflow: hidden;
}

/* ------------------------------------------------------------------------ */
/* Inclinaison 3D au pointeur (socle.js écrit --rx, --ry en degrés)           */
/* ------------------------------------------------------------------------ */
/* --tour-z : une rotation de pose propre à l'élément (étiquette penchée…),
   conservée sous l'inclinaison. */
[data-incline] {
  transform: perspective(var(--perspective, 900px)) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) rotate(var(--tour-z, 0deg));
  transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.16, 1, .3, 1);
  will-change: transform;
}
/* Un élément à la fois révélé et inclinable : une fois visible, l'inclinaison
   reprend la main (sinon « transform: none » de la révélation l'écrase). */
.socle-actif [data-revele][data-incline].est-visible {
  transform: perspective(var(--perspective, 900px)) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) rotate(var(--tour-z, 0deg));
}

/* ------------------------------------------------------------------------ */
/* Filigrane de démo (obligatoire, bas GAUCHE, couleurs par tokens)          */
/* ------------------------------------------------------------------------ */
.filigrane-demo {
  position: fixed; left: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom)); z-index: 2147483000;
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--filigrane-fond); color: var(--filigrane-texte);
  border: 1px solid var(--filigrane-bord); border-radius: 999px;
  padding: .5rem .95rem; min-height: 44px;
  font: 500 .78rem/1.2 var(--corps, system-ui, sans-serif); letter-spacing: .02em;
  text-decoration: none;
  box-shadow: 0 2px 10px rgb(0 0 0 / .12);
}
.filigrane-demo::before { content: ""; width: .4rem; height: .4rem; border-radius: 50%; background: var(--filigrane-point, currentColor); flex: none; }
.filigrane-demo:focus-visible { outline: 2px solid var(--filigrane-texte); outline-offset: 2px; }
@media (max-width: 480px) {
  .filigrane-demo { font-size: .72rem; padding: .42rem .8rem; left: .6rem; bottom: calc(.6rem + env(safe-area-inset-bottom)); }
}
@media print { .filigrane-demo { display: none; } }

/* ------------------------------------------------------------------------ */
/* Assistant (assistant.js) : bouton bas DROITE, panneau au-dessus           */
/* ------------------------------------------------------------------------ */
.assistant-bouton {
  position: fixed; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom)); z-index: 2147482999;
  width: 60px; height: 60px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center;
  background: var(--assistant-fond, var(--accent, #111)); color: var(--assistant-texte, #fff);
  box-shadow: 0 10px 30px rgb(0 0 0 / .28);
  transition: transform .35s cubic-bezier(.16, 1, .3, 1);
}
.assistant-bouton:hover { transform: scale(1.06); }
.assistant-bouton svg { width: 28px; height: 28px; }
@media (max-width: 480px) { .assistant-bouton { right: .6rem; bottom: calc(.6rem + env(safe-area-inset-bottom)); width: 54px; height: 54px; } }

.assistant-panneau {
  position: fixed; right: 1rem; bottom: calc(5.2rem + env(safe-area-inset-bottom)); z-index: 2147482999;
  width: min(380px, calc(100vw - 2rem)); max-height: min(560px, calc(100svh - 7rem));
  display: flex; flex-direction: column;
  background: var(--assistant-panneau, var(--surface, #fff)); color: var(--assistant-panneau-texte, var(--texte, #111));
  border: 1px solid var(--assistant-bord, rgb(0 0 0 / .1)); border-radius: 1.2rem;
  box-shadow: 0 30px 80px rgb(0 0 0 / .3);
  overflow: hidden;
  transform-origin: 100% 100%;
  animation: assistant-ouvre .45s cubic-bezier(.16, 1, .3, 1);
}
.assistant-panneau[hidden] { display: none; }
@keyframes assistant-ouvre { from { opacity: 0; transform: translateY(12px) scale(.96); } }
.assistant-tete { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .9rem 1rem; border-bottom: 1px solid var(--assistant-bord, rgb(0 0 0 / .1)); }
.assistant-tete strong { font-size: 1rem; }
.assistant-tete small { display: block; opacity: .7; font-size: .78rem; }
.assistant-fermer { width: 44px; height: 44px; border: 0; background: transparent; border-radius: 50%; cursor: pointer; font-size: 1.4rem; line-height: 1; }
.assistant-fil { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .6rem; }
.assistant-bulle { max-width: 88%; padding: .7rem .9rem; border-radius: 1rem; font-size: .92rem; line-height: 1.45; }
.assistant-bulle--bot { align-self: flex-start; background: var(--assistant-bulle, rgb(0 0 0 / .06)); border-bottom-left-radius: .3rem; }
.assistant-bulle--moi { align-self: flex-end; background: var(--assistant-fond, var(--accent, #111)); color: var(--assistant-texte, #fff); border-bottom-right-radius: .3rem; }
.assistant-bulle a { font-weight: 600; }
.assistant-suggestions { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 1rem .8rem; }
.assistant-suggestions button {
  min-height: 44px; padding: .45rem .8rem; border-radius: 999px; cursor: pointer; font-size: .85rem;
  border: 1px solid var(--assistant-bord, rgb(0 0 0 / .15)); background: transparent;
}
.assistant-saisie { display: flex; gap: .5rem; padding: .7rem; border-top: 1px solid var(--assistant-bord, rgb(0 0 0 / .1)); }
.assistant-saisie input {
  flex: 1; min-width: 0; min-height: 44px; padding: .5rem .8rem; border-radius: .7rem; font: inherit; font-size: 16px;
  border: 1px solid var(--assistant-bord, rgb(0 0 0 / .15)); background: transparent; color: inherit;
}
.assistant-saisie button {
  min-width: 44px; min-height: 44px; border: 0; border-radius: .7rem; cursor: pointer;
  background: var(--assistant-fond, var(--accent, #111)); color: var(--assistant-texte, #fff); font-weight: 600; padding: 0 .9rem;
}

/* ------------------------------------------------------------------------ */
/* Toile WebGL et son repli                                                  */
/* ------------------------------------------------------------------------ */
.toile { position: absolute; inset: 0; width: 100%; height: 100%; }
/* L'image de repli reste dans le DOM : elle s'affiche tant que la toile n'est
   pas prête, et pour toujours si le WebGL est refusé ou trop lent. */
.toile-prete .repli-webgl { opacity: 0; transition: opacity .8s ease; }

/* ------------------------------------------------------------------------ */
/* Mouvement réduit : tout est posé, rien ne bouge                           */
/* ------------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .socle-actif [data-revele], .socle-actif [data-mots] .mot { opacity: 1; transform: none; filter: none; }
  [data-incline] { transform: none !important; }
}
