/*
 * Vitrine — Direction A "Musée privé".
 * Charge uniquement sur auth/ma-vitrine.php (vue propriétaire).
 *
 * Chantiers livrés :
 *   1. Cascade d'entrée (les slots se posent un par un)
 *   2. Spotlight souris (halo doré qui suit le curseur)
 *   3. Tilt 3D + reflet spéculaire sur figurines
 *   4. Slots vides premium (bordure conic + halo pulsant)
 *   5. Particules de poussière dorée (canvas)
 *   6. Toolbar avec halo glissant
 */

@property --vit-cin-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

/* Variables locales (les valeurs par défaut ne déclenchent aucune anim) */
.vit-premium__stage {
  --vit-cin-rx: 0deg;
  --vit-cin-ry: 0deg;
  --vit-cin-mx: 50%;
  --vit-cin-my: 50%;
}

/* ============================================================
 * Stacking : on impose un ordre clair pour empiler particules /
 * glass / figurines / spotlight sans surprise.
 * ============================================================ */
.vit-premium__stage .vitrine { z-index: 2; }
.vit-cin-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

/* ============================================================
 * Chantier 1 — Cascade d'entrée
 * Les slots se posent un par un (fade + lift + blur).
 * Le transform combine cascade + tilt 3D pour ne pas se marcher dessus.
 * ============================================================ */
.vit-premium__stage .slot {
  opacity: 0;
  filter: blur(8px);
  transform:
    perspective(900px)
    translateY(14px)
    rotateX(var(--vit-cin-rx))
    rotateY(var(--vit-cin-ry));
  transition:
    opacity 620ms cubic-bezier(0.22, 1, 0.36, 1) calc(var(--vit-cin-i, 0) * 80ms),
    transform 620ms cubic-bezier(0.22, 1, 0.36, 1) calc(var(--vit-cin-i, 0) * 80ms),
    filter  620ms cubic-bezier(0.22, 1, 0.36, 1) calc(var(--vit-cin-i, 0) * 80ms);
}

.vit-premium__stage.is-mounted .slot {
  opacity: 1;
  filter: blur(0);
  transform:
    perspective(900px)
    translateY(0)
    rotateX(var(--vit-cin-rx))
    rotateY(var(--vit-cin-ry));
}

/* Une fois la cascade finie, les transitions tilt deviennent rapides. */
.vit-premium__stage.is-cin-ready .slot:not(.slot--empty):not(.is-empty) {
  transition: transform 140ms ease-out;
  will-change: transform;
}
.vit-premium__stage.is-cin-ready .slot.is-cin-tilt-leaving {
  transition: transform 520ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* ============================================================
 * Chantier 2 — Spotlight souris
 * Halo doré radial qui suit le curseur (warm overlay).
 * ============================================================ */
.vit-premium__stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background: radial-gradient(
    600px circle at var(--vit-cin-mx) var(--vit-cin-my),
    rgba(212, 160, 23, 0.16),
    rgba(212, 160, 23, 0.04) 32%,
    transparent 60%
  );
  opacity: 0;
  transition: opacity 420ms ease;
}
.vit-premium__stage.is-cin-spotlight::after { opacity: 1; }

@media (pointer: coarse) {
  .vit-premium__stage::after { display: none; }
}

/* ============================================================
 * Chantier 3 — Reflet spéculaire sur figurines (suit le curseur)
 * Le tilt 3D lui-même est géré dans Chantier 1 (CSS vars --vit-cin-rx/ry).
 * ============================================================ */
.vit-premium__stage .slot:not(.slot--empty):not(.is-empty)::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    240px circle at var(--vit-cin-gx, 50%) var(--vit-cin-gy, 50%),
    rgba(255, 255, 255, 0.14),
    rgba(255, 255, 255, 0.04) 30%,
    transparent 60%
  );
  pointer-events: none;
  opacity: 0;
  transition: opacity 280ms ease;
  z-index: 3;
  mix-blend-mode: overlay;
}
.vit-premium__stage .slot.is-cin-tilting::after { opacity: 1; }

/* ============================================================
 * Chantier 4 — Slots vides premium
 * Bordure dorée tournante + halo pulsant sur le +.
 * ============================================================ */
.vit-premium__stage .slot--empty,
.vit-premium__stage .slot.is-empty {
  border-color: transparent;
}

.vit-premium__stage .slot--empty::before,
.vit-premium__stage .slot.is-empty::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: conic-gradient(
    from var(--vit-cin-angle),
    rgba(212, 160, 23, 0.55) 0deg,
    rgba(212, 160, 23, 0.06) 90deg,
    rgba(212, 160, 23, 0.06) 270deg,
    rgba(212, 160, 23, 0.55) 360deg
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  z-index: 0;
  animation: vit-cin-rotate 9s linear infinite;
}

@keyframes vit-cin-rotate {
  to { --vit-cin-angle: 360deg; }
}

@supports not (background: conic-gradient(from 0deg, red, blue)) {
  .vit-premium__stage .slot--empty::before,
  .vit-premium__stage .slot.is-empty::before { display: none; }
  .vit-premium__stage .slot--empty,
  .vit-premium__stage .slot.is-empty { border-color: rgba(212, 160, 23, 0.22); }
}

.vit-premium__stage .slot--empty .slot__empty-icon,
.vit-premium__stage .slot.is-empty .slot__empty-icon {
  animation: vit-cin-pulse 3.2s ease-in-out infinite;
}

@keyframes vit-cin-pulse {
  0%, 100% {
    box-shadow:
      0 0 0 0 rgba(212, 160, 23, 0),
      inset 0 0 0 0 rgba(212, 160, 23, 0);
  }
  50% {
    box-shadow:
      0 0 18px 1px rgba(212, 160, 23, 0.22),
      inset 0 0 12px 0 rgba(212, 160, 23, 0.08);
  }
}

/* ============================================================
 * Phase 2 — Aura pulsante derrière chaque figurine occupée.
 * ::before n'est pas utilisé sur les slots non-vides (pris uniquement
 * sur .slot--empty), donc on peut l'employer ici.
 * ============================================================ */
.vit-premium__stage .slot:not(.slot--empty):not(.is-empty)::before {
  content: '';
  position: absolute;
  inset: 18% 16% 16% 16%;
  border-radius: 60% 60% 50% 50% / 50% 50% 60% 60%;
  background: radial-gradient(
    circle at 50% 60%,
    rgba(212, 160, 23, 0.18),
    rgba(212, 160, 23, 0.04) 42%,
    transparent 68%
  );
  filter: blur(10px);
  pointer-events: none;
  z-index: 0;
  animation: vit-cin-aura 4.4s ease-in-out infinite;
}
@keyframes vit-cin-aura {
  0%, 100% { opacity: 0.45; transform: scale(0.94); }
  50%      { opacity: 0.85; transform: scale(1.06); }
}

/* ============================================================
 * Phase 2 — Flash de validation (ripple doré au clic).
 * ============================================================ */
.vit-premium .vit-premium__ctl--primary {
  position: relative;
  overflow: hidden;
}
.vit-premium .vit-premium__ctl--primary::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    circle at center,
    rgba(255, 245, 210, 0.85),
    rgba(255, 215, 120, 0.35) 40%,
    transparent 70%
  );
  pointer-events: none;
  opacity: 0;
  transform: scale(0.4);
}
.vit-premium .vit-premium__ctl--primary.is-cin-flash::after {
  animation: vit-cin-flash 720ms cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes vit-cin-flash {
  0%   { opacity: 0.95; transform: scale(0.4); }
  60%  { opacity: 0.55; transform: scale(1.6); }
  100% { opacity: 0;    transform: scale(2.4); }
}

/* ============================================================
 * Chantier 6 — Toolbar avec halo glissant
 * Un halo doré flou suit le bouton survolé/focus.
 * ============================================================ */
.vit-premium .vit-premium__controls-left {
  position: relative;
}
.vit-premium .vit-premium__controls-left::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: var(--vit-cin-tl-w, 0px);
  height: var(--vit-cin-tl-h, 0px);
  transform: translate(var(--vit-cin-tl-x, 0px), var(--vit-cin-tl-y, 0px));
  border-radius: 999px;
  background: radial-gradient(
    ellipse at center,
    rgba(212, 160, 23, 0.22),
    rgba(212, 160, 23, 0.06) 60%,
    transparent 80%
  );
  box-shadow: 0 0 22px 4px rgba(212, 160, 23, 0.14);
  pointer-events: none;
  opacity: 0;
  z-index: 0;
  transition:
    transform 380ms cubic-bezier(0.22, 1, 0.36, 1),
    width  380ms cubic-bezier(0.22, 1, 0.36, 1),
    height 380ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 240ms ease;
}
.vit-premium .vit-premium__controls-left.is-cin-tl-active::before { opacity: 1; }
.vit-premium .vit-premium__controls-left .vit-premium__ctl {
  position: relative;
  z-index: 1;
}

/* ============================================================
 * Phase 3 — View Transitions sur le switch de thème.
 * Reveal circulaire centré sur le bouton cliqué.
 * Chrome 111+, Edge 111+, Safari 18+ ; sinon fallback : pas de transition.
 * ============================================================ */
/* OLD reste statique sous NEW, NEW fait le reveal circulaire au-dessus.
   La pile par défaut a NEW au-dessus de OLD : on clip NEW pour que OLD
   apparaisse à travers, puis on étend le clip pour révéler le nouveau thème. */
::view-transition-old(root) {
  animation: none;
}
::view-transition-new(root) {
  animation: vit-cin-vt-reveal 720ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes vit-cin-vt-reveal {
  from {
    clip-path: circle(0% at var(--vit-cin-vt-x, 50%) var(--vit-cin-vt-y, 50%));
  }
  to {
    clip-path: circle(150% at var(--vit-cin-vt-x, 50%) var(--vit-cin-vt-y, 50%));
  }
}

/* ============================================================
 * Phase 3 — FLIP drag & drop : on garantit que pendant l'anim
 * les images ne soient pas clippées par leur slot.
 * ============================================================ */
.vit-premium__stage .slot__img.is-cin-flying {
  position: relative;
  z-index: 4;
  pointer-events: none;
}

/* ============================================================
 * Phase 4 — Peaufinage GLOBAL de la page (hors vit-premium).
 * Hero stats / Sidebar / Activity / Insights / Hero orbe.
 * ============================================================ */

/* Stat cards : hover doré + lift subtil */
.vit-stat {
  transition:
    border-color 320ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 320ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 320ms cubic-bezier(0.22, 1, 0.36, 1),
    background 320ms ease;
}
.vit-stat:hover {
  border-color: rgba(212, 160, 23, 0.42);
  box-shadow:
    0 12px 32px -16px rgba(212, 160, 23, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transform: translateY(-2px);
  background: rgba(212, 160, 23, 0.05);
}

/* Sidebar : indicateur vertical doré qui glisse à gauche au hover/active */
.vitrine-side__item {
  position: relative;
  transition: color 220ms ease, background 220ms ease;
}
.vitrine-side__item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 22%;
  bottom: 22%;
  width: 2px;
  background: linear-gradient(
    180deg,
    transparent,
    rgba(212, 160, 23, 0.85) 20%,
    rgba(212, 160, 23, 0.85) 80%,
    transparent
  );
  transform: scaleY(0);
  transform-origin: center;
  transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}
.vitrine-side__item:hover::before,
.vitrine-side__item.is-active::before {
  transform: scaleY(1);
}

/* Avatar ring : pulse subtil */
.vitrine-side__avatar-ring {
  animation: vit-cin-avatar-ring 4.8s ease-in-out infinite;
}
@keyframes vit-cin-avatar-ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 160, 23, 0); }
  50%      { box-shadow: 0 0 0 6px rgba(212, 160, 23, 0.10); }
}

/* Activity : pulse doré sur le dot du dernier événement (premier dans le DOM) */
.vit-act__item:first-child .vit-act__dot {
  animation: vit-cin-act-pulse 2.6s ease-in-out infinite;
}
@keyframes vit-cin-act-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(212, 160, 23, 0);
    border-color: var(--line-strong, rgba(244,234,217,0.18));
  }
  50% {
    box-shadow: 0 0 0 8px rgba(212, 160, 23, 0.18);
    border-color: rgba(212, 160, 23, 0.45);
  }
}

/* Hero orbe : flotte doucement */
.vit-hero::before {
  animation: vit-cin-hero-orbe 9s ease-in-out infinite;
}
@keyframes vit-cin-hero-orbe {
  0%, 100% { transform: translate(0, 0) scale(1);    opacity: 1; }
  50%      { transform: translate(-10px, 8px) scale(1.06); opacity: 0.82; }
}

/* Insights chart : états initiaux pour l'animation au reveal.
   La transition est appliquée par JS quand la classe is-cin-chart-ready est posée. */
.vit-ins__chart polyline {
  transition: stroke-dashoffset 1800ms cubic-bezier(0.22, 1, 0.36, 1);
}
.vit-ins__chart polygon {
  opacity: 0;
  transition: opacity 1200ms ease 600ms;
}
.vit-ins.is-cin-chart-ready polygon {
  opacity: 1;
}

/* CTA hero : glow doré subtil au hover sur les boutons ghost */
.vit-hero__cta .lt26-btn {
  transition:
    transform 280ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 280ms ease,
    border-color 280ms ease;
}
.vit-hero__cta .lt26-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px -14px rgba(212, 160, 23, 0.35);
}

/* ============================================================
 * Phase 5 — Responsive mobile / tablette.
 * Le CSS existant gère déjà sidebar, hero stats et vit-grid
 * en dessous de 1100px. On corrige ici les vrais problèmes :
 *   - Grille 5 colonnes du stage → écrasée sous 700px
 *   - Toolbar 6 boutons label+icône → trop large
 *   - Titre, stats et CTA hero à dimensionner finement
 * ============================================================ */

/* Tablette / mobile large (≤900px) : grille premium en 3 colonnes */
@media (max-width: 900px) {
  .vit-premium__stage .etagere {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }
  .vit-premium__stage {
    padding: 14px;
  }
  .vit-premium__title {
    font-size: clamp(20px, 4vw, 26px);
  }
}

/* Mobile (≤600px) : grille en 2 colonnes, toolbar compactée, header empilé */
@media (max-width: 600px) {
  .vit-premium__stage .etagere {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .vit-premium__stage {
    padding: 10px;
    border-radius: 14px;
  }

  /* Slots compacts pour ne pas avoir une grille géante verticale */
  .vit-premium__stage .vitrine.vitrine-size-m .slot,
  .vit-premium__stage .vitrine.vitrine-size-l .slot {
    min-height: 170px;
  }
  .vit-premium__stage .vitrine.vitrine-size-s .slot {
    min-height: 140px;
  }
  .vit-premium__stage .vitrine.vitrine-size-m .slot__img,
  .vit-premium__stage .vitrine.vitrine-size-l .slot__img {
    width: min(88%, 150px);
    max-height: 140px;
  }

  /* Header : titre + meta empilés verticalement */
  .vit-premium__toprow {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .vit-premium__meta {
    white-space: normal;
    flex-wrap: wrap;
    font-size: 10px;
  }

  /* Toolbar : icônes seules, padding réduit. On garde les labels
     uniquement pour les actions critiques (Valider / Annuler). */
  .vit-premium__controls {
    padding: 10px 12px;
    gap: 10px;
  }
  .vit-premium__controls-left {
    gap: 4px;
    flex-wrap: wrap;
  }
  .vit-premium__ctl {
    padding: 9px 11px;
    font-size: 11px;
    gap: 0;
  }
  .vit-premium__ctl > span:not(.vit-premium__ctl-ic) {
    display: none;
  }
  .vit-premium__ctl--primary > span,
  .vit-premium__ctl[data-vit-premium-cancel] > span {
    display: inline;
  }
  .vit-premium__ctl-ic {
    margin: 0;
    font-size: 16px;
  }
  .vit-premium__controls-right {
    width: 100%;
    margin-left: 0;
    text-align: left;
    font-size: 10px;
  }

  /* Hero : taille des chiffres réduite pour rester lisible en 2x2 */
  .vit-stat__num {
    font-size: 22px;
  }
  .vit-stat {
    padding: 12px 12px 10px;
  }

  /* CTA hero : empile en pleine largeur */
  .vit-hero__cta {
    flex-direction: column;
    gap: 8px;
  }
  .vit-hero__cta .lt26-btn {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  /* Hero title + section spacing */
  .vit-hero {
    padding: 26px 18px 22px;
    border-radius: 18px;
  }

  /* Insights chart : labels et titres légèrement réduits */
  .vit-ins__base {
    font-size: 9.5px;
  }
  .vit-ins__num {
    font-size: 26px;
  }
  .vit-act__head h3 {
    font-size: 20px;
  }

  /* Particules : déjà réduites en JS (18 au lieu de 42).
     On baisse encore l'opacité pour ne pas saturer l'écran. */
  .vit-cin-particles {
    opacity: 0.7;
  }
}

/* Mobile très petit (≤380px) : hero stats en 1 colonne */
@media (max-width: 380px) {
  .vit-hero__stats {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .vit-stat__num {
    font-size: 26px;
  }
  .vit-premium__title {
    font-size: 18px;
  }
}

/* Sans hover (tactile) : on neutralise les lift+shadow inutiles */
@media (hover: none) {
  .vit-stat:hover,
  .vit-hero__cta .lt26-btn:hover {
    transform: none;
    box-shadow: inherit;
  }
  /* L'aura derrière les figurines est ralentie pour préserver la batterie */
  .vit-premium__stage .slot:not(.slot--empty):not(.is-empty)::before {
    animation-duration: 6s;
    opacity: 0.6;
  }
}

/* ============================================================
 * Garde-fou : prefers-reduced-motion → tout figé.
 * ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .vit-premium__stage .slot {
    opacity: 1;
    filter: none;
    transform: none;
    transition: none;
  }
  .vit-premium__stage::after,
  .vit-premium__stage .slot::after,
  .vit-premium__stage .slot--empty::before,
  .vit-premium__stage .slot.is-empty::before { animation: none; }
  .vit-premium__stage .slot--empty .slot__empty-icon,
  .vit-premium__stage .slot.is-empty .slot__empty-icon { animation: none; }
  .vit-cin-particles { display: none; }
  .vit-premium .vit-premium__controls-left::before { display: none; }
  .vit-premium__stage .slot:not(.slot--empty):not(.is-empty)::before { animation: none; }
  .vit-premium .vit-premium__ctl--primary::after { display: none; }
  ::view-transition-old(root),
  ::view-transition-new(root) { animation: none; }
  .vit-stat { transition: none; }
  .vit-stat:hover { transform: none; }
  .vitrine-side__avatar-ring,
  .vit-act__item:first-child .vit-act__dot,
  .vit-hero::before { animation: none; }
}
