/* The reading layout — round 166. Styles for assets/js/reader.js.
 *
 * Every rule is scoped under html.rd, which reader.js sets only on chapter
 * pages and only once it has run, so a page without the script is untouched.
 *
 * Three widths:
 *   phone (< 760px)     reading bar fixed at the BOTTOM (thumb reach): Chapters,
 *                        On this page, Emergency. Drawer opens as a bottom sheet.
 *   laptop (760-1439)   reading bar appears at the TOP once the page head has
 *                        scrolled away. Drawer opens as a left panel.
 *   wide (>= 1440px)    a left rail holds the chapters and "On this page"; the
 *                        page shifts right by the rail's width. At 1440 that
 *                        leaves 1,160px, so the text column is within a few
 *                        pixels of its normal width: round 158's rule (prose
 *                        spans the column) still holds, and no max-width is set.
 *
 * Colours are tokens only, so dark mode needs nothing extra. Nothing below 14px
 * (audit-layout check 10).
 */

/* ---- Head ----------------------------------------------------------------- */
html.rd .rd-hide{display:none}
html.rd .crumb .rd-meta{color:var(--ink-4);white-space:nowrap}
html.rd .crumb .rd-meta::before{content:"\00b7";margin:0 .6em;opacity:.6}
html.rd .rd-depth{display:inline-flex;align-items:stretch;flex-wrap:wrap;border:1px solid var(--line-2);
  border-radius:var(--r);overflow:hidden;background:var(--surface)}
html.rd .rd-depth-lab{display:flex;align-items:center;padding:0 11px;font-family:var(--f-data);font-size:14px;
  letter-spacing:.06em;text-transform:uppercase;color:var(--ink-4);background:var(--surface-2);
  border-right:1px solid var(--line)}
html.rd .rd-depth .lvl{border:0;border-radius:0;border-right:1px solid var(--line);margin:0;background:transparent}
html.rd .rd-depth .lvl:last-child{border-right:0}
html.rd .rd-depth .lvl-on{background:var(--ultra-pale);color:var(--ultra);font-weight:600}

/* The chapter list no longer sits in the page head. reader.js moves the same
   element into the drawer or the rail; these rules restyle it there. */
html.rd .guide-nav.rd-moved{background:none;border:0;padding:0}
html.rd .guide-nav.rd-moved .wrap{padding:0;margin:0}
html.rd .guide-nav.rd-moved .guide-chips{grid-template-columns:1fr;gap:4px}
/* core.css stretches a lone final card across 2 or 3 columns; in a one-column list
   that span would create phantom columns. */
html.rd .guide-nav.rd-moved .guide-chips > li:last-child{grid-column:auto}
html.rd .guide-nav.rd-moved .gc{padding:8px 10px}
html.rd .guide-nav.rd-moved .guide-subchips{margin:4px 0 6px 30px}
html.rd .guide-nav.rd-moved .guide-nav-search{margin:0 0 12px}
html.rd .guide-nav.rd-moved .guide-nav-label{margin:0 0 10px}
html.rd .guide-nav.rd-moved .guide-nav-aside{font-size:14px}

/* ---- Shared pieces -------------------------------------------------------- */
/* A jump from "On this page" lands below the reading bar, not under it. */
html.rd #main h2[id],html.rd #main h3[id]{scroll-margin-top:72px}
html.rd .rd-h{font-family:var(--f-data);font-size:14px;font-weight:500;letter-spacing:.12em;
  text-transform:uppercase;color:var(--ink-3);margin:0 0 10px}
html.rd .rd-toc{list-style:none;margin:0 0 18px;padding:0;border-left:2px solid var(--line)}
html.rd .rd-toc li{margin:0}
html.rd .rd-toc a{display:block;padding:6px 0 6px 14px;margin-left:-2px;border-left:2px solid transparent;
  font-family:var(--f-ui);font-size:14.5px;line-height:1.35;color:var(--ink-2);text-decoration:none}
html.rd .rd-toc a:hover{color:var(--ultra)}
html.rd .rd-toc a.rd-cur{border-left-color:var(--ultra);color:var(--ultra);font-weight:600}
html.rd .rd-ev{border:1px solid var(--line);border-radius:var(--r);padding:12px 14px;background:var(--surface)}
html.rd .rd-ev-bar{display:flex;height:9px;border-radius:99px;overflow:hidden;margin:0 0 10px;background:var(--line)}
html.rd .rd-ev-bar i{display:block;flex-basis:0}
html.rd .rd-ev-bar .rd-ev-s{background:var(--ok)}
html.rd .rd-ev-bar .rd-ev-m{background:var(--mid)}
html.rd .rd-ev-bar .rd-ev-e{background:var(--hi)}
html.rd .rd-ev-bar .rd-ev-n{background:var(--ink-4)}
html.rd .rd-ev-key{list-style:none;margin:0;padding:0;display:grid;gap:5px}
html.rd .rd-ev-key li{display:flex;justify-content:space-between;align-items:center;font-family:var(--f-data);
  font-size:14px;color:var(--ink-2)}
html.rd .rd-ev-note{margin:10px 0 0;font-family:var(--f-ui);font-size:14px}
html.rd .rd-empty{font-family:var(--f-ui);font-size:14.5px;color:var(--ink-3)}
html.rd .rd-related{margin:40px 0 0;padding-top:20px;border-top:1px solid var(--line)}
html.rd .rd-related-list{display:flex;flex-wrap:wrap;gap:8px}

/* ---- Reading bar ---------------------------------------------------------- */
html.rd .rd-bar{position:fixed;left:0;right:0;z-index:60;background:var(--surface);
  border-bottom:1px solid var(--line);box-shadow:0 2px 10px rgba(0,0,0,.06);
  top:0;transform:translateY(-110%);transition:transform .18s ease}
html.rd.rd-past-head .rd-bar{transform:none}
html.rd .rd-bar-in{display:flex;align-items:center;gap:8px;min-height:52px}
html.rd .rd-btn{display:inline-flex;align-items:center;gap:7px;flex:none;padding:7px 12px;
  font-family:var(--f-ui);font-size:14.5px;font-weight:500;color:var(--ink-2);background:var(--surface-2);
  border:1px solid var(--line);border-radius:var(--r);cursor:pointer;text-decoration:none}
html.rd .rd-btn:hover{border-color:var(--ultra);color:var(--ultra)}
html.rd .rd-btn em{font-style:normal;font-family:var(--f-data);font-size:14px;color:var(--ink-4)}
html.rd .rd-ico{font-size:15px;line-height:1}
html.rd .rd-bar-title{flex:1;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;
  font-family:var(--f-ui);font-size:14.5px;font-weight:600;color:var(--ink);padding:0 6px}
html.rd .rd-btn-em{color:var(--hi);background:var(--hi-bg);margin-left:auto}
html.rd .rd-progress{position:absolute;left:0;right:0;bottom:-1px;height:3px;background:transparent}
html.rd .rd-progress i{display:block;height:3px;width:0;background:var(--ultra)}

/* ---- Drawer --------------------------------------------------------------- */
html.rd .rd-veil{position:fixed;inset:0;z-index:70;background:rgba(10,12,14,.38)}
html.rd .rd-drawer{position:fixed;z-index:71;background:var(--paper);display:flex;flex-direction:column;
  box-shadow:0 10px 40px rgba(0,0,0,.25);top:0;bottom:0;left:0;width:min(420px,92vw)}
html.rd .rd-drawer[hidden],html.rd .rd-veil[hidden]{display:none}
html.rd .rd-drawer-head{display:flex;align-items:center;gap:8px;padding:12px 14px;border-bottom:1px solid var(--line);
  background:var(--surface)}
html.rd .rd-tabs{display:flex;gap:6px;flex:1}
html.rd .rd-tab{padding:7px 12px;font-family:var(--f-ui);font-size:14.5px;font-weight:500;color:var(--ink-3);
  background:none;border:1px solid transparent;border-radius:var(--r);cursor:pointer}
html.rd .rd-tab[aria-selected="true"]{color:var(--ink);background:var(--surface-2);border-color:var(--line)}
html.rd .rd-close{width:36px;height:36px;font-size:22px;line-height:1;color:var(--ink-3);background:none;
  border:1px solid var(--line);border-radius:var(--r);cursor:pointer}
html.rd .rd-pane{overflow:auto;padding:16px 16px 28px;flex:1;-webkit-overflow-scrolling:touch}
html.rd.rd-open{overflow:hidden}

/* ---- Rail (wide screens) -------------------------------------------------- */
html.rd .rd-rail{display:none}
html.rd.rd-wide body{padding-left:290px}
html.rd.rd-wide .rd-rail{display:flex;flex-direction:column;position:fixed;z-index:50;top:0;bottom:0;left:0;
  width:290px;background:var(--surface);border-right:1px solid var(--line)}
html.rd.rd-wide .rd-rail-ch{position:relative;flex:1 1 55%;overflow:auto;padding:18px 16px 12px;border-bottom:1px solid var(--line)}
html.rd.rd-wide .rd-rail-on{flex:1 1 45%;overflow:auto;padding:16px 16px 20px}
html.rd.rd-wide .rd-rail .guide-nav-label a{margin-left:0}
html.rd.rd-wide .rd-bar{transform:none;background:none;border:0;box-shadow:none;left:290px;pointer-events:none}
html.rd.rd-wide .rd-bar-in{display:none}

/* ---- Phone ---------------------------------------------------------------- */
@media (max-width:759px){
  html.rd body{padding-bottom:66px}
  html.rd .rd-bar{top:auto;bottom:0;transform:none;border-bottom:0;border-top:1px solid var(--line);
    box-shadow:0 -2px 10px rgba(0,0,0,.06);padding-bottom:env(safe-area-inset-bottom)}
  html.rd .rd-bar-in{display:grid;grid-auto-flow:column;grid-auto-columns:1fr;gap:0;min-height:58px;padding:0}
  html.rd .rd-bar-title{display:none}
  html.rd .rd-btn{flex-direction:column;gap:2px;justify-content:center;border:0;border-radius:0;background:none;
    padding:7px 4px;font-size:14px;color:var(--ink-2);margin:0}
  html.rd .rd-btn .rd-ico{font-size:18px}
  html.rd .rd-btn em{display:none}
  html.rd .rd-btn-em{color:var(--hi)}
  html.rd .rd-progress{top:-1px;bottom:auto}
  html.rd .rd-drawer{top:auto;left:0;right:0;width:auto;max-height:82vh;border-radius:16px 16px 0 0}
  /* The page head, tightened. */
  html.rd .topic-head{padding:20px 0 18px}
  html.rd .topic-head h1{margin:8px 0 10px}
  html.rd .topic-head .lede{font-size:17px}
  html.rd .topic-head .levels{padding-top:14px}
  html.rd .rd-depth-lab{display:none}
  html.rd .topic-body{padding-top:16px}
  html.rd .topic-body > .container > section:first-child{padding-top:0}
  /* The theme toggle keeps its icon; its label was what pushed it onto a line
     of its own. */
  html.rd .mnav{flex-wrap:nowrap;gap:14px}
  html.rd .mnav .theme #themeLbl{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
  html.rd .mnav .theme{padding:6px 9px}
  /* Masthead on chapter pages: the tagline goes, the search launcher keeps its
     place but loses the long label, which the reading bar's drawer covers. */
  html.rd .mark-sub{display:none}
  html.rd .mast-in{padding-top:10px}
  html.rd .cmd-launch{margin-bottom:10px;padding-top:8px;padding-bottom:8px}
}

@media print{
  html.rd .rd-bar,html.rd .rd-rail,html.rd .rd-drawer,html.rd .rd-veil,html.rd .rd-related{display:none}
  html.rd.rd-wide body{padding-left:0}
}
