/* ==========================================================================
   base — reset, typography, the night ground, focus, layout shell
   Written with logical properties throughout: the Arabic RTL build is the
   design, and the English LTR build is the same CSS read in the other
   direction. There is no `.rtl` override block anywhere in this project.
   ========================================================================== */

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

/* The `hidden` attribute must always win, even on an element whose own class
   sets a `display` (.empty, .card, …) — otherwise a success panel that is
   both `class="empty"` and `hidden` shows up immediately instead of waiting
   for its trigger, since an author rule at equal specificity beats the UA
   stylesheet's own `[hidden]{display:none}` by cascade order alone. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* The sticky header must not swallow the anchor it just scrolled to. */
  scroll-padding-block-start: 6rem;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--night-1);
  color: var(--chalk-soft);
  font-family: var(--font-body);
  font-size: var(--t-base);
  line-height: var(--lh-body);
  font-weight: 400;
  /* Arabic renders thin on dark grounds without this. */
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;            /* belt; the braces are in the layout rules */
}

/* Grain + the far glow of the two mast pairs. One fixed layer, no repaint. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(60vw 42vh at 12% -6%, rgba(255,238,186,.10), transparent 62%),
    radial-gradient(60vw 42vh at 88% -6%, rgba(255,238,186,.085), transparent 62%),
    radial-gradient(90vw 60vh at 50% 108%, rgba(14,92,51,.30), transparent 70%);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: .05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

/* --- Type ---------------------------------------------------------------- */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--chalk);
  line-height: var(--lh-head);
  font-weight: 700;
  margin: 0;
  text-wrap: balance;
}
h1 { font-size: var(--t-xxl); line-height: var(--lh-tight); font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: var(--t-xl); font-weight: 800; }
h3 { font-size: var(--t-lg); }
h4 { font-size: var(--t-md); }

p { margin: 0 0 var(--s-4); text-wrap: pretty; }
p:last-child { margin-block-end: 0; }

a { color: var(--flood); text-underline-offset: .28em; text-decoration-thickness: 1px; }
a:hover { color: var(--sodium); }

strong, b { font-weight: 600; color: var(--chalk); }

ul, ol { margin: 0 0 var(--s-4); padding-inline-start: 1.35em; }
li { margin-block-end: var(--s-2); }

hr {
  border: 0;
  border-block-start: var(--line) solid var(--hairline);
  margin-block: var(--s-6);
}

/* Latin digits inside Arabic prose keep their own direction and stay tabular
   so that score columns and time columns line up. */
.num, time, .score { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

.eyebrow {
  font-family: var(--font-display);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--sodium);
  margin: 0 0 var(--s-3);
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.eyebrow::after {
  content: "";
  flex: 1;
  block-size: var(--line);
  background: linear-gradient(to left, transparent, var(--hairline));
}
:dir(ltr) .eyebrow::after { background: linear-gradient(to right, transparent, var(--hairline)); }

.lede {
  font-size: var(--t-md);
  color: var(--chalk-dim);
  max-inline-size: 58ch;
}

.muted { color: var(--chalk-dim); }
.label {
  font-family: var(--font-display);
  font-size: var(--t-micro);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--chalk-mute);
  font-weight: 600;
}

/* --- Accessibility plumbing ---------------------------------------------- */

:focus-visible {
  outline: 3px solid var(--sodium);
  outline-offset: 3px;
  border-radius: var(--r-1);
}
/* Never remove the outline for mouse users without replacing it — but do stop
   the double ring on elements that already draw their own focus treatment. */
.focus-self:focus-visible { outline-color: transparent; }

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

.skip-link {
  position: fixed;
  inset-block-start: var(--s-3);
  inset-inline-start: var(--s-3);
  z-index: 200;
  transform: translateY(-160%);
  background: var(--sodium);
  color: var(--night-1);
  font-weight: 700;
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-2);
  text-decoration: none;
  transition: transform var(--d-quick) var(--e-out);
}
.skip-link:focus { transform: translateY(0); color: var(--night-1); }

/* --- Layout shell -------------------------------------------------------- */

.shell {
  inline-size: min(100% - (var(--gutter) * 2), var(--shell));
  margin-inline: auto;
}
.shell--narrow { inline-size: min(100% - (var(--gutter) * 2), 900px); }

main { position: relative; z-index: var(--z-content); }

.section { padding-block: var(--section-y); position: relative; }
.section--tight { padding-block: clamp(2.5rem, 1.5rem + 4vw, 5rem); }

/* The halfway line: a chalk rule interrupted by the centre circle. It is the
   only section divider in the project. */
.halfway {
  position: relative;
  block-size: 0;
  border-block-start: var(--line) solid var(--hairline);
}
.halfway::after {
  content: "";
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 50%;
  inline-size: 56px; block-size: 56px;
  translate: 50% -50%;
  border: var(--line) solid var(--hairline);
  border-radius: 50%;
  background: var(--night-1);
}
:dir(ltr) .halfway::after { translate: -50% -50%; }

/* --- Grids used by more than one page ------------------------------------ */

.grid { display: grid; gap: var(--s-5); }
.grid--2 { grid-template-columns: minmax(0, 1fr); }
.grid--3 { grid-template-columns: minmax(0, 1fr); }
.grid--4 { grid-template-columns: minmax(0, 1fr); }

@media (min-width: 640px) {
  .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.stack > * + * { margin-block-start: var(--s-4); }
.stack-lg > * + * { margin-block-start: var(--s-6); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
.push-end { margin-inline-start: auto; }

/* --- Scroll reveal -------------------------------------------------------
   JS adds .is-in when the element crosses the viewport. If JS never runs the
   content is still visible: the hidden state is applied by JS itself
   (html.js-reveal), never by the stylesheet alone.                          */

.js-reveal [data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition:
    opacity var(--d-enter) var(--e-out),
    transform var(--d-enter) var(--e-out);
  transition-delay: var(--reveal-delay, 0ms);
}
.js-reveal [data-reveal].is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .js-reveal [data-reveal] { opacity: 1; transform: none; transition: none; }
}

::selection { background: var(--sodium); color: var(--night-1); }

/* Firefox keeps a visible scrollbar; colour it so it stops glowing white. */
html { scrollbar-color: var(--hairline) var(--night-1); }
