/* =========================================================
   Clinical AI — استایل‌شیت تجربه تعاملی اسکرول‌محور و WebGL2
   ========================================================= */

:root {
  --bg-void: #070709;
  --bg-elevated: rgba(16, 16, 22, 0.84);
  --text-primary: #f6f6f8;
  --text-secondary: rgba(235, 236, 242, 0.78);
  --text-muted: rgba(215, 218, 230, 0.56);
  --accent-gold: #e7aa3a;
  --accent-purple: #b380ff;
  --accent-purple-hover: #c39bff;
  --accent-purple-glow: rgba(179, 128, 255, 0.42);
  --border-subtle: rgba(255, 255, 255, 0.1);
  --font-display: 'Vazirmatn', 'Inter', system-ui, -apple-system, sans-serif;
  --font-sans: 'Vazirmatn', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --scroll-progress: 0;
}

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

html {
  background-color: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-sans);
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg-void);
  color: var(--text-primary);
  overflow-x: hidden;
  line-height: 1.5;
}

/* ---------- صحنه ثابت سه‌بعدی و بافت پس‌زمینه ---------- */

.stage-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(circle at 64% 48%, rgba(114, 72, 204, 0.08) 0%, transparent 48%),
    radial-gradient(circle at 26% 72%, rgba(255, 214, 60, 0.04) 0%, transparent 42%),
    var(--bg-void);
}

/* بافت شبکه مدار دیجیتال ظریف در پس‌زمینه مطابق تصاویر نمونه */
.circuit-grid {
  position: absolute;
  inset: -6%;
  opacity: 0.24;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    radial-gradient(circle at 24px 24px, rgba(255, 216, 80, 0.14) 1px, transparent 1.2px);
  background-size: 64px 64px, 64px 64px, 128px 128px;
  mask-image: radial-gradient(ellipse 82% 80% at 55% 50%, #000 35%, transparent 100%);
  transform: translate3d(calc(var(--pointer-x, 0) * -10px), calc(var(--pointer-y, 0) * -10px), 0);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

#brain-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.ambient-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, transparent 55%, rgba(4, 4, 7, 0.72) 100%);
}

/* ---------- نوار پیشرفت اسکرول (CSS Scroll-Driven با Fallback) ---------- */

.scroll-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 40;
  pointer-events: none;
  transform-origin: 0 50%;
  background: linear-gradient(90deg, #ffe135 0%, #ba55ff 52%, #3ee8b5 100%);
  transform: scaleX(var(--scroll-progress));
}

@supports ((animation-timeline: scroll()) and (animation-range: 0% 100%)) {
  @keyframes grow-scroll-progress {
    from {
      transform: scaleX(0);
    }
    to {
      transform: scaleX(1);
    }
  }

  .scroll-progress-bar {
    transform: scaleX(0);
    animation: grow-scroll-progress linear both;
    animation-timeline: scroll(root block);
    animation-range: 0% 100%;
  }
}

/* ---------- هدر ثابت بالا ---------- */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 44px;
  transition:
    background-color 0.25s ease,
    backdrop-filter 0.25s ease,
    padding 0.25s ease;
}

.site-header.is-scrolled {
  padding: 15px 44px;
  background-color: rgba(7, 7, 9, 0.56);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0;
}

.brand-sub {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-inline-start: 6px;
  letter-spacing: 0.04em;
}

.brand-mark {
  display: block;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.brand:hover .brand-mark {
  transform: rotate(-8deg) scale(1.06);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-link {
  color: rgba(246, 246, 248, 0.86);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 500;
  letter-spacing: 0;
  transition: color 0.2s ease;
}

.nav-link:hover,
.nav-link.is-active {
  color: #ffffff;
}

/* دکمه‌های کپسولی برند */
.btn-pill {
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #ba8dff 0%, #9b66ff 100%);
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 22px rgba(162, 107, 255, 0.28);
  transition:
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.22s ease,
    filter 0.22s ease;
}

.btn-pill--secondary {
  background: linear-gradient(135deg, rgba(62, 232, 181, 0.22) 0%, rgba(155, 102, 255, 0.28) 100%);
  border: 1px solid rgba(179, 128, 255, 0.45);
  box-shadow: 0 6px 22px rgba(62, 232, 181, 0.14);
}

.btn-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 30px var(--accent-purple-glow);
  filter: brightness(1.07);
}

.btn-pill:active {
  transform: translateY(0) scale(0.98);
}

.btn-pill--header {
  padding: 9px 18px;
}

.btn-pill--hero {
  padding: 13px 26px;
}

.btn-ghost {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  padding: 12px 22px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}

.btn-ghost--header {
  padding: 9px 16px;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.34);
}

/* ---------- کنترل‌های شناور HUD (نشانگر بخش‌ها و دکمه Pause) ---------- */

.hud-controls {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
}

.chapter-dots {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.chapter-dot {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 3px 4px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 0.2s ease;
}

.chapter-dot__label {
  opacity: 0;
  transform: translateX(6px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.chapter-dot:hover .chapter-dot__label,
.chapter-dot:focus-visible .chapter-dot__label,
.chapter-dot.is-active .chapter-dot__label {
  opacity: 1;
  transform: translateX(0);
}

.chapter-dot__pip {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  transition:
    transform 0.25s ease,
    background-color 0.25s ease,
    box-shadow 0.25s ease;
}

.chapter-dot.is-active {
  color: #ffffff;
}

.chapter-dot.is-active .chapter-dot__pip {
  background: #ffe135;
  transform: scale(1.35);
  box-shadow: 0 0 12px rgba(255, 225, 53, 0.75);
}

.motion-toggle {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(12, 12, 18, 0.72);
  backdrop-filter: blur(8px);
  color: rgba(246, 246, 248, 0.84);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    background-color 0.2s ease,
    color 0.2s ease;
}

.motion-toggle:hover {
  border-color: rgba(255, 255, 255, 0.34);
  color: #ffffff;
}

.motion-toggle__icon {
  font-size: 0.62rem;
  color: var(--accent-gold);
}

/* راهنمای اسکرول پایین صحنه اول */
.scroll-hint {
  position: fixed;
  left: 44px;
  bottom: 24px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
  opacity: 0.78;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.scroll-hint.is-hidden {
  opacity: 0;
  transform: translateY(10px);
}

.scroll-hint__text {
  font-size: 0.64rem;
  letter-spacing: 0;
  color: var(--text-muted);
}

.scroll-hint__line {
  width: 34px;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 225, 53, 0.8), transparent);
}

/* ---------- بخش‌های داستانی اسکرول (Scrollytelling Layout) ---------- */

.scrolly-main {
  position: relative;
  z-index: 10;
}

.story-section {
  position: relative;
  min-height: 112svh;
  display: flex;
  align-items: center;
  padding: 96px 6vw;
}

.story-section--hero {
  min-height: 106svh;
  padding-top: 110px;
  direction: ltr;
}

.story-section--right {
  min-height: 118svh;
  justify-content: flex-end;
  direction: ltr;
}

.story-section--spacer {
  min-height: 92svh;
  justify-content: center;
  align-items: flex-end;
  padding-bottom: 64px;
  pointer-events: none;
}

.story-section--center {
  min-height: 128svh;
  justify-content: center;
}

.story-section--finale {
  min-height: 100svh;
  flex-direction: column;
  justify-content: center;
  padding-bottom: 32px;
}

.section-inner {
  width: min(440px, 44vw);
  direction: rtl;
  text-align: right;
  position: relative;
  z-index: 2;
}

.section-inner--left {
  margin-left: clamp(0px, 1.5vw, 24px);
}

.section-inner--right {
  width: min(440px, 44vw);
  margin-right: clamp(0px, 2vw, 40px);
}

/* تایپوگرافی فارسی Hero */
.hero-title {
  margin: 0 0 28px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.6rem, 5.2vw, 4.4rem);
  line-height: 1.18;
  letter-spacing: 0;
  color: #ffffff;
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--accent-gold);
}

.hero-copy {
  margin: 0 0 28px;
  max-width: 44ch;
  font-size: clamp(0.96rem, 1.15vw, 1.06rem);
  line-height: 1.75;
  color: var(--text-secondary);
  text-shadow: 0 2px 18px rgba(7, 7, 9, 0.92);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

/* تیتر بخش دوم */
.section-title {
  margin: 0 0 20px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 3.4vw, 3rem);
  line-height: 1.22;
  letter-spacing: 0;
  color: #ffffff;
}

.section-copy {
  margin: 0;
  max-width: 44ch;
  font-size: clamp(0.96rem, 1.1vw, 1.05rem);
  line-height: 1.75;
  color: var(--text-secondary);
}

/* برچسب ظریف مرحله زوم */
.zoom-whisper {
  text-align: center;
}

.zoom-whisper__tag {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(7, 7, 11, 0.55);
  backdrop-filter: blur(8px);
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  color: rgba(255, 225, 53, 0.85);
}

/* متن مرکزی بخش ۴ (پراکندگی ذرات) مطابق تصاویر ۱۰ تا ۱۲ با هاله محافظ خوانایی */
.scattered-copy {
  position: relative;
  width: min(880px, 100%);
  text-align: center;
  padding: clamp(28px, 4vw, 48px) clamp(20px, 4vw, 44px);
  border-radius: 36px;
  background: radial-gradient(
    ellipse 78% 72% at 50% 50%,
    rgba(7, 7, 11, 0.84) 0%,
    rgba(7, 7, 11, 0.56) 58%,
    rgba(7, 7, 11, 0) 100%
  );
  backdrop-filter: blur(4px);
}

.scattered-statement {
  margin: 0 auto 38px;
  font-family: var(--font-display);
    font-weight: 500;
  font-size: clamp(1.2rem, 2vw, 1.55rem);
  line-height: 1.7;
  letter-spacing: 0;
  color: #f4f4fa;
  text-shadow:
    0 2px 14px rgba(0, 0, 0, 0.95),
    0 6px 34px rgba(0, 0, 0, 0.9);
}

.scattered-statement--secondary {
  margin-bottom: 0;
  color: rgba(246, 246, 248, 0.94);
}

/* کارت پایانی (بخش ۵) */
.finale-card {
  width: min(640px, 100%);
  margin: auto 0;
  text-align: center;
  padding: clamp(28px, 4vw, 48px);
  border-radius: 28px;
  background: rgba(11, 11, 16, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.11);
  backdrop-filter: blur(18px);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
}

.finale-title {
  margin: 0 0 16px;
  font-family: var(--font-display);
    font-weight: 700;
  font-size: clamp(1.85rem, 3.3vw, 2.75rem);
  line-height: 1.25;
  letter-spacing: 0;
}

.finale-copy {
  margin: 0 auto 28px;
  max-width: 48ch;
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.6;
}

.finale-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}

.site-footer {
  width: 100%;
  max-width: 1200px;
  margin-top: 48px;
  padding: 22px 185px 12px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 20px;
}

.footer-links a,
.footer-link-btn {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  color: var(--text-muted);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
  transition: color 0.2s ease;
}

.footer-links a:hover,
.footer-link-btn:hover {
  color: #ffffff;
}

/* ---------- انیمیشن‌های ظاهر شدن عناصر (Compositor-only: transform & opacity) ---------- */

[data-reveal] {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

@media (prefers-reduced-motion: no-preference) {
  .has-reveal [data-reveal] {
    opacity: 0;
    transform: translate3d(0, 28px, 0);
    transition:
      opacity 0.75s cubic-bezier(0.22, 1, 0.36, 1),
      transform 0.75s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .has-reveal [data-reveal].is-visible {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

/* ---------- دیالوگ بومی Request Access ---------- */

dialog#access-dialog {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 24px;
  padding: 0;
  width: min(460px, calc(100vw - 32px));
  background: rgba(13, 13, 19, 0.94);
  color: var(--text-primary);
  box-shadow: 0 32px 96px rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(22px);
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  background: rgba(4, 4, 8, 0.72);
  backdrop-filter: blur(8px);
  overflow: hidden;
  overscroll-behavior: contain;
}

@media (prefers-reduced-motion: no-preference) {
  dialog#access-dialog {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
    transition:
      opacity 0.24s ease,
      transform 0.24s cubic-bezier(0.22, 1, 0.36, 1),
      display 0.24s allow-discrete,
      overlay 0.24s allow-discrete;
  }

  dialog#access-dialog[open] {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  @starting-style {
    dialog#access-dialog[open] {
      opacity: 0;
      transform: translateY(14px) scale(0.98);
    }
  }
}

.dialog-shell {
  padding: 28px;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.dialog-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 5px;
  margin-bottom: 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
}

.auth-tab {
  appearance: none;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 9px 12px;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.auth-tab.is-active {
  background: rgba(179, 128, 255, 0.2);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(179, 128, 255, 0.35);
}

.dialog-close {
  appearance: none;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.dialog-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.access-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field__label {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-muted);
}

.field input,
.field select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: #ffffff;
  padding: 11px 14px;
  font-family: var(--font-sans);
  font-size: 0.94rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field select option {
  background: #101016;
  color: #ffffff;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(179, 128, 255, 0.2);
}

.form-feedback {
  margin: 0;
  min-height: 1.3em;
  font-size: 0.86rem;
  color: #3ee8b5;
}

.form-feedback.is-error {
  color: #ff7a8a;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

/* فوکوس دسترس‌پذیر صفحه‌کلید */
:focus-visible {
  outline: 2px solid var(--accent-purple);
  outline-offset: 3px;
}

/* ---------- ریسپانسیو موبایل و تبلت ---------- */

@media (max-width: 900px) {
  .site-header {
    padding: 18px 20px;
  }

  .site-header.is-scrolled {
    padding: 14px 20px;
  }

  .site-nav {
    gap: 16px;
  }

  .nav-link {
    display: none;
  }

  .story-section {
    padding: 96px 22px 11vh;
    align-items: flex-end;
  }

  .story-section--hero {
    align-items: flex-end;
    padding-top: 44vh;
    padding-bottom: 10vh;
  }

  .story-section--right {
    justify-content: flex-start;
    padding-top: 44vh;
  }

  .section-inner,
  .section-inner--left,
  .section-inner--right {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    padding: 18px 20px;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(7, 7, 11, 0.55) 0%, rgba(7, 7, 11, 0.86) 100%);
    backdrop-filter: blur(8px);
  }

  .site-footer {
    padding: 22px 0 64px;
  }

  .hud-controls {
    right: 16px;
    bottom: 16px;
  }

  .chapter-dots {
    display: none;
  }

  .scroll-hint {
    left: 22px;
  }
}
