:root {
  --bg: #fbf9f5;
  --paper: #fffdf9;
  /* One tint per depth: the line highlight, ribbon and panel of a level share it. */
  --tint-1: #e5eeed;
  --tint-2: #d6e6e4;
  --tint-3: #c8dddb;
  --tint-4: #bad4d1;
  --ink: #1d2327;
  --muted: #5d6870;
  --faint: #8a949b;
  --line: #e4ded3;
  --accent: #1f6f78;
  --accent-ink: #17565d;
  --accent-soft: rgba(31, 111, 120, 0.08);
  --accent-active: rgba(31, 111, 120, 0.16);
  --dur: 680ms;
  --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --top: 60px;
}

@media (prefers-reduced-motion: reduce) {
  :root { --dur: 1ms; }
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }

body.no-anim .track,
body.no-anim .panel,
body.no-anim .ribbon { transition: none !important; }

/* ---------- Top bar ---------- */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--top);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 24px;
  z-index: 10;
}

.brand {
  all: unset;
  cursor: pointer;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
}
.brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }

.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  font-size: 13px;
  color: var(--muted);
}
.crumbs button {
  all: unset;
  cursor: pointer;
  white-space: nowrap;
  padding: 3px 8px;
  border-radius: 999px;
  transition: background 0.2s;
}
.crumbs button:hover { background: rgba(0, 0, 0, 0.05); }
.crumbs button:focus-visible { outline: 2px solid var(--accent); }
.crumbs button[aria-current="page"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.crumbs .sep { color: var(--faint); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.hint { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
kbd {
  font: 11px var(--sans);
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--paper);
}

/* ---------- Stage / track / panels ---------- */

.stage {
  position: fixed;
  z-index: 1;
  inset: var(--top) 0 18px 0;
  overflow: hidden;
}

.track {
  position: absolute;
  inset: 0 auto 0 0;
  transition: transform var(--dur) var(--ease);
  will-change: transform;
}

.panel {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  transition:
    transform var(--dur) var(--ease),
    opacity 0.45s ease,
    left var(--dur) var(--ease),
    width var(--dur) var(--ease);
}
.panel.is-entering,
.panel.is-leaving { opacity: 0; transform: translateX(64px); }
.panel.is-leaving { pointer-events: none; }
.panel.is-faded { opacity: 0.5; cursor: pointer; }
.panel.is-faded:hover { opacity: 0.75; }


.panel-scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 44px 52px 56px;
  scrollbar-width: thin;
  scrollbar-color: rgba(23, 86, 93, 0.22) transparent;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px 0 40px;
}
.back {
  all: unset;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  padding: 4px 10px;
  margin-left: -10px;
  border-radius: 999px;
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.back:hover { background: var(--accent-soft); color: var(--accent-ink); }
.back:focus-visible { outline: 2px solid var(--accent); }
.panel--detail .panel-scroll { padding: 18px 40px 56px; }

/* ---------- Ribbons ---------- */

.ribbons {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}
.ribbon { transition: opacity 0.25s; }
.ribbon--intro { animation: ribbon-in 0.45s ease both; }
.ribbon.is-leaving { opacity: 0; }
@keyframes ribbon-in { from { opacity: 0; } }

/* ---------- Justified body text ---------- */
/* Running text is set square; headings and short labels stay ragged. */
.cv-summary, .cv-desc, .cv-tags dd,
.node:not(.node--heading) .node-body,
.d-lede, .d-section p, .d-section li {
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}

/* ---------- Clickable nodes ---------- */

.node {
  all: unset;
  box-sizing: border-box;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: calc(100% + 16px);
  margin: 0 -8px;
  padding: 3px 8px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.2s;
}
button.node:hover { background: var(--accent-soft); }
button.node:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* The active line's highlight is drawn by its ribbon, in the next level's tint. */
button.node.is-active { background: transparent; }
.node--static { cursor: default; }

.node-body { flex: 1; min-width: 0; }
button.node .node-text {
  text-decoration: underline;
  text-decoration-color: rgba(31, 111, 120, 0.28);
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}
button.node:hover .node-text,
button.node.is-active .node-text { text-decoration-color: var(--accent); }

.node-teaser { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }

.dot {
  flex: none;
  width: 5px;
  height: 5px;
  margin-top: 0.62em;
  border-radius: 50%;
  background: var(--faint);
}
button.node .dot { background: var(--accent); }

.cue {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 0.15em;
  color: var(--accent);
  opacity: 0.35;
  transform: translateX(-3px);
  transition: opacity 0.2s, transform 0.2s;
}
button.node:hover .cue,
button.node.is-active .cue,
button.node:focus-visible .cue { opacity: 1; transform: none; }
.cue-count {
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 999px;
  background: var(--accent-soft);
}

/* ---------- CV (root panel) ---------- */

.cv-head { border-bottom: 1px solid var(--line); padding-bottom: 18px; margin-bottom: 18px; }
.cv-head h1 { font: 600 32px/1.15 var(--serif); margin: 0; letter-spacing: -0.01em; outline: none; }
.cv-title { margin: 4px 0 10px; color: var(--muted); font-size: 16px; }
.cv-contact { display: flex; flex-wrap: wrap; gap: 4px 18px; list-style: none; padding: 0; margin: 0; font-size: 13px; color: var(--muted); }
.cv-contact a { color: var(--accent-ink); text-decoration: none; }
.cv-contact a:hover { text-decoration: underline; }
.cv-summary { margin: 0 0 8px; }
.cv-summary p { margin: 0 0 8px; }

.cv-section { margin-top: 40px; }
.cv-section > h2 {
  font: 600 20px/1.2 var(--serif);
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0 0 12px;
}

.cv-entry + .cv-entry { margin-top: 22px; }
.cv-role { font-size: 15.5px; font-weight: 650; margin: 0; }
.cv-role .node { font-weight: inherit; align-items: baseline; }
.cv-role .cue { align-self: center; margin-top: 0; }
.cv-dates { font-size: 12.5px; font-weight: 400; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cv-org { color: var(--muted); font-size: 13.5px; margin: 1px 0 6px; }
.cv-points { list-style: none; padding: 0; margin: 0; }
.cv-desc { font-style: italic; color: var(--muted); font-size: 14px; margin: 2px 0 8px; }
.cv-desc p { margin: 0 0 6px; }
.cv-group { margin-top: 12px; }
.cv-group-title { font-size: 14.5px; font-weight: 600; margin: 0 0 4px; color: var(--ink); }
.cv-points li + li { margin-top: 1px; }

.cv-tags { margin: 0; display: grid; gap: 6px; }
.cv-tags div { display: grid; grid-template-columns: 150px 1fr; gap: 12px; }
.cv-tags dt { font-weight: 600; font-size: 13.5px; }
.cv-tags dd { margin: 0; color: var(--muted); font-size: 13.5px; }

/* ---------- Detail panels ---------- */

.d-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-ink);
}
.d-title { font: 600 26px/1.2 var(--serif); margin: 6px 0 10px; outline: none; letter-spacing: -0.01em; }
.d-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; padding: 0; list-style: none; }
.d-meta li { font-size: 12.5px; color: var(--muted); background: rgba(255, 255, 255, 0.6); border-radius: 999px; padding: 2px 10px; }
.d-lede { font-size: 16px; line-height: 1.6; margin: 0 0 20px; }
.d-lede p { margin: 0 0 10px; }

.d-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 0 0 22px; }
.d-metric { background: rgba(255, 255, 255, 0.45); border: 1px solid rgba(23, 86, 93, 0.12); border-radius: 10px; padding: 12px 14px; }
.d-metric b { display: block; font: 600 24px/1.1 var(--serif); color: var(--accent-ink); }
.d-metric span { font-size: 12.5px; color: var(--muted); }

.d-section { margin: 0 0 18px; }
.d-section h3 { font-size: 13px; font-weight: 700; margin: 0 0 6px; letter-spacing: 0.02em; }
.d-section p { margin: 0 0 8px; }
.d-section ul, .d-section ol { margin: 0 0 8px; padding-left: 20px; }
.d-section li { margin: 3px 0; }
.d-section li > ul, .d-section li > ol { margin: 3px 0 0; }
.d-section h4 { font-size: 13.5px; margin: 12px 0 4px; }
.d-section blockquote { margin: 8px 0; padding: 2px 0 2px 14px; border-left: 3px solid rgba(23, 86, 93, 0.3); color: var(--muted); }
.d-section a, .d-lede a { color: var(--accent-ink); }
code { font: 0.9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: rgba(255, 255, 255, 0.55); padding: 1px 4px; border-radius: 4px; }

.load-error { max-width: 560px; margin: 12vh auto; padding: 0 24px; }
.load-error h1 { font: 600 24px var(--serif); margin: 0 0 8px; }

.d-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 22px; padding: 0; list-style: none; }
.d-tags li { font-size: 12px; border: 1px solid rgba(23, 86, 93, 0.18); border-radius: 6px; padding: 2px 8px; color: var(--muted); }

.d-points { border-top: 1px solid rgba(23, 86, 93, 0.14); padding-top: 16px; margin-top: 8px; }
.d-points h3 { font-size: 11.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-ink); margin: 0 0 8px; }
.d-points ul { list-style: none; margin: 0; padding: 0; }
.d-points li + li { margin-top: 4px; }
.d-points .node { padding-top: 6px; padding-bottom: 6px; }

/* ---------- Small screens: one panel at a time ---------- */

@media (max-width: 899px) {
  :root { --top: 52px; }
  .topbar { padding: 0 12px; gap: 10px; }
  .brand { display: none; }
  .hint { display: none; }
  .ribbons { display: none; }
  .panel--detail { background: var(--tint); border-radius: 14px; }
  .panel-scroll { padding: 28px 22px 44px; }
  .panel--detail .panel-scroll { padding: 14px 22px 44px; }
  .panel-head { padding: 12px 16px 0 22px; }
  .cv-tags div { grid-template-columns: 1fr; gap: 0; }
  .cv-role .node { flex-wrap: wrap; }
}
