/* ============================================================
   Nobo Deal — Scroll Reveal System (nd-reveal.css)
   ------------------------------------------------------------
   Polished, pronounced scroll-triggered "fade-up" reveal for:
     • [data-reveal]   — sections/cards revealed by
                         public/js/islamic.js (adds .revealed)
     • .nd-scroll-card — <ProductCard/>'s own reveal observer
                         (adds .is-scroll-visible)

    Motion design (spec 2.2):
      • Hidden state   : opacity 0, translateY(34px), scale(.985)
      • Revealed state : opacity 1, translateY(0),    scale(1)
      • Transition     : 450ms cubic-bezier(0.16, 1, 0.3, 1)
      • GPU-only       : opacity + transform (no layout/animation props)
      • Stagger        : product-grid children cascade at 70ms steps
                         (children 2–10, total cap ≈ 0.63s)

   IMPORTANT — load order: link this file AFTER nd-modern.css
   (append it at the END of CSS_LINKS in app/layout.jsx) so these
   rules win the cascade.

   Root-cause note: nd-modern.css references `var(--nd-ease)`, a
   custom property that is never defined anywhere in the project.
   A `transition` declaration containing an undefined var() is
   invalid at computed-value time, so [data-reveal] and
   .nd-scroll-card ended up with `transition: none` — the reveal
   "snapped" instead of animating. This file (a) defines --nd-ease
   so those declarations resolve, and (b) re-declares every reveal
   transition with explicit values and springier timing.

   No-JS safety: every hidden state is gated under html.js-enabled,
   and an ungated fallback forces transform:none / opacity:1, so
   users without JS always see content unshifted and fully visible.
   ============================================================ */

/* ------------------------------------------------------------
   0. Define the easing token nd-modern.css assumes exists
   ------------------------------------------------------------ */
:root {
  --nd-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ------------------------------------------------------------
   1. No-JS / pre-JS fallback — nothing may be shifted or hidden
   ------------------------------------------------------------
   Wins over the ungated directional transforms left by older
   stylesheets; loses to every html.js-enabled rule below. */
[data-reveal] {
  opacity: 1;
  transform: none;
}

/* ------------------------------------------------------------
   2. [data-reveal] hidden state (JS-enabled only)
   ------------------------------------------------------------ */
html.js-enabled [data-reveal] {
  opacity: 0;
  transform: translateY(44px);
  will-change: opacity, transform;
  transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Directional variants — declared after the generic rule so they
   keep their character (same specificity, later source wins). */
html.js-enabled [data-reveal="up"]    { transform: translateY(44px); }
html.js-enabled [data-reveal="left"]  { transform: translateX(-38px); }
html.js-enabled [data-reveal="right"] { transform: translateX(38px); }
html.js-enabled [data-reveal="zoom"]  { transform: scale(0.9); }

/* ------------------------------------------------------------
   3. [data-reveal] revealed state — force the final values so
      nothing can ever stay stuck (also guards wrappers that
      contain .nd-scroll-card children).
   ------------------------------------------------------------ */
[data-reveal].revealed {
  opacity: 1;
  transform: none;
}

/* ------------------------------------------------------------
   4. Product-grid stagger — children cascade upward one after
      another. 70ms steps, children 2–10, cap ≈ 0.63s (< 0.7s).
      .row.shop-grid covers every store grid (shop, collection,
      brand, search, offered, wishlists); .row covers related
      products and section rows; .products-grid is future-proof.
      Higher specificity beats the per-page <style> blocks that
      used 50ms steps (children 2–6).
   ------------------------------------------------------------ */
.row.shop-grid > [data-reveal]:nth-child(2),
.shop-grid > [data-reveal]:nth-child(2),
.products-grid > [data-reveal]:nth-child(2),
.row > [data-reveal]:nth-child(2) { transition-delay: 0.07s; }

.row.shop-grid > [data-reveal]:nth-child(3),
.shop-grid > [data-reveal]:nth-child(3),
.products-grid > [data-reveal]:nth-child(3),
.row > [data-reveal]:nth-child(3) { transition-delay: 0.14s; }

.row.shop-grid > [data-reveal]:nth-child(4),
.shop-grid > [data-reveal]:nth-child(4),
.products-grid > [data-reveal]:nth-child(4),
.row > [data-reveal]:nth-child(4) { transition-delay: 0.21s; }

.row.shop-grid > [data-reveal]:nth-child(5),
.shop-grid > [data-reveal]:nth-child(5),
.products-grid > [data-reveal]:nth-child(5),
.row > [data-reveal]:nth-child(5) { transition-delay: 0.28s; }

.row.shop-grid > [data-reveal]:nth-child(6),
.shop-grid > [data-reveal]:nth-child(6),
.products-grid > [data-reveal]:nth-child(6),
.row > [data-reveal]:nth-child(6) { transition-delay: 0.35s; }

.row.shop-grid > [data-reveal]:nth-child(7),
.shop-grid > [data-reveal]:nth-child(7),
.products-grid > [data-reveal]:nth-child(7),
.row > [data-reveal]:nth-child(7) { transition-delay: 0.42s; }

.row.shop-grid > [data-reveal]:nth-child(8),
.shop-grid > [data-reveal]:nth-child(8),
.products-grid > [data-reveal]:nth-child(8),
.row > [data-reveal]:nth-child(8) { transition-delay: 0.49s; }

.row.shop-grid > [data-reveal]:nth-child(9),
.shop-grid > [data-reveal]:nth-child(9),
.products-grid > [data-reveal]:nth-child(9),
.row > [data-reveal]:nth-child(9) { transition-delay: 0.56s; }

.row.shop-grid > [data-reveal]:nth-child(10),
.shop-grid > [data-reveal]:nth-child(10),
.products-grid > [data-reveal]:nth-child(10),
.row > [data-reveal]:nth-child(10) { transition-delay: 0.63s; }

/* ------------------------------------------------------------
   5. ProductCard's own reveal (.nd-scroll-card)
      Same motion language: fade + 34px rise + subtle shrink,
      ~0.8s with the same springy easing. !important on the
      visible state matches nd-modern.css's own rule so the card
      ALWAYS ends fully visible (inline tilt transform cannot
      fight the reveal end-state either).
   ------------------------------------------------------------ */
.nd-scroll-card {
  opacity: 0;
  transform: translate3d(0, 44px, 0);
  will-change: opacity, transform;
  transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.7s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.35s ease,
              border-color 0.3s ease;
}

.nd-scroll-card.is-scroll-visible {
  opacity: 1 !important;
  transform: none !important;
}

/* ------------------------------------------------------------
   6. Inner-card stagger safety net — applies only when a grid
      child is NOT a [data-reveal] wrapper (wrappers already
      cascade via section 4, so no doubled delays). Inline
      transitionDelay from the `delay` prop always wins over
      these (inline beats stylesheet), so ProductCards that pass
      a delay prop keep their exact rhythm.
   ------------------------------------------------------------ */
.shop-grid > div:not([data-reveal]):nth-child(2) .nd-scroll-card,
.products-grid > div:not([data-reveal]):nth-child(2) .nd-scroll-card { transition-delay: 0.07s; }

.shop-grid > div:not([data-reveal]):nth-child(3) .nd-scroll-card,
.products-grid > div:not([data-reveal]):nth-child(3) .nd-scroll-card { transition-delay: 0.14s; }

.shop-grid > div:not([data-reveal]):nth-child(4) .nd-scroll-card,
.products-grid > div:not([data-reveal]):nth-child(4) .nd-scroll-card { transition-delay: 0.21s; }

.shop-grid > div:not([data-reveal]):nth-child(5) .nd-scroll-card,
.products-grid > div:not([data-reveal]):nth-child(5) .nd-scroll-card { transition-delay: 0.28s; }

.shop-grid > div:not([data-reveal]):nth-child(6) .nd-scroll-card,
.products-grid > div:not([data-reveal]):nth-child(6) .nd-scroll-card { transition-delay: 0.35s; }

.shop-grid > div:not([data-reveal]):nth-child(7) .nd-scroll-card,
.products-grid > div:not([data-reveal]):nth-child(7) .nd-scroll-card { transition-delay: 0.42s; }

.shop-grid > div:not([data-reveal]):nth-child(8) .nd-scroll-card,
.products-grid > div:not([data-reveal]):nth-child(8) .nd-scroll-card { transition-delay: 0.49s; }

.shop-grid > div:not([data-reveal]):nth-child(9) .nd-scroll-card,
.products-grid > div:not([data-reveal]):nth-child(9) .nd-scroll-card { transition-delay: 0.56s; }

.shop-grid > div:not([data-reveal]):nth-child(10) .nd-scroll-card,
.products-grid > div:not([data-reveal]):nth-child(10) .nd-scroll-card { transition-delay: 0.63s; }

/* ------------------------------------------------------------
   7. 3D tilt vs reveal — CSS-only conflict resolution.
      ProductCard feeds --mx / --my on mousemove, and
      .is-scroll-visible forces transform:none !important, which
      would kill the inline tilt transform. Derive the exact same
      rotation from --mx/--my in a hover rule with equal
      !important weight and higher specificity, and make the tilt
      snappy (short duration, zero delay) instead of inheriting
      the 0.8s reveal easing. Values mirror productcard.jsx:
        rx = (0.5 - py) * 2 * 12deg ; py = --my / 100
        ry = (px - 0.5) * 2 * 14deg ; px = --mx / 100
   ------------------------------------------------------------ */
.nd-3d-card.is-scroll-visible:hover {
  transform: perspective(900px)
    rotateX(calc((0.5 - (var(--my, 50%) / 100)) * 24deg))
    rotateY(calc(((var(--mx, 50%) / 100) - 0.5) * 28deg))
    translateY(-6px) scale(1.01) !important;
  transition-duration: 0.2s, 0.18s, 0.35s, 0.3s;
  transition-delay: 0s !important;
}

/* Click "pop" must win over both the reveal end-state and the
   hover tilt (same specificity as the hover rule, later source). */
.nd-3d-card.is-scroll-visible.nd-clicked {
  transform: scale(0.955) !important;
  transition: transform 0.12s ease !important;
}

/* ------------------------------------------------------------
   8. prefers-reduced-motion — force everything visible and
      static for both reveal systems.
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  [data-reveal],
  html.js-enabled [data-reveal],
  [data-reveal].revealed,
  .nd-scroll-card,
  .nd-scroll-card.is-scroll-visible {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
    will-change: auto;
  }
}
