/* HTML edition typography, page layout, and navigation. */

body {
  color: #263442;
  background: #ffffff;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 {
  color: #17365d;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.25;
}

section.level1 > h1 { margin-top: 2em; }
h2 { color: #2878a8; margin-top: 1.5em; }

a { color: #2878a8; }

pre {
  overflow-x: auto;
  padding: 1em 1.2em;
  border: 1px solid #dce3e9;
  border-radius: 5px;
  background: #f4f6f8;
  font-size: 0.85em;
  line-height: 1.5;
}

code {
  font-family: "DejaVu Sans Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.9em;
}

blockquote {
  color: #263442;
  border-left: 0.2em solid #2878a8;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  background: #f1f5f8;
  border-radius: 4px;
  overflow-x: auto;
}

blockquote > :first-child { margin-top: 0; }
blockquote > :last-child { margin-bottom: 0; }
blockquote table { width: 100%; }

table {
  border-collapse: collapse;
}

th, td {
  border: 1px solid #dce3e9;
  padding: 0.4em 0.6em;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f3f6f8;
  font-family: Arial, Helvetica, sans-serif;
}

img, svg {
  max-width: 100%;
  height: auto;
}

hr {
  margin: 3em 0;
  border: 0;
  border-top: 1px solid #dce3e9;
}

@media screen {
  html {
    box-sizing: border-box;
    scroll-behavior: smooth;
    font-size: 18px;
  }

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

  body {
    width: min(100% - 2rem, 920px);
    margin: 3rem auto;
    padding: clamp(1.5rem, 5vw, 4.5rem);
    box-shadow: 0 8px 36px rgb(23 54 93 / 8%);
  }

  /* Pandoc's metadata title is for the browser tab; each page has its own heading. */
  header#title-block-header { display: none; }

  h1, h2, h3, h4 {
    scroll-margin-top: 1.5rem;
    overflow-wrap: break-word;
  }

  h1 { font-size: clamp(2rem, 5vw, 3rem); }
  section.level1 > h1 { font-size: 1.8rem; }
  h2 { font-size: 1.3rem; }

  p, li { max-width: 75ch; }

  nav#TOC {
    margin: 2rem 0 3rem;
    padding: 1.5rem 2rem;
    border: 1px solid #dce3e9;
    border-left: 4px solid #d69a32;
    background: #fbfcfd;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 0.88rem;
    line-height: 1.55;
  }

  nav#TOC > ul { columns: 2; column-gap: 2.5rem; }
  nav#TOC li { break-inside: avoid; margin: 0.25rem 0; }
  nav#TOC ul { padding-left: 1.3rem; }
  nav#TOC a { text-decoration: none; }

  div.chapter, div.section {
    scroll-margin-top: 1.5rem;
  }
}

@media screen and (max-width: 640px) {
  html { font-size: 16px; }
  body {
    width: 100%;
    margin: 0;
    padding: 1.25rem;
    box-shadow: none;
  }
  nav#TOC { padding: 1rem; }
  nav#TOC > ul { columns: 1; }
}

@media print {
  body {
    width: 100%;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }
  h1 { break-before: page; }
  nav#TOC { break-after: page; }
  a { color: inherit; }
}

/* Navigation shared by the standalone chapter pages. */
.book-navigation {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  margin: 3rem 0 1rem;
  padding-top: 1.25rem;
  border-top: 1px solid #dce3e9;
  font-family: Arial, Helvetica, sans-serif;
}
.book-navigation a { text-decoration: none; }
.book-navigation .disabled { color: #8b9299; cursor: default; }
@media screen and (max-width: 640px) {
  .book-navigation { gap: 0.75rem; }
}

/* Separate the three contents groups with whitespace. */
.book-contents { list-style: none; padding-left: 0; }
.book-contents > .front-matter + .introduction,
.book-contents > :not(.back-matter) + .back-matter { margin-top: 1.5em; }

/* Book mark above the title on the HTML landing page. */
.book-cover-mark {
  text-align: center;
  margin: 0 0 1.5rem;
}
.book-cover-mark img {
  display: block;
  width: 265px;
  max-width: 100%;
  height: auto;
  margin: 0 auto 1.5rem;
}
/* Center only the HTML landing-page title and author. */
.book-landing-title { text-align: center; }
.book-landing-title .book-cover-mark { text-align: center; }
.book-landing-title .book-cover-mark img { display: block; margin-left: auto; margin-right: auto; }
.book-landing-title p { max-width: none; }


/* Give the landing-page author a distinct, understated hierarchy. */
.book-landing-title .book-author { font-size: 1.25rem; }
