/* =========================================================
   گالری + نمایشگر تمام‌صفحه
   صفحه‌ی گالری: «پرواز در عمق» — صفحه‌ی اول: «حلقه‌ی سه‌بعدی»
   همه‌ی تصاویر مربعی (۵۶۷×۵۶۷)
   ⚠️ روی والدهای زنجیره‌ی preserve-3d هرگز overflow: hidden نگذارید.
   ========================================================= */

.page { padding-top: var(--header-h); }

/* عنوان بخش — هم‌سبک عنوان «خدمات» */
.gv__title {
  position: relative;
  z-index: 3;
  margin: 0;
  padding: 0 var(--gutter);
  font-size: var(--fs-h);
  font-weight: 800;
  line-height: 1.3;
  color: var(--brand);
}

/* دکمه‌ی هر تصویر (کل کاشی قابل کلیک برای نمایش بزرگ) */
.gv button {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
}
.gv button:focus-visible { outline: 2px solid var(--brand); outline-offset: 4px; border-radius: 18px; }
.gv img {
  display: block;
  -webkit-user-drag: none;
  user-select: none;
  background: #1b0d06;           /* تا بارگذاری عکس، جای خالی تیره (نه سفید) */
}

/* =========================================================
   پرواز در عمق (صفحه‌ی گالری)
   ========================================================= */
.gv--tunnel { position: relative; height: 520vh; }
.tn__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  padding-top: calc(var(--header-h) + 20px);
  background: radial-gradient(60% 60% at 50% 55%, rgba(255, 106, 0, .10), transparent 70%);
}
.tn__space {
  position: absolute;
  inset: 0;
  perspective: 900px;
  perspective-origin: 50% 52%;
}
.tn__item {
  --w: clamp(240px, 30vw, 480px);
  --b: 1;            /* روشنایی بر اساس فاصله — از JS */
  position: absolute;
  left: 50%;
  top: 52%;
  width: var(--w);
  aspect-ratio: 1;
  margin: calc(var(--w) / -2) 0 0 calc(var(--w) / -2);
  will-change: transform, opacity;
}
.tn__item__frame {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 18px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .08), 0 50px 90px -30px rgba(0, 0, 0, .95);
  filter: brightness(var(--b));
}
.tn__img { width: 100%; height: 100%; object-fit: cover; transition: scale .8s var(--ease-out); }
.tn__item:hover .tn__img { scale: 1.05; }

/* =========================================================
   حلقه‌ی سه‌بعدی (صفحه‌ی اول)
   ========================================================= */
.gv--ring { position: relative; height: 420vh; }
.rg__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  padding-top: calc(var(--header-h) + 20px);
  overflow: hidden;
}
.rg__stage {
  --w: clamp(200px, 21vw, 330px);
  --r: calc(var(--w) * 1.78);
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  perspective: 1900px;
  perspective-origin: 50% 40%;
  cursor: grab;
  touch-action: pan-y;
}
.rg__stage.is-dragging { cursor: grabbing; }
.rg__ring {
  position: relative;
  width: var(--w);
  aspect-ratio: 1;
  transform-style: preserve-3d;
  transform: translateZ(calc(var(--r) * -1)) rotateX(-6deg) rotateY(var(--angle, 0deg));
  will-change: transform;
}
.rg__item {
  --f: 1;     /* ۱ = روبه‌رو، ۰ = پشت — از JS */
  position: absolute;
  inset: 0;
  transform: rotateY(calc(var(--i) * 36deg)) translateZ(var(--r));
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.rg__item__frame {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 18px;
  filter: brightness(calc(.35 + var(--f) * .65));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, calc(var(--f) * .14)), 0 30px 60px -30px rgba(0, 0, 0, .9);
  -webkit-box-reflect: below 14px linear-gradient(transparent 72%, rgba(0, 0, 0, .22));
}
.rg__img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }

/* ---------- نسخه‌ی صفحه‌ی اول ----------
   بلوک چسبان کوتاه‌تر از صفحه و وسط ناحیه‌ی زیر هدر می‌ایستد؛
   فاصله‌ی بالا/پایین بخش را services.js برابر فاصله‌ی بخش خدمات تنظیم می‌کند */
.gv--ring.gv--home {
  --sh: min(calc(100svh - var(--header-h) - 32px), 680px);
  box-sizing: content-box;          /* padding-bottom از JS به طول اسکرول اضافه شود، نه از آن کم */
  overflow-x: clip;                 /* حلقه از عرض صفحه بیرون نزند؛ clip برخلاف hidden چسبان بودن را خراب نمی‌کند */
  height: calc(var(--sh) + 240vh);
}
.gv--home .rg__sticky {
  top: calc(var(--header-h) + (100svh - var(--header-h) - var(--sh)) / 2);
  height: var(--sh);
  padding-top: 0;
  overflow: visible;
}
.gv--home .rg__stage { --w: clamp(210px, 22vw, 340px); }

/* =========================================================
   نمایشگر تمام‌صفحه
   ========================================================= */
.lb {
  position: fixed;
  inset: 0;
  z-index: 95;
  visibility: hidden;
  transition: visibility 0s linear .5s;
}
.lb.is-open { visibility: visible; transition: none; }
.lb__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 4, 1, .92);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity .5s var(--ease-out);
}
.lb.is-open .lb__backdrop { opacity: 1; }
.lb__figure {
  position: absolute;
  inset: clamp(64px, 9vh, 96px) clamp(16px, 7vw, 110px);
  margin: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.lb__img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 14px;
  box-shadow: 0 50px 120px -30px rgba(0, 0, 0, .95);
  transform-origin: 0 0;
  pointer-events: auto;
  user-select: none;
}
.lb__btn {
  position: absolute;
  z-index: 2;
  opacity: 0;
  transition: opacity .4s var(--ease-out) .1s, background .3s var(--ease-out), transform .45s var(--ease-out);
}
.lb.is-open .lb__btn { opacity: 1; }
.lb__close { top: 18px; left: 18px; }
.lb__prev { top: 50%; right: clamp(10px, 2vw, 32px); margin-top: -22px; }
.lb__next { top: 50%; left: clamp(10px, 2vw, 32px); margin-top: -22px; }
.lb__prev:hover, .lb__next:hover { transform: none; background: var(--brand); border-color: var(--brand); }
.lb__dots {
  position: absolute;
  bottom: max(22px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity .4s var(--ease-out) .15s;
}
.lb.is-open .lb__dots { opacity: 1; }
.lb__dots span { width: 18px; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .22); transition: background .3s, width .3s; }
.lb__dots span.is-active { width: 30px; background: var(--brand); }

/* ---------------------------------------------------------
   ریسپانسیو
   --------------------------------------------------------- */
@media (max-width: 767px) {
  .gv--home .rg__stage { --w: 46vw; }
  .tn__item { --w: 64vw; }
  .rg__stage { --w: 50vw; perspective: 1000px; }
  .lb__figure { inset: 72px 12px 64px; }
  .lb__prev, .lb__next { top: auto; bottom: max(14px, env(safe-area-inset-bottom)); margin-top: 0; }
  .lb__dots { bottom: max(34px, calc(env(safe-area-inset-bottom) + 20px)); }
  .lb__dots span { width: 10px; }
  .lb__dots span.is-active { width: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .tn__img { transition: none; }
}
