/* ==========================================================================
   HUB Distribution — Slider interactif « Tablettes de chocolat »
   --------------------------------------------------------------------------
   4 calques superposés :
     1. Fond          — couleur de thème animée + typographie géante
     2. Décor         — éléments flottants en parallaxe
     3. Produit       — la tablette active, détourée, en lévitation
     4. Interface     — en-tête, flèches, fiche produit, pastilles

   Aucune dépendance externe : ni GSAP, ni jQuery, ni Slider Revolution.
   Toutes les animations n'utilisent que `transform` et `opacity`, composées
   par le GPU, et respectent `prefers-reduced-motion`.

   Préfixe .hcs (Hub Choco Slider) : aucun risque de collision avec le thème.
   ========================================================================== */

.hcs {
  /* — Valeurs par défaut, remplacées en JS pour chaque variante — */
  --bg-color: #3a1f18;
  --accent: #e0a45c;
  --ink: #fdf6ee;

  --font-display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --font-ui: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;

  --duration: 620ms;
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-back: cubic-bezier(0.34, 1.46, 0.64, 1);

  position: relative;
  display: block;
  overflow: hidden;
  isolation: isolate;
  min-height: clamp(620px, 88vh, 860px);
  background-color: var(--bg-color);
  /* Le fondu de couleur entre deux variantes : 0,6 s comme au cahier des
     charges, appliqué au calque de fond et non à la section entière. */
  transition: background-color var(--duration) ease;
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

/* ══════════════════════════════════ CALQUE 1 — FOND ══════════════════════ */

.hcs__bg {
  position: absolute;
  inset: 0;
  z-index: 1;
  background-color: var(--bg-color);
  transition: background-color var(--duration) ease;
}

/* Voile radial : donne de la profondeur au fond uni et détache la tablette. */
.hcs__bg::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(58% 52% at 50% 44%, rgba(255, 255, 255, 0.14) 0%, rgba(255, 255, 255, 0) 68%),
    radial-gradient(120% 100% at 50% 120%, rgba(0, 0, 0, 0.42) 0%, rgba(0, 0, 0, 0) 62%);
}

/* — Typographie géante, coupée par la tablette —
   Centrée sur la scène (et non sur la section) : elle reste derrière le
   produit et ne descend jamais sur la fiche produit. */
.hcs__giant {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 0;
  margin: 0;
  transform: translate3d(-50%, -50%, 0);
  font-family: var(--font-display);
  font-size: clamp(4.5rem, 17vw, 15rem);
  font-weight: 700;
  line-height: 0.82;
  letter-spacing: -0.035em;
  text-transform: uppercase;
  white-space: nowrap;
  color: rgba(253, 246, 238, 0.13);
  user-select: none;
  pointer-events: none;
}

/* Révélation lettre par lettre à l'entrée d'une variante. */
.hcs__giant span {
  display: inline-block;
  opacity: 0;
  transform: translate3d(0, 0.42em, 0);
}

.hcs.is-ready .hcs__giant span {
  animation: hcs-letter 700ms var(--ease-out) forwards;
  animation-delay: calc(var(--i) * 38ms);
}

@keyframes hcs-letter {
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

.hcs.is-leaving .hcs__giant {
  opacity: 0;
  transform: translate3d(-50%, -50%, 0) translateX(-6%);
  transition: opacity 300ms ease, transform 300ms ease;
}

/* ══════════════════════════════ CALQUE 2 — DÉCOR ═════════════════════════ */

.hcs__decor {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.hcs__float {
  position: absolute;
  top: var(--top, 50%);
  left: var(--left, 50%);
  width: var(--size, 56px);
  height: var(--size, 56px);
  opacity: 0;
  /* Chaque élément flotte à son propre rythme : c'est ce décalage qui crée
     la sensation de profondeur, plutôt qu'un mouvement uniforme. */
  animation: hcs-drift var(--drift-duration, 7s) ease-in-out
    var(--drift-delay, 0s) infinite alternate;
}

.hcs__float svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Entrée en volée depuis les bords, avec décalage de 0,05 s par élément. */
.hcs.is-ready .hcs__float {
  animation:
    hcs-fly-in 820ms var(--ease-back) forwards,
    hcs-drift var(--drift-duration, 7s) ease-in-out infinite alternate;
  animation-delay: calc(var(--i) * 50ms), calc(820ms + var(--i) * 50ms);
}

@keyframes hcs-fly-in {
  from {
    opacity: 0;
    transform: translate3d(var(--from-x, -120px), var(--from-y, -80px), 0)
      scale(0.4) rotate(var(--from-r, -90deg));
  }
  to {
    opacity: var(--opacity, 0.9);
    transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
  }
}

/* Éjection vers l'extérieur à la sortie du produit. */
.hcs.is-leaving .hcs__float {
  animation: hcs-fly-out 400ms cubic-bezier(0.5, 0, 0.75, 0) forwards;
}

@keyframes hcs-fly-out {
  to {
    opacity: 0;
    transform: translate3d(var(--exit-x, 60px), var(--exit-y, -90px), 0)
      scale(0.35) rotate(120deg);
  }
}

@keyframes hcs-drift {
  from { transform: translate3d(0, -10px, 0) rotate(-5deg); }
  to   { transform: translate3d(0, 12px, 0) rotate(6deg); }
}

/* ══════════════════════════ CALQUE 3 — PRODUIT HERO ══════════════════════ */

.hcs__hero {
  position: relative;
  z-index: 3;
  display: flex;
  /* Ancre le texte géant, qui vit désormais dans cette scène. */
  isolation: isolate;
  align-items: center;
  justify-content: center;
  /* min-height:0 permet à la cellule de grille de se réduire ; overflow:hidden
     garantit que la lévitation ne fait jamais sortir la tablette du cadre. */
  min-height: 0;
  overflow: hidden;
  /* Marge verticale = amplitude de lévitation (±12 px) + élargissement de la
     boîte englobante dû à la rotation (±3°), sinon la tablette est rognée. */
  padding: 1.6rem 0;
  pointer-events: none;
}

.hcs__tablet {
  position: relative;
  /* Largeur bornée par la hauteur disponible : la tablette garde toujours une
     marge au-dessus de la fiche produit. */
  width: min(22vh, 17vw, 214px);
  min-width: 132px;
  /* Léger balancement continu : la tablette ne paraît jamais figée. */
  animation: hcs-levitate 3.5s ease-in-out infinite alternate;
}

.hcs__tablet img {
  display: block;
  width: 100%;
  height: auto;
  /* Ombre portée douce : détache la tablette du fond coloré. */
  filter: drop-shadow(0 30px 44px rgba(0, 0, 0, 0.46));
  -webkit-user-drag: none;
  user-select: none;
}

@keyframes hcs-levitate {
  from { transform: translate3d(0, -12px, 0) rotate(-3deg); }
  to   { transform: translate3d(0, 12px, 0) rotate(3deg); }
}

/* Sortie : rotation rapide, réduction, glissement vers le bas. */
.hcs.is-leaving .hcs__tablet {
  animation: hcs-tablet-out 400ms cubic-bezier(0.5, 0, 0.75, 0) forwards;
}

@keyframes hcs-tablet-out {
  to {
    opacity: 0;
    transform: translate3d(0, 90px, 0) scale(0.8) rotate(15deg);
  }
}

/* Entrée : arrivée du haut avec rebond doux. */
.hcs.is-ready .hcs__tablet {
  animation:
    hcs-tablet-in 820ms var(--ease-back) forwards,
    hcs-levitate 3.5s ease-in-out 820ms infinite alternate;
}

@keyframes hcs-tablet-in {
  from {
    opacity: 0;
    transform: translate3d(0, -70px, 0) scale(0.7) rotate(-10deg);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
  }
}

/* ═════════════════════════ CALQUE 4 — INTERFACE ══════════════════════════ */

.hcs__ui {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(0.75rem, 2vw, 1.5rem);
  padding: clamp(1rem, 2.6vw, 2rem) clamp(1rem, 3vw, 2.25rem);
  pointer-events: none;
}

.hcs__ui > * {
  pointer-events: auto;
}

/* — En-tête — */
.hcs__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.hcs__brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-family: var(--font-display);
  font-size: clamp(1rem, 2vw, 1.3rem);
  letter-spacing: 0.02em;
  color: var(--ink);
}

.hcs__brand small {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.6rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  opacity: 0.62;
}

.hcs__head-right {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

.hcs__social {
  display: flex;
  gap: 0.85rem;
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hcs__social a {
  color: var(--ink);
  text-decoration: none;
  opacity: 0.72;
  transition: opacity 200ms ease;
}

.hcs__social a:hover { opacity: 1; }

/* Bouton « Explorer » : ouvre la vue galerie. */
.hcs__explore {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.05rem;
  border: 1px solid rgba(253, 246, 238, 0.38);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease;
}

.hcs__explore:hover {
  background: var(--ink);
  color: var(--bg-color);
  border-color: var(--ink);
}

/* — Bas de page : flèches / fiche produit / pastilles — */
.hcs__foot {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: end;
  gap: clamp(1rem, 3vw, 2.5rem);
}

/* Flèches de navigation verticale. */
.hcs__arrows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.hcs__arrow {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid rgba(253, 246, 238, 0.3);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  cursor: pointer;
  transition: background-color 220ms ease, border-color 220ms ease, color 220ms ease;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.hcs__arrow:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg-color);
}

.hcs__arrow svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Fiche produit centrée. */
.hcs__info {
  text-align: center;
  /* Le bloc garde sa hauteur : le décor ne saute pas d'une variante à l'autre. */
  min-height: 168px;
}

.hcs__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 3.4vw, 2.5rem);
  font-weight: 400;
  line-height: 1.14;
  letter-spacing: -0.012em;
  color: var(--ink);
}

.hcs__tasting {
  margin: 0.6rem auto 0;
  max-width: 42ch;
  font-size: clamp(0.82rem, 1.6vw, 0.95rem);
  line-height: 1.6;
  opacity: 0.76;
}

.hcs__cta {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.15rem;
  padding: 0.8rem 1.7rem;
  border: none;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg-color);
  font-family: var(--font-ui);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: transform 220ms var(--ease-out), box-shadow 220ms ease;
}

.hcs__cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 26px -12px rgba(0, 0, 0, 0.6);
}

/* Le bloc texte glisse vers le haut à chaque changement de variante. */
.hcs__info > * {
  opacity: 0;
  transform: translate3d(0, 20px, 0);
}

.hcs.is-ready .hcs__info > * {
  opacity: 1;
  transform: translate3d(0, 0, 0);
  transition:
    opacity 520ms var(--ease-out) var(--info-delay, 320ms),
    transform 520ms var(--ease-out) var(--info-delay, 320ms);
}

.hcs.is-leaving .hcs__info > * {
  opacity: 0;
  transform: translate3d(0, -14px, 0);
  transition: opacity 240ms ease, transform 240ms ease;
}

/* Pastilles de sélection rapide. */
.hcs__thumbs {
  display: flex;
  gap: 0.6rem;
}

.hcs__thumb {
  position: relative;
  width: 54px;
  height: 54px;
  padding: 3px;
  border: 1px solid rgba(253, 246, 238, 0.26);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 240ms ease, transform 240ms var(--ease-out);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.hcs__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  -webkit-user-drag: none;
}

.hcs__thumb:hover { transform: translateY(-3px); }

.hcs__thumb[aria-current="true"] {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px rgba(253, 246, 238, 0.22);
}

/* Jauge d'intensité de cacao, sous la forme d'une barre fine. */
.hcs__meter {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  margin-top: 0.7rem;
}

.hcs__meter-track {
  position: relative;
  width: 92px;
  height: 3px;
  border-radius: 2px;
  background: rgba(253, 246, 238, 0.24);
  overflow: hidden;
}

.hcs__meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--level, 60%);
  border-radius: 2px;
  background: var(--accent);
  transition: width 520ms var(--ease-out);
}

.hcs__meter-label {
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.72;
}

/* Focus visible partout : le slider reste pilotable au clavier. */
.hcs :focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* ═════════════════════════ VUE GALERIE (calque 5) ════════════════════════ */

/* Révélation par masque circulaire, du centre vers l'écran entier. */
.hcs__showcase {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  align-items: center;
  gap: clamp(1.5rem, 4vw, 4rem);
  padding: clamp(1.5rem, 5vw, 4rem);
  background: var(--bg-color);
  clip-path: circle(0% at 50% 50%);
  visibility: hidden;
  overflow: hidden;
}

.hcs.is-showcase .hcs__showcase {
  visibility: visible;
  clip-path: circle(150% at 50% 50%);
  transition: clip-path 900ms cubic-bezier(0.65, 0, 0.35, 1), visibility 0s;
}

/* Cascade 3D des six tablettes, à gauche. */
.hcs__stack {
  position: relative;
  height: min(58vh, 460px);
  perspective: 1400px;
  transform-style: preserve-3d;
}

.hcs__stack-card {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 150px;
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 620ms var(--ease-out), opacity 400ms ease;
}

.hcs__stack-card img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 16px 26px rgba(0, 0, 0, 0.45));
}

.hcs__stack-card span {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-align: center;
  opacity: 0;
  transition: opacity 260ms ease;
}

.hcs__stack-card:hover span,
.hcs__stack-card:focus-visible span {
  opacity: 0.85;
}

/* Colonne de droite : discours de marque + sélection. */
.hcs__showcase-copy h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4.4vw, 3.2rem);
  font-weight: 400;
  line-height: 1.06;
  letter-spacing: -0.018em;
}

.hcs__showcase-copy p {
  margin: 1rem 0 0;
  max-width: 40ch;
  font-size: clamp(0.85rem, 1.7vw, 1rem);
  line-height: 1.65;
  opacity: 0.74;
}

.hcs__showcase-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.6rem;
}

.hcs__showcase-chip {
  padding: 0.5rem 0.95rem;
  border: 1px solid rgba(253, 246, 238, 0.28);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease;
}

.hcs__showcase-chip:hover,
.hcs__showcase-chip[aria-current="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg-color);
}

.hcs__close {
  position: absolute;
  top: clamp(1rem, 3vw, 2.25rem);
  right: clamp(1rem, 3vw, 2.25rem);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(253, 246, 238, 0.34);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 200ms ease, color 200ms ease;
}

.hcs__close:hover { background: var(--ink); color: var(--bg-color); }

.hcs__close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* Statut réservé aux lecteurs d'écran. */
.hcs__status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ═══════════════════════════════ RESPONSIVE ══════════════════════════════ */

/* ═════════════════════════ MOUVEMENT RÉDUIT ══════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  /* On conserve toutes les fonctions, on supprime les mouvements : les états
     finaux sont appliqués directement, sans animation ni décalage. */
  .hcs__float,
  .hcs__tablet,
  .hcs.is-ready .hcs__float,
  .hcs.is-ready .hcs__tablet,
  .hcs.is-ready .hcs__giant span,
  .hcs.is-leaving .hcs__float,
  .hcs.is-leaving .hcs__tablet {
    animation: none !important;
    opacity: var(--opacity, 1);
    transform: none;
  }

  .hcs__giant span { opacity: 1; transform: none; }

  .hcs.is-showcase .hcs__showcase {
    transition: none;
  }

  .hcs__bg,
  .hcs,
  .hcs__meter-fill,
  .hcs__stack-card {
    transition-duration: 1ms;
  }
}

@media (max-width: 1024px) {
  .hcs__showcase {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .hcs__stack { height: min(34vh, 300px); }
  .hcs__stack-card { width: 110px; }
}

@media (max-width: 767px) {
  /* `dvh` suit la barre d'adresse mobile ; `vh` sert de repli.
     `height: auto` est indispensable : sur un écran court, l'en-tête du site
     + la scène + la fiche produit dépassent la hauteur d'écran. Une hauteur
     figée rognait alors les pastilles ; la section grandit désormais. */
  .hcs {
    min-height: 100vh;
    min-height: 100dvh;
    height: auto;
  }

  .hcs__giant { font-size: clamp(3.4rem, 22vw, 6rem); }

  .hcs__social { display: none; }

  /* La grille devient une simple colonne : plus de rangée rigide à 1fr. */
  .hcs__ui {
    position: relative;
    grid-template-rows: auto auto auto;
    gap: 0.6rem;
    padding: 0.8rem 1rem clamp(1rem, 4vw, 1.6rem);
  }

  /* La scène redevient un élément de la pile. La tablette est dimensionnée
     pour laisser la place à l'amplitude de lévitation (±12 px) et à la
     rotation, sinon `overflow: hidden` la rogne. */
  .hcs__hero {
    position: relative;
    inset: auto;
    padding: 1.5rem 0;
  }

  .hcs__foot {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "info info"
      "arrows thumbs";
    gap: 1rem;
    align-items: center;
  }

  .hcs__arrows { grid-area: arrows; flex-direction: row; }
  .hcs__info { grid-area: info; min-height: 0; }
  .hcs__thumbs { grid-area: thumbs; justify-content: flex-end; flex-wrap: wrap; }

  /* Bloc texte resserré : sur 390 px de large, chaque ligne compte. */
  .hcs__title { font-size: clamp(1.15rem, 5.6vw, 1.5rem); }
  .hcs__tasting { font-size: 0.82rem; max-width: 34ch; }
  .hcs__cta { margin-top: 0.85rem; padding: 0.7rem 1.4rem; font-size: 0.7rem; }
  .hcs__meter { margin-top: 0.55rem; }

  .hcs__thumb { width: 44px; height: 44px; }
  .hcs__arrow { width: 42px; height: 42px; }

  /* Sur mobile, la hauteur d'écran est la seule contrainte fiable. */
  .hcs__tablet { width: min(44vw, 19vh, 150px); }

  .hcs__decor .hcs__float:nth-child(n + 5) { display: none; }
}
