/* ==========================================================================
   The Engineering Dispatch — Design Tokens & Foundations
   Warm-neutral editorial paper ground, dense ink, disciplined typography.
   ========================================================================== */

:root {
  color-scheme: light;

  /* Paper & Surface */
  --page: #fbf9f4;
  --surface: #ffffff;
  --surface-raised: #f3eee3;
  --surface-tint: #f8f4ec;

  /* Ink & Typography */
  --text: #191c21;
  --text-muted: #545d6b;
  --text-subtle: #7e8795;

  /* Editorial Rules */
  --rule: #e5ded2;
  --rule-strong: #191c21;
  --rule-accent: #bd3920;

  /* Editorial Accent (Terracotta / Vermilion) */
  --accent: #bd3920;
  --accent-soft: #fbf0ec;
  --accent-hover: #9c2a14;

  /* Warm Category Cues */
  --cat-cue: #885324;
  --cat-agent: #1e5bb8;
  --cat-infra: #0f766e;
  --cat-system: #b45309;
  --cat-wool: #c2410c;

  /* Code & Syntax Surfaces */
  --code-bg: #14161a;
  --code-text: #ece9e2;
  --code-inline-bg: #f0ebe0;
  --code-inline-border: #ded7c7;
  --code-inline-text: #bd3920;
  --quote-bg: #f5f0e6;
  --quote-border: #bd3920;

  /* Feedback */
  --success: #236c4b;
  --danger: #b23838;
  --focus: #bd3920;
  --shadow: 0 16px 48px rgb(25 28 32 / 10%);
  --shadow-overlay: 0 24px 64px rgb(20 22 26 / 20%);

  /* Layout Scales */
  --content-width: 1220px;
  --reading-width: 710px;

  /* Corner Radii (Compact 4px-6px, content rows stay square 0px) */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;

  /* System Font Stacks */
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
}

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

  /* Dark Near-Black Ink Surfaces */
  --page: #121316;
  --surface: #181a1f;
  --surface-raised: #20232a;
  --surface-tint: #1a1c22;

  /* Warm Ivory Text */
  --text: #ece9e2;
  --text-muted: #9fa7b4;
  --text-subtle: #757d8b;

  /* Dark Editorial Rules */
  --rule: #2a2e37;
  --rule-strong: #ece9e2;
  --rule-accent: #ea6b52;

  /* Terracotta Accent in Dark Mode */
  --accent: #ea6b52;
  --accent-soft: #2e1a16;
  --accent-hover: #f58973;

  /* Dark Category Cues */
  --cat-cue: #e49e5d;
  --cat-agent: #60a5fa;
  --cat-infra: #2dd4bf;
  --cat-system: #fbbf24;
  --cat-wool: #fb923c;

  /* Dark Code & Syntax */
  --code-bg: #0d0e11;
  --code-text: #ece9e2;
  --code-inline-bg: #21242c;
  --code-inline-border: #313642;
  --code-inline-text: #ea6b52;
  --quote-bg: #1a1c22;
  --quote-border: #ea6b52;

  /* Feedback */
  --success: #70c499;
  --danger: #ee8686;
  --focus: #ea6b52;
  --shadow: 0 16px 48px rgb(0 0 0 / 50%);
  --shadow-overlay: 0 28px 72px rgb(0 0 0 / 70%);
}

/* ==========================================================================
   CSS Reset & Document Defaults
   ========================================================================== */

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

html {
  min-width: 320px;
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
  background-color: var(--page);
}

body {
  margin: 0;
  background-color: var(--page);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

button, a {
  -webkit-tap-highlight-color: transparent;
}

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

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

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

img {
  height: auto;
  display: block;
}

::selection {
  background: color-mix(in srgb, var(--accent) 26%, transparent);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute !important;
  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;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 8px 14px;
  background: var(--rule-strong);
  color: var(--page);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transform: translateY(-160%);
  transition: transform 120ms ease;
}

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

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