/* ==========================================================================
   site.css: page shell, masthead, essay column, sections, footer, responsive
   Owner: SITE agent. Tokens come from tokens.css (fallbacks kept inline so the
   page still renders if tokens.css is unavailable).
   All sizes in px on purpose: nothing here depends on the root font-size.
   ========================================================================== */

/* --- shell ---------------------------------------------------------------- */

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg, #141518);
  color: var(--fg, #E8E6E3);
  font-family: var(--font-serif, et-book, Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif);
  font-size: 21px;
  line-height: 1.55;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* anything anchored must clear the 56px sticky header */
[id] {
  scroll-margin-top: 84px;
}

::selection {
  background: var(--accent-dim, #2F6B4F);
  color: var(--fg, #E8E6E3);
}

:focus-visible {
  outline: 2px solid var(--accent, #6FD3A0);
  outline-offset: 3px;
  border-radius: 2px;
}

/* --- masthead ------------------------------------------------------------- */

#masthead {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 56px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line, #2A2E35);
  background: rgba(20, 21, 24, 0.85);
  background: color-mix(in srgb, var(--bg, #141518) 85%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

#brandmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  text-decoration: none;
  color: var(--fg, #E8E6E3);
}

#brandmark img {
  display: block;
  width: 22px;
  height: 22px;
  filter: none;
}

#brandmark span {
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace);
  font-size: 13px;
  letter-spacing: normal;
  text-transform: uppercase;
  white-space: nowrap;
}

#brandmark:hover span {
  color: var(--accent, #6FD3A0);
}

#nav {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-left: auto;
  min-width: 0;
}

#nav a {
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  color: var(--fg-dim, #9AA0A8);
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: color 120ms ease, border-color 120ms ease;
}

#nav a:hover {
  color: var(--fg, #E8E6E3);
  border-bottom-color: var(--fg-faint, #5F656D);
}

#nav a[aria-current="true"] {
  color: var(--fg, #E8E6E3);
  border-bottom-color: var(--accent, #6FD3A0);
}

/* ca.js injects into this. Empty until the token exists. */
#ca-slot {
  display: flex;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;
}

#ca-slot:not(:empty) {
  margin-left: 16px;
}

/* --- page grid ------------------------------------------------------------ */

#page {
  display: grid;
  grid-template-columns: minmax(0, var(--maxw-essay, 720px)) minmax(0, 430px);
  column-gap: 64px;
  align-items: start;
  justify-content: center;
  max-width: var(--maxw-page, 1400px);
  margin: 0 auto;
  padding: 0 40px;
}

#essay {
  min-width: 0;
  padding: 72px 0 96px;
}

/* --- masthead of the essay ------------------------------------------------ */

#essay h1 {
  margin: 0;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace);
  font-size: clamp(34px, 7.2vw, 60px);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: normal;
  text-transform: uppercase;
  color: var(--fg, #E8E6E3);
}

#essay h2.byline {
  margin: 18px 0 0;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-dim, #9AA0A8);
}

.lede {
  margin: 34px 0 0;
  font-size: 23px;
  line-height: 1.5;
  color: var(--fg, #E8E6E3);
  text-wrap: pretty;
}

/* --- intro tabs (donor outline-button style) ------------------------------ */

#intro-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 30px;
}

#intro-tabs button {
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace);
  font-size: 12px;
  line-height: 1.2;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: start;
  white-space: nowrap;
  padding: 8px 12px;
  color: var(--fg-dim, #9AA0A8);
  background: transparent;
  border: 1.5px solid var(--line, #2A2E35);
  border-radius: var(--radius, 6px);
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

#intro-tabs button:hover {
  color: var(--fg, #E8E6E3);
  border-color: var(--fg-faint, #5F656D);
}

#intro-tabs button[aria-expanded="true"] {
  color: var(--fg, #E8E6E3);
  background: var(--bg-raised, #1B1D21);
  border-color: var(--fg-faint, #5F656D);
}

#intro-panels {
  margin-top: 10px;
}

.intro-panel {
  padding: 16px 18px;
  border: 1.5px solid var(--line, #2A2E35);
  border-radius: var(--radius, 6px);
  background: var(--bg-raised, #1B1D21);
}

.intro-panel[hidden] {
  display: none;
}

.intro-panel > p {
  margin: 0 0 16px;
  font-size: 18px;
  line-height: 1.55;
  color: var(--fg-dim, #9AA0A8);
}

.intro-panel > p:last-child {
  margin-bottom: 0;
}

.intro-panel.is-opening {
  animation: introReveal 220ms ease-out both;
}

@keyframes introReveal {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

/* --- publine -------------------------------------------------------------- */

.publine {
  margin: 34px 0 0;
  padding: 12px 0;
  border-top: 1px solid var(--line, #2A2E35);
  border-bottom: 1px solid var(--line, #2A2E35);
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace);
  font-size: 11px;
  line-height: 1.6;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-dim, #9AA0A8);
}

#essay .publine a {
  color: var(--fg-dim, #9AA0A8);
  text-decoration: none;
  border-bottom: 1px solid var(--fg-faint, #5F656D);
}

#essay .publine a:hover {
  color: var(--accent, #6FD3A0);
  border-bottom-color: var(--accent, #6FD3A0);
}

/* --- essay body ----------------------------------------------------------- */

#essay section {
  margin-top: 92px;
}

#essay section h2 {
  margin: 0 0 26px;
  font-family: var(--font-serif, et-book, Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif);
  font-size: 33px;
  font-weight: 400;
  line-height: 1.15;
  color: var(--fg, #E8E6E3);
  text-wrap: balance;
}

#essay h3 {
  margin: 32px 0 10px;
  font-family: var(--font-serif, et-book, Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif);
  font-size: 24px;
  font-weight: 400;
  line-height: 1.25;
  color: var(--fg, #E8E6E3);
}

#essay p {
  margin: 21px 0;
  font-size: 21px;
  line-height: 1.55;
  text-wrap: pretty;
}

#essay p:last-child {
  margin-bottom: 0;
}

.section-note {
  color: var(--fg-dim, #9AA0A8);
  font-size: 19px;
}

#essay a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  text-decoration-color: var(--fg-faint, #5F656D);
  transition: color 120ms ease, text-decoration-color 120ms ease;
}

#essay a:hover {
  color: var(--accent, #6FD3A0);
  text-decoration-color: var(--accent, #6FD3A0);
}

/* the scroll hooks that drive the panel must occupy no space */
.chart-hook {
  display: block;
  height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* --- footnote superscripts ------------------------------------------------ */

sup.fn {
  font-size: 12px;
  line-height: 0;
  position: relative;
  top: -0.5em;
  margin-left: 1px;
  white-space: nowrap;
}

#essay sup.fn a {
  color: var(--accent, #6FD3A0);
  text-decoration: none;
  padding: 0 2px;
  border-radius: 3px;
}

#essay sup.fn a:hover {
  background: var(--accent-dim, #2F6B4F);
  color: var(--fg, #E8E6E3);
  text-decoration: none;
}

/* --- how it works --------------------------------------------------------- */

.steps {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.step {
  position: relative;
  margin-top: 34px;
  padding-left: 58px;
}

.step::before {
  content: attr(data-step);
  position: absolute;
  left: 0;
  top: 3px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace);
  font-size: 13px;
  color: var(--fg-dim, #9AA0A8);
  border: 1px solid var(--line, #2A2E35);
  border-radius: var(--radius, 6px);
  background: var(--bg-raised, #1B1D21);
}

.step h3 {
  margin: 0 0 6px;
  font-size: 23px;
}

.step p {
  margin: 0;
  color: var(--fg-dim, #9AA0A8);
  font-size: 19px;
}

/* --- FAQ ------------------------------------------------------------------ */

#faq .faq-item {
  border-top: 1px solid var(--line, #2A2E35);
}

#faq .faq-item:last-of-type {
  border-bottom: 1px solid var(--line, #2A2E35);
}

#faq summary {
  position: relative;
  list-style: none;
  cursor: pointer;
  padding: 18px 40px 18px 0;
  font-size: 20px;
  line-height: 1.4;
  color: var(--fg, #E8E6E3);
}

#faq summary::-webkit-details-marker {
  display: none;
}

#faq summary::after {
  content: "+";
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace);
  font-size: 16px;
  line-height: 1;
  color: var(--fg-dim, #9AA0A8);
}

#faq details[open] > summary::after {
  content: "\2212";
}

#faq summary:hover {
  color: var(--accent, #6FD3A0);
}

#faq summary:focus-visible {
  outline: 2px solid var(--accent, #6FD3A0);
  outline-offset: -2px;
}

#faq .faq-item > p {
  margin: 0 0 22px;
  padding-right: 40px;
  font-size: 19px;
  color: var(--fg-dim, #9AA0A8);
}

/* --- footnotes ------------------------------------------------------------ */

.footnote-list {
  list-style: none;
  counter-reset: fn;
  margin: 8px 0 0;
  padding: 0;
}

.footnote-list li {
  counter-increment: fn;
  position: relative;
  margin-top: 14px;
  padding: 4px 8px 4px 34px;
  border-radius: var(--radius, 6px);
  font-size: 17px;
  line-height: 1.5;
  color: var(--fg-dim, #9AA0A8);
  transition: background-color 900ms ease, box-shadow 900ms ease;
}

.footnote-list li::before {
  content: counter(fn);
  position: absolute;
  left: 8px;
  top: 8px;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace);
  font-size: 12px;
  line-height: 1;
  color: var(--accent, #6FD3A0);
}

#essay .footnote-list li a {
  color: var(--fg-dim, #9AA0A8);
  overflow-wrap: anywhere;
  text-decoration-color: var(--line, #2A2E35);
}

#essay .footnote-list li a:hover {
  color: var(--accent, #6FD3A0);
  text-decoration-color: var(--accent, #6FD3A0);
}

.footnote-list li.fn-flash {
  background: var(--bg-raised, #1B1D21);
  box-shadow: inset 2px 0 0 var(--accent, #6FD3A0);
  transition-duration: 120ms;
}

/* --- footer --------------------------------------------------------------- */

#footer {
  border-top: 1px solid var(--line, #2A2E35);
  margin-top: 40px;
  padding: 48px 24px 72px;
  text-align: center;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.footer-brand img {
  display: block;
  width: 28px;
  height: 28px;
  filter: none;
}

.footer-brand span {
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace);
  font-size: 14px;
  letter-spacing: normal;
  text-transform: uppercase;
  color: var(--fg, #E8E6E3);
}

.footer-chain {
  margin: 16px 0 0;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-dim, #9AA0A8);
}

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 22px;
  margin-top: 20px;
}

.footer-links a {
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--fg-dim, #9AA0A8);
  border-bottom: 1px solid var(--line, #2A2E35);
  padding-bottom: 2px;
}

.footer-links a:hover {
  color: var(--accent, #6FD3A0);
  border-bottom-color: var(--accent, #6FD3A0);
}

.footer-legal {
  margin: 28px 0 0;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace);
  font-size: 11px;
  line-height: 1.6;
  color: var(--fg-faint, #5F656D);
}

/* --- responsive ----------------------------------------------------------- */

@media (max-width: 1360px) {
  #page {
    column-gap: 48px;
    padding: 0 28px;
  }
}

/* below 1100 the panel is gone and the essay stands alone, like the donor */
@media (max-width: 1099px) {
  #page > #panel {
    display: none;
  }

  #page {
    grid-template-columns: minmax(0, var(--maxw-essay, 720px));
    column-gap: 0;
  }
}

@media (max-width: 860px) {
  #essay {
    padding-top: 56px;
  }

  #essay section {
    margin-top: 76px;
  }

  #essay section h2 {
    font-size: 29px;
  }

  .lede {
    font-size: 21px;
  }

  #essay p,
  .intro-panel > p,
  .step p,
  #faq .faq-item > p,
  .section-note {
    font-size: 19px;
  }

  #faq summary {
    font-size: 19px;
  }
}

@media (max-width: 760px) {
  #masthead {
    padding: 0 16px;
    gap: 12px;
  }

  #nav {
    gap: 14px;
  }

  #nav a {
    font-size: 11px;
    letter-spacing: 0.04em;
  }

  #page {
    padding: 0 20px;
  }

  #footer {
    padding: 40px 20px 64px;
  }
}

@media (max-width: 520px) {
  /* the wordmark is the first thing in the essay anyway, the blob carries it here */
  #brandmark span {
    display: none;
  }

  #nav {
    gap: 11px;
  }

  #nav a {
    font-size: 10px;
    letter-spacing: 0.03em;
  }

  #essay {
    padding: 44px 0 72px;
  }

  #essay section {
    margin-top: 64px;
  }

  #essay section h2 {
    font-size: 26px;
  }

  #intro-tabs button {
    font-size: 11px;
    padding: 7px 10px;
    white-space: normal;
  }

  .step {
    padding-left: 46px;
  }

  .step::before {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }

  #faq summary {
    padding-right: 32px;
  }

  #faq .faq-item > p {
    padding-right: 0;
  }
}

@media (min-width: 1600px) {
  #page {
    column-gap: 80px;
  }
}

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

@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;
  }
}
