/* rl.css — the ONE reading layer (29-Oct-2026, Dr Shah: "fonts must be proper, the reading area properly organised, the screen must not jump,
 * the buttons all sit on top, headings sticky"). Every reading screen (Daily Learnings, KB reading notes, OT Guide, Instruments, the quiz's
 * explanations, Medicines compare, Sutra's detail) draws its text inside one [data-rl] block; rl.js adds the section rail and the scroll-spy.
 * No screen keeps its own copy of these rules (test_reading_layer.js; UI_STANDARD.md U11). The numbers come from UI_READING_BENCHMARK.md
 * (Wikipedia Vector-2022, MDN, Docusaurus, GitBook, AMBOSS, Kindle; NN/g and Butterick on measure, sticky headers and phone TOCs).
 *   Laptop (>= 1025 px): a left side rail of the sections (210 px, 224 px from 1600 px — the app's allowed widths, test_layout_rules.js), sticky 16 px under the top bar; the text column beside it;
 *     each section heading sticks while its section is on screen.
 *   Phone and tablet (<= 1024 px): one compact sticky bar "Section 3/7 ▾" (48 px) naming where he is; tap = the list of sections.
 *     Headings do not stick there (the bar already names the section, and a second strip eats the screen).
 *   Type: body 17 px at line-height 1.6, lines of at most 70 characters; Aa gives 19/1.55 and 21/1.5 (kept on the device, html[data-rl-size]).
 *   Secondary blocks (references, trial detail, long tables) may fold: <details class="rl-fold">; the core text never starts closed. */
.rl { --rl-top: 0px; --rl-bar: 0px; --rl-fs: 17px; --rl-lh: 1.6; --rl-bg: var(--rl-page, #fff); --rl-ink: #1b2733; --rl-soft: #5a6878; --rl-line: #e3e8ee;
  --rl-acc: #0B6B63; --rl-hover: #f1f5f8; --rl-on: #e6f2f0;
  display: block; max-width: 1100px; margin: 0 auto; color: var(--rl-ink); overflow-anchor: auto; }
html[data-rl-size="2"] .rl { --rl-fs: 19px; --rl-lh: 1.55; }
html[data-rl-size="3"] .rl { --rl-fs: 21px; --rl-lh: 1.5; }
html:has(.rl) { scrollbar-gutter: stable; }   /* a scrollbar that comes and goes never shifts the text sideways */
.rl-main { min-width: 0; font-size: var(--rl-fs); line-height: var(--rl-lh); }
.rl-main :is(p, li, dd, dt, blockquote, figcaption, summary, td, th) { font-size: inherit; line-height: inherit; }
.rl-main :is(p, li, dd, blockquote, figcaption) { max-width: 70ch; }
.rl-main :is(small, .rl-meta) { font-size: 15px; line-height: 1.5; color: var(--rl-soft); }
.rl-main h1 { font-size: calc(var(--rl-fs) + 9px); line-height: 1.25; margin: 6px 0 10px; }
.rl-main h3 { font-size: calc(var(--rl-fs) + 2px); line-height: 1.35; margin: 18px 0 6px; }
.rl-main h4 { font-size: var(--rl-fs); line-height: 1.4; margin: 16px 0 4px; }
.rl-main p { margin: 0 0 12px; }
.rl-main :is(ul, ol) { padding-left: 1.3em; margin: 0 0 12px; }
.rl-main table { font-size: calc(var(--rl-fs) - 1px); line-height: 1.5; }
.rl-main .rl-scroll { overflow-x: auto; max-width: 100%; }   /* a wide table scrolls inside its own box, never the page (U4.4) */
.rl-sec { margin: 0 0 28px; scroll-margin-top: calc(var(--rl-top) + var(--rl-bar) + 10px); }
.rl-h { z-index: 6; display: flex; align-items: center; gap: 8px; margin: 0 0 10px; padding: 10px 2px 8px; background: var(--rl-bg);
  border-bottom: 1px solid var(--rl-line); font-size: calc(var(--rl-fs) + 4px); line-height: 1.3; font-weight: 700; color: var(--rl-ink); }
.rl-h small { font-weight: 500; }
/* "#": copy a link to this section; the "Link copied" note has its own reserved space, so nothing moves */
.rl-link { flex: none; margin-left: auto; width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--rl-soft);
  font: inherit; font-size: 17px; font-weight: 700; cursor: pointer; opacity: 1; }
.rl-link:hover, .rl-link:focus-visible { opacity: 1; background: var(--rl-hover); }
.rl-copied { flex: none; width: 92px; font-size: 13px; font-weight: 600; color: var(--rl-acc); visibility: hidden; }
.rl-copied.on { visibility: visible; }
/* folded secondary blocks */
.rl-fold { margin: 0 0 12px; border: 1px solid var(--rl-line); border-radius: 10px; padding: 0 12px; }
.rl-fold > summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; color: #1e5aa8; }
.rl-fold[open] > summary { border-bottom: 1px solid var(--rl-line); margin-bottom: 8px; }
.rl-resume { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin: 0 0 10px; padding: 0 14px; border: 1px solid var(--rl-line);
  border-radius: 22px; background: var(--rl-hover); color: var(--rl-ink); font: inherit; font-size: 15px; cursor: pointer; }
.rl-resume b { color: var(--rl-acc); }

/* the rail */
.rl-rail { z-index: 12; background: var(--rl-bg); }
.rl-rail ol { list-style: none; margin: 0; padding: 0; }
.rl-rail a { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border-radius: 10px; color: var(--rl-ink); text-decoration: none;
  font-size: 15.5px; line-height: 1.3; font-weight: 600; }
.rl-rail a:hover { background: var(--rl-hover); }
.rl-rail a[aria-current] { background: var(--rl-on); color: var(--rl-acc); box-shadow: inset 3px 0 0 var(--rl-acc); }
.rl-grp { padding: 10px 12px 2px; font-size: 14px; font-weight: 700; color: var(--rl-ink); opacity: .7; }
.rl-rail .rl-x { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--rl-line); }
.rl-rail .rl-totop a { color: var(--rl-soft); font-weight: 500; }
.rl-tools { display: flex; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--rl-line); }
.rl-tools button, .rl-bar .rl-aa { min-height: 44px; min-width: 44px; padding: 0 12px; border: 1px solid var(--rl-line); border-radius: 10px; background: #fff;
  color: var(--rl-ink); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }
.rl-tools .rl-all { min-width: 118px; }   /* "Expand all" / "Collapse all" — fixed width, the button never resizes */
.rl-bar { display: none; }
.rl-solo > .rl-rail, .rl-solo > .rl-bar { display: none !important; }

@media (min-width: 1025px) {
  .rl { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 28px; align-items: start; }
  .rl.rl-solo { grid-template-columns: minmax(0, 1fr); }
  .rl-rail { position: sticky; top: calc(var(--rl-top) + 16px); max-height: calc(100vh - var(--rl-top) - 32px); overflow: auto; padding: 0 0 16px;
    -webkit-mask-image: linear-gradient(#000 calc(100% - 16px), transparent); mask-image: linear-gradient(#000 calc(100% - 16px), transparent); }
  .rl-rail::before { content: attr(data-rl-label); display: block; padding: 0 12px 6px; font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--rl-soft); }
  .rl-main { max-width: 760px; }
  .rl.rl-wide .rl-main { max-width: none; }
  .rl-h { position: sticky; top: var(--rl-top); }   /* the section heading stays at the top while its section is on screen */
}
@media (min-width: 1600px) { .rl { grid-template-columns: 224px minmax(0, 1fr); } }
@media (max-width: 1024px) {
  .rl { --rl-bar: 48px; }
  .rl.rl-solo { --rl-bar: 0px; }
  .rl-rail { display: none; }
  .rl-bar { display: flex; gap: 8px; position: sticky; top: var(--rl-top); z-index: 12; height: 48px; align-items: center; margin: 0 -12px 10px; padding: 0 12px;
    background: var(--rl-bg); border-bottom: 1px solid var(--rl-line); box-shadow: 0 2px 6px #0f2a3a0d; }
  .rl-bar .rl-cur { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; height: 40px; padding: 0 12px; border: 1px solid var(--rl-line); border-radius: 10px;
    background: #fff; color: var(--rl-ink); font: inherit; font-size: 16px; text-align: left; cursor: pointer; }
  .rl-bar .rl-cur b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .rl-bar .rl-cur :is(span, i) { flex: none; font-style: normal; color: var(--rl-soft); font-size: 14px; }
  .rl-bar .rl-aa { min-height: 40px; height: 40px; }
  .rl-bar ol { display: none; position: absolute; left: 12px; right: 12px; top: calc(100% + 2px); max-height: 65vh; overflow: auto; margin: 0; padding: 6px; list-style: none;
    background: #fff; border: 1px solid var(--rl-line); border-radius: 12px; box-shadow: 0 10px 28px #0f2a3a26; }
  .rl-bar.open ol { display: block; }
  .rl-bar ol a { display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 10px; color: var(--rl-ink); text-decoration: none; font-weight: 600; }
  .rl-bar ol a[aria-current] { background: var(--rl-on); color: var(--rl-acc); }
  .rl-bar ol .rl-x { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--rl-line); }
  .rl-main { padding: 0 2px; }
  .rl-main h1 { font-size: calc(var(--rl-fs) + 7px); }
  .rl-h { font-size: calc(var(--rl-fs) + 2px); }
  .rl-main h3 { font-size: calc(var(--rl-fs) + 1px); }
  .rl-copied { width: 0; overflow: hidden; }
  .rl-copied.on { width: 92px; }
}
/* phone "Top ↑": only on long pages, only after scrolling back up; fixed, so it never moves the text; above the save bar */
.rl-top { position: fixed; right: 14px; bottom: calc(env(safe-area-inset-bottom, 0px) + 84px); z-index: 30; min-height: 44px; padding: 0 16px; border: 1px solid var(--rl-line, #e3e8ee);
  border-radius: 22px; background: #fff; color: #1b2733; font: inherit; font-size: 15px; font-weight: 600; box-shadow: 0 4px 14px #0f2a3a26; cursor: pointer;
  opacity: 0; visibility: hidden; }
.rl-top.on { opacity: 1; visibility: visible; }
@media (min-width: 1025px) { .rl-top { display: none; } }
@media (prefers-reduced-motion: no-preference) { .rl-rail a, .rl-top { transition: background .15s, opacity .15s; } }

/* .rl[data-rl] (08-Nov-2026, Dr Shah on Daily Learnings: "too much space being wasted … fonts … too large & not reader friendly"): the reading variant — a book serif at 16 px / 1.55,
 * smaller headings, tighter section / paragraph gaps, a narrower rail and a wider text column. Aa still steps it up (18 / 20 px). Every reading block ([data-rl]) gets it, so all reading places match. */
.rl[data-rl] { --rl-fs: 16px; --rl-lh: 1.55; }
html[data-rl-size="2"] .rl[data-rl] { --rl-fs: 18px; --rl-lh: 1.55; }
html[data-rl-size="3"] .rl[data-rl] { --rl-fs: 20px; --rl-lh: 1.5; }
.rl[data-rl] .rl-main { font-family: Georgia, "Iowan Old Style", "Source Serif 4", "Noto Serif", "Times New Roman", serif; }
.rl[data-rl] .rl-main :is(h1, h2, h3, h4, small, button, summary, .rl-meta) { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.rl[data-rl] .rl-main :is(p, li, dd, blockquote, figcaption) { max-width: 75ch; }
.rl[data-rl] .rl-main h1 { font-size: calc(var(--rl-fs) + 5px); margin: 2px 0 6px; }
.rl[data-rl] .rl-main h3 { font-size: calc(var(--rl-fs) + 1px); margin: 10px 0 4px; }
.rl[data-rl] .rl-main h4 { margin: 10px 0 3px; }
.rl[data-rl] .rl-main p { margin: 0 0 8px; }
.rl[data-rl] .rl-main :is(ul, ol) { margin: 0 0 8px; }
.rl[data-rl] .rl-sec { margin: 0 0 12px; }
.rl[data-rl] .rl-h { padding: 6px 2px 5px; margin: 0 0 6px; font-size: calc(var(--rl-fs) + 2px); }
@media (min-width: 1025px) {
  .rl[data-rl] { grid-template-columns: 176px minmax(0, 1fr); gap: 20px; max-width: 1560px; }
  /* 12-Nov-2026 (Dr Shah: single-card Daily Learnings page squeezed into a 176px column): a block with no rail is solo and must be ONE column;
   * the rule above (same specificity, later than .rl.rl-solo) had put it back to rail + main, so the card sat in the empty rail column. */
  .rl[data-rl].rl-solo { grid-template-columns: minmax(0, 1fr); }
  .rl[data-rl] .rl-main { max-width: none; }
  /* 08-Nov-2026 (Dr Shah: "use the horizontal screen as much as possible without compromising experience"): prose keeps a readable line (~80 characters),
   * everything that is not a paragraph — tables, figures, cards, folds — takes the full width beside the rail, and on a wide screen long
   * sections that are only lists flow into two columns. */
  .rl[data-rl] .rl-main :is(p, li, dd, blockquote, figcaption) { max-width: 82ch; }
  .rl[data-rl] .rl-main :is(table, figure, .rl-scroll, .rl-fold, details, pre) { max-width: 100%; }
}
@media (min-width: 1600px) {
  .rl[data-rl] .rl-sec > :is(ul, ol):not([class]) { column-count: 2; column-gap: 40px; max-width: none; }
  .rl[data-rl] .rl-sec > :is(ul, ol):not([class]) > li { break-inside: avoid; max-width: none; }
}
@media (max-width: 1024px) { .rl[data-rl] .rl-main h1 { font-size: calc(var(--rl-fs) + 4px); } .rl[data-rl] .rl-h { font-size: calc(var(--rl-fs) + 1px); } }
@media print {
  .rl { display: block; } .rl-rail, .rl-bar, .rl-top, .rl-tools, .rl-link, .rl-copied, .rl-resume { display: none !important; }
  .rl-h { position: static; } .rl-main { font-size: 11pt; line-height: 1.45; max-width: none; }
  .rl-main :is(table, figure, img, pre) { break-inside: avoid; } .rl-h { break-after: avoid; }
}

/* 12-Nov-2026 (Dr Shah: "memory so Back returns to my last read paragraph … more features that improve reading"): reading-progress line and "N min left" */
.rl-prog { position: fixed; left: 0; top: 0; width: 100%; height: 3px; z-index: 60; background: var(--rl-acc, #0B6B63); transform-origin: 0 50%; transform: scaleX(0); opacity: 0; pointer-events: none; }
.rl-left { margin: 6px 12px 0; font-size: 13px; font-weight: 600; color: var(--rl-soft, #5a6878); }
.rl-bar .rl-left { margin: 0; flex: none; white-space: nowrap; }
@media print { .rl-prog, .rl-left { display: none !important; } }
/* 12-Nov-2026 (Dr Shah: "avoid unnecessary lengthening of the topics & too many headings, it ruins the reading experience"): the small headings inside a card
   (Context, The hidden reason, Strengths …) run into their first paragraph as a bold label instead of standing on a line of their own; one line saved per heading. */
.rl[data-rl] .rl-main :is(.idsub, .idwhy, .idorig-box, .idenblk, .idpro, .idcon) > h4 { display: inline; margin: 0 .45em 0 0; font-size: inherit; font-weight: 700; }
.rl[data-rl] .rl-main :is(.idsub, .idwhy, .idorig-box, .idenblk) > h4 + p { display: inline; }
.rl[data-rl] .rl-main :is(.idsub, .idwhy, .idorig-box, .idenblk) > h4 + p + p { margin-top: 6px; }
.rl[data-rl] .rl-main :is(.idsub, .idwhy, .idorig-box, .idenblk) { margin: 0 0 8px; }
