/*
  Average Joe Chess: shared base styles for all three sites.
  Light only (newsprint). Load order in every page:
    <link rel="stylesheet" href="/assets/fonts/fonts.css">
    <link rel="stylesheet" href="/assets/base.css">
    <link rel="stylesheet" href="/assets/site.css">   (per site, optional)

  CSP note: the Caddy blocks send style-src 'self', so <style> elements
  (including one inside an inline SVG) and style="" attributes are BLOCKED.
  Put every rule in a stylesheet file. SVG presentation attributes such as
  fill="" and stroke="" are fine.

  Palette is PROPOSED on the AJC wiki /Brand. Rust is the one loud thing.
*/

/* ---------- Tokens ---------- */
:root {
  /* Palette */
  --ajc-newsprint: #F4F1EA;
  --ajc-ink: #161616;
  --ajc-rust: #B5452B;
  --ajc-steel: #5B6770;

  /* Roles: pages use these, not the raw palette names */
  --color-bg: var(--ajc-newsprint);
  --color-text: var(--ajc-ink);
  --color-muted: var(--ajc-steel);
  --color-accent: var(--ajc-rust);
  --color-rule: var(--ajc-ink);
  --color-focus: var(--ajc-ink);
  --color-on-accent: var(--ajc-newsprint);

  /* Families */
  --font-display: 'Oswald', 'Arial Narrow', 'Roboto Condensed', Impact, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --font-body: 'Source Serif 4', Georgia, 'Times New Roman', serif;

  /* Type scale: fixed sizes for text, fluid sizes for display type */
  --text-xs: 0.8125rem;   /* 13px mono labels */
  --text-sm: 0.9375rem;   /* 15px small print */
  --text-base: 1.125rem;  /* 18px body serif */
  --text-lg: 1.3125rem;   /* 21px lead paragraph */
  --text-xl: clamp(1.625rem, 1.3rem + 1.4vw, 2.25rem);
  --text-2xl: clamp(2.25rem, 1.6rem + 3vw, 3.75rem);
  --text-3xl: clamp(3rem, 1.9rem + 5.6vw, 6.5rem);

  --leading-tight: 1.05;
  --leading-snug: 1.25;
  --leading-body: 1.6;

  --tracking-display: 0.01em;
  --tracking-label: 0.14em;

  /* Spacing scale (4px base) */
  --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: 4.5rem;
  --space-9: 6.5rem;

  /* Layout */
  --gutter: 1rem;           /* 16px side gutter at phone width */
  --measure: 62ch;          /* comfortable line length for body text */
  --page-max: 72rem;
  --radius-sm: 4px;
  --radius-md: 10px;
  --rule-thin: 2px;
  --rule-thick: 6px;
  --focus-ring: 3px;
}

@media (min-width: 48em) {
  :root {
    --gutter: 2rem;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color-scheme: light;
}

body,
h1, h2, h3, h4, h5, h6,
p, figure, blockquote,
ul, ol, dl, dd {
  margin: 0;
}

ul[role='list'],
ol[role='list'] {
  list-style: none;
  padding: 0;
}

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

img {
  height: auto;
}

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

button {
  cursor: pointer;
}

/* ---------- Base typography ---------- */
body {
  min-height: 100vh;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-display);
  text-wrap: balance;
}

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 {
  max-width: var(--measure);
  text-wrap: pretty;
}

strong, b {
  font-weight: 600;
}

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

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--color-accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.18em;
}

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

hr {
  border: 0;
  border-top: var(--rule-thin) solid var(--color-rule);
  margin: var(--space-6) 0;
}

/* Mono label: the "WITH JOE HUNGERMAN" style rule line */
.label {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

/* ---------- Focus ---------- */
:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: var(--focus-ring) solid var(--color-focus);
  outline-offset: 3px;
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--ajc-ink);
  color: var(--ajc-newsprint);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--text-sm);
  text-decoration: none;
  transform: translateY(-200%);
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: none;
  outline: var(--focus-ring) solid var(--ajc-rust);
  outline-offset: 2px;
}

/* ---------- Utilities ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Inline SVG icon that follows the text color; give it aria-hidden="true"
   and put the accessible name on the link around it. */
.icon {
  display: inline-block;
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: currentColor;
  vertical-align: -0.2em;
}

.wrap {
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

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

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}
