/* Category previews unfold beneath the original, unmoving genre card. */
.cinema-genre-gallery {
  isolation: isolate;
  overflow: visible;
  z-index: 6;
}

/* Keep the scrolling rail out of its own stacking context: the real source
   card must paint above this sibling layer without changing its geometry. */
.cinema-genre-gallery .cinema-category-card.is-fan-source { z-index: 3; }
.cinema-genre-gallery .cinema-category-card {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.cinema-genre-gallery .cinema-category-card img { -webkit-user-drag: none; }

.cinema-fan-layer {
  --fan-open-ease: cubic-bezier(.18, 1.3, .32, 1);
  --fan-close-ease: cubic-bezier(.22, .78, .25, 1);
  position: absolute;
  z-index: 2;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}
.cinema-fan-layer:empty { display: none; }
.cinema-fan-deck {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}
.cinema-fan-card {
  position: absolute;
  left: calc(var(--fan-width, 160px) * -.5);
  top: calc(var(--fan-height, 100px) * -.5);
  width: var(--fan-width, 160px);
  height: var(--fan-height, 100px);
  border-radius: clamp(10px, 1.1vw, 17px);
  opacity: 1;
  pointer-events: none;
  transform: perspective(900px) translate3d(0, 0, 0) rotateZ(0deg) rotateY(0deg) scale(.9);
  transform-origin: center;
  backface-visibility: hidden;
  will-change: transform;
  transition-property: transform;
  transition-duration: 350ms;
  transition-timing-function: var(--fan-close-ease);
  transition-delay: calc((3 - var(--fan-i, 0)) * 25ms);
}
.cinema-fan-deck.is-open .cinema-fan-card {
  transform: perspective(900px) translate3d(var(--fan-x, 0px), var(--fan-y, 0px), 0)
    rotateZ(var(--fan-rotation, 0deg)) rotateY(var(--fan-tilt, 0deg)) scale(1);
  transition-duration: 520ms;
  transition-timing-function: var(--fan-open-ease);
  transition-delay: calc(var(--fan-i, 0) * 60ms);
}

.cinema-fan-float {
  position: relative;
  isolation: isolate;
  display: block;
  width: 100%;
  height: 100%;
  border: 1px solid rgb(255 255 255 / .22);
  border-radius: inherit;
  background: linear-gradient(145deg, var(--genre-glow, #48545e), #11161c 82%);
  color: #fff;
  transform: translate3d(0, 0, 0);
  animation: cinema-fan-drift var(--fan-float-duration, 3.4s) ease-in-out
    var(--fan-float-delay, 700ms) infinite;
  animation-play-state: paused;
}
.cinema-fan-float::before {
  position: absolute;
  z-index: -1;
  inset: -1px;
  border-radius: inherit;
  box-shadow: 0 17px 35px -15px rgb(0 0 0 / .72),
    0 5px 13px -5px rgb(0 0 0 / .55),
    0 0 0 1px rgb(255 255 255 / .04);
  opacity: 0;
  pointer-events: none;
  content: "";
  transition: opacity 180ms ease;
}
.cinema-fan-float::after {
  position: absolute;
  z-index: 1;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(165deg, rgb(255 255 255 / .12), transparent 38%),
    linear-gradient(180deg, transparent 25%, rgb(3 5 9 / .14) 53%, rgb(3 5 9 / .88));
  pointer-events: none;
  content: "";
}
.cinema-fan-deck.is-open .cinema-fan-float { animation-play-state: running; }
.cinema-fan-deck.is-open .cinema-fan-float::before { opacity: 1; }
.cinema-fan-deck.is-closing .cinema-fan-float { animation-play-state: paused; }
.cinema-fan-float > img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
  opacity: .96;
  pointer-events: none;
  -webkit-user-drag: none;
}
.cinema-fan-float > img[hidden] { display: none; }
.cinema-fan-title {
  position: absolute;
  z-index: 2;
  right: 10px;
  bottom: 9px;
  left: 10px;
  display: -webkit-box;
  overflow: hidden;
  color: #fbfbfc;
  font: 600 clamp(9px, .86vw, 13px)/1.25 "Space Grotesk", system-ui, sans-serif;
  letter-spacing: -.02em;
  text-shadow: 0 2px 7px rgb(0 0 0 / .55);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

@keyframes cinema-fan-drift {
  0%, 100% { transform: translate3d(0, 0, 0) rotateZ(0deg); }
  50% { transform: translate3d(0, -3px, 0) rotateZ(.6deg); }
}

/* A sampled damped spring adds a restrained overshoot where supported. */
@supports (transition-timing-function: linear(0, 1)) {
  .cinema-fan-layer {
    --fan-open-ease: linear(0, .036 6%, .145 15%, .43 29%, .79 46%,
      1.035 66%, 1.052 74%, 1.014 89%, 1);
    --fan-close-ease: linear(0, .075 7%, .29 21%, .63 42%, .87 62%,
      .98 82%, 1);
  }
}

@media (max-width: 560px) {
  .cinema-fan-card { border-radius: 9px; }
  .cinema-fan-title {
    right: 7px;
    bottom: 6px;
    left: 7px;
    font-size: clamp(8px, 2.4vw, 11px);
    line-height: 1.2;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cinema-fan-card,
  .cinema-fan-float,
  .cinema-fan-float::before {
    animation: none !important;
    transition: none !important;
  }
  .cinema-fan-float { transform: none !important; }
  .cinema-fan-deck.is-open .cinema-fan-card {
    transform: translate3d(var(--fan-x, 0px), var(--fan-y, 0px), 0);
  }
}
