/* Study guide layout + typography on top of ../css/style.css (tokens, header, pill, buttons, tables). */
html { scroll-behavior: auto; }
/* The header (.hwrap/.hnav) is shared site-wide in ../css/style.css; .g-layout below mirrors its 280px + content grid. */
.g-menu { display: none; }
:root { --g-hdr: 57px; --hl: #f2d383; --hl-ink: #f2d383; --hl-tint: rgba(242, 211, 131, .16); }
:root[data-theme="light"] { --hl: #9c7a1f; --hl-ink: #6b5108; --hl-tint: rgba(156, 122, 31, .14); }
@media (prefers-color-scheme: light) { :root:not([data-theme]) { --hl: #9c7a1f; --hl-ink: #6b5108; --hl-tint: rgba(156, 122, 31, .14); } }

.g-layout { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); align-items: start; max-width: var(--page-w); margin: 0 auto; }
/* The sidebar's scroll box starts at the top of the viewport, behind the sticky header (negative margin pulls it up,
   padding pushes its content back below), so its contents slide under the frosted header exactly like the main column. */
.g-side { position: sticky; top: 0; height: 100vh; height: 100dvh; margin-top: calc(-1 * var(--g-hdr)); overflow-y: auto; overscroll-behavior: contain;
  padding: calc(var(--g-hdr) + var(--s4)) var(--s3) var(--s6) 16px; scroll-padding-top: calc(var(--g-hdr) + var(--s4)); border-right: 1px solid var(--line); font-size: 14px;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }  /* no track showing through the frosted header */
.g-main { max-width: var(--col-w); min-width: 0; width: 100%; margin: 0 auto; padding: var(--s5) 24px var(--s7) 40px; }  /* 40px left: room for the highlight buttons */
.g-main:focus { outline: none; }

/* search */
.g-search input { width: 100%; min-height: 40px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-btn); padding: 7px 12px; color: var(--ink); font-size: 14.5px; }
.g-search input::placeholder { color: var(--ink-3); }
.g-search input:hover { border-color: var(--line-strong); }
.g-results { margin-top: var(--s2); }
.g-res-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin-top: var(--s2); padding: 0 4px; font-size: 12.5px; color: var(--ink-3); }
.g-res-top[hidden] { display: none; }
.g-res-back { font: inherit; font-size: 13px; font-weight: 500; color: var(--accent); background: none; border: 0; padding: 4px 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: transparent; }
.g-res-back:hover { text-decoration-color: currentColor; color: var(--accent-hi); }
.g-res-back:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.g-res-group { margin: var(--s3) 0 var(--s1); font-size: 11.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); }
.g-res { display: block; padding: 8px 10px; border-radius: var(--r-btn); border: 1px solid transparent; color: var(--ink); text-decoration: none; cursor: pointer; line-height: 1.4; }
.g-res:hover { background: var(--bg-2); color: var(--ink); }
.g-res[aria-selected="true"] { background: var(--accent-tint); border-color: var(--accent); }
.g-res .r-path { display: block; font-size: 11.5px; color: var(--ink-3); }
.g-res .r-title { display: block; font-weight: 600; font-size: 13.5px; }
.g-res .r-snip { display: block; font-size: 12.5px; color: var(--ink-2); margin-top: 2px; overflow-wrap: anywhere; }
.g-res .r-key { font-family: var(--font-mono); font-weight: 600; margin-right: 6px; }
.g-res .r-exp { color: var(--ink-2); font-size: 13px; }
.g-empty { color: var(--ink-2); padding: var(--s2) 4px; }
mark { background: var(--warn-tint); color: var(--warn); border-radius: 3px; padding: 0 2px; }
mark.hit { background: var(--warn); color: var(--bg-0); }

/* tree */
.g-tree { margin-top: var(--s4); }
.g-tree ul { list-style: none; margin: 0; padding: 0; }
.nt-file > a { display: flex; align-items: baseline; gap: 6px; justify-content: space-between; padding: 6px 8px; border-radius: var(--r-chip); color: var(--ink-2); text-decoration: none; font-weight: 500; line-height: 1.35; }
.nt-file > a:hover { background: var(--bg-2); color: var(--ink); }
.nt-file.open > a { color: var(--ink); font-weight: 600; }
.nt-file.open > a[aria-current="page"] { background: var(--bg-2); }
/* .g-tree prefix: ".g-tree ul" resets margin/padding and would otherwise win over these indents */
.g-tree .nt-h2s { margin: 2px 0 var(--s2) 12px; padding-left: 6px; border-left: 1px solid var(--line); }
.nt-h2s a { display: flex; align-items: baseline; gap: 6px; padding: 4px 8px; border-radius: var(--r-chip); color: var(--ink-2); text-decoration: none; line-height: 1.35; font-size: 13.5px; }
.nt-h2s a:hover { background: var(--bg-2); color: var(--ink); }
.nt-h2s a.cur { color: var(--ink); background: var(--accent-tint); }
.g-tree .nt-h3s { display: none; margin: 0 0 2px 21px; padding-left: 6px; border-left: 1px solid var(--line); }
.nt-h2.active > .nt-h3s { display: block; }
.nt-h3s a { font-size: 13px; padding: 3px 8px; }
.dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); align-self: center; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.dot.none { background: transparent; border: 1px solid var(--line-strong); opacity: .6; }
.nt-h2 .dot.none { visibility: hidden; }

/* weak spots */
.g-weak { margin-top: var(--s5); padding-top: var(--s3); border-top: 1px solid var(--line); }
.g-weak h2 { font-size: 11.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); margin: 0 0 var(--s2); }
.g-weak ul { list-style: none; margin: 0; padding: 0; }
.g-weak li a { display: flex; gap: 8px; align-items: baseline; padding: 4px 8px; border-radius: var(--r-chip); text-decoration: none; color: var(--ink-2); line-height: 1.35; }
.g-weak li a:hover { background: var(--bg-2); color: var(--ink); }
.g-weak .w-pct { margin-left: auto; font-family: var(--font-mono); font-size: 12.5px; }
.g-weak p { color: var(--ink-3); margin: 0; font-size: 13px; }

/* content typography */
.g-doc h1 { font-size: 28px; margin: 0 0 var(--s4); }
.g-doc h2 { font-size: 21px; margin: var(--s7) 0 var(--s3); padding-top: var(--s4); border-top: 1px solid var(--line); }
.g-doc h1 + h2 { margin-top: var(--s5); }
.g-doc hr + h2 { margin-top: 0; padding-top: 0; border-top: 0; }
.g-doc h3 { font-size: 17px; margin: var(--s5) 0 var(--s2); }
.g-doc h4, .g-doc h5 { font-size: 15px; font-weight: 600; margin: var(--s4) 0 var(--s1); }
.g-doc h1, .g-doc h2, .g-doc h3, .g-doc h4, .g-doc h5, .g-doc tr[id] { scroll-margin-top: calc(var(--g-hdr) + 16px); }
.g-doc p, .g-doc li { line-height: 1.6; }
.g-doc ul, .g-doc ol { padding-left: 1.4em; margin: var(--s2) 0; }
.g-doc li { margin: 3px 0; }
.g-doc li > ul, .g-doc li > ol { margin: 2px 0; }
.g-doc hr { margin: var(--s5) 0; }
.g-doc blockquote { margin: var(--s3) 0; padding: var(--s2) var(--s4); background: var(--accent-tint); border-left: 3px solid var(--accent); border-radius: 0 var(--r-btn) var(--r-btn) 0; }
.g-doc blockquote p { margin: var(--s1) 0; }
.g-doc code { font-family: var(--font-mono); font-size: .9em; background: var(--bg-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; overflow-wrap: anywhere; }
.g-doc pre { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-btn); padding: var(--s3) var(--s4); overflow-x: auto; max-width: 100%; margin: var(--s3) 0; }
.g-doc pre code { background: none; border: 0; padding: 0; font-size: 13.5px; overflow-wrap: normal; white-space: pre; }
.g-doc .table-wrap { margin: var(--s3) 0; }
.g-doc table { font-size: 14px; }
.g-doc th, .g-doc td { vertical-align: top; }
.g-doc thead th { white-space: normal; }
.g-doc td { min-width: 5.5em; }
.g-doc tr.flash td, .g-doc tr.flash th { background: var(--accent-tint); }
.g-doc .hanchor { margin-left: 8px; font-weight: 400; font-size: .8em; text-decoration: none; color: var(--ink-3); opacity: 0; }
.g-doc :is(h1, h2, h3, h4, h5):hover > .hanchor, .g-doc .hanchor:focus-visible { opacity: 1; }
.g-doc .hanchor:hover { color: var(--accent); }
@media (hover: none) { .g-doc .hanchor { display: none; } }

/* acronym + objective references */
.tip { text-decoration: underline dotted; text-decoration-thickness: 1px; text-underline-offset: 3px; cursor: help; color: var(--ink-2); }
.tip:hover, .tip:focus-visible, .tip.on { color: var(--ink); }
.xref { font-family: var(--font-mono); font-size: .95em; }
.g-doc a { overflow-wrap: anywhere; }

/* tooltip */
.tooltip { position: fixed; z-index: 60; left: 0; top: 0; max-width: min(320px, calc(100vw - 16px)); background: var(--bg-3); color: var(--ink); border: 1px solid var(--line-strong);
  border-radius: var(--r-btn); padding: 8px 12px; font-size: 13.5px; line-height: 1.45; box-shadow: var(--shadow); overflow-wrap: anywhere; }
.tooltip[hidden] { display: none; }
.tooltip b { font-family: var(--font-mono); font-weight: 600; margin-right: 6px; }
.tooltip .t-mean { display: block; margin-top: 4px; font-size: 13px; color: var(--ink-2); }
.tooltip .t-more { display: block; margin-top: 4px; font-size: 12.5px; }
.tooltip::before { content: ""; position: absolute; left: var(--caret, 20px); width: 8px; height: 8px; margin-left: -4px; background: var(--bg-3); transform: rotate(45deg); }
.tooltip.below::before { top: -5px; border-left: 1px solid var(--line-strong); border-top: 1px solid var(--line-strong); }
.tooltip.above::before { bottom: -5px; border-right: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }

/* bottom: prev/next + footer */
.g-pn { display: flex; justify-content: space-between; gap: var(--s3); margin-top: var(--s7); flex-wrap: wrap; }
.g-pn a { flex: 1 1 220px; display: block; padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--r-card); background: var(--bg-1); text-decoration: none; color: var(--ink); min-width: 0; }
.g-pn a:hover { border-color: var(--line-strong); }
.g-pn small { display: block; color: var(--ink-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; }
.g-pn a.next { text-align: right; }
.g-foot { margin-top: var(--s5); color: var(--ink-3); font-size: 13px; }
.g-foot a { color: var(--ink-2); }
.g-backdrop { display: none; }

/* phone / narrow: sidebar is an off-canvas drawer */
@media (max-width: 899px) {
  .g-layout { display: block; }
  /* floating over the content, bottom-left (thumb reach); above the drawer (z 40) so it shows the back arrow while open */
  .g-menu { display: inline-flex; position: fixed; z-index: 45; left: 16px; bottom: max(16px, env(safe-area-inset-bottom, 0px)); align-items: center; justify-content: center;
    width: 48px; height: 48px; padding: 0; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--bg-2); color: var(--ink); cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .35); }
  .g-menu:hover, .g-menu[aria-expanded="true"] { background: var(--bg-3); }
  .g-main, .g-side { padding-bottom: 88px; }  /* keep the last lines and the drawer's last rows clear of the floating button */
  .g-menu:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  /* closed: hamburger (open the contents); open: back arrow (return to the page) */
  .g-menu .i-back, .g-menu[aria-expanded="true"] .i-open { display: none; }
  .g-menu[aria-expanded="true"] .i-back { display: block; }
  .g-side { position: fixed; z-index: 40; left: 0; top: var(--g-hdr); bottom: 0; height: auto; margin-top: 0; padding-top: var(--s4); scroll-padding-top: var(--s4); width: min(320px, 88vw); background: var(--bg-1); border-right: 1px solid var(--line-strong);
    transform: translateX(-102%); visibility: hidden; transition: transform .18s ease, visibility 0s linear .18s; }
  .g-side.open { transform: none; visibility: visible; transition: transform .18s ease; }
  .g-backdrop { position: fixed; z-index: 30; inset: var(--g-hdr) 0 0 0; background: rgba(0, 0, 0, .5); }
  .g-backdrop[hidden] { display: none; }
  .g-backdrop:not([hidden]) { display: block; }
  .g-main { padding: var(--s4) 16px 88px 40px; }
  .g-doc h1 { font-size: 24px; }
  .g-res { padding: 10px; }
  .nt-file > a, .nt-h2s a { min-height: 36px; }
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .g-menu { background: var(--hdr-bg); -webkit-backdrop-filter: blur(14px) saturate(1.15); backdrop-filter: blur(14px) saturate(1.15); }
}
@media (prefers-reduced-motion: reduce) { .g-side { transition: none !important; } }
@media print {
  :root, :root[data-theme] { --hl: #9c7a1f; --hl-ink: #6b5108; --hl-tint: rgba(156, 122, 31, .12); }
  .g-side, .g-backdrop, .tooltip, .g-pn, .g-menu { display: none; }
  .g-layout { display: block; }
  .g-main { max-width: none; width: auto; padding: 0; margin: 0; }
  /* tables: on paper there is no scrolling, so let headers wrap and the table shrink to the page instead of clipping the
     right edge (nowrap headers made the table wider than the sheet at 100%) */
  .table-wrap { overflow: visible; border-radius: 0; break-inside: auto; }
  table { width: 100%; max-width: 100%; }
  thead th { white-space: normal; }
  th, td { overflow-wrap: anywhere; }
  tr { break-inside: avoid; }
  .g-doc pre { white-space: pre-wrap; overflow: visible; }
  .g-doc h1, .g-doc h2, .g-doc h3 { break-after: avoid; }
  .tip { text-decoration: none; }
}

/* paragraph highlights */
.hl-block { position: relative; }
.hl-host { position: relative; padding-left: 32px !important; }  /* first cell of a highlightable row: the button sits in this padding, never over the key text */
.g-doc thead tr > :first-child { padding-left: 32px !important; }  /* keep the column label aligned with the padded cells below */
.hl-btn { position: absolute; left: -30px; top: 2px; width: 22px; height: 22px; padding: 0; display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  background: var(--bg-2); color: var(--ink-2); border: 1px solid var(--line-strong); border-radius: var(--r-chip); opacity: 0; z-index: 1; }
li.hl-block > .hl-btn { left: calc(-1.4em - 30px); }
.hl-host > .hl-btn { left: 5px; top: 5px; }
/* a nested list item shows only its own button, not its parent's as well */
.hl-block:hover:not(:has(.hl-block:hover)) > .hl-btn, .hl-row:hover .hl-btn, .hl-btn:focus-visible { opacity: 1; }
.hl-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.hl-btn[aria-pressed="true"] { color: var(--hl); border-color: var(--hl); background: var(--hl-tint); }
@media (hover: none) { .hl-btn { opacity: .45; } }
.g-doc .hl-on { background: var(--hl-tint); box-shadow: inset 3px 0 0 var(--hl); }
.g-doc :is(p, li).hl-on { padding-inline: 8px; margin-inline: -8px; }
.g-doc blockquote.hl-on { border-left-color: var(--hl); }
/* links on the tint: --accent is 4.2:1 there in light mode, --accent-hi is >= 4.7:1 (even on a nested, doubly tinted item) */
.g-doc .hl-on a, .hl-item a { color: var(--accent-hi); }
.g-doc tr.hl-on { background: none; box-shadow: none; }
.g-doc tr.hl-on > td, .g-doc tr.hl-on > th { background: var(--hl-tint); }
.g-doc tr.hl-on > :first-child { box-shadow: inset 3px 0 0 var(--hl); }
.g-doc tr.hl-on.flash > td, .g-doc tr.hl-on.flash > th { background: var(--accent-tint); }  /* arrival flash still shows on a highlighted row */
.hl-flash:not(tr) { outline: 2px solid var(--accent); outline-offset: 2px; }
/* a row flashes like an acronym-list arrival (cell outlines would draw one box per cell) */
.g-doc tr.hl-flash > td, .g-doc tr.hl-flash > th { background: var(--accent-tint); }
.g-doc [data-hl] { scroll-margin-top: calc(var(--g-hdr) + 16px); }
.hl-mark { display: inline-flex; vertical-align: -1px; margin-left: 8px; color: var(--hl); }
.hl-badge { flex: none; margin-left: auto; min-width: 18px; padding: 0 6px; border-radius: 999px; background: var(--hl-tint); color: var(--hl-ink); font-family: var(--font-mono); font-size: 11.5px; line-height: 18px; text-align: center; }
.g-hlink { display: flex; align-items: center; gap: 6px; margin-top: var(--s3); padding: 6px 8px; border-radius: var(--r-chip); color: var(--ink-2); text-decoration: none; font-weight: 500; }
.g-hlink svg { color: var(--hl); flex: none; }
.g-howlink { margin-top: var(--s3); } .g-howlink + .g-hlink { margin-top: 2px; }
.g-howlink svg { color: var(--accent); }
/* "How to use this guide": static page from a template in index.html, not part of the markdown */
.g-howto h1 { font-size: 28px; margin: 0 0 var(--s3); }
.g-howto h2 { font-size: 19px; margin: var(--s5) 0 var(--s2); }
.g-howto p, .g-howto li { line-height: 1.6; color: var(--ink-2); }
.g-howto .lede { font-size: 17px; color: var(--ink); }
.g-howto ul { padding-left: 22px; } .g-howto li { margin: 6px 0; } .g-howto li b, .g-howto p b { color: var(--ink); font-weight: 600; }
.g-howto kbd { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink); background: var(--bg-2); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 6px; }
.g-hlink:hover { background: var(--bg-2); color: var(--ink); }
.g-hlink.cur { background: var(--bg-2); color: var(--ink); }
.g-hlink .n { font-family: var(--font-mono); font-size: 12.5px; }

/* Highlighted page */
.g-hlpage h1 { font-size: 28px; margin: 0 0 var(--s3); }
.hl-toolbar { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-bottom: var(--s4); }
.hl-toolbar .btn[disabled] { opacity: .45; cursor: default; }
.hl-toolbar .danger { border-color: var(--bad); color: var(--bad); }
.hl-confirm { display: inline-flex; flex-wrap: wrap; gap: var(--s2); align-items: center; color: var(--ink-2); }
.hl-empty, .hl-note { color: var(--ink-2); max-width: 60ch; }
.hl-chap { font-size: 20px; margin: var(--s6) 0 var(--s2); padding-top: var(--s3); border-top: 1px solid var(--line); }
.hl-sec { font-size: 15px; margin: var(--s3) 0 var(--s2); color: var(--ink-2); }
.hl-items { list-style: none; margin: 0; padding: 0; }
.hl-item { margin: var(--s2) 0; padding: var(--s2) var(--s3); background: var(--hl-tint); border-left: 3px solid var(--hl); border-radius: 0 var(--r-btn) var(--r-btn) 0; }
.hl-text { margin: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; line-clamp: 6; overflow: hidden; overflow-wrap: anywhere; }
.hl-actions { display: flex; gap: var(--s3); align-items: center; margin-top: var(--s2); font-size: 13.5px; }
@media print { .hl-btn, .g-hlink { display: none; } }
