/* 3D motion: card tilt, cards rising into place, the hero photo turning between sections, and a
   turntable turn on the product view. js/motion.js sets the --tilt-* variables and .is-in classes.
   Everything here is off for "reduce motion" and for the accessibility menu's "stop animations". */

/* Cards: tilt toward the pointer, with a soft sheen where it points. */
.item {
  --tilt-x: 0deg;
  --tilt-y: 0deg;
  --glare-x: 50%;
  --glare-y: 0%;
  transform: perspective(1000px) rotateX(var(--tilt-x)) rotateY(var(--tilt-y));
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s, border-color 0.3s;
}
.item.is-tilting { will-change: transform; transition: transform 0.12s linear, box-shadow 0.3s, border-color 0.3s; box-shadow: 0 22px 40px rgb(37 35 31 / 0.14); }
.item__stage .photo { transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); }
.item.is-tilting .item__stage .photo {
  transition: transform 0.12s linear;
  transform: translate(calc(var(--tilt-y) * -1.2), calc(var(--tilt-x) * 1.2)) scale(1.05);
}
.item__stage::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--glare-x) var(--glare-y), rgb(255 255 255 / 0.55), transparent 55%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.item.is-tilting .item__stage::after { opacity: 1; }
@media (hover: none) {
  .item:active { transform: perspective(1000px) scale(0.98) rotateX(3deg); transition-duration: 0.15s; }
}

/* Cards rise into place, tipped back a little, as they scroll into view. */
.item.is-waiting { opacity: 0; }
.item.is-in { animation: card-in 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; animation-delay: var(--delay, 0ms); }
@keyframes card-in {
  from { opacity: 0; transform: perspective(1000px) translateY(40px) rotateX(18deg) scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* Hero: the photo turns in on arrival, like a showcase door opening. */
.hero { perspective: 1600px; }
.hero__photo img { transform-origin: 50% 60%; }
.hero__photo img { animation: hero-turn 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes hero-turn {
  from { transform: rotateY(-14deg) scale(1.16); filter: brightness(0.6); }
  to { transform: none; filter: none; }
}
/* While scrolling, the photo slowly moves closer and the text rises away. */
.hero__photo { transform: scale(calc(1 + var(--hero-scroll, 0) * 0.1)); transform-origin: 50% 40%; }
.hero__text { transform: translateY(calc(var(--hero-scroll, 0) * -40px)); opacity: calc(1 - var(--hero-scroll, 0) * 0.9); }

/* Product view opens in 3D: the panel swings up like the lid of a display case, the product
   comes forward from deep in the stage and settles, and the details float in one by one.
   On a computer the product then follows the pointer. */
#product-dialog[open] { animation: case-open 0.75s cubic-bezier(0.2, 0.8, 0.2, 1) both; transform-origin: 50% 100%; }
#product-dialog[open]::backdrop { animation: backdrop-in 0.5s ease both; }
@keyframes case-open {
  from { opacity: 0; transform: perspective(1200px) translateY(14%) rotateX(-24deg) scale(0.94); }
  to { opacity: 1; transform: none; }
}
@keyframes backdrop-in { from { opacity: 0; } }

.pdp__stage { perspective: 800px; }
/* Plays once per product: js/motion.js marks the stage .is-settled when it ends, and only then can the pointer tilt it. */
.pdp__stage:not(.is-settled) .photo, .pdp__stage:not(.is-settled) .bottle { animation: product-forward 1.1s cubic-bezier(0.2, 0.9, 0.25, 1.15) 0.08s both; transform-origin: 50% 80%; }
@keyframes product-forward {
  from { opacity: 0; transform: translateZ(-420px) rotateX(24deg) rotateY(-18deg); }
  60% { opacity: 1; }
  to { opacity: 1; transform: none; }
}
.pdp__stage.is-settled .photo, .pdp__stage.is-settled .bottle { transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.pdp__stage.is-settled.is-tilting .photo, .pdp__stage.is-settled.is-tilting .bottle { transform: rotateY(var(--tilt-y, 0deg)) rotateX(var(--tilt-x, 0deg)); transition-duration: 0.15s; }

.pdp__info > * { animation: detail-in 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.pdp__info > :nth-child(1) { animation-delay: 0.35s; }
.pdp__info > :nth-child(2) { animation-delay: 0.42s; }
.pdp__info > :nth-child(3) { animation-delay: 0.49s; }
.pdp__info > :nth-child(4) { animation-delay: 0.56s; }
.pdp__info > :nth-child(n + 5) { animation-delay: 0.63s; }
@keyframes detail-in {
  from { opacity: 0; transform: perspective(600px) translateY(16px) rotateX(-30deg); }
  to { opacity: 1; transform: none; }
}

@media print {
  .item.is-waiting { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .item, .item__stage .photo, .hero__photo, .hero__text { transform: none !important; transition: none !important; }
  .item.is-waiting { opacity: 1; }
  .item.is-in, .hero__photo img, #product-dialog[open], #product-dialog[open]::backdrop, .pdp__stage .photo, .pdp__stage .bottle, .pdp__info > * { animation: none !important; }
}
html.a11y-still .item, html.a11y-still .item__stage .photo, html.a11y-still .hero__photo, html.a11y-still .hero__text { transform: none !important; }
html.a11y-still .item, html.a11y-still .hero__text { opacity: 1; }
html.a11y-still .item.is-waiting { opacity: 1; }
