/*
 * Navigation (components/m-brandbar.js, components/m-contents.js).
 *   top bar     brand · where you are (chapter chip) · Contents, theme
 *   track       the bar's lower edge: one segment per chapter, as wide as the
 *               chapter is long, filled in the chapter's colour
 *   pill        phones: where you are, at the bottom of the screen
 *   contents    a full-screen dialog: chapters on the left, the chapter's
 *               drawn object and parts on the right (one list on a phone)
 * --obj is the chapter object's colour (core/chapter-objects.js). In the light
 * theme it is mixed with ink for contrast; --obj-ink is the mixed colour.
 */
:root { --obj-mix: 70%; }
:root[data-theme="dark"] { --obj-mix: 100%; }
.nv-bar, .nv-pill, .nv-dialog { --obj: var(--accent2); }
.nv-bar *, .nv-pill, .nv-pill *, .nv-dialog * { --obj-ink: color-mix(in srgb, var(--obj) var(--obj-mix), var(--ink)); }

/* ---- top bar ---------------------------------------------------------------- */
.brandbar {
  position: fixed; inset: 0 0 auto; z-index: 30;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: 72px; padding: 0 40px;
  background: var(--nav-strong-bg);
  border-bottom: 1px solid rgba(var(--ink-rgb), .12);
  backdrop-filter: blur(14px) saturate(1.2);
  transition: background .24s, transform .36s cubic-bezier(.4, 0, .2, 1), opacity .3s;
}
html.intro-nav-hidden .brandbar { opacity: 0; pointer-events: none; transform: translateY(-100%); }
.brand { justify-self: start; display: flex; align-items: center; gap: 12px; padding: 0; background: none; border: 0; cursor: pointer; }
.brand .mark { width: 28px; height: 28px; }
.brand .word { display: block; height: 26px; aspect-ratio: 281 / 76; background: var(--wordmark) center / contain no-repeat; }
.actions { justify-self: end; display: flex; align-items: center; gap: 10px; }

/* where you are: the report's name, or the chapter chip, in one place */
.nv-where { display: grid; justify-items: center; align-items: center; min-width: 0; }
.nv-title, .nv-chip { grid-area: 1 / 1; transition: opacity .35s ease, translate .45s cubic-bezier(.2, .8, .2, 1); }
.nv-title { display: flex; flex-direction: column; align-items: center; gap: 2px; line-height: 1; }
.nv-title .eyebrow { font-family: var(--font-mono); font-size: 12px; font-weight: 300; letter-spacing: .14em; text-transform: uppercase; color: rgba(var(--ink-rgb), .62); }
.nv-title .name { font-family: var(--font-display); font-size: 20px; color: rgba(var(--ink-rgb), .82); }
.nv-chip {
  display: inline-flex; align-items: center; gap: 10px;
  max-width: min(46vw, 460px);
  padding: 4px 8px 4px 4px;
  color: var(--ink);
  background: rgba(var(--ink-rgb), .04);
  border: 1px solid rgba(var(--ink-rgb), .14);
  border-radius: 999px;
  cursor: pointer;
  opacity: 0; translate: 0 10px; pointer-events: none;
}
.nv-bar.in-chapter .nv-title { opacity: 0; translate: 0 -10px; pointer-events: none; }
.nv-bar.in-chapter .nv-chip { opacity: 1; translate: 0 0; pointer-events: auto; }
.nv-chip:hover { border-color: var(--obj-ink); background: color-mix(in srgb, var(--obj) 10%, transparent); }
.nv-chip:focus-visible, .nv-open:focus-visible, .nv-seg:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
.nv-chip-obj, .nv-pill-obj, .nv-obj {
  flex: none; display: grid; place-items: center; overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--obj) 20%, transparent);
}
.nv-chip-obj { width: 50px; height: 34px; }
.nv-chip-obj img, .nv-pill-obj img, .nv-obj img { width: 88%; height: auto; display: block; }
.nv-chip.swap .nv-chip-obj img { animation: nv-swap .6s cubic-bezier(.2, .9, .25, 1.25); }
.nv-chip-num { font-family: var(--font-mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nv-chip-name { font-family: var(--font-display); font-size: 18px; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes nv-swap { from { opacity: 0; transform: translateY(8px) rotate(-14deg) scale(.8); } to { opacity: 1; transform: none; } }

/* progress ring: chip and pill */
.nv-ring { flex: none; width: 22px; height: 22px; rotate: -90deg; }
.nv-ring circle { fill: none; stroke-width: 2.4; }
.nv-ring-bg { stroke: rgba(var(--ink-rgb), .14); }
.nv-ring-fg { stroke: var(--obj-ink); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; transition: stroke-dashoffset .25s linear; }

/* Contents: a labelled button */
.nv-open {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 14px 0 11px;
  font-family: var(--font-sans); font-size: 14px; font-weight: 500;
  color: var(--ink);
  background: none;
  border: 1.1px solid rgba(var(--ink-rgb), .2);
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.nv-open:hover { background: rgba(var(--ink-rgb), .06); border-color: rgba(var(--ink-rgb), .45); }

/* the track: chapters along the lower edge */
.nv-track {
  position: absolute; left: 0; right: 0; bottom: -1px;
  display: flex; gap: 2px; height: 3px;
  transition: height .2s ease;
}
.nv-track:hover, .nv-track:focus-within { height: 8px; }
.nv-seg { position: relative; flex: 1 1 0; min-width: 6px; height: 100%; padding: 0; overflow: visible; background: rgba(var(--ink-rgb), .1); border: 0; cursor: pointer; }
.nv-seg::before { content: ""; position: absolute; inset: -8px 0 -10px; }   /* a taller target */
.nv-seg-fill { position: absolute; inset: 0; background: var(--obj-ink); transform: scaleX(0); transform-origin: left; transition: transform .2s linear; }
.nv-seg.now { background: color-mix(in srgb, var(--obj) 22%, rgba(var(--ink-rgb), .1)); }
.nv-tip {
  position: absolute; left: 0; top: calc(100% + 14px);
  margin: 0; padding: 5px 9px;
  font-family: var(--font-mono); font-size: 12px; white-space: pre;
  color: var(--tooltip-ink); background: var(--tooltip-bg);
  border: 1px solid var(--tooltip-line); border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.nv-tip.on { opacity: 1; }

@media (width <= 600px) {
  .brandbar { grid-template-columns: 1fr auto; height: 64px; padding: 0 16px 0 20px; background: var(--nav-soft-bg); }
  .nv-where { display: none; }
  .brand .word { height: 24px; }
  .nv-open { width: 34px; padding: 0; justify-content: center; }
  .nv-open span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .nv-track { height: 2px; pointer-events: none; }
  .nv-tip { display: none; }
}

/* ---- phone pill ------------------------------------------------------------- */
.nv-pill { display: none; }
@media (width <= 600px) {
  .nv-pill {
    position: fixed; z-index: 30; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom));
    display: flex; align-items: center; gap: 10px;
    max-width: calc(100% - 32px);
    padding: 5px 8px 5px 5px;
    color: var(--ink);
    background: color-mix(in srgb, var(--nav-sheet-bg) 88%, transparent);
    border: 1px solid rgba(var(--ink-rgb), .14);
    border-radius: 999px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
    backdrop-filter: blur(14px);
    translate: -50% 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: opacity .3s, translate .36s cubic-bezier(.4, 0, .2, 1);
  }
  html.intro-nav-hidden .nv-pill, html.nv-locked .nv-pill { opacity: 0; pointer-events: none; translate: -50% 140%; }
  .nv-pill-obj { width: 38px; height: 28px; }
  .nv-pill:not(.in-chapter) .nv-pill-obj { display: none; }
  .nv-pill-text { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
  .nv-pill-num { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
  .nv-pill-name { font-family: var(--font-sans); font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .nv-pill:not(.in-chapter) { padding-left: 16px; }
  .nv-pill:not(.in-chapter) .nv-ring { display: none; }
}

/* ---- contents dialog -------------------------------------------------------- */
html.nv-locked { overflow: hidden; }
.nv-dialog {
  width: 100vw; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  color: var(--ink); background: transparent;
  overflow: hidden;
}
.nv-dialog::backdrop { background: var(--nav-scrim); backdrop-filter: blur(6px); opacity: 0; transition: opacity .25s; }
.nv-dialog.in::backdrop { opacity: 1; }
.nv-sheet {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
  background: color-mix(in srgb, var(--bg) 93%, transparent);
  backdrop-filter: blur(20px);
  opacity: 0; translate: 0 14px;
  transition: opacity .25s ease, translate .4s cubic-bezier(.2, .8, .2, 1);
}
.nv-dialog.in .nv-sheet { opacity: 1; translate: 0 0; }

.nv-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 40px 14px; border-bottom: 1px solid rgba(var(--ink-rgb), .1); }
.nv-kick { margin: 0 0 4px; font-family: var(--font-mono); font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.nv-report { margin: 0; font-family: var(--font-display); font-size: 22px; }
.nv-close {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px 0 12px;
  font-family: var(--font-sans); font-size: 14px; font-weight: 500;
  color: var(--ink); background: none; border: 1.1px solid rgba(var(--ink-rgb), .2); border-radius: 999px; cursor: pointer;
}
.nv-close:hover { background: rgba(var(--ink-rgb), .06); }

.nv-body {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(32px, 5vw, 88px);
  width: 100%; max-width: 1320px; margin: 0 auto;
  padding: 18px 40px 28px; box-sizing: border-box;
  overflow-y: auto; overscroll-behavior: contain;
}
.nv-list { margin: 0; padding: 0; list-style: none; align-self: start; }
.nv-list > li { border-bottom: 1px solid rgba(var(--ink-rgb), .1); }
.nv-item {
  position: relative;
  display: grid; grid-template-columns: 56px 30px minmax(0, 1fr) auto; align-items: center; gap: 4px 14px;
  width: 100%; padding: 14px 6px 14px 0;
  text-align: left; color: var(--ink); background: none; border: 0; cursor: pointer;
}
.nv-item:focus-visible { outline: 1.5px solid var(--obj-ink); outline-offset: -1px; border-radius: 12px; }
.nv-obj { width: 56px; height: 40px; transition: transform .45s cubic-bezier(.2, .9, .25, 1.3), opacity .3s, background .3s; opacity: .7; }
.nv-intro .nv-obj { background: #000; }
.nv-intro .nv-obj img { width: 100%; height: 100%; object-fit: cover; }
.nv-num { font-family: var(--font-mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nv-name {
  font-family: var(--font-display); font-size: clamp(24px, 2.5vw, 34px); font-weight: 420; line-height: 1.1; letter-spacing: -.015em;
  color: rgba(var(--ink-rgb), .72);
  transition: color .25s, translate .35s cubic-bezier(.2, .8, .2, 1);
}
.nv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.nv-intro .nv-meta { grid-column: 3 / -1; align-items: flex-start; white-space: normal; }
.nv-here { display: none; padding: 2px 8px; border-radius: 999px; color: var(--bg); background: var(--obj-ink); letter-spacing: .04em; }
.nv-item.now .nv-here { display: inline-block; }
.nv-item.done .nv-status::before { content: "✓ "; color: var(--obj-ink); }
.nv-prog { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; pointer-events: none; }
.nv-prog span { display: block; height: 100%; background: var(--obj-ink); transform: scaleX(0); transform-origin: left; }
.nv-item.staged .nv-name, .nv-item.now .nv-name, .nv-item:hover .nv-name { color: var(--ink); }
.nv-item.staged .nv-name { translate: 6px 0; }
.nv-item.staged .nv-obj, .nv-item.now .nv-obj { opacity: 1; transform: rotate(-6deg) scale(1.08); }
.nv-subparts { display: none; }

/* the stage */
.nv-stage {
  position: sticky; top: 0; align-self: start;
  padding: clamp(20px, 2.4vw, 32px);
  border: 1px solid rgba(var(--ink-rgb), .1);
  border-radius: 24px;
  background:
    radial-gradient(120% 90% at 78% 8%, color-mix(in srgb, var(--obj) 26%, transparent), transparent 62%),
    color-mix(in srgb, var(--obj) 5%, transparent);
  transition: background .5s ease;
}
.nv-art { display: flex; align-items: center; justify-content: center; height: clamp(120px, 24vh, 260px); margin: 0 0 10px; }
.nv-art.film img { max-width: 100%; border-radius: 18px; filter: none; box-shadow: 0 18px 40px rgba(0, 0, 0, .3); }
.nv-art img { display: block; max-width: 78%; max-height: 100%; width: auto; height: auto; object-fit: contain; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .18)); }
.nv-stage.swap .nv-art img { animation: nv-art .7s cubic-bezier(.2, .9, .25, 1.15); }
.nv-stage.swap .nv-stage-kick, .nv-stage.swap .nv-stage-title, .nv-stage.swap .nv-stage-deck, .nv-stage.swap .nv-parts { animation: nv-rise .5s cubic-bezier(.2, .8, .2, 1) both; }
.nv-stage.swap .nv-stage-title { animation-delay: .04s; }
.nv-stage.swap .nv-stage-deck { animation-delay: .08s; }
.nv-stage.swap .nv-parts { animation-delay: .12s; }
@keyframes nv-art { from { opacity: 0; transform: translateY(14px) rotate(-6deg) scale(.92); } to { opacity: 1; transform: none; } }
@keyframes nv-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.nv-stage-kick { margin: 0 0 8px; font-family: var(--font-mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--obj-ink); white-space: pre; }
.nv-stage-title { margin: 0 0 10px; font-family: var(--font-display); font-size: clamp(30px, 3.2vw, 44px); font-weight: 420; line-height: 1.08; letter-spacing: -.02em; }
.nv-stage-deck { margin: 0 0 18px; max-width: 46ch; font-family: var(--font-display); font-size: 19px; line-height: 1.45; color: rgba(var(--ink-rgb), .78); }
.nv-parts { margin: 0 0 20px; padding: 0; list-style: none; }
.nv-part {
  display: grid; gap: 2px; width: 100%; padding: 9px 28px 9px 0; position: relative;
  text-align: left; color: var(--ink); background: none; border: 0; border-top: 1px solid rgba(var(--ink-rgb), .1); cursor: pointer;
}
.nv-part::after { content: "›"; position: absolute; right: 4px; top: 50%; translate: 0 -50%; color: var(--muted); transition: translate .2s, color .2s; }
.nv-part:hover::after, .nv-part:focus-visible::after { translate: 4px -50%; color: var(--obj-ink); }
.nv-part:hover .nv-part-title { color: var(--obj-ink); }
.nv-part:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; border-radius: 4px; }
.nv-part-kick { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .06em; color: var(--muted); }
.nv-part-title { font-family: var(--font-sans); font-size: 15px; line-height: 1.4; transition: color .2s; }
.nv-go {
  display: inline-flex; align-items: center; gap: 10px; height: 42px; padding: 0 18px;
  font-family: var(--font-sans); font-size: 15px; font-weight: 600;
  color: var(--bg); background: var(--ink); border: 0; border-radius: 999px; cursor: pointer;
  transition: gap .2s;
}
.nv-go:hover { gap: 14px; }
.nv-go:focus-visible, .nv-close:focus-visible, .nv-top:focus-visible, .nv-lab:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }

.nv-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; padding: 14px 40px 20px; border-top: 1px solid rgba(var(--ink-rgb), .1); font-family: var(--font-mono); font-size: 12px; }
.nv-top, .nv-lab { padding: 0; font: inherit; color: var(--ink); background: none; border: 0; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(var(--ink-rgb), .3); cursor: pointer; }
.nv-top:hover, .nv-lab:hover { text-decoration-color: currentColor; }
.nv-note { margin-left: auto; color: var(--muted); }

/* one list on a phone or a narrow window */
@media (width <= 760px) {
  .nv-head { padding: 14px 16px 12px 20px; }
  .nv-report { font-size: 19px; }
  .nv-body { grid-template-columns: minmax(0, 1fr); padding: 4px 16px 20px 20px; }
  .nv-stage { display: none; }
  .nv-item { grid-template-columns: 48px 24px minmax(0, 1fr) auto; gap: 2px 10px; padding: 12px 0; }
  .nv-obj { width: 48px; height: 35px; opacity: 1; }
  .nv-name { font-size: 22px; }
  .nv-here { display: none !important; }
  .nv-item.now .nv-num { color: var(--obj-ink); font-weight: 600; }
  .nv-subparts { display: block; margin: -4px 0 12px 82px; padding: 0; list-style: none; }
  .nv-subparts:empty { display: none; }
  .nv-subparts .nv-part { padding: 8px 24px 8px 0; }
  .nv-subparts .nv-part-title { font-size: 14px; }
  .nv-foot { padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); }
  .nv-note { margin-left: 0; flex-basis: 100%; }
  .nv-word { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .nv-title, .nv-chip, .nv-sheet, .nv-dialog::backdrop, .nv-ring-fg, .nv-seg-fill, .nv-track, .nv-name, .nv-obj, .nv-pill { transition: none !important; }
  .nv-chip.swap .nv-chip-obj img, .nv-stage.swap * { animation: none !important; }
}

/* ---- the bar, sharp and black (review, 17 Nov) ---------------------------------------------------------------- */
/* the logo in black (in white on the dark theme), from the brand files */
.brand .mark, .brand .word { filter: brightness(0); }
:root[data-theme="dark"] .brand .mark, :root[data-theme="dark"] .brand .word { filter: brightness(0) invert(1); }
/* the chapter chip (and its phone pill): a sharp rectangle, like the chart cards */
.nv-chip, .nv-pill, .nv-chip-obj, .nv-pill-obj { border-radius: 0; }
/* Contents: the icon only, on every screen (the word stays for screen readers) */
.nv-open { width: 34px; padding: 0; justify-content: center; border-radius: 0; }
.nv-open span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* ---- the contents menu, compact (review 17 Nov) -----------------------------------------------------------------
 * A drawer on the right instead of the whole screen; sharp rectangles like the chart cards; smaller type and
 * tighter rows. Phones keep the full sheet. */
@media (width > 760px) {
  .nv-dialog { inset: 0 0 0 auto; width: min(980px, 100vw); }
  .nv-sheet { border-left: 1px solid rgba(var(--ink-rgb), .12); box-shadow: -24px 0 60px -30px rgba(var(--ink-rgb), .35); translate: 24px 0; }
  .nv-dialog.in .nv-sheet { translate: 0 0; }
  .nv-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 28px; padding: 14px 28px 22px; }
  .nv-head { padding: 16px 28px 12px; }
  .nv-foot { padding: 12px 28px 16px; }
}
.nv-report { font-size: 19px; }
.nv-close, .nv-go, .nv-here { border-radius: 0; }
.nv-close { height: 32px; font-size: 13px; }
.nv-item { grid-template-columns: 42px 24px minmax(0, 1fr) auto; gap: 2px 10px; padding: 9px 4px 9px 0; }
.nv-item:focus-visible { border-radius: 0; }
.nv-obj { width: 42px; height: 30px; border-radius: 0; }
.nv-num { font-size: 11px; }
.nv-name { font-size: clamp(19px, 1.7vw, 23px); }
.nv-meta { font-size: 10.5px; }
.nv-item.staged .nv-name { translate: 4px 0; }
.nv-item.staged .nv-obj, .nv-item.now .nv-obj { transform: none; }
.nv-stage { padding: 20px 22px; border-radius: 0; }
.nv-art { height: clamp(90px, 16vh, 170px); margin-bottom: 6px; }
.nv-art.film img { border-radius: 0; }
.nv-stage-kick { font-size: 11px; }
.nv-stage-title { font-size: clamp(24px, 2.3vw, 32px); }
.nv-stage-deck { font-size: 16px; margin-bottom: 12px; }
.nv-part { padding: 7px 24px 7px 0; }
.nv-part:focus-visible { border-radius: 0; }
.nv-part-kick { font-size: 10.5px; }
.nv-part-title { font-size: 14px; }
.nv-go { height: 38px; font-size: 14px; }
.nv-foot { font-size: 11px; }
