/* Riboswitches: chart tokens (validated categorical slots 1-3 + chart chrome) layered on /assets/site.css */

.rs {
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --nha: #2a78d6;    /* categorical slot 1 */
  --duf: #eb6834;    /* slot 2 */
  --comb: #1baf7a;   /* slot 3 */
  --lina: #52514e;   /* neutral: the model that is not one of the three entities above */
  --off: #d6d5ce;    /* bars outside the E-value threshold */
}
@media (prefers-color-scheme: dark) {
  .rs {
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --ink-3: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --nha: #3987e5;
    --duf: #d95926;
    --comb: #199e70;
    --lina: #c3c2b7;
    --off: #383835;
  }
}

.rs .lede { font-size: 1.05rem; }
.rs .credit { color: var(--muted); font-size: .92rem; }

/* R2R figures: the originals have a transparent background and black text, so they sit on a white card in both modes */
.rs figure { margin: 1rem 0; }
.rs figure img { background: #fff; padding: .5rem; border-radius: 4px; display: block; }
.rs figcaption { color: var(--muted); font-size: .9rem; margin-top: .35rem; }
.rs .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.rs .pair figure { margin: .5rem 0; }
.rs .quad { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem 1rem; }
.rs .quad figure { margin: .25rem 0; }
@media (max-width: 34rem) { .rs .pair, .rs .quad { grid-template-columns: 1fr; } }

.rs ol.steps { padding-left: 0; list-style: none; counter-reset: step; }
.rs ol.steps > li { counter-increment: step; margin: 1.6rem 0; }
.rs ol.steps > li > h3 { margin: 0 0 .3em; }
.rs ol.steps > li > h3::before { content: counter(step) ". "; color: var(--muted); }

/* chart frame ---------------------------------------------------------- */

.rs .chart {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: .8rem .9rem;
  margin: 1rem 0;
  position: relative;
}
.rs .chart h4 { margin: 0 0 .15rem; font-size: 1rem; }
.rs .chart .sub { margin: 0 0 .6rem; color: var(--muted); font-size: .88rem; }
.rs svg { display: block; width: 100%; height: auto; overflow: visible; }
.rs svg text { fill: var(--ink-2); font-size: 11px; font-family: inherit; }
.rs svg .tick, .rs svg .axis-title { fill: var(--ink-3); }
.rs svg .grid { stroke: var(--grid); stroke-width: 1; }
.rs svg .axis { stroke: var(--axis); stroke-width: 1; }
.rs svg .ring { stroke: var(--surface); stroke-width: 2; }
.rs svg .hit { fill: transparent; }
.rs svg .row:hover .wash, .rs svg .row:focus .wash { fill: var(--grid); }
.rs svg .row:focus { outline: none; }
.rs svg .wash { fill: transparent; }
.rs svg .marker { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; }
.rs svg .marker-label { fill: var(--ink-2); }

.rs .c-nha  { fill: var(--nha); }
.rs .c-duf  { fill: var(--duf); }
.rs .c-comb { fill: var(--comb); }
.rs .c-lina { fill: var(--lina); }
.rs .c-on   { fill: var(--ink-2); }
.rs .c-off  { fill: var(--off); }
.rs .c-dot  { fill: var(--ink-2); }
.rs .c-band { fill: var(--grid); opacity: .5; }

.rs .legend { display: flex; flex-wrap: wrap; gap: .25rem 1.1rem; margin: 0 0 .5rem; padding: 0; list-style: none; font-size: .88rem; color: var(--ink-2); }
.rs .legend li { display: flex; align-items: center; gap: .4rem; }
.rs .swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex: none; }
.rs .sw-nha { background: var(--nha); }
.rs .sw-duf { background: var(--duf); }
.rs .sw-comb { background: var(--comb); }
.rs .sw-lina { background: var(--lina); }

/* funnel table with in-cell bars */
.rs table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.rs th, .rs td { text-align: left; padding: .35rem .5rem .35rem 0; vertical-align: bottom; }
.rs th { font-weight: normal; color: var(--muted); border-bottom: 1px solid var(--rule); }
.rs td.n { font-variant-numeric: tabular-nums; }
.rs #funnel { overflow-x: auto; }
.rs .funnel td { padding-top: .55rem; }
.rs .funnel .cell { min-width: 4.5rem; }
.rs .funnel .num { display: block; font-variant-numeric: tabular-nums; color: var(--fg); }
.rs .funnel .bar { display: block; height: 6px; border-radius: 0 3px 3px 0; margin-top: 2px; min-width: 2px; }
.rs .funnel .bar.c-nha { background: var(--nha); }
.rs .funnel .bar.c-duf { background: var(--duf); }
.rs .funnel .bar.c-comb { background: var(--comb); }
.rs .funnel .bar.c-lina { background: var(--lina); }
.rs .funnel th.model, .rs .funnel td.model { white-space: nowrap; padding-right: .8rem; }
@media (max-width: 34rem) {
  .rs .funnel { font-size: .82rem; }
  .rs .funnel th.model, .rs .funnel td.model { white-space: normal; }
}

/* controls */
.rs .controls { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; align-items: center; margin: 0 0 .6rem; }
.rs .controls label { display: inline-flex; align-items: center; gap: .5rem; margin: 0; }
.rs input[type="range"] { width: 12rem; padding: 0; border: 0; background: none; accent-color: var(--ink-2); }
.rs .readout { margin: .2rem 0 .4rem; font-size: .95rem; }
.rs .readout strong { font-size: 1.15rem; font-weight: 600; }
.rs .takeaway { margin: .6rem 0 0; font-size: .92rem; color: var(--ink-2); }

.rs details { margin-top: .5rem; font-size: .88rem; }
.rs details summary { cursor: pointer; color: var(--muted); }
.rs details table { margin-top: .4rem; }

/* tooltip: values lead, names follow */
.rs-tip {
  position: fixed; z-index: 10; pointer-events: none; display: none;
  max-width: 16rem; padding: .4rem .6rem; border-radius: 4px;
  background: var(--bg); color: var(--fg); border: 1px solid var(--rule);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18); font-size: .85rem; line-height: 1.35;
}
.rs-tip .tt { color: var(--muted); margin-bottom: .15rem; }
.rs-tip .row { display: flex; align-items: center; gap: .4rem; }
.rs-tip .key { width: 12px; height: 3px; border-radius: 2px; flex: none; }
.rs-tip .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.rs-tip .k-nha { background: var(--nha); } .rs-tip .k-duf { background: var(--duf); } .rs-tip .k-comb { background: var(--comb); }
.rs-tip { --nha: #2a78d6; --duf: #eb6834; --comb: #1baf7a; }
@media (prefers-color-scheme: dark) { .rs-tip { --nha: #3987e5; --duf: #d95926; --comb: #199e70; } }

/* journey */
.rs ol.phases { list-style: none; padding: 0; margin: .5rem 0; counter-reset: ph; }
.rs ol.phases li { counter-increment: ph; margin: .5rem 0; padding-left: 1.6rem; position: relative; }
.rs ol.phases li::before { content: counter(ph); position: absolute; left: 0; top: .05rem; width: 1.15rem; height: 1.15rem; border-radius: 50%; background: var(--accent-bg); color: var(--ink-2); font-size: .75rem; text-align: center; line-height: 1.15rem; }
.rs ol.phases .when { color: var(--muted); font-size: .88rem; }

@media (forced-colors: active) {
  .rs svg .c-nha, .rs svg .c-duf, .rs svg .c-comb, .rs svg .c-lina { stroke: CanvasText; }
}
