/* ============================================================
   RNA folding guide — TAU-Israel iGEM 2026 wiki
   ------------------------------------------------------------
   Loaded only by wiki/pages/rna-folding-guide.html (extra_head).
   Everything is scoped under .rg, so nothing here can reach
   another page. Builds on style.css tokens: callouts and tables
   are the site's own (.bd-callout, .table); this file only adds
   what the guide has and the rest of the wiki doesn't — code
   blocks, the live widgets, the robot and the part dividers.
   ============================================================ */

.rg {
  /* The four bases. Used by the widgets' SVG (rna-folding-guide.js)
     and by the legend swatches; the same four everywhere. */
  --A: #E0A32E;
  --U: #DE5B49;
  --G: #0F8A86;
  --C: #6D5BD0;

  /* Short names the guide's inline styles and script were written
     against, pointed at the site's tokens. */
  --mono: var(--font-mono);
  --muted: var(--ink-2);
  --rule: var(--paper-edge);

  --rg-code-bg: #121A2B;
  --rg-code-fg: #DCE4EE;
  --rg-code-dim: #8FA0B8;
}

/* ------------------------------------------------------------
   Opening
   ------------------------------------------------------------ */
.rg-crumb {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-2);
  margin: 0 0 1.25rem;
}

.rg-hero-fig {
  max-width: 760px;
  margin: 0 auto;
}

.rg-hero-fig img {
  display: block;
  width: 100%;
  height: auto;
}

.rg-hero-fig figcaption {
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--ink-2);
  margin-top: 0.75rem;
}

.rg-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  margin-top: 0.75rem;
}

.rg-sw {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.rg-sw i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.rg-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.75rem;
}

.rg-pill {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius-pill);
  color: var(--ink-2);
  background: var(--paper-sink);
}

.rg-pill--link {
  border: var(--border-w) solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--shadow-sticker-sm);
}

.rg-pill--link:hover,
.rg-pill--link:focus-visible {
  background: var(--ink);
  color: var(--paper);
}

/* A control whose target doesn't exist yet: visible, but inert. */
.rg-pill--link.is-disabled,
.rg-pill--link.is-disabled:hover {
  background: var(--paper-sink);
  color: var(--ink-3);
  border-color: var(--ink-3);
  box-shadow: none;
  font-weight: 400;
  cursor: not-allowed;
}

/* ------------------------------------------------------------
   Parts and chapters
   ------------------------------------------------------------ */
.rg-part {
  margin-top: 5rem;
  padding-top: 1.75rem;
  border-top: var(--border-w-bold) solid var(--ink);
}

.rg-part--first { margin-top: 3rem; }

.rg-part__lbl {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.rg-part h2 { margin: 0; }

.rg-chapter { padding-top: 3rem; }

/* Chapters own the float they contain, so a robot never hangs into
   the next chapter. */
.rg-chapter::after {
  content: "";
  display: block;
  clear: both;
}

.rg-chapter > h3 {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  margin: 0 0 0.75rem;
}

.rg-num {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--accent);
}

.rg-sub {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 2rem 0 0.5rem;
}

.rg-chapter li { margin: 0.4rem 0; }

.rg-lede {
  font-size: 1.1rem;
  color: var(--ink);
}

.rg-part .rg-lede { margin: 0.85rem 0 0; }

/* A short table with its callout beside it. Stacked until the column
   is wide enough for both. */
@media (min-width: 1200px) {
  .rg-pair {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: 2rem;
    align-items: center;
    margin: 1.5rem 0;
  }

  .rg-pair > *,
  .rg-pair .table { margin: 0; }

  /* Running text beside a callout reads from the top, not the middle. */
  .rg-pair--text { align-items: start; }
  .rg-pair--text > div > :last-child { margin-bottom: 0; }
}

/* Tables: the "looks like" column is dot-bracket, which must not wrap. */
.rg-table { font-size: 0.9375rem; }
.rg-table code { white-space: nowrap; }

/* ------------------------------------------------------------
   Robot — floats beside the first paragraphs of a chapter
   ------------------------------------------------------------ */
.rg-robot {
  float: right;
  width: 160px;
  margin: 0.25rem 0 1.1rem 1.6rem;
}

.rg-robot.rg-left {
  float: left;
  margin: 0.25rem 1.6rem 1.1rem 0;
}

.rg-robot img {
  display: block;
  width: 100%;
  height: auto;
}

.rg-robot img.rg-flip { transform: scaleX(-1); }

.rg-robot figcaption {
  font-size: 0.8125rem;
  font-style: italic;
  line-height: 1.45;
  color: var(--ink-2);
  margin-top: 0.5rem;
}

/* Text that stays in its own column beside the robot instead of
   wrapping underneath it; whatever follows starts below both. */
.rg-beside { display: flow-root; }
.rg-beside > :first-child { margin-top: 0.25rem; }
.rg-beside + * { clear: both; }

@media (max-width: 767.98px) {
  .rg-robot,
  .rg-robot.rg-left {
    float: none;
    width: 150px;
    margin: 1.1rem auto;
  }
}

/* ------------------------------------------------------------
   Code blocks
   ------------------------------------------------------------ */
.rg-code {
  background: var(--rg-code-bg);
  color: var(--rg-code-fg);
  border: var(--border-w) solid var(--ink);
  border-radius: var(--radius-md);
  margin: 1.25rem 0;
  overflow: hidden;
}

.rg-code-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.rg-code-top span {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--rg-code-dim);
}

.rg-copy {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  background: transparent;
  color: var(--rg-code-dim);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 5px;
  padding: 0.15rem 0.55rem;
  cursor: pointer;
}

.rg-copy:hover,
.rg-copy:focus-visible {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.55);
}

.rg-code pre {
  margin: 0;
  padding: 0.9rem;
  overflow-x: auto;
  font-size: 0.8125rem;
  line-height: 1.62;
  color: inherit;
}

.rg-code .rg-c { color: #8FA0B8; }
.rg-code .rg-s { color: #8FD18C; }
.rg-code .rg-k { color: #E8A6C0; }
.rg-code .rg-o { color: #8FC7F0; }

/* ------------------------------------------------------------
   Widgets
   ------------------------------------------------------------ */
.rg-widget {
  background: var(--paper);
  border: var(--border-w) solid var(--ink);
  border-radius: var(--radius-md);
  margin: 1.75rem 0;
  overflow: hidden;
}

.rg-widget-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem 0.75rem;
  padding: 0.75rem 1.1rem;
  background: var(--paper-sink);
  border-bottom: 1px solid var(--paper-edge);
}

.rg-widget-top h4 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  margin: 0;
  color: var(--ink);
}

.rg-hint {
  font-size: 0.78rem;
  color: var(--ink-2);
}

.rg-widget-body { padding: 1.1rem; }

.rg-ctrl {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.rg-ctrl label {
  font-size: 0.8125rem;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.rg input[type="text"] {
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  letter-spacing: 0.08em;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--ink-3);
  border-radius: var(--radius-sm);
  background: var(--paper-sink);
  color: var(--ink);
  width: 100%;
  max-width: 420px;
}

.rg input[type="range"] { accent-color: var(--G); }

.rg-btn {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--ink);
  color: var(--paper);
  border: var(--border-w) solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.85rem;
}

.rg-btn.rg-ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--ink-3);
  font-weight: 600;
}

.rg-btn.rg-ghost:hover,
.rg-btn.rg-ghost:focus-visible {
  border-color: var(--ink);
  color: var(--ink);
}

.rg-readout {
  display: flex;
  gap: 1.4rem;
  flex-wrap: wrap;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--paper-edge);
}

.rg-readout div { min-width: 110px; }

.rg-readout .rg-k {
  display: block;
  font-size: 0.75rem;
  color: var(--ink-2);
}

.rg-readout .rg-v {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--ink);
}

.rg-scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.rg-widget svg {
  display: block;
  max-width: none;
  height: auto;
}

/* Output drawn by the script is plain text on the widget's own
   surface, not a site code chip. */
.rg-widget pre {
  background: none;
  border: 0;
  padding: 0;
}

.rg-baseA { fill: var(--A); }
.rg-baseU { fill: var(--U); }
.rg-baseG { fill: var(--G); }
.rg-baseC { fill: var(--C); }

.rg-legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-2);
  margin-top: 0.6rem;
}

.rg-legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  margin-right: 5px;
}

/* Ensemble table: rank · structure · energy · share */
.rg-structrow {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.75rem;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--paper-edge);
}

.rg-structrow .rg-bar {
  height: 7px;
  background: var(--paper-edge);
  border-radius: var(--radius-pill);
  overflow: hidden;
  min-width: 60px;
}

.rg-structrow .rg-bar i {
  display: block;
  height: 100%;
  background: var(--C);
}

.rg-structrow .rg-db {
  white-space: pre;
  overflow-x: auto;
}

/* ------------------------------------------------------------
   Closing
   ------------------------------------------------------------ */
.rg-outro {
  clear: both;
  margin-top: 5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--paper-edge);
  font-size: 0.875rem;
  color: var(--ink-2);
}
