/* ==========================================================================
   The Marathon — shared styles
   ========================================================================== */

/* Design tokens
   -------------------------------------------------------------------------- */
:root {
  color-scheme: light dark;

  /* Light theme (default) */
  --color-bg: #fbfaf7;
  --color-surface: #ffffff;
  --color-text: #1a1a1a;
  --color-muted: #5b5b5b;
  --color-border: #e6e3dd;
  --color-accent: #c84630;       /* marathon-tape red */
  --color-accent-soft: #fbe8e3;
  --color-ink: #16213e;          /* deep ink for headings */

  /* Type scale */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: ui-serif, Georgia, "Times New Roman", serif;

  /* Layout */
  --content-max: 72ch;
  --wide-max: 1100px;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.08);

  /* Motion */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0f1117;
    --color-surface: #161922;
    --color-text: #ececec;
    --color-muted: #9aa0ad;
    --color-border: #262a36;
    --color-accent: #ff6b52;
    --color-accent-soft: #2a1a16;
    --color-ink: #ececec;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.5);
  }
}

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

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: var(--color-accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 120ms var(--ease), color 120ms var(--ease);
}
a:hover, a:focus-visible {
  border-bottom-color: currentColor;
}
a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 2px;
}

h1, h2, h3, h4 {
  color: var(--color-ink);
  line-height: 1.2;
  font-weight: 700;
  margin: 0 0 0.5em;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(2rem, 1.4rem + 2.5vw, 3rem); }
h2 { font-size: clamp(1.5rem, 1.1rem + 1.5vw, 2rem); margin-top: 2em; }
h3 { font-size: 1.2rem; margin-top: 1.5em; }
p, ul, ol { margin: 0 0 1em; }

ul, ol { padding-left: 1.25em; }
li + li { margin-top: 0.25em; }

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95em;
}
code { background: var(--color-accent-soft); padding: 0.1em 0.35em; border-radius: 4px; }

hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: 2.5rem 0;
}

/* Skip link
   -------------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--color-accent);
  color: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: 0 0 var(--radius) 0;
  z-index: 1000;
}
.skip-link:focus { left: 0; }

/* Layout
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--wide-max);
  margin: 0 auto;
  padding: 0 1.25rem;
}

main { padding: 2.5rem 0 4rem; }

.prose {
  max-width: var(--content-max);
}

/* Header / Nav
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--color-border);
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--color-ink);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  border-bottom: none;
}
.brand:hover { border-bottom: none; }
.brand__mark {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: var(--color-accent);
  color: #fff;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 800;
}
.brand__text { font-family: var(--font-serif); font-size: 1.15rem; }

.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}

.site-nav ul {
  list-style: none;
  display: flex;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
}
.site-nav a {
  display: inline-block;
  padding: 0.45rem 0.75rem;
  color: var(--color-text);
  border-radius: 8px;
  border-bottom: none;
  font-size: 0.95rem;
}
.site-nav a:hover {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  border-bottom: none;
}
.site-nav a[aria-current="page"] {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  font-weight: 600;
}

@media (max-width: 760px) {
  .nav-toggle { display: inline-flex; align-items: center; gap: 0.4rem; }
  .site-nav {
    position: absolute;
    left: 0; right: 0; top: 100%;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0.5rem 1rem 1rem;
    display: none;
  }
  .site-nav[data-open="true"] { display: block; }
  .site-nav ul { flex-direction: column; gap: 0; }
  .site-nav a { display: block; padding: 0.65rem 0.5rem; }
}

/* Hero
   -------------------------------------------------------------------------- */
.hero {
  padding: 4rem 0 3rem;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 80% at 80% 20%, var(--color-accent-soft), transparent 70%),
    radial-gradient(50% 60% at 0% 100%, color-mix(in srgb, var(--color-accent) 12%, transparent), transparent 70%);
  pointer-events: none;
  z-index: -1;
}
.hero h1 { font-family: var(--font-serif); }
.hero__eyebrow {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.75rem;
  color: var(--color-accent);
  font-weight: 700;
  margin-bottom: 0.75rem;
}
.hero__lede {
  font-size: clamp(1.05rem, 0.95rem + 0.5vw, 1.25rem);
  color: var(--color-muted);
  max-width: 60ch;
}
.hero__cta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
  background: var(--color-accent);
  color: #fff;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  font-weight: 600;
  border-bottom: none;
}
.hero__cta:hover { filter: brightness(1.05); border-bottom: none; }

/* Page header (non-home pages)
   -------------------------------------------------------------------------- */
.page-header {
  padding: 2rem 0 1.5rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 2rem;
}
.page-header__eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.75rem;
  color: var(--color-accent);
  font-weight: 700;
}
.page-header h1 { margin-top: 0.4rem; font-family: var(--font-serif); }
.page-header p { color: var(--color-muted); max-width: 60ch; margin: 0; }

/* Cards / grids
   -------------------------------------------------------------------------- */
.card-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin: 1.5rem 0;
}
.card {
  display: block;
  padding: 1.25rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
  transition: transform 160ms var(--ease), box-shadow 160ms var(--ease), border-color 160ms var(--ease);
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--color-accent) 35%, var(--color-border));
}
.card h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}
.card p {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.95rem;
}
.card__arrow {
  display: inline-block;
  margin-top: 0.75rem;
  color: var(--color-accent);
  font-weight: 600;
}

/* Tables
   -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 1rem 0 1.5rem; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}
th, td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}
thead th {
  background: var(--color-accent-soft);
  color: var(--color-ink);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: color-mix(in srgb, var(--color-accent-soft) 60%, transparent); }

/* Callout
   -------------------------------------------------------------------------- */
.callout {
  border-left: 3px solid var(--color-accent);
  background: var(--color-accent-soft);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.5rem 0;
}
.callout p:last-child { margin-bottom: 0; }

/* TOC
   -------------------------------------------------------------------------- */
.toc {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
}
.toc h2 {
  font-size: 0.8rem;
  margin: 0 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-muted);
}
.toc ol { margin: 0; padding-left: 1.25rem; }

/* Footer
   -------------------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 2rem 0;
  font-size: 0.9rem;
  color: var(--color-muted);
}
.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.site-footer a { color: var(--color-muted); }
.site-footer a:hover { color: var(--color-accent); }

/* Utilities
   -------------------------------------------------------------------------- */
.muted { color: var(--color-muted); }
.center { text-align: center; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.stat {
  display: inline-flex; flex-direction: column;
  padding: 0.75rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  min-width: 120px;
}
.stat__value { font-family: var(--font-serif); font-size: 1.5rem; color: var(--color-ink); font-weight: 700; }
.stat__label { font-size: 0.8rem; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.stats { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1rem 0 1.5rem; }
