/*
 * Research article stylesheet — the reusable, unified look for everything under
 * /research (index + monthly report pages). Loaded ONLY on research pages via
 * the layout's {{{ pageCss }}} slot (lib/research.js supplies the <link>), so
 * the homepage never pays for it and every current/future report renders
 * identically from this one file.
 *
 * Sections: page hero · report chrome (meta, badges) · index cards · article
 * masthead (header + hero artwork + abstract, one merged unit) · article
 * typography (incl. tables + figures) · methodology notice · funding CTA.
 * Uses only design-system tokens — no new colors or type styles.
 */

/* ---------- Page hero (index + article header band) ---------- */
.page-hero {
  background: var(--color-bg-alt);
  margin-top: calc(-1 * var(--header-h));
  padding-block: calc(var(--header-h) + var(--space-7)) var(--space-7);
}

.page-hero .eyebrow {
  margin: 0 0 var(--space-4);
}

.page-hero__title {
  font-family: var(--font-display);
  font-weight: var(--weight-light);
  font-size: var(--fs-h1);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0;
  max-width: 26ch;
}

.page-hero__lede {
  margin: var(--space-5) 0 0;
  color: var(--color-muted);
  max-width: 58ch;
}

/* ---------- Report chrome ---------- */

/* "← All research" crumb above the report header + the one after the article. */
.report__back {
  margin: 0 0 var(--space-6);
  font-size: var(--fs-small);
}

.report__back a {
  color: var(--color-muted);
  transition: color var(--dur-fast) var(--ease);
}

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

.report__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-4) 0 0;
  font-size: var(--fs-small);
  color: var(--color-muted);
}

/* "Research O" / "Research F" attribution chip — identifies the researcher
   model family (frontmatter `researcher:`, rendered by lib/research.js). */
.research-tag {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  padding: 1px 10px 2px;
  font-size: var(--fs-eyebrow);
  font-weight: var(--weight-regular);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
  white-space: nowrap;
}

.research-tag strong {
  font-weight: var(--weight-medium);
  color: var(--color-ink);
}

.eyebrow .research-tag {
  margin-left: var(--space-2);
}

.report__footer-back {
  margin: 0 0 var(--space-9);
}

/* ---------- Index list — one card per monthly report, newest first ---------- */
.report-index {
  padding-block: var(--space-7) var(--section-py);
}

.report-list {
  display: grid;
  gap: var(--space-5);
  max-width: 880px;
}

/* Each card is ONE click target (Goal 15): the title anchor stretches over the
   whole card via ::after, so the padding/excerpt areas navigate too. The art and
   "Read the report" anchors share the same href and simply sit beneath the
   overlay — they stay in the markup as a no-CSS/no-JS fallback but are out of
   the a11y tree, keeping exactly one tab stop per card (the title link). */
.report-card {
  position: relative;
  cursor: pointer;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-6);
  overflow: hidden;
  transition: box-shadow var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}

/* Full-bleed artwork strip atop each card — the report's hero SVG, linked. */
.report-card__art {
  display: block;
  margin: calc(-1 * var(--space-6)) calc(-1 * var(--space-6)) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.report-card__art svg {
  display: block;
  width: 100%;
  height: auto;
}

.report-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-border-strong);
}

.report-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  margin-bottom: var(--space-3);
}

.report-card__head .eyebrow,
.report-card__meta {
  margin: 0;
}

.report-card__meta {
  font-size: var(--fs-eyebrow);
  color: var(--color-faint);
}

.report-card__title {
  font-family: var(--font-display);
  font-weight: var(--weight-regular);
  font-size: var(--fs-h3);
  line-height: 1.35;
  margin: 0 0 var(--space-3);
}

/* The stretched-link overlay itself. */
.report-card__title a::after {
  content: '';
  position: absolute;
  inset: 0;
}

/* Hover affordances key off the CARD, not the individual anchors, so the whole
   surface reads as one control (the shadow/border lift above already does). */
.report-card:hover .report-card__title a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.report-card:hover .btn-arrow {
  transform: translateX(3px);
}

/* Keyboard focus on the title draws the ring around the whole card (the
   overlay), matching the click target's true extent. */
.report-card__title a:focus-visible {
  outline: none;
}

.report-card__title a:focus-visible::after {
  outline: 2px solid var(--color-ink);
  outline-offset: -2px;
  border-radius: var(--radius);
}

.report-card__excerpt {
  margin: 0 0 var(--space-5);
  color: var(--color-muted);
  font-size: var(--fs-small);
  line-height: 1.7;
  max-width: 72ch;
}

/* ---------- Index → article loading feedback (public/js/research-nav.js) ----------
   A plain left-click on a card sets .is-loading on it (gentle dim/desaturate
   hold) and activates the fixed top progress bar, bridging the click →
   next-paint gap of the MPA navigation. Teal owns live/loading moments
   (pd/DESIGN.md); all movement is gated behind no-preference — reduced-motion
   users get an instant static teal bar and an instant (untransitioned) dim. */
.report-card.is-loading {
  opacity: 0.55;
  filter: saturate(0.5);
}

.research-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 200; /* above the sticky header (100) */
  background: rgba(15, 164, 126, 0.18);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.research-progress.is-active {
  opacity: 1;
  visibility: visible;
}

/* The sweeping segment — static full-width teal unless motion is allowed. */
.research-progress::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--color-live);
}

/* Hero-animation viewport gate (research-nav.js): when JS confirms
   IntersectionObserver support it sets .research-anim-gate on <html>, which
   pauses every card hero's CSS animations; only cards currently on screen
   (.is-inview) run theirs. Without JS/observer no class is set and the heroes
   play as authored. The longhand play-state out-specifies the heroes' inline
   `animation:` shorthands, whatever their slug-namespaced class names. */
.research-anim-gate .report-card__art svg * {
  animation-play-state: paused;
}

.research-anim-gate .report-card.is-inview .report-card__art svg * {
  animation-play-state: running;
}

@media (prefers-reduced-motion: no-preference) {
  .report-card.is-loading {
    transition: opacity var(--dur) var(--ease), filter var(--dur) var(--ease);
  }

  .research-progress.is-active::before {
    width: 38%;
    animation: research-progress-sweep 1.6s var(--ease) infinite;
  }

  @keyframes research-progress-sweep {
    from {
      transform: translateX(-110%);
    }
    to {
      transform: translateX(290%);
    }
  }
}

/* ---------- Article masthead — header + abstract + hero artwork, ONE unit ----------
   The article opens as a single merged masthead (maintainer-directed
   2026-06-12, centered layout same day): a top utility row (back crumb left,
   researcher tag + sources + updated date RIGHT), then a centered column —
   month eyebrow, title, subtitle deck, #tag chips, abstract — and the hero
   artwork as the band's BOTTOM element (a bordered surface card closing the
   band). The artwork is the report's content-representative hero SVG
   (authored per article — see research/monthly.md step 5). */
.report__masthead {
  text-align: center;
}

.report__masthead-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2) var(--space-5);
  margin-bottom: var(--space-7);
  text-align: left;
}

.report__masthead-top .report__back,
.report__masthead-top .report__meta {
  margin: 0;
}

.report__masthead-top .report__meta {
  justify-content: flex-end;
}

/* Long report titles stay on as few balanced lines as possible — full
   container width (the index hero keeps the narrow 26ch measure). */
.report__masthead .page-hero__title {
  max-width: none;
  margin-inline: auto;
  font-size: clamp(1.875rem, 3.2vw, 2.625rem);
  text-wrap: balance;
}

/* Subtitle deck — the one-sentence hook under the H1. Display face at light
   weight so it reads as part of the headline group, clearly distinct from the
   muted body-face abstract below. */
.report__deck {
  margin: var(--space-4) auto 0;
  font-family: var(--font-display);
  font-weight: var(--weight-light);
  font-size: 1.3125rem;
  line-height: 1.55;
  color: var(--color-ink);
  max-width: 60ch;
}

/* #tag chips — 1–5 frontmatter hashtags summarizing the report. Teal pills
   (the design system's single accent) so they can't be mistaken for body text. */
.report__tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin: var(--space-5) auto 0;
  font-size: var(--fs-small);
}

.report__tag {
  white-space: nowrap;
  padding: 1px 12px 2px;
  border-radius: var(--radius-pill);
  background: rgba(15, 164, 126, 0.08);
  color: var(--color-live);
}

/* On index cards the tags sit left-aligned between excerpt and read-link. */
.report-card .report__tags {
  justify-content: flex-start;
  margin: calc(-1 * var(--space-2)) 0 var(--space-5);
}

/* Centered abstract lede on the band. */
.report__opening-body {
  max-width: 76ch;
  margin: var(--space-6) auto 0;
}

.report__opening-body .eyebrow {
  margin: 0 0 var(--space-3);
}

.report__opening-abstract {
  margin: 0;
  line-height: 1.7;
  color: var(--color-muted);
}

/* The hero artwork — a bordered surface card closing the masthead band. */
.report__opening-art {
  max-width: 960px;
  margin: var(--space-6) auto 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.report__opening-art svg {
  display: block;
  width: 100%;
  height: auto;
}

/* ---------- Article typography — rendered from research/*.md ---------- */
.report__body {
  max-width: 760px;
  padding-block: var(--space-7) var(--space-6);
  line-height: 1.75;
}

.report__body h2 {
  font-family: var(--font-display);
  font-weight: var(--weight-regular);
  font-size: var(--fs-h2);
  line-height: 1.25;
  margin: var(--space-8) 0 var(--space-4);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border);
}

.report__body h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.report__body h3 {
  font-size: var(--fs-h3);
  font-weight: var(--weight-medium);
  line-height: 1.35;
  margin: var(--space-6) 0 var(--space-3);
}

.report__body p {
  margin: 0 0 var(--space-4);
}

.report__body blockquote {
  margin: 0 0 var(--space-5);
  padding: var(--space-2) 0 var(--space-2) var(--space-5);
  border-left: 2px solid var(--color-border-strong);
  color: var(--color-muted);
  font-size: var(--fs-small);
}

.report__body blockquote p {
  margin: 0;
}

/* Inline highlight (==text== in the report Markdown) — the report's key,
   load-bearing claims, tinted with the live-teal accent. */
.report__body mark {
  background: rgba(15, 164, 126, 0.14);
  color: inherit;
  padding: 0 3px;
  border-radius: 3px;
}

/* Researcher callouts (GFM-callout syntax in the report Markdown):
   > [!NOTE]      → "Researcher's Note"  — reading notes, caveats, cross-refs
   > [!IMPORTANT] → "Why This Matters"   — reasoning for flagging a finding */
.report__note {
  margin: var(--space-5) 0;
  padding: var(--space-4) var(--space-5);
  background: var(--color-bg-alt);
  border-left: 3px solid var(--color-ink);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: var(--fs-small);
  line-height: 1.7;
  color: var(--color-ink-soft);
}

.report__note p {
  margin: 0;
}

.report__note .report__note-label {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-eyebrow);
  font-weight: var(--weight-medium);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.report__note--important {
  border-left-color: var(--color-live);
  background: rgba(15, 164, 126, 0.07);
}

.report__note--important .report__note-label {
  color: var(--color-live);
}

.report__body ul,
.report__body ol {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-5);
}

.report__body li {
  margin-bottom: var(--space-2);
  /* citation jumps (#src-N) land clear of the sticky header */
  scroll-margin-top: calc(var(--header-h) + var(--space-4));
}

.report__body li:target {
  background: var(--color-bg-alt);
}

.report__body a {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--color-border-strong);
  transition: text-decoration-color var(--dur-fast) var(--ease);
  word-break: break-word;
}

.report__body a:hover {
  text-decoration-color: var(--color-ink);
}

/* Numbered source citations ([3]) — quiet superscripts linking into Sources. */
.report__body a.cite {
  font-size: 0.8em;
  vertical-align: super;
  line-height: 1;
  color: var(--color-muted);
  text-decoration: none;
}

.report__body a.cite:hover {
  color: var(--color-ink);
}

.report__body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.875em;
  background: var(--color-bg-alt);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-1);
}

/* ---------- Tables (GFM `|` tables from the report Markdown) ---------- */
.report__table-wrap {
  margin: 0 0 var(--space-5);
  overflow-x: auto;
}

.report__body table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-small);
  line-height: 1.55;
}

.report__body th {
  text-align: left;
  font-size: var(--fs-eyebrow);
  font-weight: var(--weight-medium);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
  padding: var(--space-2) var(--space-4) var(--space-2) 0;
  border-bottom: 1px solid var(--color-border-strong);
}

.report__body td {
  padding: var(--space-3) var(--space-4) var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

.report__body tbody tr:hover {
  background: var(--color-bg-alt);
}

/* ---------- In-article SVG figures ---------- */
.report__figure {
  margin: var(--space-6) 0;
}

.report__figure svg {
  display: block;
  width: 100%;
  height: auto;
}

/* ---------- Methodology notice — the reports' standfirst, re-homed ----------
   Every report's boilerplate "what this note is" blockquote renders here at the
   article's very bottom as a quiet colophon (maintainer-directed 2026-06-12),
   instead of opening the article. */
.report__notice {
  max-width: 760px;
  margin: var(--space-7) 0;
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
  font-size: var(--fs-small);
  line-height: 1.7;
  color: var(--color-muted);
}

.report__notice p {
  margin: 0;
  max-width: 80ch;
}

/* Compound selector so the label's gap survives the `.report__notice p` reset. */
.report__notice .report__notice-label {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-eyebrow);
  font-weight: var(--weight-medium);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-faint);
}

/* ---------- Funding CTA (frontmatter `funding:` — investable signal) ---------- */
.report-cta {
  max-width: 880px;
  margin: var(--space-8) 0 var(--space-7);
  padding: var(--space-7);
  background: var(--color-ink);
  color: #fff;
  border-radius: var(--radius);
}

.report-cta__eyebrow {
  color: var(--color-live);
  margin: 0 0 var(--space-4);
}

.report-cta__title {
  font-family: var(--font-display);
  font-weight: var(--weight-light);
  font-size: var(--fs-h2);
  line-height: 1.35;
  margin: 0 0 var(--space-4);
  max-width: 56ch;
}

.report-cta__note {
  color: rgba(255, 255, 255, 0.65);
  font-size: var(--fs-small);
  margin: 0 0 var(--space-5);
  max-width: 64ch;
}

/* Invert the primary pill on the dark panel. */
.report-cta .btn--primary {
  background: #fff;
  color: var(--color-ink);
  border-color: #fff;
}

.report-cta .btn--primary:hover {
  background: var(--color-bg-alt);
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .report-card,
  .report-cta {
    padding: var(--space-5);
  }

  .report-card__art {
    margin: calc(-1 * var(--space-5)) calc(-1 * var(--space-5)) var(--space-4);
  }
}
