@font-face {
  font-family: Manrope;
  src: url("./assets/fonts/manrope-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

/*
  One family, two voices: heavy, tightly set Manrope for titles and quiet
  regular Manrope for everything else. White paper, graphite ink, no accent
  colour. Structure comes from space and alignment rather than rules and boxes.
*/
:root {
  color-scheme: light;
  --paper: #ffffff;
  --ink: #1d1d1b;
  --muted: #6b6b66;
  --line: #e7e7e3;
  --mist: #f4f4f1;
  --font: Manrope, system-ui, sans-serif;
  --gutter: clamp(1.25rem, 5.5vw, 5rem);
  --column-gap: clamp(2rem, 5vw, 5rem);
  --label-column: minmax(9rem, 15rem);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);
  interpolate-size: allow-keywords;
  scrollbar-color: #c9c8c1 transparent;
  /* The site header and the page bar beneath it stay in view; the header
     tightens once the page scrolls. */
  --header-h: 5.5rem;
  --bar-h: 3rem;
  scroll-padding-top: calc(var(--header-h) + var(--bar-h) + 1rem);
}
:root.is-scrolled { --header-h: 4rem; }
html:has(dialog[open]) { overflow: hidden; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
::selection { color: var(--paper); background: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 400 1rem / 1.7 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
main { flex: 1; }
main:focus { outline: none; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .25em; }
button, select { font: inherit; }
button, select, summary { cursor: pointer; }
button:disabled { cursor: default; }
img { display: block; width: 100%; height: auto; }
ol { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 {
  font-weight: 750;
  line-height: 1.04;
  letter-spacing: -.035em;
  text-wrap: balance;
}
h1 { font-size: clamp(2.6rem, 6vw, 5rem); letter-spacing: -.045em; }
h2 { font-size: clamp(1.6rem, 2.6vw, 2.2rem); }
h3 { font-size: 1.0625rem; letter-spacing: -.01em; line-height: 1.35; }
.frame { width: min(100% - var(--gutter) * 2, 74rem); margin-inline: auto; }
.loading, .page-notice { padding-block: 6rem; }
/* The loading line only appears if the library takes a moment to arrive. */
.loading { animation: appear .2s ease .6s both; }
@keyframes appear { from { opacity: 0; } }
.page-notice h1 { margin-bottom: 2rem; }
.sr-only, .skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link:focus {
  position: absolute;
  z-index: 5;
  top: .5rem;
  left: .5rem;
  padding: .5rem 1rem;
  background: var(--paper);
}

/* Small tracked capitals for the author, the book's divisions and the companion. */
.byline, .division-title, .companion-label {
  font-size: .75rem;
  font-weight: 650;
  line-height: 1.6;
  letter-spacing: .14em;
  text-transform: uppercase;
}

/* Header and footer */
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--header-h);
  transition: min-height .35s var(--ease-out);
}
.header-actions { display: flex; align-items: center; gap: clamp(.75rem, 2vw, 1.75rem); }
.header-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  font-size: .8125rem;
  font-weight: 600;
  text-decoration: none;
}
.header-link:hover, .header-link[aria-current] { text-decoration: underline; text-underline-offset: .3em; }
.brand {
  font-size: 1.0625rem;
  font-weight: 400;
  letter-spacing: -.01em;
  text-decoration: none;
}
.brand span { font-weight: 800; }
.brand:hover { text-decoration: underline; }
.language { position: relative; display: block; }
.language::after {
  content: "";
  pointer-events: none;
  position: absolute;
  top: calc(50% - .3rem);
  right: .2rem;
  width: .38rem;
  height: .38rem;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}
.language select {
  display: block;
  min-height: 2.75rem;
  appearance: none;
  padding: .35rem 1.3rem .35rem .4rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: .8125rem;
  font-weight: 600;
}
.language:hover select { text-decoration: underline; text-underline-offset: .3em; }
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  view-transition-name: site-header;
  transition: box-shadow .25s ease;
}
/* A hairline marks where scrolled content passes under the fixed bars. */
:root.is-scrolled body:not(:has(.page-bar)) .site-header { box-shadow: 0 1px 0 var(--line); }
.page-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--bar-h);
  transition: top .35s var(--ease-out);
}
.page-bar::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0 calc(50% - 50vw);
  background: var(--paper);
  box-shadow: 0 1px 0 transparent;
  transition: box-shadow .25s ease;
}
:root.is-scrolled .page-bar::before { box-shadow: 0 1px 0 var(--line); }
.page-bar .breadcrumbs { min-width: 0; }
.site-footer { margin-top: clamp(4rem, 9vw, 8rem); }
.footer-inner {
  padding-block: 1.75rem 2.25rem;
  border-top: 1px solid var(--line);
  font-size: .8125rem;
  color: var(--muted);
}

/* Links and actions */
.text-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  font-size: .875rem;
  font-weight: 650;
}
.text-link:hover { text-decoration-thickness: 2px; }
.play-link {
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  min-height: 3rem;
  font-size: .9375rem;
  font-weight: 650;
  text-decoration: none;
}
.play-square {
  display: grid;
  flex: none;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  background: var(--ink);
  color: var(--paper);
  transition: transform .2s ease;
}
.play-link:hover span:last-child { text-decoration: underline; text-underline-offset: .3em; }
.play-link:hover .play-square { transform: scale(.94); }
.play-icon {
  width: .55rem;
  height: .68rem;
  margin-left: .12rem;
  background: currentColor;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}
.button {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  padding: .6rem 1.1rem;
  font-size: .875rem;
  font-weight: 650;
  line-height: 1.35;
  text-decoration: none;
}
.button.primary { background: var(--ink); color: var(--paper); }
.button.primary:hover { text-decoration: underline; text-underline-offset: .3em; }

/* Library */
.library { padding-block: clamp(2.5rem, 6vw, 5.5rem) clamp(1rem, 3vw, 2rem); }
.library-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: end;
  gap: var(--column-gap);
}
.library-heading h1 { font-size: clamp(3.25rem, 8vw, 6rem); }
/* The intro sits on the heading's baseline, over the last column of books. */
.library-heading p { max-width: 30ch; padding-bottom: .95rem; color: var(--muted); font-size: .9375rem; }
@media (min-width: 76rem) {
  .library-heading { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .library-heading h1 { grid-column: span 2; }
}
.library-books {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  gap: 4rem var(--column-gap);
  padding-top: clamp(3rem, 7vw, 6rem);
}
.library-book { position: relative; display: flex; flex-direction: column; min-width: 0; }
/* The contents link covers the whole card. */
.card-link::after { content: ""; position: absolute; z-index: 1; inset: 0; }
.card-link:focus-visible { outline: 0; }
.library-book:has(.card-link:focus-visible) { outline: 2px solid var(--ink); outline-offset: 6px; }
.library-book:hover .card-link { text-decoration-thickness: 2px; }
.library-book:has(.card-link):hover h2 { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: .12em; }
.library-book:only-child { grid-column: 1 / -1; }
.library-book:only-child.has-artwork {
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(0, 1fr);
  align-items: center;
  gap: var(--column-gap);
}
.book-copy { display: flex; flex: 1; flex-direction: column; align-items: flex-start; }
.library-book h2 { font-size: clamp(1.75rem, 3vw, 2.5rem); }
.library-book:only-child h2 { font-size: clamp(2.4rem, 4.4vw, 3.75rem); }
.library-book .byline { margin-top: .9rem; }
.book-description { max-width: 40ch; margin-top: 1rem; color: var(--muted); font-size: .9375rem; }
.library-book .text-link, .card-status { margin-top: auto; padding-top: 1rem; }
.card-status { color: var(--muted); font-size: .875rem; font-weight: 650; }
.book-artwork {
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: var(--mist);
}
.book-artwork img {
  height: 100%;
  object-fit: cover;
  transition: transform .7s var(--ease-out);
}
.library-book:has(.card-link):hover .book-artwork img { transform: scale(1.035); }
.library-book h2 > span, .contents-hero h1 > span { display: inline-block; }
.library-book:not(:only-child) .book-artwork { order: -1; margin-bottom: 1.75rem; }
.library-empty { padding-top: 3rem; color: var(--muted); }

/* Book contents */
.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .25rem .6rem;
  color: var(--muted);
  font-size: .8125rem;
}
.breadcrumbs li {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  min-width: 0;
  overflow-wrap: anywhere;
}
.breadcrumbs a { display: inline-block; min-height: 2rem; padding-block: .3rem; text-decoration: none; }
.breadcrumbs a:hover { color: var(--ink); text-decoration: underline; }
.breadcrumbs [aria-current="page"] > :last-child { color: var(--ink); font-weight: 650; }
/* Title and author read as one block; the description and play action sit
   beside it, starting on the title's cap height. */
.contents-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  align-items: start;
  gap: 1.5rem var(--column-gap);
  padding-block: clamp(2rem, 5vw, 4.5rem) clamp(4rem, 8vw, 7rem);
}
.contents-hero h1 { font-size: clamp(3rem, 7vw, 5.75rem); }
.contents-hero .byline { margin-top: 1.25rem; }
.contents-hero .hero-text { padding-top: clamp(.4rem, 1vw, 1rem); }
.contents-hero .book-description { max-width: 44ch; margin: 0; }
.contents-hero .book-artwork {
  grid-column: 1 / -1;
  aspect-ratio: 5 / 2;
  margin-top: clamp(1.5rem, 4vw, 3.5rem);
}
.contents-hero .book-artwork img { object-position: 50% 62%; }
.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; margin-top: 1.75rem; }
.action-row:empty { display: none; }
.availability { margin-top: .9rem; color: var(--muted); font-size: .8125rem; font-variant-numeric: tabular-nums; }

.contents-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .75rem 2rem;
  padding-bottom: clamp(1.75rem, 3.5vw, 3rem);
}
.filters { display: flex; flex-wrap: wrap; gap: 0 1.5rem; }
.filters button, .caption-toggle {
  min-height: 2.75rem;
  padding: .3rem 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: .8125rem;
  font-weight: 600;
}
.filters button:hover, .filters button[aria-pressed="true"],
.caption-toggle:hover, .caption-toggle[aria-pressed="true"] {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: .4em;
}
.empty-filter { padding-block: 1rem 2rem; color: var(--muted); }

/* Each division sits in its own label column, like a margin note. */
.division {
  display: grid;
  grid-template-columns: var(--label-column) minmax(0, 1fr);
  gap: 1rem var(--column-gap);
  padding-block: 1.6rem 2.75rem;
  border-top: 1px solid var(--ink);
  scroll-margin-top: 1.5rem;
}
.division-title { padding-top: .2rem; }

/* Chapter, part and game rows share one grid: number, title, status, pages. */
.chapter summary, .contents-row a {
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 1rem;
}
.index { color: var(--muted); font-size: .8125rem; font-variant-numeric: tabular-nums; }
.chapter + .chapter { border-top: 1px solid var(--line); }
.chapter[id] { scroll-margin-top: 1.5rem; }
.chapter summary {
  position: relative;
  padding: .7rem 2rem .7rem 0;
  font-weight: 650;
  list-style: none;
}
.chapter summary::-webkit-details-marker { display: none; }
.chapter summary .index { font-weight: 500; }
.chapter-count { color: var(--muted); font-size: .8125rem; font-weight: 500; white-space: nowrap; }

/* A thin plus that becomes a minus when a chapter is open. */
.chapter summary::before, .chapter summary::after,
.engine summary::before, .engine summary::after {
  content: "";
  position: absolute;
  top: 50%;
  right: .2rem;
  width: .7rem;
  height: 1.5px;
  background: currentColor;
  transition: transform .2s ease;
}
.chapter summary::after, .engine summary::after { transform: rotate(90deg); }
details[open] > summary::after { transform: rotate(0deg); }
.chapter summary:hover .name { text-decoration: underline; text-underline-offset: .3em; }
/* Chapters unfold rather than snap open. */
@supports selector(::details-content) {
  .chapter::details-content {
    block-size: 0;
    overflow-y: clip;
    transition: block-size .22s var(--ease-in), content-visibility .22s allow-discrete;
  }
  .chapter[open]::details-content {
    block-size: auto;
    transition-duration: .4s;
    transition-timing-function: var(--ease-out);
  }
}

.contents-list { padding-bottom: 1.1rem; }
.contents-list.standalone { padding-bottom: 0; }
.contents-row a {
  grid-template-columns: 2.75rem 2.75rem minmax(0, 1fr) auto 5.5rem;
  padding-block: .38rem;
  font-size: .9375rem;
  text-decoration: none;
}
.contents-row a > :first-child { grid-column: 2; }
.contents-list.standalone .contents-row a { grid-template-columns: 2.75rem minmax(0, 1fr) auto 5.5rem; }
.contents-list.standalone .contents-row a > :first-child { grid-column: 1; }
.contents-row .name { font-weight: 500; }
.contents-row a:hover .name { text-decoration: underline; text-underline-offset: .3em; }
.contents-row:not([data-status="ready"]) .name { color: var(--muted); }
.part-status { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.row-pages { color: var(--muted); font-size: .8125rem; text-align: right; font-variant-numeric: tabular-nums; }
.reference {
  display: grid;
  grid-template-columns: var(--label-column) minmax(0, 1fr);
  gap: .25rem var(--column-gap);
  padding-top: 1.6rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .8125rem;
}
.reference > :first-child { color: var(--ink); font-weight: 650; }

/* Lesson. The video and its text sit side by side like a spread: the video
   stays in view while the narration's text scrolls beside it. */
.contents-button {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: .5rem;
  min-height: 2.75rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: .8125rem;
  font-weight: 650;
}
.contents-button svg { width: 1.1rem; height: 1.1rem; transition: transform .25s var(--ease-out); }
.contents-button:hover { text-decoration: underline; text-underline-offset: .3em; }
.contents-button:hover svg { transform: translateX(2px); }
.lesson-heading { padding-block: clamp(1.75rem, 4.5vw, 4rem) clamp(1.75rem, 3.5vw, 3rem); }
.lesson-heading h1 { max-width: 20ch; font-size: clamp(2.4rem, 5.4vw, 4.5rem); }
.lesson-meta {
  margin-top: 1.1rem;
  color: var(--muted);
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
}
.lesson-spread {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(19rem, 1fr);
  column-gap: clamp(2.5rem, 5vw, 5rem);
}
.lesson-spread.media-only { grid-template-columns: minmax(0, 56rem); }
.media-stack { position: sticky; top: calc(var(--header-h) + var(--bar-h) + 1.5rem); transition: top .35s var(--ease-out); }
/* The video frame is paper-white like the page, so the picture sits on the
   page with no box, shadow or overlaid controls. Controls live below it. */
.player { --progress: 0; background: var(--paper); }
.video-wrap {
  position: relative;
  overflow: hidden;
  background: var(--paper);
  aspect-ratio: 16 / 9;
  container-type: inline-size;
}
.video-wrap video { display: block; width: 100%; height: 100%; cursor: pointer; }
.video-wrap video::cue { font-size: clamp(.72rem, 3.1cqw, 1.65rem) !important; }
.master .player { max-width: 56rem; }

/* A brief mark acknowledges a click on the picture. */
.player-flash {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  margin: -1.75rem 0 0 -1.75rem;
  background: var(--ink);
  color: var(--paper);
  opacity: 0;
  pointer-events: none;
}
.player-flash svg { width: 1.3rem; height: 1.3rem; }
.player-flash.is-on { animation: flash .6s var(--ease-out); }
@keyframes flash {
  from { opacity: .92; transform: scale(.85); }
  to { opacity: 0; transform: scale(1.12); }
}
/* While the video waits for data, the progress line breathes. */
.player.is-waiting .scrubber { animation: waiting 1.2s ease-in-out infinite alternate; }
@keyframes waiting { to { opacity: .45; } }

.player-bar {
  display: flex;
  align-items: center;
  gap: .25rem .9rem;
  min-height: 3.5rem;
  padding-top: .6rem;
}
.player-toggle, .player-button {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}
.player-toggle { background: var(--ink); color: var(--paper); transition: transform .2s var(--ease-out); }
.player-toggle:hover { transform: scale(.94); }
.player-toggle:active { transform: scale(.88); }
.player-toggle svg, .player-button svg { width: 1.15rem; height: 1.15rem; }
.player-button { color: var(--muted); transition: color .15s ease; }
.player-button:hover { color: var(--ink); }
.player-time {
  flex: none;
  color: var(--ink);
  font-size: .8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.player-time span { color: var(--muted); font-weight: 500; }
.player-bar .caption-toggle { flex: none; margin-left: .25rem; }

/* The seek line: a hairline that fills with ink and thickens on approach. */
.scrubber {
  --fill: calc(var(--progress) * 100%);
  flex: 1;
  min-width: 4rem;
  height: 2.75rem;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
.scrubber::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(to right, var(--ink) var(--fill), var(--line) var(--fill));
  transition: height .2s var(--ease-out);
}
.scrubber::-webkit-slider-thumb {
  width: 3px;
  height: 14px;
  margin-top: -6px;
  appearance: none;
  border: 0;
  background: var(--ink);
  transform: scaleY(0);
  transition: transform .2s var(--ease-out), margin-top .2s var(--ease-out);
}
.scrubber:hover::-webkit-slider-runnable-track, .scrubber:focus-visible::-webkit-slider-runnable-track { height: 4px; }
.scrubber:hover::-webkit-slider-thumb, .scrubber:focus-visible::-webkit-slider-thumb { margin-top: -5px; transform: none; }
.scrubber::-moz-range-track { height: 2px; background: var(--line); }
.scrubber::-moz-range-progress { height: 2px; background: var(--ink); }
.scrubber::-moz-range-thumb { width: 3px; height: 14px; border: 0; border-radius: 0; background: var(--ink); }
.scrubber:focus-visible { outline-offset: 0; }

.player:fullscreen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 var(--gutter);
}
.player:fullscreen .video-wrap, .player:fullscreen .player-bar {
  width: min(100%, (100vh - 6rem) * 16 / 9);
  margin-inline: auto;
}

.playback-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .35rem 1.2rem;
  min-height: 2.75rem;
  color: var(--muted);
  font-size: .8125rem;
}
.playback-strip a, .playback-strip strong { color: var(--ink); font-weight: 650; }
.queue { display: inline-flex; flex-wrap: wrap; gap: 0 .75rem; }
.playback-message { margin-top: .75rem; color: var(--muted); font-size: .875rem; }
.lesson-notice { padding: clamp(1.75rem, 4vw, 3rem); background: var(--mist); }
.lesson-notice h2 { font-size: clamp(1.4rem, 2.4vw, 1.85rem); }
.lesson-notice h2 + p { margin-top: .6rem; color: var(--muted); }
.lesson-notice .button { margin-top: 1.25rem; }
.up-next { padding-block: .9rem; border-top: 1px solid var(--line); font-size: .875rem; }
.up-next a { text-decoration: none; }
.up-next a:hover .name { text-decoration: underline; text-underline-offset: .3em; }
.lesson-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}
.lesson-notice + .lesson-pager { margin-top: 1.25rem; border-top: 0; padding-top: 0; }
.lesson-pager a { display: grid; gap: .15rem; min-width: 0; text-decoration: none; font-size: .875rem; line-height: 1.45; }
.lesson-pager a.next { grid-column: 2; justify-items: end; text-align: right; }
.lesson-pager a:hover .name { text-decoration: underline; text-underline-offset: .3em; }
.lesson-pager small, .up-next p { color: var(--muted); font-size: .75rem; }
.pager-title { font-weight: 650; }
.pager-title .index { margin-right: .55rem; font-weight: 500; }
.pager-title .index:empty { display: none; }

/* Companion. With captions, each passage carries the time its narration
   starts in a narrow gutter; selecting the time plays from there. */
.companion { --time-gutter: 0rem; position: relative; align-self: start; min-width: 0; }
.companion.timed { --time-gutter: 3.5rem; }
.companion-label { margin-bottom: 1.6rem; padding-left: var(--time-gutter); }
.passage { position: relative; padding-left: var(--time-gutter); scroll-margin-top: 1.5rem; }
.passage + .passage { margin-top: 1.9rem; }
.passage h3 { margin-bottom: .3rem; font-size: 1rem; }
.passage p { color: #3d3d3a; font-size: .9375rem; }
.passage h3, .passage p { transition: color .35s ease; }
.passage.overview p { color: var(--ink); font-size: 1.1875rem; font-weight: 500; line-height: 1.5; letter-spacing: -.01em; }
.passage.takeaway { margin-top: 2.75rem; padding-top: 1.4rem; border-top: 1px solid var(--line); }
.passage.takeaway .seek { top: 1.35rem; }
.passage.takeaway h3 { margin-bottom: .6rem; color: var(--muted); font-size: .8125rem; font-weight: 600; letter-spacing: 0; }
.passage.takeaway p { color: var(--ink); font-size: 1.3125rem; font-weight: 600; line-height: 1.38; letter-spacing: -.02em; }
.seek {
  position: absolute;
  top: -.1rem;
  left: 0;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 1.75rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.passage.overview .seek { top: .05rem; }
.seek::after {
  content: "";
  width: .4rem;
  height: .5rem;
  background: currentColor;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  opacity: 0;
}
.seek:hover { color: var(--ink); }
.seek:hover::after, .passage.is-current .seek::after { opacity: 1; }
.passage.is-current .seek { color: var(--ink); }
/* The narrated passage's marker draws down from its top as the narration arrives. */
.passage::before {
  content: "";
  position: absolute;
  top: .15rem;
  bottom: .15rem;
  left: -1.25rem;
  width: 2px;
  background: var(--ink);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform .2s var(--ease-in);
}
.passage.is-current::before { transform: none; transition: transform .55s var(--ease-out); }
/* While the video plays, the passage being narrated keeps full ink. */
.companion.is-playing.is-synced .passage:not(.is-current) :is(h3, p) { color: var(--muted); }

/* Beside the video, a timed companion is a box exactly as tall as the video
   column. It scrolls on its own, so the narrated passage can sit at its top
   while the page stays still. Size containment keeps the text from setting
   the row height; the closing spacer lets the last passage reach the top. */
@media (min-width: 60.0625rem) {
  .companion.timed {
    align-self: stretch;
    container-type: size;
    margin-left: -1.25rem;
    padding: 0 1rem 0 1.25rem;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
    mask-image: linear-gradient(to bottom, #000 calc(100% - 2.5rem), transparent);
  }
  .companion.timed .companion-label {
    position: sticky;
    top: 0;
    z-index: 1;
    margin: 0;
    padding-bottom: 1.4rem;
    background: var(--paper);
  }
  .companion.timed::after { content: ""; display: block; height: calc(100cqh - 8rem); }
}

.lesson-more { margin-top: clamp(4.5rem, 9vw, 7rem); }
/* The link to the full contents lines up with the part titles above it. */
.lesson-more .division-body > .text-link { margin: .5rem 0 0 3.75rem; color: var(--muted); }
.lesson-more .text-link:hover { color: var(--ink); }
.contents-row a[aria-current] .name { font-weight: 700; }
.contents-row a[aria-current] .index { color: var(--ink); }

/* About */
.about-hero { padding-block: clamp(2rem, 5vw, 4.5rem) clamp(3.5rem, 7vw, 6rem); }
.about-hero h1 { max-width: 13ch; font-size: clamp(3rem, 7vw, 5.75rem); }
.about-lead {
  max-width: 40ch;
  margin-top: clamp(1.5rem, 3vw, 2.25rem);
  color: var(--muted);
  font-size: clamp(1.0625rem, 1.5vw, 1.3125rem);
  line-height: 1.55;
}
.about-section {
  display: grid;
  grid-template-columns: var(--label-column) minmax(0, 1fr);
  gap: 1rem var(--column-gap);
  padding-block: 1.6rem clamp(3.5rem, 7vw, 6rem);
  border-top: 1px solid var(--ink);
}
.about-section .division-title { padding-top: .2rem; font-size: .75rem; letter-spacing: .14em; line-height: 1.6; }
.about-text { display: grid; gap: 1.1rem; max-width: 62ch; color: #3d3d3a; font-size: 1.0625rem; }
.about-text p:first-child { color: var(--ink); font-size: clamp(1.1875rem, 1.6vw, 1.375rem); font-weight: 500; line-height: 1.5; letter-spacing: -.01em; }
.maker {
  display: grid;
  grid-template-columns: minmax(0, 21rem) minmax(0, 1fr);
  align-items: end;
  gap: var(--column-gap);
}
.maker-portrait { margin: 0; aspect-ratio: 4 / 5; overflow: hidden; background: var(--mist); }
.maker-portrait img { height: 100%; object-fit: cover; }
/* The portrait is uncovered from the bottom as it scrolls into view. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .maker-portrait img {
      animation: uncover linear both;
      animation-timeline: view();
      animation-range: entry 10% cover 40%;
    }
  }
}
@keyframes uncover {
  from { clip-path: inset(100% 0 0 0); transform: scale(1.08); }
  to { clip-path: inset(0); transform: none; }
}
.maker-text { display: grid; justify-items: start; gap: 1rem; max-width: 52ch; color: #3d3d3a; }
.maker-name { color: var(--ink); font-size: clamp(1.75rem, 3vw, 2.5rem); font-weight: 750; line-height: 1.04; letter-spacing: -.035em; text-wrap: balance; }
.maker-text .byline { margin: -.35rem 0 .5rem; color: var(--ink); }
.maker-elsewhere { color: var(--muted); font-size: .9375rem; }
.maker-elsewhere a { color: var(--ink); font-weight: 650; }
.about-contact { padding-bottom: 0; }
.contact-title { font-size: clamp(3rem, 8vw, 6rem); font-weight: 750; line-height: 1; letter-spacing: -.045em; }
.contact-text { max-width: 44ch; margin-top: 1.25rem; color: var(--muted); }
.contact-link { margin-top: 1.75rem; }
.contact-link .play-square svg { width: 1.15rem; height: 1.15rem; transition: transform .3s var(--ease-out); }
.contact-link:hover .play-square svg { transform: translate(2px, -2px); }

/* Chess replay */
.replay { margin-top: clamp(4.5rem, 9vw, 7rem); padding-top: 1.6rem; border-top: 1px solid var(--ink); }
.replay-heading h2 { font-size: clamp(1.5rem, 2.4vw, 2rem); }
.replay-heading p { margin-top: .3rem; color: var(--muted); font-size: .9375rem; }
.replay-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .82fr);
  gap: 2rem;
  margin-top: 1.5rem;
}
.board { display: grid; grid-template-columns: repeat(8, 1fr); aspect-ratio: 1; container-type: inline-size; overflow: hidden; }
.square { display: grid; position: relative; place-items: center; aspect-ratio: 1; }
.square.light { background: #f0efeb; color: #6b6b66; }
.square.dark { background: #c9c8c1; color: #4a4a46; }
.square.last-move::after { content: ""; position: absolute; inset: 0; background: rgb(29 29 27 / .13); }
.square.highlight::before { content: ""; position: absolute; z-index: 1; inset: 0; box-shadow: inset 0 0 0 3px var(--ink); }
.piece { position: relative; z-index: 1; width: 88%; height: 88%; }
.piece-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.rank, .file { position: absolute; z-index: 2; font: 600 clamp(.55rem, 2.3cqw, .72rem) / 1 var(--font); }
.rank { top: 3px; left: 4px; }
.file { bottom: 3px; right: 4px; }
.board-controls { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: .75rem; border-top: 1px solid var(--line); }
.board-controls button, .move-list button, .teaching-stops button {
  border: 0;
  background: transparent;
  color: var(--ink);
}
.board-controls button { min-height: 2.75rem; padding: .4rem .25rem; font-size: .8125rem; font-weight: 600; }
.board-controls button:disabled { color: var(--muted); opacity: .5; }
.board-controls button:hover:not(:disabled), .move-list button:hover, .teaching-stops button:hover {
  text-decoration: underline;
  text-underline-offset: .3em;
}
.replay-lines { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.replay-lines button {
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  min-height: 2.75rem;
  padding: .35rem .75rem;
  font-size: .875rem;
  font-weight: 600;
}
.replay-lines button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.replay-position { margin-bottom: 1rem; font-size: .9375rem; }
.replay-position span { color: var(--muted); }
.move-list { display: flex; flex-wrap: wrap; gap: .1rem 1rem; font-size: .9375rem; font-variant-numeric: tabular-nums; }
.move-pair { display: inline-flex; align-items: baseline; gap: .15rem; white-space: nowrap; }
.move-number { color: var(--muted); font-size: .8125rem; margin-right: .2rem; }
.move-list button { min-height: 2rem; padding: .1rem .3rem; font-weight: 500; }
.move-list button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.teaching-stops { display: grid; justify-items: start; margin-top: 1.5rem; border-top: 1px solid var(--line); }
.teaching-stops button {
  width: 100%;
  min-height: 2.75rem;
  padding: .55rem 0 .55rem 1rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: .875rem;
  font-weight: 600;
  text-align: left;
  box-shadow: inset 2px 0 0 transparent;
}
.teaching-stops button[aria-pressed="true"] { color: var(--ink); box-shadow: inset 2px 0 0 var(--ink); }
.replay-explanation { margin-top: 1rem; font-size: .9375rem; }
.engine { margin-top: 1.25rem; font-size: .875rem; }
.engine summary { position: relative; padding: .3rem 1.75rem .3rem 0; font-weight: 650; list-style: none; }
.engine summary::-webkit-details-marker { display: none; }
.engine summary:hover { text-decoration: underline; text-underline-offset: .3em; }
.engine p { margin-top: .45rem; }
.engine-meta { display: flex; flex-wrap: wrap; gap: 0 1rem; color: var(--muted); }

/* Lesson contents panel. It slides in from the left edge over a dimmed page,
   opened on the current chapter, and leaves faster than it arrives. */
.contents-drawer {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(30rem, 100vw - 2.5rem);
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  overflow: hidden auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  transform: translateX(-100%);
  transition: transform .26s var(--ease-in), overlay .26s allow-discrete, display .26s allow-discrete;
}
.contents-drawer[open] { transform: none; transition-duration: .5s; transition-timing-function: var(--ease-out); }
@starting-style { .contents-drawer[open] { transform: translateX(-100%); } }
.contents-drawer::backdrop {
  background: rgb(29 29 27 / 0);
  transition: background-color .26s ease, overlay .26s allow-discrete, display .26s allow-discrete;
}
.contents-drawer[open]::backdrop { background: rgb(29 29 27 / .32); transition-duration: .5s; }
@starting-style { .contents-drawer[open]::backdrop { background: rgb(29 29 27 / 0); } }
.drawer-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 1.25rem 1.25rem 1.75rem;
  background: var(--paper);
}
.drawer-title { font-size: 1.5rem; font-weight: 750; line-height: 1.1; letter-spacing: -.03em; }
.drawer-subtitle { margin-top: .35rem; font-size: .8125rem; font-weight: 650; }
.drawer-close {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-top: -.6rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  transition: transform .25s var(--ease-out);
}
.drawer-close svg { width: 1.2rem; height: 1.2rem; }
.drawer-close:hover { transform: rotate(90deg); }
.drawer-body { padding: 0 1.75rem 3rem; }
.contents-drawer .division { grid-template-columns: minmax(0, 1fr); gap: .5rem; padding-block: 1.1rem 1.5rem; }
.contents-drawer .division-title { color: var(--muted); }
.contents-drawer .chapter summary { grid-template-columns: 2rem minmax(0, 1fr) auto; column-gap: .6rem; font-size: .9375rem; }
.contents-drawer .chapter-count { display: none; }
.contents-drawer .contents-row a,
.contents-drawer .contents-list.standalone .contents-row a { grid-template-columns: 2rem minmax(0, 1fr) auto; column-gap: .6rem; font-size: .875rem; }
.contents-drawer .contents-row a > :first-child,
.contents-drawer .contents-list.standalone .contents-row a > :first-child { grid-column: 1; }
.contents-drawer .contents-list:not(.standalone) { padding-left: 2.6rem; }
.contents-drawer .row-pages { display: none; }
.contents-drawer .contents-row a[aria-current] { position: relative; }
.contents-drawer .contents-row a[aria-current]::before {
  content: "";
  position: absolute;
  top: .45rem;
  bottom: .45rem;
  left: -.85rem;
  width: 2px;
  background: var(--ink);
}

/* Route changes: the old page lifts away quickly, the new one settles in.
   A book's artwork and title travel between the library and its contents. */
::view-transition-old(root) { animation: page-out .16s var(--ease-in) both; }
::view-transition-new(root) { animation: page-in .45s var(--ease-out) both; }
@keyframes page-out { to { opacity: 0; } }
@keyframes page-in { from { opacity: 0; transform: translateY(.6rem); } }
::view-transition-group(*.art), ::view-transition-group(*.title) {
  animation-duration: .55s;
  animation-timing-function: var(--ease-out);
}
::view-transition-old(*.art), ::view-transition-new(*.art) { width: 100%; height: 100%; object-fit: cover; }
::view-transition-old(*.title), ::view-transition-new(*.title) {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: left top;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: .01ms !important; }
  .player-flash.is-on { animation: none; }
  .library-book:hover .book-artwork img { transform: none; }
}

@media (max-width: 64rem) {
  .contents-hero { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .about-maker { grid-template-columns: minmax(0, 1fr); }
  .maker { grid-template-columns: minmax(0, min(40%, 21rem)) minmax(0, 1fr); }
}

/* In one column the player stays pinned to the top while the text scrolls under it. */
@media (max-width: 60rem) {
  .lesson-spread { grid-template-columns: minmax(0, 1fr); }
  .spread-media, .media-stack { display: contents; }
  .lesson-spread .player { position: sticky; top: calc(var(--header-h) + var(--bar-h)); z-index: 2; transition: top .35s var(--ease-out); }
  .lesson-spread .player-bar { padding-block: .35rem; border-bottom: 1px solid var(--line); }
  .lesson-spread .lesson-pager { order: 1; margin-top: 3rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
  .companion { margin-top: 2rem; }
  .passage { scroll-margin-top: calc((100vw - 2 * var(--gutter)) * 9 / 16 + 5rem); }
}

@media (max-width: 58rem) {
  .replay-layout { grid-template-columns: minmax(0, 1fr); }
  .replay-layout > :first-child { max-width: 28rem; width: 100%; }
}

@media (max-width: 42rem) {
  :root { --label-column: minmax(0, 1fr); --header-h: 4.25rem; --bar-h: 2.75rem; }
  :root.is-scrolled { --header-h: 3.5rem; }
  .about-section { grid-template-columns: minmax(0, 1fr); }
  .maker { grid-template-columns: minmax(0, 1fr); gap: 1.75rem; }
  .maker-portrait { max-width: 20rem; }
  .library-heading, .library-book:only-child.has-artwork, .contents-hero,
  .division, .reference { grid-template-columns: minmax(0, 1fr); }
  .library-heading { gap: 1rem; }
  .library-heading p { padding-bottom: 0; }
  .library-books { gap: 3.5rem; }
  .library-book:only-child.has-artwork { gap: 1.75rem; }
  .library-book .book-artwork { order: -1; }
  .contents-hero { gap: 0; }
  .contents-hero .byline { margin-top: 1rem; }
  .contents-hero .hero-text { margin-top: 1.25rem; padding-top: 0; }
  .contents-hero .book-artwork { aspect-ratio: 3 / 2; margin-top: 2.5rem; }
  .division { gap: .9rem; padding-bottom: 2rem; }
  .chapter summary, .contents-row a { column-gap: .6rem; }
  .chapter summary { grid-template-columns: 2rem minmax(0, 1fr); }
  .chapter-count { grid-column: 2; }
  .contents-row a,
  .contents-list.standalone .contents-row a { grid-template-columns: 2rem minmax(0, 1fr) auto; }
  .contents-row a > :first-child,
  .contents-list.standalone .contents-row a > :first-child { grid-column: 1; }
  .contents-row .part-status { grid-row: 2; grid-column: 2; }
  .lesson-spread .player { margin-inline: calc(var(--gutter) * -1); }
  .lesson-spread .player-bar { gap: .25rem .6rem; padding-inline: calc(var(--gutter) - .5rem) var(--gutter); }
  .lesson-spread .player-time span, .master .player-time span { display: none; }
  .lesson-pager { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
  .companion.timed { --time-gutter: 3rem; }
  .passage { scroll-margin-top: calc(56.25vw + 5rem); }
  .passage::before { left: -.75rem; }
  .lesson-more .division-body > .text-link { margin-left: 2.6rem; }
  /* On a phone the lesson breadcrumb becomes one link back to its chapter;
     the title right below already names the lesson. */
  .lesson .breadcrumbs li:not(:nth-last-child(2)) { display: none; }
  .lesson .breadcrumbs li > span[aria-hidden] { display: none; }
  .lesson .breadcrumbs li::before {
    content: "";
    flex: none;
    width: .4rem;
    height: .4rem;
    margin-right: .15rem;
    border: solid currentColor;
    border-width: 0 0 1.5px 1.5px;
    transform: translateY(-.1rem) rotate(45deg);
  }
  .lesson .breadcrumbs li { align-items: center; }
  .lesson .breadcrumbs a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 62vw; }
}

@media (max-width: 26rem) {
  .player .player-bar { column-gap: .25rem; padding-inline: .5rem; }
  .player-bar .caption-toggle { margin-left: 0; }
  .scrubber { min-width: 2rem; }
  .player:fullscreen { padding-inline: .5rem; }
  .player:fullscreen .player-bar { padding-inline: 0; }
}

/* In short landscape viewports the player needs to scroll with its controls. */
@media (orientation: landscape) and (max-width: 60rem) and (max-height: 30rem) {
  .lesson-spread .player { position: static; }
  .passage { scroll-margin-top: 1.5rem; }
}

@media (forced-colors: active) {
  .button.primary, .language select, .play-square, .player-toggle { border: 1px solid ButtonText; }
  .scrubber::-webkit-slider-runnable-track { background: ButtonText; }
  .play-icon { forced-color-adjust: none; background: ButtonText; }
  .move-list button[aria-pressed="true"], .teaching-stops button[aria-pressed="true"], .replay-lines button[aria-pressed="true"] { outline: 2px solid Highlight; }
}
