/* Syzygy book theme for the web: the HTML pages' twin of book.typ.
 *
 * `build.py --format=html` copies this file to out/html/assets/ next to the
 * fonts. Fonts and colours come first, as in book.typ; keep the two in step
 * when the look changes. Then the page layout, and one block per component,
 * named as in book.typ.
 */

/* --- Fonts, colours, measure ----------------------------------------------------- */

@font-face { font-family: "Source Serif 4 SmText"; src: url("fonts/SourceSerif4SmText-Regular.otf"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Source Serif 4 SmText"; src: url("fonts/SourceSerif4SmText-It.otf"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Source Serif 4 SmText"; src: url("fonts/SourceSerif4SmText-Semibold.otf"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Source Serif 4 SmText"; src: url("fonts/SourceSerif4SmText-SemiboldIt.otf"); font-weight: 600; font-style: italic; font-display: swap; }
@font-face { font-family: "Source Serif 4 SmText"; src: url("fonts/SourceSerif4SmText-Bold.otf"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Source Serif 4 SmText"; src: url("fonts/SourceSerif4SmText-BoldIt.otf"); font-weight: 700; font-style: italic; font-display: swap; }
@font-face { font-family: "Source Serif 4 Display"; src: url("fonts/SourceSerif4Display-Regular.otf"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Source Serif 4 Display"; src: url("fonts/SourceSerif4Display-It.otf"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Source Serif 4 Display"; src: url("fonts/SourceSerif4Display-Semibold.otf"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("fonts/Barlow-Regular.ttf"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("fonts/Barlow-Italic.ttf"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("fonts/Barlow-Medium.ttf"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("fonts/Barlow-SemiBold.ttf"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("fonts/BarlowCondensed-Regular.ttf"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("fonts/BarlowCondensed-Italic.ttf"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("fonts/BarlowCondensed-Medium.ttf"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("fonts/BarlowCondensed-MediumItalic.ttf"); font-weight: 500; font-style: italic; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("fonts/BarlowCondensed-SemiBold.ttf"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("fonts/BarlowCondensed-Bold.ttf"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --body: "Source Serif 4 SmText", Georgia, serif;
  --display: "Source Serif 4 Display", "Source Serif 4 SmText", Georgia, serif;
  --sans: "Barlow", system-ui, sans-serif;
  --cond: "Barlow Condensed", "Barlow", system-ui, sans-serif; /* labels and headings */

  --ink: #1c1a1f;
  --head: #1f2a44; /* night navy: headings */
  --accent: #9e2a2b; /* the Red: roll labels, ornaments, rules */
  --link: #2b4d7e;
  --muted: #6e6872;
  --rule: #c8bdb0;
  --tint: #f5f0e9;
  --tint-strong: #ebe2d6;
  --paper: #fffdfa;
  --design: #2f6690; /* draft-only notes to the authors */
  --editor: #b86a10;
  --incomplete: #7a4a9c;

  --measure: 38rem; /* the text column */
  --gutter: 1.25rem; /* beside the text on narrow screens */
}

/* --- Page --------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 1.5rem; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.125rem;
  line-height: 1.6;
  font-kerning: normal;
  hyphens: auto;
  -webkit-hyphens: auto;
  text-rendering: optimizeLegibility;
}

@media (max-width: 30rem) {
  body { font-size: 1.0625rem; }
}

.layout { padding: 0 var(--gutter) 4rem; }
.book, .toc { max-width: var(--measure); margin-inline: auto; }

/* Wide screens: the contents beside the text, always in reach. */
@media (min-width: 68rem) {
  .layout {
    display: grid;
    grid-template-columns: 15rem minmax(0, var(--measure));
    column-gap: 4.5rem;
    justify-content: center;
    align-items: start;
  }
  .toc {
    position: sticky;
    top: 0;
    max-height: 100vh;
    overflow-y: auto;
    padding: 2.5rem 0.5rem 2.5rem 0;
    margin: 0;
    font-size: 0.875rem;
    scrollbar-width: thin;
  }
  .book { margin: 0; }
}

/* Justified like the book where the column is wide enough not to show rivers. */
@media (min-width: 36rem) {
  .book p, .book li { text-align: justify; }
  .book .callout-title, .credits p { text-align: left; }
}

p { margin: 0 0 0.9em; }
strong { font-weight: 600; }
em { font-style: italic; }

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 0.16em; }
.book a { text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent); }
.book a:hover { text-decoration-color: currentColor; }
a:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 2px; }

code, pre { font-family: var(--sans); font-weight: 500; font-size: 1.02em; color: var(--head); }
pre { white-space: pre-wrap; margin: 1.2em 0; }

/* --- The mark ------------------------------------------------------------------------ */

/* Three bodies in a line: the book's mark. */
.mark { display: block; height: 0.5rem; width: auto; margin: 0 auto; overflow: visible; }
.mark .arm { stroke: var(--rule); stroke-width: 0.6; }
.mark .moon { fill: var(--head); }
.mark .planet { fill: none; stroke: var(--head); stroke-width: 0.8; }
.mark .sun { fill: var(--accent); }

/* --- Title, contents, credits ---------------------------------------------------- */

.title-page { text-align: center; padding: clamp(3.5rem, 12vh, 7rem) var(--gutter) clamp(2.5rem, 8vh, 4.5rem); }
.book-title {
  margin: 0 0 0.9rem;
  padding-left: 0.16em; /* balances the tracking after the last letter */
  font: 600 clamp(2.4rem, 9vw, 3.75rem)/1.1 var(--display);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--head);
}
.title-mark { height: 0.7rem; }
.book-subtitle {
  margin: 1.3rem 0 0;
  padding-left: 0.34em;
  font: 600 1.2rem/1.3 var(--cond);
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--accent);
}
.book-tagline { margin: 0.6rem 0 0; font-style: italic; color: var(--muted); }
.book-draft { margin: 2rem 0 0; font: 600 0.85rem var(--cond); letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }

.toc { margin-bottom: 3rem; }
.toc-title { margin: 0 0 1rem; font: 400 1.6rem/1.2 var(--display); color: var(--head); }
.toc-title::after { content: ""; display: block; width: 2.6rem; height: 2px; margin-top: 0.5rem; background: var(--accent); }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a { display: block; text-decoration: none; hyphens: manual; }
.toc-part > a {
  margin: 1.3rem 0 0.35rem;
  font: 600 0.8rem/1.35 var(--cond);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}
.toc li li a, .toc > ol > li:not(.toc-part) > a { padding: 0.2rem 0; color: var(--ink); line-height: 1.35; }
.toc a:hover { color: var(--link); }

.credits {
  margin-top: 6rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--muted);
}
.credits p { margin: 0; }
.credits-title { font-weight: 600; color: var(--head); }
.credits-text { margin-top: 0.8rem !important; }

/* The site's front page: a link to each book. */
.shelf { max-width: 26rem; margin: 0 auto; padding: 0 var(--gutter) 5rem; }
.shelf ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.shelf a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  text-decoration: none;
  background: var(--tint);
  border-left: 3px solid var(--accent);
  border-radius: 0 4px 4px 0;
}
.shelf a:hover { background: var(--tint-strong); }
.shelf-title { font: 400 1.6rem/1.2 var(--display); color: var(--head); }
.shelf-version { font: 500 0.85rem var(--cond); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }

.draft-stamp {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1;
  margin: 0;
  padding: 0.2rem 0.6rem;
  font: 500 0.8rem var(--cond);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--paper);
  border: 1px solid var(--accent);
  border-radius: 3px;
}

/* --- Headings --------------------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 { hyphens: manual; -webkit-hyphens: manual; text-wrap: balance; font-weight: 600; color: var(--head); }

/* A part: "# Part One: The Basics" sets "Part One" above "The Basics". */
.book h1 { margin: 7rem 0 4.5rem; text-align: center; font-weight: 400; }
.book h1 .kicker {
  display: block;
  margin-bottom: 0.9rem;
  padding-left: 0.32em;
  font: 600 0.95rem/1.3 var(--cond);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--accent);
}
.book h1 .part-title { display: block; font: 400 clamp(2.2rem, 7vw, 3rem)/1.15 var(--display); }
.book h1 .mark { margin-top: 1.2rem; height: 0.55rem; }

/* A chapter. */
.book h2 { margin: 5rem 0 1.6rem; font: 400 clamp(1.9rem, 6vw, 2.5rem)/1.15 var(--display); }
.book h2::after { content: ""; display: block; width: 2.6rem; height: 2px; margin-top: 0.55rem; background: var(--accent); }
.book h1 + h2, .book h1 + .anchor + h2 { margin-top: 0; }

.book h3 { margin: 2.4rem 0 0.75rem; font: 600 1.6rem/1.2 var(--cond); letter-spacing: 0.01em; }
.book h4 { margin: 1.9rem 0 0.6rem; font: 600 1.25rem/1.25 var(--cond); letter-spacing: 0.02em; color: var(--accent); }
.book h5 { margin: 1.5rem 0 0.5rem; font: 600 1rem/1.3 var(--cond); letter-spacing: 0.1em; text-transform: uppercase; }
.book h6 { margin: 1.3rem 0 0.4rem; font: italic 600 1em/1.4 var(--body); color: var(--ink); }

/* An invisible link target at the start of a note. */
.anchor { height: 0; }

/* --- Components --------------------------------------------------------------------- */

/* Lists. */
.book ul, .book ol { margin: 0.9em 0; padding-left: 1.4em; }
.book li { margin: 0.4em 0; }
.book li > p { margin: 0.5em 0; }
.book li > :first-child { margin-top: 0; }
.book li > :last-child { margin-bottom: 0; }
.book .tight > li { margin: 0.25em 0; }
.book .tight > li > p { margin: 0; }
.book ul > li::marker { color: var(--accent); }
.book ol > li::marker { font-family: var(--cond); font-weight: 600; color: var(--accent); }

/* voice: in-fiction quote, "> words" ending "> — Name, detail". */
.voice { margin: 2rem 1.6rem; }
.voice blockquote { margin: 0; font-style: italic; font-size: 0.95em; }
.voice blockquote p { margin: 0 0 0.6em; }
.voice figcaption {
  margin-top: 0.5rem;
  text-align: right;
  font: 500 0.85rem/1.4 var(--cond);
  letter-spacing: 0.03em;
  color: var(--muted);
  hyphens: manual;
}
.voice-name { margin-left: 0.25em; font-weight: 700; color: var(--head); text-transform: uppercase; }
/* The chapter epigraph. */
.voice.lead { margin: 0.6rem 0 2.6rem; padding: 0.2rem 0 0.2rem 1.1rem; border-left: 2px solid var(--accent); }
.voice.lead blockquote { font-size: 1.08em; }

/* vignette: above-the-table narrative, set like a novel, with a hairline in the margin. */
.vignette {
  margin: 2.4rem 0 2.6rem;
  padding: 0.15rem 0 0.15rem 1.1rem;
  border-left: 1px solid color-mix(in srgb, var(--accent) 75%, var(--paper));
  font-size: 1.08em;
  line-height: 1.65;
}
.vignette p { margin: 0; text-indent: 1.4em; }
.vignette p:first-child, .vignette .section-break + p { text-indent: 0; }
@media (min-width: 48rem) {
  .vignette { margin-left: -1.2rem; padding-left: 1.2rem; }
}
.lead-in { font-variant-caps: small-caps; letter-spacing: 0.04em; }

/* move-card: the move's name and stat on a navy band, its rules on a tinted panel. */
.move { margin: 2.2rem 0 1.6rem; border-radius: 4px; overflow: hidden; background: var(--tint); }
.move-band {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  column-gap: 1rem;
  padding: 0.6rem 1rem 0.5rem;
  background: var(--head);
}
.book .move-band > :is(h1, h2, h3, h4, h5, h6) {
  margin: 0;
  text-align: left;
  font: 600 1.35rem/1.2 var(--cond);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #fff;
}
.book .move-band > h2::after { content: none; }
.move-stat {
  font: 500 0.95rem/1.2 var(--cond);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--tint-strong);
}
.move-body { padding: 0.9rem 1rem 1rem; }
.move-body > :first-child { margin-top: 0; }
.move-body > :last-child { margin-bottom: 0; }

/* rules-box: an unattributed quote, such as the gift move. */
.rules-box { margin: 1.4rem 0 1.5rem; padding: 0.95rem 1.15rem; background: var(--tint); border-left: 3px solid var(--accent); }
.rules-box > :first-child, .callout > :first-child { margin-top: 0; }
.rules-box > :last-child, .callout > :last-child { margin-bottom: 0; }

/* roll-results: **10+** / **7-9** / **6-** lists, with hanging labels. */
.roll-results {
  display: grid;
  grid-template-columns: 2.4em minmax(0, 1fr);
  column-gap: 0.75em;
  row-gap: 0.6em;
  align-items: baseline;
  margin: 0.8em 0 1.1em;
}
.roll-results dt { text-align: right; white-space: nowrap; font-family: var(--cond); font-weight: 700; color: var(--accent); }
.roll-results dd { margin: 0; }
.roll-results dd > :first-child { margin-top: 0; }
.roll-results dd > :last-child { margin-bottom: 0; }

/* section-break: a `---` between moves or scenes. */
.section-break { margin: 1.8rem 0; }
.section-break .mark { height: 0.42rem; }

/* callout: sidebars in every build; notes to the authors in drafts. */
.callout {
  margin: 1.5rem 0;
  padding: 0.9rem 1.1rem;
  font-size: 0.92em;
  background: var(--tint);
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.callout-title { margin: 0 0 0.6rem; font: 600 1.15rem/1.3 var(--cond); color: var(--head); }
.callout.editorial { --kind: var(--head); border: 0; border-left: 3px solid var(--kind); border-radius: 0; background: color-mix(in srgb, var(--kind) 8%, var(--paper)); }
.callout.design { --kind: var(--design); }
.callout.editor { --kind: var(--editor); }
.callout.incomplete { --kind: var(--incomplete); }
.callout.editorial .callout-title { font-size: 1.05rem; color: var(--kind); }
.callout-kind { margin-right: 0.4em; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }

/* xref-ext: a term explained in another book, tagged with its abbreviation. */
.book-tag {
  margin-left: 0.06em;
  font: 700 0.62em/0 var(--cond);
  letter-spacing: 0.04em;
  color: var(--accent);
  vertical-align: 0.6em;
}
.xref-ext { white-space: normal; }

/* book-table */
.table-wrap { margin: 1.5rem 0 1.6rem; overflow-x: auto; }
.book table { width: 100%; border-collapse: collapse; font: 0.95rem/1.4 var(--sans); hyphens: manual; }
.book th {
  padding: 0.5rem 0.55rem;
  text-align: left;
  vertical-align: bottom;
  font: 600 1.05rem/1.25 var(--cond);
  color: var(--head);
  border-bottom: 1.5px solid var(--head);
}
.book td { padding: 0.5rem 0.55rem; vertical-align: top; text-align: left; }
.book :is(td, th).short { white-space: nowrap; } /* a column of short entries never wraps */
.book tbody tr:nth-child(even) { background: var(--tint); }
.book tbody tr:last-child { border-bottom: 1px solid var(--rule); }

/* book-figure */
.figure { margin: 1.6rem 0; }
.figure img { display: block; max-width: 100%; height: auto; margin: 0 auto; }
img.icon { height: 1em; width: auto; vertical-align: -0.15em; }

/* --- Print ------------------------------------------------------------------------- */

@media print {
  .toc, .draft-stamp { display: none; }
  .layout { display: block; }
  .move, .rules-box, .callout, .roll-results, table { break-inside: avoid; }
  .book h1, .book h2 { break-before: page; }
}
