/*
 * The reading rail, the side contents and the "Summarise with AI" dock (pages/rail.js, pages/ai-summary.js).
 * After plumhq.com/standard-of-employee-benefits. The rail, the contents and the dock use Data Labs blue.
 */
:root { --dl-blue: #ff4052; --dl-blue-rgb: 255, 64, 82; }
/* dark mode: the accent turns a soft lilac (review 17 Nov) */
html[data-theme="dark"] { --dl-blue: #c4a0ff; --dl-blue-rgb: 196, 160, 255; }   /* the UI accent (was Data Labs blue #002dc0) */

/* ---- the rail: a tick every 6px; ticks above the reading position fill with the accent ---------------------- */
.rr {
  position: fixed; left: 0; top: 0; bottom: 0; width: 30px; z-index: 60; cursor: pointer;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  border-right: 1px solid rgba(var(--ink-rgb), .08);
  backdrop-filter: blur(6px);
  transition: background .2s;
}
.rr:hover, .rr:focus-visible { background: color-mix(in srgb, var(--bg) 85%, #fff); outline: none; }
/* the rail's label: a list icon and "Contents", read from the bottom up, above the ticks (pages/rail.js: TOP) */
.rr-label { position: absolute; left: 0; right: 0; top: 16px; display: grid; justify-items: center; gap: 10px; color: var(--dl-blue); pointer-events: none; }
.rr-label svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.rr-label span { writing-mode: vertical-rl; transform: rotate(180deg); font: 500 10px/1 var(--font-mono); letter-spacing: .18em; text-transform: uppercase; }
.rr:hover .rr-label, .rr:focus-visible .rr-label { color: var(--ink); }
.rr-ticks > i { position: absolute; left: 9px; width: 9px; height: 1.5px; margin-top: -.75px; border-radius: 2px; background: rgba(var(--dl-blue-rgb), .16); transition: background .35s; }
.rr-ticks > i.done { background: rgba(var(--dl-blue-rgb), .75); }

/* chapters and parts: longer ticks at their place in the page; hover names them, a click goes there */
.rr-mk { position: absolute; left: 0; right: 0; height: 9px; margin-top: -4.5px; padding: 0; border: 0; background: none; cursor: pointer; }
.rr-mk::before { content: ""; position: absolute; left: 9px; top: 50%; width: 13px; height: 1.5px; border-radius: 2px; transform: translateY(-50%); background: rgba(var(--dl-blue-rgb), .4); transition: width .25s cubic-bezier(.2, .8, .25, 1), background .2s, height .2s; }
.rr-mk.ch::before { width: 17px; height: 2px; background: rgba(var(--dl-blue-rgb), .65); }
.rr-mk.done::before { background: var(--dl-blue); }
.rr-mk.on::before { width: 20px; height: 2.5px; background: var(--dl-blue); }
.rr-mk:hover::before, .rr-mk:focus-visible::before { width: 20px; background: var(--dl-blue); }
.rr-mk:focus-visible { outline: none; }
.rr-tip {
  position: absolute; left: calc(100% + 10px); top: 50%; transform: translate(-4px, -50%); opacity: 0; pointer-events: none;
  white-space: nowrap; font: 12px/1.3 var(--font-mono); color: var(--ink);
  background: color-mix(in srgb, var(--bg) 70%, #fff); border: 1px solid rgba(var(--ink-rgb), .1);
  padding: 6px 10px; border-radius: var(--ui-radius-s, 8px); box-shadow: var(--ui-shadow-s);
  transition: opacity .15s, transform .15s;
}
.rr-mk.ch .rr-tip { font: 15px/1.2 var(--font-display); letter-spacing: -.02em; color: var(--dl-blue); }
.rr-mk:hover .rr-tip, .rr-mk:focus-visible .rr-tip { opacity: 1; transform: translate(0, -50%); }

/* ---- the side contents ---------------------------------------------------------------------------------------- */
.rr-toc {
  position: fixed; z-index: 59; top: 76px; bottom: 16px; left: 38px; width: min(340px, calc(100vw - 54px));
  overflow-y: auto; overscroll-behavior: contain;
  padding: 22px 22px 28px;
  background: color-mix(in srgb, var(--bg) 82%, #fff);
  border: 1px solid rgba(var(--ink-rgb), .08); border-radius: var(--ui-radius, 12px);
  box-shadow: 0 2px 4px rgba(40, 24, 12, .04), 0 18px 48px rgba(40, 24, 12, .12);
  transform: translateX(calc(-100% - 48px)); opacity: 0;
  transition: transform .38s cubic-bezier(.2, .8, .2, 1), opacity .25s;
}
html.rr-open .rr-toc { transform: none; opacity: 1; }
.rr-scrim { position: fixed; inset: 0; z-index: 58; background: rgba(31, 26, 23, .18); opacity: 0; pointer-events: none; transition: opacity .25s; }
html.rr-open:not(.rr-pinned) .rr-scrim { opacity: 1; pointer-events: auto; }

.rr-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.rr-title { flex: 1; margin: 0; font: 400 30px/1.1 var(--font-display); letter-spacing: -.02em; color: var(--ink); }
.rr-pin, .rr-close { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid rgba(var(--dl-blue-rgb), .2); border-radius: var(--ui-radius-s, 8px); background: transparent; color: var(--dl-blue); cursor: pointer; }
.rr-pin svg, .rr-close svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.rr-pin[aria-pressed="true"] { background: var(--dl-blue); border-color: var(--dl-blue); color: #fff; }
.rr-pin:hover, .rr-close:hover { border-color: rgba(var(--ink-rgb), .4); }
@media (width < 1280px) { .rr-pin { display: none; } }   /* pinning needs room beside the page */

.rr-list, .rr-list ol { list-style: none; margin: 0; padding: 0; }
.rr-list > li { padding: 12px 0; border-top: 1px solid rgba(var(--ink-rgb), .1); }
.rr-list > li:first-child { border-top: 0; padding-top: 4px; }
.rr-list a { display: block; color: var(--ink); text-decoration: none; border-radius: 6px; transition: color .15s, background .15s; }
.rr-ch { display: flex !important; gap: 10px; align-items: baseline; padding: 4px 8px; margin: 0 -8px; font: 400 19px/1.25 var(--font-display); letter-spacing: -.02em; }
.rr-n { flex: none; font: 11px var(--font-mono); letter-spacing: .04em; color: var(--muted); }
.rr-list ol { margin-top: 4px; }
.rr-pt { padding: 4px 8px 4px 30px; margin: 0 -8px; font: 14px/1.4 var(--font-sans); color: rgba(var(--ink-rgb), .72) !important; }
.rr-list a:hover { background: rgba(var(--ink-rgb), .05); }
.rr-list a.on { background: rgba(var(--dl-blue-rgb), .08); color: var(--dl-blue) !important; }
.rr-list a.on .rr-n { color: var(--dl-blue); }

/* phones: the top bar already shows progress and the menu has the contents */
@media (width < 900px) { .rr, .rr-toc, .rr-scrim { display: none; } }
@media (prefers-reduced-motion: reduce) { .rr-toc, .rr-tip, .rr-mk::before { transition: none; } }

/* ---- Summarise with AI, the app and back to top: floating in the bottom-right corner ------------------------
 * After the reference: a blurred glass panel with the line and four icons split by thin rules; under it a row with
 * a button to the embryo app and a rounded square back to the top. */
.ai-dock {
  position: fixed; right: 20px; bottom: 20px; z-index: 57; width: 268px;   /* room for "Explore 3D embryo app" */
  display: flex; flex-direction: column; gap: 6px;
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity .3s, transform .3s cubic-bezier(.2, .8, .2, 1);
}
.ai-dock.in { opacity: 1; transform: none; pointer-events: auto; }
.ai-dock-panel, .ai-app, .ai-top {
  background: rgba(255, 255, 255, .55);
  -webkit-backdrop-filter: blur(16px) saturate(1.3); backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid rgba(var(--dl-blue-rgb), .14); border-radius: 10px;
  box-shadow: var(--ui-shadow-s);
}
.ai-dock-panel { padding: 8px 6px 6px; }
.ai-dock-label { margin: 0 0 6px; padding: 0 6px; font: 11.5px/1.2 var(--font-mono); letter-spacing: .02em; color: var(--dl-blue); }
.ai-dock-tools { display: flex; list-style: none; margin: 0; padding: 0; }
.ai-dock-tools li { flex: 1; display: flex; }
.ai-dock-tools li + li { border-left: 1px solid rgba(var(--dl-blue-rgb), .18); }   /* the vertical rules */
.ai-dock-link { flex: 1; display: grid; place-items: center; height: 30px; color: var(--dl-blue); border-radius: 6px; transition: background .15s; }
.ai-dock-link svg { width: 17px; height: 17px; }
.ai-dock-link:hover, .ai-dock-link:focus-visible { background: rgba(var(--dl-blue-rgb), .08); outline: none; }
.ai-dock-row { display: flex; gap: 6px; }
.ai-app {
  flex: 1; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
  font: 500 13.5px/1 var(--font-sans); color: #fff; text-decoration: none;
  background: var(--dl-blue); border-color: var(--dl-blue);
  transition: filter .15s;
}
.ai-app svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; }
.ai-app-go { margin-left: auto; opacity: .85; }
.ai-app:hover, .ai-app:focus-visible { filter: brightness(1.06); outline: none; }
.ai-top { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; cursor: pointer; color: var(--dl-blue); transition: background .15s; }
.ai-top svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ai-top:hover, .ai-top:focus-visible { background: rgba(255, 255, 255, .9); outline: none; }


/* ---- pinned contents: docked beside the rail, and the page makes room (wide screens) ------------------------- */
:root { --page-w: 100vw; --rr-dock: 370px; }   /* the rail (30px) + the docked contents (340px) */
@media (width >= 1280px) {
  html.rr-pinned { --page-w: calc(100vw - var(--rr-dock)); }
  html.rr-pinned body { padding-left: var(--rr-dock); }
  html.rr-pinned .brandbar { left: var(--rr-dock); }
  html.rr-pinned .rr-toc {
    top: 0; bottom: 0; left: 30px; width: 340px;
    border-radius: 0; border-width: 0 1px 0 0; box-shadow: none; padding-top: 24px;
    background: color-mix(in srgb, var(--bg) 70%, #fff);
  }
}
@media print { .rr, .rr-toc, .rr-scrim, .ai-dock { display: none !important; } }

/* ---- the top bar: only the Data Labs logo, over a fade (review 17 Nov) ----------------------------------------------
 * The title, the chapter chip, the Contents button and the chapter progress are gone from the top: the rail on the
 * left tracks progress and opens the contents (phones keep the floating chapter pill at the bottom).
 * The bar has no panel or rule any more. Content passing under it blurs more and more towards the top edge and
 * fades into the page colour: two blur layers, each masked with a linear gradient, then a colour wash. */
.brandbar .nv-where, .brandbar .actions, .brandbar .nv-track, .brandbar .nv-tip, .brandbar .nv-prog { display: none !important; }
.brandbar { background: transparent !important; border-bottom: 0 !important; backdrop-filter: none !important; }
.brandbar::before, .brandbar::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; z-index: -1; pointer-events: none;
}
.brandbar::before {   /* a light blur that eases out below the logo */
  height: 96px;
  backdrop-filter: blur(3px);
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 30%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 30%, transparent 100%);
}
.brandbar::after {    /* the page colour at the very top, fading out */
  height: 72px;
  background: linear-gradient(to bottom, rgba(245, 244, 240, .85) 0%, rgba(245, 244, 240, .4) 50%, rgba(245, 244, 240, 0) 100%);
}
/* the logo in Data Labs blue: both pictures used as masks over the blue */
.brand .mark { display: none; }
.brand::before { content: ""; width: 28px; height: 28px; background: var(--dl-blue); -webkit-mask: url("../../images/brand/plum-mark.svg") center / contain no-repeat; mask: url("../../images/brand/plum-mark.svg") center / contain no-repeat; }
.brand .word { background: var(--dl-blue); -webkit-mask: var(--wordmark) center / contain no-repeat; mask: var(--wordmark) center / contain no-repeat; }
/* the age chapter's own orange reading-progress line under the top bar: not needed, the rail tracks progress */
.age-reading-progress { display: none !important; }

/* ---- the light/dark switch: a rounded square at the top right (pages/theme-button.js) ----------------------- */
.theme-sq {
  position: fixed; top: 16px; right: 20px; z-index: 61;
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0; cursor: pointer;
  color: var(--dl-blue);
  background: rgba(255, 255, 255, .55);
  -webkit-backdrop-filter: blur(16px) saturate(1.3); backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid rgba(var(--dl-blue-rgb), .14); border-radius: 10px; box-shadow: var(--ui-shadow-s);
  transition: background .15s, transform .15s, opacity .3s, visibility 0s .3s;
  opacity: 0; visibility: hidden; pointer-events: none;   /* shown from the intro of chapter 1 (pages/theme-button.js) */
}
.theme-sq.in { opacity: 1; visibility: visible; pointer-events: auto; transition: background .15s, transform .15s, opacity .3s; }
.theme-sq svg { width: 16px; height: 16px; }
.theme-sq:hover, .theme-sq:focus-visible { background: rgba(255, 255, 255, .9); transform: translateY(-1px); outline: none; }
@media (width < 600px) { .theme-sq { top: 12px; right: 12px; width: 36px; height: 36px; } }

/* ---- the rest of the new UI in dark mode ------------------------------------------------------------------------ */
html[data-theme="dark"] .ai-dock-panel, html[data-theme="dark"] .ai-top, html[data-theme="dark"] .theme-sq {
  background: rgba(32, 27, 25, .6); border-color: rgba(var(--dl-blue-rgb), .22);
}
html[data-theme="dark"] .ai-top:hover, html[data-theme="dark"] .theme-sq:hover { background: rgba(48, 41, 38, .9); }
html[data-theme="dark"] .rr { background: color-mix(in srgb, var(--bg) 70%, transparent); border-right-color: rgba(var(--ink-rgb), .08); }
html[data-theme="dark"] .rr:hover { background: color-mix(in srgb, var(--bg) 92%, #fff); }
html[data-theme="dark"] .rr-toc, html[data-theme="dark"] .rr-tip { background: #1c1715; border-color: rgba(var(--ink-rgb), .1); }
html[data-theme="dark"] .rr-scrim { background: rgba(0, 0, 0, .4); }
html[data-theme="dark"] .brandbar::after { background: linear-gradient(to bottom, rgba(20, 17, 16, .85) 0%, rgba(20, 17, 16, .4) 50%, rgba(20, 17, 16, 0) 100%); }
/* the contributors' dot portraits: light dots screened onto the dark page */
html[data-theme="dark"] .pp-photo { background: #000; mix-blend-mode: screen; box-shadow: 0 0 0 1px #000; }

/* ---- illustrations sit on the page, not in a box (review 17 Nov) ----------------------------------------------
 * The condition artworks are drawn on a plain ground (near-white in light, near-black in dark). Blending drops the
 * ground and keeps every stroke's exact colour: darken on the light page, lighten on the dark one. */
.vw-art, .vw-art-stack > img { mix-blend-mode: darken; }
html[data-theme="dark"] .vw-art, html[data-theme="dark"] .vw-art-stack > img { mix-blend-mode: lighten; }
/* the frame is filled with the page colour and the picture blends into it, so the ground matches the page even
   where a wrapper isolates the blend (the scroll stories' sticky stage, the walk's fading figures) */
.vw-art-box, .vw-art-stack { background: var(--bg); }

/* the contributors' dot portraits on the dark page: dots in the report's pink, not white */
/* and the dark set of halftones (.tools/people/halftone.py, HALFTONE=dark): dot size follows the photo's light,
   so faces read as positives (highlights bright, shadows dark), not as negatives */
html[data-theme="dark"] .pp-photo:not(.ph) i { background: var(--dl-blue); }
html[data-theme="dark"] .pp-photo[aria-label="Portrait of Ganapathi"] i { -webkit-mask-image: url("../../images/people/ganapathi-dark-20533524c9.png") !important; mask-image: url("../../images/people/ganapathi-dark-20533524c9.png") !important; }
html[data-theme="dark"] .pp-photo[aria-label="Portrait of Saurabh"] i { -webkit-mask-image: url("../../images/people/saurabh-dark-3d30860d04.png") !important; mask-image: url("../../images/people/saurabh-dark-3d30860d04.png") !important; }
html[data-theme="dark"] .pp-photo[aria-label="Portrait of Biswarup"] i { -webkit-mask-image: url("../../images/people/biswarup-dark-ed77d99ce8.png") !important; mask-image: url("../../images/people/biswarup-dark-ed77d99ce8.png") !important; }
html[data-theme="dark"] .pp-photo[aria-label="Portrait of Gayatri"] i { -webkit-mask-image: url("../../images/people/gayatri-dark-95d844e4ea.png") !important; mask-image: url("../../images/people/gayatri-dark-95d844e4ea.png") !important; }
html[data-theme="dark"] .pp-photo[aria-label="Portrait of Prasanna"] i { -webkit-mask-image: url("../../images/people/prasanna-dark-2e70dd7d92.png") !important; mask-image: url("../../images/people/prasanna-dark-2e70dd7d92.png") !important; }
html[data-theme="dark"] .pp-photo.ph i { background: radial-gradient(circle, var(--dl-blue) 1.2px, transparent 1.6px) 0 0 / 7px 7px; opacity: .3; }
html[data-theme="dark"] .pp-photo.ph b { color: var(--dl-blue); }

/* ---- charts in dark mode (review 17 Nov) ------------------------------------------------------------------------
 * The chart cards (.np, hosp-pictogram.css) and the age city cards mix a fixed near-white into their background, so
 * they stayed light on the dark page. In dark they sit on a slightly lifted dark surface instead. */
html[data-theme="dark"] .np { box-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 18px 50px rgba(0, 0, 0, .35); }
html[data-theme="dark"] .acm { --acm-card: color-mix(in srgb, var(--bg) 90%, #fff); }
html[data-theme="dark"] .csp-pill[aria-pressed="true"] { color: var(--bg); }
.pv-v-lbl { fill: var(--ink); }   /* the cost estimator's value labels had no fill of their own (black on dark) */
/* one card colour for the chart cards, the halos behind their numbers and their hollow marks (was a fixed
 * near-white mix, written out in each chart's CSS): defined where the page colour is, so it follows it */
html, [data-mood] { --np-card: color-mix(in srgb, var(--bg) 12%, #f8f8f6); }
html[data-theme="dark"], html[data-theme="dark"] [data-mood] { --np-card: color-mix(in srgb, var(--bg) 92%, #fff); }
/* "below the rate" bubbles in the age matrix: a muted mid tone that still reads on the dark card */
html[data-theme="dark"] .cam-cell.down .cam-b, html[data-theme="dark"] .cam-key i.down { fill: color-mix(in srgb, var(--cat-primary) 45%, #5a4f4b); background: color-mix(in srgb, var(--cat-primary) 45%, #5a4f4b); }

/* the overview card in dark mode: a lifted dark card (it mixed in white, so it turned grey), light greys inside */
html[data-theme="dark"] .op-over > .overview { background: color-mix(in srgb, var(--bg) 90%, #fff); --muted: rgba(242, 233, 228, .62); box-shadow: 0 30px 90px rgba(0, 0, 0, .45); }
html[data-theme="dark"] .ov-index a:hover, html[data-theme="dark"] .ov-index a:focus-visible { background: rgba(255, 255, 255, .05); }

/* ---- chevrons: the only directional mark on the site (core/chevron.js; review 17 Nov: no arrows) ------------- */
.chev { display: inline-block; width: .9em; height: .9em; vertical-align: -.12em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button > .chev:only-child { width: 16px; height: 16px; vertical-align: middle; }
.rl-btn { display: inline-grid; place-items: center; }

/* ---- no accent bars anywhere (review 17 Nov) ---------------------------------------------------------------------
 * The coloured side bars are gone from the page's own parts: the app card's audience line and the quotes in the
 * scroll stories. The charts keep their accent bars (17 Nov, round 2). */
html .apt-who { border-left: 0; }
html .sc-card .sc-quote { border-left: 0; padding-left: 0; }
html[data-theme="dark"] .ai-app { color: #1a1220; }   /* dark text reads better on the lilac button */

/* ---- phones (review 17 Nov) ------------------------------------------------------------------------------------- */
@media (width < 600px) {
  /* nothing against the screen edge: figures that run edge to edge get side padding */
  m-figure[bare] { display: block; padding-inline: 12px; box-sizing: border-box; }
  .acm { padding-inline: 4px; box-sizing: border-box; }
  .wk-axis { margin-inline: 8px; }
  .sc-plot { left: 4px; right: 4px; }

  /* Summarise with AI: one flat row along the bottom (the four tools, the app, back to top) */
  .ai-dock { left: 12px; right: 12px; bottom: 12px; width: auto; flex-direction: row; align-items: stretch; gap: 6px; }
  .ai-dock-panel { flex: 1; display: flex; align-items: center; padding: 3px 4px; min-width: 0; }
  .ai-dock-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .ai-dock-tools { flex: 1; }
  .ai-dock-link { height: 36px; }
  .ai-dock-link svg { width: 16px; height: 16px; }
  .ai-dock-row { gap: 6px; }
  .ai-app { flex: none; height: auto; padding: 0 12px; gap: 6px; }
  .ai-app .ai-app-t { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }   /* icon only; the name stays for screen readers */
  .ai-app-go { margin-left: 0; }
  .ai-top { width: 44px; height: auto; }
  /* the floating chapter pill sits above the row while the row shows (from the conclusion on, pages/ai-summary.js) */
  html.ai-dock-in .nv-pill { bottom: 66px !important; }
}
