/*
  Shared design tokens for generated pages.

  Text contrast on #f6f3ec (WCAG 2.1 AA needs 4.5:1 for normal text):
    --cr-ink   #1b2422  14.33:1
    --cr-muted #5c6a65   5.12:1
    --cr-accent #1d5c55  6.98:1
  All three clear AA, so the proposed values are unchanged.

  --cr-line #e3dbd0 is about 1.24:1 against the paper. It is a decorative
  rule, not the boundary of a control, so it is not held to the 3:1
  non-text requirement. Focus rings use --cr-accent, which clears 3:1.

  Dark bar, measured on #172420:
    --cr-bar-text  #f4f1ea  14.22:1
    --cr-bar-muted #d5ddd8  11.58:1
    --cr-bar-focus #e6d3ae  10.91:1 against the bar, used only as a focus ring

  Homepage and site-bar rules live below the tokens. They are scoped to
  body.cr-home and #cr-sitebar so essay styles are left alone.
*/

:root {
  --cr-bg: #f6f3ec;
  --cr-ink: #1b2422;
  --cr-muted: #5c6a65;
  --cr-accent: #1d5c55;
  --cr-line: #e3dbd0;
  --cr-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --cr-sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --cr-measure: 47.5rem;
  --cr-container: 72.5rem;
  --cr-focus: #1d5c55;
  --cr-bar: #172420;
  --cr-bar-text: #f4f1ea;
  --cr-bar-muted: #d5ddd8;
  --cr-bar-focus: #e6d3ae;
  --cr-break: 640px;
}

/* Site bar. The id selector outranks essay link rules, so the old
   priority overrides are gone. This file still loads after each essay. */
#cr-sitebar {
  display: block;
  margin: 0;
  padding: 0;
  background: var(--cr-bar);
  color: var(--cr-bar-text);
  font-family: var(--cr-sans);
  font-size: 13px;
  line-height: 1.3;
  letter-spacing: 0.01em;
  text-transform: none;
  position: relative;
  width: auto;
  max-width: none;
  min-height: 0;
  border: 0;
  float: none;
  box-sizing: border-box;
}
#cr-sitebar * { box-sizing: border-box; }
#cr-sitebar .cr-sitebar-inner {
  max-width: var(--cr-container);
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
#cr-sitebar a {
  display: inline;
  color: var(--cr-bar-text);
  background: transparent;
  text-decoration: none;
  font-weight: 600;
  font-family: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  text-transform: none;
  border: 0;
  padding: 0;
  margin: 0;
}
#cr-sitebar a.cr-all {
  font-weight: 500;
  color: var(--cr-bar-muted);
}
#cr-sitebar a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
  color: var(--cr-bar-text);
}
#cr-sitebar a:focus-visible {
  outline: 2px solid var(--cr-bar-focus);
  outline-offset: 3px;
}
@media print {
  #cr-sitebar { display: none; }
}

/* Homepage and the small missing-page view. Scoped so essay class names
   such as .mast and .dek keep their own rules.
   The index lede (#3e4c48, 8.13:1) and entry dek (#31403c, 9.82:1)
   stay between ink and muted so the list keeps its hierarchy. */
html:has(body.cr-home) { scroll-behavior: smooth; }
body.cr-home {
  margin: 0;
  background: var(--cr-bg);
  color: var(--cr-ink);
  font-family: var(--cr-serif);
  font-size: 18px;
  line-height: 1.55;
  border-top: 6px solid var(--cr-bar);
}
body.cr-home * { box-sizing: border-box; }
body.cr-home a { color: inherit; }
body.cr-home .skip {
  position: absolute;
  left: 12px;
  top: -48px;
  background: #fff;
  color: var(--cr-ink);
  padding: 8px 12px;
  z-index: 2;
  font-family: var(--cr-sans);
}
body.cr-home .skip:focus { top: 12px; }
body.cr-home .wrap { width: min(55rem, calc(100% - 40px)); margin: 0 auto; }
body.cr-home .mast { padding: 28px 0 8px; }
body.cr-home .topline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  font-family: var(--cr-sans);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
body.cr-home .kicker { margin: 0; color: var(--cr-accent); font-weight: 700; }
body.cr-home .tools a {
  color: var(--cr-accent);
  text-decoration: none;
  letter-spacing: 0.12em;
  padding: 8px 0;
}
body.cr-home .tools a:hover { text-decoration: underline; text-underline-offset: 3px; }
body.cr-home .tools a:focus-visible,
body.cr-home .back:focus-visible,
body.cr-home .entry:focus-visible {
  outline: 3px solid var(--cr-focus);
  outline-offset: 4px;
}
body.cr-home h1 {
  font-weight: 500;
  font-size: clamp(2.15rem, 7.2vw, 4.25rem);
  letter-spacing: -0.045em;
  line-height: 0.98;
  margin: 22px 0 14px;
  text-wrap: balance;
}
body.cr-home .lede {
  max-width: 38rem;
  margin: 0 0 8px;
  color: #3e4c48;
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  line-height: 1.45;
}
body.cr-home .count {
  margin: 28px 0 0;
  font-family: var(--cr-sans);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cr-muted);
}
body.cr-home .entry {
  display: grid;
  grid-template-columns: 9.25rem 1fr;
  gap: 8px 28px;
  padding: 26px 0;
  border-bottom: 1px solid var(--cr-line);
  text-decoration: none;
  color: inherit;
}
body.cr-home .entry:first-of-type { border-top: 1px solid var(--cr-ink); margin-top: 12px; }
body.cr-home .entry time {
  font-family: var(--cr-sans);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cr-muted);
  padding-top: 7px;
}
body.cr-home .entry h2 {
  font-weight: 500;
  font-size: clamp(1.45rem, 2.5vw, 1.9rem);
  letter-spacing: -0.03em;
  line-height: 1.16;
  margin: 0 0 8px;
  text-wrap: balance;
}
body.cr-home .entry:hover h2 { color: var(--cr-accent); }
body.cr-home .dek { margin: 0; color: #31403c; font-size: 1.02rem; line-height: 1.45; }
body.cr-home .colophon {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-top: 1px solid var(--cr-ink);
  margin-top: 8px;
  padding: 22px 0 48px;
  font-family: var(--cr-sans);
  font-size: 13px;
  color: var(--cr-muted);
}
body.cr-home .colophon a { color: var(--cr-accent); }
body.cr-home .missing { padding: 48px 0 80px; }
body.cr-home .back {
  display: inline-block;
  margin-top: 8px;
  color: var(--cr-accent);
  font-family: var(--cr-sans);
  font-size: 14px;
}
@media (max-width: 640px) {
  body.cr-home .wrap { width: min(100% - 32px, 55rem); }
  body.cr-home .entry { grid-template-columns: 1fr; gap: 6px; padding: 22px 0; }
  body.cr-home .entry time { padding-top: 0; }
  body.cr-home h1 { margin-top: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  html:has(body.cr-home) { scroll-behavior: auto; }
}
