/* Site styling. Chapter text spacing follows AO3's defaults (paragraph
   spacing, hr, headings) so the books look as they do there; typeface,
   size and measure are our own. All colors are variables so a dark scheme can
   be swapped in. */

:root {
  --bg: #fff;
  --fg: #2a2a2a;
  --muted: #777;
  --link: #2a2a2a;
  --link-visited: #666;
  --rule: #2a2a2a;
  --hover-bg: #f1f1ee;
  --figure-bg: #f3f3f3;

  --font-text: 'Source Serif 4', Georgia, serif;
  /* Site chrome (navigation, labels) is set in a sans-serif so it reads as
     distinct from the books' text. */
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --rule-light: #d8d8d8;
  --text-size: 1.0625rem;  /* 17px */
  --text-leading: 1.5;
  --text-width: 44rem;
  --text-align: justify;
  --text-hyphens: manual;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  color: var(--fg);
}

body {
  margin: 0;
  padding: 1.5em 1.25em 4em;
  font-family: var(--font-text);
  font-size: 100%;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a, a:link {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid;
}
a:visited {
  color: var(--link-visited);
  border-bottom-style: dashed;
}
a:hover { color: var(--muted); }

h1, h2, h3, h4, h5, h6 {
  font-weight: normal;
}

main {
  max-width: var(--text-width);
  margin: 0 auto;
}

/* ---- Site-level navigation ---- */

.site-nav {
  max-width: var(--text-width);
  margin: 0 auto 2em;
  font-family: var(--font-ui);
  font-size: 0.8125em;
  color: var(--muted);
}
.site-nav a, .site-nav a:visited { color: var(--muted); border-bottom-color: var(--rule-light); border-bottom-style: solid; }

/* ---- Index ---- */

.index h1 {
  font-size: 1.5em;
  margin: 1em 0 1.5em;
}
.books {
  list-style: none;
  padding: 0;
}
.books li { margin: 0.75em 0; }
.books .year, .books .links { color: var(--muted); }

/* ---- Book contents page ---- */

.book h1 { font-size: 2em; margin: 0.5em 0 0.25em; }
.book .byline { margin-top: 0; color: var(--muted); }
.book h2 { font-size: 1.25em; margin-top: 2em; }
/* Each row is one link, so even a one-letter title ("I") is easy to hit. */
.toc {
  list-style: none;
  padding: 0;
  margin: 0 -0.5em;
}
.toc a {
  display: flex;
  gap: 1em;
  padding: 0.3em 0.5em;
  border-bottom: none;
  border-radius: 3px;
}
.toc a:hover { background: var(--hover-bg); color: var(--fg); }
.toc-number {
  flex: 0 0 5.5em;
  color: var(--muted);
}
.toc-title {
  border-bottom: 1px solid;
}
.toc a:visited .toc-title { border-bottom-style: dashed; }

/* ---- Chapter pages ---- */

/* The header (chapter number and title) is closed off by a rule, and the
   navigation sits below the text as a row of buttons, so neither can be
   mistaken for the chapter's own content. */
.chapter-header {
  text-align: center;
  margin: 1.5em 0 2.5em;
  padding-bottom: 1.5em;
  border-bottom: 1px solid var(--rule-light);
}
.chapter-number {
  font-family: var(--font-ui);
  font-size: 0.75em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.6em;
}
.chapter-title {
  font-size: 1.35em;
  line-height: 1.3;
  margin: 0;
}

.chapter-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6em;
  margin: 3em 0 1em;
  padding-top: 2em;
  border-top: 1px solid var(--rule-light);
}
.button, .button:link, .button:visited {
  font-family: var(--font-ui);
  font-size: 0.8125em;
  color: var(--fg);
  border: 1px solid var(--rule-light);
  border-radius: 4px;
  padding: 0.45em 0.9em;
}
.button:hover { background: var(--hover-bg); color: var(--fg); }

/* Chapters made mostly of mock web pages (TNC's forum threads) get a wider
   column, closer to how such pages looked. */
main.wide { --text-width: 68rem; }
main.wide .chapter-header { max-width: 44rem; margin-left: auto; margin-right: auto; }

/* ---- Chapter text: AO3's .userstuff / #workskin defaults ---- */

.work-text {
  font-family: var(--font-text);
  font-size: var(--text-size);
  line-height: var(--text-leading);
  word-wrap: break-word;
  margin-bottom: 3em;
  position: relative;
}
.work-text p {
  margin: 1.286em auto;
  padding: 0;
  text-align: var(--text-align);
  hyphens: var(--text-hyphens);
  -webkit-hyphens: var(--text-hyphens);
}
.work-text hr {
  width: 33%;
  margin: 0.875em auto 1.2525em auto;
  border: 0;
  border-top: 2px solid var(--rule);
}
.work-text img {
  max-width: 100%;
  height: auto;
}
/* Detailed figures (marked by the build) may extend a little beyond the
   text column, but never past the window. They sit on a tinted panel so their
   captions (part of the image) don't read as part of the main text. */
.work-text .wide-figure {
  width: max(100%, min(52rem, calc(100vw - 2.5rem)));
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  background: var(--figure-bg);
  padding: 1.25rem;
  border-radius: 4px;
  margin: 2.5em auto;
}
.work-text .wide-figure img {
  width: 100%;
  mix-blend-mode: multiply;  /* the image's white background takes the panel's tint */
}
@media (max-width: 40rem) {
  .work-text .wide-figure { padding: 0.5rem; }
}
.work-text h1 { font-size: 2.5em; line-height: 1; margin: 0.5em 0; text-align: center; }
.work-text h2 { font-size: 2.143em; line-height: 1; margin: 1.5em 0; }
.work-text h3 {
  font-size: 1.286em;
  line-height: 1;
  margin: 0.5375em 0;
  font-weight: 500;
  padding: 0.125em;
  border-bottom: 0.25em double var(--rule);
}
.work-text blockquote {
  margin-inline-start: 1.5em;
  padding: 0.75em;
  border-inline-start: 2px solid #999;
}
.work-text ol, .work-text ul { margin: 0.75em auto; padding: 0 1.5em; }
/* As AO3's reset stylesheet: */
.work-text table { border-collapse: collapse; border-spacing: 0; }
.work-text td, .work-text th { vertical-align: top; text-align: left; }
.work-text li { margin: 0.75em 0 0.75em 1.75em; }

.work-text .nobreak { white-space: nowrap; }

/* Outlines (e.g. TNC ch. 18's table of contents): one indent step per level,
   wrapped lines hanging under the title rather than the number. */
.work-text p.outline {
  display: flex;
  gap: 0.5em;
  margin: 0.3em 0;
  text-align: left;
  font-weight: bold;
}
.work-text p.outline-1 { margin-top: 0.9em; }
.work-text .outline-number { flex: none; }
.work-text p.outline-2 { padding-left: 1.75em; }
.work-text p.outline-3 { padding-left: 3.5em; font-weight: normal; }
.work-text p.outline-4 { padding-left: 5.25em; font-weight: normal; }
.work-text p.outline-5 { padding-left: 7em; font-weight: normal; }
.work-text p.outline-6 { padding-left: 8.75em; font-weight: normal; }
.work-text .align-center { text-align: center; }
.work-text .align-right { text-align: right; }
.work-text .align-left { text-align: left; }
.work-text .align-justify { text-align: justify; }
