/* ==========================================================================
   Design System — Kun Chen
   editorial × system console × field manual
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,300..900;1,8..60,300..900&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap");

/* --------------------------------------------------------------------------
   Tokens
   -------------------------------------------------------------------------- */

:root {
  /* Color */
  --color-bg: #f5f2ed;
  --color-bg-surface: #eceae4;
  --color-bg-code: #e2ded7;
  --color-text: #1a1a1a;
  --color-text-muted: #6b6560;
  --color-accent: #1a6b5a;
  --color-accent-hover: #145447;
  --color-border: #d1ccc4;

  /* Typography */
  --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-sans:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Courier New", monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.25rem;
  --text-xl: 1.5rem;
  --text-2xl: 2rem;
  --text-3xl: 2.5rem;

  --leading-tight: 1.2;
  --leading-base: 1.6;
  --leading-loose: 1.8;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;

  /* Layout */
  --max-width: 72rem;
  --border-width: 1px;
  --border-radius: 2px;
}

/* --------------------------------------------------------------------------
   Reset
   -------------------------------------------------------------------------- */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

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

/* --------------------------------------------------------------------------
   Typography — Roles
   Serif  = Thesis (headlines, big ideas)
   Sans   = Explanation (body)
   Mono   = Proof (code, commands, benchmarks)
   -------------------------------------------------------------------------- */

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

h1 {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-lg);
}
h2 {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-md);
}
h3 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-md);
}
h4 {
  font-size: var(--text-lg);
  margin-bottom: var(--space-sm);
}

p {
  margin-bottom: var(--space-md);
  line-height: var(--leading-loose);
}

h3,
h4 {
  margin-top: var(--space-lg);
}

ul,
ol {
  margin-bottom: var(--space-md);
  padding-left: var(--space-xl);
}

li {
  margin-bottom: var(--space-xs);
  line-height: var(--leading-loose);
}

strong {
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Links
   -------------------------------------------------------------------------- */

a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  text-decoration-thickness: 1px;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--color-accent-hover);
}

/* --------------------------------------------------------------------------
   Annotation — Signature Element
   The [bracketed concept] in titles
   -------------------------------------------------------------------------- */

.annotation {
  color: var(--color-accent);
}

/* --------------------------------------------------------------------------
   Section Label
   Small uppercase labels: PREMISE, MECHANISM, PROOF, etc.
   -------------------------------------------------------------------------- */

.section-label {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-xl);
}

.section {
  padding: var(--space-3xl) 0;
}

.section + .section {
  border-top: var(--border-width) solid var(--color-border);
}

.divider {
  border: none;
  border-top: var(--border-width) solid var(--color-border);
  margin: var(--space-2xl) 0;
}

/* --------------------------------------------------------------------------
   Grid
   -------------------------------------------------------------------------- */

.grid {
  display: grid;
  gap: var(--space-xl);
}

@media (min-width: 48rem) {
  .grid--2 {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid--3 {
    grid-template-columns: repeat(3, 1fr);
  }
  .grid--4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* --------------------------------------------------------------------------
   Card
   -------------------------------------------------------------------------- */

.card {
  background: var(--color-bg-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--border-radius);
  padding: var(--space-xl);
}

.card > *:last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Table
   -------------------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  margin-bottom: var(--space-md);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 2px solid var(--color-border);
}

.table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: var(--border-width) solid var(--color-border);
  vertical-align: top;
}

.table tr:last-child td {
  border-bottom: none;
}

/* --------------------------------------------------------------------------
   Code — Proof
   -------------------------------------------------------------------------- */

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-bg-code);
  padding: 0.15em 0.4em;
  border-radius: var(--border-radius);
}

pre {
  background: var(--color-bg-code);
  padding: var(--space-lg);
  border-radius: var(--border-radius);
  overflow-x: auto;
  margin-bottom: var(--space-md);
  line-height: var(--leading-base);
}

pre code {
  background: transparent;
  padding: 0;
  font-size: var(--text-sm);
}

/* --------------------------------------------------------------------------
   Swatch (for color documentation)
   -------------------------------------------------------------------------- */

.swatch {
  width: 3rem;
  height: 3rem;
  border-radius: var(--border-radius);
  border: var(--border-width) solid var(--color-border);
  display: inline-block;
  margin-bottom: var(--space-sm);
}

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */

.font-serif {
  font-family: var(--font-serif);
}
.font-sans {
  font-family: var(--font-sans);
}
.font-mono {
  font-family: var(--font-mono);
}

.text-muted {
  color: var(--color-text-muted);
}
.text-accent {
  color: var(--color-accent);
}
.text-sm {
  font-size: var(--text-sm);
}
.text-lg {
  font-size: var(--text-lg);
}

.mt-0 {
  margin-top: 0;
}
.mt-sm {
  margin-top: var(--space-sm);
}
.mt-md {
  margin-top: var(--space-md);
}
.mt-lg {
  margin-top: var(--space-lg);
}
.mt-xl {
  margin-top: var(--space-xl);
}
.mt-2xl {
  margin-top: var(--space-2xl);
}

.mb-0 {
  margin-bottom: 0;
}
.mb-sm {
  margin-bottom: var(--space-sm);
}
.mb-md {
  margin-bottom: var(--space-md);
}
.mb-lg {
  margin-bottom: var(--space-lg);
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 48rem) {
  :root {
    --text-3xl: 2rem;
    --text-2xl: 1.5rem;
  }

  .container {
    padding: 0 var(--space-md);
  }

  .section {
    padding: var(--space-2xl) 0;
  }

  pre {
    padding: var(--space-md);
  }

  pre code {
    font-size: 0.8125rem;
  }
}
