/* ============================================================
   Design tokens. Inter for everything, JetBrains Mono for code
   only.
   ============================================================ */

@font-face { font-family: 'Inter'; src: url('/fonts/inter-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/inter-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/inter-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('/fonts/jetbrains-mono-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }

:root {
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --fs-xs: 0.75rem;     /* 12px  labels */
  --fs-sm: 0.8125rem;   /* 13px  secondary */
  --fs-base: 0.9375rem; /* 15px  body */
  --fs-h3: 1rem;
  --fs-h2: 1.125rem;
  --fs-h1: 1.75rem;

  --lh-body: 1.65;
  --lh-tight: 1.25;

  --s-1: 0.25rem;  --s-2: 0.5rem;  --s-3: 0.75rem;  --s-4: 1rem;
  --s-5: 1.5rem;   --s-6: 2rem;    --s-7: 3rem;     --s-8: 4rem;

  --measure: 880px;
  --page-pad-y: 4rem;
  --page-pad-x: 2rem;

  /* Ink, the default: a charcoal with a little violet in it. Palette after
     herdr.dev. */
  color-scheme: dark;
  --bg: #17171a;
  --ink: #eae8ee;
  --ink-2: #cdccd2;
  --muted: #908f96;
  --rule: #2b2b31;
  --code-bg: #1e1e22;
  --sel-bg: #35353d;
  --accent: #cba6f7;
  --grain: 0.07;
  --doodle: 0.07;
}

/* Paper: warm off-white with brown-black ink. Muted is a step darker than
   herdr's so small text keeps AA contrast. */
:root[data-theme='paper'] {
  color-scheme: light;
  --bg: #efece5;
  --ink: #15140f;
  --ink-2: #55534a;
  --muted: #6b6759;
  --rule: #d6d1c5;
  --code-bg: #e7e3da;
  --sel-bg: #ddd8cc;
  --accent: #8839ef;
  --grain: 0.09;
  --doodle: 0.09;
}

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

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  background: var(--bg);
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  max-width: var(--measure);
  margin: 0 auto;
  padding: var(--page-pad-y) var(--page-pad-x);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  transition: color 0.2s ease;
}
@media (max-width: 34rem) {
  body { padding: 2.5rem 1.25rem; }
}

::selection { background: var(--sel-bg); }

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  line-height: var(--lh-tight);
  text-wrap: balance;
}
h1 { font-size: var(--fs-h1); letter-spacing: -0.02em; }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }

p { margin: 0; }
ul, ol { margin: 0; padding-left: 1.1rem; }
li::marker { color: var(--muted); }
img, svg, video { max-width: 100%; height: auto; display: block; }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--muted);
  text-decoration-thickness: 1px;
  text-underline-offset: 2.5px;
  transition: text-decoration-color 0.15s ease, color 0.15s ease;
}
a:hover { text-decoration-color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--ink-2);
  outline-offset: 3px;
  border-radius: 2px;
}

hr { border: 0; height: 1px; background: var(--rule); margin: var(--s-7) 0; }

.muted { color: var(--muted); }

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 99;
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: var(--s-2) var(--s-4);
  font-size: var(--fs-sm);
  text-decoration: none;
}
.skip:focus { left: var(--s-4); top: var(--s-4); }

/* ============================================================
   Home: a name, one sentence, the links, then everything on
   one scroll.
   ============================================================ */

body.home { max-width: 1000px; padding-top: 0; padding-bottom: 0; }

/* Profile on the left, sticky and vertically centred; the lists scroll
   beside it. */
.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  column-gap: 5rem;
  align-items: start;
}
.intro {
  position: sticky;
  top: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: var(--page-pad-y) 0;
}
/* Starts level with the avatar rather than at the top of the screen. */
.lists { padding: max(var(--page-pad-y), calc(50svh - 15rem)) 0 var(--page-pad-y); }
.avatar {
  align-self: center;
  width: 168px;
  height: 168px;
  border-radius: 50%;
  margin-bottom: var(--s-6);
}
@media (max-width: 52rem) {
  .layout { grid-template-columns: 1fr; }
  .intro { position: static; min-height: 0; padding-bottom: 0; }
  .lists { padding-top: var(--s-7); }
  .avatar { width: 120px; height: 120px; }
}

.intro h1 { font-size: 2rem; }
.intro .muted { margin-top: var(--s-1); font-size: var(--fs-sm); }
.sentence { margin-top: var(--s-5); color: var(--ink-2); }
.sentence a {
  color: var(--ink);
  text-decoration-style: dotted;
  text-decoration-color: var(--muted);
}
.sentence a:hover { text-decoration-style: solid; }

/* ---------- round icons, and the résumé as the one button ---------- */
.elsewhere {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  margin-top: var(--s-5);
}
.icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  color: var(--ink-2);
  transition: border-color 0.15s ease, color 0.15s ease;
}
.icon:hover { color: var(--ink); border-color: var(--muted); }
.icon svg { width: 15px; height: 15px; }
.icon svg:not([fill]) { fill: currentColor; }
.cv {
  margin-left: var(--s-2);
  padding: 0.4rem 1.1rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.15s ease;
}
.cv:hover { opacity: 0.85; }

/* ---------- tabs: one list at a time, no page load ---------- */
.tabs {
  position: relative;
  display: flex;
  justify-content: center;
  gap: var(--s-6);
  margin-bottom: var(--s-6);
  border-bottom: 1px solid var(--rule);
}
html:not(.js) .tabs { display: none; }
.tabs button {
  padding: 0 0 var(--s-3);
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s ease;
}
.tabs button:hover,
.tabs button[aria-current='true'] { color: var(--ink); }
.tab-line {
  position: absolute;
  bottom: -1px;
  height: 1px;
  background: var(--accent);
}
.tab-line.ready { transition: left 0.25s ease, width 0.25s ease; }

.js .lists section { display: none; }
.js .lists section.active { display: block; }
.js .lists .label { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .js .lists section.active { animation: rise 0.3s ease both; }
  .js .lists[data-slide='left'] section.active { animation-name: from-right; }
  .js .lists[data-slide='right'] section.active { animation-name: from-left; }
  @keyframes rise { from { opacity: 0; transform: translateY(4px); } }
  @keyframes from-right { from { opacity: 0; transform: translateX(24px); } }
  @keyframes from-left { from { opacity: 0; transform: translateX(-24px); } }
}

/* ---------- sections ---------- */
html:not(.js) .home section + section { margin-top: var(--s-8); }
.home section { scroll-margin-top: var(--page-pad-y); }
.label {
  margin-bottom: var(--s-4);
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--muted);
}

/* ---------- the index: name, dot leaders, year ---------- */
.index { list-style: none; padding: 0; }
.index > li + li { margin-top: var(--s-3); }
.row {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  color: var(--ink);
  text-decoration: none;
}
.row i {
  flex: 1;
  min-width: var(--s-5);
  border-bottom: 1px dotted var(--rule);
  transform: translateY(-0.3em);
}
.row > :last-child, .row .year { color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }
a.row:hover > :first-child { text-decoration: underline; text-decoration-color: var(--muted); text-underline-offset: 2.5px; }
.note { color: var(--muted); font-size: var(--fs-sm); }
.about { margin-top: var(--s-1); color: var(--ink-2); font-size: 0.875rem; font-style: italic; }
.points {
  margin-top: var(--s-2);
  padding-left: 1rem;
  color: var(--ink-2);
  font-size: 0.875rem;
  line-height: 1.6;
}
.points li + li { margin-top: var(--s-1); }

/* ---------- one glyph: the moon in Ink, the sun on Paper ---------- */
.theme {
  position: fixed;
  top: var(--s-4);
  right: var(--s-4);
  z-index: 10;
  display: grid;
  width: 32px;
  height: 32px;
  padding: 8px;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.theme:hover { color: var(--ink); }
.theme svg {
  grid-area: 1 / 1;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 0.3s ease, transform 0.4s ease;
}
.theme .sun { opacity: 0; transform: rotate(-90deg) scale(0.6); }
:root[data-theme='paper'] .theme .sun { opacity: 1; transform: none; }
:root[data-theme='paper'] .theme .moon { opacity: 0; transform: rotate(90deg) scale(0.6); }

/* ============================================================
   A single project or note: one plain reading column.
   ============================================================ */

.back {
  display: inline-block;
  margin-bottom: var(--s-7);
  color: var(--muted);
  font-size: var(--fs-sm);
  text-decoration-color: transparent;
}
.back:hover { color: var(--ink); text-decoration-color: var(--muted); }

article h1 { margin-bottom: var(--s-2); }
.meta { margin: 0 0 var(--s-6); font-size: var(--fs-sm); }

.prose { color: var(--ink-2); }
.prose > * + * { margin-top: var(--s-5); }
.prose strong { color: var(--ink); font-weight: 600; }
.prose :is(h2, h3, h4) { color: var(--ink); }
.prose h2 { margin-top: var(--s-7); }
.prose h3 { margin-top: var(--s-6); }
.prose h4 { font-size: var(--fs-base); margin-top: var(--s-5); }
.prose ul, .prose ol { padding-left: 1.2rem; }
.prose li + li { margin-top: var(--s-2); }
.prose blockquote {
  margin: 0;
  padding-left: var(--s-4);
  border-left: 1px solid var(--rule);
  color: var(--muted);
  font-style: italic;
}
.prose code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.12em 0.34em;
  border-radius: 3px;
}
.prose pre {
  margin: 0;
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: var(--s-4);
  overflow-x: auto;
  font-size: var(--fs-sm);
  line-height: 1.55;
}
.prose pre code { background: none; padding: 0; font-size: 0.9em; }
.prose figure { margin: 0; }
.prose figcaption { margin-top: var(--s-2); font-size: var(--fs-sm); color: var(--muted); }
.prose table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.prose :is(th, td) {
  text-align: left;
  padding: var(--s-2) var(--s-3) var(--s-2) 0;
  border-bottom: 1px solid var(--rule);
}
.prose th { color: var(--ink); font-weight: 600; }

.flow > * + * { margin-top: var(--s-5); }

/* Mileage has the column to itself now, so it reads one step larger. */
#mileage .row > :first-child { font-size: 1.0625rem; font-weight: 500; }
#mileage .index > li + li { margin-top: var(--s-6); }

/* ---------- Garage: one row each, a tag on the right ---------- */
#garage .index > li + li { margin-top: var(--s-4); }
.row .tag {
  width: 5.25rem;
  margin-left: var(--s-3);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-align: right;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}
a.tag:hover { color: var(--accent); }

/* ---------- Scratchpad: grouped by year, a type tag on the right ---------- */
.year-head { margin: var(--s-6) 0 var(--s-3); color: var(--muted); font-size: var(--fs-sm); }
#scratchpad .year-head:first-of-type { margin-top: 0; }

/* ---------- grain behind every page ---------- */
.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.grain rect { opacity: var(--grain); mix-blend-mode: overlay; }

/* ---------- doodles: faint line drawings per tab ---------- */
.doodles {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  /* Fade toward the middle so the reading area stays clean. */
  -webkit-mask-image: radial-gradient(ellipse 38% 34% at 50% 50%, transparent 55%, #000 100%);
  mask-image: radial-gradient(ellipse 38% 34% at 50% 50%, transparent 55%, #000 100%);
}
/* On a post the text runs down a wide column, so clear that whole band. */
body:not(.home) .doodles {
  -webkit-mask-image: linear-gradient(to right, #000 calc(50% - 500px), transparent calc(50% - 450px), transparent calc(50% + 450px), #000 calc(50% + 500px));
  mask-image: linear-gradient(to right, #000 calc(50% - 500px), transparent calc(50% - 450px), transparent calc(50% + 450px), #000 calc(50% + 500px));
}
.doodles .set {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transition: opacity 0.5s ease;
}
body[data-tab='mileage'] .set[data-set='mileage'],
body[data-tab='garage'] .set[data-set='garage'],
body[data-tab='scratchpad'] .set[data-set='scratchpad'] { opacity: var(--doodle); }
/* Phones get the narrow canvas, with no clear zone. */
.doodles .tall { display: none; }
@media (max-width: 52rem) {
  .doodles .wide { display: none; }
  .doodles .tall { display: block; }
  .doodles, body:not(.home) .doodles { -webkit-mask-image: none; mask-image: none; }
  :root { --doodle: 0.06; }
  :root[data-theme='paper'] { --doodle: 0.08; }
}
@media print { .grain, .doodles { display: none; } }
