/* Research Read — supplemental styles layered on top of read.css.
   Only affects pages built by the research renderer (body[data-research]).
   Uses read.css custom properties where available, with safe fallbacks. */

:root {
  --rr-accent: #f08c8c;
  --rr-defense: #34d399;
  --rr-line: rgba(128, 128, 128, .28);
}

/* Width alignment: on research pages the prose fills the SAME width as the
   diagrams (read.css otherwise constrains prose to the narrower --measure while
   figures span the full article column, which looks misaligned). */
.rr-article.rb-article > * { max-width: none; }

/* --- level / mode badges --- */
.rr-badge {
  display: inline-block;
  margin-left: .5rem;
  padding: .08em .55em;
  border-radius: 999px;
  font-size: .62em;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  vertical-align: middle;
  border: 1px solid var(--rr-line);
}
.rr-badge-l1 { background: rgba(52, 211, 153, .16); color: #10b981; }
.rr-badge-l2 { background: rgba(129, 140, 248, .18); color: #818cf8; }
.rr-badge-l3 { background: rgba(240, 140, 140, .18); color: var(--rr-accent); }
.rr-badge-mode { background: rgba(148, 163, 184, .16); color: #94a3b8; }

/* --- structured abstract --- */
.rr-abstract {
  border-left: 3px solid var(--rr-accent);
  background: rgba(148, 163, 184, .06);
  padding: .9rem 1.15rem;
  border-radius: 0 8px 8px 0;
  margin: 1.2rem 0 1.6rem;
}
.rr-abstract-h {
  font-size: .72rem !important;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin: 0 0 .4rem !important;
  opacity: .7;
  border: 0 !important;
  padding: 0 !important;
}
.rr-abstract p { margin: 0; font-size: .98rem; line-height: 1.6; }

/* --- KaTeX math block --- */
.rr-math {
  overflow-x: auto;
  padding: .5rem 0;
  margin: 1rem 0;
}

/* --- code / pseudocode ---
   Solid dark surface in BOTH themes (a dark code block on a light page is the
   conventional, high-contrast pattern) so text never washes out. */
figure.rr-code {
  margin: 1.3rem 0;
  border: 1px solid rgba(148, 163, 184, .30);
  border-radius: 10px;
  overflow: hidden;
  background: #0f172a;
}
figure.rr-code pre {
  margin: 0;
  padding: 1rem 1.15rem;
  overflow-x: auto;
  font-size: .86rem;
  line-height: 1.55;
}
/* Neutralize read.css's inline-code pill (.rb-article code) for the block code. */
.rb-article figure.rr-code pre code {
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  white-space: pre;
  color: #e2e8f0;
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: .86rem;
}
figure.rr-code figcaption {
  padding: .5rem 1.15rem;
  font-size: .78rem;
  color: #94a3b8;
  background: #0f172a;
  border-top: 1px solid rgba(148, 163, 184, .22);
}

/* --- results / comparison table --- */
.rr-tablewrap { overflow-x: auto; margin: 1.3rem 0; }
table.rr-table {
  border-collapse: collapse;
  width: 100%;
  font-size: .9rem;
}
table.rr-table caption {
  caption-side: bottom;
  text-align: left;
  padding-top: .5rem;
  font-size: .8rem;
  opacity: .7;
}
table.rr-table th,
table.rr-table td {
  border: 1px solid var(--rr-line);
  padding: .5rem .7rem;
  text-align: left;
  vertical-align: top;
}
table.rr-table thead th {
  background: rgba(148, 163, 184, .12);
  font-weight: 700;
}
table.rr-table tbody tr:nth-child(even) td { background: rgba(148, 163, 184, .05); }

/* --- paired countermeasures (threat-lab) --- */
.rr-defense {
  border: 1px solid rgba(52, 211, 153, .38);
  background: rgba(52, 211, 153, .08);
  border-radius: 10px;
  padding: .85rem 1.1rem;
  margin: 1.1rem 0 1.4rem;
}
.rr-defense-h {
  font-weight: 700;
  font-size: .82rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--rr-defense);
  margin-bottom: .4rem;
}
.rr-shield { margin-right: .35rem; }
.rr-defense ul { margin: 0; padding-left: 1.2rem; }
.rr-defense li { margin: .25rem 0; line-height: 1.55; }

/* --- references --- */
ol.rr-refs { font-size: .9rem; line-height: 1.6; padding-left: 1.4rem; }
ol.rr-refs li { margin: .3rem 0; }

/* --- practitioner toolkit --- */
.rr-kit-intro { opacity: .82; margin: .3rem 0 1rem; }
.rr-kit { display: grid; gap: 1rem; }
.rr-kit-card {
  border: 1px solid var(--rr-line);
  border-left: 3px solid var(--rr-accent);
  border-radius: 10px;
  padding: .9rem 1.1rem 1rem;
  background: rgba(148, 163, 184, .05);
}
.rr-kit-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.rr-kit-ic { font-size: 1.05rem; }
.rr-kit-title { font-weight: 700; font-size: 1rem; }
.rr-kit-kind {
  margin-left: auto;
  font-size: .62rem; letter-spacing: .06em; text-transform: uppercase;
  padding: .1em .55em; border-radius: 999px;
  border: 1px solid var(--rr-line); color: var(--rr-accent);
}
.rr-kit-blurb { margin: .35rem 0 .6rem; opacity: .8; font-size: .9rem; line-height: 1.5; }
.rr-kit-list { margin: .2rem 0 0; padding-left: 1.2rem; }
.rr-kit-list li { margin: .28rem 0; line-height: 1.55; }
.rr-kit-card figure.rr-code { margin: .4rem 0 0; }

.rr-ethics {
  margin: 2rem 0 1rem;
  padding: .9rem 1.15rem;
  border: 1px dashed rgba(240, 140, 140, .5);
  border-radius: 10px;
  background: rgba(240, 140, 140, .06);
  font-size: .86rem;
  line-height: 1.55;
}

/* --- research series index --- */
.rr-index-hero { padding: 2.2rem 0 1.2rem; }
ol.rr-index-list { list-style: none; padding: 0; margin: 1rem 0 3rem; }
.rr-index-list li {
  display: flex;
  gap: 1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--rr-line);
}
.rr-idx-n {
  flex: 0 0 auto;
  width: 2rem; height: 2rem;
  display: grid; place-items: center;
  border-radius: 999px;
  border: 1px solid var(--rr-line);
  font-weight: 700; font-size: .85rem;
}
.rr-idx-title { font-weight: 700; font-size: 1.05rem; text-decoration: none; }
a.rr-idx-title:hover { text-decoration: underline; }
.rr-idx-dek { margin: .3rem 0 0; opacity: .78; font-size: .92rem; line-height: 1.5; }
.rr-idx-soon {
  margin-left: .5rem; font-size: .68rem; text-transform: uppercase;
  letter-spacing: .06em; opacity: .6;
}
.rr-idx-planned { opacity: .62; }
.rr-idx-actions { margin-top: .6rem; display: flex; gap: .5rem; flex-wrap: wrap; }
.rr-idx-act {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .28rem .7rem; border-radius: 999px; text-decoration: none;
  font-size: .8rem; font-weight: 700; border: 1px solid var(--rr-line);
  color: var(--fg-primary, #e8eaed); background: rgba(148, 163, 184, .08);
}
.rr-idx-act:hover { border-color: var(--brand, #f08c8c); background: rgba(148, 163, 184, .16); }
.rr-idx-act.rr-act-read::before { content: "\1F4D6"; }
.rr-idx-act.rr-act-listen::before { content: "\1F3A7"; }
.rr-idx-act.rr-act-video::before { content: "\25B6"; }

/* --- series hero: intro + "at a glance" card (index pages only) --- */
.rr-hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 320px); gap: clamp(24px, 4vw, 48px); align-items: start; }
.rr-index-hero .rb-dek { max-width: 46rem; font-style: normal; font-size: clamp(1.02rem, 1.6vw, 1.12rem); line-height: 1.7; }
.rr-glance {
  border: 1px solid var(--rr-line); border-radius: 14px; padding: 18px 18px 16px;
  background: rgba(148, 163, 184, .06); font-family: var(--font-ui);
}
.rr-glance-k { margin: 0 0 12px; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-tertiary); }
.rr-glance-cta { display: grid; gap: 8px; margin-bottom: 14px; }
.rr-glance-btn {
  display: block; text-align: center; padding: .62rem .9rem; border-radius: 10px; text-decoration: none;
  font-weight: 700; font-size: .92rem; color: var(--fg-primary); border: 1px solid var(--rr-line);
  background: rgba(148, 163, 184, .08);
}
.rr-glance-btn:hover { border-color: var(--brand, #f08c8c); }
.rr-glance-primary { background: var(--brand, #f08c8c); border-color: transparent; color: #0d1117; }
.rr-glance-primary:hover { filter: brightness(1.08); }
.rr-glance-facts { margin: 0; display: grid; gap: 8px; font-size: .86rem; }
.rr-glance-facts > div { display: grid; grid-template-columns: 4.2rem 1fr; gap: 8px; }
.rr-glance-facts dt { color: var(--fg-tertiary); }
.rr-glance-facts dd { margin: 0; color: var(--fg-secondary); }
.rr-glance-facts a { color: inherit; }
.rr-glance-more { display: inline-block; margin-top: 12px; font-size: .84rem; font-weight: 600; color: var(--fg-secondary); }
@media (max-width: 860px) { .rr-hero-grid { grid-template-columns: 1fr; } }

/* --- Watch series page: episode cards --- */
ol.rr-ep-grid { list-style: none; padding: 0; margin: 1.4rem 0 3rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.rr-ep { display: flex; flex-direction: column; height: 100%; text-decoration: none; color: inherit; border: 1px solid var(--rr-line); border-radius: 14px; overflow: hidden; background: rgba(148, 163, 184, .05); }
.rr-ep:hover { border-color: var(--brand, #f08c8c); }
.rr-ep-thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: #10161d; }
.rr-ep-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rr-ep-play { position: absolute; inset: 0; margin: auto; width: 46px; height: 46px; border-radius: 999px; display: grid; place-items: center; background: rgba(0, 0, 0, .55); color: #fff; font-size: 1rem; opacity: 0; transition: opacity .15s; }
.rr-ep:hover .rr-ep-play, .rr-ep:focus-visible .rr-ep-play { opacity: 1; }
.rr-ep-dur { position: absolute; right: 8px; bottom: 8px; padding: 2px 7px; border-radius: 6px; background: rgba(0, 0, 0, .72); color: #fff; font: 600 .74rem var(--font-ui); }
.rr-ep-body { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px 14px; }
.rr-ep-n { font: 700 .7rem var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--fg-tertiary); }
.rr-ep-title { font-weight: 700; font-size: 1rem; line-height: 1.35; color: var(--fg-primary); }
.rr-ep-dek { font-size: .86rem; line-height: 1.5; color: var(--fg-secondary); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
