/* Choices and Considerations: shared parts. Tokens live in tokens.css. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-variant-numeric: oldstyle-nums proportional-nums;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 800; line-height: 1.05; letter-spacing: -0.02em; text-wrap: balance; }
p { margin: 0 0 var(--s4); text-wrap: pretty; }
p:last-child { margin-bottom: 0; }
ul, ol { margin: 0 0 var(--s4); padding-left: 1.2em; }
li { margin-bottom: var(--s2); }
::selection { background: var(--yellow); color: var(--on-yellow); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.num, table, input[type="number"], output { font-variant-numeric: tabular-nums lining-nums; }

a { color: var(--blue); text-decoration-line: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }

.skip { position: absolute; left: var(--s4); top: -100px; background: var(--ink); color: var(--paper); padding: var(--s2) var(--s4); z-index: 10; }
.skip:focus { top: var(--s4); }
.vh { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.wrap { max-width: var(--wide); margin-inline: auto; padding-inline: var(--gutter); }
.prose { max-width: var(--measure); }

/* ---------- Site header (identical on every page; JS sets aria-current) ---------- */
.site-head { border-bottom: var(--bw) solid var(--ink); background: var(--paper); }
.site-head .wrap { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "mark cta" "rooms rooms"; align-items: center; column-gap: var(--s5); padding-top: var(--s3); }
.mark { grid-area: mark; display: inline-block; align-items: baseline; gap: 0; color: var(--ink); text-decoration: none; font-size: 1.1875rem; line-height: 1; letter-spacing: -0.01em; white-space: nowrap; }
.mark-a { font-weight: 850; }
.mark-and { font-weight: 300; font-style: italic; }
.mark-b { font-weight: 300; }
.mark:hover .mark-b { font-weight: 850; }
.mark:hover .mark-a { font-weight: 300; }
.mark span { transition: font-weight var(--t-mid) var(--ease); }
.head-cta { grid-area: cta; }

/* The rooms: their own row, spread evenly, each with a small drawing of its instrument. */
.rooms { grid-area: rooms; margin-top: var(--s2); }
.rooms ul { list-style: none; margin: 0; padding: 0; display: flex; justify-content: space-between; gap: var(--s1); }
.rooms li { margin: 0; }
.rooms a { display: inline-flex; align-items: center; gap: 0.5em; min-height: 50px; padding: 0 var(--s2); color: var(--ink); text-decoration: none; font-size: var(--fs-small); font-weight: 600; white-space: nowrap; border-bottom: 4px solid transparent; transition: background var(--t-fast) var(--ease); }
.rooms .g { flex: none; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; color: var(--ink-2); }
.rooms .g .solid { fill: currentColor; stroke: none; }
.rooms a:hover { background: var(--paper-2); }
.rooms a:hover .g { color: var(--ink); }
.rooms a[aria-current="page"] { border-bottom-color: var(--ink); font-weight: 780; }
.rooms a[aria-current="page"] .g { color: var(--ink); stroke-width: 2; }
.btn-solid { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 var(--s4); border-radius: var(--r-control); background: var(--blue); color: var(--paper); text-decoration: none; font-weight: 650; font-size: var(--fs-small); white-space: nowrap; transition: background var(--t-fast) var(--ease); }
.btn-solid:hover { background: var(--ink); }
.btn-solid[aria-current="page"] { background: var(--ink); }

@media (max-width: 1100px) {
  /* Not enough room for all eight: the row scrolls sideways and fades at the edge that has more. */
  .rooms { position: relative; margin-inline: calc(var(--gutter) * -1); padding: 0 var(--gutter); overflow-x: auto; scrollbar-width: none; }
  .rooms ul { justify-content: flex-start; gap: var(--s2); }
  .rooms.more-right { -webkit-mask-image: linear-gradient(to right, black calc(100% - 56px), transparent); mask-image: linear-gradient(to right, black calc(100% - 56px), transparent); }
  .rooms.more-left { -webkit-mask-image: linear-gradient(to left, black calc(100% - 56px), transparent); mask-image: linear-gradient(to left, black calc(100% - 56px), transparent); }
  .rooms.more-left.more-right { -webkit-mask-image: linear-gradient(to right, transparent, black 56px, black calc(100% - 56px), transparent); mask-image: linear-gradient(to right, transparent, black 56px, black calc(100% - 56px), transparent); }
  .rooms::-webkit-scrollbar { display: none; }
}
@media (max-width: 520px) {
  .site-head .wrap { column-gap: var(--s3); }
  .mark { font-size: 1rem; }
  .head-cta .btn-solid { padding: 0 var(--s3); font-size: 0.9375rem; }
  .head-cta .long { display: none; }
  .rooms a { padding: 0 var(--s1); }
}
@media (min-width: 521px) { .head-cta .short { display: none; } }

/* ---------- Controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s4); border: var(--bw-strong) solid var(--ink); border-radius: var(--r-control); background: transparent; color: var(--ink); font-weight: 620; font-size: var(--fs-small); text-decoration: none; cursor: pointer; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.btn:hover { background: var(--paper-2); }
.btn:active { transform: translateY(1px); }
.btn[aria-pressed="true"] { background: var(--paper-2); font-weight: 760; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.3em; }
.btn-quiet { border-color: var(--line); }
.btn-quiet:hover { border-color: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Sliders: one look everywhere (class="range", plus range-a / range-b for option colours) ---------- */
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 44px; margin: 0; background: transparent; cursor: pointer; }
.range::-webkit-slider-runnable-track { height: 2px; background: var(--ink); }
.range::-moz-range-track { height: 2px; background: var(--ink); }
.range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 24px; height: 24px; margin-top: -11px; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink); }
.range::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink); }
.range-a::-webkit-slider-thumb { background: var(--a); border-color: var(--a); }
.range-a::-moz-range-thumb { background: var(--a); border-color: var(--a); }
.range-b::-webkit-slider-thumb { background: var(--b); }
.range-b::-moz-range-thumb { background: var(--b); }
.range:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---------- Ideas named in prose, matching the instrument ---------- */
.hl { color: var(--on-yellow); background: linear-gradient(transparent 12%, var(--yellow) 12%, var(--yellow) 88%, transparent 88%); -webkit-box-decoration-break: clone; box-decoration-break: clone; padding: 0 0.08em; }
.w-a { color: var(--blue); font-weight: 650; }
.w-b { font-weight: 650; text-decoration: underline; text-decoration-color: var(--yellow); text-decoration-thickness: 0.32em; text-underline-offset: -0.12em; text-decoration-skip-ink: none; }

/* ---------- Room page structure (the same labelled parts on every room) ---------- */
.room-head { padding-block: var(--s6) var(--s5); }
.room-head h1 { font-size: var(--fs-h1); line-height: var(--lh-tight); letter-spacing: -0.03em; font-weight: 850; }
.room-head .dek { margin-top: var(--s3); font-size: clamp(1.25rem, 1rem + 1vw, 1.625rem); line-height: 1.3; color: var(--ink-2); max-width: 36rem; font-weight: 400; }
.part { padding-block: var(--s7); }
.part > .wrap > h2, .part > h2 { font-size: var(--fs-h2); padding-top: var(--s3); border-top: var(--bw-strong) solid var(--ink); margin-bottom: var(--s5); }
.part h3 { font-size: var(--fs-h3); margin: var(--s5) 0 var(--s2); letter-spacing: -0.01em; }
@media (max-width: 640px) {
  /* Phones: the instrument starts sooner. */
  .room-head { padding-block: var(--s4) var(--s2); }
  .room-head .dek { margin-top: var(--s2); }
  .part { padding-block: var(--s6); }
  #try.part { padding-top: var(--s4); }
  .part > .wrap > h2, .part > h2 { margin-bottom: var(--s4); }
}

/* ---------- Wayfinding on long rooms (scripts/sync-wayfinding.mjs writes the markup) ---------- */
html { scroll-behavior: smooth; }
.part[id] { scroll-margin-top: var(--s3); }
.onpage { margin-top: var(--s3); }
.onpage ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 var(--s5); }
.onpage li { margin: 0; }
.onpage a { display: inline-flex; align-items: center; min-height: 44px; font-size: var(--fs-small); font-weight: 600; color: var(--ink-2); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; }
.onpage a:hover { color: var(--ink); border-bottom-color: var(--ink); }
@media (max-width: 640px) {
  .onpage { margin-inline: calc(var(--gutter) * -1); padding: 0 var(--gutter); overflow-x: auto; scrollbar-width: none; }
  .onpage::-webkit-scrollbar { display: none; }
  .onpage ul { flex-wrap: nowrap; gap: 0 var(--s4); }
  .onpage.more-right { -webkit-mask-image: linear-gradient(to right, black calc(100% - 48px), transparent); mask-image: linear-gradient(to right, black calc(100% - 48px), transparent); }
  .onpage.more-left { -webkit-mask-image: linear-gradient(to left, black calc(100% - 48px), transparent); mask-image: linear-gradient(to left, black calc(100% - 48px), transparent); }
  .onpage.more-left.more-right { -webkit-mask-image: linear-gradient(to right, transparent, black 48px, black calc(100% - 48px), transparent); mask-image: linear-gradient(to right, transparent, black 48px, black calc(100% - 48px), transparent); }
}
.next-room { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s4) var(--s6); margin-top: var(--s4); padding-block: var(--s5) var(--s8); border-top: var(--bw-strong) solid var(--ink); }
.next-go { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "g k" "g n" "g q"; column-gap: var(--s4); align-items: center; padding: var(--s2) 0; color: var(--ink); text-decoration: none; }
.next-g { grid-area: g; width: 64px; height: 64px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.next-g .solid { fill: currentColor; stroke: none; }
.next-k { grid-area: k; font-size: var(--fs-meta); font-weight: 650; color: var(--ink-2); }
.next-n { grid-area: n; font-size: clamp(1.75rem, 1.2rem + 2vw, 2.75rem); font-weight: 840; letter-spacing: -0.025em; line-height: 1.05; }
.next-q { grid-area: q; margin-top: var(--s1); font-size: var(--fs-small); color: var(--ink-2); }
.next-go:hover .next-n, .next-go:focus-visible .next-n { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 0.12em; }
.next-prev { display: inline-flex; align-items: center; min-height: 44px; font-size: var(--fs-small); font-weight: 600; }
@media (max-width: 520px) { .next-g { width: 48px; height: 48px; } }

/* ---------- Tables (row-readable) ---------- */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); line-height: 1.45; }
.table th, .table td { text-align: left; vertical-align: top; padding: var(--s3) var(--s4) var(--s3) 0; border-bottom: var(--bw) solid var(--hair); }
.table thead th { font-weight: 700; border-bottom: var(--bw-strong) solid var(--ink); font-size: var(--fs-small); }
.table tbody th { font-weight: 650; }
.table td.n, .table th.n { text-align: right; font-variant-numeric: tabular-nums lining-nums; }
.table-scroll { overflow-x: auto; }

/* ---------- Scripture: the one night surface per page ---------- */
.night { background: var(--night); color: var(--night-ink); }
.night a { color: var(--night-blue); }
.night :focus-visible { outline-color: var(--yellow); }
.night .part-title, .night > .wrap > h2 { border-top-color: var(--night-ink); }
.night ::selection { background: var(--yellow); color: var(--on-yellow); }
.verse { margin: 0 0 var(--s6); padding: 0; }
.verse p { font-family: var(--serif); font-size: clamp(1.375rem, 1.1rem + 1vw, 1.875rem); line-height: 1.38; font-weight: 400; margin-bottom: var(--s2); hanging-punctuation: first; text-wrap: pretty; }
.verse cite { font-style: normal; font-family: var(--sans); font-size: var(--fs-small); font-weight: 600; color: var(--ink-2); }
.night .verse cite { color: var(--night-ink-2); }
.verse .in-context { display: block; margin-top: var(--s2); max-width: 36rem; font-family: var(--sans); font-size: var(--fs-small); line-height: 1.45; color: var(--ink-2); }
.verse .in-context b { font-weight: 650; color: var(--ink); }
.night .verse .in-context { color: var(--night-ink-2); }
.night .verse .in-context b { color: var(--night-ink); }
.verse.big p { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 3rem); line-height: 1.22; }
.verse.big.long p { font-size: clamp(1.375rem, 1.1rem + 1vw, 1.875rem); line-height: 1.38; }
.verse.small p { font-size: 1.25rem; line-height: 1.45; }
.scripture-grid { display: grid; gap: var(--s7); grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; }
@media (min-width: 861px) { .scripture-grid > .painting { position: sticky; top: var(--s5); } }
@media (max-width: 860px) { .scripture-grid { grid-template-columns: 1fr; gap: var(--s6); } }

/* Paintings are shown whole, never cropped. */
.painting { margin: 0; }
.painting img { width: 100%; height: auto; background: var(--paper-2); }
.night .painting img { background: var(--night); }
.painting figcaption { margin-top: var(--s3); font-size: var(--fs-meta); line-height: 1.5; color: var(--ink-2); }
.painting figcaption .t { font-style: italic; }
.night .painting figcaption { color: var(--night-ink-2); }
.painting .note { display: block; margin-top: var(--s2); font-size: var(--fs-small); color: inherit; }

/* ---------- Video facade: nothing loads from YouTube until the visitor asks ---------- */
.videos { display: grid; gap: var(--s5); grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); }
.video { margin: 0; }
.video-frame { position: relative; aspect-ratio: 16 / 9; border: var(--bw-strong) solid var(--ink); background: var(--paper-2); }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-play { position: absolute; inset: 0; width: 100%; display: flex; flex-direction: column; justify-content: flex-start; align-items: flex-start; gap: var(--s3); padding: var(--s4); border: 0; background: transparent; text-align: left; cursor: pointer; color: var(--ink); }
.video-play .vt { font-size: clamp(1.0625rem, 0.95rem + 0.5vw, 1.375rem); font-weight: 760; line-height: 1.15; letter-spacing: -0.01em; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.video-play .vc { font-size: var(--fs-meta); font-weight: 650; color: var(--ink-2); }
.video-play .go { margin-top: auto; display: inline-flex; align-items: center; gap: var(--s3); font-size: var(--fs-small); font-weight: 620; }
.video-play .tri { width: 52px; height: 52px; border-radius: 50%; background: var(--ink); position: relative; flex: none; transition: background var(--t-fast) var(--ease); }
.video-play .tri::after { content: ""; position: absolute; left: 21px; top: 16px; border-left: 16px solid var(--paper); border-top: 10px solid transparent; border-bottom: 10px solid transparent; }
.video-play:hover .tri { background: var(--blue); }
.video figcaption { margin-top: var(--s2); font-size: var(--fs-small); color: var(--ink-2); line-height: 1.45; }
.video .by { font-weight: 600; color: var(--ink); }

/* ---------- Site footer ---------- */
.site-foot { border-top: var(--bw) solid var(--ink); padding-block: var(--s6) var(--s7); font-size: var(--fs-small); color: var(--ink-2); }
.site-foot .wrap { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); }
.site-foot a { color: var(--ink); }
.site-foot p { margin: 0; }

/* ---------- Motion that answers the visitor (assets/js/motion.js) ---------- */
:root { interpolate-size: allow-keywords; }
/* The sweep is a background, so it follows every line of a phrase that wraps. */
.flash { background-image: linear-gradient(var(--yellow), var(--yellow)); background-repeat: no-repeat; background-position: 0 70%; -webkit-box-decoration-break: clone; box-decoration-break: clone; animation: flash-sweep 1500ms var(--ease) both; }
@keyframes flash-sweep { 0% { background-size: 0% 78%; } 22% { background-size: 100% 78%; } 72% { background-size: 100% 78%; } 100% { background-size: 100% 0%; } }
.cue { position: relative; }
.cue::after { content: ""; position: absolute; left: 0; right: 0; bottom: -7px; height: 3px; background: var(--yellow); transform-origin: left center; animation: cue-draw 2600ms var(--ease) both; pointer-events: none; }
@keyframes cue-draw { 0% { transform: scaleX(0); opacity: 1; } 18% { transform: scaleX(1); opacity: 1; } 80% { opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }

/* Evening: text under the highlighter turns to dark ink, as it would under a real one. */
/* Evening: the words go dark only while the yellow is behind them, and come back as it leaves. */
[data-theme="evening"] .flash { animation-name: flash-sweep-evening; }
@keyframes flash-sweep-evening { 0% { background-size: 0% 78%; } 12% { color: var(--on-yellow); } 22% { background-size: 100% 78%; color: var(--on-yellow); } 72% { background-size: 100% 78%; color: var(--on-yellow); } 100% { background-size: 100% 0%; } }
[data-theme="evening"] .night { border-block: var(--bw) solid var(--hair); }

/* ---------- The evening setting toggle (words, never an icon swap) ---------- */
.theme-toggle { display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--s2); border: 0; background: none; color: var(--ink); font-size: var(--fs-small); font-weight: 600; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 0.25em; cursor: pointer; }
.theme-toggle:hover { text-decoration-color: var(--ink); text-decoration-thickness: 2px; }
.head-cta { display: flex; align-items: center; gap: var(--s3); }
@media (max-width: 520px) { .head-cta .theme-toggle { display: none; } }

/* ---------- Expanders: <details class="more"><summary>Why this works</summary>...</details> ---------- */
/* State is said in words (Open / Close), never by a turning icon. The body eases open where supported. */
.more { border-top: var(--bw) solid var(--ink); border-bottom: var(--bw) solid var(--hair); margin-block: var(--s4); }
.more > summary { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); min-height: 48px; padding: var(--s2) 0; font-weight: 700; cursor: pointer; list-style: none; }
.more > summary::-webkit-details-marker { display: none; }
.more > summary::after { content: "Open"; flex: none; font-size: var(--fs-meta); font-weight: 650; color: var(--blue); text-decoration: underline; text-underline-offset: 0.2em; }
.more[open] > summary::after { content: "Close"; }
.more > summary:hover::after { text-decoration-thickness: 2px; }
.more::details-content { block-size: 0; overflow-y: clip; transition: block-size var(--t-slow) var(--ease), content-visibility var(--t-slow) allow-discrete; }
.more[open]::details-content { block-size: auto; }
.more > :not(summary) { max-width: var(--measure); }
.more > :last-child { margin-bottom: var(--s4); }
.more .video { max-width: 40rem; }
.night .more { border-top-color: var(--night-ink); border-bottom-color: var(--ink-2); }
.night .more > summary::after { color: var(--night-blue); }

/* ---------- The choice picker (home and Weigh it): built by scripts/sync-picker.mjs ---------- */
/* An index, not a wall of buttons: ruled rows of plain questions, eight first, the rest one tap away. */
.pick-top, .pick-group ul { list-style: none; margin: 0; padding: 0; }
.pick li { margin: 0; }
/* Nine questions: three by three on a wide screen, so the last one never sits alone. */
.pick-top { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: var(--s6); border-top: var(--bw) solid var(--ink); }
@media (max-width: 860px) { .pick-top { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .pick-top { grid-template-columns: minmax(0, 1fr); } }
.pick a { display: flex; align-items: center; min-height: 48px; padding: var(--s1) 0; border-bottom: var(--bw) solid var(--hair); color: var(--ink); font-size: var(--fs-small); font-weight: 580; line-height: 1.25; text-decoration: none; transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.pick-top a { min-height: 56px; font-size: 1.1875rem; font-weight: 740; letter-spacing: -0.012em; }
.pick a:hover { color: var(--blue); border-bottom-color: var(--blue); }
.pick a:focus-visible { outline-offset: -3px; }
.pick a[aria-current="true"] { border-bottom: 3px solid var(--ink); font-weight: 820; }
.pick [data-s="other"] { color: var(--blue); }
.pick-all { margin-block: 0 var(--s2); border-top: 0; }
/* Picking from the long list closes it at once, so the page can land on the question (tray.js). */
.pick-all.snap::details-content { transition: none; }
/* Groups flow down columns like a book's index, so a long group does not leave a hole beside a short one. */
.pick-all > .pick-groups { max-width: none; columns: 4 13.5rem; column-gap: var(--s6); padding-top: var(--s2); }
.pick-group { break-inside: avoid; margin-bottom: var(--s5); }
.pick-group :is(h3, h4) { margin: 0; padding-bottom: var(--s1); border-bottom: var(--bw-strong) solid var(--ink); font-size: var(--fs-small); font-weight: 820; letter-spacing: 0; }
@media (max-width: 560px) { .pick-all > .pick-groups { columns: 2; column-gap: var(--s5); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .flash { background-image: none; }
  .cue::after { display: none; }
}
@media print {
  .site-head, .site-foot, .video, .skip { display: none !important; }
  body { background: white; }
}
