/*! Ninja Motion Lite 1.3.0 | (c) OCNinja https://ocninja.com | MIT */
/*
 * House rules: on Journal3 elements only opacity, translate, scale, rotate, filter and clip-path;
 * individual transform properties only (Journal3 positions #cart-items and .count-badge with the
 * transform shorthand). Nothing here hides anything: scroll reveal is played by motion.js as Web
 * Animations (a class on a Journal3 block restyles its whole subtree, an animation only the element).
 */

:root {
  --nm-ease-out: cubic-bezier(.2, .8, .2, 1);
  --nm-spring-soft: cubic-bezier(.2, .8, .2, 1);
  --nm-spring-normal: cubic-bezier(.2, .8, .2, 1);
  --nm-spring-snappy: cubic-bezier(.2, .8, .2, 1);
}

@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --nm-spring-soft: linear(0, 0.006, 0.025 2.8%, 0.101 6.1%, 0.539 18.9%, 0.721 25.3%, 0.849 31.5%, 0.937 38.1%, 0.968 41.8%, 0.991 45.7%, 1.006 50.1%, 1.015 55%, 1.017 63.9%, 1.001 85.9%, 1);
    --nm-spring-normal: linear(0, 0.009, 0.035 2.1%, 0.141 4.4%, 0.723 12.9%, 0.938 16.7%, 1.017, 1.077, 1.121, 1.149 24.3%, 1.159, 1.163, 1.161, 1.154 29.9%, 1.129 32.8%, 1.051 39.6%, 1.017 43.1%, 0.991, 0.977 51%, 0.974 53.8%, 0.975 57.1%, 0.997 69.8%, 1.003 76.9%, 1);
    --nm-spring-snappy: linear(0, 0.157 4.3%, 0.537 9.8%, 0.893 16.1%, 1.047 21.2%, 1.098 25.5%, 1.097 29.3%, 1.058 34.4%, 1.006 41.6%, 0.99 49%, 0.996 63.8%, 1);
  }
}

/* ================= Scroll reveal (A.1) ================= */

/* Played by motion.js as Web Animations (frames, timing and the spring easing live in its FRAMES table):
   nothing in this file hides or moves a reveal target. */

/* ================= Micro-interactions (A.2) ================= */

/* Card lift + soft shadow. Journal3 already zooms the image on hover (.product-img > div, --scale)
   and has its own ripple; neither is duplicated. Journal3's "transition: all .075s ease-out" on
   .product-thumb is restated first so only translate gets the spring. */
html.nm-on.nm-f-card .product-thumb {
  transition: all .075s ease-out, translate 320ms var(--nm-spring-normal);
}

html.nm-on.nm-f-card .product-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  box-shadow: 0 22px 40px -16px rgba(0, 0, 0, .32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms ease-out;
}

@media (hover: hover) and (pointer: fine) {
  html.nm-on.nm-f-card .product-thumb:hover { translate: 0 -8px; }
  html.nm-on.nm-f-card .product-thumb:hover::after { opacity: 1; }
}

/* Button press: scale only (Journal3's .btn transition "all .1s ease-out" restated first) */
html.nm-on.nm-f-press :where(.btn, .button-cart, .btn-primary, #button-cart) {
  transition: all .1s ease-out, scale 220ms var(--nm-spring-snappy), translate 220ms var(--nm-spring-snappy);
}

html.nm-on.nm-f-press :where(.btn, .button-cart, .btn-primary, #button-cart):active { scale: .95; }

@media (hover: hover) and (pointer: fine) {
  html.nm-on.nm-f-press :where(.btn-primary, .btn-cart, .button-cart, #button-cart):hover { translate: 0 -1px; }
}

/* Cart badge pop: the individual scale property composes with Journal3's translate3d positioning */
@keyframes nm-pop {
  0% { scale: 1; }
  40% { scale: 1.35; }
  100% { scale: 1; }
}

html.nm-on .nm-pop { animation: nm-pop 420ms var(--nm-spring-snappy); }

/* Label shine (spec 4.2): a module-owned clip box (.nm-shine, data-nm-own) that motion.js appends inside a
   Journal3 badge; its .nm-shine-bar sweeps once via Web Animations. Nothing here styles the J3 badge. The
   clip box only exists when the effect ran, so it needs no feature class. */
.nm-shine {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
}
.nm-shine-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 60%;
  translate: -120% 0;
  background: linear-gradient(100deg, transparent 0%, rgba(255, 255, 255, .55) 50%, transparent 100%);
}
@media (prefers-reduced-motion: reduce) {
  .nm-shine { display: none; }
}

/* Card spotlight (spec 4.3): a module-owned overlay (.nm-spotlight, data-nm-own) that motion.js appends
   inside a .product-thumb on first hover; a soft radial highlight follows the cursor via --nm-mx/--nm-my.
   pointer-events:none so clicks pass through. Nothing here styles the J3 card. */
.nm-spotlight {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 200ms ease-out;
  background: radial-gradient(circle at var(--nm-mx, 50%) var(--nm-my, 50%), rgba(255, 255, 255, .14), transparent 40%);
}
@media (hover: hover) and (pointer: fine) {
  .product-thumb:hover > .nm-spotlight { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .nm-spotlight { display: none; }
}

/* Fly-to-cart clone (our own element) */
.nm-fly {
  position: fixed;
  z-index: 100000;
  margin: 0;
  object-fit: cover;
  border-radius: 8px;
  pointer-events: none;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .18);
  will-change: transform, opacity;
}

/* Success: a check mark over the button (our own element) + a short pulse on the button */
.nm-check {
  position: fixed;
  z-index: 100000;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border-radius: 50%;
  pointer-events: none;
  background: var(--nm-success, #1f9d55);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .18);
  animation: nm-check-in 380ms var(--nm-spring-snappy) backwards;
  transition: opacity 250ms ease-out;
}

.nm-check::after {
  content: "";
  position: absolute;
  left: 11px;
  top: 6px;
  width: 7px;
  height: 14px;
  border: solid #fff;
  border-width: 0 3px 3px 0;
  rotate: 45deg;
}

.nm-check.nm-out { opacity: 0; }

@keyframes nm-check-in { from { scale: 0; opacity: 0; } }

@keyframes nm-success-pulse {
  0% { scale: 1; }
  35% { scale: 1.06; }
  100% { scale: 1; }
}

html.nm-on .nm-success { animation: nm-success-pulse 600ms var(--nm-spring-snappy); }

/* ================= Page transitions (A.3) ================= */

/* The view-transition rules live in motion-vt.css, linked only while the transitions toggle is on. */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}

/* 2 px progress bar in the Journal3 brand colour (plain blue on other themes) */
.nm-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 100001;
  pointer-events: none;
  opacity: 0;
  scale: 0 1;
  transform-origin: 0 50%;
  background: var(--nm-progress-color, hsla(var(--j-color-scheme-brand-primary-h, 210), var(--j-color-scheme-brand-primary-s, 90%), var(--j-color-scheme-brand-primary-l, 50%), var(--j-color-scheme-brand-primary-a, 1)));
}

.nm-progress.nm-progress-run {
  opacity: 1;
  animation: nm-progress 8s cubic-bezier(.1, .7, .2, 1) forwards;
}

@keyframes nm-progress {
  from { scale: 0 1; }
  to { scale: .92 1; }
}

/* ================= Loading states (A.4) ================= */

/* Filter AJAX: dim the old cards and run a shimmer over them until Journal3 swaps the grid.
   Journal3's "transition: all .075s ease-out" on .product-thumb is restated first. */
html.nm-on .main-products-wrapper.nm-loading .product-thumb {
  opacity: .45;
  transition: all .075s ease-out, opacity 160ms ease-out;
}

html.nm-on .main-products-wrapper.nm-loading .product-thumb::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 20%, hsla(var(--j-color-scheme-background-secondary-h, 0), var(--j-color-scheme-background-secondary-s, 0%), var(--j-color-scheme-background-secondary-l, 92%), .9) 50%, transparent 80%) 0 0 / 200% 100%;
  animation: nm-shimmer 1.1s linear infinite;
}

@keyframes nm-shimmer {
  from { background-position: 150% 0; }
  to { background-position: -50% 0; }
}

/* Search autosuggest skeleton (our own element, positioned by motion.js under #search-input-el) */
.nm-skeleton-rows {
  position: fixed;
  z-index: 10050;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 6px;
  pointer-events: none;
  background: hsla(var(--j-color-scheme-background-primary-h, 0), var(--j-color-scheme-background-primary-s, 0%), var(--j-color-scheme-background-primary-l, 100%), var(--j-color-scheme-background-primary-a, 1));
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}

.nm-skeleton-rows > span {
  display: block;
  height: 14px;
  border-radius: 4px;
  background:
    linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .55) 50%, transparent 70%) 0 0 / 200% 100%,
    hsla(var(--j-color-scheme-background-secondary-h, 0), var(--j-color-scheme-background-secondary-s, 0%), var(--j-color-scheme-background-secondary-l, 92%), var(--j-color-scheme-background-secondary-a, 1));
  animation: nm-shimmer 1.1s linear infinite;
}

.nm-skeleton-rows > span:nth-child(2) { width: 82%; }
.nm-skeleton-rows > span:nth-child(3) { width: 64%; }

/* Lazy images (lozad sets data-loaded="true" when it swaps the real source in) */
@keyframes nm-img-in { from { opacity: 0; } }

html.nm-on.nm-f-imgfade img[data-loaded="true"] { animation: nm-img-in 300ms ease-out backwards; }

/* ================= Extras (A.5) ================= */

/* Header shadow: our own fixed strip under the pinned header (Journal3 already uses header::after) */
.nm-header-shadow {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--nm-hb, 0px);
  height: 14px;
  z-index: 99; /* below Journal3's header stacking context (z-index 100) and its dropdowns */
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, .10), rgba(0, 0, 0, 0));
  transition: opacity 200ms ease-out;
}

.nm-header-shadow.nm-visible { opacity: 1; }

/* "Scrolled past 8 px" comes from an IntersectionObserver on this strip, not from scroll-time reads */
/* Page end for the reveal observer: 1 px at the end of <body>, its -1 px margin keeps the page height */
.nm-end-strip {
  display: block;
  height: 1px;
  margin: -1px 0 0;
  padding: 0;
  border: 0;
  visibility: hidden;
  pointer-events: none;
}

.nm-top-sentinel {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 9px;
  pointer-events: none;
  visibility: hidden;
}

/* Count-up: digits keep their width while they change */
.nm-count { font-variant-numeric: tabular-nums; }

/* Marquee: operator class on an element holding plain inline content */
html.nm-on.nm-f-marquee .nm-marquee { overflow: hidden; }

/* the marquee track keeps its own animation */
html.nm-on .nm-marquee-track {
  display: flex;
  width: max-content;
  animation: nm-marquee var(--nm-marquee-duration, 24s) linear infinite;
  animation-timeline: auto;
}

.nm-marquee-item {
  flex: 0 0 auto;
  padding-inline-end: 3em;
  white-space: nowrap;
}

.nm-marquee:hover .nm-marquee-track { animation-play-state: paused; }

@keyframes nm-marquee { to { translate: -50% 0; } }

