/* ============================================================
   CareerPigeon Blog — styles
   Built on the landing-page palette: cream paper, ink, one
   blue-indigo accent, hairline rules, plain functional labels.
   Light + dark themes keyed off html[data-theme].
   ============================================================ */

:root,
html[data-theme="light"] {
  color-scheme: light;

  --indigo:      #2057D0;
  --indigo-deep: #183DA6;
  --indigo-mid:  #5A93EC;
  --indigo-soft: #90C0F8;

  --page:         #FAF6F0;
  --page-2:       #F4EFE6;
  --surface:      #FFFFFF;
  --surface-soft: #FBF8F2;
  --surface-sunk: #F1ECE2;

  --ink:    #1A1B2E;
  --ink-2:  #2B2D45;
  --muted:  #5D6072;
  --faint:  #676C80;

  --hair:          rgba(26, 27, 46, 0.07);
  --hair-2:        rgba(26, 27, 46, 0.11);
  --hair-3:        rgba(26, 27, 46, 0.18);
  --hair-indigo:   rgba(32, 87, 208, 0.18);
  --hair-indigo-2: rgba(32, 87, 208, 0.32);
  --grid-line:     rgba(26, 27, 46, 0.04);

  --tint:   #E9F1FD;
  --tint-2: #D1E2FB;

  --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 1px 2px rgba(26, 27, 46, 0.04);
  --shadow-2: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 2px 6px rgba(26, 27, 46, 0.05),
    0 10px 24px -12px rgba(26, 27, 46, 0.1);
  --shadow-lift: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 4px 10px rgba(26, 27, 46, 0.06),
    0 22px 50px -22px rgba(26, 27, 46, 0.16);

  --nav-bg:        rgba(247, 247, 251, 0.42);
  --nav-bg-scroll: rgba(247, 247, 251, 0.72);
  --nav-line:      rgba(10, 15, 40, 0.06);

  --ease:     cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --display: "Outfit", system-ui, sans-serif;
  --body:    "Inter", system-ui, sans-serif;
  --mono:    "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;

  --nav-h: 64px;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --indigo:      #5189FF;
  --indigo-deep: #2D63D6;
  --indigo-mid:  #82B5FF;
  --indigo-soft: #A4C8FF;

  --page:         #020612;
  --page-2:       #051428;
  --surface:      #0A1A30;
  --surface-soft: #0E2138;
  --surface-sunk: #081528;

  --ink:    #ECEDF6;
  --ink-2:  #D4D6E6;
  --muted:  #B0B8CC;
  --faint:  #828798;

  --hair:          rgba(255, 255, 255, 0.07);
  --hair-2:        rgba(255, 255, 255, 0.11);
  --hair-3:        rgba(255, 255, 255, 0.2);
  --hair-indigo:   rgba(81, 137, 255, 0.32);
  --hair-indigo-2: rgba(81, 137, 255, 0.55);
  --grid-line:     rgba(255, 255, 255, 0.04);

  --tint:   rgba(81, 137, 255, 0.1);
  --tint-2: rgba(81, 137, 255, 0.18);

  --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 2px 6px rgba(0, 0, 0, 0.45),
    0 12px 28px -14px rgba(0, 0, 0, 0.6);
  --shadow-lift: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 4px 10px rgba(0, 0, 0, 0.5),
    0 22px 50px -22px rgba(0, 0, 0, 0.7);

  --nav-bg:        rgba(255, 255, 255, 0.04);
  --nav-bg-scroll: rgba(255, 255, 255, 0.08);
  --nav-line:      rgba(255, 255, 255, 0.1);
}

/* ---------- Base ---------- */

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--page);
  padding-top: var(--nav-h);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main {
  flex: 1;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
}

::selection {
  background: var(--tint-2);
  color: var(--ink);
}

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

/* Anchor targets must clear the fixed glass nav */
:target,
.article-body h2,
.article-body h3 {
  scroll-margin-top: calc(var(--nav-h) + 28px);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.wrap {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -64px;
  z-index: 100;
  background: var(--ink);
  color: var(--page);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
}

.skip-link:focus {
  top: 12px;
}

/* ---------- Type utilities ---------- */

.deck {
  margin: 0;
  font-size: 18px;
  line-height: 1.6;
  color: var(--muted);
  max-width: 660px;
  text-wrap: pretty;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  font-family: var(--body);
  font-size: 13.5px;
  font-weight: 550;
  letter-spacing: -0.006em;
  color: var(--ink);
  transition: transform 0.18s var(--ease), background 0.18s var(--ease), border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease);
}

.btn .arr {
  transition: transform 0.2s var(--ease);
  display: inline-flex;
}

.btn:hover .arr {
  transform: translateX(3px);
}

.btn-primary {
  background: var(--indigo);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 2px 8px -2px rgba(32, 87, 208, 0.45);
}

.btn-primary:hover {
  background: var(--indigo-deep);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

html[data-theme="dark"] .btn-primary {
  color: #06122b;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.28) inset, 0 2px 10px -2px rgba(81, 137, 255, 0.5);
}

.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--hair-2);
  box-shadow: var(--shadow-1);
}

.btn-ghost:hover {
  border-color: var(--hair-3);
  transform: translateY(-1px);
}

.btn-quiet {
  color: var(--ink-2);
}

.btn-quiet:hover {
  background: rgba(81, 137, 255, 0.07);
}

/* ---------- Glass nav ---------- */

.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  border-bottom: 1px solid transparent;
  transition: background 0.4s var(--ease), border-color 0.4s var(--ease);
}

.site-nav.scrolled {
  background: var(--nav-bg-scroll);
  border-bottom-color: var(--nav-line);
}

.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--nav-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.018em;
  color: var(--ink);
  white-space: nowrap;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
}

.brand .brand-suffix {
  font-weight: 400;
  color: var(--muted);
  margin-left: -3px;
}

.nav-links {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-right: auto;
  margin-left: 18px;
}

.nav-links a {
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  padding: 7px 11px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}

.nav-links a:hover {
  color: var(--ink);
  background: rgba(81, 137, 255, 0.07);
}

.nav-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

/* Theme toggle — glass pill, two buttons, sliding thumb */

.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--hair-2);
  background: var(--surface-soft);
}

html[data-theme="dark"] .theme-toggle {
  background: rgba(255, 255, 255, 0.05);
}

.theme-toggle .thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--hair-2);
  box-shadow: var(--shadow-1);
  transition: transform 0.25s var(--ease);
}

html[data-theme="dark"] .theme-toggle .thumb {
  transform: translateX(26px);
  background: var(--surface-soft);
}

.theme-toggle button {
  position: relative;
  z-index: 1;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: var(--faint);
  transition: color 0.2s;
}

.theme-toggle button.active {
  color: var(--ink);
}

.theme-toggle svg {
  width: 14px;
  height: 14px;
}

/* ---------- Reading progress (post pages) ---------- */

.progress {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  right: 0;
  height: 2px;
  z-index: 49;
  pointer-events: none;
}

.progress b {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--indigo-mid), var(--indigo));
  transition: width 0.08s linear;
}

/* ---------- Masthead (index + category + trust heroes) ---------- */

.masthead {
  position: relative;
  padding: 72px 0 44px;
}

.masthead::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 56px 56px;
  background-repeat: repeat;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 82%);
  mask-image: linear-gradient(180deg, #000 0%, transparent 82%);
  pointer-events: none;
}

.masthead > .wrap {
  position: relative;
}

.masthead h1 {
  margin: 18px 0 18px;
  font-family: var(--display);
  font-weight: 650;
  font-size: clamp(38px, 6.4vw, 72px);
  line-height: 1.02;
  letter-spacing: -0.032em;
  color: var(--ink);
  max-width: 900px;
}

.masthead .deck {
  font-size: clamp(16.5px, 2vw, 19px);
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 22px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.breadcrumbs a {
  color: var(--muted);
  transition: color 0.15s;
}

.breadcrumbs a:hover {
  color: var(--indigo);
}

.breadcrumbs .sep {
  color: var(--hair-3);
}

/* Broadsheet double rule under mastheads */

.rule-double {
  border: 0;
  margin: 0;
  height: 5px;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  opacity: 0.85;
}

html[data-theme="dark"] .rule-double {
  opacity: 0.6;
}

/* ---------- Section labels ---------- */

.chapter {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 0 0 26px;
}

.chapter h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 620;
  font-size: 24px;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.chapter .line {
  flex: 1;
  height: 1px;
  background: var(--hair-2);
  align-self: center;
}

.section {
  padding: 52px 0 8px;
}

/* ---------- Lead story ---------- */

.lead-story {
  position: relative;
  display: block;
  background: var(--surface);
  border: 1px solid var(--hair-2);
  border-radius: 18px;
  padding: clamp(28px, 4.5vw, 52px);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
}

.lead-story::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--indigo) 0%, var(--indigo-mid) 60%, transparent 100%);
  background-repeat: no-repeat;
}

.lead-story:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
  border-color: var(--hair-indigo);
}

.lead-story .tag-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.lead-story h3 {
  margin: 0 0 14px;
  font-family: var(--display);
  font-weight: 640;
  font-size: clamp(26px, 3.6vw, 40px);
  line-height: 1.12;
  letter-spacing: -0.026em;
  color: var(--ink);
  max-width: 820px;
  transition: color 0.2s;
}

.lead-story:hover h3 {
  color: var(--indigo-deep);
}

html[data-theme="dark"] .lead-story:hover h3 {
  color: var(--indigo-mid);
}

.lead-story p {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 16.5px;
  line-height: 1.65;
  max-width: 720px;
}

.lead-story .foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.read-cue {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 550;
  font-size: 14px;
  color: var(--indigo);
}

.read-cue .arr {
  transition: transform 0.2s var(--ease);
}

.lead-story:hover .read-cue .arr {
  transform: translateX(3px);
}

/* ---------- Tags / badges / meta ---------- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--indigo-deep);
  background: var(--tint);
  border: 1px solid var(--hair-indigo);
  border-radius: 999px;
  padding: 5px 11px;
}

html[data-theme="dark"] .tag {
  color: var(--indigo-mid);
}

.tag-draft {
  color: #8a5a00;
  background: rgba(245, 166, 35, 0.14);
  border-color: rgba(245, 166, 35, 0.35);
}

html[data-theme="dark"] .tag-draft {
  color: #ffc866;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.05em;
  color: var(--faint);
}

.meta .dot::before {
  content: "·";
  color: var(--hair-3);
}

/* ---------- Desks (categories) ---------- */

.desk-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.desk {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--hair-2);
  border-radius: 14px;
  padding: 26px 24px 22px;
  box-shadow: var(--shadow-1);
  transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease), border-color 0.22s var(--ease);
}

.desk:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-2);
  border-color: var(--hair-indigo);
}

.desk h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 630;
  font-size: 21px;
  letter-spacing: -0.02em;
  color: var(--ink);
  transition: color 0.2s;
}

.desk:hover h3 {
  color: var(--indigo-deep);
}

html[data-theme="dark"] .desk:hover h3 {
  color: var(--indigo-mid);
}

.desk p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--muted);
  flex: 1;
}

.desk .count {
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--hair);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}

.desk .count .arr {
  color: var(--indigo);
  transition: transform 0.2s var(--ease);
}

.desk:hover .count .arr {
  transform: translateX(3px);
}

/* ---------- Guide index rows ---------- */

.index-list {
  border-top: 1px solid var(--hair-2);
}

.index-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: baseline;
  padding: 26px 8px;
  border-bottom: 1px solid var(--hair-2);
  transition: background 0.2s var(--ease);
}

.index-row:hover {
  background: var(--surface-soft);
}

html[data-theme="dark"] .index-row:hover {
  background: var(--surface-sunk);
}

.index-row h3 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-weight: 620;
  font-size: clamp(19px, 2.4vw, 24px);
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--ink);
  transition: color 0.18s;
}

.index-row:hover h3 {
  color: var(--indigo-deep);
}

html[data-theme="dark"] .index-row:hover h3 {
  color: var(--indigo-mid);
}

.index-row .desc {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--muted);
  max-width: 640px;
}

.index-row .side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  text-align: right;
}

.index-row .side .meta {
  justify-content: flex-end;
}

/* ---------- Empty state ---------- */

.empty {
  border: 1px dashed var(--hair-3);
  border-radius: 14px;
  padding: 44px 24px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-soft);
}

.empty .msg {
  margin: 0;
  font-size: 15.5px;
  color: var(--muted);
}

/* ---------- Post page ---------- */

.post-hero {
  position: relative;
  padding: 64px 0 0;
}

.post-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 56px 56px;
  background-repeat: repeat;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 88%);
  mask-image: linear-gradient(180deg, #000 0%, transparent 88%);
  pointer-events: none;
}

.post-hero > .wrap {
  position: relative;
  max-width: 880px;
}

.post-hero h1 {
  margin: 16px 0 18px;
  font-family: var(--display);
  font-weight: 650;
  font-size: clamp(32px, 5vw, 54px);
  line-height: 1.06;
  letter-spacing: -0.028em;
  color: var(--ink);
}

.post-hero .lede {
  margin: 0 0 34px;
  font-size: clamp(17px, 2.2vw, 20px);
  line-height: 1.6;
  color: var(--muted);
  max-width: 720px;
}

.post-hero .tag-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* Byline — single ruled row, NYT-style */

.byline {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 22px;
  padding: 14px 0;
  border-top: 1px solid var(--hair-2);
  border-bottom: 1px solid var(--hair-2);
}

.byline .who {
  font-size: 14px;
  font-weight: 550;
  color: var(--ink);
}

.byline .who a {
  color: inherit;
  border-bottom: 1px solid var(--hair-3);
  transition: color 0.15s, border-color 0.15s;
}

.byline .who a:hover {
  color: var(--indigo);
  border-color: var(--hair-indigo-2);
}

.byline .meta {
  font-family: var(--body);
  font-size: 13px;
  letter-spacing: 0;
  color: var(--muted);
}

/* Article shell: centered measure + sticky rail */

.post-shell {
  display: grid;
  grid-template-columns: minmax(0, 720px) 240px;
  justify-content: center;
  gap: 72px;
  padding: 56px 0 40px;
}

/* Key takeaways */

.takeaways {
  margin: 0 0 40px;
  background: var(--surface-sunk);
  border: 1px solid var(--hair-2);
  border-radius: 14px;
  padding: 22px 26px 20px;
}

.takeaways .lbl {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--indigo-deep);
}

html[data-theme="dark"] .takeaways .lbl {
  color: var(--indigo-mid);
}

.takeaways .lbl::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--hair-2);
}

.takeaways ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.takeaways li {
  position: relative;
  padding: 5px 0 5px 26px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-2);
}

.takeaways li::before {
  content: "→";
  position: absolute;
  left: 2px;
  color: var(--indigo);
  font-weight: 600;
}

/* Long-form body */

.article-body {
  font-size: 17px;
  line-height: 1.78;
  color: var(--ink-2);
}

.article-body p {
  margin: 0 0 1.35em;
}

.article-body a {
  color: var(--indigo);
  text-decoration: underline;
  text-decoration-color: var(--hair-indigo-2);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: text-decoration-color 0.15s;
}

.article-body a:hover {
  text-decoration-color: var(--indigo);
}

.article-body h2 {
  margin: 2.4em 0 0.8em;
  padding-top: 1.4em;
  border-top: 1px solid var(--hair-2);
  font-family: var(--display);
  font-weight: 630;
  font-size: clamp(23px, 2.8vw, 28px);
  line-height: 1.22;
  letter-spacing: -0.022em;
  color: var(--ink);
}

.article-body h3 {
  margin: 2em 0 0.6em;
  font-family: var(--display);
  font-weight: 620;
  font-size: 20px;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.article-body ul,
.article-body ol {
  margin: 0 0 1.35em;
  padding-left: 1.35em;
}

.article-body li {
  margin: 0.45em 0;
}

.article-body li::marker {
  color: var(--indigo);
}

.article-body blockquote {
  margin: 2em 0;
  padding: 0.3em 0 0.3em 1.4em;
  border-left: 2px solid var(--indigo-mid);
  color: var(--muted);
}

.article-body blockquote p {
  margin: 0 0 0.6em;
}

.article-body blockquote p:last-child {
  margin-bottom: 0;
}

.article-body code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--surface-sunk);
  border: 1px solid var(--hair);
  border-radius: 6px;
  padding: 0.12em 0.4em;
}

.article-body pre {
  background: var(--surface-sunk);
  border: 1px solid var(--hair-2);
  border-radius: 12px;
  padding: 18px 20px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.6;
}

.article-body pre code {
  background: none;
  border: 0;
  padding: 0;
}

.article-body hr {
  border: 0;
  margin: 2.6em 0;
  text-align: center;
  height: auto;
}

.article-body hr::after {
  content: "· · ·";
  font-family: var(--mono);
  letter-spacing: 0.6em;
  color: var(--faint);
}

.article-body table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 2em 0;
  font-size: 14.5px;
}

.article-body th {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: left;
  color: var(--muted);
  border-bottom: 2px solid var(--hair-3);
  padding: 10px 18px 10px 0;
}

.article-body td {
  border-bottom: 1px solid var(--hair-2);
  padding: 11px 18px 11px 0;
  vertical-align: top;
}

.article-body img {
  border: 1px solid var(--hair-2);
  border-radius: 12px;
  margin: 2em 0;
}

.article-body strong {
  color: var(--ink);
  font-weight: 620;
}

/* ---------- Rail (TOC) ---------- */

.rail {
  position: sticky;
  top: calc(var(--nav-h) + 36px);
  align-self: start;
  max-height: calc(100vh - var(--nav-h) - 72px);
  overflow-y: auto;
  padding-bottom: 8px;
}

.rail .lbl {
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
}

.toc {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--hair-2);
}

.toc li a {
  display: block;
  padding: 6px 0 6px 16px;
  margin-left: -1px;
  border-left: 1px solid transparent;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  transition: color 0.15s, border-color 0.15s;
}

.toc li.depth-3 a {
  padding-left: 30px;
  font-size: 12.5px;
  color: var(--faint);
}

.toc li a:hover {
  color: var(--ink);
}

.toc li a.active {
  color: var(--indigo);
  border-left-color: var(--indigo);
  font-weight: 550;
}

.rail .top-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  transition: color 0.15s;
}

.rail .top-link:hover {
  color: var(--indigo);
}

/* ---------- Post endmatter ---------- */

.endmatter {
  max-width: 880px;
  margin: 0 auto;
  padding-bottom: 72px;
}

.endmatter .wrap-inner {
  border-top: 1px solid var(--hair-2);
  padding-top: 40px;
}

.author-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--hair-2);
  border-radius: 14px;
  padding: 22px 26px;
  box-shadow: var(--shadow-1);
}

.author-card .who .lbl {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 4px;
}

.author-card .who .name {
  margin: 0;
  font-family: var(--display);
  font-weight: 620;
  font-size: 18px;
  color: var(--ink);
}

.author-card .who .name a {
  color: inherit;
  transition: color 0.15s;
}

.author-card .who .name a:hover {
  color: var(--indigo);
}

.author-card .fix {
  font-size: 13px;
  color: var(--muted);
  max-width: 380px;
}

.author-card .fix a {
  color: var(--indigo);
  border-bottom: 1px solid var(--hair-indigo-2);
}

.related {
  margin-top: 40px;
}

.related .lbl {
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.related-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--hair-2);
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: var(--shadow-1);
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.related-card:hover {
  transform: translateY(-2px);
  border-color: var(--hair-indigo);
  box-shadow: var(--shadow-2);
}

.related-card .cat {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--indigo);
}

.related-card h4 {
  margin: 0;
  font-family: var(--display);
  font-weight: 620;
  font-size: 16.5px;
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.related-card:hover h4 {
  color: var(--indigo-deep);
}

html[data-theme="dark"] .related-card:hover h4 {
  color: var(--indigo-mid);
}

/* ---------- Trust pages ---------- */

.doc {
  max-width: 660px;
  padding: 48px 0 80px;
}

.doc-section {
  padding: 30px 0;
  border-bottom: 1px solid var(--hair-2);
}

.doc-section:last-of-type {
  border-bottom: 0;
}

.doc-section h2 {
  margin: 0 0 12px;
  font-family: var(--display);
  font-weight: 630;
  font-size: 24px;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.doc-section p {
  margin: 0;
  font-size: 16.5px;
  line-height: 1.75;
  color: var(--ink-2);
}

.doc-more {
  margin-top: 44px;
  padding-top: 26px;
  border-top: 1px solid var(--hair-2);
}

.doc-more .lbl {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 14px;
}

.doc-more ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.doc-more a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--hair-2);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  transition: border-color 0.18s, color 0.18s, transform 0.18s var(--ease);
}

.doc-more a:hover {
  border-color: var(--hair-indigo);
  color: var(--indigo);
  transform: translateY(-1px);
}

/* ---------- 404 ---------- */

.notfound {
  position: relative;
  min-height: calc(100vh - var(--nav-h) - 280px);
  display: flex;
  align-items: center;
  padding: 80px 0;
  overflow: hidden;
}

.notfound .watermark {
  position: absolute;
  right: -2%;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(200px, 34vw, 420px);
  line-height: 1;
  letter-spacing: -0.05em;
  color: var(--ink);
  opacity: 0.045;
  pointer-events: none;
  user-select: none;
}

.notfound h1 {
  margin: 16px 0 14px;
  font-family: var(--display);
  font-weight: 650;
  font-size: clamp(34px, 5.4vw, 60px);
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--ink);
  max-width: 700px;
}

.notfound .deck {
  margin-bottom: 32px;
}

.notfound .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 96px;
  border-top: 1px solid var(--hair-2);
  background: var(--page-2);
}

.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr));
  gap: 40px;
  padding: 52px 0 40px;
}

.footer-brand .brand {
  margin-bottom: 14px;
}

.footer-brand p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--muted);
  max-width: 260px;
}

.footer-col .lbl {
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
}

.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.footer-col a {
  font-size: 13.5px;
  color: var(--muted);
  transition: color 0.15s;
}

.footer-col a:hover {
  color: var(--indigo);
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 0 26px;
  border-top: 1px solid var(--hair);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--faint);
}

.footer-bottom a {
  color: var(--muted);
}

.footer-bottom a:hover {
  color: var(--indigo);
}

/* ---------- Entrance motion ---------- */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.rise {
  animation: rise 0.6s var(--ease-out) both;
}

.rise-1 { animation-delay: 0.05s; }
.rise-2 { animation-delay: 0.12s; }
.rise-3 { animation-delay: 0.2s; }
.rise-4 { animation-delay: 0.28s; }

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 1023px) {
  .post-shell {
    grid-template-columns: minmax(0, 720px);
  }

  .rail {
    display: none;
  }
}

@media (max-width: 860px) {
  .desk-grid {
    grid-template-columns: 1fr;
  }

  .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 32px;
  }

  .index-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .index-row .side {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    text-align: left;
    width: 100%;
  }
}

@media (max-width: 759px) {
  .nav-links {
    display: none;
  }

  .wrap {
    width: calc(100% - 40px);
  }

  .masthead {
    padding: 48px 0 36px;
  }

  .post-hero {
    padding-top: 44px;
  }

  .byline {
    gap: 14px 28px;
  }

  .related-grid {
    grid-template-columns: 1fr;
  }

  .notfound .watermark {
    display: none;
  }
}

@media (max-width: 480px) {
  .nav-actions .btn-quiet {
    display: none;
  }

  .site-nav .brand .brand-suffix {
    display: none;
  }

  .nav-row {
    gap: 10px;
  }

  .footer-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Print ---------- */

@media print {
  .site-nav,
  .site-footer,
  .rail,
  .progress,
  .skip-link {
    display: none !important;
  }

  body {
    padding-top: 0;
    background: #fff;
  }
}

/* ============================================================
   Article figures
   Charts are inline SVG, not raster: the blog has a manual
   light/dark toggle (html[data-theme]), so a baked-in
   background would be wrong in whichever theme it was not
   built for. Mapping the marks onto the theme variables lets
   one figure serve both. Every figure ships a <details> table
   twin, so no value is reachable only by looking at a shape.
   ============================================================ */

.fig {
  --fig-accent:  var(--indigo);
  --fig-muted:   var(--muted);
  --fig-hair:    var(--hair-2);
  --fig-surface: var(--surface);

  margin: 2.4em 0;
  padding: 26px 26px 20px;
  background: var(--surface);
  border: 1px solid var(--hair-2);
  border-radius: 14px;
  box-shadow: var(--shadow-1);
}

.post-hero-figure .fig {
  margin-top: 0;
}

.fig-head {
  margin-bottom: 18px;
}

.fig-title {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: 17px;
  line-height: 1.4;
  color: var(--ink);
}

.fig-svg {
  display: block;
  width: 100%;
  height: auto;
  /* Floor the scale so axis and category labels stay legible on a phone
     (~13px effective) instead of shrinking to fit; the card scrolls instead. */
  min-width: 560px;
  overflow: visible;
}

/* Narrow screens scroll the figure rather than shrinking the
   labels past legibility. */
.fig {
  overflow-x: auto;
}

.fig-cat {
  font-family: var(--body);
  font-size: 17px;
  font-weight: 500;
  fill: var(--ink-2);
}

.fig-val {
  font-family: var(--body);
  font-size: 18px;
  font-weight: 600;
  fill: var(--ink);
}

.fig-note {
  font-family: var(--body);
  font-size: 15px;
  font-weight: 400;
  fill: var(--faint);
}

.fig-step {
  font-family: var(--body);
  font-size: 18px;
  font-weight: 500;
  fill: var(--ink-2);
}

.fig-big {
  font-family: var(--display);
  font-size: 34px;
  font-weight: 700;
  fill: var(--ink);
}

.fig-hero {
  font-family: var(--display);
  font-size: 62px;
  font-weight: 800;
  fill: var(--indigo);
}

.fig-data {
  margin-top: 18px;
  border-top: 1px solid var(--hair);
  padding-top: 12px;
}

.fig-data summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  list-style: none;
}

.fig-data summary::-webkit-details-marker {
  display: none;
}

.fig-data summary::before {
  content: "+ ";
  color: var(--indigo);
}

.fig-data[open] summary::before {
  content: "\2212 ";
}

.fig-table {
  width: 100%;
  margin-top: 14px;
  border-collapse: collapse;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.fig-table th,
.fig-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--hair);
  color: var(--ink-2);
}

.fig-table tr:first-child th {
  font-weight: 600;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.fig-table th[scope="row"] {
  font-weight: 500;
}

.fig-source {
  margin: 14px 0 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--faint);
}

.fig-source a {
  color: var(--faint);
  text-decoration: underline;
  text-decoration-color: var(--hair-3);
  text-underline-offset: 0.2em;
}

.fig-source a:hover {
  color: var(--indigo);
}

/* A provenance chain is a list, not a plot: HTML so the steps wrap and a
   screen reader gets a real ordered list. */
.fig-steps {
  margin: 0;
  padding: 0 0 0 30px;
  list-style: none;
  position: relative;
}

.fig-steps::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 9px;
  bottom: 9px;
  width: 2px;
  background: var(--hair-2);
}

.fig-steps-step {
  position: relative;
  padding-bottom: 22px;
}

.fig-steps-step:last-child {
  padding-bottom: 0;
}

.fig-steps-step::before {
  content: "";
  position: absolute;
  left: -30px;
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--indigo);
  box-shadow: 0 0 0 3px var(--surface);
}

.fig-steps-step:last-child::before {
  background: var(--muted);
}

.fig-steps-when {
  display: block;
  font-size: 14px;
  color: var(--faint);
  margin-bottom: 2px;
}

.fig-steps-what {
  display: block;
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink-2);
}
