/*
 * Base: reset, document, typography, links, focus.
 *
 * RTL rule for this whole theme: logical properties only. margin-inline-start,
 * padding-inline-end, inset-inline-start, border-inline-start, text-align:start.
 * The physical equivalents do not flip under dir="rtl" and are the single most
 * common cause of a Persian layout that looks right in development and wrong in
 * production. DESIGN.md rule 12 forbids them; grep before shipping.
 */

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

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

body {
  margin: 0;
  background-color: var(--color-void);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: var(--leading-body);
  text-align: start;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Persian is never letter-spaced: it breaks the connected letterforms.
   DESIGN.md rule 9. Only isolated Latin strings may carry tracking. */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-2);
  line-height: var(--leading-tight);
  font-weight: 700;
  letter-spacing: normal;
  text-wrap: balance;
}

h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }

p, ul, ol, dl, blockquote, figure, table {
  margin: 0 0 var(--space-3);
}

p, li {
  max-width: var(--measure);
  text-wrap: pretty;
}

a {
  color: inherit;
  text-decoration-color: var(--color-line-strong);
  text-underline-offset: 0.25em;
  transition: color var(--dur-fast) var(--ease-out),
              text-decoration-color var(--dur-fast) var(--ease-out);
}

a:hover {
  color: var(--color-signal);
  text-decoration-color: var(--color-signal);
}

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

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* Visible focus everywhere. A 2px signal outline with an offset, never a glow. */
:focus-visible {
  outline: 2px solid var(--color-signal);
  outline-offset: 2px;
  border-radius: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

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

.skip-link:focus {
  position: fixed;
  inset-block-start: var(--space-2);
  inset-inline-start: var(--space-2);
  z-index: 999;
  padding: var(--space-1) var(--space-2);
  background: var(--color-signal);
  color: var(--color-void);
  border-radius: var(--radius-sm);
}

/* Numeric columns line up. No second monospace font is loaded for this. */
.tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

@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;
    scroll-behavior: auto !important;
  }
}
