/* ============================================================
   The book page — the section chooser, the edition chooser, and an
   article that opens at one of its own sections.

   Board 6 of "A Way In", under the density rule
   (docs/planning/READING_AT_LENGTH.md): open at a readable length, let
   the reader ask for more, remove nothing. Everything here is either a
   plain anchor that works with no script at all, or a control the kit
   keeps hidden until `html.js` is set — so a reader without JavaScript
   meets both complete articles and no dead chips.

   Tokens and chips are reference.css's and kit.css's own; no new
   colours are minted here.
   ============================================================ */

/* ---- 1 · the page's sections, as one row of chips ---------------- */

/* The chips are the rail: plain #anchors that jump to a section, and —
   once book.js can mark them — the shell's "On this page" card stands
   down rather than saying the same list twice. */
.bkSecs .onthis {
  display: none;
}
.wwrap:has(nav.secBar) .onthis {
  display: none;
}

.secBar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 4px;
  padding: 9px 12px;
  border-radius: 14px;
  border: 1px solid rgba(232, 184, 115, 0.26);
  background: rgba(11, 16, 36, 0.86);
}
.secBar .fLbl {
  flex: none;
}
/* one line, always: a chip row that wraps to three lines is a wall of its
   own, and a sticky one that tall would take the screen it is saving. The
   row scrolls sideways instead, and book.js keeps the marked chip in it. */
.secChips {
  position: relative; /* the offset parent book.js scrolls the marked chip into */
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding: 3px 0;
}
.secChips::-webkit-scrollbar {
  display: none;
}
/* what is off the end of the row, said quietly */
.secBar::before,
.secBar::after {
  content: "";
  position: absolute;
  top: 1px;
  bottom: 1px;
  width: 38px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.secBar::after {
  right: 1px;
  border-radius: 0 13px 13px 0;
  background: linear-gradient(90deg, rgba(11, 16, 36, 0), rgba(11, 16, 36, 0.95));
}
.secBar::before {
  left: 1px;
  border-radius: 13px 0 0 13px;
  background: linear-gradient(270deg, rgba(11, 16, 36, 0), rgba(11, 16, 36, 0.95));
}
.secBar.moreR::after,
.secBar.moreL::before {
  opacity: 1;
}
.secBar a.facet {
  min-height: 34px;
  color: #b4bddd;
  text-decoration: none;
}
.secBar a.facet:hover {
  border-color: var(--hairline);
  color: var(--starlight);
  text-decoration: none;
}
.secBar a.facet[aria-current="true"] {
  background: rgba(232, 184, 115, 0.16);
  border-color: var(--gold);
  color: #f5d9a8;
  font-weight: 600;
}

/* a jump must clear the slim bar and the chip row above the heading */
.bookPage h2.sec,
.bookPage .wart.read p.artH {
  scroll-margin-top: 124px;
}

@media (min-width: 601px) {
  .secBar {
    position: sticky;
    top: 56px;
    z-index: 12;
    backdrop-filter: blur(8px);
  }
}
@media (max-width: 900px) {
  .secBar {
    flex-wrap: nowrap;
  }
}
@media (max-width: 600px) {
  .secBar .fLbl {
    display: none;
  }
  .bookPage h2.sec,
  .bookPage .wart.read p.artH {
    scroll-margin-top: 16px;
  }
}

/* ---- 2 · the two editions ---------------------------------------- */

/* The chooser needs script to do anything, so it is not drawn without
   it; both articles are then simply open, one after the other. */
.edPick {
  display: none;
}
.js .edPick {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 14px 0 2px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(232, 184, 115, 0.26);
  background: rgba(11, 16, 36, 0.8);
}
.edPick .fLbl {
  flex: none;
}
.edArt {
  margin-top: 10px;
}
.edArt + .edArt {
  margin-top: 28px;
}
.edArt .masthead {
  margin-bottom: 2px;
}

/* ---- 3 · the article's own sections ------------------------------ */

.artSecs {
  display: none;
}
.js .artSecs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 68ch;
  margin: 14px 0 22px;
}
.artSecs .facet.all {
  border-color: rgba(232, 184, 115, 0.38);
  color: var(--gold);
}
.artSecs .facet.all[aria-pressed="true"] {
  color: #f5d9a8;
}

/* "Read on": the door to the rest of a long run of prose. The chip itself
   is the kit's `.reveal` — which kit.css keeps visible against styles.css's
   same-named scroll-in animation, so nothing is needed here for that. */
.artMore {
  display: none;
}
.js .artMore {
  display: flex;
  max-width: 68ch;
  margin-top: 18px;
}
.artMore .n {
  color: rgba(232, 184, 115, 0.75);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.edArt .wart.read + .artMore + .credit,
.edArt .wart.read + .credit {
  max-width: 68ch;
  margin-top: 16px;
}

/* ---- 4 · touch ---------------------------------------------------- */

@media (max-width: 900px), (pointer: coarse) {
  .secBar a.facet,
  .edPick .facet,
  .artSecs .facet,
  .artMore .reveal {
    min-height: 44px;
    padding: 0 14px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .secBar a.facet,
  .secBar::before,
  .secBar::after {
    transition: none;
  }
}
