/* ==========================================
   CAROUSEL DESKTOP POSITIONING FIX
   Addresses:
   1. Image display issues on devices >= 768px
   2. Dot navigation centering issues
   3. Hover glowing border effect
   4. Proper Disney+ aspect ratio dimensions
   5. Mobile content positioning and container width fix
   6. Mobile carousel height and positioning optimization - Disney+ accurate
   ========================================== */

/* ==========================================
   MOBILE FIRST: Disney+ accurate mobile dimensions (< 768px)
   ========================================== */

@media (max-width: 767px) {
  /* Mobile carousel container - compact like Disney+ */
  [data-set-style="hero_carousel"] {
    height: 50vh !important; /* Much more compact - matches Disney+ proportions */
    width: 100vw !important;
    position: relative !important;
    overflow: visible !important; /* Allow dots to show outside */
    /* Add padding around the container */
    padding: 0 16px !important; /* Side padding for breathing room */
    box-sizing: border-box !important;
    /* Position higher on screen like Disney+ */
    margin-top: 4vh !important;
  }

  /* Mobile carousel track - contained within padded area */
  .carousel-track {
    width: 100% !important;
    height: 100% !important;
    position: relative !important;
    border-radius: 12px !important; /* Round corners like Disney+ */
    overflow: hidden !important;
  }

  /* Mobile carousel items - compact content positioning */
  .carousel-item {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important; /* Center content vertically */
    justify-content: flex-start !important;
    /* Compact padding for Disney+ style */
    padding: 6vh 6vw 4vh 6vw !important; /* Top-heavy but compact */
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    background-image: var(--mobile-bg) !important;
    border-radius: 12px !important; /* Match track border radius */
  }

  /* Mobile content wrapper */
  .item-content-wrapper {
    position: relative !important;
    z-index: 10 !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  /* Mobile gradient overlay - adjusted for compact design */
  .item-gradient-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 100% !important; /* Cover entire compact content area */
    background: linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.6) 0%,
      rgba(0, 0, 0, 0.4) 30%,
      rgba(0, 0, 0, 0.2) 60%,
      rgba(0, 0, 0, 0.6) 100%
    ) !important;
    z-index: 5 !important;
    pointer-events: none !important;
    border-radius: 12px !important;
  }

  /* Mobile typography - optimized for compact design */
  .title-text {
    font-size: 1.8rem !important; /* Smaller for compact design */
    line-height: 1.1 !important;
    margin-bottom: 0.5rem !important;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.9) !important;
    color: white !important;
    text-align: left !important;
  }

  .title-logo {
    max-height: 70px !important; /* Much smaller for compact design */
    margin-bottom: 0.5rem !important;
  }

  .item-metadata {
    font-size: 0.8rem !important;
    margin-bottom: 0.5rem !important;
    gap: 0.4rem !important;
    color: rgba(255, 255, 255, 0.9) !important;
  }

  .promo-text {
    font-size: 0.9rem !important;
    line-height: 1.3 !important;
    margin-bottom: 1rem !important;
    max-width: 85% !important;
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.9) !important;
    color: rgba(255, 255, 255, 0.9) !important;
  }

  /* Mobile navigation dots - positioned just below content area like Disney+ */
  .carousel-navigation {
    position: absolute !important;
    bottom: -4vh !important; /* Just below the content area */
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 20 !important;
    display: flex !important;
    gap: 0.4rem !important;
    background: none !important; /* Remove background on mobile */
    backdrop-filter: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
  }

  /* Mobile navigation dots styling */
  .nav-dot {
    background: none !important;
    border: none !important;
    color: rgba(255, 255, 255, 0.5) !important;
    font-size: 1rem !important; /* Smaller dots for compact design */
    cursor: pointer !important;
    padding: 0.2rem !important;
    transition: color 0.3s ease !important;
    line-height: 1 !important;
  }

  .nav-dot:hover,
  .nav-dot.active,
  .nav-dot[aria-current="true"] {
    color: rgba(255, 255, 255, 1) !important;
  }

  /* Mobile navigation buttons - positioned within compact content area */
  .carousel-prev,
  .carousel-next {
    position: absolute !important;
    top: 50% !important; /* Center vertically within compact content area */
    transform: translateY(-50%) !important;
    z-index: 20 !important;
    background: rgba(0, 0, 0, 0.6) !important;
    border: none !important;
    border-radius: 50% !important;
    width: 2.2rem !important; /* Slightly smaller for compact design */
    height: 2.2rem !important;
    color: white !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .carousel-prev {
    left: 0.5rem !important; /* Position within the compact content area */
  }

  .carousel-next {
    right: 0.5rem !important;
  }

  .carousel-prev svg,
  .carousel-next svg {
    width: 1.1rem !important;
    height: 1.1rem !important;
  }

  /* Ensure mobile styles provide proper spacing for content below */
  .shelf-collections-wrapper {
    margin-top: 8vh !important; /* More space since carousel is more compact */
  }
}

/* ==========================================
   TABLET BREAKPOINT: Transition from mobile to desktop (768px - 1023px)
   ========================================== */

@media (min-width: 768px) and (max-width: 1023px) {
  /* Tablet-specific adjustments */
  [data-set-style="hero_carousel"] {
    padding: 0 24px !important; /* Slightly more padding on tablets */
    height: 45vh !important; /* Intermediate height for tablets */
    margin-top: 0 !important; /* Reset margin for tablets */
    overflow: hidden !important; /* Reset overflow for tablets */
  }
  
  .carousel-track {
    border-radius: 16px !important; /* Larger border radius on tablets */
  }
  
  .carousel-item {
    border-radius: 16px !important;
    align-items: flex-end !important; /* Bottom align for tablets */
    padding: 3rem 2rem 4rem 2rem !important;
  }

  /* Reset navigation for tablets */
  .carousel-navigation {
    bottom: 1.5rem !important;
    background: rgba(0, 0, 0, 0.4) !important;
    backdrop-filter: blur(10px) !important;
    border-radius: 2rem !important;
    padding: 0.75rem 1.25rem !important;
  }

  .nav-dot {
    font-size: 1.3rem !important;
    padding: 0.25rem !important;
  }

  /* Reset shelf spacing for tablets */
  .shelf-collections-wrapper {
    margin-top: 0 !important;
  }
}

/* ==========================================
   FIX 1: DESKTOP IMAGE DISPLAY (1024px+)
   ========================================== */

@media (min-width: 1024px) {
  
  /* Fix main carousel container sizing and overflow - UPDATED DIMENSIONS */
  [data-set-style="hero_carousel"] {
    width: 100vw !important;
    height: 45vh !important; /* Reduced from 60vh to match Disney+ */
    max-height: 600px !important; /* Increased from 500px for larger screens */
    min-height: 350px !important; /* Ensure minimum size */
    position: relative !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important; /* Remove padding on desktop */
    left: 50% !important;
    transform: translateX(-50%) !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    /* Ensure proper cinematic aspect ratio */
    aspect-ratio: 16/9 !important;
  }

  /* Fix carousel track to ensure full width */
  .carousel-track {
    width: 100% !important;
    height: 100% !important;
    position: relative !important;
    overflow: visible !important; /* Changed to visible for glowing border */
    padding: 8px !important; /* Add padding for glow effect */
    border-radius: 0 !important; /* Remove border radius on desktop */
  }

  /* CRITICAL: Fix carousel item background display */
  .carousel-item {
    position: absolute !important;
    top: 8px !important; /* Offset for glow effect */
    left: 8px !important; /* Offset for glow effect */
    width: calc(100% - 16px) !important; /* Account for glow padding */
    height: calc(100% - 16px) !important; /* Account for glow padding */
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    background-attachment: scroll !important;
    /* Ensure proper layering */
    z-index: 1 !important;
    /* Use desktop background image */
    background-image: var(--desktop-bg) !important;
    /* Reset any transforms that might crop the image */
    transform: none !important;
    /* Ensure full coverage */
    object-fit: cover !important;
    overflow: hidden !important;
    /* Proper flex alignment for content */
    display: flex !important;
    align-items: flex-end !important;
    justify-content: flex-start !important;
    /* Disney+ standard padding - adjusted for new dimensions */
    padding: 2rem calc(3.5vw + 24px) 4rem calc(3.5vw + 24px) !important;
    /* Border radius for modern look */
    border-radius: 12px !important;
    /* Transition for smooth glow effect */
    transition: all 0.3s ease !important;
    /* Default border (invisible) */
    border: 3px solid transparent !important;
    box-shadow: none !important;
  }

  /* ==========================================
     NEW: GLOWING BORDER EFFECT ON HOVER
     ========================================== */

  /* Hover effect with glowing green border */
  .carousel-item:hover {
    /* Bright green glowing border effect */
    border: 3px solid #00ff88 !important;
    box-shadow: 
      0 0 20px rgba(0, 255, 136, 0.6),
      0 0 40px rgba(0, 255, 136, 0.4),
      0 0 60px rgba(0, 255, 136, 0.2),
      inset 0 0 20px rgba(0, 255, 136, 0.1) !important;
    /* Slight scale up for emphasis */
    transform: scale(1.01) !important;
  }

  /* Ensure active items are properly displayed */
  .carousel-item[data-isactive="true"],
  .carousel-item.active {
    opacity: 1 !important;
    visibility: visible !important;
    z-index: 3 !important;
  }

  .carousel-item[data-isactive="false"],
  .carousel-item:not(.active) {
    opacity: 0 !important;
    visibility: hidden !important;
    z-index: 1 !important;
  }

  /* Enhanced gradient overlay for better text readability */
  .item-gradient-overlay {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 70% !important; /* Increased from 60% for better text readability */
    background: linear-gradient(
      to top,
      rgba(0, 0, 0, 0.9) 0%,
      rgba(0, 0, 0, 0.7) 30%,
      rgba(0, 0, 0, 0.3) 60%,
      transparent 100%
    ) !important;
    z-index: 4 !important;
    pointer-events: none !important;
    /* Match border radius */
    border-radius: 0 0 9px 9px !important;
  }

  /* Content positioning - adjusted for new dimensions */
  .item-content-wrapper {
    position: relative !important;
    z-index: 5 !important;
    max-width: 65% !important; /* Increased from 60% for better text display */
    padding-bottom: 0 !important;
  }

  /* ==========================================
     FIX 2: DOT NAVIGATION CENTERING
     ========================================== */

  /* Reset any conflicting navigation styles */
  .carousel-navigation {
    position: absolute !important;
    bottom: 1.5rem !important; /* Reduced from 2rem for new dimensions */
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 20 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
    /* Enhanced styling for better visibility */
    background: rgba(0, 0, 0, 0.4) !important;
    backdrop-filter: blur(10px) !important;
    border-radius: 2rem !important;
    padding: 0.75rem 1.25rem !important;
    /* Ensure proper centering */
    width: auto !important;
    margin: 0 !important;
    /* Remove any margin/padding that might affect centering */
    box-sizing: border-box !important;
  }

  /* Navigation dots styling */
  .nav-dot {
    background: none !important;
    border: none !important;
    color: rgba(255, 255, 255, 0.5) !important;
    font-size: 1.5rem !important;
    cursor: pointer !important;
    padding: 0.25rem !important;
    transition: color 0.3s ease, transform 0.2s ease !important;
    line-height: 1 !important;
    border-radius: 50% !important;
    width: auto !important;
    height: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .nav-dot:hover {
    color: rgba(255, 255, 255, 0.8) !important;
    transform: scale(1.2) !important;
  }

  .nav-dot.active,
  .nav-dot[aria-current="true"] {
    color: rgba(255, 255, 255, 1) !important;
  }

  .nav-dot:focus-visible {
    outline: 2px solid white !important;
    outline-offset: 4px !important;
  }

  /* ==========================================
     FIX 3: NAVIGATION BUTTONS POSITIONING
     ========================================== */

  .carousel-prev,
  .carousel-next {
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 20 !important;
    background: rgba(42, 42, 42, 0.8) !important;
    border: none !important;
    border-radius: 50% !important;
    width: 3rem !important;
    height: 3rem !important;
    color: white !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    backdrop-filter: blur(10px) !important;
    transition: all 0.3s ease !important;
    cursor: pointer !important;
  }

  .carousel-prev:hover,
  .carousel-next:hover {
    background: rgba(42, 42, 42, 1) !important;
    transform: translateY(-50%) scale(1.1) !important;
    /* Subtle green glow on hover */
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.3) !important;
  }

  .carousel-prev {
    left: 2rem !important;
  }

  .carousel-next {
    right: 2rem !important;
  }

  .carousel-prev svg,
  .carousel-next svg {
    width: 1.5rem !important;
    height: 1.5rem !important;
  }

  /* ==========================================
     FIX 4: CONTENT CONTAINER ADJUSTMENTS
     ========================================== */

  /* Ensure main container doesn't create horizontal scroll */
  main#browse.remove-main-padding {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
  }

  /* Reset Disney+ wrapper classes that might interfere */
  .x8kqcf0.basj101,
  ._8vuruf0 {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  /* ==========================================
     FIX 5: TYPOGRAPHY IMPROVEMENTS - ADJUSTED FOR NEW DIMENSIONS
     ========================================== */

  .title-text {
    font-size: 3.5rem !important; /* Reduced from 4rem for new dimensions */
    line-height: 1.1 !important;
    margin-bottom: 1rem !important; /* Reduced from 1.5rem */
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.9) !important;
    color: white !important;
  }

  .title-logo {
    max-height: 100px !important; /* Reduced from 120px for new dimensions */
    margin-bottom: 1rem !important; /* Reduced from 1.5rem */
  }

  .item-metadata {
    font-size: 0.95rem !important; /* Slightly reduced from 1rem */
    margin-bottom: 1.5rem !important; /* Reduced from 2rem */
    gap: 0.75rem !important;
    color: rgba(255, 255, 255, 0.9) !important;
  }

  .promo-text {
    font-size: 1.1rem !important; /* Slightly reduced from 1.125rem */
    line-height: 1.5 !important; /* Reduced from 1.6 for tighter spacing */
    margin-bottom: 2rem !important; /* Reduced from 2.5rem */
    max-width: 85% !important; /* Increased from 80% for better use of space */
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.9) !important;
    color: rgba(255, 255, 255, 0.9) !important;
  }

  /* Reset shelf collections spacing for desktop */
  .shelf-collections-wrapper {
    margin-top: 0 !important;
  }
}

/* ==========================================
   FIX 6: LARGE DESKTOP OPTIMIZATION (1200px+)
   ========================================== */

@media (min-width: 1200px) {
  /* Slightly larger dimensions for large screens */
  [data-set-style="hero_carousel"] {
    height: 50vh !important; /* Increased from 45vh for large screens */
    max-height: 700px !important; /* Increased from 600px */
  }

  .title-text {
    font-size: 4.5rem !important; /* Increased for large screens */
  }

  .title-logo {
    max-height: 120px !important; /* Restored for large screens */
  }

  .item-metadata {
    font-size: 1rem !important;
    margin-bottom: 1.75rem !important;
  }

  .promo-text {
    font-size: 1.2rem !important;
    line-height: 1.6 !important;
    margin-bottom: 2.25rem !important;
  }

  .item-content-wrapper {
    max-width: 60% !important; /* Reduced from 50% for better balance */
  }

  .carousel-prev {
    left: 3rem !important;
  }

  .carousel-next {
    right: 3rem !important;
  }

  .carousel-navigation {
    bottom: 2.5rem !important; /* Increased for large screens */
  }
}

/* ==========================================
   FIX 7: ULTRA-WIDE SCREEN SUPPORT (1440px+)
   ========================================== */

@media (min-width: 1440px) {
  [data-set-style="hero_carousel"] {
    height: 55vh !important; /* Further increased for ultra-wide */
    max-height: 800px !important;
  }

  .carousel-item {
    /* Ensure images maintain center focus on ultra-wide screens */
    background-position: center 30% !important;
  }

  .item-content-wrapper {
    max-width: 55% !important; /* Reduced for ultra-wide screens */
  }

  .title-text {
    font-size: 5rem !important;
  }
}

/* ==========================================
   FIX 8: ENHANCED HOVER EFFECTS (DESKTOP ONLY)
   ========================================== */

@media (min-width: 1024px) {
  /* Subtle pulsing animation for the hover glow effect */
  @keyframes carousel-glow-pulse {
    0%, 100% {
      box-shadow: 
        0 0 20px rgba(0, 255, 136, 0.6),
        0 0 40px rgba(0, 255, 136, 0.4),
        0 0 60px rgba(0, 255, 136, 0.2),
        inset 0 0 20px rgba(0, 255, 136, 0.1);
    }
    50% {
      box-shadow: 
        0 0 25px rgba(0, 255, 136, 0.8),
        0 0 50px rgba(0, 255, 136, 0.6),
        0 0 75px rgba(0, 255, 136, 0.3),
        inset 0 0 25px rgba(0, 255, 136, 0.15);
    }
  }

  /* Apply subtle pulsing animation on hover */
  .carousel-item:hover {
    animation: carousel-glow-pulse 2s ease-in-out infinite !important;
  }

  /* Disable animation for users who prefer reduced motion */
  @media (prefers-reduced-motion: reduce) {
    .carousel-item:hover {
      animation: none !important;
    }
  }

  /* Enhanced text contrast on hover */
  .carousel-item:hover .title-text,
  .carousel-item:hover .item-metadata,
  .carousel-item:hover .promo-text {
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 1) !important;
  }

  /* Subtle dot hover enhancement */
  .nav-dot:hover {
    color: rgba(255, 255, 255, 0.8) !important;
    transform: scale(1.2) !important;
    text-shadow: 0 0 5px rgba(0, 255, 136, 0.3) !important;
  }
}
