/* =========================================================
   ÉQUIPE : cartes empilées au scroll (même principe que Luc Valier).
   Chaque carte reste collée en haut de l'écran ; la suivante monte
   et vient la recouvrir, pendant que la précédente recule
   (légère réduction + voile sombre). La dernière carte est dorée.
   Tout est activé par team-reveal.js (.team-stack) : sans JS, la
   grille d'origine reste affichée.
   ========================================================= */

/* sticky ne fonctionne pas sous un parent en overflow:hidden :
   on remplace ces "hidden" par "clip" (même rendu, sans casser sticky) */
html:has(body.contact-page),
body.contact-page { overflow-x: clip !important; overflow-y: visible !important; }
.contact-pro-page { overflow: clip; }
.contact-team-section { content-visibility: visible; }

.team-flip-grid.team-stack {
  --stack-top: 96px;
  --stack-step: 16px;
  --stack-h: min(470px, calc(100vh - 150px));
  display: block;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 30px 40px;
  perspective: none;
}

.team-stack .team-flip-card {
  --p: 0;
  position: sticky;
  top: calc(var(--stack-top) + var(--i, 0) * var(--stack-step));
  height: var(--stack-h);
  margin: 0 0 7vh;
  border-radius: 24px;
  background: #121211;
  border: 1px solid rgba(233, 196, 106, .16);
  box-shadow: 0 -18px 50px -30px rgba(0, 0, 0, .55), 0 30px 70px -40px rgba(0, 0, 0, .6);
  overflow: hidden;
  cursor: default;
  animation: none !important;
  transform: none !important;
  scale: calc(1 - var(--p) * .06);
  transform-origin: 50% 0;
  will-change: scale;
}
.team-stack .team-flip-card:last-child { margin-bottom: 0; }
.team-stack .team-flip-card:focus-visible { outline: 2px solid var(--gold, #e9c46a); outline-offset: 4px; }

/* voile qui assombrit la carte recouverte (jamais d'opacité sur la carte) */
.team-stack .team-flip-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: #050505;
  opacity: calc(var(--p) * .6);
}

/* la carte devient un panneau : texte à gauche, photo à droite */
.team-stack .team-flip-inner {
  display: grid;
  grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr);
  gap: clamp(22px, 3vw, 40px);
  height: 100%;
  padding: clamp(22px, 2.6vw, 34px);
  transform: none !important;
  transform-style: flat;
  transition: none;
}

.team-stack .team-flip-front,
.team-stack .team-flip-back {
  position: relative;
  inset: auto;
  transform: none !important;
  backface-visibility: visible;
  border-radius: 0;
  box-shadow: none;
}

/* colonne texte */
.team-stack .team-flip-back {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 6px 4px 8px;
  text-align: left;
  background: none;
  color: #f5f1e8;
  overflow: visible;
}
.team-stack .team-flip-back::before {
  content: attr(data-role);
  position: absolute;
  top: 6px;
  left: 4px;
  font-family: var(--font-utility, inherit);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--gold, #e9c46a);
}
.team-stack .team-flip-back h4 {
  margin: 0 0 16px;
  font-size: clamp(2.3rem, 4.6vw, 4rem);
  line-height: .95;
  font-weight: 800;
  letter-spacing: -.02em;
  color: #f5f1e8;
}
.team-stack .team-flip-back h4::after {
  content: ".";
  color: var(--gold, #e9c46a);
}
.team-stack .team-flip-back p {
  max-width: 40ch;
  margin: 0;
  font-size: clamp(.86rem, .95vw, .98rem);
  line-height: 1.65;
  color: rgba(245, 241, 232, .66);
  opacity: 1;
}
.team-stack .team-flip-socials { margin-top: 18px; }

/* colonne photo */
.team-stack .team-flip-front {
  grid-column: 2;
  grid-row: 1;
  overflow: hidden;
  border-radius: 16px;
  border: 0;
  background: #1b1b19;
}
.team-stack .team-flip-front:hover { transform: none !important; }
.team-stack .team-flip-front img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 22%;
  scale: calc(1.06 - var(--p) * .06);
}
.team-stack .team-flip-card[data-supabase-team-member] .team-flip-front img[src*="logo"],
.team-stack .team-flip-front img[src*="logo"] {
  object-fit: contain;
  padding: 18%;
  background: radial-gradient(circle at 50% 45%, #1f2a24, #0d0f0e 70%);
}
.team-stack .team-flip-front::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, transparent 52%, rgba(5, 5, 5, .72));
}
.team-stack .team-flip-front-info {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 18px;
  z-index: 2;
  padding: 0;
  text-align: left;
}
:root[data-theme] .team-stack .team-flip-front-info h4,
.team-stack .team-flip-front-info h4 {
  margin: 0 0 2px;
  font-size: 1rem;
  font-style: italic;
  color: #fffdf7 !important;
}
:root[data-theme] .team-stack .team-flip-front-info span,
.team-stack .team-flip-front-info span {
  font-size: .74rem;
  letter-spacing: .04em;
  color: rgba(255, 253, 247, .7) !important;
}

/* dernière carte : version dorée */
.team-stack .team-flip-card:last-child {
  background: var(--gold, #e9c46a);
  border-color: rgba(0, 0, 0, .08);
}
.team-stack .team-flip-card:last-child .team-flip-back,
.team-stack .team-flip-card:last-child .team-flip-back h4 { color: #121211; }
.team-stack .team-flip-card:last-child .team-flip-back h4::after { color: #121211; }
.team-stack .team-flip-card:last-child .team-flip-back::before { color: rgba(18, 18, 17, .62); }
.team-stack .team-flip-card:last-child .team-flip-back p { color: rgba(18, 18, 17, .72); }

/* mobile : photo au-dessus, texte en dessous */
@media (max-width: 760px) {
  .team-flip-grid.team-stack {
    --stack-top: 84px;
    --stack-step: 10px;
    --stack-h: min(560px, calc(100svh - 120px));
    padding: 0 16px 24px;
  }
  .team-stack .team-flip-card { margin-bottom: 5vh; border-radius: 20px; }
  .team-stack .team-flip-inner {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1.15fr) auto;
    gap: 16px;
    padding: 14px;
  }
  .team-stack .team-flip-front { grid-column: 1; grid-row: 1; border-radius: 13px; }
  .team-stack .team-flip-back { grid-column: 1; grid-row: 2; padding: 22px 6px 6px; justify-content: flex-start; }
  .team-stack .team-flip-back::before { top: 0; left: 6px; }
  .team-stack .team-flip-back h4 { font-size: 2.2rem; margin-bottom: 10px; }
  .team-stack .team-flip-back p {
    font-size: .84rem;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  .team-stack .team-flip-card { scale: none; }
  .team-stack .team-flip-front img { scale: none; }
}
