/* 051 — Coverflow 3D
   Chaque carte est placée par 3 custom properties écrites par anim.js :
   --coverflow-3d-d   : offset signé par rapport à la carte active (-2…+2)
   --coverflow-3d-abs : |offset| (profondeur, z-index, assombrissement)
   --coverflow-3d-r   : signe borné (-1/0/+1) → sens de l'inclinaison
   Tout le placement est du transform pur, transitionné en bloc. */

.coverflow-3d {
  display: grid;
  gap: 14px;
  justify-items: center;
  width: min(340px, 100%);
}

.coverflow-3d__stage {
  position: relative;
  width: 100%;
  height: 178px;
  perspective: 860px;
}

.coverflow-3d__card {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 122px;
  height: 160px;
  margin: -80px 0 0 -61px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid color-mix(in oklab, var(--ml-fg, #e8eaf2) 12%, transparent);
  border-radius: 14px;
  background: var(--ml-surface, #151a24);
  color: var(--ml-fg, #e8eaf2);
  cursor: pointer;
  z-index: calc(10 - var(--coverflow-3d-abs, 0));
  transform:
    translateX(calc(var(--coverflow-3d-d, 0) * 54px))
    translateZ(calc(var(--coverflow-3d-abs, 0) * -92px))
    rotateY(calc(var(--coverflow-3d-r, 0) * -38deg));
  filter: brightness(calc(1 - var(--coverflow-3d-abs, 0) * 0.16));
  transition:
    transform 0.7s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.5s ease,
    opacity 0.45s ease,
    box-shadow 0.5s ease;
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
}

.coverflow-3d__card.is-active {
  cursor: default;
  box-shadow:
    0 22px 44px -20px color-mix(in oklab, var(--ml-accent, #7c8cff) 55%, transparent),
    0 6px 18px -8px rgba(0, 0, 0, 0.6);
  border-color: color-mix(in oklab, var(--ml-accent, #7c8cff) 45%, transparent);
}

.coverflow-3d__card.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.coverflow-3d__card:focus-visible {
  outline: 2px solid var(--ml-accent-2, #2dd4bf);
  outline-offset: 3px;
}

/* Reflet doux qui glisse selon l'inclinaison */
.coverflow-3d__card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    115deg,
    transparent 30%,
    color-mix(in oklab, var(--ml-fg, #e8eaf2) 10%, transparent) 46%,
    transparent 62%
  );
  opacity: calc(var(--coverflow-3d-abs, 0) * 0.9);
  transition: opacity 0.6s ease;
  pointer-events: none;
}

/* Teintes de démo */
.coverflow-3d__card--1 {
  background: linear-gradient(160deg,
    color-mix(in oklab, #f472b6 34%, var(--ml-surface, #151a24)),
    var(--ml-surface, #151a24) 82%);
}
.coverflow-3d__card--2 {
  background: linear-gradient(160deg,
    color-mix(in oklab, var(--ml-accent, #7c8cff) 36%, var(--ml-surface, #151a24)),
    var(--ml-surface, #151a24) 82%);
}
.coverflow-3d__card--3 {
  background: linear-gradient(160deg,
    color-mix(in oklab, #a78bfa 36%, var(--ml-surface, #151a24)),
    var(--ml-surface, #151a24) 82%);
}
.coverflow-3d__card--4 {
  background: linear-gradient(160deg,
    color-mix(in oklab, #f59e0b 30%, var(--ml-surface, #151a24)),
    var(--ml-surface, #151a24) 82%);
}
.coverflow-3d__card--5 {
  background: linear-gradient(160deg,
    color-mix(in oklab, var(--ml-accent-2, #2dd4bf) 32%, var(--ml-surface, #151a24)),
    var(--ml-surface, #151a24) 82%);
}

.coverflow-3d__num {
  font: 500 10px/1 system-ui, -apple-system, sans-serif;
  letter-spacing: 0.16em;
  color: color-mix(in oklab, var(--ml-fg, #e8eaf2) 62%, transparent);
}

.coverflow-3d__name {
  font: 600 15px/1.15 system-ui, -apple-system, sans-serif;
  letter-spacing: -0.01em;
  text-align: left;
}

/* --- Contrôles ------------------------------------------------------------ */

.coverflow-3d__controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.coverflow-3d__arrow {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid color-mix(in oklab, var(--ml-fg, #e8eaf2) 14%, transparent);
  background: var(--ml-surface, #151a24);
  color: var(--ml-fg, #e8eaf2);
  cursor: pointer;
  transition:
    transform 0.35s cubic-bezier(0.3, 1.4, 0.5, 1),
    border-color 0.25s ease,
    opacity 0.25s ease;
}

.coverflow-3d__arrow svg {
  display: block;
  width: 15px;
  height: 15px;
}

.coverflow-3d__arrow:is(:hover, :focus-visible) {
  transform: scale(1.12);
  border-color: color-mix(in oklab, var(--ml-accent, #7c8cff) 60%, transparent);
}

.coverflow-3d__arrow:focus-visible {
  outline: 2px solid var(--ml-accent-2, #2dd4bf);
  outline-offset: 2px;
}

.coverflow-3d__arrow:active {
  transform: scale(0.9);
  transition-duration: 0.12s;
}

.coverflow-3d__arrow[disabled] {
  opacity: 0.25;
  transform: none;
  pointer-events: none;
}

.coverflow-3d__status {
  min-width: 44px;
  text-align: center;
  font: 500 12px/1 system-ui, -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  color: var(--ml-muted, #8b91a3);
}

/* --- Reduced motion -------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .coverflow-3d__card {
    transition: box-shadow 0.2s ease, opacity 0.2s ease;
  }
  .coverflow-3d__card::after { transition: none; }
  .coverflow-3d__arrow { transition: border-color 0.2s ease, opacity 0.2s ease; }
  .coverflow-3d__arrow:is(:hover, :focus-visible, :active) { transform: none; }
}
