/* Color Correction Section Styles */
.color-section {
  height: 200vh; /* Extended height for scroll-based card stacking */
  display: block;
  /* Simplified gradient - only 2 colors for better performance */
  background: linear-gradient(135deg, #1a1a2e 0%, #0f3460 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 200vh;
}

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

/* Text Content - Left Side */
.color-container {
  max-width: 650px;
  flex-shrink: 0;
  text-align: left;
}

.color-content {
  text-align: left;
}

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

/* Word animation */
.color-heading .word {
  display: inline-block;
  opacity: 0;
  transform: translateX(-50px) rotate(-5deg);
  transform-origin: left center;
}

.color-heading.in-view .word {
  animation: colorWordSlide 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

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

@keyframes colorWordSlide {
  0% {
    opacity: 0;
    transform: translateX(-50px) rotate(-5deg);
  }
  70% {
    opacity: 1;
    transform: translateX(5px) rotate(1deg);
  }
  100% {
    opacity: 1;
    transform: translateX(0) rotate(0deg);
  }
}

/* Color gradient effect on "Color" word */
.color-heading .word:first-child {
  background: linear-gradient(90deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.color-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 */
.color-text .word {
  display: inline-block;
  opacity: 1;
  transform: translateY(0);
  margin-right: 0.35em;
}

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

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

/* Comparison Card - Right Side */
.color-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;
}

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

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

.color-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;
  
}

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

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

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

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

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

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

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

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

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

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

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

/* Color Slider */
.color-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 */
.color-comparison-card.active .color-comparison-slider {
  animation: colorSliderMove 6s linear infinite;
}

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

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

.color-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);
}

.color-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;
}

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


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

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

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

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

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