/* Ghost Mannequin Section Styles */
.ghost-section {
  height: 250vh; /* Reduced height for faster scrolling */
  display: block;
  /* Simplified gradient - only 2 colors for better performance */
  background: linear-gradient(135deg, #1a1a2e 0%, #0f0f23 100%);
  padding: 0 80px;
  position: relative;
  overflow: visible;
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  contain: layout style;
  content-visibility: auto;
  contain-intrinsic-size: auto 250vh;
}

/* Fog/mist overlay effect - simplified for performance */
.ghost-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at 50% 50%, rgba(100, 100, 150, 0.03) 0%, transparent 60%);
  pointer-events: none;
  z-index: 1;
}

/* Haunted floating images */
.haunted-images {
  position: relative;
  height: 120px;
  margin-bottom: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 15px;
}

.haunted-img {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  overflow: hidden;
  opacity: 0;
  filter: grayscale(30%) brightness(0.8);
  box-shadow: 
    0 0 20px rgba(255, 255, 255, 0.1),
    0 0 40px rgba(100, 100, 150, 0.1),
    0 10px 30px rgba(0, 0, 0, 0.3);
  animation: hauntedFloat 4s ease-in-out infinite;
  transform-origin: center center;
}

.haunted-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.haunted-1 {
  animation-delay: 0s;
  transform: translateY(10px);
}

.haunted-2 {
  animation-delay: 0.5s;
  transform: translateY(-5px);
}

.haunted-3 {
  animation-delay: 1s;
  transform: translateY(15px);
}

/* Haunted float animation */
@keyframes hauntedFloat {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
    opacity: 0.7;
  }
  25% {
    transform: translateY(-15px) rotate(-2deg);
    opacity: 0.9;
  }
  50% {
    transform: translateY(-8px) rotate(1deg);
    opacity: 0.6;
  }
  75% {
    transform: translateY(-20px) rotate(-1deg);
    opacity: 0.85;
  }
}

/* Ghostly glow pulse */
.haunted-img::after {
  content: '';
  position: absolute;
  top: -5px;
  left: -5px;
  right: -5px;
  bottom: -5px;
  border-radius: 16px;
  background: transparent;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
  animation: ghostGlow 3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes ghostGlow {
  0%, 100% {
    opacity: 0.3;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
  }
  50% {
    opacity: 0.7;
    box-shadow: 0 0 25px rgba(200, 200, 255, 0.3);
  }
}

.ghost-wrapper {
  max-width: 100%;
  width: 100%;
  height: 100vh;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 2;
  pointer-events: none;
  padding: 100px 0;
  box-sizing: border-box;
  gap: 60px;
}

.ghost-wrapper * {
  pointer-events: auto;
}

/* Comparison Cards - Left Side */
.ghost-comparison-wrapper {
  position: relative;
  width: 500px;
  height: 650px;
  flex-shrink: 0;
  opacity: 0;
  transform: translate3d(0, 100%, 0);
  
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.ghost-comparison-wrapper.rocket-enter {
  animation: ghostRocketEntrance 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes ghostRocketEntrance {
  0% {
    opacity: 0;
    transform: translate3d(0, 100%, 0);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

.ghost-comparison-card {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translate3d(0, 100px, 0);
  transition: opacity 0.4s ease-out, transform 0.4s ease-out;
  
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  contain: strict;
  
}

.ghost-comparison-card.active {
  opacity: 1;
  transform: translate3d(0, 0, 0);
  z-index: 3;
}

.ghost-comparison-card.prev {
  opacity: 0.5;
  transform: translate3d(0, -30px, 0);
  z-index: 2;
  pointer-events: none;
}

.ghost-comparison-card.next {
  opacity: 0;
  transform: translate3d(0, 50px, 0);
  z-index: 1;
  pointer-events: none;
}

.ghost-comparison-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: ew-resize;
}

.ghost-comparison-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: translateZ(0);
  backface-visibility: hidden;
  transform: translateZ(0);
}

.ghost-comparison-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}

.ghost-comparison-image.before {
  z-index: 1;
  clip-path: inset(0 50% 0 0);
  backface-visibility: hidden;
}

/* Only animate the active card */
.ghost-comparison-card.active .ghost-comparison-image.before {
  animation: ghostSliderReveal 6s linear infinite;
}

.ghost-comparison-container.user-interacting .ghost-comparison-image.before {
  animation: none !important;
}

@keyframes ghostSliderReveal {
  0% { clip-path: inset(0 95% 0 0); }
  50% { clip-path: inset(0 5% 0 0); }
  100% { clip-path: inset(0 95% 0 0); }
}

.ghost-comparison-image.after {
  z-index: 0;
}

/* Ghost Slider */
.ghost-comparison-slider {
  position: absolute;
  top: 0;
  width: 44px;
  background: transparent;
  left: 50%;
  width: 4px;
  height: 100%;
  z-index: 10;
  transform: translateX(-50%);
  cursor: ew-resize;
}

/* Only animate the active card's slider */
.ghost-comparison-card.active .ghost-comparison-slider {
  animation: ghostSliderMove 6s linear infinite;
}

.ghost-comparison-container.user-interacting .ghost-comparison-slider {
  animation: none !important;
}

@keyframes ghostSliderMove {
  0% { left: 5%; }
  50% { left: 95%; }
  100% { left: 5%; }
}

.ghost-slider-line {
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 100%;
  background: #ffffff;
  transform: translateX(-50%);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

.ghost-slider-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  background: #ffffff;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  cursor: ew-resize;
}

.ghost-slider-handle span {
  width: 20px;
  height: 2px;
  background: #333;
  border-radius: 1px;
}

/* Text Content - Right Side */
.ghost-container {
  max-width: 650px;
  flex-shrink: 0;
  text-align: right;
}

.ghost-content {
  text-align: right;
}

.ghost-heading {
  font-size: 4rem;
  font-weight: 700;
  margin-bottom: 2rem;
  color: #ffffff;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.3em;
  line-height: 1.2;
}

/* Word animation */
.ghost-heading .word {
  display: inline-block;
  opacity: 0;
  transform: translateY(50px) scale(0.8);
  transform-origin: center bottom;
}

.ghost-heading.in-view .word {
  animation: ghostWordRise 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.ghost-heading.in-view .word:nth-child(1) { animation-delay: 0s; }
.ghost-heading.in-view .word:nth-child(2) { animation-delay: 0.15s; }

@keyframes ghostWordRise {
  0% {
    opacity: 0;
    transform: translateY(50px) scale(0.8);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Ghost effect on heading */
.ghost-heading .word:first-child {
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.5), 0 0 40px rgba(255, 255, 255, 0.3);
}

.ghost-text {
  font-family: 'Space Mono', monospace;
  font-size: 1.2rem;
  font-weight: 400;
  line-height: 1.8;
  color: rgba(255, 255, 255, 0.9);
  letter-spacing: 0.01em;
  min-height: 150px;
}

/* Falling word animation */
.ghost-text .word {
  display: inline-block;
  opacity: 1;
  transform: translateY(0);
  margin-right: 0.35em;
}

.ghost-text .word.animate {
  opacity: 0;
  transform: translateY(-40px);
  animation: ghostWordFall 0.5s ease-out forwards;
}

@keyframes ghostWordFall {
  0% {
    opacity: 0;
    transform: translateY(-40px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}


/* Responsive - Large Tablet / iPad Landscape */
@media (max-width: 1366px) {
  .ghost-section {
    padding: 0 60px;
  }
  
  .ghost-comparison-wrapper {
    width: 450px;
    height: 600px;
  }
  
  .ghost-container {
    max-width: 450px;
  }
}

/* Responsive - Desktop / iPad Pro Portrait */
@media (max-width: 1200px) {
  .ghost-wrapper {
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  
  .ghost-container {
    max-width: 100%;
    text-align: center;
    margin-top: 40px;
  }
  
  .ghost-content {
    text-align: center;
  }
  
  .ghost-heading {
    justify-content: center;
  }
  
  .ghost-comparison-wrapper {
    width: 420px;
    height: 550px;
    max-width: 90vw;
  }
}

/* Responsive - Tablet / iPad Portrait */
@media (max-width: 1024px) {
  .ghost-section {
    padding: 0 40px;
  }
  
  .ghost-heading {
    font-size: 3rem;
  }
  
  .ghost-text {
    font-size: 1.1rem;
  }
  
  .ghost-comparison-wrapper {
    width: 380px;
    height: 500px;
    max-width: 85vw;
  }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
  .ghost-section {
    padding: 60px 20px;
    height: auto;
    min-height: 100vh;
  }
  
  .ghost-wrapper {
    padding: 20px 0;
    gap: 30px;
    height: auto;
    min-height: auto;
    position: relative;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
  }
  
  .ghost-container {
    position: relative;
    z-index: 10;
    max-width: 100%;
    text-align: center;
  }
  
  .ghost-content {
    text-align: center;
  }
  
  .ghost-heading {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    justify-content: center;
  }
  
  /* Force heading words to be visible on mobile */
  .ghost-heading .word {
    opacity: 1 !important;
    transform: translateY(0) scale(1) !important;
    animation: none !important;
  }
  
  .ghost-text {
    font-size: 1rem;
    line-height: 1.7;
    min-height: auto;
    opacity: 1 !important;
    margin-bottom: 30px;
  }
  
  /* Force falling text words to be visible */
  .ghost-text .word {
    opacity: 1 !important;
    transform: translateY(0) !important;
  }
  
  .ghost-comparison-wrapper {
    position: relative !important;
    transform: none !important;
    opacity: 1 !important;
    width: 100%;
    max-width: 320px;
    height: 420px;
    margin: 0 auto;
  }
  
  .ghost-comparison-wrapper.rocket-enter {
    animation: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
  
  .ghost-slider-handle {
    width: 36px;
    height: 36px;
  }
  
  /* GPU optimization for mobile */
  .ghost-comparison-card {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }
  
  .ghost-comparison-image.before {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }
  
  /* Enable auto slider animation on mobile */
  .ghost-comparison-card.active .ghost-comparison-image.before {
    animation: ghostSliderReveal 5s linear infinite !important;
  }
  
  .ghost-comparison-card.active .ghost-comparison-slider {
    animation: ghostSliderMove 5s linear infinite !important;
  }
  
  /* Pause animation when user is interacting */
  .ghost-comparison-container.user-interacting .ghost-comparison-image.before,
  .ghost-comparison-container.user-interacting .ghost-comparison-slider {
    animation: none !important;
  }
}

/* Responsive - Small Mobile */
@media (max-width: 480px) {
  .ghost-section {
    padding: 40px 15px;
  }
  
  .ghost-heading {
    font-size: 2rem;
  }
  
  .ghost-text {
    font-size: 0.9rem;
    min-height: auto;
  }
  
  .ghost-comparison-wrapper {
    max-width: 280px;
    height: 380px;
  }
}
