/* ============================================================
   Endoxa — Colors & Type
   ------------------------------------------------------------
   The full system is documented in brand-brief.md (§ IX, § X).
   This file is the single source of truth for tokens.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Crimson+Pro:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&family=Arsenal+SC:wght@400;700&family=IBM+Plex+Mono:ital,wght@0,400;0,500;1,400&display=swap');

:root {
  /* ---------- Colour ---------- */
  /* A disciplined palette. One paper. One ink. One accent. */
  --paper:       #F0ECE1;  /* page background · warm cream */
  --ink:         #2B2824;  /* body text · wordmark · never pure black */
  --soft-ink:    #645C4E;  /* secondary text · captions · quiet labels */
  --hairline:    #AA9E8C;  /* rules · dividers · borders · 1 px only */
  --vermillion:  #BF5E44;  /* printer's mark · earned accent */
  --faint:       #CDC3B2;  /* de-emphasized rules · subtle backgrounds */

  /* Semantic aliases — use these in components */
  --bg:            var(--paper);
  --fg:            var(--ink);
  --fg-muted:      var(--soft-ink);
  --rule:          var(--hairline);
  --rule-faint:    var(--faint);
  --accent:        var(--vermillion);

  /* ---------- Typefaces ---------- */
  /* Never pair two different serifs in the same page. */
  --font-display: 'Instrument Serif', 'Cormorant Garamond', 'EB Garamond', Georgia, serif;
  --font-body:    'Crimson Pro', 'Crimson Text', 'Minion Pro', Georgia, serif;
  --font-smallcaps: 'Arsenal SC', 'Optima', 'Trajan Pro', serif;
  --font-mono:    'IBM Plex Mono', 'SF Mono', Menlo, monospace;
  --font-greek:   'DejaVu Serif', 'GFS Didot', 'Gentium Plus', 'Crimson Pro', serif;

  /* ---------- Type scale (web defaults) ---------- */
  --fs-h1:        clamp(3.5rem, 6vw + 1rem, 6rem);    /* 64–96 px */
  --fs-h2:        clamp(2.25rem, 3vw + 1rem, 3rem);   /* 36–48 px */
  --fs-h3:        clamp(1.5rem, 1vw + 1rem, 1.75rem); /* 24–28 px */
  --fs-body:      1.1875rem;                          /* 19 px */
  --fs-body-lg:   1.25rem;                            /* 20 px */
  --fs-label:     0.875rem;                           /* 14 px · small caps */
  --fs-label-lg:  1rem;                               /* 16 px · small caps */
  --fs-caption:   0.8125rem;                          /* 13 px · mono */
  --fs-caption-lg:0.9375rem;                          /* 15 px · mono */

  /* ---------- Line height ---------- */
  --lh-display:  1.04;
  --lh-heading:  1.12;
  --lh-body:     1.58;
  --lh-tight:    1.3;

  /* ---------- Letter-spacing ---------- */
  --ls-smallcaps: 0.16em;   /* ~0.12–0.18em; 0.16 reads best at 14px */
  --ls-smallcaps-tight: 0.08em;
  --ls-display:  -0.01em;
  --ls-body:      0;

  /* ---------- Spacing (page rhythm) ---------- */
  /* A gentle 4-step scale. Generous whitespace is a design principle. */
  --sp-0:    0.25rem;   /*  4 px */
  --sp-1:    0.5rem;    /*  8 px */
  --sp-2:    1rem;      /* 16 px */
  --sp-3:    1.5rem;    /* 24 px */
  --sp-4:    2rem;      /* 32 px */
  --sp-5:    3rem;      /* 48 px */
  --sp-6:    4.5rem;    /* 72 px */
  --sp-7:    6rem;      /* 96 px */
  --sp-8:    8rem;      /* 128 px — page-gutter on desktop */

  /* ---------- Measure (reading widths) ---------- */
  --measure-tight:  32rem;   /* 512 px — pull quotes, lockups */
  --measure-body:   38rem;   /* 608 px — body prose */
  --measure-wide:   46rem;   /* 736 px — lists, tables */
  --measure-page:   64rem;   /* 1024 px — full page frame */

  /* ---------- Rules ---------- */
  --rule-width:    1px;
  --rule-length-sm: 3rem;
  --rule-length-md: 5rem;
  --rule-length-lg: 8rem;

  /* ---------- Corners ---------- */
  /* Never round more than 4px. Most things are 0. */
  --radius-0: 0;
  --radius-1: 2px;
  --radius-2: 4px;
}

/* ============================================================
   Base elements
   ============================================================ */

html {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern", "liga", "onum";
}

body {
  margin: 0;
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--fg);
  background: var(--bg);
}

/* ---------- Headings ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--fg);
  letter-spacing: var(--ls-display);
  line-height: var(--lh-heading);
  margin: 0 0 var(--sp-3) 0;
  text-wrap: balance;
}
h1 { font-size: var(--fs-h1); line-height: var(--lh-display); letter-spacing: -0.015em; }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }

/* ---------- Body prose ---------- */
p {
  font-family: var(--font-body);
  font-size: var(--fs-body-lg);
  line-height: var(--lh-body);
  max-width: var(--measure-body);
  margin: 0 0 1.25em 0;
  text-wrap: pretty;
}

em, i, .italic {
  font-family: var(--font-body);
  font-style: italic;
}

strong, b {
  font-weight: 700;
}

/* ---------- Links ---------- */
a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color 180ms ease, text-decoration-color 180ms ease;
}
a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}
/* When vermillion is already used elsewhere on the page, add
   `.vermillion-claimed` to <main> and hovers fall back to ink. */
.vermillion-claimed a:hover {
  color: var(--ink);
  text-decoration-color: var(--ink);
}

/* ---------- Small caps ---------- */
.smallcaps, .label {
  font-family: var(--font-smallcaps);
  font-weight: 400;
  font-size: var(--fs-label);
  letter-spacing: var(--ls-smallcaps);
  text-transform: uppercase;
  color: var(--fg-muted);
}
.smallcaps--ink { color: var(--fg); }

/* ---------- Mono captions ---------- */
.caption, code, kbd, samp {
  font-family: var(--font-mono);
  font-size: var(--fs-caption-lg);
  color: var(--fg-muted);
  font-feature-settings: "kern", "liga";
}

/* ---------- Greek ---------- */
.greek {
  font-family: var(--font-greek);
  font-style: italic;
  font-feature-settings: "kern";
}

/* ---------- Rules ---------- */
hr, .rule {
  border: 0;
  height: var(--rule-width);
  background: var(--rule);
  margin: var(--sp-5) auto;
  width: var(--rule-length-md);
}
.rule--faint  { background: var(--rule-faint); }
.rule--short  { width: var(--rule-length-sm); }
.rule--long   { width: var(--rule-length-lg); }
.rule--full   { width: 100%; }

/* Three-dot centered separator: rule · · · rule */
.rule-dotted {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  color: var(--fg-muted);
  margin: var(--sp-5) 0;
}
.rule-dotted::before,
.rule-dotted::after {
  content: "";
  height: 1px;
  width: var(--rule-length-sm);
  background: var(--rule);
}

/* ---------- Selection ---------- */
::selection {
  background: var(--accent);
  color: var(--paper);
}

/* ---------- Focus ---------- */
:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}

/* ============================================================
   Utilities
   ============================================================ */
.page       { max-width: var(--measure-page); margin: 0 auto; padding: 0 var(--sp-4); }
.measure    { max-width: var(--measure-body); }
.measure-tight { max-width: var(--measure-tight); }
.center     { text-align: center; }
.mute       { color: var(--fg-muted); }
.accent     { color: var(--accent); }
