/* Precision scientific motion & micro-interactions (respects prefers-reduced-motion). */

.scroll-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--spectrum, linear-gradient(90deg,#6b57c9,#4559d8 17%,#248dd5 30%,#37b1a5 45%,#83ba6d 57%,#e5ca64 71%,#d78855 85%,#ae5469));
  transform-origin: left center;
  transform: scaleX(0);
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  transition: opacity .25s ease;
}
.scroll-progress.is-visible { opacity: .95; }

/* Carousel auto-play progress hairline */
.carousel-progress {
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: rgb(33 71 141 / .1);
  overflow: hidden;
  pointer-events: none;
}
.carousel-progress-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #1d4284, #234ee8, #248dd5);
  transform-origin: left center;
  transform: scaleX(0);
}
.carousel-progress.is-running .carousel-progress-fill {
  animation: carousel-tick var(--carousel-duration, 7000ms) linear forwards;
}
.carousel-progress.is-paused .carousel-progress-fill {
  animation-play-state: paused;
}
@keyframes carousel-tick {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* Layered subtle text entrance when switching hero slides */
.carousel-ready .instrument-slide:not([hidden]) :is(.campaign-copy > :first-child, .instrument-copy .instrument-tagline) {
  animation: hero-layer-in .48s cubic-bezier(.22, 1, .36, 1) both;
}
.carousel-ready .instrument-slide:not([hidden]) :is(.campaign-copy p, .instrument-copy :is(h1, .carousel-model-title)) {
  animation: hero-layer-in .52s cubic-bezier(.22, 1, .36, 1) .06s both;
}
.carousel-ready .instrument-slide:not([hidden]) :is(.campaign-actions, .instrument-copy .instrument-name, .instrument-copy .instrument-summary, .instrument-copy .en-hero-summary, .stage-actions) {
  animation: hero-layer-in .54s cubic-bezier(.22, 1, .36, 1) .12s both;
}
.carousel-ready .instrument-slide:not([hidden]) .campaign-photo {
  animation: hero-photo-in .58s cubic-bezier(.22, 1, .36, 1) .08s both;
}
@keyframes hero-layer-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes hero-photo-in {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Smooth detail glide for Application Showcase accordion */
.application-showcase__detail:not([hidden]) p {
  animation: detail-glide-in .32s cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes detail-glide-in {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Scroll-triggered staggered reveal (only applied below the initial fold) */
.reveal-pending {
  opacity: 0;
  transform: translateY(16px);
  will-change: opacity, transform;
}
.reveal-in {
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity .52s cubic-bezier(.22, 1, .36, 1) var(--reveal-delay, 0ms),
    transform .58s cubic-bezier(.22, 1, .36, 1) var(--reveal-delay, 0ms);
}

/* Subtle frosted back-to-top floating button */
.back-to-top {
  position: fixed;
  right: clamp(16px, 2.2vw, 30px);
  bottom: clamp(18px, 2.4vw, 32px);
  z-index: 18;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #cdd9e8;
  border-radius: 50%;
  background: rgb(255 255 255 / .92);
  color: var(--navy, #142847);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 26px -10px rgb(15 31 56 / .28);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity .26s ease, transform .28s cubic-bezier(.22, 1, .36, 1), background .2s ease, border-color .2s ease, color .2s ease;
}
.back-to-top.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.back-to-top:hover {
  background: var(--blue, #21478d);
  border-color: var(--blue, #21478d);
  color: #fff;
  transform: translateY(-2px);
}
.back-to-top svg { width: 19px; height: 19px; }

@media (prefers-reduced-motion: reduce) {
  .carousel-progress.is-running .carousel-progress-fill,
  .carousel-ready .instrument-slide:not([hidden]) :is(.campaign-copy > *, .instrument-copy > *, .campaign-photo),
  .application-showcase__detail:not([hidden]) p {
    animation: none !important;
  }
  .reveal-pending, .reveal-in {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}
