/* Contents: the book's real contents page as an open spread, and a 312-leaf gilt edge that lights each chapter's span.
   Default (touch, no JS): the whole book, chapters marked by alternating leaf tones. */
.sec.contents {
  --toc-paper: #FBF8F1;
  --toc-num: #8A6020;
  background: var(--ivory-2);
  padding: clamp(48px, 5vw, 64px) 0;
}
.contents__head { display: flex; align-items: center; gap: 18px clamp(28px, 3vw, 48px); }
.contents__title { flex: none; }
.contents__lede { flex: 1 1 auto; }
.contents__cta { flex: none; }

.contents__body { position: relative; margin-top: clamp(18px, 2.4vh, 24px); }

/* the pane: an ink panel holding the readout and the ribbon of 312 leaves */
.contents__pane {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: minmax(330px, 33%) 1fr; gap: clamp(24px, 3vw, 44px); align-items: center;
  padding: 14px clamp(22px, 2.4vw, 34px) 10px; background: var(--ink); color: var(--ivory);
  box-shadow: 0 24px 50px -30px rgba(24, 32, 47, .6);
}
.contents__pane::before { content: ''; position: absolute; inset: 7px; border: 1px dotted rgba(226, 176, 98, .45); pointer-events: none; }
.contents__readout { position: relative; min-width: 0; }
.contents__ro-label { font-weight: 600; font-size: 1rem; color: var(--gold); letter-spacing: .02em; }
/* the title always takes exactly two lines, so the pane never changes height as chapters change
   (a changing height moved the list under the pointer and made it flick between chapters) */
.contents__ro-title {
  font-family: var(--f-display); font-weight: 600; font-size: clamp(1.15rem, 1.35vw, 1.3rem); line-height: 1.2; color: var(--white);
  /* padded clip box pulled back by the same amount, so glyph edges never touch the clip */
  box-sizing: content-box; height: 2.4em; padding: .25em .15em 0; margin: calc(2px - .25em) -.15em 0;
  overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
}
.contents__ro-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contents__ro-meta { margin-top: 4px; font-size: 1rem; line-height: 1.45; color: var(--mist); font-variant-numeric: tabular-nums; }
.contents__ro-meta span { display: block; white-space: nowrap; }
.contents__readout > p { will-change: transform; }

.contents__ribbon { position: relative; padding: 26px 0 24px; min-width: 0; }
.contents__ticks { position: absolute; left: 0; right: 0; top: 0; height: 22px; }
.contents__tick {
  position: absolute; top: 0; height: 22px; padding-left: 3px; border-left: 1px solid rgba(226, 176, 98, .55);
  font-size: 1rem; line-height: 1; font-weight: 600; color: var(--mist); font-variant-numeric: tabular-nums; transition: color .3s;
}
.contents__tick--bare { height: 10px; top: 12px; border-left-color: rgba(243, 236, 221, .35); }
.contents__tick.is-lit { color: var(--gold); }
.contents__edge { position: relative; height: clamp(44px, 5.2vh, 54px); }
.contents__leaves { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.contents__group { fill: var(--ivory); transition: opacity .45s var(--ease-out), fill .45s; }
.contents__group--a { opacity: .72; }
.contents__group--b { opacity: .3; }
.contents__group--front { opacity: .18; }
.contents__ribbon.has-active .contents__group { opacity: .14; }
.contents__ribbon.has-active .contents__group.is-lit { opacity: 1; fill: var(--gold); }
.contents__span {
  position: absolute; left: 0; top: -6px; bottom: -6px; width: 100%; transform-origin: 0 50%; transform: scaleX(0); opacity: 0;
  border-top: 1px solid var(--gold); border-bottom: 1px solid var(--gold); background: rgba(226, 176, 98, .1); pointer-events: none;
}
.contents__gleam-clip { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.contents__gleam {
  position: absolute; left: 0; top: 0; bottom: 0; width: 16%; pointer-events: none; transform: translateX(-110%); mix-blend-mode: screen;
  background: linear-gradient(90deg, rgba(255, 226, 160, 0), rgba(255, 226, 160, .55) 50%, rgba(255, 226, 160, 0));
}
.contents__needle { position: absolute; left: 0; top: -10px; bottom: -10px; width: 1px; background: var(--white); opacity: 0; pointer-events: none; }
.contents__mark {
  position: absolute; left: -13px; top: -40px; bottom: -32px; width: 12px; overflow: hidden; pointer-events: none;
  background: linear-gradient(90deg, #9C6E2C, #F1CF8C 45%, #E2B062 60%, #9C6E2C);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 9px), 0 100%);
  box-shadow: 0 0 18px rgba(226, 176, 98, .5);
}
.contents__mark-sheen { position: absolute; left: 0; right: 0; top: 0; height: 40%; background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .85), rgba(255, 255, 255, 0)); transform: translateY(-120%); }
.contents__scale { position: absolute; left: 0; right: 0; bottom: 0; height: 18px; }
.contents__scale span { position: absolute; top: 0; transform: translateX(-50%); font-size: 1rem; line-height: 1; color: rgba(180, 191, 210, .8); font-variant-numeric: tabular-nums; }
.contents__scale span:first-child { transform: none; }
.contents__scale span:last-child { transform: translateX(-100%); }
.contents__ribbon { cursor: crosshair; }

/* the spread: two pages and a gutter */
.contents__spread {
  position: relative; margin-top: clamp(16px, 2.2vh, 22px);
  display: grid; grid-template-columns: 1fr 1fr;
  padding: clamp(14px, 2vh, 20px) 0; background: var(--toc-paper);
  box-shadow: 0 1px 0 rgba(24, 32, 47, .08), 0 30px 60px -36px rgba(24, 32, 47, .45);
}
.contents__spread::before {
  content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 120px; transform: translateX(-50%); pointer-events: none;
  background: linear-gradient(90deg, rgba(24, 32, 47, 0), rgba(24, 32, 47, .06) 38%, rgba(24, 32, 47, .16) 50%, rgba(24, 32, 47, .06) 62%, rgba(24, 32, 47, 0));
}
.contents__spread::after { content: ''; position: absolute; inset: 10px; border: 1px dotted rgba(184, 135, 58, .6); pointer-events: none; }
.contents__page { position: relative; padding: 0 clamp(30px, 3.4vw, 48px) 0 clamp(24px, 2.6vw, 38px); }
.contents__page--right { padding: 0 clamp(24px, 2.6vw, 38px) 0 clamp(30px, 3.4vw, 48px); }
.contents__row {
  position: relative; display: flex; align-items: flex-end; align-items: last baseline; gap: 10px;
  margin: 0 -10px; padding: 3px 10px;
  font-family: var(--f-display); font-size: 1rem; line-height: 1.38; color: var(--ink);
  cursor: default; outline: none; transition: background-color .35s var(--ease-out);
}
.contents__row::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--gold-deep);
  transform: scaleY(0); transition: transform .45s var(--ease-out);
}
.contents__row.is-lit { background: rgba(226, 176, 98, .17); }
.contents__row.is-lit::before { transform: scaleY(1); }
.contents__row:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 0; }
.contents__num { align-self: flex-start; align-self: first baseline; flex: 0 0 1.4em; text-align: right; font-weight: 600; color: var(--toc-num); font-variant-numeric: tabular-nums lining-nums; }
.contents__name { flex: 0 1 auto; min-width: 0; }
.contents__lead {
  flex: 1 1 18px; min-width: 18px; height: 3px; position: relative; top: -4px;
  background-image: radial-gradient(circle, rgba(24, 32, 47, .6) 1px, rgba(24, 32, 47, 0) 1.4px);
  background-size: 7px 3px; background-repeat: repeat-x; background-position: 0 50%;
}
.contents__pg { flex: none; min-width: 2.1em; text-align: right; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums lining-nums; }

@media (max-width: 1100px) {
  .contents__head { flex-wrap: wrap; }
  .contents__lede { flex-basis: 60%; }
}
@media (max-width: 860px) {
  .contents__head { flex-direction: column; align-items: flex-start; }
  .contents__pane { position: sticky; top: 76px; grid-template-columns: 1fr; gap: 6px; padding: 12px 16px 10px; }
  .contents__ro-title { font-size: 1.08rem; }
  .contents__ro-meta { font-size: 1rem; }
  .contents__tick { font-size: 0; height: 10px; top: 12px; }
  .contents__ribbon { padding: 24px 0 22px; }
  .contents__edge { height: 38px; }
  .contents__gleam { width: 30%; }
  .contents__mark { top: -30px; bottom: -26px; width: 10px; left: -11px; }
  .contents__spread { grid-template-columns: 1fr; padding: 14px 0; }
  .contents__spread::before { display: none; }
  .contents__page, .contents__page--right { padding: 0 18px; }
  .contents__page--right { margin-top: 10px; padding-top: 10px; border-top: 1px dotted rgba(184, 135, 58, .6); }
  .contents__row { min-height: 44px; padding: 10px 10px; }
}

/* the open-book spread must not widen the page on phones (clip keeps the sticky pane working) */
.sec.contents { overflow-x: clip; }
