:root {
  --bg: #fbfaf7;
  --text: #1d1d1b;
  --muted: #6b6a66;
  --line: #e4e1da;
  --accent: #b5452c;
  --todo-bg: #fff3c4;
  --todo-text: #6b5300;
  --serif: "Iowan Old Style", "Charter", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161614;
    --text: #e8e6e1;
    --muted: #9a9890;
    --line: #2e2d2a;
    --accent: #e8805f;
    --todo-bg: #3a3214;
    --todo-text: #f0d77a;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 var(--sans);
}

.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

/* Header */
.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 18px;
  padding-bottom: 14px;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.site-nav .name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 18px;
  color: var(--text);
  margin-right: auto;
}
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current] { color: var(--text); }

/* Type */
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; }
h1 { font-size: 34px; margin: 0 0 12px; letter-spacing: -0.01em; }
h2 { font-size: 22px; margin: 44px 0 10px; }
h3 { font-size: 18px; margin: 28px 0 4px; }
p { margin: 0 0 14px; }
a { color: var(--accent); text-underline-offset: 2px; }
.lede { font-size: 20px; color: var(--muted); font-family: var(--serif); margin-bottom: 28px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* Homepage portrait + intro */
.intro { display: flex; gap: 22px; align-items: flex-start; margin-bottom: 8px; }
.portrait {
  flex: 0 0 96px; width: 96px; height: 96px; border-radius: 50%;
  object-fit: cover; background: var(--line);
}
.cover { display: flex; gap: 18px; align-items: flex-start; margin: 16px 0 8px; }
.cover img { width: 150px; height: auto; border: 1px solid var(--line); flex: 0 0 auto; }
.cover p { margin: 0; }
@media (max-width: 520px) { .cover { flex-direction: column; } }

/* Section cards on the homepage */
.threads { list-style: none; padding: 0; margin: 28px 0 0; }
.threads li { padding: 16px 0; border-top: 1px solid var(--line); }
.threads li:last-child { border-bottom: 1px solid var(--line); }
.threads a.title { font-family: var(--serif); font-size: 19px; font-weight: 600; color: var(--text); text-decoration: none; }
.threads a.title:hover { color: var(--accent); }
.threads p { margin: 4px 0 0; color: var(--muted); font-size: 16px; }

/* Role / case-study blocks */
.role { margin: 32px 0; }
.role .meta { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.role dl { margin: 10px 0 0; }
.role dt { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-top: 10px; }
.role dd { margin: 2px 0 0; }

ul.plain { padding-left: 20px; }
ul.plain li { margin-bottom: 6px; }

/* Numbers strip */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 20px 0 8px; }
.stat { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.stat b { display: block; font-family: var(--serif); font-size: 24px; line-height: 1.2; white-space: nowrap; }
.stat span { font-size: 13px; color: var(--muted); }

/* Race log */
.table-scroll { overflow-x: auto; margin: 12px 0 20px; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
td.year { color: var(--muted); white-space: nowrap; }
td.result { white-space: nowrap; }

/* Draft placeholders: delete this rule once all copy is final */
.todo {
  background: var(--todo-bg); color: var(--todo-text);
  padding: 1px 6px; border-radius: 4px; font-size: 0.9em;
}

/* Footer */
footer {
  margin-top: 56px; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: 14px; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 6px 18px;
}
footer a { color: var(--muted); }

@media (max-width: 520px) {
  body { font-size: 16px; }
  h1 { font-size: 28px; }
  .intro { flex-direction: column-reverse; gap: 14px; }
  .portrait { flex-basis: auto; width: 80px; height: 80px; }
}
