/* ------------------------------------------------------------------ tokens */
:root {
  --paper: #fafaf7;
  --ink: #171a1e;
  --muted: #61686f;
  --faint: #8a9096;
  --accent: #1c6b4c;
  --accent-soft: #1c6b4c22;
  --hairline: #e2e3dc;
  --card: #ffffff;

  --font-display: "Space Grotesk", "Avenir Next", sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;

  --measure: 60rem;
  --rail: 8rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121514;
    --ink: #e6e4de;
    --muted: #9aa29c;
    --faint: #6f7772;
    --accent: #56b189;
    --accent-soft: #56b18926;
    --hairline: #262b28;
    --card: #181c1a;
  }
}
:root[data-theme="light"] {
  --paper: #fafaf7; --ink: #171a1e; --muted: #61686f; --faint: #8a9096;
  --accent: #1c6b4c; --accent-soft: #1c6b4c22; --hairline: #e2e3dc; --card: #ffffff;
}
:root[data-theme="dark"] {
  --paper: #121514; --ink: #e6e4de; --muted: #9aa29c; --faint: #6f7772;
  --accent: #56b189; --accent-soft: #56b18926; --hairline: #262b28; --card: #181c1a;
}

/* ------------------------------------------------------------------- base */
* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; text-underline-offset: 0.2em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* ---------------------------------------------------------------- toolbar */
.toolbar {
  position: fixed;
  top: 0.9rem;
  right: 0.9rem;
  display: flex;
  gap: 0.4rem;
  z-index: 10;
}
.toolbar button {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.38em 0.7em;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  cursor: pointer;
}
.toolbar button:hover { color: var(--accent); border-color: var(--accent); }
.toolbar-group { position: relative; }
.toolbar-menu[hidden] { display: none; }
.toolbar-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.3rem);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  min-width: 100%;
}
.toolbar-menu a {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.45em 0.8em;
  color: var(--muted);
  white-space: nowrap;
}
.toolbar-menu a:hover { color: var(--accent); background: var(--accent-soft); text-decoration: none; }

/* ----------------------------------------------------------------- layout */
.resume {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 4.5rem 1.5rem 3rem;
}

/* ----------------------------------------------------------------- header */
.masthead { margin-bottom: 2.8rem; }
.masthead .name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.1rem, 6vw, 3.4rem);
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.masthead .label {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.05rem;
  color: var(--accent);
  margin-top: 0.5rem;
}
.masthead .tagline {
  color: var(--muted);
  max-width: 46rem;
  margin-top: 0.6rem;
}
.masthead .contact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.4rem;
  margin-top: 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  list-style: none;
}
.masthead .contact a { color: inherit; }
.masthead .contact a:hover { color: var(--accent); }

/* --------------------------------------------------------------- sections */
.section {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  gap: 0 1.6rem;
  padding: 1.7rem 0;
  border-top: 1px solid var(--hairline);
}
/* The signature: section titles are the data's own keys. */
.section > h2 {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--accent);
  letter-spacing: 0.01em;
  padding-top: 0.15rem;
}
.section > h2::after { content: ":"; color: var(--faint); }
.section-note {
  font-size: 0.85rem;
  color: var(--faint);
  margin-top: 0.5rem;
  grid-column: 2;
}

@media (max-width: 46rem) {
  .section { display: block; }
  .section > h2 { margin-bottom: 0.9rem; }
}

/* ------------------------------------------------------------------ prose */
.prose p + p { margin-top: 0.7rem; }

/* --------------------------------------------------------------- timeline */
.timeline { list-style: none; }
.timeline > li + li { margin-top: 1.5rem; }
.entry-head { display: flex; align-items: baseline; gap: 0.8rem; flex-wrap: wrap; }
.entry-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.02rem;
}
.entry-org { color: var(--muted); }
.entry-org::before { content: "· "; color: var(--faint); }
.entry-period {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--faint);
  white-space: nowrap;
}
.entry-sub {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--faint);
  margin-top: 0.15rem;
}
.entry-body { margin-top: 0.45rem; }

/* ---------------------------------------------------------------- bullets */
.bullets { list-style: none; }
.bullets > li {
  padding-left: 1.05rem;
  position: relative;
}
.bullets > li + li { margin-top: 0.3rem; }
.bullets > li::before {
  content: "–";
  position: absolute;
  left: 0;
  color: var(--accent);
}

/* ----------------------------------------------------------------- groups */
.groups { display: grid; gap: 0.55rem; }
.group { display: grid; grid-template-columns: 11rem 1fr; gap: 1rem; }
.group-name {
  font-weight: 600;
  font-size: 0.85rem;
  padding-top: 0.1rem;
}
.group-items { color: var(--muted); font-size: 0.92rem; }
.group-items .sep { color: var(--faint); padding: 0 0.35em; }
@media (max-width: 46rem) {
  .group { grid-template-columns: 1fr; gap: 0.1rem; }
}

/* ------------------------------------------------------------------ cards */
.cards { display: grid; gap: 1.5rem; list-style: none; }
/* nowrap + flexible name: a long title wraps inside its own column while
   the period keeps its dedicated slot on the first line. */
.card-head { display: flex; align-items: baseline; gap: 0.8rem; flex-wrap: nowrap; }
.card-name { font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; flex: 1 1 auto; min-width: 0; }
.card-name a { color: inherit; }
.card-name a:hover { color: var(--accent); }
.card-period { flex: none; margin-left: auto; font-family: var(--font-mono); font-size: 0.74rem; color: var(--faint); white-space: nowrap; }
.card-stack { font-family: var(--font-mono); font-size: 0.74rem; color: var(--accent); margin-top: 0.15rem; }
.card-desc { margin-top: 0.4rem; }
.card-desc + .bullets { margin-top: 0.45rem; }

/* ------------------------------------------------------------------ media */
/* Floated right of the card text, which wraps around it. */
.media {
  float: right;
  width: 15rem;
  margin: 0.3rem 0 0.8rem 1.4rem;
  display: grid;
  gap: 1rem;
}
.media-item { width: 100%; }
.cards > li::after { content: ""; display: block; clear: both; }
@media (max-width: 34rem) {
  .media { float: none; width: 100%; max-width: 15rem; margin: 0.8rem 0 0; }
}
.media-item img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid var(--hairline);
  border-radius: 4px;
}
.media-item a:hover img, .media-item a:focus-visible img { border-color: var(--accent); }
.media-item figcaption {
  margin-top: 0.35rem;
  display: grid;
  gap: 0.1rem;
}
.media-title {
  font-family: var(--font-mono);
  font-size: 0.74rem;
}
.media-title a { color: var(--muted); }
.media-title a:hover { color: var(--accent); text-decoration: none; }
.media-note {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
}

/* ---------------------------------------------------------------- columns */
.columns { columns: 2; gap: 2rem; list-style: none; }
.columns > li { padding-left: 1.05rem; position: relative; break-inside: avoid; margin-bottom: 0.3rem; }
.columns > li::before { content: "–"; position: absolute; left: 0; color: var(--accent); }
@media (max-width: 34rem) { .columns { columns: 1; } }

/* --------------------------------------------------------------- colophon */
.colophon {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.5rem 2.5rem;
  border-top: 0;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--faint);
}
.colophon a { color: var(--muted); }
.colophon a:hover { color: var(--accent); }
.colophon p + p { margin-top: 0.3rem; }
.colophon-site[hidden] { display: none; }

/* ------------------------------------------------------------------ print */
@media print {
  @page { size: letter; margin: 0.55in; }
  :root, :root[data-theme="dark"] {
    --paper: #ffffff; --ink: #111111; --muted: #444444; --faint: #777777;
    --accent: #1c6b4c; --hairline: #dddddd; --card: #ffffff;
  }
  html { scroll-behavior: auto; }
  body { font-size: 9.7pt; line-height: 1.4; }
  /* The callback URL becomes a running footer, pinned to the bottom edge
     of every printed page (paged CSS has no "last page only" - a fixed
     element repeats per page, and Chromium clips it to the content area,
     so it cannot sit inside the page margin). The interactive line goes. */
  /* In flow, after the content: what browser printing gets. The canonical
     PDF does better - cv/pdf.py stamps the URL onto the bottom of the
     last page via a qpdf overlay, since paged CSS cannot express "bottom
     of the last page only" (fixed repeats on every page, and Chromium
     clips fixed elements out of the page margins). */
  .toolbar, .colophon-data { display: none; }
  .colophon { padding: 0.5rem 0 0; font-size: 7.5pt; }
  .resume { max-width: none; padding: 0; }
  .masthead { margin-bottom: 1.2rem; }
  .masthead .name { font-size: 22pt; }
  .masthead .contact { margin-top: 0.5rem; }
  .section {
    display: block;
    padding: 0.55rem 0;
    break-inside: auto;
  }
  .section > h2 { margin-bottom: 0.45rem; }
  .timeline > li, .cards > li, .group, .media-item { break-inside: avoid; }
  .media { gap: 0.7rem; width: 11rem; margin: 0.2rem 0 0.5rem 1rem; }
  .media-title a { color: var(--muted); }
  .timeline > li + li { margin-top: 0.7rem; }
  .cards { gap: 0.7rem; }
  .groups { gap: 0.25rem; }
  a { color: inherit; }
  .card-stack, .section > h2 { color: var(--accent); }
}
