/* One reading column hung on a left spine. The spine is the page's one motion: as the reader
   scrolls, its fill follows and its nodes (sections and positions) tick from pending to done.
   Only the spine moves: text is never hidden, dimmed or delayed, and with no script or with
   reduced motion the page stands in its finished state. On a phone the spine is a thin rail in
   the side padding, so it costs the text column no width (design.md, Screens). */

:root {
  color-scheme: light dark;

  --bg: #f7f8f9;
  --surface: #ffffff;
  --fg: #14171a;
  --muted: #50575f;
  --line: #d9dde1;
  --line-strong: #7d858d;
  --accent: #0b7a4b;
  --link: #0b6b42;
  --code-bg: #eceef1;
  --focus: #14171a;

  --font-display: "Avenir Next", Avenir, "Segoe UI Variable Display", "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --t-xs: 0.8125rem;
  --t-sm: 0.875rem;
  --t-base: 1.0625rem;
  --t-lead: 1.125rem;
  --t-h3: 1.25rem;
  --t-h2: clamp(1.625rem, 1.2rem + 1.4vw, 2.125rem);
  --t-h1: clamp(2.5rem, 1.6rem + 3.6vw, 4.25rem);

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;

  --dur: 250ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.55, 0, 1, 0.45);

  /* Phone: the column takes the full width, the spine sits in the side padding */
  --pad: 16px;
  --gutter: 0px;
  --spine-x: calc(var(--pad) / -2);
  --col: 50rem;
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1113;
    --surface: #16191c;
    --fg: #e9ecef;
    --muted: #a3abb4;
    --line: #2a2f35;
    --line-strong: #6b737c;
    --accent: #3fd18f;
    --link: #5fdca3;
    --code-bg: #1d2125;
    --focus: #e9ecef;
  }
}

@media (min-width: 768px) {
  :root {
    --t-lead: 1.25rem;
    --pad: 32px;
    --gutter: 56px;
    --spine-x: calc(var(--gutter) / -2);
  }
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  padding: 0 var(--pad);
  background: var(--bg);
  color: var(--fg);
  font: 400 var(--t-base)/1.6 var(--font-body);
  overflow-wrap: break-word;
}
p { margin: 0; }
p, li, dd { text-wrap: pretty; }
.nowrap { white-space: nowrap; }
a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: var(--line-strong);
}
/* Links in the text read as ordinary links: underlined, in the link colour */
main a, .colophon a { color: var(--link); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 2px; }
code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.1em 0.3em;
  border-radius: 4px;
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--s4);
  top: var(--s4);
  z-index: 10;
  padding: var(--s2) var(--s4);
  background: var(--fg);
  color: var(--bg);
  border-radius: var(--radius);
  text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

/* One column; on wide screens the gutter on its left holds the spine */
.masthead, main, .colophon {
  max-width: var(--col);
  margin-inline: auto;
  padding-left: var(--gutter);
}

/* Header */
.masthead { padding-top: var(--s6); padding-bottom: var(--s5); }
h1 {
  margin: 0;
  font: 600 var(--t-h1)/1.04 var(--font-display);
  letter-spacing: -0.025em;
}
.role {
  margin-top: var(--s2);
  font-size: var(--t-lead);
  line-height: 1.4;
}
.contacts { margin-top: var(--s4); font-style: normal; }
.contacts-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}
.contacts-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  font: 500 var(--t-sm)/1 var(--font-mono);
  letter-spacing: 0.01em;
  text-decoration: none;
}
@media (max-width: 380px) {
  .contacts-links a { padding: 0 var(--s2); }
}
.contacts-links a[href$=".pdf"] {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
}

@media (min-width: 768px) {
  .masthead { padding-top: var(--s8); padding-bottom: var(--s7); }
  .role { margin-top: var(--s4); }
  .contacts { margin-top: var(--s6); }
  .contacts-links a { padding: 0 var(--s3); }
}

/* The spine: a track, and the fill scaled by --run (set by the script; full without it) */
main { position: relative; padding-bottom: var(--s8); }
main::before, main::after {
  content: "";
  position: absolute;
  z-index: 0;
  top: 0;
  bottom: 0;
  left: calc(var(--gutter) + var(--spine-x) - 1px);
  width: 2px;
  border-radius: 1px;
}
main::before { background: var(--line); }
main::after {
  background: var(--accent);
  transform-origin: 50% 0;
  transform: scaleY(var(--run, 1));
}

/* Nodes on the spine: sections (diamond) and positions */
main h2, .position { position: relative; }
main h2 { --node: 10px; --node-y: 0.575em; }
.position { --node: 8px; --node-y: 0.8em; }
@media (min-width: 768px) {
  main h2 { --node: 14px; }
  .position { --node: 10px; }
}
:is(main h2, .position)::before {
  content: "";
  position: absolute;
  z-index: 1;
  left: calc(var(--spine-x) - var(--node) / 2);
  top: calc(var(--node-y) - var(--node) / 2);
  width: var(--node);
  height: var(--node);
  border: 2px solid var(--fg);
  border-radius: 50%;
  background: var(--fg);
}
main h2::before { border-radius: 2px; rotate: 45deg; }

/* Pending: only while the script runs, and only the node itself — never the text beside it */
.spine-run :is(main h2, .position):not(.is-passed)::before {
  border-color: var(--line-strong);
  background: var(--bg);
  transform: scale(0.75);
}

/* Intro: who, what, and the two outcomes, all on the first phone screen */
.intro .lede { max-width: 36em; font-size: var(--t-lead); line-height: 1.55; }
.intro .open {
  position: relative;
  margin-top: var(--s4);
  padding-left: 18px;
  font: 500 var(--t-sm)/1.5 var(--font-mono);
}
.intro .open::before {
  content: "";
  position: absolute;
  left: 0;
  top: calc(0.75em - 4px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.outcomes, .practices, .notes {
  list-style: none;
  margin: var(--s4) 0 0;
  padding: 0;
  display: grid;
  gap: var(--s2);
  max-width: 65ch;
}
:is(.outcomes, .practices, .notes) > li { position: relative; padding-left: 18px; }
:is(.outcomes, .practices, .notes) > li::before {
  content: "";
  position: absolute;
  left: 0;
  top: calc(0.75em - 1px);
  width: 10px;
  height: 2px;
  background: var(--fg);
}
.outcomes > li { font-weight: 500; }

/* Sections */
main > section + section { margin-top: var(--s8); }
main h2 {
  margin: 0 0 var(--s5);
  font: 600 var(--t-h2)/1.15 var(--font-display);
  letter-spacing: -0.015em;
}

/* Projects */
.project {
  padding: var(--s5);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.project + .project { margin-top: var(--s4); }
.project h3 {
  margin: 0 0 var(--s3);
  font: 600 1.375rem/1.2 var(--font-display);
  letter-spacing: -0.01em;
}
.project h3 a { display: inline-flex; align-items: center; min-height: 44px; }
.project p { max-width: 65ch; font-size: 1rem; }
.project p + p, .project .practices + p { margin-top: var(--s3); }
.project .practices { margin-block: var(--s3) 0; font-size: 1rem; }
.project .project-meta {
  margin-top: var(--s4);
  color: var(--muted);
  font: 500 var(--t-sm)/1.5 var(--font-mono);
}
.projects-note { margin-top: var(--s5); max-width: 65ch; color: var(--muted); }

/* The harness case: short prose, real subheadings, three small lists, all in 16px body type. On a
   phone it stays within a screen and a half (1266 px at 390 and 375, cv-page «The case fits a
   screen and a half»); the D7 copy is sized for that. */
.case { font-size: 1rem; line-height: 1.5; }
.case > p { max-width: 65ch; }
.case > p + p { margin-top: var(--s3); }
.case h3 {
  margin: var(--s5) 0 0;
  font: 600 var(--t-h3)/1.3 var(--font-display);
  letter-spacing: -0.005em;
}
.case h3 + p, .case .notes { margin-top: var(--s2); }
.case .notes strong { font-weight: 600; }
.case .asof { margin-top: var(--s4); color: var(--muted); }

/* Experience */
.experience-lead { max-width: 65ch; margin-bottom: var(--s6); }
.org + .org { margin-top: var(--s7); }
.org h3 {
  margin: 0 0 var(--s4);
  font: 600 var(--t-h3)/1.3 var(--font-display);
  letter-spacing: -0.005em;
}
.position + .position { margin-top: var(--s5); }
.position h4 { margin: 0; font: 600 var(--t-base)/1.5 var(--font-body); }
.position .when { color: var(--muted); font: 500 var(--t-sm)/1.5 var(--font-mono); }
.position ul { margin: var(--s2) 0 0; padding-left: 1.1em; max-width: 65ch; }
.position li + li { margin-top: var(--s1); }

/* Skills */
.skill-groups { margin: 0; display: grid; gap: var(--s4); }
.skill-groups > div { display: grid; gap: var(--s1); }
.skill-groups dt { font: 600 var(--t-sm)/1.6 var(--font-mono); letter-spacing: 0.01em; }
.skill-groups dd { margin: 0; max-width: 65ch; }
@media (min-width: 768px) {
  .skill-groups { gap: 0; }
  .skill-groups > div {
    grid-template-columns: 10rem 1fr;
    gap: var(--s4);
    padding: var(--s3) 0;
    border-top: 1px solid var(--line);
  }
  .skill-groups dt { padding-top: 2px; }
}

/* Education and languages */
.degrees { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.degree { display: block; font-weight: 600; }
.degree-where { display: block; color: var(--muted); }
.languages { margin-top: var(--s5); }

/* Footer */
.colophon { padding-top: var(--s5); padding-bottom: var(--s8); }
.colophon ul {
  list-style: none;
  margin: 0;
  padding: var(--s4) 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--s5);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font: 500 var(--t-sm)/1.5 var(--font-mono);
}
.colophon li { min-height: 44px; display: flex; align-items: center; }
.colophon a { display: inline-flex; align-items: center; min-height: 44px; }

/* Hover, for pointers only: colour feedback, never movement */
@media (hover: hover) {
  a:hover { text-decoration-color: currentColor; text-decoration-thickness: 2px; }
  .contacts-links a:hover { border-color: var(--fg); }
}

/* The one motion, only when the reader has not asked for less: hover and focus change at once */
@media (prefers-reduced-motion: no-preference) {
  /* The spine: nodes tick to done on the way down (enter), back to pending on the way up (exit) */
  :is(main h2, .position)::before {
    transition:
      transform var(--dur) var(--ease-out),
      background-color var(--dur) var(--ease-out),
      border-color var(--dur) var(--ease-out);
  }
  .spine-run :is(main h2, .position):not(.is-passed)::before {
    transition-duration: 160ms;
    transition-timing-function: var(--ease-in);
  }

  /* Classes the script sets before the first frame do not animate */
  .spine-still *, .spine-still *::before, .spine-still *::after { transition: none !important; }
}
