/* ==========================================================================
   BASE LAYER — Dark Polarity, Accessibility & Multilingual Font Discipline
   ========================================================================== */

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

html {
  scroll-behavior: smooth;
  background-color: var(--bg-ground);
  color: var(--ink-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  scrollbar-color: rgba(255, 255, 255, 0.25) var(--bg-surface);
  scrollbar-width: thin;
}

html[lang="fa"] {
  font-family: var(--font-fa), var(--font-body);
}

body {
  background-color: var(--bg-ground);
  color: var(--ink-primary);
  min-height: 100dvh;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  caret-color: var(--accent);
}

::selection {
  background-color: var(--accent);
  color: var(--accent-ink);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-surface);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--ui-focus);
  outline-offset: 3px;
}

h1, h2 {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--ink-primary);
  text-wrap: balance;
}

h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink-primary);
  text-wrap: balance;
}

html[lang="fa"] h1,
html[lang="fa"] h2,
html[lang="fa"] h3,
html[lang="fa"] h4 {
  font-family: var(--font-fa), var(--font-display);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.32;
}

h1 {
  font-size: var(--step-display);
  line-height: 1.06;
  letter-spacing: -0.025em;
}

h2 {
  font-size: var(--step-heading);
  line-height: 1.14;
  letter-spacing: -0.02em;
}

h3 {
  font-size: var(--step-sub);
  line-height: 1.28;
  letter-spacing: -0.01em;
}

p {
  font-size: var(--step-body);
  color: var(--ink-secondary);
  max-width: 64ch;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}

img, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

pre, code, kbd, samp {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.ltr-iso {
  direction: ltr;
  unicode-bidi: isolate;
}

html[dir="rtl"] svg[data-flip] {
  transform: scaleX(-1);
}

.tabular-num {
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 900;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 18px;
  border-radius: var(--radius-control);
  font-weight: 700;
  font-size: var(--step-meta);
  transition: transform var(--dur-fast) var(--ease-spring);
}

.skip-link:focus {
  top: 16px;
}

@media (prefers-reduced-motion: no-preference) {
  .motion-target {
    will-change: transform, opacity;
  }

  .motion-ready .motion-reveal {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity var(--dur-slow) var(--ease-spring), transform var(--dur-slow) var(--ease-spring);
    transition-delay: var(--stagger, 0ms);
  }

  .motion-ready .motion-reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .motion-ready .motion-reveal {
    opacity: 1 !important;
    transform: none !important;
  }
}
