/* Base, layout primitives and shared components — docs/02-design-system.md §4–§12 (refreshed) */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 16px);
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--surface-page);
  color: var(--text-body);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.6;
  font-weight: 400;
  letter-spacing: -0.003em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

img, svg, picture { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
dl, dd { margin: 0; }
figure { margin: 0; }
address { font-style: normal; }
hr { border: 0; border-top: 1px solid var(--border-subtle); margin: 0; }
::selection { background: var(--purple-200); color: var(--text-strong); }

h1, h2, h3, h4 {
  margin: 0;
  color: var(--text-strong);
  text-wrap: balance;
}
/* Display levels: light serif at large optical size */
h1, h2 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.012em;
}
h1 { font-size: var(--fs-h1); line-height: 1.04; }
h2 { font-size: var(--fs-h2); line-height: 1.06; }
/* Working levels: the sans, for scanning */
h3, h4 { font-family: var(--font-body); letter-spacing: -0.012em; }
h3 { font-size: var(--fs-h3); line-height: 1.25; font-weight: 500; }
h4 { font-size: var(--fs-h4); line-height: 1.3; font-weight: 500; }
p, li, dd { text-wrap: pretty; }

/* ---------- Utilities ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--page-x));
  margin-inline: auto;
  /* viewport-fit=cover: keep content clear of notches in landscape */
  padding-inline: max(var(--page-x), env(safe-area-inset-left)) max(var(--page-x), env(safe-area-inset-right));
}
.section { padding-block: var(--section-y); }
.section.funds, .section.assets, .section.people, .section.insights, .section.stewardship { padding-block: var(--section-y-tight); }
.surface-subtle { background: var(--surface-subtle); }
.surface-brand { background: var(--surface-brand-deep); color: var(--text-on-brand); }
.prose { max-width: var(--measure); }
.lead { font-size: var(--fs-body-lg); line-height: 1.55; color: var(--text-body); }
.tabular { font-variant-numeric: tabular-nums lining-nums; }
.muted { color: var(--text-muted); }

.as-at {
  font-size: var(--fs-as-at);
  font-weight: 400;
  line-height: 1.4;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums lining-nums;
}

/* ---------- Focus ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus-ring-light);
  outline-offset: 3px;
  border-radius: var(--radius-1);
}
.on-dark :focus-visible,
.surface-brand :focus-visible { outline-color: var(--focus-ring-dark); }

.skip-link {
  position: absolute;
  left: var(--space-4); top: var(--space-3);
  z-index: calc(var(--z-tooltip) + 1);
  padding: var(--space-3) var(--space-4);
  background: #fff; color: var(--purple-900);
  font-weight: 500; text-decoration: underline;
  border-radius: var(--radius-1);
  box-shadow: var(--shadow-1);
  transform: translateY(-200%);
}
.skip-link:focus-visible { transform: none; }

/* ---------- Icons ---------- */
.icon { width: 1.25em; height: 1.25em; flex: none; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.icon--16 { width: 16px; height: 16px; }
.icon--20 { width: 20px; height: 20px; }
.icon--24 { width: 24px; height: 24px; }
.chev {
  display: inline-block;
  width: .58em; height: .58em;
  fill: currentColor;
  flex: none;
  transition: transform var(--dur-2) var(--ease-out);
}

/* ---------- Links ---------- */
.link {
  display: inline-flex; align-items: center; gap: .5em;
  color: var(--link);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 30%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: .28em;
  transition: color var(--dur-1) var(--ease-out), text-decoration-color var(--dur-2) var(--ease-out);
}
.link:hover { color: var(--link-hover); text-decoration-color: currentColor; }
.link:hover .chev, .link:focus-visible .chev { transform: translateX(3px); }
.link--plain { text-decoration: none; }
.link--plain:hover { text-decoration: underline; }
.on-dark .link, .surface-brand .link { color: #fff; }
.on-dark .link:hover, .surface-brand .link:hover { color: var(--gold-300); }

/* ---------- Buttons (pill) ---------- */
.btn {
  --btn-bg: var(--purple-900);
  --btn-fg: #fff;
  --btn-bd: var(--purple-900);
  display: inline-flex; align-items: center; justify-content: center; gap: .65em;
  min-height: 48px;
  padding: 12px 24px;
  border: 1px solid var(--btn-bd);
  border-radius: var(--radius-1);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: var(--font-body);
  font-size: var(--fs-label);
  font-weight: 500;
  letter-spacing: -0.005em;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out);
}
.btn:hover { --btn-bg: var(--purple-800); --btn-bd: var(--purple-800); }
.btn:active { --btn-bg: var(--purple-950); --btn-bd: var(--purple-950); transform: translateY(1px); }
.btn:hover .chev, .btn:focus-visible .chev { transform: translateX(3px); }
.btn--secondary { --btn-bg: transparent; --btn-fg: var(--text-strong); --btn-bd: var(--border-strong); }
.btn--secondary:hover { --btn-bg: var(--surface-panel); --btn-fg: var(--text-strong); --btn-bd: var(--text-strong); }
.btn--secondary:active { --btn-bg: var(--purple-50); }
.btn--on-dark { --btn-bg: #fff; --btn-fg: var(--purple-950); --btn-bd: #fff; }
.btn--on-dark:hover { --btn-bg: var(--gold-100); --btn-bd: var(--gold-100); }
.btn--on-dark:active { --btn-bg: var(--gold-200); --btn-bd: var(--gold-200); }
.btn--ghost-dark { --btn-bg: rgb(255 255 255 / .06); --btn-fg: #fff; --btn-bd: rgb(255 255 255 / .38); }
.btn--ghost-dark:hover { --btn-bg: rgb(255 255 255 / .14); --btn-bd: #fff; }
.btn[aria-disabled="true"] { opacity: .6; cursor: progress; }
.btn--block { width: 100%; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px;
  padding: 0 10px 0 8px;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}
.badge .icon { width: 13px; height: 13px; stroke-width: 2; }
.badge--open { background: var(--positive-tint); color: var(--positive); }
.badge--winddown { background: var(--warning-tint); color: var(--warning); }
.badge--pro { background: var(--purple-100); color: var(--purple-900); }
.badge--neutral { background: var(--surface-muted); color: var(--text-body); }
@media (forced-colors: active) { .badge { border: 1px solid CanvasText; } }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-1);
  background: var(--surface-muted);
  color: var(--text-body);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.4;
}
.chip--warning { background: var(--warning-tint); color: var(--warning); border-radius: var(--radius-1); }
.chip .icon { width: 14px; height: 14px; stroke-width: 2; }

/* ---------- Definition tooltip ---------- */
.tip { position: relative; display: inline-flex; vertical-align: middle; }
.tip__btn {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px;
  margin: -4px 0 -4px 2px;
  padding: 0;
  border: 0; border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  transition: color var(--dur-1), background-color var(--dur-1);
}
.tip__btn:hover, .tip__btn[aria-expanded="true"] { color: var(--purple-900); background: var(--purple-100); }
.tip__btn .icon { width: 15px; height: 15px; }
/* 44px touch area without changing the visual size */
@media (pointer: coarse) { .tip__btn { position: relative; } .tip__btn::before { content: ""; position: absolute; inset: -10px; } }
.tip__panel {
  position: absolute;
  left: 50%; bottom: calc(100% + 10px);
  z-index: var(--z-tooltip);
  width: max-content; max-width: min(300px, 80vw);
  padding: 12px 14px;
  border-radius: var(--radius-2);
  background: var(--purple-950);
  color: #fff;
  font-family: var(--font-body);
  font-size: var(--fs-body-sm);
  font-weight: 400;
  line-height: 1.5;
  text-align: left;
  letter-spacing: 0;
  white-space: normal;
  box-shadow: var(--shadow-2);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 4px);
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out), visibility 0s linear var(--dur-2);
  pointer-events: none;
}
.tip__panel::after {
  content: ""; position: absolute; left: 50%; top: 100%;
  width: 10px; height: 10px; margin-left: -5px; margin-top: -5px;
  background: inherit; transform: rotate(45deg); border-radius: 2px;
}
.tip.is-open .tip__panel {
  opacity: 1; visibility: visible; transform: translate(-50%, 0);
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out);
}
.tip--start .tip__panel { left: -8px; transform: translate(0, 4px); }
.tip--start.is-open .tip__panel { transform: none; }
.tip--start .tip__panel::after { left: 20px; }
.tip--end .tip__panel { left: auto; right: -8px; transform: translate(0, 4px); }
.tip--end.is-open .tip__panel { transform: none; }
.tip--end .tip__panel::after { left: auto; right: 15px; }

/* ---------- Disclosure block ---------- */
.disclosure {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  padding: 20px 24px;
  border: 0;
  border-radius: var(--radius-3);
  background: var(--surface-subtle);
  color: var(--text-body);
  font-size: var(--fs-body-sm);
  line-height: 1.55;
}
.disclosure > .icon { grid-row: span 2; width: 20px; height: 20px; margin-top: 2px; color: var(--info); }
.disclosure strong { color: var(--text-strong); font-weight: 500; }

/* ---------- Provenance caption (signature device) ---------- */
.provenance {
  position: relative;
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  font-size: var(--fs-caption);
  line-height: 1.5;
  color: var(--text-muted);
}
.provenance::before {
  content: "";
  position: absolute; left: 0; top: 0;
  width: 24px; height: 1px;
  background: var(--rule-accent);
  transform-origin: left center;
  transition: transform var(--dur-4) var(--ease-out);
}
.provenance strong { color: var(--text-strong); font-weight: 500; }
.provenance.is-pending::before { transform: scaleX(0); }

/* ---------- Toast ---------- */
.toast-region {
  position: fixed;
  left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: var(--z-toast);
  display: grid; gap: 8px;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px 12px 18px;
  border-radius: var(--radius-3);
  background: var(--purple-950);
  color: #fff;
  font-size: var(--fs-body-sm);
  box-shadow: var(--shadow-2);
  pointer-events: auto;
  animation: toast-in var(--dur-3) var(--ease-out-expo) both;
}
.toast .icon { color: var(--gold-300); }
.toast__msg { flex: 1; }
.toast__action {
  padding: 6px 12px; border: 0; border-radius: var(--radius-1);
  background: rgb(255 255 255 / .1); color: #fff;
  font-weight: 500;
}
.toast__action:hover { background: rgb(255 255 255 / .18); }
.toast.is-leaving { animation: toast-out var(--dur-2) var(--ease-in-out) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ---------- Reveal motion ----------
   Generic fade-ups are intentionally retired: content simply appears.
   Only photographs (clip) and data graphics (their own rules) animate in. */
@media (prefers-reduced-motion: no-preference) {
  .js [data-reveal="clip"].is-pending { clip-path: inset(0 0 100% 0 round var(--radius-3)); }
  .js [data-reveal="clip"] { transition: clip-path 1.2s var(--ease-out-expo); transition-delay: var(--reveal-delay, 0ms); }
  .js [data-reveal="clip"] img { transition: transform 1.8s var(--ease-out-expo); transition-delay: var(--reveal-delay, 0ms); }
  .js [data-reveal="clip"].is-pending img { transform: scale(1.08); }
}

/* ---------- Dialog base ---------- */
dialog {
  padding: 0; border: 0;
  color: var(--text-body);
  background: var(--surface-panel);
  max-width: calc(100vw - 32px);
}
dialog::backdrop { background: rgb(26 17 36 / .55); backdrop-filter: blur(4px); }
@media (prefers-reduced-motion: no-preference) {
  dialog[open] { animation: dialog-in var(--dur-3) var(--ease-out-expo); }
  dialog[open]::backdrop { animation: fade-in var(--dur-2) var(--ease-out); }
}
@keyframes dialog-in { from { opacity: 0; transform: translateY(12px) scale(.985); } }
@keyframes fade-in { from { opacity: 0; } }
