/* =========================================================
   اسکرول موشن — استایل
   نکته‌ی تایپوگرافی: روی متن فارسی هرگز letter-spacing نگذارید؛
   اتصال حروف را می‌شکند. فقط روی ارقام/لاتین مجاز است.
   ========================================================= */

:root {
  --bg: #0b0b0c;
  --fg: #f5f3ef;
  --fg-dim: rgba(245, 243, 239, .72);
  --fg-mute: rgba(245, 243, 239, .48);
  --line: rgba(245, 243, 239, .18);
  --accent: #e9d8c4;

  --font: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;

  --gutter: clamp(20px, 5vw, 72px);

  /* قانون تایپوگرافی کل سایت: فقط دو اندازه */
  --fs-h: clamp(20px, 1.6vw, 24px);   /* همه‌ی عنوان‌ها */
  --fs-t: clamp(15px, 1vw, 16px);     /* همه‌ی متن‌ها */
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-io: cubic-bezier(.65, 0, .35, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.9;
  font-feature-settings: "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body.is-loading { overflow: hidden; }

a { color: inherit; }

/* ---------------------------------------------------------
   لودر
   --------------------------------------------------------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity .9s var(--ease-io), visibility 0s linear .9s;
}
.loader.is-done {
  opacity: 0;
  visibility: hidden;
}
.loader__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: min(240px, 60vw);
}
.loader__count {
  font-weight: 200;
  font-size: clamp(44px, 6vw, 64px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.loader__count small {
  font-size: .4em;
  margin-inline-start: 4px;
  color: var(--fg-mute);
}
.loader__bar {
  position: relative;
  width: 100%;
  height: 1px;
  background: var(--line);
  overflow: hidden;
}
.loader__bar > span {
  position: absolute;
  inset: 0;
  background: var(--fg);
  transform: scaleX(0);
  transform-origin: right center; /* RTL: از راست پر می‌شود */
  transition: transform .25s linear;
}
.loader__label {
  font-size: 13px;
  font-weight: 300;
  color: var(--fg-mute);
  line-height: 1.6;
}

/* ---------------------------------------------------------
   سکانس
   --------------------------------------------------------- */
.sequence {
  position: relative;
  height: 500vh; /* طول اسکرول؛ برای ۱۰۰ فریم ≈ هر فریم ۵٪ ارتفاع صفحه */
}

.sequence__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  width: 100%;
  overflow: hidden;
  isolation: isolate;
}

.sequence__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: -3;
}

/* نویز خیلی ظریف فیلمی — حس سینمایی و پنهان کردن باندینگ گرادیان */
.sequence__grain {
  position: absolute;
  inset: -50%;
  z-index: -1;
  pointer-events: none;
  opacity: .06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-3%, 2%); }
  40%  { transform: translate(2%, -3%); }
  60%  { transform: translate(-2%, -1%); }
  80%  { transform: translate(3%, 3%); }
  100% { transform: translate(0, 0); }
}

/* ---------------------------------------------------------
   راهنمای اسکرول
   --------------------------------------------------------- */
.scroll-hint {
  position: absolute;
  bottom: max(28px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  /* سایه‌ی نرم برای خوانایی روی تصویر روشن/آبی */
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .35)) drop-shadow(0 2px 10px rgba(0, 0, 0, .25));
  transition: opacity .6s var(--ease-out);
}
.scroll-hint.is-hidden { opacity: 0; }
.scroll-hint__mouse {
  position: relative;
  width: 22px;
  height: 34px;
  border: 1.5px solid var(--fg);
  border-radius: 12px;
}
.scroll-hint__mouse > span {
  position: absolute;
  top: 7px;
  left: 50%;
  width: 2px;
  height: 6px;
  margin-left: -1px;
  border-radius: 2px;
  background: var(--fg);
  animation: wheel 1.8s var(--ease-io) infinite;
}
@keyframes wheel {
  0%   { transform: translateY(0); opacity: 0; }
  20%  { opacity: 1; }
  70%  { transform: translateY(10px); opacity: 0; }
  100% { transform: translateY(10px); opacity: 0; }
}
.scroll-hint__label {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--fg);
}

/* ---------------------------------------------------------
   ریسپانسیو
   --------------------------------------------------------- */
@media (max-width: 767px) {
  .sequence { height: 420vh; }

  .scroll-hint { bottom: max(64px, calc(env(safe-area-inset-bottom) + 40px)); }
}

/* کاربرانی که حرکت کمتر می‌خواهند: بدون blur، بدون جابه‌جایی و بدون نویز متحرک */
@media (prefers-reduced-motion: reduce) {
  .sequence__grain { animation: none; }
  .scroll-hint__mouse > span { animation: none; opacity: 1; }
}
