/* The Asymmetry Engine: the reading layout, loaded after the page's inline styles.
   Black and white, the site's serif. From 880px verse numbers sit in the left
   gutter; from 1200px each verse's margin sits beside it (the text column stays
   42rem). Below that the margin opens under its verse from the + toggle. */

article a,
.pop a {
  color: inherit;
}

a.ref {
  text-decoration-color: #aaa;
  text-underline-offset: 0.15em;
}

a.lw {
  text-decoration: underline dotted #888;
  text-underline-offset: 0.22em;
}

a.ref:hover,
a.lw:hover {
  text-decoration-color: currentColor;
}

/* ------------------------------------------------------------ headings */

article h1 {
  font-size: 2.2rem;
  line-height: 1.15;
  margin: 0 0 0.4rem;
}

article h1 + p,
article h1 + .subtitle + p {
  margin-top: 0;
  color: #666;
}

article h1 + .subtitle {
  margin: 0 0 0.4rem;
  color: inherit;
}

article h2,
article h3,
article h4 {
  position: relative;
  line-height: 1.25;
}

article h2 {
  font-size: 1.55rem;
  margin: 3rem 0 1.2rem;
}

article h3 {
  font-size: 1.2rem;
  margin: 2.2rem 0 0.9rem;
}

article h4 {
  font-size: 1rem;
  font-style: italic;
  margin: 1.8rem 0 0.7rem;
}

.hn {
  color: #999;
  font-weight: normal;
  font-style: normal;
  font-variant-numeric: tabular-nums;
  margin-right: 0.45em;
}

h2.part {
  margin: 4.5rem 0 1rem;
  padding-top: 2.5rem;
  border-top: 1px solid #000;
  font-size: 1rem;
  font-weight: normal;
  letter-spacing: 0.14em;
  text-align: center;
  text-transform: uppercase;
}

/* ------------------------------------------------------------ contents and the note */

nav.toc {
  max-width: none;
  margin: 2.2rem 0 1.8rem;
}

.toc h2 {
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
  font-weight: normal;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #666;
}

.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc li {
  margin: 0.15rem 0;
}

.toc ol ol {
  margin: 0.2rem 0 0.5rem;
  padding-left: 2rem;
  font-size: 0.92rem;
}

.toc a {
  text-decoration: none;
}

.toc a:hover {
  text-decoration: underline;
}

.toc .hn {
  display: inline-block;
  min-width: 2rem;
  margin: 0;
}

.toc ol ol .hn {
  min-width: 2.6rem;
}

.toc .tp {
  margin: 1rem 0 0.3rem;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #666;
}

.toc summary {
  cursor: pointer;
  list-style: none;
}

.toc summary::-webkit-details-marker {
  display: none;
}

.toc summary::after {
  content: "+";
  margin-left: 0.5em;
  font-size: 0.85em;
  color: #999;
}

.toc details[open] > summary::after {
  content: "\2212";
}

.howto {
  margin: 0 0 2.5rem;
  padding: 0.1rem 0;
  border-top: 1px solid #ccc;
  border-bottom: 1px solid #ccc;
  font-size: 0.92rem;
  color: #333;
}

.howto p {
  margin: 0.7rem 0;
}

/* ------------------------------------------------------------ chapters and verses */

.ch {
  content-visibility: auto;
  contain-intrinsic-size: auto var(--cn, 6000px);
}

.v {
  position: relative;
  margin: 1rem 0;
}

.v,
.eq,
.box,
figure,
article h2,
article h3,
article h4 {
  scroll-margin-top: 1.5rem;
}

.v > * {
  margin-top: 0;
  margin-bottom: 0;
}

.v > * + * {
  margin-top: 0.6rem;
}

.v > .mg + *,
.v > .vhp + * {
  margin-top: 0;
}

.vh {
  margin-right: 0.3rem;
  font-size: 0.7rem;
  line-height: 1;
  white-space: nowrap;
  vertical-align: 0.3em;
  font-variant-numeric: tabular-nums;
}

a.vn {
  color: #999;
  text-decoration: none;
}

a.vn:hover {
  color: #000;
  text-decoration: underline;
}

.vhp {
  padding-bottom: 0.25rem;
  line-height: 1;
}

.mt {
  display: none;
  position: relative;
  width: 1.1rem;
  height: 1.1rem;
  margin: 0 0 0 0.3rem;
  padding: 0;
  border: 1px solid #bbb;
  border-radius: 50%;
  background: #fff;
  color: #555;
  font: inherit;
  font-size: 0.7rem;
  line-height: 1;
  text-align: center;
  vertical-align: 0.05em;
  cursor: pointer;
}

html.js .mt {
  display: inline-block;
}

.mt::before {
  content: "+";
}

.v.open .mt::before {
  content: "\2212";
}

.mt::after {
  content: "";
  position: absolute;
  inset: -0.55rem;
}

.mt:hover {
  border-color: #000;
  color: #000;
}

.mt:focus-visible {
  outline: 2px solid #000;
  outline-offset: 2px;
}

.mg {
  display: none;
  font-size: 0.8rem;
  line-height: 1.4;
  color: #666;
}

.mg p {
  margin: 0 0 0.2rem;
}

.mg a {
  color: #444;
  text-decoration: none;
}

.mg a:hover {
  text-decoration: underline;
}

@media (max-width: 1199.98px) {
  .v.open {
    display: flex;
    flex-direction: column;
  }

  .v.open > .mg {
    display: block;
    order: 1;
    margin-top: 0.55rem;
    padding: 0.3rem 0 0.3rem 0.7rem;
    border-left: 2px solid #ccc;
  }
}

/* ------------------------------------------------------------ objects */

.box {
  padding: 0.7rem 1rem;
  border: 1px solid #000;
}

.box > * {
  margin: 0.55rem 0;
}

.box > :first-child {
  margin-top: 0;
}

.box > :last-child {
  margin-bottom: 0;
}

.box.fc {
  border-style: dashed;
}

.fcd {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.15rem 0.9rem;
  font-size: 0.92rem;
}

.fcd dt {
  color: #666;
}

.fcd dd {
  margin: 0;
}

details.pf > summary {
  width: fit-content;
  font-style: italic;
  color: #444;
  cursor: pointer;
}

details.pf[open] {
  padding-left: 0.9rem;
  border-left: 1px solid #ccc;
}

details.pf > :not(summary) {
  margin: 0.55rem 0;
}

details.proof > :last-child::after {
  content: " \220E";
}

.eq {
  display: block;
}

.katex-display {
  margin: 0.4rem 0;
  padding: 0.15rem 0;
  overflow-x: auto;
  overflow-y: hidden;
}

figure.fig,
figure.anim {
  margin: 0;
}

figure.fig img {
  margin: 0 auto 0.6rem;
}

figcaption {
  font-size: 0.9rem;
  line-height: 1.45;
  color: #222;
}

figure.anim figcaption {
  margin-top: 0.6rem;
}

.fn {
  font-weight: bold;
}

/* Reserves the widget's space before it mounts, on the page's white: the
   canvas height core.js will pick (width × height / 680, kept between 260px
   and the figure's height, 420 by default) plus the controls under it. */
figure.anim {
  container-type: inline-size;
}

.anim-stage:empty {
  box-sizing: border-box;
  height: calc(clamp(260px, 100cqw * var(--h, 420) / 680, var(--h, 420) * 1px) + 3rem);
  border: 1px solid #e5e5e5;
  background: #fff;
}

figure.anim noscript p {
  margin: 0.5rem 0;
  font-size: 0.9rem;
  color: #666;
}

.anim-error {
  margin: 0;
  padding: 1rem;
  border: 1px solid #e5e5e5;
  background: #f6f6f6;
  color: #333;
  font-size: 0.9rem;
}

/* ------------------------------------------------------------ appendices */

.gi {
  font-size: 0.92rem;
  color: #666;
}

.fcr {
  margin: 1rem 0;
}

.fcr p {
  margin: 0;
}

.fcm {
  font-size: 0.88rem;
  color: #666;
}

.ix {
  list-style: none;
  padding-left: 0;
}

.ix li {
  margin: 0.25rem 0;
}

.ixe li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.8rem;
}

.ixw {
  font-size: 0.9rem;
  color: #666;
}

.ixe .katex {
  font-size: 1em;
}

.cc {
  margin: 0.35rem 0;
  padding-left: 1.5rem;
  text-indent: -1.5rem;
}

.cc a.ref,
.sb a.ref {
  color: #444;
  text-decoration: none;
}

.chl {
  list-style: none;
  padding-left: 0;
}

.chl li {
  margin: 0.35rem 0;
  padding-left: 3rem;
  text-indent: -3rem;
}

.chl li > a.ref:first-child {
  display: inline-block;
  min-width: 3rem;
  text-indent: 0;
  color: #999;
  text-decoration: none;
}

.src {
  padding-left: 1.3rem;
}

.src li {
  margin: 0.35rem 0;
}

.sh,
.sb {
  font-size: 0.85rem;
  color: #666;
}

/* ------------------------------------------------------------ previews and the target */

.pop {
  position: absolute;
  z-index: 30;
  box-sizing: border-box;
  width: min(30rem, calc(100vw - 1rem));
  max-height: min(26rem, 70vh);
  overflow: auto;
  padding: 0.55rem 0.9rem 0.75rem;
  border: 1px solid #000;
  background: #fff;
  color: #000;
  box-shadow: 0 0.4rem 1.4rem rgba(0, 0, 0, 0.18);
  font-size: 0.92rem;
  line-height: 1.45;
}

.pop + .pop {
  z-index: 31;
}

.pop-h {
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
}

.pop-h a {
  color: #666;
}

@media (pointer: coarse) {
  .pop-h {
    font-size: 0.9rem;
  }

  .pop-h a {
    display: inline-block;
    padding: 0.35rem 0;
  }
}

.pop .v,
.pop h2,
.pop h3,
.pop h4 {
  margin: 0 0 0.5rem;
}

.pop h2,
.pop h3,
.pop h4 {
  font-size: 1rem;
}

.pop .v,
.pop .v.open {
  display: block;
}

.pop .hn {
  position: static;
}

.pop .mg,
.pop .vhp,
.pop .vh,
.pop .anim-stage,
.pop noscript {
  display: none;
}

.pop figure.fig img {
  width: auto;
  max-height: 14rem;
  margin: 0 0 0.5rem;
}

.hl {
  animation: book-hl 2.6s ease-out;
}

@keyframes book-hl {
  0%,
  35% {
    background: #e9e9e9;
    box-shadow: 0 0 0 0.45rem #e9e9e9;
  }
  100% {
    background: transparent;
    box-shadow: 0 0 0 0.45rem transparent;
  }
}

/* ------------------------------------------------------------ wider screens */

@media (min-width: 880px) {
  .ch {
    margin-left: -6rem;
    padding-left: 6rem;
    contain-intrinsic-size: auto var(--ch, 4000px);
  }

  .vh,
  .ch > h2 .hn,
  .ch > h3 .hn,
  .ch > h4 .hn {
    position: absolute;
    right: calc(100% + 0.9rem);
    margin: 0;
    white-space: nowrap;
  }

  .vh {
    padding-top: 0.1rem;
    font-size: 0.72rem;
    line-height: 1.5rem;
    vertical-align: baseline;
  }

  .vhp {
    padding: 0;
  }

  /* A boxed verse's number lines up with the first line inside the box. */
  .v > .vhp:has(+ .box) > .vh {
    top: calc(0.7rem + 1px);
  }
}

@media (min-width: 1200px) {
  body > nav,
  main {
    margin-left: min(calc((100% - 42rem) / 2), calc(100% - 60rem));
    margin-right: auto;
  }

  .ch {
    margin-right: -18rem;
    padding-right: 18rem;
  }

  .v > .mg {
    display: block;
    float: right;
    clear: right;
    width: 14.5rem;
    margin: 0.2rem -17rem 0 0;
  }

  .v:has(> .vhp + .box) > .mg {
    margin-top: calc(0.9rem + 1px);
  }

  html.js .mt {
    display: none;
  }
}
