/* =============================================================================
   RAYASA — Fonts, reset, typography, layout primitives
   ========================================================================== */

/* -----------------------------------------------------------------------------
   Self-hosted variable fonts.

   Google Fonts is unreliable from inside Iran, which is where most of this
   site's audience is; shipping the woff2 files ourselves removes a third-party
   round trip that can hang for seconds or fail outright. One variable file per
   subset covers weights 100–900, and the unicode-range split means a visitor
   reading Persian never downloads the Latin-ext file unless the page uses it.
   -------------------------------------------------------------------------- */
@font-face {
  font-family: 'Vazirmatn';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/vazirmatn-arabic-wght.woff2') format('woff2-variations');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1,
    U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF,
    U+FE70-FE74, U+FE76-FEFC;
}

@font-face {
  font-family: 'Vazirmatn';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/vazirmatn-latin-wght.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Vazirmatn';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/vazirmatn-latin-ext-wght.woff2') format('woff2-variations');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF,
    U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url('../fonts/jetbrains-mono-latin-wght.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-block-start: calc(var(--header-h) + var(--space-6));
}

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

body {
  min-block-size: 100svh;
  background-color: var(--bg);
  color: var(--text-soft);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-loose);
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body.is-locked {
  overflow: hidden;
}

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

img,
video {
  block-size: auto;
}

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

button {
  background: none;
  border: 0;
  cursor: pointer;
}

ul[class],
ol[class] {
  list-style: none;
  padding: 0;
}

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

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

::selection {
  background: rgb(34 211 238 / 26%);
  color: var(--accent-300);
}

/* -----------------------------------------------------------------------------
   Focus. Never remove the indicator — replace it with a better one.
   -------------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--accent-400);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}

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

.skip-link {
  position: fixed;
  inset-block-start: var(--space-3);
  inset-inline-start: var(--space-3);
  z-index: 200;
  padding: var(--space-3) var(--space-5);
  background: var(--brand-400);
  color: #fff;
  font-weight: 700;
  font-size: var(--text-sm);
  border-radius: var(--r-md);
  transform: translateY(-200%);
  transition: transform var(--dur-base) var(--ease-out);
}

.skip-link:focus-visible {
  transform: translateY(0);
}

/* -----------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */
h1,
h2,
h3,
h4 {
  color: var(--text);
  line-height: var(--leading-tight);
  font-weight: 800;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

.h1 {
  font-size: var(--text-5xl);
  font-weight: 900;
  letter-spacing: -0.01em;
}

.h2 {
  font-size: var(--text-4xl);
  font-weight: 900;
}

.h3 {
  font-size: var(--text-2xl);
}

.h4 {
  font-size: var(--text-xl);
}

.lede {
  font-size: var(--text-lg);
  color: var(--text-muted);
  line-height: var(--leading-loose);
  max-inline-size: 58ch;
}

.text-muted {
  color: var(--text-muted);
}

.text-dim {
  color: var(--text-dim);
}

.text-sm {
  font-size: var(--text-sm);
}

.text-xs {
  font-size: var(--text-xs);
}

/* Gradient headline fragment. */
.grad {
  background: linear-gradient(275deg, var(--brand-300), var(--accent-400) 45%, var(--brand-500));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* -----------------------------------------------------------------------------
   Bidirectional text.

   Persian is RTL but the page is full of Latin technical terms, version
   strings and figures. Left to itself the bidi algorithm reorders a run like
   "99.99%" into "%99.99" and drags trailing punctuation to the wrong end.
   `unicode-bidi: isolate` fences each run off so it lays out on its own terms
   without disturbing the sentence around it — this is the only reliable fix.
   -------------------------------------------------------------------------- */
.mono,
.ltr {
  font-family: var(--font-mono);
  direction: ltr;
  unicode-bidi: isolate;
  font-feature-settings: 'ss02' 1;
}

.ltr {
  font-family: inherit;
}

/* A Latin/number run sitting inside a Persian sentence. */
.num {
  unicode-bidi: isolate;
  direction: ltr;
  font-variant-numeric: tabular-nums;
}

/* Blocks of terminal output need left alignment as well as LTR order. */
.mono-block {
  font-family: var(--font-mono);
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
}

/* -----------------------------------------------------------------------------
   Layout primitives
   -------------------------------------------------------------------------- */
.shell {
  inline-size: 100%;
  max-inline-size: var(--shell-max);
  margin-inline: auto;
  padding-inline: var(--shell-pad);
}

.shell--wide {
  max-inline-size: 88rem;
}

.stack > * + * {
  margin-block-start: var(--flow, var(--space-4));
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap, var(--space-3));
}

.grid {
  display: grid;
  gap: var(--gap, var(--space-6));
}

.section {
  padding-block: var(--section-gap);
  position: relative;
}

.section + .section {
  padding-block-start: 0;
}

/*
  Trailing space before the footer.

  `.section` carries its own, so a page built from sections ends correctly by
  accident of the rhythm. A page that ends on a bare `.shell` — the two legal
  pages, both lab pages — had nothing at all: `main.page` has no bottom padding
  and neither does `.shell`, so the last block sat exactly on the footer's top
  border, at zero.

  `:not(.section)` keeps it from doubling where a section already ends the page.
  It used to also exclude `.cardpage`, the about page's one-screen card: that
  page had no footer, so trailing space there was not spacing, it was a
  scrollbar. The about page is now an ordinary sectioned page with a footer like
  every other, so the exclusion went with it — but the reasoning is kept here
  because the next page that ends without a footer will need it again.

  **A page must not add its own `padding-block-end` on top of this.** Two pages
  did, and both put roughly 310–360px between the last line and the footer. The
  single exception is `.status-page`, whose last child is a `hidden` section —
  there this rule lands on something invisible, and CSS cannot express "the last
  child that is actually displayed". That exception is written down where it
  lives.
*/
main.page > *:last-child:not(.section) {
  padding-block-end: var(--section-gap);
}

/* -----------------------------------------------------------------------------
   Utilities

   Deliberately a short list. Every one of these exists because a `style="…"`
   attribute would otherwise appear in the markup, and the site's
   Content-Security-Policy does not allow inline styles.
   -------------------------------------------------------------------------- */
.mt-5 {
  margin-block-start: var(--space-5);
}

.mt-6 {
  margin-block-start: var(--space-6);
}

.mb-3 {
  margin-block-end: var(--space-3);
}

.mb-5 {
  margin-block-end: var(--space-5);
}

.mb-6 {
  margin-block-end: var(--space-6);
}

.gap-2 {
  --gap: var(--space-2);
}

.gap-3 {
  --gap: var(--space-3);
}

.gap-4 {
  --gap: var(--space-4);
}

.grow {
  flex: 1;
}

.block {
  display: block;
}

.measure-narrow {
  max-inline-size: 26rem;
}

.link-accent {
  color: var(--accent-300);
}

.sprite {
  position: absolute;
}

/* A figure and its caption stacked in a tight two-line block. */
.stat-line {
  display: block;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text);
}

.visually-hidden {
  position: absolute !important;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

.no-scrollbar {
  scrollbar-width: none;
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}

/* -----------------------------------------------------------------------------
   Scrollbar
   -------------------------------------------------------------------------- */
@supports (scrollbar-color: red blue) {
  html {
    scrollbar-color: var(--surface-4) var(--bg);
    scrollbar-width: thin;
  }
}

::-webkit-scrollbar {
  inline-size: 7px;
  block-size: 7px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--surface-4);
  border-radius: var(--r-full);
}

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

/* -----------------------------------------------------------------------------
   Print — the marketing chrome is noise on paper.
   -------------------------------------------------------------------------- */
@media print {
  body {
    background: #fff;
    color: #000;
  }

  .site-header,
  .site-footer,
  .agent-launcher,
  .hero__media,
  .toast,
  .skip-link {
    display: none !important;
  }

  .section {
    padding-block: var(--space-8);
    break-inside: avoid;
  }
}
