/* The shared Aa control sets data-theme and --font on <html>. Keep its
   navigation dimensions independent of the book's adjustable reading type. */
html {
  -webkit-text-size-adjust: 100%;
  --book-paper: #f6f1e5;
  --book-ink: #282a2b;
  --book-secondary: #52594f;
  --book-pen: #263f79;
  --book-rule: #c8c5b9;
  --book-link-rule: #8b93a1;
  --book-link-hover: #152952;
  --book-plate-filter: none;
  --book-serif: Georgia, "Times New Roman", serif;
  background-color: var(--book-paper);
  color-scheme: light;
}

html[data-theme="dark"] {
  --book-paper: #242520;
  --book-ink: #f0eee3;
  --book-secondary: #bdbfb2;
  --book-pen: #b6cbf5;
  --book-rule: #505349;
  --book-link-rule: #858fa5;
  --book-link-hover: #d5e4ff;
  --book-plate-filter: brightness(0) invert(86%) sepia(15%) saturate(837%) hue-rotate(182deg);
  color-scheme: dark;
}

.still-reader main *, .still-reader .end *, .still-reader .skip {
  box-sizing: border-box;
}

.still-reader {
  margin: 0;
  --reader-size: var(--font, 1.125rem);
  --book-gutter: clamp(1.15rem, 5vw, 5.5rem);
  background: var(--book-paper);
  color: var(--book-ink);
}

.still-reader.modal-open { overflow: hidden; }

.still-reader main,
.still-reader .end {
  font: 400 var(--reader-size)/1.5 Golos, Arial, sans-serif;
  background: var(--book-paper);
  color: var(--book-ink);
}

.still-reader .book-intro,
.still-reader :is(.index, .end) > .wrap {
  width: min(100% - 2 * var(--book-gutter), 68rem);
  margin-inline: auto;
}

.still-reader :is(main, .end) a,
.still-reader .skip {
  color: var(--book-pen);
  text-decoration: underline;
  text-underline-offset: .2em;
  text-decoration-thickness: max(.06em, 1px);
}

.still-reader :is(main, .end) a:hover {
  color: var(--book-link-hover);
  text-decoration-thickness: max(.1em, 2px);
}

.still-reader :is(main, .end) a:focus-visible,
.still-reader .skip:focus-visible {
  outline: 3px solid var(--book-pen);
  outline-offset: 3px;
}

.still-reader .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.still-reader .skip {
  position: fixed;
  inset: .5rem auto auto .5rem;
  transform: translateY(calc(-100% - 1rem));
  padding: .65rem 1rem;
  z-index: 100;
  background: var(--book-paper);
}

.still-reader .skip:focus { transform: none; }

.book-intro {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(12rem, .72fr);
  grid-template-areas: "text art" "action art";
  align-items: center;
  column-gap: clamp(2rem, 7vw, 8rem);
  padding-block: clamp(2.2rem, 6vw, 6rem);
}

.intro-text { grid-area: text; align-self: end; }

.by-author {
  margin: 0 0 1em;
  font-size: .86em;
  color: var(--book-secondary);
}

.book-intro h1, .leaf h2, .index h2 {
  font-family: var(--book-serif);
  font-weight: 600;
  letter-spacing: -.035em;
  text-wrap: balance;
}

.book-intro h1 {
  margin: 0;
  max-width: 12ch;
  font-size: clamp(2.65em, 5.8vw, 4.6em);
  line-height: 1.03;
}

.book-intro .subtitle {
  max-width: 29ch;
  margin: 1em 0 0;
  font-size: clamp(1.08em, 2.2vw, 1.5em);
  line-height: 1.38;
  text-wrap: balance;
}

.jacket {
  display: block;
  grid-area: art;
  justify-self: center;
  width: min(100%, 18.5rem);
  height: auto;
  border: 1px solid var(--book-rule);
}

.invitation {
  grid-area: action;
  align-self: start;
  max-width: 49ch;
  padding-top: 1.5rem;
}

.invitation p { margin: 0; }
.invitation p + p { margin-top: .38em; }
.relationship { font-weight: 600; }

.read-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem 1.6rem;
  margin-top: 1.5rem;
}

.read-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  gap: .4em;
}

.still-reader .read-links .primary {
  padding: .62em 1.12em;
  border-radius: 3px;
  color: var(--book-paper);
  background: var(--book-pen);
  font-weight: 600;
  text-decoration: none;
}

.still-reader .read-links .primary:hover { background: var(--book-link-hover); }
.read-links small { font-size: .84em; }

.index, .leaf, .end { border-top: 1px solid var(--book-rule); }

/* reader.js measures .site-header on load and whenever the header resizes. */
.index, .leaf { scroll-margin-top: calc(var(--mast-height, 5rem) + .65rem); }

.index { padding-block: clamp(2rem, 4.5vw, 4rem); }

.index h2 {
  margin: 0 0 1em;
  font-size: clamp(2em, 3.8vw, 2.7em);
  line-height: 1.08;
}

.index-groups { columns: 2; column-gap: clamp(2rem, 6vw, 6rem); }
.index-groups section { break-inside: avoid; padding-bottom: 1.5rem; }

.index-groups h3 {
  margin: 0 0 .5em;
  color: var(--book-secondary);
  font: 600 .95em/1.4 Golos, Arial, sans-serif;
}

.index-groups ol { margin: 0; padding-inline-start: 2em; }
.index-groups li { padding-inline-start: .16em; }
.index-groups li::marker { color: var(--book-secondary); font-size: .85em; font-variant-numeric: tabular-nums; }

.still-reader .index-groups a {
  display: inline-block;
  padding-block: .45em;
  color: var(--book-ink);
  text-decoration-color: var(--book-link-rule);
  line-height: 1.42;
}

.still-reader .index-groups a:hover { color: var(--book-pen); text-decoration-color: currentColor; }
.leaf { padding-block: clamp(2.85rem, 6.5vw, 5.65rem); }
.leaf-inner { width: min(100% - 2 * var(--book-gutter), 40rem); margin-inline: auto; }

.leaf-index {
  margin: 0 0 .8em;
  color: var(--book-pen);
  font: 500 .85em/1.4 Golos, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}

.leaf h2 {
  margin: 0 0 .75em;
  font-size: clamp(2em, 4.7vw, 3.1em);
  line-height: 1.08;
}

.leaf-copy {
  font: calc(var(--reader-size) + clamp(1px, .38vw, 4px))/1.56 var(--book-serif);
}

.leaf-copy p { margin: 0; text-wrap: pretty; }
.leaf-copy p + p { margin-top: .86em; }

.drawing {
  display: flex;
  justify-content: center;
  margin: 1.55rem 0;
}
.drawing:last-child { margin-bottom: 0; }
.drawing img {
  display: block;
  width: min(var(--draw-width), 100%);
  height: auto;
  background: transparent;
  filter: var(--book-plate-filter);
  mix-blend-mode: normal;
}

.plain-switch { display: inline-block; margin-top: 1em; }

.still-reader .end .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.25rem 2rem;
  padding-block: clamp(1.75rem, 4vw, 2.5rem);
}

.end .wrap > div { flex: 1 1 20rem; }
.end p { color: var(--book-secondary); margin: 0 0 .35em; font-size: .9em; }
.end nav { display: flex; align-items: center; flex-wrap: wrap; gap: .15rem 1.2rem; }
.end .wrap > div > a { text-wrap: balance; }
.end a { display: inline-block; min-height: 44px; padding-block: .55em; }

.book-intro :is(h1, p), .index :is(h2, h3, a), .leaf :is(h2, p), .end :is(p, a) {
  overflow-wrap: break-word;
  hyphens: auto;
}

@media (max-width: 44em) {
  .book-intro {
    grid-template-columns: minmax(0, 1fr) minmax(5.4rem, 25%);
    grid-template-areas: "text art" "action action";
    column-gap: .85rem;
  }
  .intro-text { align-self: center; }
  .book-intro h1 { font-size: clamp(1.9em, 8vw, 3.15em); }
  .book-intro .subtitle { font-size: 1.02em; }
  .invitation { padding-top: 1.4rem; }
  .read-links { margin-top: 1rem; }
  .index-groups { columns: 1; }
  .index-groups section:last-child { padding-bottom: 0; }
  .still-reader .index-groups a { padding-block: .56em; }
}

@media (max-width: 24em) {
  .book-intro { grid-template-columns: minmax(0, 1fr) 22%; column-gap: .55rem; }
}

@media print {
  html, html[data-theme="dark"] {
    color-scheme: light;
    --book-paper: white;
    --book-ink: black;
    --book-secondary: #444;
    --book-pen: #263f79;
    --book-plate-filter: none;
  }
  .site-header, .skip, .read-links, .end, .index { display: none !important; }
  .book-intro { display: block; }
  .jacket { max-width: 8rem; margin: 1rem auto; }
  .leaf { break-before: page; padding: 1rem 0; }
  .leaf-inner { width: 100%; }
  .drawing { break-inside: avoid; }
}
