/*
 * Base styles: the font, a small reset, text defaults and a few helpers.
 *
 * The interface is right-to-left. Every rule uses logical properties
 * (inline-start, inline-end, block-start) and never a physical side,
 * so nothing here needs a mirrored copy. A test enforces this.
 */

@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/vazirmatn/Vazirmatn-Variable.f6d31671339d.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-block-start: var(--space-10);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  font-weight: 800;
  line-height: var(--leading-tight);
  text-wrap: balance;
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5,
h6 { font-size: var(--text-base); }

p {
  margin: 0;
  text-wrap: pretty;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease);
}

a:hover {
  color: var(--primary-deep);
}

/* A link inside a sentence is underlined, so it does not depend on colour alone. */
p a:not([class]) {
  text-decoration: underline;
  text-underline-offset: 3px;
}

img,
svg,
video,
canvas {
  display: block;
  max-inline-size: 100%;
}

img,
video {
  block-size: auto;
}

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

button,
[role="button"],
summary,
label[for],
select {
  cursor: pointer;
}

a,
button,
input,
select,
textarea,
summary {
  touch-action: manipulation;
}

button:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
}

table {
  border-collapse: collapse;
  inline-size: 100%;
}

hr {
  border: 0;
  border-block-start: 1px solid var(--line);
  margin: 0;
}

::selection {
  background: var(--primary-tint);
  color: var(--primary-deep);
}

::placeholder {
  color: var(--muted-2);
  opacity: 1;
}

/* Keyboard focus is always visible. Dark grounds switch --focus to amber. */
:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

[hidden],
[x-cloak] {
  display: none !important;
}

/* Set on <body> while a drawer is open, so the page behind does not scroll. */
body.is-locked {
  overflow: hidden;
}

/* ------------------------------------------------------------------ helpers */

/* Read by screen readers, not shown. */
.sr-only {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* First stop for keyboard users: jumps over the navigation. */
.skip-link {
  position: absolute;
  inset-block-start: var(--space-2);
  inset-inline-start: var(--space-2);
  z-index: var(--z-toast);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--surface);
  font-weight: 700;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
  color: var(--surface);
}

/* Latin fragments inside Persian text: emails, phone numbers, file names, clocks. */
.ltr {
  direction: ltr;
  unicode-bidi: isolate;
}

/* One line, cut with an ellipsis. The parent flex item needs min-inline-size: 0. */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-inline-size: 0;
}

/* Digits of equal width, for timers, prices and table columns. */
.tabular {
  font-variant-numeric: tabular-nums;
}

.icon {
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.text-muted { color: var(--muted); }
.text-subtle { color: var(--muted-2); }
.text-primary { color: var(--primary); }
.text-danger { color: var(--danger); }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-md { font-size: var(--text-md); }
.text-lg { font-size: var(--text-lg); }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }

/* A marker-pen highlight behind a few words. */
.mark {
  background: var(--highlight);
  padding: 1px var(--space-1);
  border-radius: var(--radius-xs);
}

/* Vertical rhythm: children stacked with one gap. */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--stack-gap, var(--space-4));
}

.stack--sm { --stack-gap: var(--space-2); }
.stack--lg { --stack-gap: var(--space-6); }
.stack--xl { --stack-gap: var(--space-8); }

/* A row of things that wraps when it runs out of room. */
.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cluster-gap, var(--space-3));
}

.cluster--sm { --cluster-gap: var(--space-2); }
.cluster--between { justify-content: space-between; }
.cluster--end { justify-content: flex-end; }

/* A responsive grid: as many equal columns as fit. */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(var(--grid-min, 280px), 100%), 1fr));
  gap: var(--grid-gap, var(--space-5));
}

.container {
  inline-size: 100%;
  max-inline-size: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--narrow { --container: 760px; }

/* Long running text: articles, static pages, generated minutes. */
.prose {
  line-height: var(--leading-loose);
  max-inline-size: 72ch;
}

.prose > * + * { margin-block-start: var(--space-4); }
.prose h2 { margin-block-start: var(--space-8); }
.prose h3 { margin-block-start: var(--space-6); }
.prose a { text-decoration: underline; text-underline-offset: 3px; }
.prose ul,
.prose ol { padding-inline-start: var(--space-6); }
.prose ul { list-style: disc; }
.prose ol { list-style: persian; }
.prose li + li { margin-block-start: var(--space-2); }
.prose blockquote {
  margin: 0;
  padding: var(--space-3) var(--space-5);
  border-inline-start: 4px solid var(--primary-line);
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
}
.prose img { border-radius: var(--radius-md); }
.prose code {
  direction: ltr;
  unicode-bidi: isolate;
  padding: 1px var(--space-1);
  border-radius: var(--radius-xs);
  background: var(--surface-sunken);
  font-size: 0.9em;
}

/* People who ask for less motion get none. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
