/* ==========================================================================
   MOVIE RAILS & CARDS CSS (Strict Per-Card Hover Targeting)
   ========================================================================== */

.rails-container {
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 5;
}

.movie-rail {
  position: relative;
  width: 100%;
  content-visibility: auto;
  contain: layout paint style;
  contain-intrinsic-size: auto 280px;
}

.rail-scroll-wrapper {
  position: relative;
  width: 100%;
}

.rail-track {
  display: flex;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  contain: layout paint;
  transform: translateZ(0);
}

.rail-track::-webkit-scrollbar {
  display: none;
}

/* Strictly target ONLY the single hovered card */
.movie-card.card-single-group:hover .card-hover-overlay {
  opacity: 1 !important;
  pointer-events: auto !important;
}

.movie-card.card-single-group:hover .card-poster {
  transform: scale(1.05);
}

.movie-card.card-single-group:hover .card-img {
  transform: scale(1.1);
  filter: brightness(1);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
  animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Premium Apple-Style Text Unblur Animation */
@keyframes textUnblur {
  from {
    opacity: 0;
    filter: blur(8px);
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    filter: blur(0px);
    transform: translateY(0);
  }
}

.animate-text-unblur {
  animation: textUnblur 400ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Ensure backdrop image transitions smoothly on load inside portal */
.portal-bg-img {
  will-change: opacity, filter, transform;
}

/* Portal Card Box Smooth Spring Transitions */
.portal-card-box {
  transition: transform 600ms cubic-bezier(0.34, 1.56, 0.64, 1),
              background-color 300ms ease;
  will-change: transform;
}

.portal-card-box.expanded {
  width: 420px !important;
  height: 440px !important;
}

@media (max-width: 640px) {
  .portal-card-box.expanded {
    width: 320px !important;
    height: 380px !important;
  }
}

/* Dynamic Scroll Edge Fades for Rails (Tactile Momentum Visual Indicators) */
.rail-track {
  mask-image: linear-gradient(to right, black 88%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, black 88%, transparent 100%);
  transition: mask-image 0.25s ease, -webkit-mask-image 0.25s ease;
}

.rail-track.can-scroll-left {
  mask-image: linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
}

.rail-track.is-at-end {
  mask-image: linear-gradient(to left, black 88%, transparent 100%);
  -webkit-mask-image: linear-gradient(to left, black 88%, transparent 100%);
}

.rail-track.is-at-start-and-end {
  mask-image: none !important;
  -webkit-mask-image: none !important;
}

/* Subtle Hover Stopwatch Pill */
.hover-timer-pill {
  opacity: 0;
  transition: opacity 200ms ease;
  transition-delay: 0s;
  pointer-events: none;
}

.fantom-card:hover .hover-timer-pill {
  opacity: 1;
  /* Delays the fade-in until the timer is halfway (425ms of 850ms hover delay) */
  transition-delay: 425ms;
}

.hover-timer-pill-content {
  transform: scale(0.85);
  transition: transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
  transition-delay: 0s;
}

.fantom-card:hover .hover-timer-pill-content {
  transform: scale(1);
  transition-delay: 425ms;
}

.hover-timer-circle {
  stroke-dasharray: 50.26;
  stroke-dashoffset: 50.26;
  /* Reset instantly when hover is lost */
  transition: stroke-dashoffset 0s;
}

.fantom-card:hover .hover-timer-circle {
  stroke-dashoffset: 0;
  /* Fills completely in 850ms, starting immediately on hover */
  transition: stroke-dashoffset 850ms linear;
}

/* ==========================================================================
   PILLOWY TACTILE MOTION & SOFT HOVER LIGHTING (APPLE TV LUXURY STYLE)
   ========================================================================== */

/* 1. Tactile Shadows & Ambient Depth */
body.pillowy-motion .fantom-card .smart-skeleton-container,
body.pillowy-motion .fantom-card img,
body.pillowy-motion .movie-card .smart-skeleton-container,
body.pillowy-motion .movie-card img {
  box-shadow: 0 10px 24px -8px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  transition: box-shadow 400ms cubic-bezier(0.16, 1, 0.3, 1),
              transform 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* 2. Apple-Style Fluid Spring Physics */
body.pillowy-motion .fantom-card {
  transition: transform 500ms cubic-bezier(0.16, 1, 0.3, 1),
              filter 500ms cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

/* 3. Soft Hover Lighting & Elevation Lift */
body.pillowy-motion .fantom-card:hover {
  transform: translateY(-6px) scale(1.045) !important;
}

body.pillowy-motion .fantom-card:hover .smart-skeleton-container {
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.85),
              0 0 35px 2px var(--theme-glow, rgba(255, 255, 255, 0.2)),
              inset 0 0 0 1.5px rgba(255, 255, 255, 0.35) !important;
}

/* 4. Soft Press-Down Feedback */
body.pillowy-motion .fantom-card:active {
  transform: translateY(-1px) scale(0.97) !important;
  transition-duration: 150ms !important;
}


