/* =============================================================
   CoMPhy Lab · Research page (v2)
   Prepends a "Currently" strip + 4-theme grid above the existing
   flat paper list. The flat list (from _research/index.md) stays
   intact so research.js tag filtering keeps working.
   ============================================================= */

.research-page {
  width: min(100% - 2rem, var(--maxw-page));
  margin: 0 auto;
  padding: var(--s-9) 0 var(--s-8);
  position: relative;
  z-index: 1;
}

.research-page__head {
  max-width: 68ch;
  margin: 0 auto var(--s-7);
  text-align: center;
}

.research-page__kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--t-sans);
  font-size: var(--t-eyebrow);
  font-weight: 600;
  letter-spacing: var(--t-track-wide);
  text-transform: uppercase;
  color: var(--fg-2);
  margin-bottom: var(--s-4);
}

.research-page__kicker .rule {
  width: 32px;
  height: 1px;
  background: var(--c-border-strong);
}

.research-page__title {
  font-family: var(--t-serif);
  font-weight: 600;
  font-size: clamp(32px, 4vw, 48px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--fg-strong);
  font-variation-settings: "opsz" 96;
  margin: 0 0 var(--s-4);
  text-wrap: balance;
}

.research-page__lede {
  font-family: var(--t-serif);
  font-weight: 400;
  font-size: var(--t-body-lg);
  line-height: 1.55;
  color: var(--fg-1);
  margin: 0 auto;
  max-width: 60ch;
  font-variation-settings: "opsz" 18;
}

/* =========================================================
   Currently strip (sticky at top of page, teal-left border)
   ========================================================= */
.r-now {
  padding: var(--s-6) var(--s-7);
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--c-accent-teal) 5%, var(--c-surface-strong)) 0%,
    var(--c-surface-strong) 60%
  );
  border: 1px solid color-mix(in srgb, var(--c-accent-teal) 25%, transparent);
  border-left: 3px solid var(--c-accent-teal);
  border-radius: var(--r-md);
  margin-bottom: var(--s-7);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s-5);
  align-items: center;
}

.r-now__label {
  font-family: var(--t-sans);
  font-size: var(--t-eyebrow);
  letter-spacing: var(--t-track-wide);
  text-transform: uppercase;
  color: var(--c-accent-teal);
  font-weight: 700;
  padding: 6px 10px;
  border: 1px solid var(--c-accent-teal);
  border-radius: var(--r-pill);
  white-space: nowrap;
}

.r-now__text {
  font-family: var(--t-serif);
  font-weight: 500;
  font-size: var(--t-body-lg);
  line-height: 1.5;
  color: var(--fg-1);
  margin: 0;
  max-width: none;
  font-variation-settings: "opsz" 24;
}

.r-now__text b { color: var(--fg-strong); font-weight: 600; }

@media (max-width: 820px) {
  .r-now { grid-template-columns: 1fr; }
}

/* =========================================================
   Theme grid (same pattern as homepage, scoped for the page)
   ========================================================= */
.r-themes-wrap { margin-bottom: var(--s-9); padding-top: var(--s-5); }

.r-themes-head {
  max-width: 68ch;
  margin: 0 0 var(--s-6);
}

.r-themes-head__num {
  font-family: var(--t-mono);
  font-size: var(--t-small);
  color: var(--fg-2);
  letter-spacing: var(--t-track-wide);
  margin: 0 0 var(--s-2);
}

.r-themes-head__title {
  font-family: var(--t-serif);
  font-weight: 600;
  font-size: clamp(24px, 2.8vw, 34px);
  color: var(--fg-strong);
  font-variation-settings: "opsz" 96;
  margin: 0 0 var(--s-3);
  letter-spacing: -0.015em;
}

.r-themes-head__sub {
  color: var(--fg-2);
  font-size: var(--t-body);
  margin: 0;
  line-height: 1.55;
}

.r-themes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-5);
}

.r-theme {
  display: grid;
  grid-template-rows: 200px auto;
  background: var(--c-surface-strong);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  scroll-margin-top: var(--s-7);
}

.r-theme:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); }

.r-theme__figure { position: relative; overflow: hidden; background: #111; }

.r-theme__figure img { width: 100%; height: 100%; object-fit: cover; }

.r-theme__figure-ph {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--t-mono);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: var(--t-track-wide);
  background-image: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.04) 0 10px,
    transparent 10px 20px
  );
}

.r-theme__body { padding: var(--s-5) var(--s-6) var(--s-6); }

.r-theme__tag {
  appearance: none;
  border: 0;
  background: transparent;
  font-family: var(--t-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: var(--t-track-wide);
  color: var(--fg-2);
  margin-bottom: var(--s-2);
  display: inline-block;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.r-theme__tag:hover,
.r-theme__tag:focus-visible {
  color: var(--c-accent-teal);
}

.r-theme__title {
  font-family: var(--t-serif);
  font-weight: 600;
  font-size: 22px;
  line-height: 1.25;
  color: var(--fg-strong);
  margin: 0 0 var(--s-2);
  letter-spacing: -0.01em;
  font-variation-settings: "opsz" 48;
}

.r-theme__desc {
  font-size: var(--t-body);
  color: var(--fg-1);
  line-height: 1.55;
  margin: 0 0 var(--s-4);
  max-width: none;
}

.r-theme__papers {
  display: grid;
  gap: var(--s-2);
  padding-top: var(--s-3);
  border-top: 1px dashed var(--c-border);
  margin-top: var(--s-4);
}

.r-theme__paper {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--s-3);
  align-items: baseline;
  font-size: 13px;
}

.r-theme__paper-year {
  font-family: var(--t-mono);
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
}

.r-theme__paper-title {
  color: var(--fg-1);
  line-height: 1.4;
  border-bottom: 0;
}

.r-theme__paper-title:hover { color: var(--c-accent-teal); }

.r-theme__paper-venue {
  font-family: var(--t-serif);
  font-style: italic;
  color: var(--fg-2);
  font-size: 12px;
  font-variation-settings: "opsz" 12;
}

@media (max-width: 820px) {
  .r-themes { grid-template-columns: 1fr; }
}

/* =========================================================
   Flat paper list wrapper — preserves TOC sidebar + content
   from the original research.html layout.
   ========================================================= */
.r-full {
  padding-top: var(--s-7);
  border-top: 1px solid var(--c-border);
}

.r-full__head {
  margin: 0 0 var(--s-6);
  max-width: 68ch;
}

.r-full__num {
  font-family: var(--t-mono);
  font-size: var(--t-small);
  color: var(--fg-2);
  letter-spacing: var(--t-track-wide);
  margin: 0 0 var(--s-2);
}

.r-full__title {
  font-family: var(--t-serif);
  font-weight: 600;
  font-size: clamp(24px, 2.8vw, 34px);
  color: var(--fg-strong);
  font-variation-settings: "opsz" 96;
  margin: 0 0 var(--s-3);
  letter-spacing: -0.015em;
}

.r-full__sub {
  color: var(--fg-2);
  font-size: var(--t-body);
  margin: 0;
  line-height: 1.55;
}

/* Paper list chrome — scoped to .research-content inside .r-full.
   The markdown content from _research/index.md uses h2 for year
   headings, h3 for paper titles, and .tags/.pdf-link/.doi-link for
   badges. Restyle against new tokens while preserving structure. */
.research-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--s-7);
  margin-top: var(--s-5);
}

.toc-sidebar {
  position: sticky;
  top: calc(var(--s-7) + 16px);
  align-self: start;
}

.toc-nav h3 {
  font-family: var(--t-sans);
  font-size: var(--t-eyebrow);
  letter-spacing: var(--t-track-wide);
  text-transform: uppercase;
  color: var(--fg-2);
  font-weight: 700;
  margin: 0 0 var(--s-3);
}

.toc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }

.toc-list a {
  display: block;
  font-family: var(--t-mono);
  font-size: var(--t-small);
  color: var(--fg-2);
  padding: 4px 8px;
  border-radius: 4px;
  border-bottom: 0;
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.toc-list a:hover,
.toc-list a.active {
  color: var(--c-accent-teal);
  background: color-mix(in srgb, var(--c-accent-teal) 8%, transparent);
}

.research-content {
  max-width: none;
}

.research-content h2 {
  font-family: var(--t-serif);
  font-weight: 600;
  font-size: clamp(22px, 2.4vw, 28px);
  color: var(--fg-strong);
  letter-spacing: -0.01em;
  font-variation-settings: "opsz" 72;
  margin: var(--s-7) 0 var(--s-4);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--c-border);
  scroll-margin-top: var(--s-6);
}

.research-content h2:first-of-type { margin-top: 0; }

.research-content h3 {
  font-family: var(--t-serif);
  font-weight: 500;
  font-size: var(--t-body-lg);
  color: var(--fg-strong);
  letter-spacing: -0.005em;
  font-variation-settings: "opsz" 24;
  margin: var(--s-5) 0 var(--s-2);
  line-height: 1.35;
}

.research-content strong { color: var(--c-accent-coral); font-weight: 600; }

.research-content p { color: var(--fg-1); line-height: 1.65; max-width: 68ch; }

/* Highlights subhead (`#### Highlights`) and its bullet list. The
   legacy chain in styles.css points the list text at `--color-secondary`,
   which bridge.css remaps to `--c-paper-tint` — invisible on dark paper.
   `--c-brand-blue` also lacks a dark-mode override, so the heading reads
   too dim. Pin both to theme-aware values. */
.research-content h4 {
  color: var(--c-brand-blue);
}

[data-theme="dark"] .research-content h4 {
  color: #8fb8ff;
}

.research-content h4 + ul {
  border-left-color: var(--c-border-strong);
}

.research-content h4 + ul li {
  color: var(--fg-1);
}

/* Tag filter chip row — consecutive `<div class="tags">` siblings
   flow horizontally and wrap. The `_research/index.md` sort-by-topic
   block uses one `.tags` div per tag; inline-flex lets them queue up
   on a single line instead of stacking. Per-paper `.tags` rows still
   look right because each contains its own spans in one div. */
.research-content .tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 6px 6px 0;
  vertical-align: top;
}

/* Add a trailing break between the last sort-by-topic tag row and
   the blockquote that follows. Blockquote is block-level so already
   starts a new line — just give some breathing room. */
.research-content .tags + blockquote { margin-top: var(--s-4); }

/* Inside a paper card, the tags sit on their own line — the parent
   `.paper-container` gives them block context so this selector wins
   over the inline-flex default without overriding it. */
.research-content .paper-container .tags {
  display: flex;
  margin: var(--s-2) 0 var(--s-3);
}

.research-content .tags span {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: color-mix(in srgb, var(--c-brand-purple) 10%, transparent);
  color: var(--c-brand-purple);
  border: 1px solid color-mix(in srgb, var(--c-brand-purple) 22%, transparent);
  border-radius: var(--r-pill);
  font-family: var(--t-sans);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}

.research-content .tags span:hover {
  background: color-mix(in srgb, var(--c-accent-teal) 15%, transparent);
  color: var(--c-accent-teal);
  border-color: var(--c-accent-teal);
}

[data-theme="dark"] .research-content .tags span { color: #d99adc; }

/* Shield badges inline */
.research-content img[src*="img.shields.io"] {
  display: inline-block;
  vertical-align: middle;
  margin: 2px 4px 2px 0;
  height: 24px;
  width: auto;
}

/* Video embeds — research.js wraps iframes in .video-container */
.video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--fg-strong);
  border-radius: var(--r-md);
  overflow: hidden;
  margin: var(--s-4) 0;
}

.video-container iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Static images in the paper list sit at full width, paper-style */
.research-content img:not([src*="img.shields.io"]) {
  max-width: 100%;
  border-radius: var(--r-sm);
  margin: var(--s-3) 0;
}

@media (max-width: 900px) {
  .research-layout { grid-template-columns: 1fr; }

  .toc-sidebar { position: static; }
}
