/* الگوی صالح — page-load motion, picked in «تنظیمات ظاهر» (html[data-motion]).
   Emil Kowalski rules: strong ease-out (no ease-in), transform/opacity/filter only, nothing from scale(0),
   30–80ms non-uniform stagger, one entrance per container, never blocks interaction.
   js/theme.js adds html.is-entering at load (and on «پیش‌نمایش حرکت»), removes it when done,
   so without JS everything is simply visible. --motion-k scales every duration (speed slider). */

:root {
  --motion-k: 1;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-glass: cubic-bezier(0.16, 1, 0.3, 1);
  --d-enter: calc(560ms * var(--motion-k));
}

@media (prefers-reduced-motion: no-preference) {
  /* ground settles first, under everything */
  html.is-entering:not([data-motion="none"]) .ground { animation: m-ground calc(700ms * var(--motion-k)) var(--ease-out) both; }
  @keyframes m-ground { from { opacity: .4; } }

  /* containers: .enter / .enter-2 / .enter-3 already mark the 1–3 blocks of each page */
  html.is-entering .enter   { --m-delay: 0ms; }
  html.is-entering .enter-2 { --m-delay: calc(80ms * var(--motion-k)); }
  html.is-entering .enter-3 { --m-delay: calc(150ms * var(--motion-k)); }

  /* نرم — soft rise with a whisper of blur */
  html.is-entering[data-motion="soft"] :is(.enter, .enter-2, .enter-3) { animation: m-soft var(--d-enter) var(--ease-out) var(--m-delay) both; }
  @keyframes m-soft { from { opacity: 0; transform: translateY(10px); filter: blur(4px); } }

  /* شیشه‌ای — panes condense out of the blur, then light sweeps across the glass once */
  html.is-entering[data-motion="glass"] :is(.enter, .enter-2, .enter-3) { animation: m-glass calc(680ms * var(--motion-k)) var(--ease-glass) var(--m-delay) both; }
  html.is-entering[data-motion="glass"] .glass:is(.enter, .enter-2, .enter-3) {
    animation: m-glass calc(680ms * var(--motion-k)) var(--ease-glass) var(--m-delay) both, m-sweep calc(1100ms * var(--motion-k)) cubic-bezier(0.77, 0, 0.175, 1) calc(var(--m-delay) + 380ms * var(--motion-k)) both;
  }
  /* glass inside an entering block only gets the light sweep — never a second blur */
  html.is-entering[data-motion="glass"] :is(.enter, .enter-2, .enter-3) .glass {
    animation: m-sweep calc(1100ms * var(--motion-k)) cubic-bezier(0.77, 0, 0.175, 1) calc(var(--m-delay) + 380ms * var(--motion-k)) both;
  }
  @keyframes m-glass { from { opacity: 0; transform: translateY(6px) scale(.975); filter: blur(14px); } }

  /* آبشاری — containers fade, their rows cascade in */
  html.is-entering[data-motion="cascade"] :is(.enter, .enter-2, .enter-3) { animation: m-fade calc(420ms * var(--motion-k)) var(--ease-out) var(--m-delay) both; }
  html.is-entering[data-motion="cascade"] [data-stagger] > * {
    animation: m-row calc(460ms * var(--motion-k)) var(--ease-out) calc(var(--m-delay, 0ms) + 120ms * var(--motion-k) + var(--si, 0) * 52ms * var(--motion-k)) both;
  }
  @keyframes m-fade { from { opacity: 0; } }
  @keyframes m-row { from { opacity: 0; transform: translateY(8px); } }

  /* the specular sweep, played once by the «شیشه‌ای» entrance */
  @keyframes m-sweep { from { --sweep-x: 160%; } to { --sweep-x: -60%; } }

}
@property --sweep-x { syntax: "<percentage>"; inherits: true; initial-value: 160%; } /* inherits so the rim (::before) glints with the pane */

/* reduced motion: gentler, not zero — same timing, opacity only */
@media (prefers-reduced-motion: reduce) {
  html.is-entering:not([data-motion="none"]) :is(.enter, .enter-2, .enter-3) { animation: m-fade-r 300ms ease-out both; }
  @keyframes m-fade-r { from { opacity: 0; } }
}
