/* MILORIA · one quiet rhythm for browsing and buying. Load after the visual styles. */
body.storefront {
  --motion-ease: cubic-bezier(.22, .68, .2, 1);
  --motion-quick: 160ms;
  --motion-ui: 240ms;
}

/* Product visibility never depends on an observer, image event or animation. */
body.storefront .product.scroll-reveal {
  opacity: 1;
  transform: none;
  transition: none;
}

body.storefront .product.scroll-reveal .photo img {
  opacity: 1;
  transition: none;
}

/* Avoid layering older page entrances and hover movements over this system. */
body.storefront :is(.header, .catalog, .buy-steps, .checkout-callout) {
  animation: none;
}

body.storefront .product:hover,
body.storefront .buy-steps li:hover,
body.storefront .hero-secondary:hover span,
body.storefront :is(.button, .product-action, .product-options-action, .product-quick-add, .close,
  .quick-purchase-close, .favorite-button, .related-card, .recently-viewed-card,
  .floating-whatsapp, .collection-guide-grid button):is(:hover, :active, :focus-visible),
body.storefront :is(#filter-toggle, .sort-trigger):active,
body.storefront .checkout-methods label:hover .checkout-method-card {
  transform: none;
}

body.storefront .search-clear:active {
  transform: translateY(-50%);
}

/* Keyboard focus stays visible even on controls whose older hover style hid it. */
body.storefront :is(.favorite-button, .related-card, .recently-viewed-card,
  .floating-whatsapp, .collection-guide-grid button, .search-clear):focus-visible {
  outline: 3px solid #815e75;
  outline-offset: 3px;
}

@media (prefers-reduced-motion: no-preference) {
  body.storefront .hero-copy {
    animation: miloria-motion-copy 520ms var(--motion-ease) both;
  }

  /* Only opacity changes: the original photograph keeps its full geometry. */
  body.storefront .hero-photo {
    animation: miloria-motion-photo 640ms var(--motion-ease) both;
  }

  body.storefront dialog[open] {
    animation: miloria-motion-dialog 260ms var(--motion-ease);
  }

  body.storefront dialog[open]::backdrop {
    animation: miloria-motion-backdrop 180ms ease-out;
  }

  body.storefront :is(.button, .product-action, .product-options-action, .product-quick-add, .categories button,
    .close, .quick-purchase-close, .favorite-button, .filters-close, .related-card,
    .recently-viewed-card, .floating-whatsapp, .collection-guide-grid button),
  body.storefront :is(#filter-toggle, .sort-trigger) {
    transition: background-color var(--motion-quick) ease,
      border-color var(--motion-quick) ease,
      color var(--motion-quick) ease,
      box-shadow var(--motion-ui) ease;
  }

  body.storefront .product,
  body.storefront .product.scroll-reveal {
    transition: border-color var(--motion-quick) ease,
      box-shadow var(--motion-ui) ease;
  }

  body.storefront .checkout-method-card,
  body.storefront #quick-add-dialog .quick-purchase-choice > span {
    transition: background-color var(--motion-quick) ease,
      border-color var(--motion-quick) ease,
      color var(--motion-quick) ease;
  }

  body.storefront .toast.show {
    animation: miloria-motion-toast 220ms var(--motion-ease) both;
  }

  body.storefront .favorite-button.favorite-saved {
    animation: miloria-motion-save 320ms var(--motion-ease);
  }

  body.storefront .favorite-button.favorite-removing {
    animation: miloria-motion-remove 240ms var(--motion-ease);
  }

  body.storefront #bag-button.bag-attention {
    animation: miloria-motion-bag 360ms var(--motion-ease);
  }

  body.storefront #bag-count.bag-count-pop {
    animation: miloria-motion-count 360ms var(--motion-ease);
  }

  body.storefront .receipt-success-mark {
    animation: miloria-motion-success 300ms var(--motion-ease);
  }

  body.storefront .receipt-success-mark svg path {
    stroke-dasharray: 24;
    stroke-dashoffset: 0;
    animation: miloria-motion-check 380ms var(--motion-ease);
  }

  @media (hover: hover) and (pointer: fine) {
    body.storefront :is(.button, .product-action, .product-options-action, .product-quick-add,
      .categories button, .close, .quick-purchase-close, .favorite-button,
      .related-card, .recently-viewed-card, .floating-whatsapp,
      .collection-guide-grid button),
    body.storefront :is(#filter-toggle, .sort-trigger) {
      transition: transform var(--motion-quick) var(--motion-ease),
        background-color var(--motion-quick) ease,
        border-color var(--motion-quick) ease,
        color var(--motion-quick) ease,
        box-shadow var(--motion-ui) ease;
    }

    body.storefront :is(.button, .product-action, .product-options-action, .product-quick-add,
      .related-card, .recently-viewed-card, .floating-whatsapp,
      .collection-guide-grid button):not(:disabled):hover {
      transform: translateY(-1px);
    }

    body.storefront :is(.button, .product-action, .product-options-action, .product-quick-add,
      .categories button, .close, .quick-purchase-close, .favorite-button,
      .related-card, .recently-viewed-card, .collection-guide-grid button):not(:disabled):active,
    body.storefront :is(#filter-toggle, .sort-trigger):not(:disabled):active {
      transform: translateY(1px);
      transition-duration: 100ms;
    }
  }

  @keyframes miloria-motion-copy {
    from { opacity: .6; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
  }

  @keyframes miloria-motion-photo {
    from { opacity: .55; }
    to { opacity: 1; }
  }

  @keyframes miloria-motion-dialog {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
  }

  @keyframes miloria-motion-backdrop {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  @keyframes miloria-motion-toast {
    from { opacity: 0; transform: translate(-50%, 6px); }
    to { opacity: 1; transform: translate(-50%, 0); }
  }

  @keyframes miloria-motion-save {
    0%, 100% { transform: scale(1); }
    42% { transform: scale(1.12); }
  }

  @keyframes miloria-motion-remove {
    0%, 100% { transform: scale(1); }
    42% { transform: scale(.92); }
  }

  @keyframes miloria-motion-bag {
    0%, 100% { transform: none; }
    40% { transform: translateY(-1px); }
  }

  @keyframes miloria-motion-count {
    0%, 100% { transform: scale(1); }
    40% { transform: scale(1.09); }
  }

  @keyframes miloria-motion-success {
    from { opacity: .5; transform: scale(.94); }
    to { opacity: 1; transform: none; }
  }

  @keyframes miloria-motion-check {
    from { stroke-dashoffset: 24; }
    to { stroke-dashoffset: 0; }
  }
}

@media (prefers-reduced-motion: reduce) {
  body.storefront,
  body.storefront *,
  body.storefront *::before,
  body.storefront *::after,
  body.storefront dialog::backdrop {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }

  body.storefront :is(.hero-copy, .hero-photo, .product.scroll-reveal,
    .receipt-success-mark),
  body.storefront dialog[open] {
    opacity: 1 !important;
    transform: none !important;
  }

  body.storefront .product.scroll-reveal .photo img {
    opacity: 1 !important;
  }

  body.storefront .receipt-success-mark svg path {
    stroke-dashoffset: 0 !important;
  }
}


/* A local crossfade keeps the previous result visible while the new one enters. */
body.storefront .catalog-results {
  position: relative;
  min-width: 0;
  overflow-anchor: none;
}
body.storefront .catalog-results-content {
  display: flow-root;
  min-width: 0;
}
body.storefront .catalog-results.is-changing { overflow: hidden; }
body.storefront .catalog-outgoing {
  position: absolute;
  inset: 0 0 auto;
  z-index: 1;
  width: 100%;
  pointer-events: none;
  user-select: none;
}
body.storefront .catalog-empty-copy {
  padding: 28px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
