/* 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"; }
