/* Retouch Section Styles */
.retouch-section {
  height: 200vh;
  display: block;
  background: #c9184a;
  padding: 0 80px;
  position: relative;
  overflow: visible;
  contain: layout style;
  isolation: isolate;
  z-index: 2;
}

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

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

.retouch-container {
  position: absolute;
  right: 40px;
  top: 50%;
  transform: translateY(-50%);
  max-width: 650px;
  flex-shrink: 0;
  text-align: left;
  z-index: 10;
}

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

.retouch-heading {
  font-size: 4rem;
  font-weight: 700;
  margin-bottom: 2rem;
  color: #ffffff;
  display: inline-block;
}

/* Inflating letter animation */
.retouch-heading .letter {
  display: inline-block;
  opacity: 0;
  transform: scale(0);
  transform-origin: center center;
}

.retouch-heading.in-view .letter {
  animation: letterInflate 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.retouch-heading.in-view .letter:nth-child(1) { animation-delay: 0s; }
.retouch-heading.in-view .letter:nth-child(2) { animation-delay: 0.1s; }
.retouch-heading.in-view .letter:nth-child(3) { animation-delay: 0.2s; }
.retouch-heading.in-view .letter:nth-child(4) { animation-delay: 0.3s; }
.retouch-heading.in-view .letter:nth-child(5) { animation-delay: 0.4s; }
.retouch-heading.in-view .letter:nth-child(6) { animation-delay: 0.5s; }
.retouch-heading.in-view .letter:nth-child(7) { animation-delay: 0.6s; }

@keyframes letterInflate {
  0% {
    opacity: 0;
    transform: scale(0);
  }
  50% {
    opacity: 1;
    transform: scale(1.3);
  }
  70% {
    transform: scale(0.9);
  }
  85% {
    transform: scale(1.1);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

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

.retouch-text .word.animate {
  opacity: 0;
  transform: translateY(-50px);
  animation: wordFall 0.5s ease-out forwards;
}

@keyframes wordFall {
  0% {
    opacity: 0;
    transform: translateY(-50px) rotate(-5deg);
  }
  60% {
    transform: translateY(5px) rotate(1deg);
  }
  80% {
    transform: translateY(-2px) rotate(0deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }
}


/* Retouch Comparison Cards - Left Side */
.retouch-comparison-wrapper {
  position: absolute;
  left: 40px;
  top: 50%;
  width: 500px;
  height: 650px;
  transform: translate3d(0, calc(-50% + 100%), 0);
  opacity: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  z-index: 10;
}

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

@keyframes retouchRocketEntrance {
  0% {
    opacity: 0;
    transform: translate3d(0, calc(-50% + 100%), 0);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, -50%, 0);
  }
}

.retouch-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.3);
  opacity: 0;
  transform: translate3d(0, 100px, 0);
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  contain: strict;
  will-change: transform, opacity;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/* Responsive - Desktop / iPad Pro Portrait */
@media (max-width: 1200px) {
  .retouch-wrapper {
    flex-direction: column-reverse;
    align-items: center;
    justify-content: center;
  }
  
  .retouch-container {
    position: relative;
    right: auto;
    top: auto;
    transform: none;
    max-width: 100%;
    text-align: center;
    margin-bottom: 40px;
  }
  
  .retouch-comparison-wrapper {
    position: relative;
    left: auto;
    top: auto;
    margin-top: 0;
    width: 420px;
    height: 550px;
    max-width: 90vw;
  }
  
  .retouch-comparison-card {
    width: 100%;
    height: 100%;
  }
}

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

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

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