/* ========================================================================
   TAMSIC — Hero Carousel
   Premium auto-sliding carousel for the homepage hero image frame.
   Pure CSS keyframes + transforms/opacity only (no layout reflow).
   Slots inside the existing .hero-img-frame — layout stays unchanged.
   ======================================================================== */

:root {
  /* Carousel-specific tuning (brand-aligned, overridable) */
  --hero-carousel-duration: 900ms;
  --hero-carousel-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --hero-carousel-shift: 7%;
}

/* The frame doubles as the carousel viewport. */
.hero-carousel {
  isolation: isolate;
}

/* Stage that stacks every slide on top of each other — no reflow. */
.hero-carousel-stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  border-radius: inherit;
}

/* Each slide fills the frame and is hidden until activated. */
.hero-slide {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  visibility: hidden;
  will-change: transform, opacity;
  backface-visibility: hidden;
  transform: translateZ(0);
  border-radius: inherit;
  overflow: hidden;
}

/* Image inherits the brand luminosity blend from base.css .hero-img-frame img.
   We add a slow, tasteful Ken-Burns elevation while the slide is active. */
.hero-slide img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

/* Soft brand glow + layered depth behind the active image. */
.hero-slide::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow:
    inset 0 0 90px rgba(5, 5, 5, 0.7),
    inset 0 -60px 80px rgba(5, 5, 5, 0.55);
  opacity: 0;
  transition: opacity var(--hero-carousel-duration) var(--hero-carousel-ease);
}

/* ---- Active slide ---- */
.hero-slide.is-active {
  opacity: 1;
  visibility: visible;
  z-index: 2;
}
.hero-slide.is-active::after {
  opacity: 1;
}
.hero-slide.is-active img {
  animation: heroKenBurns 7s var(--hero-carousel-ease) forwards;
}

/* ---- Entering / leaving (direction-aware) ---- */
.hero-slide.is-entering {
  visibility: visible;
  z-index: 3;
}
.hero-slide.is-leaving {
  visibility: visible;
  z-index: 2;
}

.hero-slide.enter-next {
  animation: heroSlideInRight var(--hero-carousel-duration)
    var(--hero-carousel-ease) both;
}
.hero-slide.leave-next {
  animation: heroSlideOutLeft var(--hero-carousel-duration)
    var(--hero-carousel-ease) both;
}
.hero-slide.enter-prev {
  animation: heroSlideInLeft var(--hero-carousel-duration)
    var(--hero-carousel-ease) both;
}
.hero-slide.leave-prev {
  animation: heroSlideOutRight var(--hero-carousel-duration)
    var(--hero-carousel-ease) both;
}

/* ======================== Keyframes ======================== */

/* Incoming from the right (next) — slide + subtle fade + scale settle. */
@keyframes heroSlideInRight {
  from {
    opacity: 0;
    transform: translate3d(var(--hero-carousel-shift), 0, 0) scale(1.05);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}
/* Outgoing to the left (next). */
@keyframes heroSlideOutLeft {
  from {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    opacity: 0;
    transform: translate3d(calc(var(--hero-carousel-shift) * -1), 0, 0)
      scale(0.97);
  }
}
/* Incoming from the left (prev). */
@keyframes heroSlideInLeft {
  from {
    opacity: 0;
    transform: translate3d(calc(var(--hero-carousel-shift) * -1), 0, 0)
      scale(1.05);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}
/* Outgoing to the right (prev). */
@keyframes heroSlideOutRight {
  from {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    opacity: 0;
    transform: translate3d(var(--hero-carousel-shift), 0, 0) scale(0.97);
  }
}
/* Slow image elevation on the resting active slide. */
@keyframes heroKenBurns {
  from {
    transform: scale(1.001);
  }
  to {
    transform: scale(1.06);
  }
}

/* ======================== Navigation dots ======================== */
.hero-carousel-dots {
  position: absolute;
  left: 50%;
  bottom: var(--md);
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
}
.hero-dot {
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(232, 230, 227, 0.45);
  background: transparent;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition:
    width var(--transition),
    border-color var(--transition),
    background var(--transition);
}
.hero-dot:hover {
  border-color: var(--bone);
}
.hero-dot:focus-visible {
  outline: 2px solid var(--crimson);
  outline-offset: 3px;
}
/* Active dot stretches into a brand-coloured pill with an autoplay fill. */
.hero-dot.is-active {
  width: 26px;
  border-color: var(--crimson);
  background: rgba(140, 0, 15, 0.25);
  box-shadow: 0 0 12px var(--crimson-glow);
}
.hero-dot.is-active::after {
  content: "";
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(0);
  background: var(--crimson);
}
/* Animate the fill across the autoplay interval (paused via JS on hover). */
.hero-dot.is-active.is-filling::after {
  animation: heroDotFill var(--hero-autoplay, 5000ms) linear forwards;
}
@keyframes heroDotFill {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

/* ======================== Accessibility ======================== */
@media (prefers-reduced-motion: reduce) {
  .hero-slide,
  .hero-slide img,
  .hero-slide.enter-next,
  .hero-slide.leave-next,
  .hero-slide.enter-prev,
  .hero-slide.leave-prev,
  .hero-dot,
  .hero-dot.is-active.is-filling::after {
    animation: none !important;
    transition: opacity 200ms linear !important;
  }
  .hero-slide.is-active img {
    transform: none;
  }
}
