/* Ouverture 3D par crans. Ne pas modifier pour changer un texte ou une vidéo : tout cela est dans contenu-3d.js. */

/* !important : la feuille du site impose une hauteur d'un écran et une marge à chaque section. */
main > .d3-scene, .d3-scene {
  position: relative; height: calc(var(--crans, 5) * 100vh) !important; min-height: 0 !important; max-height: none !important;
  padding: 0 !important; margin: 0 !important; background: #0d0f13; color: #f4f2ee;
}
.d3-vue {
  position: sticky; top: 0; height: 100vh; height: 100svh; display: flex; flex-direction: column;
  padding: 78px clamp(16px, 4vw, 56px) 18px; overflow: hidden; isolation: isolate;
}

/* Le décor : un halo de studio, une lueur rouge au sol qui monte quand l'objet s'ouvre, une grille fine qui s'efface vers les bords. */
.d3-fond {
  position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(58% 34% at 50% 88%, rgba(240, 58, 46, 0.10), transparent 72%),
    radial-gradient(72% 62% at 50% 46%, #2c313c 0%, #181b21 56%, #0d0f13 100%);
}
/* La lueur rouge qui monte : un calque à part dont seule l'opacité change (rien à repeindre, fluide sur téléphone). */
.d3-fond::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(58% 34% at 50% 88%, rgba(240, 58, 46, 0.24), transparent 72%);
  opacity: var(--ouverture, 0); will-change: opacity;
}
.d3-fond::before {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 56px 56px; background-position: center;
  -webkit-mask-image: radial-gradient(62% 58% at 50% 50%, #000 0%, transparent 80%);
  mask-image: radial-gradient(62% 58% at 50% 50%, #000 0%, transparent 80%);
}

/* Le titre, au-dessus de l'objet */
.d3-tete { position: relative; z-index: 3; text-align: center; }
.d3-tete .d3-titre { margin: 0; color: #f4f2ee; font-weight: 600; letter-spacing: -0.03em; line-height: 1.05; font-size: clamp(1.7rem, 3.7vw, 3.2rem); text-wrap: balance; }
.d3-mot { transition: color 0.25s ease; }
.d3-mot.eteint { color: rgba(244, 242, 238, 0.26); }
.d3-sous { margin: 10px auto 0; max-width: 34em; color: #a9aeb6; font-size: clamp(0.98rem, 1.4vw, 1.15rem); transition: opacity 0.3s ease; }
.d3-ouvert .d3-sous { opacity: 0; }

/* L'objet */
.d3-zone { position: relative; flex: 1 1 auto; min-height: 0; z-index: 1; }
.d3-plateau { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.d3-plateau::before { content: ""; position: absolute; left: 20%; right: 20%; bottom: 7%; height: 9%; background: radial-gradient(closest-side, rgba(0, 0, 0, 0.6), transparent); }
.d3-plateau canvas { position: relative; display: block; width: 100%; height: 100%; }
.d3-calque { position: absolute; inset: 0; }
.d3-charge { position: absolute; left: 0; right: 0; bottom: 4%; text-align: center; color: #a9aeb6; font-size: 0.9rem; font-variant-numeric: tabular-nums; transition: opacity 0.4s ease; }
.d3-charge.fini { opacity: 0; }

@keyframes d3-boum { from { transform: scale(0.84); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes d3-monte { from { transform: translate3d(0, 10px, 0); opacity: 0; } to { transform: none; opacity: 1; } }

/* Notes accrochées à une pièce (Mac mini) */
.d3-note { position: absolute; left: var(--x); top: var(--y); opacity: 0; transition: opacity 0.25s ease; }
.d3-note.vu { opacity: 0.42; }
.d3-note.actif { opacity: 1; }
.d3-point { position: absolute; left: -6px; top: -6px; width: 12px; height: 12px; border-radius: 50%; background: #f03a2e; box-shadow: 0 0 0 5px rgba(240, 58, 46, 0.25); font-size: 0; color: #111; font-style: normal; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.d3-fil { position: absolute; top: 0; height: 1px; width: var(--fil, 70px); background: rgba(244, 242, 238, 0.65); }
.d3-note--droite .d3-fil { left: 8px; }
.d3-note--gauche .d3-fil { right: 8px; }
.d3-etiquette { position: absolute; top: -0.85em; width: min(270px, 24vw); }
.d3-note--droite .d3-etiquette { left: calc(var(--fil, 70px) + 20px); text-align: left; transform-origin: left top; }
.d3-note--gauche .d3-etiquette { right: calc(var(--fil, 70px) + 20px); text-align: right; transform-origin: right top; }
.d3-etiquette strong { display: block; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; font-size: clamp(1.25rem, 2vw, 1.7rem); color: #fff; }
.d3-etiquette p { margin: 0.4em 0 0; font-size: clamp(0.88rem, 1.05vw, 1rem); line-height: 1.4; color: #c6cad0; }
.d3-note.actif .d3-etiquette, .d3-note.actif .d3-point { animation: d3-boum 0.38s cubic-bezier(0.2, 1.5, 0.4, 1); }

/* Écrans (clap) : la vidéo ou l'image de chaque écran est posée ici, par-dessus l'animation */
.d3-ecran { position: absolute; overflow: hidden; border-radius: 0.4%; opacity: 0; transition: opacity 0.4s ease; }
.d3-calque.pret .d3-ecran { opacity: 1; }
.d3-ecran video, .d3-ecran img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* Le voile sombre des écrans non choisis et le cadre rouge de l'écran choisi : seule leur opacité change, pour passer en fondu d'un écran à l'autre sans à-coup. */
.d3-ecran::after { content: ""; position: absolute; inset: 0; background: rgba(13, 15, 19, 0.66); opacity: 0; transition: opacity 0.4s ease; pointer-events: none; }
.d3-calque.choix .d3-ecran:not(.actif)::after { opacity: 1; }
.d3-halo { position: absolute; border-radius: 0.4%; pointer-events: none; box-shadow: 0 0 0 3px #f03a2e, 0 0 44px rgba(240, 58, 46, 0.45); opacity: 0; transition: opacity 0.4s ease; will-change: opacity; }
.d3-halo.actif { opacity: 1; }
.d3-plaque { position: absolute; left: 8px; bottom: 8px; z-index: 2; max-width: calc(100% - 16px); padding: 5px 10px; border-radius: 6px; background: rgba(13, 15, 19, 0.82); color: #fff; font-weight: 600; font-size: clamp(0.7rem, 1.15vw, 1rem); line-height: 1.15; opacity: 0; transition: opacity 0.25s ease; transform-origin: left bottom; }
.d3-ecran.vu .d3-plaque { opacity: 1; }
.d3-ecran.actif .d3-plaque { background: #f03a2e; color: #111; animation: d3-boum 0.42s cubic-bezier(0.16, 1, 0.3, 1); }

/* Sous l'objet : l'explication du cran en cours (téléphone, et écrans du clap) et le bouton */
.d3-pied { position: relative; z-index: 3; text-align: center; min-height: 5.2em; }
.d3-legende { margin: 0 auto; max-width: 36em; min-height: 2.9em; font-size: clamp(1rem, 1.45vw, 1.2rem); line-height: 1.4; color: #c6cad0; }
.d3-legende strong { color: #fff; font-weight: 600; }
.d3-legende b { color: #f03a2e; font-weight: 600; font-variant-numeric: tabular-nums; margin-right: 0.5em; }
/* Le texte change en deux temps : l'ancien s'efface (.part), puis le nouveau monte doucement (.boum). */
.d3-legende.part { opacity: 0; transition: opacity 0.14s ease-in; }
.d3-legende.boum { animation: d3-monte 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }
.d3-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 22px; margin-top: 10px; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0s linear 0.3s; }
.d3-fin .d3-actions { opacity: 1; visibility: visible; transition-delay: 0s; }
.d3-bouton { display: inline-flex; align-items: center; min-height: 46px; padding: 0 22px; border-radius: 8px; background: #f03a2e; color: #111; font-weight: 600; text-decoration: none; }
.d3-bouton:hover { background: #ff5146; }
.d3-lien { display: inline-flex; align-items: center; min-height: 44px; color: #f4f2ee; text-underline-offset: 4px; }

/* L'indice « Défiler » : à la place du bouton final, qui le remplace au dernier cran. Il fait aussi avancer d'un cran au clic. */
.d3-indice {
  position: absolute; left: 0; right: 0; bottom: 0; margin-inline: auto; width: max-content; min-width: 88px; min-height: 46px;
  display: flex; align-items: center; justify-content: center; padding: 0 12px; border: 0; border-radius: 8px; background: none;
  color: #c6cad0; font: inherit; font-size: 0.92rem; cursor: pointer; transition: color 0.2s ease, opacity 0.3s ease, visibility 0s linear 0s;
}
.d3-indice__in { display: flex; flex-direction: column; align-items: center; gap: 1px; animation: d3-apparait 0.6s ease 1s both; }
.d3-indice svg { width: 20px; height: 20px; animation: d3-flotte 1.8s ease-in-out infinite; }
.d3-indice:hover { color: #f4f2ee; }
.d3-indice:focus-visible { outline: 2px solid #f03a2e; outline-offset: 2px; }
.d3-fin .d3-indice { opacity: 0; visibility: hidden; transition: opacity 0.2s ease, visibility 0s linear 0.2s; }
@keyframes d3-apparait { from { opacity: 0; } to { opacity: 1; } }
@keyframes d3-flotte { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(4px); } }

/* Les crans, à droite */
.d3-crans { position: absolute; right: clamp(4px, 1.4vw, 20px); top: 50%; transform: translateY(-50%); z-index: 4; display: flex; flex-direction: column; gap: 0; margin: 0; padding: 0; list-style: none; }
.d3-crans button { display: flex; align-items: center; justify-content: center; width: 44px; height: 34px; padding: 0; border: 0; background: none; cursor: pointer; }
.d3-crans button::before { content: ""; width: 8px; height: 8px; border-radius: 4px; background: rgba(244, 242, 238, 0.35); transition: height 0.25s ease, background 0.25s ease; }
.d3-crans button[aria-current="true"]::before { height: 22px; background: #f03a2e; }
.d3-crans button:focus-visible { outline: 2px solid #f03a2e; outline-offset: -4px; border-radius: 8px; }

.d3-scene[data-type="notes"] .d3-legende { display: none; }
/* Un écran dans une scène à notes (par exemple la vidéo finie, au dernier cran) : il n'apparaît qu'à son cran, avec sa légende. */
.d3-scene[data-type="notes"] .d3-calque.pret .d3-ecran:not(.vu) { opacity: 0; }
.d3-scene[data-type="notes"] .d3-ecran, .d3-scene[data-type="notes"] .d3-halo { border-radius: 2.2%; }
.d3-scene[data-type="notes"].d3-sur-ecran .d3-legende { display: block; }

@media (max-width: 899px) {
  .d3-vue { padding: 70px 14px 14px; }
  .d3-scene[data-type="notes"] .d3-legende { display: block; }
  .d3-etiquette, .d3-fil { display: none; }
  .d3-point { left: -12px; top: -12px; width: 24px; height: 24px; font-size: 13px; box-shadow: 0 0 0 4px rgba(240, 58, 46, 0.25); }
  .d3-note.vu { opacity: 0.6; }
  .d3-plaque { left: 4px; bottom: 4px; padding: 3px 6px; font-size: 0.68rem; }
  .d3-plaque span { display: none; }
  .d3-crans { right: 0; }
  .d3-pied { min-height: 7.4em; }
}
@media (prefers-reduced-motion: reduce) {
  .d3-note.actif .d3-etiquette, .d3-note.actif .d3-point, .d3-ecran.actif .d3-plaque, .d3-legende.boum { animation: none; }
  .d3-halo, .d3-ecran::after, .d3-legende.part { transition: none; }
  .d3-indice__in, .d3-indice svg { animation: none; }
}
