/* HR Knowledge Book: web edition.
   Same direction as the PDFs: Source Serif 4 for reading, Source Sans 3 for structure,
   Atkinson Hyperlegible for revision notes, one teal accent, muted red only for corrections.
   Dials: ENERGY 1 / RHYTHM 2 / MOTION 1 (hover and focus states only). */

@font-face { font-family: "Source Serif 4"; src: url(fonts/SourceSerif4-400.ttf); font-weight: 400; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url(fonts/SourceSerif4-400i.ttf); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url(fonts/SourceSerif4-600.ttf); font-weight: 600; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url(fonts/SourceSerif4-600i.ttf); font-weight: 600; font-style: italic; font-display: swap; }
@font-face { font-family: "Source Sans 3"; src: url(fonts/SourceSans3-400.ttf); font-weight: 400; font-display: swap; }
@font-face { font-family: "Source Sans 3"; src: url(fonts/SourceSans3-400i.ttf); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Source Sans 3"; src: url(fonts/SourceSans3-600.ttf); font-weight: 600; font-display: swap; }
@font-face { font-family: "Source Sans 3"; src: url(fonts/SourceSans3-700.ttf); font-weight: 700; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url(fonts/AtkinsonHyperlegible-400.ttf); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url(fonts/AtkinsonHyperlegible-400i.ttf); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url(fonts/AtkinsonHyperlegible-700.ttf); font-weight: 700; font-display: swap; }

:root {
  --bg: #fbfaf7; --surface: #ffffff; --panel: #eef1ef; --ink: #1f2124; --soft: #3b3f44; --muted: #5a616b;
  --rule: #d8dde2; --control: #7a838c; --acc: #0b5560; --acc-soft: #dbe9e9; --fix: #9b2c1f; --fix-rule: #e3c3bd; --th: #e6ebe9;
  --serif: "Source Serif 4", Georgia, serif; --sans: "Source Sans 3", "Segoe UI", Arial, sans-serif;
  --notes: "Atkinson Hyperlegible", Verdana, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15181b; --surface: #1c2024; --panel: #222a2c; --ink: #e8e6e1; --soft: #cfcdc8; --muted: #a3a8ae;
    --rule: #343b41; --control: #7f8891; --acc: #6fc3c9; --acc-soft: #20393b; --fix: #f0a090; --fix-rule: #6a3a33; --th: #263033;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15181b; --surface: #1c2024; --panel: #222a2c; --ink: #e8e6e1; --soft: #cfcdc8; --muted: #a3a8ae;
  --rule: #343b41; --control: #7f8891; --acc: #6fc3c9; --acc-soft: #20393b; --fix: #f0a090; --fix-rule: #6a3a33; --th: #263033;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 76px; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--serif); font-size: 1.0625rem; line-height: 1.6;
       font-variant-numeric: lining-nums tabular-nums; }
a { color: var(--acc); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--acc); outline-offset: 2px; border-radius: 2px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }

/* Top bar */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
       padding: 10px max(20px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left));
       background: var(--surface); border-bottom: 1px solid var(--rule); font-family: var(--sans); }
.brand { font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.top button { font: 600 15px var(--sans); color: var(--ink); background: transparent; border: 1px solid var(--control);
              border-radius: 6px; min-height: 44px; min-width: 44px; padding: 0 12px; cursor: pointer;
              display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.ib svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ib svg .fill { fill: currentColor; stroke: none; }
.top button[aria-pressed="true"] { background: var(--acc-soft); }
.top button:hover { background: var(--panel); }
.menu { display: none; }
.search input::placeholder { color: var(--muted); opacity: 1; }
.search { position: relative; flex: 1; max-width: 520px; margin-left: auto; }
.search input { width: 100%; min-height: 44px; font: 16px var(--sans); color: var(--ink); background: var(--bg);
                border: 1px solid var(--control); border-radius: 6px; padding: 0 12px; }
.results { position: absolute; top: 50px; left: 0; right: 0; max-height: 70vh; overflow: auto; margin: 0; padding: 6px;
           list-style: none; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px;
           box-shadow: 0 12px 32px rgba(0,0,0,.18); }
.results li a { display: block; padding: 10px 12px; border-radius: 6px; text-decoration: none; color: var(--ink); }
.results li a:hover, .results li a:focus { background: var(--panel); }
.results .rt { font-weight: 600; display: block; }
.results .rc { font-size: 13px; color: var(--muted); display: block; }
.results .rx { font-size: 14px; color: var(--soft); display: block; margin-top: 2px; }
.results mark { background: var(--acc-soft); color: inherit; padding: 0 1px; }
.results .empty { padding: 10px 12px; color: var(--muted); }

/* Shell */
.shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.nav { position: sticky; top: 65px; height: calc(100vh - 65px); overflow: auto; padding: 16px 12px 40px;
       border-right: 1px solid var(--rule); font-family: var(--sans); font-size: 15px; background: var(--bg); }
.chapters { list-style: none; margin: 0; padding: 0; }
.chapters li { display: flex; align-items: baseline; gap: 6px; }
.chapters .bl { flex: 1; display: flex; gap: 8px; padding: 7px 8px; border-radius: 6px; color: var(--ink); text-decoration: none; line-height: 1.3; }
.chapters .bl:hover { background: var(--panel); }
.chapters .bl[aria-current="page"] { background: var(--acc-soft); font-weight: 600; }
.chapters .cn { color: var(--acc); font-weight: 600; min-width: 1.5em; }
.chapters .nl { font-size: 13px; color: var(--muted); padding: 7px 4px; }

.content { padding: 28px 40px 80px; min-width: 0; }
.doc, .toc, .switch, .pn { max-width: 1040px; }

/* Chapter text */
.doc h1 { font-family: var(--sans); font-size: 34px; line-height: 1.15; margin: 4px 0 12px; }
.chapter-meta { font-family: var(--sans); color: var(--acc); font-weight: 600; font-size: 15px; margin: 0 0 4px; }
.doc h1 ~ h1 { margin-top: 56px; padding-top: 24px; border-top: 3px solid var(--ink); }
.scope { border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule); padding: 14px 0 6px; margin: 0 0 18px; }
.doc h2 { font-family: var(--sans); font-size: 24px; line-height: 1.25; margin: 40px 0 14px; padding-top: 12px; border-top: 2px solid var(--ink); }
.doc h2 .n { color: var(--acc); margin-right: 10px; }
.doc h3 { font-family: var(--sans); font-size: 19px; margin: 26px 0 8px; }
.doc h4 { font-family: var(--sans); font-size: 17px; margin: 20px 0 6px; }
.doc p { margin: 0 0 12px; }
.doc ul, .doc ol { padding-left: 22px; margin: 0 0 12px; }
.doc li { margin: 4px 0; }
strong { font-weight: 600; }

.row { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 28px; align-items: start; margin-bottom: 8px; }
.row.full { display: block; }
.main { min-width: 0; }
.content:focus { outline: none; }
.side { position: sticky; top: 80px; background: var(--panel); border-radius: 8px; padding: 14px 16px; font-family: var(--sans);
        font-size: 15px; line-height: 1.45; color: var(--soft); }
.side p { margin: 0 0 8px; }
.side p strong:only-child { display: block; color: var(--acc); font-size: 14px; letter-spacing: .02em; }
.side ul { list-style: none; padding: 0; margin: 0; }
.side li { padding: 4px 0; border-bottom: 1px solid var(--rule); margin: 0; }
.side li:last-child { border-bottom: none; }

.note { margin: 16px 0; padding: 12px 16px; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); font-size: 16px; }
.note p:last-child { margin: 0; }
.label { font-family: var(--sans); font-weight: 600; font-size: 14px; color: var(--acc); margin-right: 8px; }
.note.fix { border-color: var(--fix-rule); }
.note.fix .label { color: var(--fix); }
.qa { margin: 0 0 20px; }
.sources { font-family: var(--sans); font-size: 14px; color: var(--muted); border-top: 1px solid var(--rule); padding-top: 12px; margin-top: 32px; }

/* Tables */
.tw { overflow-x: auto; margin: 12px 0 20px; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: 15px; line-height: 1.4; }
th { text-align: left; font-weight: 600; background: var(--th); padding: 9px 12px; border-bottom: 1px solid var(--rule); vertical-align: bottom; }
td { padding: 9px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
tr:last-child td { border-bottom: none; }

/* Chapter helpers */
.switch { font-family: var(--sans); font-size: 15px; color: var(--muted); margin: 0 0 10px; }
.toc { font-family: var(--sans); font-size: 15px; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px;
       padding: 10px 16px; margin: 0 0 24px; }
.toc summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.toc ol { columns: 2; column-gap: 32px; margin: 8px 0 4px; padding-left: 0; list-style: none; }
.toc li { break-inside: avoid; padding: 3px 0; }
.toc a { color: var(--ink); text-decoration: none; }
.toc a:hover { color: var(--acc); text-decoration: underline; }
.pn { display: flex; gap: 16px; justify-content: space-between; margin-top: 48px; font-family: var(--sans); }
.pn a { flex: 1; max-width: 48%; border: 1px solid var(--control); border-radius: 8px; padding: 12px 16px; text-decoration: none; color: var(--ink); background: var(--surface); }
.pn a:hover { border-color: var(--acc); }
.pn a span { display: block; font-size: 13px; color: var(--muted); }
.pn .next { text-align: right; margin-left: auto; }

/* Notes pages */
body.notes .doc { font-family: var(--notes); font-size: 16px; }
.sheet { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; border-top: 2px solid var(--ink); padding-top: 14px; margin: 0 0 22px; }
.cue h2 { border: none; padding: 0; margin: 0 0 10px; font-size: 20px; color: var(--acc); }
.cue h2 .n { display: block; font-size: 14px; color: var(--muted); }
.cue ul { list-style: none; padding: 0; margin: 0; font-size: 15px; }
.cue li { padding: 4px 0; border-bottom: 1px dotted var(--rule); }
.cue .side { position: static; background: none; padding: 0; font-family: var(--notes); }
.notes > :first-child { margin-top: 0; }
.qa > p:first-child { font-weight: 700; margin-bottom: 6px; }
.qa details { border-top: 1px dashed var(--muted); padding-top: 6px; }
.qa summary { cursor: pointer; font-family: var(--sans); font-weight: 600; color: var(--acc); min-height: 44px; display: inline-flex; align-items: center; }
.qa .ans { padding-top: 6px; color: var(--soft); }

/* Home */
.lede { font-size: 19px; color: var(--soft); max-width: 760px; }
.home-list { list-style: none; padding: 0; margin: 28px 0 0; max-width: 860px; }
.home-list li { display: flex; gap: 18px; padding: 18px 0; border-top: 1px solid var(--rule); }
.home-list .cn { font: 700 22px var(--sans); color: var(--acc); min-width: 2em; }
.home-list .ct { font: 600 21px var(--sans); color: var(--ink); text-decoration: none; }
.home-list .ct:hover { color: var(--acc); }
.home-list p { margin: 4px 0 0; color: var(--soft); font-size: 16px; }
.home-list .links { font-family: var(--sans); font-size: 15px; }

/* Tablet */
@media (max-width: 1100px) {
  .row, .sheet { grid-template-columns: 200px minmax(0, 1fr); gap: 20px; }
  .content { padding: 24px 28px 80px; }
}

/* Phone and small tablet */
@media (max-width: 900px) {
  body { font-size: 17px; }
  .shell { display: block; }
  .menu { display: inline-block; }
  .brand { display: none; }
  .top { padding: 8px 12px; gap: 8px; }
  .search { margin-left: 0; position: static; }
  .results { position: fixed; top: 64px; left: 8px; right: 8px; max-height: 75vh; }
  .nav { position: fixed; top: 61px; left: 0; bottom: 0; height: auto; width: min(86vw, 340px); z-index: 30;
         transform: translateX(-105%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s;
         border-right: 1px solid var(--rule); box-shadow: 12px 0 32px rgba(0,0,0,.18);
         padding-bottom: calc(40px + env(safe-area-inset-bottom)); padding-left: max(12px, env(safe-area-inset-left)); }
  body.nav-open .nav { transform: none; visibility: visible; transition: transform .2s ease; }
  .chapters .bl { min-height: 44px; align-items: center; }
  .chapters .nl { min-height: 44px; display: inline-flex; align-items: center; padding: 0 8px; }
  .toc li a { display: flex; align-items: center; min-height: 44px; padding: 4px 0; }
  .switch a { display: inline-flex; align-items: center; min-height: 44px; }
  .content { padding: 16px max(16px, env(safe-area-inset-right)) calc(64px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .doc h1 { font-size: 27px; }
  .doc h2 { font-size: 21px; margin-top: 32px; }
  .row, .sheet { display: block; }
  .side { position: static; margin: 0 0 14px; }
  .side ul, .cue ul { display: flex; flex-wrap: wrap; gap: 6px; }
  .side li, .cue li { border: 1px solid var(--rule); border-radius: 6px; padding: 3px 9px; background: var(--surface); font-size: 14px; }
  .cue { border-bottom: 1px solid var(--rule); padding-bottom: 12px; margin-bottom: 14px; }
  .toc ol { columns: 1; }
  .pn { flex-direction: column; }
  .pn a { max-width: none; }
  .pn .next { text-align: left; margin-left: 0; }
}

/* Phone: tables become stacked cards */
@media (max-width: 700px) {
  .tw { border: none; background: none; overflow: visible; }
  .tw table, .tw tbody, .tw tr, .tw td { display: block; width: 100%; }
  .tw thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tw tr { border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); padding: 10px 14px; margin: 0 0 10px; }
  .tw td { border: none; padding: 3px 0; }
  .tw td:first-child { font-weight: 600; font-size: 16px; padding-bottom: 6px; }
  .tw td:not(:first-child)::before { content: attr(data-label) ": "; color: var(--acc); font-weight: 600; }
  .tw td[data-label=""]::before { content: none; }
  .home-list li { gap: 12px; }
}

/* Icon-only header buttons on narrow phones (labels stay available to screen readers via aria-label) */
@media (max-width: 600px) {
  .top .bt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .top button { padding: 0 10px; }
}

/* Full screen / reading mode */
body.reading .top, body.reading .nav, body.reading .toc, body.reading .switch, body.reading .skip { display: none; }
body.reading .shell { display: block; }
body.reading .content { padding-top: max(20px, env(safe-area-inset-top)); margin: 0 auto; max-width: 820px; }
.exit-reading { position: fixed; z-index: 40; right: max(16px, env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom));
                min-height: 44px; padding: 0 16px; font: 600 15px var(--sans); color: var(--ink); background: var(--surface);
                border: 1px solid var(--control); border-radius: 22px; box-shadow: 0 6px 20px rgba(0,0,0,.18); cursor: pointer; }
.exit-reading[hidden] { display: none; }
/* Installed as a home-screen app: keep content clear of the notch */
@media (display-mode: fullscreen), (display-mode: standalone) { .top { padding-top: max(10px, env(safe-area-inset-top)); } }

@media (prefers-reduced-motion: reduce) { .nav, body.nav-open .nav { transition: none; } }
@media (forced-colors: active) { .top button, .search input, .pn a, .exit-reading { border: 1px solid ButtonText; } }
@media print { .top, .nav, .toc, .pn, .switch { display: none; } .shell { display: block; } }
