/* ============================================================
   base.css — design tokens, reset, typography, buttons, grid primitive
   ------------------------------------------------------------
   Mobile-first: every rule is written for 390px, then widened.
   Logical properties throughout (margin-inline, inset-inline-start)
   so an Arabic RTL build is a translation job, not a rebuild.
   ============================================================ */

:root {
  /* ---- colour ------------------------------------------------
     Measured against --bg #0A0F16 (WCAG 2.1 contrast ratio):
       --text      15.9 : 1   body copy, headlines
       --accent-hi  6.93: 1   body links, small accent text  -> AA
       --muted      6.46: 1   secondary copy                 -> AA
       --accent     4.09: 1   BELOW AA for body text.
                              Large text (>=24px), borders, fills,
                              and non-text UI only. Never small copy.
     ------------------------------------------------------------ */
  --bg:          #0A0F16;
  --surface:     #121A24;
  --surface-2:   #1A2430;
  --line:        #1E2A38;
  --line-strong: #2C3B4D;
  --accent:      #0E78C0;
  --accent-hi:   #38A3E8;
  --text:        #E8EDF2;
  --muted:       #8A97A6;

  /* ---- type ---- */
  --font-display: 'Archivo', system-ui, sans-serif;
  --font-body:    'IBM Plex Sans', system-ui, sans-serif;
  --font-mono:    'IBM Plex Mono', ui-monospace, monospace;

  /* Fluid scale. Lower bound = 390px, upper bound = 1440px. */
  --step-hero: clamp(2.75rem, 1.3rem + 6.2vw, 6rem);
  --step-xl:   clamp(2rem,   1.2rem + 3.4vw, 3.75rem);
  --step-l:    clamp(1.5rem, 1.1rem + 1.7vw, 2.5rem);
  --step-m:    clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
  --step-lead: clamp(1.0625rem, 0.98rem + 0.4vw, 1.3125rem);
  --step-body: 1rem;
  --step-sm:   0.9375rem;
  --step-xs:   0.8125rem;

  /* ---- space: 4px base, 8px module ---- */
  --sp-1: 0.25rem;  --sp-2: 0.5rem;   --sp-3: 0.75rem;  --sp-4: 1rem;
  --sp-5: 1.5rem;   --sp-6: 2rem;     --sp-7: 3rem;     --sp-8: 4rem;
  --sp-9: 6rem;     --sp-10: 8rem;

  --section-y: clamp(4rem, 2rem + 8vw, 8.5rem);
  --gutter:    clamp(1.25rem, 0.5rem + 3vw, 4rem);
  --measure:   68ch;
  --wrap:      1360px;

  /* ---- pixel module: the LED cabinet lattice ----
     One "pixel" of the grid. Everything structural is a multiple. */
  --px-pitch: 14px;

  /* ---- motion ---- */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur:  0.4s;

  /* LED cabinets have square corners. So does this site. */
  --radius: 2px;
}

@media (min-width: 768px) { :root { --px-pitch: 18px; } }

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-body);
  line-height: 1.65;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, video, svg, picture { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }

h1, h2, h3, h4, p, figure, blockquote, ul, ol, dl, dd { margin: 0; }
ul, ol { padding-inline-start: 0; list-style: none; }

/* ============================================================
   typography
   ============================================================ */
.display,
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

/* Archivo's width axis is the point of choosing it: headlines run
   wide and engineered, small headings pull back to normal width. */
.t-hero {
  font-size: var(--step-hero);
  font-stretch: 112%;
  font-weight: 700;
  line-height: 0.96;
  letter-spacing: -0.025em;
  text-transform: uppercase;
}
.t-xl { font-size: var(--step-xl); font-stretch: 108%; letter-spacing: -0.02em; }
.t-l  { font-size: var(--step-l);  font-stretch: 104%; }
.t-m  { font-size: var(--step-m);  font-stretch: 100%; font-weight: 600; letter-spacing: -0.005em; }

.lead {
  font-size: var(--step-lead);
  line-height: 1.55;
  color: var(--muted);
  max-width: 46ch;
  text-wrap: pretty;
}

.prose { max-width: var(--measure); }
.prose p + p { margin-block-start: var(--sp-4); }
.prose strong { color: var(--text); font-weight: 600; }

/* Eyebrow — mono, spaced, the label above a section.
   Marks what kind of content follows, not decoration. */
.eyebrow {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--step-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-hi);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-block-end: var(--sp-5);
}
/* The lit pixel that opens every eyebrow — the smallest instance
   of the site's one recurring device. */
.eyebrow::before {
  content: "";
  inline-size: 8px;
  block-size: 8px;
  background: var(--accent);
  flex: none;
}

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

/* ---- spec: a datasheet line. Value in mono, unit, label beneath. ---- */
.spec { display: flex; flex-direction: column; gap: var(--sp-2); }
.spec__value {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: clamp(1.75rem, 1.1rem + 2.6vw, 2.75rem);
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.spec__unit {
  font-size: 0.44em;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-inline-start: 0.25em;
}
.spec__label {
  font-size: var(--step-xs);
  line-height: 1.45;
  color: var(--muted);
  max-width: 24ch;
}

/* ============================================================
   links & focus
   ============================================================ */
a { color: var(--accent-hi); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--text); }

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent-hi);
  outline-offset: 3px;
  border-radius: 0;
}

.skip-link {
  position: absolute;
  inset-block-start: -100%;
  inset-inline-start: var(--sp-4);
  z-index: 100;
  background: var(--accent);
  color: #fff;
  padding: var(--sp-3) var(--sp-4);
  text-decoration: none;
}
.skip-link:focus { inset-block-start: var(--sp-4); color: #fff; }

/* ============================================================
   layout helpers
   ============================================================ */
.wrap {
  inline-size: 100%;
  max-inline-size: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.section { padding-block: var(--section-y); }
.section--tight { padding-block: calc(var(--section-y) * 0.6); }
.section--surface { background: var(--surface); }

.stack > * + * { margin-block-start: var(--sp-5); }

/* ============================================================
   buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  min-block-size: 48px;
  padding: var(--sp-3) var(--sp-5);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--step-sm);
  letter-spacing: 0.04em;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hi); color: #04070B; }

.btn--ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn--ghost:hover { border-color: var(--accent-hi); color: var(--accent-hi); background: rgba(56,163,232,0.06); }

/* Arrow travels on hover — the only micro-interaction on buttons. */
.btn__arrow { transition: transform var(--dur) var(--ease); }
.btn:hover .btn__arrow { transform: translateX(4px); }
@media (prefers-reduced-motion: reduce) {
  .btn__arrow, .btn:hover .btn__arrow { transition: none; transform: none; }
}

/* ============================================================
   the pixel lattice — this site's one signature device
   ------------------------------------------------------------
   An LED wall is cabinets; a cabinet is a lattice of pixel modules.
   Drawn with gradients (no DOM cost), scaled by --px-pitch.
   Three appearances, same primitive:
     .lattice        ambient field behind the hero
     .rule           a one-module divider between sections
     .card:hover     the lattice inside a card brightens
   ============================================================ */
.lattice {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right,  var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: var(--px-pitch) var(--px-pitch);
  opacity: 0.55;
  /* Light falls off toward the edges, the way it does in a dark room. */
  -webkit-mask-image: radial-gradient(120% 90% at 50% 35%, #000 0%, #000 42%, transparent 78%);
          mask-image: radial-gradient(120% 90% at 50% 35%, #000 0%, #000 42%, transparent 78%);
}

/* A single module-high rule. Three lit cells at the start, then the
   lattice fading right — reads as the edge of a cabinet. */
.rule {
  block-size: var(--px-pitch);
  border: 0;
  margin: 0;
  background-image:
    linear-gradient(to right, var(--accent) 0 calc(var(--px-pitch) * 3), transparent calc(var(--px-pitch) * 3)),
    linear-gradient(to right, var(--line) 1px, transparent 1px);
  background-size: 100% 100%, var(--px-pitch) var(--px-pitch);
  background-repeat: no-repeat, repeat-x;
  -webkit-mask-image: linear-gradient(to right, #000 0%, #000 30%, transparent 100%);
          mask-image: linear-gradient(to right, #000 0%, #000 30%, transparent 100%);
}

/* ============================================================
   scroll reveal — set by js/reveal.js, removed if reduced motion
   ============================================================ */
[data-reveal] {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
[data-reveal].is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1; transform: none; transition: none; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
