/* Documentation-only styles: rendered RDoc prose (.ruby-documentation) and the
   code block area used for inline code examples, which takes its colours from
   the selected code theme (code_theme.css) rather than a palette of its own.
   Linked by layouts/docs.html.erb, the only layout that serves these classes.

   Fingerprinted rather than inlined: the block is fully static, so as a
   <style> it cost ~3.1KB of every document and again on every Turbo
   navigation. Nothing here overrides a Tailwind utility at equal specificity
   — every rule is a descendant of .ruby-documentation or a class Tailwind
   does not define — so unlike signature.css (see its header) the load order
   is not load-bearing.

   ----- Rendered documentation prose -----
   Colour comes from the theme tokens in signature.css, never from a palette of
   its own. Each token already switches on html.dark, so no rule below needs a
   dark override. */

/* anywhere, not break-word: a long constant link
   (OpenSSL::SSL::SSLContext#verify_hostname=) is one unbroken word, and only
   `anywhere` lets it shrink its box, so it pushed Net::HTTP 12px past a 390px
   screen. It breaks a word only when the word cannot fit; <pre> keeps
   white-space: pre and still scrolls. */
.ruby-documentation { line-height: 1.7; color: var(--ink-soft); overflow-wrap: anywhere; }

.ruby-documentation p { margin: 0.75rem 0; }

/* Measure. The prose column is ~900px, which ran text to ~105-110 characters
   a line — well past the 45-75 band. `ch`, not px, so the line holds ~70
   characters when the reader changes the text-size preference. Applied to the
   text blocks rather than the wrapper on purpose: pre and table are specimens,
   not prose, and clamping them only adds horizontal scrolling inside an
   already-scrolling code block. */
.ruby-documentation > :is(p, ul, ol, blockquote, h1, h2, h3) { max-width: 70ch; }
.ruby-documentation h1,
.ruby-documentation h2,
.ruby-documentation h3 { font-weight: 700; color: var(--ink); margin: 1.25rem 0 0.5rem; }
/* 1.5 / 1.25 / 1.1rem were ~1.2x steps — too close to separate three levels
   at a glance, so a long class page read as one undifferentiated column. */
.ruby-documentation h1 { font-size: 1.75rem; }
.ruby-documentation h2 { font-size: 1.3rem; }
.ruby-documentation h3 { font-size: 1.05rem; }
/* A hairline above h2 turns a heading into a section boundary, which is what
   it actually is on a page listing dozens of methods. Scoped to a following
   sibling so it never draws above the first element in the prose. */
.ruby-documentation * + h2 { border-top: 1px solid var(--rule); padding-top: 1.5rem; margin-top: 2rem; }
/* RDoc puts an empty legacy-anchor span before each heading, so a text that
   opens with an h2 (a guide such as Encodings, after its title's span) matched
   the rule above and drew a second line under the page's own divider. No
   line when only those spans come before the h2. */
.ruby-documentation > h2:not(:not(.legacy-anchor) ~ h2) { border-top: 0; padding-top: 0; margin-top: 0; }
/* Anchor jumps (e.g. from the "On this page" TOC) land below the sticky header. */
.ruby-documentation :is(h1, h2, h3)[id] { scroll-margin-top: 5rem; }

/* Links are underlined: colour alone cannot mark them. Red measured 2.62:1
   against the body text (axe link-in-text-block, 284 elements on 5 pages),
   and no red reaches 3:1 against it. --accent is the link token (6.02:1 on
   the card); --accent-fill is for fills. */
.ruby-documentation a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.ruby-documentation a:hover { text-decoration-thickness: 2px; }
/* RDoc wraps every prose heading's text in a self-anchor. That link rule has
   the same specificity as the heading rule above and comes later, so without
   this every section heading painted in link colour — a whole red phrase,
   which is precisely what the mark rule forbids. */
.ruby-documentation :is(h1, h2, h3) > a { color: inherit; text-decoration: none; }

.ruby-documentation ul,
.ruby-documentation ol { margin: 0.75rem 0; padding-left: 1.5rem; }
.ruby-documentation ul { list-style: disc; }
.ruby-documentation ol { list-style: decimal; }
.ruby-documentation li { margin: 0.25rem 0; }

.ruby-documentation table { margin: 0.75rem 0; border-collapse: collapse; }
.ruby-documentation th,
.ruby-documentation td { border: 1px solid var(--rule); padding: 0.35rem 0.6rem; }

/* Inline code. No font-family here: the `code, kbd, pre, samp` rule in
   signature.css already pins var(--font-mono), and an element selector beats
   the reading-font preference's inherited value, so code stays mono under
   serif/OpenDyslexic. Restating a stack here is what let this one drift to a
   generic ui-monospace while every other mono element moved on.
   Ink on a sunk ground, not coloured text — under the mark rule red is
   punctuation, so a whole identifier never carries it. */
.ruby-documentation :not(pre) > code {
  font-size: 0.85em;
  background-color: var(--sunk);
  color: var(--ink);
  padding: 0.1rem 0.35rem;
  border-radius: var(--r-control);
}
/* A linked chip takes the link's colour and underline. It was ink like a
   plain chip, so the String page's 182 linked chips and 193 plain ones
   looked the same. --accent is 4.63:1 on sunk. Same specificity as the rule
   above, so it must come after it. */
.ruby-documentation a > code { color: inherit; }

/* ----- Code block area (colors come from the selected code theme; see
   code_theme.css) ----- */
.ruby-documentation pre {
  background: var(--code-bg, #272822);
  color: var(--code-fg, #f8f8f2);
  padding: 1rem 1.25rem;
  margin: 1rem 0;
  border-radius: var(--r-panel);
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
}
.ruby-documentation pre code { background: transparent; padding: 0; color: inherit; }

/* Each runnable example's div.ruby carries its header bar server-rendered
   (spliced in by ApplicationHelper#ruby_documentation, so it's in the first
   paint); join it with the pre.ruby that follows into one block. The
   min-height + bar-coloured background still reserve the bar's exact space
   as a guard for the JS-fallback path (HTML rendered before the splice gets
   the bar injected on connect — see code_example_controller.js). */
.ruby-documentation .ruby[data-controller="code-example"] {
  margin-top: 1rem;
  min-height: 2.5rem;
  background-color: var(--code-bg-soft, #3e3d32);
  border-radius: var(--r-panel) var(--r-panel) 0 0;
}
/* The bar and the pre are one visual block, so the radius is split between
   them: bar takes the top corners, pre gives up its own top corners. */
.ruby-documentation .ruby[data-controller="code-example"] + pre.ruby {
  margin-top: 0;
  border-radius: 0 0 var(--r-panel) var(--r-panel);
}
.bg-code-header { background-color: var(--code-bg-soft, #3e3d32); }
.bg-code-background { background-color: var(--code-bg, #272822); }
.text-code-text { color: var(--code-fg, #f8f8f2); }

/* RDoc ruby-* syntax tokens, mapped to the selected code theme's palette */
.ruby-documentation .ruby-keyword   { color: var(--code-keyword); }
.ruby-documentation .ruby-constant  { color: var(--code-constant); }
/* A call name is weight as well as colour: Signature light gives constants,
   numbers and call names the same ink and separates the last by 600, so the
   other themes (400, or 500 in Signature dark) keep their hue rendering. */
.ruby-documentation .ruby-identifier{ color: var(--code-function); font-weight: var(--code-function-weight, 400); }
.ruby-documentation .ruby-ivar      { color: var(--code-variable); }
.ruby-documentation .ruby-string    { color: var(--code-string); }
.ruby-documentation .ruby-value     { color: var(--code-number); }
.ruby-documentation .ruby-regexp    { color: var(--code-regexp); }
.ruby-documentation .ruby-comment   { color: var(--code-comment); font-style: italic; }
.ruby-documentation .ruby-operator  { color: var(--code-operator); }
.ruby-documentation .ruby-node,
.ruby-documentation .ruby-name      { color: var(--code-fg); }
