/* Fonts: self-hosted, Latin subset, variable, limited to the weights in use */
@font-face {
  font-family: "Space Grotesk";
  src: url("/assets/fonts/space-grotesk-v2.woff2") format("woff2");
  font-weight: 500 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter Tight";
  src: url("/assets/fonts/inter-tight-v2.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/jetbrains-mono-v2.woff2") format("woff2");
  font-weight: 400 500;
  font-style: normal;
  font-display: swap;
}

/* Local fallbacks sized to the web fonts, so the swap moves nothing */
@font-face {
  font-family: "Space Grotesk Fallback";
  src: local("Arial");
  size-adjust: 108.4%;
  ascent-override: 90.7%;
  descent-override: 26.9%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "Inter Tight Fallback";
  src: local("Arial");
  size-adjust: 95.9%;
  ascent-override: 101%;
  descent-override: 25.1%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "JetBrains Mono Fallback";
  src: local("Courier New");
  size-adjust: 100%;
  ascent-override: 102%;
  descent-override: 30%;
  line-gap-override: 0%;
}

/* Tokens */
:root {
  /* colour */
  --ink: #0b0d10;
  --panel: #12161b;
  --line: #232a32;
  --text: #e9edf1;
  --muted: #8a95a3;
  --signal: #2bc4f2;
  --pass: #3ddc84;
  --warn: #ffb23e;
  --fail: #ff5a4f;
  --error: #ff8a80;
  --paper: #f2f0ea;
  --paper-ink: #0b0d10;

  /* type families */
  --font-display: "Space Grotesk", "Space Grotesk Fallback", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Inter Tight", "Inter Tight Fallback", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "JetBrains Mono Fallback", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* fluid type scale, 360px to 1440px */
  --text-xs: clamp(0.72rem, 0.7rem + 0.1vw, 0.8rem);
  --text-sm: clamp(0.85rem, 0.83rem + 0.12vw, 0.94rem);
  --text-base: clamp(1rem, 0.96rem + 0.18vw, 1.125rem);
  --text-lg: clamp(1.2rem, 1.1rem + 0.5vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.25rem + 1.2vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.5rem + 2.4vw, 3.5rem);
  --text-3xl: clamp(2.4rem, 1.6rem + 4vw, 5rem);
  --text-hero: clamp(2.6rem, 11vw, 9rem);

  --leading-tight: 0.95;
  --leading-snug: 1.15;
  --leading-body: 1.6;
  --tracking-tight: -0.035em;
  --tracking-label: 0.08em;

  /* spacing */
  --space-3xs: 0.25rem;
  --space-2xs: 0.5rem;
  --space-xs: 0.75rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2.5rem;
  --space-xl: 4rem;
  --space-2xl: clamp(4rem, 3rem + 5vw, 8rem);
  --space-3xl: clamp(6rem, 4rem + 9vw, 12rem);
  --gutter: 1.25rem;
  --container: 80rem;
  --header-h: 4.5rem;
  --tap: 3rem;

  /* radii */
  --radius-sm: 0.375rem;
  --radius-md: 0.75rem;
  --radius-lg: 1.25rem;
  --radius-pill: 999px;

  /* layers */
  --z-base: 1;
  --z-sticky: 20;
  --z-header: 40;
  --z-menu: 60;
  --z-curtain: 80;
  --z-pointer: 90;
  --z-loader: 100;

  /* motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-micro: 0.25s;
  --dur: 0.7s;
  --dur-hero: 1.1s;
  --stagger: 0.08s;

  color-scheme: dark;
}

@media (min-width: 640px) {
  :root {
    --gutter: 2rem;
    --header-h: 5rem;
  }
}

@media (min-width: 900px) {
  :root {
    --gutter: 3rem;
  }
}

@media (min-width: 1200px) {
  :root {
    --gutter: 4rem;
  }
}

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + var(--space-sm));
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

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

img,
video {
  height: auto;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

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

p,
h1,
h2,
h3,
h4 {
  overflow-wrap: break-word;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

::selection {
  background: var(--signal);
  color: var(--ink);
}

/* Grain overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: var(--z-pointer);
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* Focus */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

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

.skip-link {
  position: fixed;
  top: var(--space-sm);
  left: var(--space-sm);
  z-index: var(--z-loader);
  padding: var(--space-xs) var(--space-md);
  background: var(--signal);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-pill);
  transform: translateY(-200%);
  transition: transform var(--dur-micro) var(--ease);
}

.skip-link:focus-visible {
  transform: translateY(0);
  outline-offset: 2px;
}

/* Reduced motion */
@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;
  }
}

/* Smooth scroll (Lenis) */
html.lenis,
html.lenis body {
  height: auto;
}

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

.lenis.lenis-smooth [data-lenis-prevent] {
  overscroll-behavior: contain;
}

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

.lenis.lenis-smooth iframe {
  pointer-events: none;
}

/* Scroll is locked only while the preloader runs; the gutter keeps the width steady */
html.is-loading {
  overflow: hidden;
  scrollbar-gutter: stable;
}
