/* Base: custom properties, reset, typography */

:root {
  color-scheme: light dark;

  /* Colours (light) */
  --color-bg: #fdfdfc;
  --color-surface: #f4f4f2;
  --color-text: #1b1b1b;
  --color-muted: #5a5a5a;
  --color-border: #dadad6;
  --color-accent: #1d5bb8;
  --color-accent-hover: #164a96;
  --color-on-accent: #ffffff;
  --color-focus: #1d5bb8;
  --color-error: #a32020;
  /* Dark badge behind white glyph icons (e.g. Github mark) */
  --color-icon-badge: #1f1f1f;

  /* Fonts */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, monospace;

  /* Type scale */
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.125rem;
  --leading: 1.6;
  --leading-tight: 1.25;

  /* Spacing scale */
  --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: 4rem;

  /* Layout */
  --gutter: 1rem;
  --container: 64rem;
  --measure: 40rem;
  --radius: 0.375rem;
  --radius-pill: 62.5rem;
  --border-width: 0.0625rem;

  /* Motion */
  --transition: 150ms ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #121212;
    --color-surface: #1b1b1a;
    --color-text: #e9e9e6;
    --color-muted: #a6a6a1;
    --color-border: #333331;
    --color-accent: #8ab4f8;
    --color-accent-hover: #aecbfa;
    --color-on-accent: #0d0d0d;
    --color-focus: #8ab4f8;
    --color-error: #f28b82;
    --color-icon-badge: #3a3a38;
  }
}

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

* {
  margin: 0;
}

body {
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading);
  color: var(--color-text);
  background-color: var(--color-bg);
}

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

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

[hidden] {
  display: none !important;
}

/* Typography */
h1,
h2,
h3,
h4 {
  line-height: var(--leading-tight);
  font-weight: 600;
}

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

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

h3 {
  font-size: var(--text-xl);
}

h4 {
  font-size: var(--text-lg);
}

p,
li {
  overflow-wrap: break-word;
}

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

a:hover {
  color: var(--color-accent-hover);
  text-decoration-thickness: 0.125rem;
}

:focus-visible {
  outline: 0.125rem solid var(--color-focus);
  outline-offset: 0.125rem;
}

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

/* 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: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 10;
  padding: var(--space-2) var(--space-4);
  color: var(--color-on-accent);
  background-color: var(--color-accent);
  border-radius: var(--radius);
  transform: translateY(-200%);
}

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

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