/*
 * Chapters — the blog set as one book.
 *
 * Every post is a chapter (scripts/apply-chapters.mjs) and the blog index is
 * the table of contents (scripts/build-blog-index.mjs). Type and colour are
 * this site's own (assets/theme.css): EB Garamond, IM Fell English italic,
 * Source Sans 3, ink and one deep green.
 *
 * Scoped to main.chapter (a post) and main.book (the contents), so no other
 * page changes.
 */

:root {
  --ch-col: 620px; /* the measure of the text */
  --ch-pad: 22px; /* page gutter on small screens */
  --ch-fs: 21px; /* body size */
  --ch-hero: clamp(16px, 4.14vw, 28.35px); /* title-page base size */
}
@media (max-width: 700px) {
  :root {
    --ch-fs: 19px;
  }
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* --- Frame ----------------------------------------------------------------- */

:root.light .blog-main:is(.chapter, .book) {
  max-width: none;
  margin: 0;
  padding: 0 var(--ch-pad) 6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--tf-serif);
  font-size: var(--ch-fs);
  line-height: 1.6;
  color: var(--tf-ink);
}
:root.light .blog-main:is(.chapter, .book) > * {
  width: 100%;
  max-width: var(--ch-col);
}
:root.light .blog-main.chapter > :is(.blog-eyebrow, .blog-original-note),
:root.light .blog-main.book > .blog-eyebrow {
  display: none;
}
/* Tags and calls to action follow the colophon, whatever order the page has. */
:root.light .blog-main.chapter > .blog-tags {
  order: 2;
  justify-content: center;
  margin-top: 3rem;
}
:root.light .blog-main.chapter > :is(.blog-subscribe-cta, .blog-contact-cta, .blog-back-link) {
  order: 3;
}

/* --- Title page ------------------------------------------------------------ */

.ch-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100svh - 58px);
  padding: 63px 0 31.5px;
  font-size: var(--ch-hero);
  font-weight: 520;
  line-height: 1.2;
  text-align: center;
}
:root.light .blog-main.chapter .ch-hero {
  max-width: 606px;
}
:root.light .ch-hero > h1,
:root.light .blog-main.book > h1 {
  margin: 0;
  font-family: var(--tf-serif);
  font-weight: 520;
  font-size: clamp(2.2rem, 11.74vw, 80.37px);
  line-height: 1.02;
  letter-spacing: 0.012em;
  text-transform: uppercase;
  text-wrap: balance;
  text-align: center;
  animation: none;
}
:root.light .blog-main.chapter[data-title="m"] .ch-hero > h1 { font-size: clamp(2rem, 8.8vw, 60px); }
:root.light .blog-main.chapter[data-title="l"] .ch-hero > h1 { font-size: clamp(1.7rem, 6.6vw, 46px); line-height: 1.06; }
:root.light .blog-main.chapter[data-title="xl"] .ch-hero > h1 { font-size: clamp(1.45rem, 5vw, 34px); line-height: 1.1; }
/* A leading "The" set above the title in italic lower case. */
.ch-the {
  display: block;
  margin-bottom: -0.14em;
  font-family: var(--tf-fell);
  font-style: italic;
  font-weight: 400;
  font-size: 1.08em;
  letter-spacing: 0.005em;
  text-transform: none;
}
:root.light .ch-dek,
:root.light .blog-main.book > .blog-lede {
  margin: 2em 0 0;
  font-family: var(--tf-serif);
  font-size: var(--ch-hero);
  font-weight: 520;
  line-height: 1.2;
  font-variant-caps: small-caps;
  font-feature-settings: "kern", "smcp", "onum";
  letter-spacing: 0.035em;
  color: var(--tf-ink);
  text-align: center;
  text-wrap: balance;
}
:root.light .ch-dek--long {
  font-size: calc(var(--ch-hero) * 0.8);
}
.ch-author {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 2.1em 0 0;
}
.ch-name,
.colo-name {
  font-variant-caps: small-caps;
  font-feature-settings: "kern", "smcp", "onum";
  letter-spacing: 0.045em;
}
:root.light .ch-mail {
  margin-top: 0.1em;
  padding: 0.25em 0.4em;
  font-size: 0.62em;
  font-weight: 500;
  letter-spacing: 0.012em;
  font-feature-settings: "kern", "onum";
  color: var(--tf-ink);
  text-decoration: none;
}
:root.light .ch-mail:hover {
  color: var(--tf-accent);
}
.ch-date {
  margin: 0.8em 0 0;
  font-family: var(--tf-fell);
  font-style: italic;
  font-weight: 400;
  font-size: 0.92em;
  font-feature-settings: "kern", "onum";
}
:root.light .ch-origin {
  margin: 0.9em 0 0;
  font-family: var(--tf-fell);
  font-style: italic;
  font-weight: 400;
  font-size: 0.6em;
  line-height: 1.4;
  color: var(--tf-slate);
}
:root.light .ch-origin a {
  color: inherit;
}
.ch-ways {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 2.6em 0 0;
  font-weight: 500;
  line-height: 1;
}
:root.light .ch-go,
:root.light .colo-go,
:root.light .colo-up {
  display: block;
  padding: 12px 6px;
  border: 0;
  background: none;
  color: var(--tf-ink);
  font-family: var(--tf-serif);
  font-size: inherit;
  font-weight: 500;
  line-height: 1;
  font-variant-caps: all-small-caps;
  font-feature-settings: "kern", "smcp", "c2sc", "onum";
  letter-spacing: 0.07em;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--tf-quick) var(--tf-ease);
}
:root.light :is(.ch-go, .colo-go, .colo-up):hover,
:root.light :is(.ch-go, .colo-go, .colo-up):focus-visible {
  color: var(--tf-accent);
}
:root.light .ch-go[aria-pressed="true"] {
  color: var(--tf-accent);
}
.ch-or {
  padding: 0 0.05em;
  font-family: var(--tf-fell);
  font-style: italic;
  font-weight: 400;
}

/* --- Chapter head ---------------------------------------------------------- */

.ch-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 164px;
  margin-bottom: 58px;
  text-align: center;
  scroll-margin-top: 40px;
}
.ch-kicker {
  margin-bottom: 22px;
  font-weight: 500;
  line-height: 1;
  font-variant-caps: all-small-caps;
  font-feature-settings: "kern", "smcp", "c2sc", "onum";
  letter-spacing: 0.1em;
}
:root.light .ch-head .ch-h {
  margin: 0;
  font-family: var(--tf-serif);
  font-size: 3em;
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: 0.02em;
}
:root.light .ch-time {
  margin: 1.4em 0 0;
  font-size: 18px;
  font-weight: 500;
  line-height: 1;
  font-variant-caps: all-small-caps;
  font-feature-settings: "kern", "smcp", "c2sc", "onum";
  letter-spacing: 0.07em;
}
.ch-rule {
  display: block;
  width: 1px;
  height: 46px;
  margin-top: 46px;
  background: var(--tf-rule);
}
@media (max-width: 700px) {
  .ch-head {
    padding-top: 112px;
    margin-bottom: 44px;
  }
}

/* --- The text -------------------------------------------------------------- */

:root.light .blog-main.chapter .blog-post-body {
  font-family: var(--tf-serif);
  font-size: var(--ch-fs);
  line-height: 1.6;
  font-feature-settings: "kern", "liga", "onum", "pnum";
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  text-wrap: pretty;
}
@media (max-width: 700px) {
  :root.light .blog-main.chapter .blog-post-body {
    line-height: 1.56;
  }
}
/* Browsers ship Russian hyphenation unevenly; justified without it leaves
   rivers. Russian chapters are set ragged-right. */
:root.light .blog-main.chapter[lang="ru"] .blog-post-body {
  text-align: left;
}
:root.light .blog-main.chapter .blog-post-body p {
  margin: 0;
}
:root.light .blog-main.chapter .blog-post-body p + p {
  text-indent: 1.5em;
}
:root.light .blog-main.chapter .blog-post-body :is(h2, h3, h4, blockquote, figure, ul, ol, pre, hr) + p,
:root.light .blog-main.chapter .blog-post-body p:has(> img:only-child) + p,
:root.light .blog-main.chapter .blog-post-body .ch-dek-dup + p,
:root.light .blog-main.chapter .blog-post-body .chapter-opening {
  text-indent: 0;
}
:root.light .blog-main.chapter .blog-post-body .ch-dek-dup {
  display: none;
}
/* The opening: a green drop cap two lines deep, then small-capital words. */
:root.light .blog-main.chapter .blog-post-body .chapter-opening::first-letter {
  float: left;
  margin: 0.06em 0.09em 0 0;
  font-size: 3.36em;
  line-height: 0.8;
  font-weight: 500;
  color: var(--tf-accent);
}
@supports (initial-letter: 2) or (-webkit-initial-letter: 2) {
  :root.light .blog-main.chapter .blog-post-body .chapter-opening::first-letter {
    float: none;
    margin: 0 0.12em 0 0;
    font-size: inherit;
    line-height: inherit;
    -webkit-initial-letter: 2;
    initial-letter: 2;
  }
}
.ch-li {
  font-variant-caps: small-caps;
  font-feature-settings: "kern", "smcp", "onum";
  letter-spacing: 0.045em;
}
:root.light .blog-main.chapter abbr.ac {
  font-variant-caps: all-small-caps;
  font-feature-settings: "kern", "smcp", "c2sc", "onum";
  letter-spacing: 0.045em;
  text-decoration: none;
  border: 0;
}
:root.light .blog-main.chapter .blog-post-body :is(h2, h3, h4) {
  scroll-margin-top: 90px;
  text-align: center;
  text-wrap: balance;
  hyphens: manual;
}
:root.light .blog-main.chapter .blog-post-body h2 {
  margin: 2.7em 0 1.1em;
  font-size: 1.5em;
  font-weight: 500;
  line-height: 1.15;
}
/* "Part I" from a heading such as "Part I: The Gray Market", set above it. */
.ch-in-kicker {
  display: block;
  margin-bottom: 0.7em;
  font-size: 0.667em;
  font-weight: 500;
  line-height: 1;
  font-variant-caps: all-small-caps;
  font-feature-settings: "kern", "smcp", "c2sc";
  letter-spacing: 0.1em;
}
:root.light .blog-main.chapter .blog-post-body h3 {
  margin: 2.2em 0 0.9em;
  font-size: 1.15em;
  font-style: italic;
  font-weight: 400;
  line-height: 1.3;
}
:root.light .blog-main.chapter .blog-post-body a {
  color: inherit;
  text-decoration-color: var(--tf-rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}
:root.light .blog-main.chapter .blog-post-body a:hover {
  color: var(--tf-accent);
  text-decoration-color: currentColor;
}
:root.light .blog-main.chapter .blog-post-body blockquote {
  margin: 1.8em 0;
  padding: 0 0 0 2.2em;
  border: 0;
  font-style: italic;
  color: var(--tf-ink);
}
:root.light .blog-main.chapter .blog-post-body blockquote p + p {
  text-indent: 1.5em;
}
:root.light .blog-main.chapter .blog-post-body hr {
  display: flex;
  justify-content: center;
  height: auto;
  margin: 2.2em 0;
  border: 0;
  line-height: 1;
  overflow: visible;
}
:root.light .blog-main.chapter .blog-post-body hr::before {
  content: "*\2003*\2003*";
  font-size: var(--ch-fs);
}
:root.light .blog-main.chapter .blog-post-body :is(ul, ol) {
  margin: 1em 0;
  padding-left: 1.5em;
  text-align: left;
}
:root.light .blog-main.chapter .blog-post-body li + li {
  margin-top: 0.3em;
}
:root.light .blog-main.chapter .blog-post-body figure {
  margin: 2.7em 0;
  text-align: center;
}
:root.light .blog-main.chapter .blog-post-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 2.7em auto;
}
:root.light .blog-main.chapter .blog-post-body figure img {
  margin: 0 auto;
}
:root.light .blog-main.chapter .blog-post-body figcaption {
  margin-top: 0.8em;
  font-family: var(--tf-serif);
  font-size: 16.5px;
  font-style: italic;
  line-height: 1.5;
  text-align: center;
  color: var(--tf-ink);
}
:root.light .blog-main.chapter .blog-post-body pre {
  text-align: left;
  hyphens: manual;
}
:root.light .blog-main.chapter .blog-post-body .blog-syndication-notice {
  margin-top: 2rem;
  font-family: var(--tf-sans);
  font-size: 0.8em;
  text-align: left;
}

/* --- Colophon -------------------------------------------------------------- */

:root.light .colophon {
  order: 1;
  margin-top: 9rem;
  font-size: var(--ch-hero);
  text-align: center;
}
.colo-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  margin-bottom: 1.6em;
}
.colo-mark::before,
.colo-mark::after {
  content: "";
  width: 3.5rem;
  border-top: 1px solid var(--tf-rule);
}
.colo-mark span {
  width: 0.55rem;
  height: 0.55rem;
  border: 1px solid var(--tf-ink);
  border-radius: 50%;
}
:root.light .colo-by {
  margin: 0;
  font-weight: 520;
  line-height: 1.2;
}
:root.light .colo-fin {
  margin: 0.35em 0 0;
  font-family: var(--tf-fell);
  font-style: italic;
  font-size: 0.66em;
  line-height: 1.4;
}
.colo-ways {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin: 1.9em 0 0;
  font-size: 19px;
}
.colo-dot {
  padding: 0 0.4em;
  font-weight: 500;
}
:root.light .colo-cite {
  max-width: 30em;
  margin: 0.6em auto 0;
  font-family: var(--tf-serif);
  font-size: 17px;
  line-height: 1.5;
  color: var(--tf-slate);
  overflow-wrap: anywhere;
}
.colo-chapters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 3rem 0 0;
  text-align: left;
}
:root.light .colo-ch {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--tf-ink);
  text-decoration: none;
}
.colo-ch--next {
  align-items: flex-end;
  text-align: right;
}
.colo-ch__n {
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  font-variant-caps: all-small-caps;
  font-feature-settings: "kern", "smcp", "c2sc";
  letter-spacing: 0.08em;
}
.colo-ch__t {
  font-size: 17px;
  font-style: italic;
  line-height: 1.4;
  text-wrap: balance;
}
:root.light .colo-ch:hover {
  color: var(--tf-accent);
}
.colo-up-wrap {
  margin: 2.4rem 0 0;
}
:root.light .colo-up {
  display: inline-block;
  font-size: 17px;
}
@media (max-width: 560px) {
  .colo-chapters {
    grid-template-columns: 1fr;
  }
  .colo-ch--next {
    align-items: flex-start;
    text-align: left;
  }
}

/* --- Reading rail and progress line (drawn by assets/js/chapters.js) ------- */

.rail {
  position: fixed;
  left: 34px;
  top: 120px;
  bottom: 120px;
  width: 28px;
  z-index: 20;
  display: none;
  font-family: var(--tf-serif);
}
@media (min-width: 1100px) {
  .rail {
    display: block;
  }
}
.rail-track,
.rail-fill {
  position: absolute;
  top: 0;
  height: 100%;
}
.rail-track {
  left: 13px;
  width: 1px;
  background: var(--tf-hair);
}
.rail-fill {
  left: 12.5px;
  width: 2px;
  background: var(--tf-ink);
  transform-origin: top;
  transform: scaleY(var(--progress, 0));
}
.rail ol {
  list-style: none;
  margin: 0;
  padding: 0;
}
.rail-stop {
  position: absolute;
  left: 0;
  top: var(--at);
  width: 28px;
  height: 28px;
  margin-top: -14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tf-slate);
  text-decoration: none;
}
.rail-stop::before {
  content: "";
  width: 8px;
  height: 8px;
  box-sizing: border-box;
  border: 1px solid var(--tf-mute);
  border-radius: 50%;
  background: var(--tf-paper);
  transition: background var(--tf-quick) var(--tf-ease), border-color var(--tf-quick) var(--tf-ease),
    transform var(--tf-quick) var(--tf-ease);
}
.rail-stop.is-passed::before {
  background: var(--tf-ink);
  border-color: var(--tf-ink);
}
.rail-stop.is-current::before {
  background: var(--tf-accent);
  border-color: var(--tf-accent);
}
.rail-stop:hover::before,
.rail-stop:focus-visible::before {
  transform: scale(1.3);
}
.rail-n {
  position: absolute;
  top: 14px;
  left: 32px;
  margin-top: -7.5px;
  font-size: 15px;
  font-weight: 500;
  line-height: 15px;
  font-variant-caps: all-small-caps;
  font-feature-settings: "kern", "smcp", "c2sc";
  letter-spacing: 0.06em;
  color: var(--tf-ink);
}
.rail-t {
  position: absolute;
  top: 14px;
  left: 24px;
  margin-top: -14.5px;
  padding: 6px 10px 7px;
  background: var(--tf-paper);
  font-size: 16px;
  font-style: italic;
  line-height: 16px;
  white-space: nowrap;
  color: var(--tf-ink);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-4px);
  transition: opacity var(--tf-quick) var(--tf-ease), transform var(--tf-quick) var(--tf-ease);
}
.rail-stop:hover .rail-t,
.rail-stop:focus-visible .rail-t {
  opacity: 1;
  transform: none;
}
.rail-play {
  position: absolute;
  top: -54px;
  left: 0;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--tf-ink);
  border-radius: 50%;
  background: var(--tf-paper);
  color: var(--tf-ink);
  cursor: pointer;
}
.rail-play svg {
  width: 10px;
  height: 10px;
  fill: currentColor;
}
.rail-play:hover,
.rail-play[aria-pressed="true"] {
  border-color: var(--tf-accent);
  color: var(--tf-accent);
}
.topline {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 2px;
  z-index: 60;
  background: var(--tf-accent);
  transform-origin: left;
  transform: scaleX(var(--progress, 0));
  pointer-events: none;
}

/* --- Contents (blog/index.html) ------------------------------------------- */

:root.light .blog-main.book {
  display: flex;
}
:root.light .blog-main.book > h1 {
  margin-top: clamp(4rem, 14vh, 9rem);
}
:root.light .blog-main.book > .blog-lede {
  max-width: 606px;
}
:root.light .blog-main.book > .blog-lede a {
  display: inline-block;
  color: var(--tf-accent);
  text-decoration: none;
}
:root.light .toc-kicker {
  margin: clamp(4.5rem, 16vh, 9rem) 0 44px;
  padding-left: 0.1em;
  font-family: var(--tf-serif);
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
  font-variant-caps: all-small-caps;
  font-feature-settings: "kern", "smcp", "c2sc", "onum";
  letter-spacing: 0.1em;
  text-align: center;
}
:root.light .blog-main.book > .blog-post-list.toc {
  max-width: 460px;
  margin: 0;
  padding: 0;
  border: 0;
  list-style: none;
}
:root.light .blog-post-list.toc > .toc-entry {
  position: relative;
  margin: 0 0 32px;
  padding: 0;
  border: 0;
  font-size: 21px;
  line-height: 1.6;
}
/* The rail: a hairline from node to node, the numeral to its left. */
:root.light .blog-post-list.toc > .toc-entry::before {
  content: "";
  position: absolute;
  left: -28px;
  top: 18px;
  height: calc(100% + 32px);
  border-left: 1px solid var(--tf-ink);
}
:root.light .blog-post-list.toc > .toc-entry:last-child::before {
  display: none;
}
:root.light .blog-post-list.toc > .toc-entry::after {
  content: "";
  position: absolute;
  left: calc(-28px - 4px);
  top: 14px;
  width: 9px;
  height: 9px;
  box-sizing: border-box;
  border: 1px solid var(--tf-ink);
  border-radius: 50%;
  background: var(--tf-paper);
  transition: background var(--tf-quick) var(--tf-ease), border-color var(--tf-quick) var(--tf-ease);
}
:root.light .blog-post-list.toc > .toc-entry:is(:hover, :focus-within)::after {
  background: var(--tf-accent);
  border-color: var(--tf-accent);
}
.toc-num {
  position: absolute;
  right: calc(100% + 44px);
  top: 4px;
  font-family: var(--tf-serif);
  font-size: 18px;
  font-weight: 500;
  line-height: 28.8px;
  font-variant-caps: all-small-caps;
  font-feature-settings: "kern", "smcp", "c2sc", "onum";
  letter-spacing: 0.06em;
  white-space: nowrap;
}
:root.light .blog-post-list.toc .toc-name {
  margin: 0;
  font-family: var(--tf-serif);
  font-size: 28px;
  font-weight: 500;
  line-height: 1.3;
  text-wrap: balance;
}
:root.light .blog-post-list.toc .toc-name a {
  color: var(--tf-ink);
  text-decoration: none;
}
:root.light .blog-post-list.toc .toc-name a:hover {
  color: var(--tf-accent);
}
:root.light .blog-post-list.toc .toc-sum {
  margin: 6px 0 0;
  font-family: var(--tf-serif);
  font-size: 17px;
  line-height: 1.45;
  color: var(--tf-ink);
}
.toc-subs {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  font-size: 17px;
  font-style: italic;
  line-height: 1.5;
}
:root.light .blog-post-list.toc .toc-subs > li {
  margin: 0;
  padding: 0;
  border: 0;
  animation: none;
}
:root.light .blog-post-list.toc .toc-meta {
  margin: 8px 0 0;
  font-family: var(--tf-fell);
  font-size: 15px;
  font-style: italic;
  line-height: 1.4;
  color: var(--tf-slate);
}
.toc-src {
  margin-left: 0.4em;
  font-family: var(--tf-serif);
  font-style: normal;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.08em;
}
:root.light .blog-main.book > :is(.blog-subscribe-cta, .blog-aside) {
  max-width: 460px;
  margin-top: 4rem;
}
:root.light .blog-main.book > .blog-aside {
  position: static;
  border: 0;
  padding: 0;
}
@media (max-width: 700px) {
  :root.light .blog-main.book > .blog-post-list.toc {
    padding-left: 76px;
    max-width: none;
  }
  .toc-num {
    right: calc(100% + 36px);
    font-size: 15px;
    letter-spacing: 0.03em;
  }
  :root.light .blog-post-list.toc > .toc-entry::before {
    left: -24px;
  }
  :root.light .blog-post-list.toc > .toc-entry::after {
    left: calc(-24px - 4px);
    top: 12px;
  }
  :root.light .blog-post-list.toc .toc-name {
    font-size: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rail *,
  .rail *::before,
  .topline,
  .toc-entry::after {
    transition: none !important;
  }
}
