/* Neritation. Base: reset, type, rhythm.
   RTL first. Logical properties only, so the English route mirrors for free. */

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

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

:root {
  --font-sans: "Geist", "Heebo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Hebrew optical corrections. Display Hebrew at 95 percent of the Latin size,
     body Hebrew at 103 percent, leading lifted. Set under :lang(he) below. */
  --he-display: 1;
  --he-body: 1;

  --fs-display: calc(clamp(2.75rem, 1.4rem + 4.6vw, 5.75rem) * var(--he-display));
  --fs-h2: calc(clamp(2rem, 1.15rem + 2.8vw, 3.5rem) * var(--he-display));
  --fs-h3: calc(clamp(1.375rem, 1.15rem + 0.8vw, 1.75rem) * var(--he-display));
  --fs-lg: clamp(1.375rem, 1.05rem + 1.1vw, 1.875rem);
  --fs-sub: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
  --fs-body: calc(1rem * var(--he-body));
  --fs-sm: 0.9375rem;
  --fs-xs: 0.8125rem;

  --lh-display: 1.05;
  --lh-body: 1.6;
  --track-display: -0.02em;
  --measure: 62ch;

  --gutter: clamp(1.25rem, 4vw, 3rem);
  --container: 1240px;
  --section-y: clamp(6rem, 4rem + 7vw, 11rem);
  --header-h: 4.5rem;

  --radius: 20px;
  --radius-pill: 999px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur: 240ms;
}

html:lang(he) {
  --he-display: 0.95;
  --he-body: 1.03;
  --lh-display: 1.14;
  --lh-body: 1.7;
  --track-display: -0.015em;
  --measure: 50ch;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--void);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

/* Author display rules must never resurrect a hidden element. */
[hidden] { display: none !important; }

h1, h2, h3, h4, p, ul, ol, figure, fieldset { margin: 0; }
fieldset { padding: 0; border: 0; min-inline-size: 0; }
legend { padding: 0; }

h1, h2, h3 {
  font-weight: 500;
  line-height: var(--lh-display);
  letter-spacing: var(--track-display);
  text-wrap: balance;
  overflow-wrap: anywhere;
}
p { text-wrap: pretty; }

/* No italics anywhere. Hebrew has none, and a synthesised oblique on Heebo reads as a fault. */
em, i, cite, dfn, address { font-style: normal; }

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

a { color: var(--text-accent); text-decoration: none; text-underline-offset: 0.18em; }
a:hover { text-decoration: underline; }

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 3px; border-radius: 4px; }

::selection { background: var(--ajna-indigo); color: var(--starlight); }

/* Bidi. Latin and digit runs inside RTL are isolated; digits set in mono. */
bdi, .num { unicode-bidi: isolate; }
.num {
  font-family: var(--font-mono);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.sep { color: var(--text-secondary); margin-inline: 0.35em; }
.nowrap { white-space: nowrap; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  inset-inline-start: 1rem;
  top: -100%;
  z-index: 100;
  background: var(--action);
  color: var(--on-action);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-pill);
  font-weight: 500;
}
.skip-link:focus { top: 1rem; outline-offset: 4px; text-decoration: none; }

/* Type roles */
.display {
  font-size: var(--fs-display);
  font-weight: 500;
  line-height: var(--lh-display);
  letter-spacing: var(--track-display);
  text-wrap: balance;
}
.subline {
  font-size: var(--fs-sub);
  line-height: 1.55;
  color: var(--text-muted);
  max-inline-size: var(--measure);
}
.section__head { margin-block-end: clamp(2.5rem, 2rem + 3vw, 4.5rem); }
.section__title { font-size: var(--fs-h2); max-inline-size: 26ch; }
.section__subline {
  margin-block-start: 1.25rem;
  font-size: var(--fs-sub);
  line-height: 1.55;
  color: var(--text-muted);
  max-inline-size: var(--measure);
}
.link { color: var(--text-accent); font-weight: 500; }

/* Long form content, posts and legal pages */
.prose { font-size: 1.0625rem; line-height: 1.75; max-inline-size: var(--measure); }
.prose > * + * { margin-block-start: 1.25em; }
.prose h2 { font-size: var(--fs-h3); margin-block-start: 2.2em; }
.prose h3 { font-size: 1.25rem; margin-block-start: 1.8em; }
.prose ul, .prose ol { padding-inline-start: 1.25em; }
.prose li + li { margin-block-start: 0.35em; }
.prose blockquote {
  border-inline-start: 2px solid var(--void-edge);
  padding-inline-start: 1.25rem;
  margin-inline: 0;
  color: var(--text-muted);
}
.prose img { border-radius: var(--radius); }
.prose code { font-family: var(--font-mono); font-size: 0.9em; background: var(--void-raised); padding: 0.1em 0.35em; border-radius: 6px; }
.prose pre { background: var(--void-raised); padding: 1.25rem; border-radius: var(--radius); overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose a { text-decoration: underline; }
.prose hr { border: 0; border-top: 1px solid var(--void-edge); margin-block: 2.5em; }
.prose figure figcaption { color: var(--text-secondary); font-size: 0.875rem; margin-block-start: 0.5em; }

@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;
  }
}
