/* =====================================================================
   Rubi Studio — la 3D du site (zones des scènes, carrousel, exemples)
   La classe has-3d est posée dans header.php AVANT le premier affichage,
   si le navigateur sait afficher la 3D et que le visiteur n'a pas demandé
   à réduire les animations. Sans elle, chaque page garde sa version
   classique : toutes les zones 3D ci-dessous en dépendent.
   La 3D elle-même est dessinée par js/site-3d.min.js (source : 3d/).
   ===================================================================== */

/* Le canvas unique, au-dessus de la page, qui ne capte jamais la souris. */
.scenes-3d {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 30;
  pointer-events: none;
}

/* ─── Haut de page : le R et les appareils ─────────────────────────── */
.hero-3d { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.hero .hero-inner { position: relative; z-index: 1; }
.has-3d .hero-aside { display: none; }
.has-3d .hero {
  background:
    radial-gradient(ellipse 70% 60% at 72% 45%, rgba(124, 58, 237, 0.22), transparent 70%),
    var(--dark);
}
/* Curseur « main » sur un appareil cliquable (quand le point violet n'est pas actif). */
html.is-survol-3d body:not(.has-cursor) { cursor: pointer; }

/* Bulle « voir le projet » au survol d'un appareil */
.bulle-3d {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(13, 11, 20, 0.88);
  border: 1px solid rgba(157, 92, 255, 0.55);
  color: var(--cream);
  font: 500 13px/1.3 var(--font-body);
  white-space: nowrap;
  transform: translate(18px, 18px);
  backdrop-filter: blur(6px);
}
.bulle-3d[hidden] { display: none; }
.bulle-3d b { font-family: var(--font-display); font-weight: 700; font-size: 16px; }
.bulle-3d span { color: var(--accent-soft); }

/* ─── Services : la pastille devient la zone où se pose l'appareil ──── */
.has-3d .service-card__visual.s3d {
  position: relative;
  top: auto;
  right: auto;
  width: auto;
  height: 250px;
  margin: -14px -10px 22px;
  border-radius: 16px;
  background: radial-gradient(circle at 50% 55%, rgba(139, 92, 246, 0.22), transparent 68%);
}
.has-3d .s3d__num {
  position: absolute;
  top: 10px;
  left: 14px;
  font: 600 13px var(--font-body);
  color: var(--accent-soft);
}

/* ─── Projets : carrousel 3D à la place de la grille ───────────────── */
.p3d { display: none; }
/* Accueil seulement : la grille de la sélection laisse place au carrousel
   (la page Projets garde sa grille, qui a la même classe). */
.has-3d .page-index .projets__grid { display: none; }
/* Scène en pleine largeur, légende dessous : les écrans voisins restent entiers. */
.has-3d .p3d {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  height: min(84vh, 820px);
  margin-top: 0.5rem;
}
.p3d__scene {
  flex: 1;
  min-height: 0;
  width: 100%;
  border-radius: 24px;
  cursor: pointer;
  background: radial-gradient(ellipse 60% 55% at 50% 50%, rgba(124, 58, 237, 0.2), transparent 72%);
}
.p3d__legende {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: 'idx idx' 'titre lien' 'type points';
  align-items: center;
  column-gap: 2rem;
}
.p3d__idx    { grid-area: idx; font: 600 14px var(--font-body); color: var(--accent-soft); }
.p3d__titre  {
  grid-area: titre;
  margin: 0.4rem 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.8rem, 3vw, 2.8rem);
  letter-spacing: -0.035em;
  line-height: 1;
  color: var(--cream);
}
.p3d__type   { grid-area: type; margin: 0; font-size: 1rem; color: var(--muted); }
.p3d__lien   { grid-area: lien; justify-self: end; }
.p3d__points { grid-area: points; justify-self: end; display: flex; gap: 10px; }
/* Barre fine dessinée au milieu d'un bouton de 24 px de haut : assez
   grand pour le doigt, discret à l'œil. */
.p3d__points button {
  position: relative;
  width: 34px;
  height: 24px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transition: width 0.3s;
}
.p3d__points button::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 9px;
  height: 6px;
  border-radius: 3px;
  background: rgba(236, 233, 245, 0.2);
  transition: background 0.3s;
}
.p3d__points button.is-on { width: 54px; }
.p3d__points button.is-on::before { background: var(--accent); }
.p3d__points button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
/* Au doigt : 44 px de haut, la barre reste au milieu. */
@media (pointer: coarse) {
  .p3d__points button { height: 44px; }
  .p3d__points button::before { top: 19px; }
}
.p3d__legende.is-entre .p3d__titre,
.p3d__legende.is-entre .p3d__type { animation: p3dEntre 0.6s var(--ease-out) both; }
.p3d__legende.is-entre .p3d__type { animation-delay: 0.06s; }
@keyframes p3dEntre {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ─── Méthode : la bande où se dessine le trait ────────────────────── */
.m3d { display: none; }
.has-3d .m3d { display: block; height: 130px; margin-top: clamp(2rem, 4vw, 3rem); }
.has-3d .process__grid { margin-top: 0; }

/* ─── Fin de page : le R à droite de l'appel à l'action ──────────── */
.c3d { display: none; }
.has-3d .c3d { display: block; }
.has-3d .cta-band { position: relative; overflow: hidden; }
.has-3d .cta-band .wrap { position: relative; z-index: 1; }
.has-3d .c3d { position: absolute; top: 0; bottom: 0; right: 2vw; width: 44%; }

/* ─── Projets → Profil : le profil arrive comme une nouvelle feuille,
       plus claire, aux coins arrondis, qui glisse par-dessus la fin des
       projets (avec ou sans 3D ; le mouvement est dans scroll.js). ────── */
.page-index .projets { padding-bottom: clamp(5rem, 9vw, 8rem); }
.page-index .profil {
  position: relative;
  z-index: 2;
  background-color: #201930;
  border-radius: clamp(28px, 4vw, 56px) clamp(28px, 4vw, 56px) 0 0;
  border-top: 1px solid rgba(157, 92, 255, 0.3);
  box-shadow: 0 -30px 80px rgba(0, 0, 0, 0.55);
}

/* ─── Téléphone : version allégée ──────────────────────────────────── */
@media (max-width: 900px) {
  /* Le texte est en haut : la scène prend l'espace libre en bas. */
  /* Hauteur fixe, réservée sous le texte (et non 42 % du haut de page) :
     sur un petit écran (320 × 640), la scène recouvrait « Devis gratuit… ». */
  .hero-3d { inset: auto 0 0 0; height: clamp(230px, 40svh, 400px); }
  .has-3d .page-index .hero { padding-bottom: calc(clamp(230px, 40svh, 400px) + 16px); }
  .has-3d .hero {
    background:
      radial-gradient(ellipse 90% 45% at 50% 75%, rgba(124, 58, 237, 0.25), transparent 70%),
      var(--dark);
  }
  .has-3d .p3d { height: min(80vh, 700px); }
  .p3d__legende {
    grid-template-columns: 1fr;
    grid-template-areas: 'idx' 'titre' 'type' 'lien' 'points';
    row-gap: 0.5rem;
  }
  .p3d__lien, .p3d__points { justify-self: start; }
  .has-3d .m3d { display: none; }
  .has-3d .c3d { position: relative; right: auto; width: 100%; height: 260px; margin-top: 1rem; }
}

/* ─── Haut des pages intérieures : appareils à droite du titre ─────── */
.vitrine-3d { display: none; }
.has-3d .page-hero--3d { position: relative; overflow: hidden; }
@media (min-width: 901px) {
  .has-3d .page-hero--3d {
    display: flex;
    align-items: center;
    min-height: min(86vh, 760px);
  }
  .has-3d .page-hero--3d > .wrap { width: 100%; }
  /* Le texte garde la moitié gauche, les appareils la moitié droite. */
  .has-3d .page-hero--3d .section-title,
  .has-3d .page-hero--3d .section-intro { max-width: min(calc(50vw - 72px), 680px); }
  .has-3d .vitrine-3d {
    display: block;
    position: absolute;
    top: var(--nav-h);
    right: 0;
    bottom: 0;
    width: 50%;
  }
}
@media (max-width: 900px) {
  .has-3d .vitrine-3d { display: block; position: relative; height: 320px; margin-top: 0.5rem; }
}

/* ─── Contact : le R à droite du grand titre (ordinateur) ──────────── */
.has-3d .c3d--contact {
  top: 130px;
  bottom: auto;
  right: 1.5vw;
  width: 19vw;
  height: clamp(220px, 21vw, 340px);
}
@media (max-width: 1100px) {
  .has-3d .c3d--contact { display: none; }
}

/* ─── « Un exemple » dans les pages d'offre ────────────────────────── */
.exemple {
  position: relative;
  padding: clamp(4rem, 8vw, 7rem) 0;
  background-color: var(--bg-now, var(--dark));
  border-top: 1px solid rgba(236, 233, 245, 0.08);
}
.exemple__grille {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: center;
}
.exemple .section-title { margin: 0.4rem 0 0; }
.exemple__type { margin: 0.8rem 0 1.2rem; font-size: 1rem; color: var(--muted); }
.exemple__desc { max-width: 52ch; font-size: 1.05rem; line-height: 1.65; color: rgba(236, 233, 245, 0.85); }
.exemple__cas { display: grid; gap: 0.9rem; margin: 1.6rem 0 2rem; }
.exemple__cas > div {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid rgba(236, 233, 245, 0.1);
}
.exemple__cas dt { font-size: 0.9rem; font-weight: 600; color: var(--accent-soft); }
.exemple__cas dd { font-size: 0.95rem; line-height: 1.55; color: rgba(236, 233, 245, 0.8); }
.exemple__visuel {
  margin: 0;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(236, 233, 245, 0.1);
  background: var(--choc-2);
}
.exemple__visuel img { display: block; width: 100%; height: auto; }
@media (max-width: 860px) {
  .exemple__grille { grid-template-columns: 1fr; }
  .exemple__cas > div { grid-template-columns: 1fr; gap: 0.25rem; }
}

/* ─── Ajustements de mise en page avec la 3D (ordinateur) ──────────── */
@media (min-width: 901px) {
  /* Titre plus compact à côté des appareils (deux ou trois lignes). */
  .has-3d .page-hero--3d .section-title { font-size: clamp(2.6rem, 4.4vw, 4.6rem); }
  /* Bandes de fin : le texte garde la gauche, le R la droite (sans se chevaucher). */
  .has-3d .cta-band .section-title,
  .has-3d .cta-band .section-intro { max-width: 52%; }
}
.exemple .section-title { font-size: clamp(2.2rem, 3.6vw, 3.4rem); }
.exemple__visuel img { max-height: 72vh; object-fit: cover; }
