/* The stage keeps the existing photo and name-card geometry at every breakpoint. */
.hero-pet-stage,
.hero-pet-stage > .hero-pet-slide {
  position: relative;
  display: block;
  width: 100%;
}

.hero-pet-stage { isolation: isolate; }
.hero-pet-stage > .hero-pet-slide { z-index: 1; }
.hero-pet-stage .hero-photo { display: block; }

/* Let the browser own vertical scrolling and pinch zoom. Horizontal touch
   gestures are handled locally by the carousel, without a scroll-blocking listener. */
.hero-pet-stage { touch-action: pan-y pinch-zoom; }
.hero-pet-stage .hero-photo,
.hero-pet-stage .hero-name-card {
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* Controls stay still while the photo and its name card turn underneath. */
.hero-pet-nav {
  position: absolute;
  z-index: 3;
  top: 54%;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transform: translateY(-50%);
  pointer-events: none;
}

.hero-pet-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 48px;
  width: 48px;
  min-width: 44px;
  height: 48px;
  min-height: 44px;
  padding: 0;
  border: 1px solid #69559533;
  border-radius: 50%;
  color: var(--purple-dark);
  background: #fffdf9f5;
  box-shadow: 0 4px 18px #302b361a;
  pointer-events: auto;
  touch-action: manipulation;
  transition: background .3s ease, border-color .3s ease, box-shadow .3s ease, transform .3s ease;
}

.hero-pet-arrow svg { width: 20px; height: 20px; }
.hero-pet-arrow:focus-visible {
  outline: 3px solid var(--purple-dark);
  outline-offset: 3px;
  background: #fffdf9;
  box-shadow: 0 0 0 3px #fffdf9, 0 4px 18px #302b361a;
}
.hero-pet-arrow:active:not(:disabled):not([aria-disabled="true"]) { transform: scale(.96); }
.hero-pet-arrow:disabled,
.hero-pet-arrow[aria-disabled="true"] {
  opacity: .5;
  cursor: default;
  transform: none;
}

.hero-pet-stage[data-swipe-direction="previous"] [data-hero-pet-prev],
.hero-pet-stage[data-swipe-direction="next"] [data-hero-pet-next] {
  background: var(--lilac);
  border-color: #69559570;
  box-shadow: 0 0 0 4px #eee8f580, 0 6px 20px #302b3624;
}

.hero-pet-wheel-hint { display: none; }
.hero-pet-touch-hint { display: inline; }

@media (hover: hover) and (pointer: fine) {
  .hero-pet-arrow:hover:not(:disabled):not([aria-disabled="true"]) {
    background: var(--lilac);
    border-color: #69559570;
    box-shadow: 0 6px 20px #302b3624;
    transform: translateY(-1px);
  }
  .hero-pet-wheel-hint { display: inline; }
  .hero-pet-touch-hint { display: none; }
}

@media (max-width: 760px) {
  .hero-pet-wheel-hint { display: none; }
  .hero-pet-touch-hint { display: inline; }
  .hero-pet-nav { left: 10px; right: 10px; }
  .hero-pet-arrow { flex-basis: 44px; width: 44px; height: 44px; }
  .hero-pet-arrow svg { width: 19px; height: 19px; }
}

.hero-pet-stage.is-pet-changing {
  overflow: clip;
  overflow-clip-margin: 40px;
}

.hero-pet-stage > .hero-pet-slide.rotate-bottom-right,
.hero-pet-stage > .hero-pet-previous {
  transform-origin: 100% 100%;
  animation-duration: .9s;
  animation-timing-function: linear;
  animation-fill-mode: both;
  backface-visibility: hidden;
  will-change: transform;
}

.hero-pet-stage > .hero-pet-slide.rotate-bottom-right {
  animation-name: rotate-bottom-right;
  visibility: hidden;
}

.hero-pet-stage > .hero-pet-previous {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  animation-name: hero-pet-turn-out;
  pointer-events: none;
  user-select: none;
}
.hero-pet-stage > .hero-pet-previous * { pointer-events: none !important; }

/* One clockwise hand-off: the old card leaves before the next one enters.
   Visibility switches at the hand-off; the cards never cross-fade. */
@keyframes rotate-bottom-right {
  0%, 46% {
    visibility: hidden;
    transform: rotate(-160deg);
  }
  46.001% {
    visibility: visible;
    transform: rotate(-160deg);
    animation-timing-function: cubic-bezier(.18, .75, .25, 1);
  }
  100% {
    visibility: visible;
    transform: rotate(0deg);
  }
}

@keyframes hero-pet-turn-out {
  0% {
    visibility: visible;
    transform: rotate(0deg);
    animation-timing-function: cubic-bezier(.42, 0, .78, .45);
  }
  44% {
    visibility: visible;
    transform: rotate(160deg);
  }
  44.001%, 100% {
    visibility: hidden;
    transform: rotate(160deg);
  }
}

@supports not (overflow: clip) {
  .hero-pet-stage.is-pet-changing { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-pet-stage > .hero-pet-slide.rotate-bottom-right { animation: none !important; transform: none; opacity: 1; visibility: visible; }
  .hero-pet-stage > .hero-pet-previous { display: none; animation: none !important; }
  .hero-pet-arrow { transition: none; }
  .hero-pet-arrow:hover,
  .hero-pet-arrow:active { transform: none !important; }
}
