/* ==========================================================================
   Level Nexus — base.css
   Design tokens, reset, typography, layout primitives, a11y utilities.
   Mobile-first: every rule here is the small-screen rule unless in a query.
   ========================================================================== */

/* --- Tokens ------------------------------------------------------------- */
:root {
  /* Brand */
  --navy:  #153A77;
  --navy-600: #1B4A96;
  --navy-300: #6B8AC4;
  --teal:  #0FD3C4;
  --teal-700: #07766F;
  --teal-100: #DFF9F6;
  --amber: #FE9A36;
  --amber-700: #A85B11;
  --amber-100: #FFF0DE;
  --paper: #F7F9FC;
  --ink:   #0B1F3F;
  --ink-800: #12294D;
  --ink-700: #1A3459;

  /* Neutrals derived from the navy hue so greys never look muddy */
  --white: #FFFFFF;
  --grey-050: #EFF3F9;
  --grey-100: #E3E9F2;
  --grey-200: #CFD8E6;
  --grey-400: #5F7189;
  --grey-600: #566A85;
  --grey-800: #2E4160;

  /* Semantic */
  --bg:            var(--paper);
  --bg-raised:     var(--white);
  --bg-sunken:     var(--grey-050);
  --text:          var(--ink);
  --text-muted:    var(--grey-600);
  --text-faint:    var(--grey-400);
  --text-invert:   #EAF1FB;
  --border:        var(--grey-100);
  --border-strong: var(--grey-200);
  --focus:         var(--teal);

  /* Type */
  --font-display: 'Space Grotesk', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body:    'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  /* Fluid type scale — 360px floor, 1280px ceiling */
  --step--2: clamp(0.694rem, 0.68rem + 0.06vw, 0.72rem);
  --step--1: clamp(0.833rem, 0.81rem + 0.1vw, 0.889rem);
  --step-0:  clamp(1rem, 0.97rem + 0.15vw, 1.0625rem);
  --step-1:  clamp(1.2rem, 1.14rem + 0.3vw, 1.424rem);
  --step-2:  clamp(1.44rem, 1.33rem + 0.55vw, 1.8rem);
  --step-3:  clamp(1.728rem, 1.53rem + 0.99vw, 2.4rem);
  --step-4:  clamp(2.074rem, 1.74rem + 1.67vw, 3.2rem);
  --step-5:  clamp(2.488rem, 1.94rem + 2.74vw, 4.2rem);

  /* Space */
  --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;

  /* Shape */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 999px;

  /* Elevation — tinted with the navy hue, not neutral black */
  --shadow-sm: 0 1px 2px rgba(11, 31, 63, .06), 0 1px 3px rgba(11, 31, 63, .05);
  --shadow-md: 0 4px 12px rgba(11, 31, 63, .07), 0 2px 4px rgba(11, 31, 63, .05);
  --shadow-lg: 0 18px 44px rgba(11, 31, 63, .12), 0 4px 12px rgba(11, 31, 63, .06);

  /* Chrome */
  --header-h: 60px;
  --actionbar-h: 60px;
  --wrap: 1180px;
  --wrap-narrow: 780px;

  --ease: cubic-bezier(.22, .61, .36, 1);
  --dur: 220ms;
}

@media (min-width: 900px) {
  :root {
    --header-h: 76px;
    --actionbar-h: 0px;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--sp-4));
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.65;
  font-feature-settings: 'kern' 1, 'liga' 1, 'cv05' 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  /* Room for the sticky mobile action bar */
  padding-bottom: var(--actionbar-h);
}

body.is-locked { overflow: hidden; }

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.022em;
  margin: 0 0 var(--sp-4);
  text-wrap: balance;
}

h1 { font-size: var(--step-5); letter-spacing: -0.032em; }
h2 { font-size: var(--step-4); letter-spacing: -0.028em; }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); }

p { margin: 0 0 var(--sp-4); text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

a { color: var(--navy); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--teal-700); }

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

ul, ol { margin: 0 0 var(--sp-4); padding-left: 1.25em; }
li { margin-bottom: var(--sp-2); }
li:last-child { margin-bottom: 0; }

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

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--sp-6) 0;
}

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

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

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

/* On ink backgrounds the teal ring needs a halo to stay visible */
.on-ink :focus-visible,
.site-footer :focus-visible {
  outline-color: var(--teal);
  box-shadow: 0 0 0 6px rgba(15, 211, 196, .22);
}

/* --- Skip link ---------------------------------------------------------- */
.skip-link {
  position: absolute;
  left: var(--sp-3);
  top: var(--sp-3);
  z-index: 200;
  transform: translateY(-160%);
  background: var(--ink);
  color: var(--white);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-md);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  text-decoration: none;
  box-shadow: var(--shadow-lg);
  transition: transform var(--dur) var(--ease);
}

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

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

@media (min-width: 640px) { .wrap { padding-inline: var(--sp-6); } }

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

.section { padding-block: var(--sp-7); }

@media (min-width: 768px) { .section { padding-block: var(--sp-8); } }
@media (min-width: 1100px) { .section { padding-block: var(--sp-9); } }

.section--sunken { background: var(--bg-sunken); }
.section--raised { background: var(--bg-raised); }
.section--tight  { padding-block: var(--sp-6); }

.section--ink {
  background: var(--ink);
  color: var(--text-invert);
}

.section--ink h2, .section--ink h3 { color: var(--white); }

.stack > * + * { margin-top: var(--sp-4); }
.stack-lg > * + * { margin-top: var(--sp-6); }

.grid { display: grid; gap: var(--sp-4); }

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

@media (min-width: 900px) {
  .grid--3 { grid-template-columns: repeat(3, 1fr); }
  .grid--4 { grid-template-columns: repeat(4, 1fr); }
  .grid { gap: var(--sp-5); }
}

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

.mono {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  font-variant-ligatures: none;
}

.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.lead {
  font-size: var(--step-1);
  line-height: 1.5;
  color: var(--text-muted);
  max-width: 62ch;
}

.section--ink .lead,
.section--ink .text-muted { color: rgba(234, 241, 251, .74); }

.nowrap { white-space: nowrap; }

/* --- Motion ------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- Print -------------------------------------------------------------- */
@media print {
  .site-header, .site-footer, .action-bar, .skip-link, .hero-console { display: none !important; }
  body { padding: 0; background: #fff; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .8em; }
}
