/* TJS foundation: type, space, radius, elevation, focus, motion.
   Reads the semantic layer only. Load order:
     variables.css  primitives (--brand-*)
     semantic.css   intent roles (--color-*)
     foundation.css this file
     components.css
*/

:root {
  /* Faces. Two families, two jobs. The mono face is for code and figures. */
  --font-display: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  /* Type scale: size / line-height / weight / tracking. */
  --text-display-size: 4rem;
  --text-display-line: 1.05;
  --text-display-weight: 700;
  --text-display-track: -0.025em;

  --text-h1-size: 2.75rem;
  --text-h1-line: 1.15;
  --text-h1-weight: 700;
  --text-h1-track: -0.02em;

  --text-h2-size: 2.25rem;
  --text-h2-line: 1.2;
  --text-h2-weight: 600;
  --text-h2-track: -0.015em;

  --text-h3-size: 1.875rem;
  --text-h3-line: 1.25;
  --text-h3-weight: 600;
  --text-h3-track: -0.01em;

  --text-h4-size: 1.5rem;
  --text-h4-line: 1.3;
  --text-h4-weight: 600;
  --text-h4-track: 0;

  --text-h5-size: 1.25rem;
  --text-h5-line: 1.4;
  --text-h5-weight: 600;
  --text-h5-track: 0;

  --text-body-size: 1rem;
  --text-body-line: 1.5;
  --text-body-weight: 400;

  --text-sm-size: 0.875rem;
  --text-sm-line: 1.5;
  --text-sm-weight: 400;

  --text-caption-size: 0.75rem;
  --text-caption-line: 1.4;
  --text-caption-weight: 500;
  --text-caption-track: 0.01em;

  /* 8px baseline. Every gap and padding comes from here. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;

  /* Radius scale. No pill controls. */
  --radius-xs: 3px;
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-full: 999px;

  --border-width: 1px;

  /* Elevation is an exception, not a default. */
  --shadow-sm: 0 1px 2px rgba(17, 17, 17, 0.06);
  --shadow-md: 0 4px 12px rgba(17, 17, 17, 0.08);
  --shadow-lg: 0 12px 32px rgba(17, 17, 17, 0.12);

  /* Focus is never removed. */
  --focus-width: 2px;
  --focus-offset: 2px;

  --motion-fast: 0.1s;
  --motion-mid: 0.2s;
  --motion-slow: 0.3s;
  --ease-out: cubic-bezier(0.215, 0.61, 0.355, 1);
  --ease-in-out: cubic-bezier(0.645, 0.045, 0.355, 1);

  /* Layout. Breakpoints are documented, not tokenised: 480, 768, 1024, 1280. */
  --container-max: 1200px;
  --container-gutter: var(--space-5);
  --measure: 65ch;
}

[data-theme="dark"] {
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
  }
}

/* ------------------------------------------------------------------ base */

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

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

[data-theme="dark"] {
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
  }
}

body {
  margin: 0;
  background: var(--color-canvas);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
  font-weight: var(--text-body-weight);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5 {
  margin: 0;
  font-family: var(--font-display);
  color: var(--color-text);
  text-wrap: balance;
}

h1 {
  font-size: var(--text-h1-size);
  line-height: var(--text-h1-line);
  font-weight: var(--text-h1-weight);
  letter-spacing: var(--text-h1-track);
}

h2 {
  font-size: var(--text-h2-size);
  line-height: var(--text-h2-line);
  font-weight: var(--text-h2-weight);
  letter-spacing: var(--text-h2-track);
}

h3 {
  font-size: var(--text-h3-size);
  line-height: var(--text-h3-line);
  font-weight: var(--text-h3-weight);
  letter-spacing: var(--text-h3-track);
}

h4 {
  font-size: var(--text-h4-size);
  line-height: var(--text-h4-line);
  font-weight: var(--text-h4-weight);
}

h5 {
  font-size: var(--text-h5-size);
  line-height: var(--text-h5-line);
  font-weight: var(--text-h5-weight);
}

p {
  margin: 0;
}

a:not([class*="tjs-"]) {
  color: var(--color-accent-text);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:not([class*="tjs-"]):hover {
  color: var(--color-accent-active);
}

:focus-visible {
  outline: var(--focus-width) solid var(--color-focus-ring);
  outline-offset: var(--focus-offset);
}

::selection {
  background: var(--color-selection-bg);
  color: var(--color-text);
}

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

hr {
  border: 0;
  border-top: var(--border-width) solid var(--color-border);
}

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

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

[hidden] {
  display: none !important;
}

.tjs-container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-gutter);
}

.tjs-prose {
  max-width: var(--measure);
}

.tjs-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;
}

.tjs-skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface);
  color: var(--color-text);
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  transform: translateY(-200%);
}

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

.tjs-display {
  font-family: var(--font-display);
  font-size: var(--text-display-size);
  line-height: var(--text-display-line);
  font-weight: var(--text-display-weight);
  letter-spacing: var(--text-display-track);
}

.tjs-caption {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-weight: var(--text-caption-weight);
  letter-spacing: var(--text-caption-track);
  color: var(--color-text-muted);
}

.tjs-muted {
  color: var(--color-text-muted);
}

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