/* Accueil du site — « Vedette sur mosaïque » (base commune avec les démonstrations /variantes/6a/, 6b/, 6c/).
   Un mur de photos défile en décor (colonnes ou rangées) ; par-dessus, un gâteau détouré à la fois flotte dans un halo
   clair. Les images viennent de assets/js/hero-visuels.js ; hero.js construit le mur et les vedettes.
   Rien ici ne suppose la forme des vedettes : chacune tient dans une boîte (--w × --h, calculée par hero.js d'après
   l'image et sa rotation), l'ombre et le halo sont des ellipses CSS qui suivent cette boîte.

   Réglages par page, posés sur la <section class="v6x"> :
     data-mur="colonnes" | "rangees"   sens du mur (vertical ou horizontal)
     data-pistes="4"                   nombre de colonnes ou de rangées
     data-vitesse="8"                  vitesse du défilement, en pixels par seconde
     data-sens="alterne" | "meme"      pistes en sens opposés (défaut) ou toutes dans le même sens
     data-pivot="0"                    inclinaison ajoutée à toutes les vedettes, en degrés
     --v6x-ampleur     taille de la vedette par rapport à son cadre (1 = elle le remplit)
     --v6x-haut / --v6x-bas / --v6x-cotes   marges du cadre de la vedette dans la scène (sa position)
     --v6x-voile       voile crème posé sur le mur (0 = aucun, 1 = mur invisible)
     --v6x-halo        intensité du halo (0 à 1) ; --v6x-halo-taille : son étendue ; --v6x-halo-net : netteté du bord (%)
     --v6x-pente / --v6x-zoom          inclinaison du mur et agrandissement (pour couvrir les coins)
     --v6x-espace / --v6x-rayon        espace entre tuiles, arrondi des tuiles
     --v6x-duree       durée d'affichage d'une vedette en défilement automatique
     --v6x-flottement  amplitude du flottement de la vedette (1 = normal, 0 = immobile)
   Mouvements en transform / opacity uniquement. */

.v6x {
  --v6x-L: min(80vw, 42vh, 30rem);          /* taille de secours (sans JavaScript) et base du halo */
  --v6x-ampleur: 1;
  --v6x-haut: .4rem; --v6x-bas: 1.35rem; --v6x-cotes: 0px;
  --v6x-voile: .22;
  --v6x-halo: 1; --v6x-halo-taille: 1; --v6x-halo-net: 46%;
  --v6x-pente: -4deg; --v6x-zoom: 1.12;
  --v6x-espace: .45rem; --v6x-rayon: .85rem;
  --v6x-duree: 5.8s; --v6x-flottement: 1;
  --v6x-creme: 251, 246, 239;
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto;
  min-height: 100vh; min-height: 100svh;
  background: var(--ivory-light);
}
@supports (height: 1svh) { .v6x { --v6x-L: min(80vw, 42svh, 30rem); } }

/* ── Scène : mur (décor) + voile + cadre de la vedette (halo, gâteau) + points ── */
.v6x-scene { position: relative; grid-row: 1; min-height: 14rem; touch-action: pan-y; -webkit-user-select: none; user-select: none; cursor: grab; outline: none; -webkit-tap-highlight-color: transparent; }
.v6x-scene:active { cursor: grabbing; }
.v6x-scene:focus-visible { outline: 2px solid var(--rose); outline-offset: -4px; }

/* Le mur descend de 3.5rem SOUS le bloc texte, dont le dégradé crème le recouvre. Il apparaît en fondu une fois construit. */
.v6x-mur { position: absolute; inset: 0 0 -3.5rem 0; z-index: 0; overflow: hidden; pointer-events: none; opacity: 0; transition: opacity 1.3s ease; }
.v6x.is-mur .v6x-mur { opacity: 1; }
.v6x-pente { position: absolute; inset: -2% -4%; display: flex; gap: var(--v6x-espace); transform: rotate(var(--v6x-pente)) scale(var(--v6x-zoom)); transform-origin: 50% 45%; }
.v6x-rail { flex: 1 1 0; min-width: 0; min-height: 0; }
.v6x-piste { display: flex; flex-direction: column; transform: translate3d(0, var(--y0, 0%), 0); }
.v6x-serie { flex: none; display: flex; flex-direction: column; gap: var(--v6x-espace); padding-bottom: var(--v6x-espace); }
.v6x-tuile { position: relative; flex: none; display: block; width: 100%; aspect-ratio: var(--r, .8); overflow: hidden; border-radius: var(--v6x-rayon); background: var(--ivory); box-shadow: 0 0 0 1px rgba(185, 138, 107, .14); }
.v6x-tuile img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
/* Image détourée : montrée entière, posée sur un fond crème */
.v6x-tuile.is-detoure { background: radial-gradient(closest-side, var(--white), var(--ivory) 130%); }
.v6x-tuile.is-detoure img { inset: 8%; width: 84%; height: 84%; object-fit: contain; }

/* Mur horizontal : des rangées qui glissent vers la gauche et vers la droite */
.v6x[data-mur='rangees'] .v6x-pente { inset: -4% -2%; flex-direction: column; }
.v6x[data-mur='rangees'] .v6x-piste { flex-direction: row; width: max-content; height: 100%; transform: translate3d(var(--y0, 0%), 0, 0); }
.v6x[data-mur='rangees'] .v6x-serie { flex-direction: row; height: 100%; padding: 0 var(--v6x-espace) 0 0; }
.v6x[data-mur='rangees'] .v6x-tuile { width: auto; height: 100%; }

/* Défilement continu : chaque piste contient plusieurs fois la même série ; --pas = exactement une série → boucle sans couture. */
.v6x.is-vivant .v6x-piste { animation: v6x-file var(--dur, 80s) linear infinite; will-change: transform; }
.v6x.is-vivant[data-mur='rangees'] .v6x-piste { animation-name: v6x-file-x; }
.v6x.is-vivant .v6x-rail.is-inverse .v6x-piste { animation-direction: reverse; }
@keyframes v6x-file { from { transform: translate3d(0, var(--y0, 0%), 0); } to { transform: translate3d(0, calc(var(--y0, 0%) - var(--pas, 50%)), 0); } }
@keyframes v6x-file-x { from { transform: translate3d(var(--y0, 0%), 0, 0); } to { transform: translate3d(calc(var(--y0, 0%) - var(--pas, 50%)), 0, 0); } }

/* Voile crème : plus dense en haut (barre du site), léger partout ailleurs (réglable par page) */
.v6x-voile {
  position: absolute; inset: 0 0 -3.5rem 0; z-index: 1; pointer-events: none;
  background:
    linear-gradient(rgba(var(--v6x-creme), .92), rgba(var(--v6x-creme), .66) calc(3.2rem + env(safe-area-inset-top)), rgba(var(--v6x-creme), 0) calc(6.6rem + env(safe-area-inset-top))),
    linear-gradient(rgba(var(--v6x-creme), var(--v6x-voile)), rgba(var(--v6x-creme), var(--v6x-voile)));
}

/* Le cadre : la zone de la scène où la vedette doit tenir (sous la barre du site, au-dessus des points). Il n'a pas de
   z-index à lui : le halo passe SOUS le fondu crème du bloc texte, la vedette passe DEVANT (elle n'est jamais voilée). */
.v6x-cadre {
  position: absolute; pointer-events: none;
  top: calc(var(--bar-h) + env(safe-area-inset-top) + var(--v6x-haut)); bottom: var(--v6x-bas);
  left: var(--v6x-cotes); right: var(--v6x-cotes);
}

/* Halo clair : une ellipse qui épouse la boîte de la vedette (hero.js règle --rot, --hx, --hy) et la détache du mur */
.v6x-halo {
  position: absolute; z-index: 2; left: 50%; top: 50%; width: var(--v6x-L); height: var(--v6x-L); margin: calc(var(--v6x-L) / -2) 0 0 calc(var(--v6x-L) / -2);
  opacity: var(--v6x-halo);
  transform: rotate(var(--rot, 0deg)) scale(var(--hx, 1.3), var(--hy, 1.3));
  transition: transform 1.1s var(--ease-out);
  background: radial-gradient(closest-side,
    rgba(253, 250, 245, .99) 0, rgba(253, 250, 245, .97) var(--v6x-halo-net),
    rgba(252, 248, 242, .74) calc(var(--v6x-halo-net) + (100% - var(--v6x-halo-net)) * .36),
    rgba(var(--v6x-creme), .28) calc(var(--v6x-halo-net) + (100% - var(--v6x-halo-net)) * .7),
    rgba(var(--v6x-creme), 0) 100%);
}
.v6x-teinte { position: absolute; inset: 7%; opacity: 0; transition: opacity 1.2s ease; background: radial-gradient(closest-side, currentColor, transparent); }
.v6x-teinte.is-actif { opacity: .46; }

/* Les vedettes */
.v6x-vedettes { position: absolute; z-index: 5; inset: 0; }
.v6x-vedette {
  --h: var(--v6x-L); --w: calc(var(--h) * var(--ar, 1)); --o: calc(var(--h) * .05); --rot: 0deg;   /* valeurs de secours */
  position: absolute; inset: 0; margin: 0; display: grid; place-items: center; place-content: center;
  transition: transform .95s var(--ease-out), opacity .45s ease;
}
.v6x-vedette[data-pos='0'] { transition: transform 1.05s cubic-bezier(.2, 1.12, .32, 1), opacity .35s ease; }
.v6x-vedette[data-pos='1'] { transform: translate3d(120%, -5%, 0) rotate(48deg) scale(.8); opacity: 0; }
.v6x-vedette[data-pos='-1'] { transform: translate3d(-120%, 9%, 0) rotate(-48deg) scale(.8); opacity: 0; }
.v6x-vedette.is-fixe, .v6x-vedette.is-glisse { transition: none; }

.v6x-sol, .v6x-flotte { grid-area: 1 / 1; display: grid; place-items: center; }
.v6x-flotte { animation: v6x-flotte 6.4s ease-in-out infinite; }
.v6x-sol { animation: v6x-sol 6.4s ease-in-out infinite; }
.v6x-vedette:not([data-pos='0']) .v6x-flotte, .v6x-vedette:not([data-pos='0']) .v6x-sol,
.v6x.is-pause .v6x-flotte, .v6x.is-pause .v6x-sol, .v6x.is-pause .v6x-piste, .v6x.is-pause .v6x-commander::after { animation-play-state: paused; }
.v6x-photo { display: block; width: var(--w); height: var(--h); max-width: none; object-fit: contain; transform: rotate(var(--rot)); -webkit-user-drag: none; }
/* Ombre portée : une ellipse douce de la taille de la boîte, tournée comme elle et décalée vers le bas. Elle reste
   plausible que le gâteau soit allongé, rond ou haut. */
.v6x-ombre {
  display: block; width: calc(var(--w) + var(--o) * 3.4); height: calc(var(--h) + var(--o) * 2);
  transform: translate3d(calc(var(--o) * .35), calc(var(--o) * 1.5), 0) rotate(var(--rot));
  background: radial-gradient(closest-side, rgba(70, 40, 22, .62) 0, rgba(70, 40, 22, .54) 50%, rgba(70, 40, 22, .36) 68%, rgba(70, 40, 22, .16) 84%, rgba(70, 40, 22, .04) 95%, rgba(70, 40, 22, 0) 100%);
}
@keyframes v6x-flotte {
  0%, 100% { transform: translate3d(0, calc(var(--v6x-flottement) * -8px), 0) rotate(calc(var(--v6x-flottement) * -1.6deg)); }
  50% { transform: translate3d(0, calc(var(--v6x-flottement) * 7px), 0) rotate(calc(var(--v6x-flottement) * 1.4deg)); }
}
@keyframes v6x-sol {
  0%, 100% { transform: scale(1.05); opacity: .7; }
  50% { transform: scale(.96); opacity: 1; }
}

/* Repère : de très petits points sous la vedette (décoratifs ; on change au doigt, au clavier ou en attendant) */
.v6x-points { position: absolute; z-index: 6; left: 50%; bottom: .28rem; display: flex; align-items: center; gap: .42rem; margin: 0; transform: translateX(-50%); pointer-events: none; }
.v6x-points i { display: block; width: .3rem; height: .3rem; border-radius: 50%; background: var(--rose-deep); opacity: .28; transform: scale(.82); transition: opacity .5s ease, transform .5s var(--ease-out); }
.v6x-points i.is-actif { opacity: 1; transform: scale(1.18); }
.v6x-points:empty { display: none; }

/* ── Texte, sur fond crème ── */
.v6x-texte { position: relative; z-index: 4; grid-row: 2; display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: .55rem; padding: 0 var(--pad) calc(1rem + env(safe-area-inset-bottom)); text-align: center; }
.v6x-texte::before {
  content: ''; position: absolute; z-index: -1; inset: -4.6rem 0 0 0; pointer-events: none;
  background: linear-gradient(rgba(var(--v6x-creme), 0) 0, rgba(var(--v6x-creme), .4) 1.4rem, rgba(var(--v6x-creme), .84) 2.9rem, rgba(var(--v6x-creme), .98) 4.2rem, var(--ivory-light) 5rem);
}
.v6x-repere { display: flex; align-items: center; justify-content: center; gap: .6rem; margin-top: .15rem; font: 600 .68rem/1.3 var(--font-sans); letter-spacing: .18em; text-transform: uppercase; color: var(--rose-deep); white-space: nowrap; }
.v6x-repere i { width: .3rem; height: .3rem; border-radius: 50%; background: var(--caramel); flex: none; }
.v6x-titre { font-size: clamp(1.66rem, 8.7vw, 2.7rem); line-height: 1.05; letter-spacing: -.025em; font-weight: 380; color: var(--choc-deep); text-wrap: nowrap; }
.v6x-titre > span { display: block; }
.v6x-titre em {
  font-style: italic; font-weight: 400; padding-inline-end: .06em;
  background: linear-gradient(100deg, #8A5D43 0%, #C08F68 42%, #A46F4E 70%, #8A5D43 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.v6x-phrase { max-width: 21.5rem; font-size: .98rem; line-height: 1.42; color: var(--choc-soft); }
.v6x-actions { display: grid; justify-items: center; width: 100%; margin-top: .3rem; }
.v6x-commander { width: 100%; max-width: 22rem; min-height: 3.6rem; font-size: 1.1rem; font-weight: 600; letter-spacing: .02em; }
.v6x-commander svg { transition: transform .3s var(--ease-out); }
.v6x-commander::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(105deg, transparent 38%, rgba(243, 222, 196, .34) 50%, transparent 62%); transform: translateX(-130%); animation: v6x-reflet 5s var(--ease-out) 2.6s infinite; }
@keyframes v6x-reflet { 0%, 60% { transform: translateX(-130%); } 100% { transform: translateX(130%); } }
.v6x-comment { display: none; align-items: center; min-height: 2.75rem; padding-inline: 1rem; font: 500 .92rem/1.2 var(--font-sans); color: var(--rose-deep); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: .28em; }
@media (hover: hover) {
  .v6x-commander:hover svg { transform: translateX(4px); }
  .v6x-comment:hover { color: var(--choc); }
}

/* ── Entrée en scène : lancée quand <html> reçoit « is-ready » ; sans JavaScript, tout apparaît de toute façon ── */
@keyframes v6x-in { from { opacity: .01; transform: translate3d(0, 20px, 0); } }
@keyframes v6x-in-go { from { opacity: .01; transform: translate3d(0, 20px, 0); } }
@keyframes v6x-fondu { from { opacity: 0; } }
@keyframes v6x-fondu-go { from { opacity: .01; } }
@keyframes v6x-arrive { from { opacity: 0; transform: translate3d(75%, -9%, 0) rotate(40deg) scale(.78); } 30% { opacity: 1; } }
@keyframes v6x-arrive-go { from { opacity: .01; transform: translate3d(75%, -9%, 0) rotate(40deg) scale(.78); } 30% { opacity: 1; } }
.v6x [data-in] { animation: v6x-in .8s var(--ease-out) 2.6s both; }
.v6x [data-in='halo'], .v6x [data-in='points'] { animation-name: v6x-fondu; }
.v6x [data-in='vedette'] { animation-name: v6x-arrive; }
html.is-ready .v6x [data-in] { animation: v6x-in-go .9s var(--ease-out) calc(85ms * var(--d, 0)) both; }
html.is-ready .v6x [data-in='halo'] { animation: v6x-fondu-go 1.3s ease .1s both; }
html.is-ready .v6x [data-in='points'] { animation: v6x-fondu-go 1s ease .9s both; }
html.is-ready .v6x [data-in='vedette'] { animation: v6x-arrive-go 1.35s cubic-bezier(.2, 1.1, .3, 1) .2s both; }

/* ── Petits téléphones ── */
@media (max-width: 359px) {
  .v6x-repere { font-size: .6rem; letter-spacing: .14em; gap: .45rem; }
  .v6x-phrase { font-size: .92rem; }
}
@media (max-height: 600px) and (max-width: 899px) {
  .v6x-texte { gap: .4rem; padding-bottom: calc(.8rem + env(safe-area-inset-bottom)); }
  .v6x-commander { min-height: 3.3rem; }
}
/* Grands téléphones : il reste la place pour le lien secondaire */
@media (min-height: 720px) and (max-width: 899px) { .v6x-comment { display: inline-flex; margin-bottom: -.6rem; } }

/* ── Ordinateur : texte à gauche, scène à droite sur toute la hauteur ── */
@media (min-width: 900px) {
  .v6x { --v6x-L: min(34vw, 56vh, 34rem); --v6x-espace: .7rem; --v6x-rayon: 1.2rem; --v6x-haut: 1.5rem; --v6x-bas: 4rem; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); grid-template-rows: minmax(0, 1fr); align-items: center; }
  .v6x-scene { grid-column: 2; grid-row: 1; align-self: stretch; min-height: 100svh; }
  .v6x-mur, .v6x-voile { inset: 0; }
  .v6x-voile {
    background:
      linear-gradient(90deg, var(--ivory-light), rgba(var(--v6x-creme), 0) 22%),
      linear-gradient(0deg, var(--ivory-light), rgba(var(--v6x-creme), 0) 20%),
      linear-gradient(rgba(var(--v6x-creme), .92), rgba(var(--v6x-creme), 0) 9rem),
      linear-gradient(rgba(var(--v6x-creme), var(--v6x-voile)), rgba(var(--v6x-creme), var(--v6x-voile)));
  }
  .v6x-cadre { left: max(var(--v6x-cotes), 8%); right: max(var(--v6x-cotes), 4%); }
  .v6x-points { bottom: 2.2rem; gap: .55rem; }
  .v6x-points i { width: .4rem; height: .4rem; }
  .v6x-texte { grid-column: 1; grid-row: 1; justify-items: start; text-align: start; gap: 1.05rem; padding: calc(var(--bar-h) + 2rem) clamp(1rem, 3vw, 3rem) 3rem clamp(2.5rem, 8vw, 8rem); }
  .v6x-texte::before { display: none; }
  .v6x-repere { font-size: .76rem; }
  .v6x-titre { font-size: clamp(2.5rem, 4vw, 4rem); }
  .v6x-phrase { font-size: 1.12rem; max-width: 27rem; }
  .v6x-actions { grid-template-columns: auto auto; justify-content: start; align-items: center; gap: .6rem; margin-top: .4rem; }
  .v6x-commander { width: auto; padding-inline: 2.6rem; }
  .v6x-comment { display: inline-flex; }
}

/* ── Mouvement réduit : mur fixe, ni flottement ni défilement automatique, simple fondu entre vedettes ── */
@media (prefers-reduced-motion: reduce) {
  .v6x [data-in], html.is-ready .v6x [data-in] { animation: none; }
  .v6x .v6x-piste { animation: none !important; }
  .v6x-flotte, .v6x-sol, .v6x-commander::after { animation: none; }
  .v6x-mur, .v6x-halo { transition: none; }
  .v6x-vedette, .v6x-vedette[data-pos='0'] { transition: opacity .4s ease; }
  .v6x-vedette[data-pos='1'], .v6x-vedette[data-pos='-1'] { transform: none; }
}
