/* ==========================================================================
   NEXISTEK — Reset & Base
   Normalises the browser, then establishes the dark baseline.
   ========================================================================== */

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

* {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Lenis owns scrolling once JS boots; this is the no-JS fallback. */

  /* Clear the fixed header when jumping to an anchor. The header is
     position:fixed, so without this a heading linked from the contents list,
     from a menu, or from a pasted #fragment lands at viewport top — which is
     underneath the header, with its first line covered.

     It belongs here rather than as scroll-margin-top on each target, because
     main.js reads this value to offset the smooth-scroll engine:

         var offset = -(parseFloat(getComputedStyle(root).scrollPaddingTop) || 0);

     Unset, that parsed to NaN and fell through to 0, so every scripted jump
     on the site landed under the header regardless of any scroll-margin the
     target carried — Lenis scrolls to a computed position and never consults
     it. Setting it here fixes the scripted path and the native one together. */
  scroll-padding-top: calc(var(--nav-h) + var(--sp-5));
}

html.lenis,
html.lenis body {
  height: auto;
}

.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

.lenis.lenis-stopped {
  overflow: hidden;
}

body {
  min-height: 100dvh;
  background-color: var(--surface-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: 400;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

/* The hidden attribute, made to actually mean it -------------------------- *
 * `hidden` is honoured only by `[hidden] { display: none }` in the browser's
 * own stylesheet, which loses to any author rule that sets display — so
 * `<button class="btn" hidden>` renders anyway, because .btn sets
 * `display: inline-flex`. That is not a hypothetical: the admin's Copy prompt
 * button shipped hidden, stayed visible, and did nothing when pressed.
 *
 * Two components already carried their own `[hidden] { display: none }` patch
 * for this. One rule here covers every case instead. */
[hidden] {
  display: none !important;
}

/* Media defaults ---------------------------------------------------------- */
img,
picture,
video,
canvas,
svg {
  max-width: 100%;
}

img,
video {
  height: auto;
}

svg {
  fill: none;
}

/* Forms inherit type instead of resetting it per component ----------------- */
input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  background: none;
  border: none;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

/* Typography base --------------------------------------------------------- */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--lh-heading);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

a {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

ul[role="list"],
ol[role="list"] {
  list-style: none;
}

address {
  font-style: normal;
}

strong,
b {
  font-weight: 600;
}

::selection {
  background-color: rgb(var(--rgb-primary) / 0.85);
  color: var(--text-on-primary);
}

/* Focus: never removed, only restyled ------------------------------------- */
:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}

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

/* Scrollbar ----------------------------------------------------------------
 * The thumb used to be 14% white inside a 3px void-coloured border, which on
 * a 10px track left about 4px of something almost exactly as dark as the page
 * behind it — on a laptop it was invisible, and there was no way to tell how
 * far down a long page you were. Wider track, thinner inset, and enough
 * contrast to actually find it.
 */
::-webkit-scrollbar {
  width: 14px;
}

::-webkit-scrollbar-track {
  background-color: var(--c-void);
}

::-webkit-scrollbar-thumb {
  background-color: rgb(var(--rgb-text) / 0.34);
  border-radius: var(--r-full);
  border: 4px solid var(--c-void);
}

::-webkit-scrollbar-thumb:hover {
  background-color: rgb(var(--rgb-primary) / 0.85);
}

/* Firefox has no thumb-inset equivalent, so 'thin' plus a brighter colour is
   the whole control there. */
html {
  scrollbar-color: rgb(var(--rgb-text) / 0.38) var(--c-void);
  scrollbar-width: thin;
}

/* Layout primitives -------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--narrow {
  max-width: var(--container-narrow);
}

/* Visually hidden but available to assistive tech -------------------------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Skip link ---------------------------------------------------------------- */
.skip-link {
  position: absolute;
  top: var(--sp-3);
  left: var(--sp-3);
  z-index: var(--z-overlay);
  padding: var(--sp-3) var(--sp-5);
  background-color: var(--c-primary);
  color: var(--text-on-primary);
  font-size: var(--fs-sm);
  font-weight: 600;
  border-radius: var(--r-sm);
  transform: translateY(-160%);
  transition: transform var(--dur-base) var(--ease-out);
}

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

/* Honour the OS request even before JS has had a chance to run ------------- */
@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;
    scroll-behavior: auto !important;
  }
}
