/* Storefront motion: page transitions, add-to-cart feedback and scroll reveals.
   Loaded on every storefront page after the shell; storefront_motion.js drives the
   parts that need a script. Every rule here is decoration: without support, or with
   reduced motion requested, the pages look and work the same, only still. */

/* Card → product page: the clicked card's photo grows into the product photo.
   storefront_motion.js names that one card photo on click. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }
}

.store-header {
  view-transition-name: store-header;
}

#product-main-image {
  view-transition-name: product-hero;
}

/* A card on the product page (related, recently viewed) takes the name while it is being
   opened, so the current photo gives it up. */
.is-card-navigation #product-main-image {
  view-transition-name: none;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 220ms;
  animation-timing-function: ease-out;
}

::view-transition-group(product-hero) {
  animation-duration: 380ms;
  animation-timing-function: var(--ease);
}

::view-transition-old(product-hero),
::view-transition-new(product-hero) {
  height: 100%;
  object-fit: contain;
}

/* Add to cart: a copy of the photo flies to the header bag, then the counter bumps. */
.cart-flyer {
  position: fixed;
  z-index: 1000;
  margin: 0;
  border-radius: 18px;
  object-fit: contain;
  mix-blend-mode: multiply;
  pointer-events: none;
  will-change: transform, opacity;
}

@keyframes cart-bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.45); }
  65% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

.icon-btn b.is-bumped {
  animation: cart-bump 420ms var(--ease);
}

/* Sections below the first screen settle in as they scroll into view. The hero is not
   listed: content above the fold never starts hidden. Product cards are not listed
   either: tied to the scroll, a row at the bottom of the screen stayed faded and drifted
   against the page, and faded out again on the way back up. */
@keyframes reveal-up {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .storefront-home .promo,
    .product-page .product-spec,
    .product-page .product-highlight {
      animation: reveal-up linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 45%;
    }
  }
}

/* Skeleton cards hold the grid while the next cards and their photos load.
   They reuse the card box (.product, .product-image, .product-info) so nothing shifts
   when the real cards replace them. */
.product--skeleton {
  pointer-events: none;
}

.product--skeleton .skeleton-block {
  display: block;
  border-radius: 10px;
  background: linear-gradient(100deg, #ececea 30%, #f4f4f2 50%, #ececea 70%) 0 0 / 300% 100%;
  animation: skeleton-shimmer 1.3s linear infinite;
}

.product--skeleton .product-image {
  padding: 14% 22% 8%;
}

.product--skeleton .skeleton-image {
  height: 100%;
  border-radius: 18px;
}

.product--skeleton .skeleton-line {
  width: 70%;
  height: 14px;
  margin-top: 10px;
}

.product--skeleton .skeleton-line--short {
  width: 40%;
  height: 12px;
}

.product--skeleton .skeleton-line--price {
  width: 32%;
  height: 20px;
  margin-top: 26px;
}

/* A card whose colour photo is still being fetched shimmers instead of showing another
   colour's photo; it becomes the photo or «Нет фото» (storefront_cards.js). */
.product-image-placeholder--loading {
  border-radius: 18px;
  background: linear-gradient(100deg, #ececea 30%, #f4f4f2 50%, #ececea 70%) 0 0 / 300% 100%;
  animation: skeleton-shimmer 1.3s linear infinite;
}

@keyframes skeleton-shimmer {
  to {
    background-position: -150% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .product--skeleton .skeleton-block,
  .product-image-placeholder--loading {
    animation: none;
  }
}
