/* ==========================================================================
   Reset, typography, primitives
   ========================================================================== */

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

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

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

body.nx-locked { overflow: hidden; }

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

/* --- Headings ------------------------------------------------------------ */

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  color: inherit;
  font-family: var(--nx-font-display);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

h1 { font-size: var(--nx-step-6); }
h2 { font-size: var(--nx-step-4); }
h3 { font-size: var(--nx-step-2); letter-spacing: -0.02em; }
h4 { font-size: var(--nx-step-1); letter-spacing: -0.015em; }

p { margin: 0; text-wrap: pretty; }
p + p { margin-top: 0.9em; }

ul, ol { margin: 0; padding: 0; }
dl, dd { margin: 0; }

/* Emphasis inside a headline: cobalt weight, never a contrasting typeface. */
.nx-hl { color: var(--nx-blue); }

/* --- Mono labels --------------------------------------------------------- */

.nx-label {
  display: inline-block;
  color: var(--nx-ink-3);
  font-family: var(--nx-font-mono);
  font-size: var(--nx-step--2);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.nx-label--blue { color: var(--nx-blue); }

/* --- Links ----------------------------------------------------------------- */

a {
  color: var(--nx-blue);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
  transition: color var(--nx-dur) var(--nx-ease);
}

a:hover { color: var(--nx-coral); }

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--nx-blue);
  outline-offset: 2px;
}

::selection {
  color: var(--nx-white);
  background: var(--nx-blue);
}

/* --- Scrollbar --------------------------------------------------------------- */

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--nx-paper-2); }
::-webkit-scrollbar-thumb { background: var(--nx-rule-strong); border: 4px solid var(--nx-paper-2); }
::-webkit-scrollbar-thumb:hover { background: var(--nx-blue); }

/* --- Layout primitives --------------------------------------------------------- */

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

.nx-container--narrow { max-width: 58rem; }

.nx-section { padding-block: var(--nx-section); }
.nx-section--sm { padding-block: var(--nx-section-sm); }

.nx-stack { display: grid; gap: 1.25rem; }
.nx-stack--lg { gap: 2.25rem; }

/* --- Rules: the main structural device ------------------------------------------- */

.nx-rule {
  width: 100%;
  height: 1px;
  background: var(--nx-rule);
  transform-origin: left;
}

/* Sections are separated by hairlines rather than by colour blocks. */
.nx-divide { border-top: 1px solid var(--nx-rule); }

/* --- Surfaces ------------------------------------------------------------------------
   Three surfaces alternate down a page: paper, charcoal slab, and a single
   cobalt block. A section declares its own surface; nothing switches globally. */

.nx-surface-paper2 { background: var(--nx-paper-2); }

/* --- Charcoal slab -------------------------------------------------------------------- */

.nx-surface-slab {
  color: var(--nx-on-slab);
  background: var(--nx-slab);
}

.nx-surface-slab :is(h1, h2, h3, h4) { color: var(--nx-on-slab); }
.nx-surface-slab .nx-muted { color: var(--nx-on-slab-2); }
.nx-surface-slab .nx-lede { color: var(--nx-on-slab-2); }
.nx-surface-slab .nx-label { color: var(--nx-on-slab-3); }
.nx-surface-slab .nx-label--blue { color: var(--nx-blue-lit); }
.nx-surface-slab .nx-hl { color: var(--nx-blue-lit); }
.nx-surface-slab .nx-rule { background: var(--nx-rule-slab); }
.nx-surface-slab .nx-divide { border-top-color: var(--nx-rule-slab); }
.nx-surface-slab a:not(.nx-btn) { color: var(--nx-blue-lit); }
.nx-surface-slab a:not(.nx-btn):hover { color: var(--nx-on-slab); }
.nx-surface-slab ::selection { color: var(--nx-slab); background: var(--nx-blue-lit); }

/* --- Cobalt block: the one saturated surface, used for a call to action ---------------- */

.nx-surface-blue {
  color: var(--nx-white);
  background: var(--nx-blue);
}

.nx-surface-blue :is(h1, h2, h3, h4) { color: var(--nx-white); }
.nx-surface-blue a:not(.nx-btn) { color: var(--nx-white); }
.nx-surface-blue a:not(.nx-btn):hover { color: var(--nx-paper); }
.nx-surface-blue .nx-label { color: rgba(255, 255, 255, 0.7); }
.nx-surface-blue .nx-muted { color: rgba(255, 255, 255, 0.78); }

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

.nx-muted { color: var(--nx-ink-2); }

.nx-lede {
  max-width: 58ch;
  color: var(--nx-ink-2);
  font-size: var(--nx-step-1);
  line-height: 1.5;
}

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

/* --- Skip link -------------------------------------------------------------------------- */

.nx-skip-link {
  position: fixed;
  z-index: 1000;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.7rem 1rem;
  color: var(--nx-white);
  background: var(--nx-blue);
  font-family: var(--nx-font-mono);
  font-size: var(--nx-step--2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform var(--nx-dur) var(--nx-ease);
}

.nx-skip-link:focus-visible { color: var(--nx-white); transform: translateY(0); }

/* --- Motion initial states ---------------------------------------------------------------
   Applied only while `nx-js` is on <html>. motion.js removes that class if GSAP
   never arrives, so nothing can stay invisible.

   The `:not([data-nx-seen])` guard matters: motion.js stamps that attribute the
   moment it takes charge of an element. Without it, clearing GSAP's inline
   styles would drop the element straight back onto this rule and hide it
   again. */

.nx-js [data-reveal]:not([data-nx-seen]) { opacity: 0; }
.nx-js [data-wipe]:not([data-nx-seen]) { clip-path: inset(0 100% 0 0); }
.nx-js [data-draw]:not([data-nx-seen]) { transform: scaleX(0); }

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

  .nx-js [data-reveal]:not([data-nx-seen]) { opacity: 1; }
  .nx-js [data-wipe]:not([data-nx-seen]) { clip-path: none; }
  .nx-js [data-draw]:not([data-nx-seen]) { transform: none; }
}
