/* Public-page motion is progressive: no waiting element is hidden by these rules. */
:root {
  --motion-ease: cubic-bezier(.2, .7, .2, 1);
  --motion-gold: #fbb931;
  --motion-ink: #30231d;
}

.motion-active .motion-enter {
  animation: offtab-enter 320ms var(--motion-ease) var(--motion-delay, 0ms) both;
}

@keyframes offtab-enter {
  from { opacity: .82; translate: 0 8px; }
  to { opacity: 1; translate: 0 0; }
}

/* Individual translate preserves the existing angle/scale of the catalogue artwork. */
.motion-active .hero-art .motion-enter {
  animation-name: offtab-art-enter;
}

@keyframes offtab-art-enter {
  from { opacity: .88; translate: 0 8px; }
  to { opacity: 1; translate: 0 0; }
}

.motion-active :is(.catalog-card, .store-card, .branch-card) {
  transition: transform 240ms var(--motion-ease);
}

.motion-active :is(.product-card, .catalog-card, .store-card, .branch-card):focus-within {
  transform: translateY(-3px);
}

.motion-active .product-card:focus-within .product-media img {
  transform: scale(1.035);
}

@media (hover: hover) and (pointer: fine) {
  .motion-active :is(.catalog-card, .store-card, .branch-card):hover {
    transform: translateY(-3px);
  }
  .motion-to-top:hover { transform: translateY(-3px); }
}

@media (prefers-reduced-motion: no-preference) {
  .button > .icon, .ledger-product > .icon { transition: translate 160ms var(--motion-ease); }
  .button:active > .icon { translate: 0 2px; }
  @media (hover: hover) and (pointer: fine) {
    .ledger-product:hover > .icon { translate: -4px 0; }
  }
}

/* Keep header height stable, avoiding a layout jump when it becomes sticky. */
@media (min-width: 1024px) {
  .motion-active .site-header {
    position: sticky;
    top: 0;
    z-index: 110;
  }
  .motion-active .site-header::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 1px;
    pointer-events: none;
    box-shadow: 0 8px 24px #213c351c;
    background: #dbe2d3;
    opacity: 0;
    transition: opacity 240ms var(--motion-ease);
  }
  .motion-active.motion-header-scrolled .site-header::after { opacity: 1; }
  .motion-active .guide-content section { scroll-margin-top: 175px; }
}

/* One slow decorative movement, paused whenever the hero or browser tab is out of view. */
@media (min-width: 769px) and (prefers-reduced-motion: no-preference) {
  .motion-active .hero-art-orbit {
    animation: offtab-orbit 58s linear infinite;
    animation-play-state: paused;
  }
  .motion-active.motion-hero-in-view .hero-art-orbit { animation-play-state: running; }
}

@keyframes offtab-orbit {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.motion-to-top {
  position: fixed;
  inset-inline-end: 24px;
  bottom: 24px;
  z-index: 90;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 11px;
  border: 1px solid #d4bd77;
  border-radius: 50%;
  background: #f5cf6f;
  color: var(--motion-ink);
  box-shadow: 0 4px 16px #213c3512;
  cursor: pointer;
  transition: transform 200ms var(--motion-ease);
  -webkit-tap-highlight-color: transparent;
}
.motion-to-top[hidden] { display: none !important; }
.motion-to-top svg { width: 21px; height: 21px; }
.motion-to-top:focus-visible {
  outline: 3px solid var(--motion-ink);
  outline-offset: 4px;
}
.motion-to-top:active { transform: translateY(-1px); }

.motion-reading-progress {
  position: fixed;
  inset: 0 0 auto;
  height: 2px;
  z-index: 120;
  pointer-events: none;
  background: var(--motion-gold);
  transform: scaleX(0);
  transform-origin: right center;
}

@media (max-width: 600px) {
  .motion-to-top {
    inset-inline-end: 16px;
    bottom: calc(82px + env(safe-area-inset-bottom, 0px));
  }
}

/* Setting changes take effect immediately; the back-to-top action still works. */
.motion-active.motion-reduced .motion-enter {
  animation: none !important;
  opacity: 1 !important;
  translate: none !important;
}
.motion-active.motion-reduced .hero-art-orbit { animation: none !important; }

@media (prefers-reduced-motion: reduce) {
  .motion-active .motion-enter,
  .motion-active .hero-art-orbit { animation: none !important; opacity: 1 !important; translate: none !important; }
  .motion-active :is(.product-card, .catalog-card, .store-card, .branch-card, .button, .add-button, .icon-button),
  .motion-active .product-media img,
  .motion-to-top { transition: none !important; }
  .motion-active :is(.product-card, .catalog-card, .store-card, .branch-card, .button, .add-button, .icon-button):is(:hover, :focus-within, :focus-visible),
  .motion-active .product-card:is(:hover, :focus-within) .product-media img,
  .motion-to-top:is(:hover, :active) { transform: none !important; }
}

@media (forced-colors: active) {
  .motion-to-top { border: 1px solid ButtonText; background: ButtonFace; color: ButtonText; }
  .motion-reading-progress { background: Highlight; }
}

.site-loader {
  position: fixed;
  inset: 0;
  z-index: 115;
  display: grid;
  place-items: center;
  padding: max(1.5rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right))
    max(1.5rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
  background: radial-gradient(ellipse at 50% 43%, #fff8df 0%, #fffaf0 27%, #fffdf9 68%);
  color: #43536b;
  font-family: Vazirmatn, Tahoma, sans-serif;
  text-align: center;
}

.site-loader-content {
  width: min(100%, 33rem, 160vh);
  transform: translateY(-2vh);
}

.site-loader img {
  display: block;
  width: 100%;
  height: auto;
}

@media (prefers-reduced-motion: no-preference) {
  .site-loader img { animation: offtab-enter 400ms var(--motion-ease) both; }
}

.site-loader p {
  margin: clamp(.85rem, 3.2vw, 1.4rem) 0 0;
  font-size: clamp(.875rem, 2.6vw, 1rem);
  line-height: 1.8;
}

@media (prefers-reduced-motion: reduce) {
  .initial-loading .loading-dot { animation: none; }
}

@media print {
  .site-loader { display: none; }
  .motion-to-top, .motion-reading-progress { display: none !important; }
  .motion-active .site-header { position: static !important; }
  .motion-active .motion-enter { animation: none !important; opacity: 1 !important; translate: none !important; }
  .motion-active .hero-art-orbit { animation: none !important; }
}
