/* ============================================================
   The World Bank — A Documentary History
   Archival-editorial design language. Light + dark.
   ============================================================ */

:root {
  /* Type */
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, "Times New Roman", serif;
  --sans:  ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono:  ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  /* Archival paper palette (light) */
  --paper:      #f6f2e9;
  --paper-2:    #efe9db;
  --card:       #fffdf8;
  --ink:        #20242c;
  --ink-soft:   #4c4a44;
  --ink-faint:  #7c766a;
  --rule:       #ddd3bf;
  --rule-soft:  #e7ddca;
  --gold:       #a97e2e;
  --gold-soft:  #f0e6cf;
  --shadow:     0 1px 2px rgba(40,32,10,.05), 0 8px 26px -14px rgba(40,32,10,.28);
  --shadow-lg:  0 2px 4px rgba(40,32,10,.06), 0 20px 50px -22px rgba(40,32,10,.4);

  /* Category accents */
  --c-era:         #24507a;
  --c-theme:       #2c6a58;
  --c-person:      #a9742a;
  --c-document:    #8f3a3a;
  --c-event:       #4a5568;
  --c-institution: #35638f;
  --c-debate:      #6a4c86;

  --maxw: 1120px;
}

:root[data-theme="dark"] {
  --paper:      #14161c;
  --paper-2:    #191c24;
  --card:       #1e222c;
  --ink:        #e9e3d4;
  --ink-soft:   #b9b3a4;
  --ink-faint:  #857f70;
  --rule:       #2f333e;
  --rule-soft:  #262a33;
  --gold:       #d9b25f;
  --gold-soft:  #2a2618;
  --shadow:     0 1px 2px rgba(0,0,0,.3), 0 10px 30px -16px rgba(0,0,0,.7);
  --shadow-lg:  0 2px 6px rgba(0,0,0,.4), 0 24px 60px -24px rgba(0,0,0,.8);
  --c-era:         #6ba3d8;
  --c-theme:       #63c2a5;
  --c-person:      #e0ad5b;
  --c-document:    #e08585;
  --c-event:       #9aa6bd;
  --c-institution: #7db0e0;
  --c-debate:      #b394d6;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:#14161c; --paper-2:#191c24; --card:#1e222c; --ink:#e9e3d4;
    --ink-soft:#b9b3a4; --ink-faint:#857f70; --rule:#2f333e; --rule-soft:#262a33;
    --gold:#d9b25f; --gold-soft:#2a2618;
    --shadow:0 1px 2px rgba(0,0,0,.3),0 10px 30px -16px rgba(0,0,0,.7);
    --shadow-lg:0 2px 6px rgba(0,0,0,.4),0 24px 60px -24px rgba(0,0,0,.8);
    --c-era:#6ba3d8; --c-theme:#63c2a5; --c-person:#e0ad5b; --c-document:#e08585;
    --c-event:#9aa6bd; --c-institution:#7db0e0; --c-debate:#b394d6;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 100; background: var(--card); padding: 8px 12px; border-radius: 6px; }

/* category color helper */
[data-cat="era"]         { --cat: var(--c-era); }
[data-cat="theme"]       { --cat: var(--c-theme); }
[data-cat="person"]      { --cat: var(--c-person); }
[data-cat="document"]    { --cat: var(--c-document); }
[data-cat="event"]       { --cat: var(--c-event); }
[data-cat="institution"] { --cat: var(--c-institution); }
[data-cat="debate"]      { --cat: var(--c-debate); }

/* ---------- Masthead ---------- */
.masthead {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.masthead-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: 20px;
  padding: 14px 24px 12px;
}
.brand { display: flex; align-items: center; gap: 13px; text-decoration: none; color: inherit; }
.brand-mark {
  width: 30px; height: 30px; flex: none; border-radius: 3px;
  background:
    linear-gradient(135deg, var(--c-era) 0%, var(--c-era) 48%, var(--gold) 48%, var(--gold) 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15), var(--shadow);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 6px;
  border: 1.5px solid rgba(255,255,255,.55); border-radius: 1px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-title { font-family: var(--serif); font-size: 21px; font-weight: 600; letter-spacing: .2px; }
.brand-sub { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-faint); margin-top: 3px; }
.masthead-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.search input {
  font-family: var(--sans); font-size: 14px;
  width: 260px; max-width: 42vw;
  padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--card); color: var(--ink);
}
.search input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.icon-btn {
  font-size: 16px; width: 38px; height: 38px; border-radius: 999px;
  border: 1px solid var(--rule); background: var(--card); color: var(--ink-soft);
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--gold); color: var(--gold); }

/* ---------- Tabs ---------- */
.tabs {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; gap: 2px; padding: 0 16px;
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  font-family: var(--sans); font-size: 13px; letter-spacing: .04em;
  text-transform: uppercase; font-weight: 600;
  padding: 12px 15px 13px; white-space: nowrap;
  color: var(--ink-faint); text-decoration: none;
  border-bottom: 2px solid transparent; cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--gold); }

/* ---------- Layout primitives ---------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 34px 24px 80px; }
.eyebrow {
  font-size: 12px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600;
}
.section { margin-top: 52px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head h2 { font-family: var(--serif); font-weight: 600; font-size: 27px; margin: 0; }
.section-head a { font-size: 13px; color: var(--gold); text-decoration: none; font-weight: 600; white-space: nowrap; }
.section-head a:hover { text-decoration: underline; }

/* ---------- Hero ---------- */
.hero { padding: 20px 0 8px; border-bottom: 1px solid var(--rule); }
.hero h1 {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(34px, 6vw, 62px); line-height: 1.02; margin: 12px 0 0;
  letter-spacing: -.5px;
}
.hero h1 .amp { color: var(--gold); font-style: italic; }
.hero .lede {
  font-family: var(--serif); font-size: clamp(18px, 2.4vw, 23px);
  line-height: 1.5; color: var(--ink-soft); max-width: 60ch; margin: 22px 0 26px;
}
.hero .lede strong { color: var(--ink); font-weight: 600; }

/* ---------- Cards ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-5 { grid-template-columns: repeat(5, 1fr); }

.card {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--card); border: 1px solid var(--rule);
  border-radius: 10px; padding: 18px 18px 17px;
  text-decoration: none; color: inherit;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--cat, var(--gold));
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--cat, var(--gold)) 45%, var(--rule)); }
.card .kind {
  font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
  font-weight: 700; color: var(--cat, var(--gold));
}
.card .card-title { font-family: var(--serif); font-size: 19px; font-weight: 600; line-height: 1.18; }
.card .card-sub { font-size: 13px; color: var(--ink-faint); margin-top: -3px; }
.card .card-summary { font-size: 14px; color: var(--ink-soft); line-height: 1.5; }
.card.compact { padding: 14px 15px; }
.card.compact .card-title { font-size: 16px; }

/* featured / start-here */
.featured .card { padding: 22px; }
.featured .card .card-title { font-size: 22px; }
.featured .card .card-summary { font-size: 14.5px; }

/* ---------- Timeline spine (home) ---------- */
.spine { margin: 30px 0 4px; }
.spine-track {
  display: flex; gap: 4px; align-items: stretch;
  border-radius: 10px; overflow: hidden; box-shadow: var(--shadow);
}
.spine-era {
  position: relative; text-decoration: none; color: #fff;
  padding: 15px 14px 14px; min-width: 0;
  background: var(--cat, var(--c-era));
  display: flex; flex-direction: column; justify-content: flex-end; min-height: 118px;
  transition: filter .16s ease, flex-grow .2s ease;
}
.spine-era:hover { filter: brightness(1.08); }
.spine-era .yr { font-family: var(--mono); font-size: 11px; opacity: .82; letter-spacing: .04em; }
.spine-era .nm { font-family: var(--serif); font-size: 15px; font-weight: 600; line-height: 1.12; margin-top: 3px; }
.spine-era .who { font-size: 11.5px; opacity: .85; margin-top: 2px; }
.spine-era::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,.02), rgba(0,0,0,.32));
  pointer-events: none;
}
.spine-era > * { position: relative; z-index: 1; }

/* ---------- Full timeline tab ---------- */
.tl { position: relative; margin-top: 12px; padding-left: 0; }
.tl-era-band {
  margin: 30px 0 6px; padding: 14px 18px; border-radius: 9px;
  background: var(--card); border: 1px solid var(--rule);
  border-left: 4px solid var(--cat, var(--c-era));
  box-shadow: var(--shadow); text-decoration: none; color: inherit; display: block;
}
.tl-era-band:hover { border-color: var(--cat); }
.tl-era-band .yr { font-family: var(--mono); font-size: 12px; color: var(--cat); font-weight: 600; }
.tl-era-band .nm { font-family: var(--serif); font-size: 22px; font-weight: 600; margin-top: 2px; }
.tl-era-band .who { font-size: 13px; color: var(--ink-faint); }
.tl-era-band .sm { font-size: 14px; color: var(--ink-soft); margin-top: 6px; max-width: 72ch; }
.tl-events { border-left: 2px solid var(--rule); margin-left: 20px; padding-left: 0; }
.tl-event {
  position: relative; margin-left: 26px; padding: 11px 0;
  display: block; text-decoration: none; color: inherit;
  border-bottom: 1px dashed var(--rule-soft);
}
.tl-event:last-child { border-bottom: none; }
.tl-event::before {
  content: ""; position: absolute; left: -33px; top: 17px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--card); border: 2.5px solid var(--cat, var(--c-event));
}
.tl-event .yr { font-family: var(--mono); font-size: 12.5px; color: var(--cat); font-weight: 600; }
.tl-event .nm { font-family: var(--serif); font-size: 17px; font-weight: 600; }
.tl-event .sm { font-size: 13.5px; color: var(--ink-soft); }

/* ---------- Article ---------- */
.article { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 48px; align-items: start; }
.article-main { min-width: 0; }
.breadcrumb { font-size: 13px; color: var(--ink-faint); margin-bottom: 14px; }
.breadcrumb a { color: var(--cat, var(--gold)); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.article h1 {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(30px, 4.6vw, 46px); line-height: 1.05; margin: 4px 0 6px; letter-spacing: -.4px;
}
.article .subtitle { font-family: var(--serif); font-size: 20px; color: var(--ink-soft); font-style: italic; margin-bottom: 6px; }
.article .kind-badge {
  display: inline-block; font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  font-weight: 700; color: var(--cat); padding: 3px 0;
}
.article .summary {
  font-family: var(--serif); font-size: 20px; line-height: 1.55; color: var(--ink);
  border-left: 3px solid var(--cat); padding-left: 18px; margin: 20px 0 26px;
}

/* Voice mode */
.voice { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; margin: 2px 0 30px; }
.voice-btn {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--sans); font-size: 14px; font-weight: 600; letter-spacing: .01em;
  padding: 9px 17px 9px 14px; border-radius: 999px; cursor: pointer; color: #fff;
  background: var(--cat, var(--gold)); border: none; box-shadow: var(--shadow);
  transition: filter .15s ease, transform .15s ease;
}
.voice-btn:hover { filter: brightness(1.07); transform: translateY(-1px); }
.voice-btn:focus-visible { outline: 2px solid var(--cat, var(--gold)); outline-offset: 2px; }
.voice-bars { display: inline-flex; align-items: center; gap: 2.5px; height: 15px; }
.voice-bars i { width: 3px; height: 6px; border-radius: 2px; background: rgba(255,255,255,.9); }
.voice-bars i:nth-child(1){ height: 9px; } .voice-bars i:nth-child(2){ height: 5px; }
.voice-bars i:nth-child(3){ height: 13px; } .voice-bars i:nth-child(4){ height: 7px; }
.voice.is-speaking .voice-bars i { animation: vbar .95s ease-in-out infinite; }
.voice.is-speaking .voice-bars i:nth-child(2){ animation-delay: .2s; }
.voice.is-speaking .voice-bars i:nth-child(3){ animation-delay: .38s; }
.voice.is-speaking .voice-bars i:nth-child(4){ animation-delay: .12s; }
@keyframes vbar { 0%,100% { height: 4px; } 50% { height: 15px; } }
.voice-ctrls { display: inline-flex; align-items: center; gap: 8px; }
.voice-mini {
  font-family: var(--sans); font-size: 12.5px; font-weight: 600;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
  background: var(--card); color: var(--ink-soft); border: 1px solid var(--rule);
  font-variant-numeric: tabular-nums;
}
.voice-mini:hover { border-color: var(--cat, var(--gold)); color: var(--ink); }
.voice-status { font-size: 12.5px; color: var(--ink-faint); font-style: italic; }
@media (prefers-reduced-motion: reduce) {
  .voice.is-speaking .voice-bars i { animation: none; height: 9px; }
  .voice-btn:hover { transform: none; }
}

/* prose */
.prose { font-family: var(--serif); font-size: 19px; line-height: 1.72; color: var(--ink); }
.prose h2 {
  font-family: var(--serif); font-size: 26px; font-weight: 600;
  margin: 42px 0 12px; padding-bottom: 7px; border-bottom: 1px solid var(--rule);
}
.prose h3 { font-size: 20px; font-weight: 600; margin: 30px 0 8px; }
.prose p { margin: 0 0 18px; }
.prose ul, .prose ol { margin: 0 0 20px; padding-left: 24px; }
.prose li { margin: 6px 0; }
.prose blockquote {
  margin: 22px 0; padding: 4px 0 4px 22px; border-left: 3px solid var(--gold);
  font-style: italic; color: var(--ink-soft);
}
.prose blockquote cite { display: block; font-style: normal; font-size: 14px; color: var(--ink-faint); margin-top: 8px; font-family: var(--sans); }
.prose hr { border: none; border-top: 1px solid var(--rule); margin: 34px 0; }
.prose a.xlink {
  text-decoration: none; color: var(--link, var(--gold));
  border-bottom: 1.5px solid color-mix(in srgb, var(--link, var(--gold)) 40%, transparent);
  font-family: var(--serif); white-space: nowrap;
}
.prose a.xlink:hover { border-bottom-color: var(--link, var(--gold)); background: color-mix(in srgb, var(--link, var(--gold)) 9%, transparent); }
.prose a.xlink[data-missing="1"] { color: var(--ink-faint); border-bottom-style: dashed; }
.prose a.ext { color: var(--gold); text-decoration: none; border-bottom: 1px dotted var(--gold); }

/* sidebar */
.sidebar { position: sticky; top: 108px; display: flex; flex-direction: column; gap: 22px; }
.facts { background: var(--card); border: 1px solid var(--rule); border-radius: 10px; padding: 16px 18px; box-shadow: var(--shadow); border-top: 3px solid var(--cat); }
.facts h4, .relbox h4, .toc h4 {
  font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint);
  font-weight: 700; margin: 0 0 12px;
}
.facts dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; }
.facts dt { font-size: 12px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .05em; }
.facts dd { margin: 0; font-size: 14px; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; padding: 5px 11px; border-radius: 999px;
  text-decoration: none; background: var(--card); color: var(--ink-soft);
  border: 1px solid var(--rule);
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--cat, var(--gold)); }
.chip:hover { border-color: var(--cat, var(--gold)); color: var(--ink); }
.relbox, .toc { }
.toc a { display: block; font-size: 13.5px; padding: 4px 0; color: var(--ink-soft); text-decoration: none; border-left: 2px solid var(--rule); padding-left: 12px; }
.toc a:hover { color: var(--ink); border-left-color: var(--gold); }
.sources { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--rule); }
.sources h4 { font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint); font-weight: 700; }
.sources ol { font-family: var(--sans); font-size: 13px; color: var(--ink-soft); line-height: 1.5; padding-left: 20px; }
.sources li { margin: 5px 0; }

/* ---------- Collection pages ---------- */
.collection-head { border-bottom: 1px solid var(--rule); padding-bottom: 18px; margin-bottom: 26px; }
.collection-head h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(30px, 5vw, 46px); margin: 6px 0 8px; }
.collection-head p { font-size: 16px; color: var(--ink-soft); max-width: 62ch; margin: 0; }

/* ---------- Search results ---------- */
.results { margin-top: 8px; }
.result {
  display: block; text-decoration: none; color: inherit;
  padding: 14px 0; border-bottom: 1px solid var(--rule);
}
.result .kind { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--cat); font-weight: 700; }
.result .r-title { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.result .r-sum { font-size: 14px; color: var(--ink-soft); }
.result mark { background: var(--gold-soft); color: inherit; padding: 0 2px; border-radius: 2px; }

/* ---------- Footer ---------- */
.site-foot { border-top: 1px solid var(--rule); margin-top: 40px; }
.foot-inner { max-width: var(--maxw); margin: 0 auto; padding: 24px; display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--ink-faint); font-family: var(--serif); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .article { grid-template-columns: 1fr; gap: 28px; }
  .sidebar { position: static; order: 2; }
  .grid.cols-4, .grid.cols-5 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .spine-track { flex-direction: column; }
  .spine-era { min-height: auto; flex-direction: row; align-items: baseline; gap: 10px; }
}
@media (max-width: 640px) {
  main { padding: 24px 16px 60px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.cols-5 { grid-template-columns: 1fr; }
  .search input { width: 150px; }
  .brand-sub { display: none; }
  .masthead-inner { padding: 12px 16px 10px; }
}
