/*
  tokens.css: sitewide design tokens and base element styles.
  One-off, section-specific styles live in styles.css.

  Breakpoints (custom properties can't be used inside media queries, so the
  values are written out in styles.css):
    600px = 37.5em    900px = 56.25em    1200px = 75em
  Mobile-first: base styles are for a 320px phone, queries use min-width.
*/

/* ---------- Font ----------
   One variable file covers every weight from 200 to 800. OFL.txt sits beside
   it in fonts/. */
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("../fonts/AtkinsonHyperlegibleNext-Variable.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

/* ---------- Palette (sampled from media/sentinel-icon-512.png) ---------- */
:root {
  --blue-50: #f5f9fd;
  --blue-100: #e4f1fb;
  --blue-200: #c7e6fc;
  --blue-300: #98d1f6;
  --blue-500: #55a3d9;   /* decorative only: 2.6:1 on the light page */
  --blue-700: #265188;
  --blue-800: #2d4d7a;
  --navy-900: #16263b;
  --navy-950: #0d1827;
  --slate-500: #4a5b73;
  --slate-300: #9fb2c8;
  --slate-control-light: #5f7189;
  --slate-control-dark: #7f93ab;
  --silver-100: #e8f0f8;
  --white: #ffffff;
  --highlight: #ffe08a;
}

/* ---------- Color scheme ----------
   No saved choice: follow the system. A saved choice sets data-theme on
   <html> (see app/theme-init.js) and overrides it. */
:root {
  color-scheme: light dark;
}
:root[data-theme="light"] {
  color-scheme: light;
}
:root[data-theme="dark"] {
  color-scheme: dark;
}

/* ---------- Semantic tokens: light-dark(light, dark) ---------- */
:root {
  --color-bg: light-dark(var(--blue-50), var(--navy-950));
  --color-surface: light-dark(var(--blue-100), var(--navy-900));
  --color-text: light-dark(var(--navy-900), var(--silver-100));
  --color-muted: light-dark(var(--slate-500), var(--slate-300));
  --color-accent: light-dark(var(--blue-700), var(--blue-300));
  --color-accent-fill: light-dark(var(--blue-700), var(--blue-300));
  --color-on-accent: light-dark(var(--white), var(--navy-950));
  --color-focus: light-dark(var(--blue-700), var(--blue-300));
  --color-control-border: light-dark(var(--slate-control-light), var(--slate-control-dark));
  /* Decorative only. Never the sole mark of a control. */
  --color-rule: light-dark(var(--blue-200), var(--blue-800));
  --color-tint: light-dark(var(--blue-200), var(--blue-800));
  --color-mark-bg: var(--highlight);
  --color-mark-text: var(--navy-900);
}

/* ---------- Typography ---------- */
:root {
  --font-body: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system,
    "Segoe UI", Roboto, sans-serif;
  --font-heading: var(--font-body);
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;

  --text-sm: clamp(0.9rem, 0.88rem + 0.1vw, 0.95rem);
  --text-base: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1.05rem + 0.4vw, 1.3125rem);
  --text-xl: clamp(1.25rem, 1.1rem + 0.7vw, 1.625rem);
  --text-2xl: clamp(1.625rem, 1.3rem + 1.5vw, 2.375rem);
  --text-3xl: clamp(2.25rem, 1.6rem + 3vw, 4rem);

  --leading-body: 1.55;
  --leading-heading: 1.15;
  --tracking-heading: -0.01em;
  --weight-regular: 400;
  --weight-bold: 700;
}

/* ---------- Spacing, layout, shape ---------- */
:root {
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;
  --space-section: clamp(2.5rem, 1.5rem + 4vw, 5rem);

  --gutter: clamp(1rem, 0.5rem + 2.5vw, 2rem);
  --measure: 68ch;
  --container: 70rem;
  --header-height: 4rem;
  --target-size: 2.75rem;

  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --border-width: 1px;

  --focus-width: 3px;
  --focus-offset: 3px;
}

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

[hidden] {
  display: none !important;
}

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

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-body);
  padding-inline: env(safe-area-inset-left) env(safe-area-inset-right);
}

img,
svg {
  max-width: 100%;
  height: auto;
}

h1,
h2,
h3 {
  font-family: var(--font-heading);
  font-weight: var(--weight-bold);
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-heading);
  text-wrap: balance;
  margin-block: 0 var(--space-4);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }

p,
ul,
ol,
dl {
  margin-block: 0 var(--space-4);
}

p,
li,
dd,
summary {
  max-width: var(--measure);
}

ul,
ol {
  padding-inline-start: 1.5em;
}

li + li {
  margin-block-start: var(--space-2);
}

a {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 0.15em;
}

:focus-visible {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: var(--focus-offset);
  border-radius: var(--radius-sm);
}

code,
pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

code {
  background: var(--color-surface);
  padding: 0.1em 0.25em;
  border-radius: var(--radius-sm);
  overflow-wrap: anywhere;
}

pre {
  margin: 0;
  padding: var(--space-4);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-control-border);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

pre code {
  background: none;
  padding: 0;
  overflow-wrap: normal;
}

dt {
  font-weight: var(--weight-bold);
}

dd {
  margin-inline-start: 0;
  margin-block-end: var(--space-4);
}

dfn {
  font-style: normal;
  font-weight: var(--weight-bold);
}

summary {
  cursor: pointer;
  min-height: var(--target-size);
  font-weight: var(--weight-bold);
}

mark {
  background: var(--color-mark-bg);
  color: var(--color-mark-text);
  border-radius: 0.15em;
}

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

button {
  min-height: var(--target-size);
  min-width: var(--target-size);
  cursor: pointer;
}

input[type="search"] {
  min-height: var(--target-size);
  padding: 0 var(--space-3);
  background: var(--color-bg);
  border: var(--border-width) solid var(--color-control-border);
  border-radius: var(--radius-md);
}

/* ---------- Layout primitives ---------- */
main,
header,
footer {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

main > section {
  padding-block: var(--space-section) 0;
}

/* ---------- Skip link and visually hidden helper ---------- */
.skip-link {
  position: absolute;
  inset-block-start: var(--space-2);
  inset-inline-start: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--color-accent-fill);
  color: var(--color-on-accent);
  border-radius: var(--radius-md);
  transform: translateY(-200%);
  z-index: 100;
}

.skip-link:focus {
  transform: none;
}

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

/* ---------- User preferences ---------- */
@media (prefers-contrast: more) {
  :root {
    --color-rule: var(--color-control-border);
  }
}

@media (forced-colors: active) {
  pre,
  input[type="search"],
  button {
    border: var(--border-width) solid CanvasText;
  }
}
