/* ==========================================================================
   Base
   ========================================================================== */

:root {
  color-scheme: light dark;
}

body {
  display: block;
  margin: 0;
  padding: 0;
  background: white;
  color: black;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1.18em;
  line-height: 1.55;
  text-align: justify;
  word-spacing: 0.08em;
  letter-spacing: 0.01em;
}

main {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.25em;
  background: #f9f9f9;
  border-left: 2px solid #e9e9e9;
  border-right: 2px solid #e9e9e9;
}

a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

p {
  margin: 0 0 1em 0;
}

/* ==========================================================================
   Logo
   ========================================================================== */

.logo {
  width: 300px;
  height: 200px;
  margin: 0 auto 0.25em auto;
  background-image: url("/logo.webp");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.logo + h1 {
  font-size: 3em;
}

.logo + h1::before,
.logo + h1::after {
  display: none;
}

h1::before,
h1::after {
  content: "";
  flex: 0 0 auto;
  width: 1.25em;
  height: 1.25em;
  margin: 0;
  background-image: url("/logo.webp");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

@media (prefers-color-scheme: dark) {
  .logo{
    filter: invert(1);
  }
}

@media (max-width: 600px) {
  .logo {
    width: 200px;
    height: 140px;
    margin: 0 auto;
  }
}

@media print {
  .logo {
  }
}

/* ==========================================================================
   Navigation
   ========================================================================== */

nav.pagination,
nav.languages {
  text-align: center;
  text-transform: uppercase;
}

nav.pagination {
  padding: 0.6em 0;
  border-bottom: 2px solid black;
  font-size: 1.05em;
}

body > nav.pagination:last-of-type {
  border-top: 2px solid black;
  border-bottom: none;
}

nav.languages {
  padding: 0.5em 0;
  border-bottom: 2px solid black;
  font-size: 0.75em;
}

nav.pagination a,
nav.pagination span,
nav.languages a {
  margin: 0 0.2em;
  text-decoration: none;
}

.disabled {
  opacity: 0.25;
}

.sep {
  opacity: 0.4;
}

.nav-icon {
  font-size: 0.9em;
  letter-spacing: -0.08em;
}

/* ==========================================================================
 *  Covers
========================================================================== */
.cover {
  --cover-max-width: 640px;
  --cover-max-height: 1000px;

  display: block;
  box-sizing: border-box;

  width: auto;
  height: auto;
  max-width: min(100%, var(--cover-max-width));
  max-height: var(--cover-max-height);

  margin: 0 auto 0.85em auto;
  border: 2px solid #ddd;
  box-shadow: 0 0 0.35em rgba(0, 0, 0, 0.18);
}

.cover.portrait {
  --cover-max-width: 600px;
  --cover-max-height: 800px;
}

@media (prefers-color-scheme: dark) {
  .cover {
    border-color: #777;
    box-shadow: 0 0 0.35em rgba(0, 0, 0, 0.55);
  }
}

@media (max-width: 600px) {
  .cover {
    --cover-max-width: 100%;
    --cover-max-height: 70vh;
    margin-bottom: 0.75em;
  }
}

@media print {
  .cover {
    border-color: #ddd;
    box-shadow: none;
  }
}


/* ==========================================================================
   Headings
   ========================================================================== */

.scene-header {
  margin-bottom: 1.5em;
}

.kicker {
  margin: 0 0 0.25em 0;
  opacity: 0.65;
  font-size: 0.75em;
  text-align: center;
  text-justify: center;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  word-spacing: 0.1em;
}

h1 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  margin: 0.25em 0 0.75em 0;
  padding-bottom: 0.2em;
  border-bottom: 2px solid #ddd;
  font-size: 2.2em;
  line-height: 1.15;
  text-align: center;
}

h2 {
  margin-top: 1.5em;
  border-bottom: 2px solid #ddd;
  font-size: 1.45em;
  line-height: 1.2;
  text-align: left;
}

h3 {
  margin-top: 1.5em;
  font-size: 1.2em;
  line-height: 1.2;
  text-align: left;
}

/* ==========================================================================
   Homepage saga book rows
   ========================================================================== */

.saga-book-row {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  column-gap: 1rem;
  width: 100%;
  gap: 0.15em 1em;
  margin: 0.55em 0;
  padding: 0.75em 0;
  border-top: 2px solid #ddd;
  text-align: left;
  text-decoration: none;

  /* Prevent book rows from inheriting smaller font sizes from parent sections */
  font-size: 1.25rem;
}

.saga-book-number {
  grid-row: span 2;
  align-self: start;
  opacity: 0.75;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  word-spacing: normal;
  padding-top: 0.15em;
}

.saga-book-title {
  font-size: 1em;
  font-weight: 700;
  line-height: 1.2;
}

.saga-book-status {
  opacity: 0.68;
  font-size: 0.78em;
  line-height: 1.25;
  word-spacing: normal;
}

.saga-book-row:hover .saga-book-title {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

@media (prefers-color-scheme: dark) {
  .saga-book-row {
    border-color: #777;
  }
}

@media (max-width: 600px) {
  .saga-book-row {
    grid-template-columns: 1fr;
    gap: 0.2em;
    padding: 0.85em 0;

    /* Keep mobile rows normalized too */
    font-size: 1rem;
  }

  .saga-book-number {
    grid-row: auto;
    align-self: auto;
  }

  .saga-book-title {
    font-size: 1em;
  }

  .saga-book-status {
    font-size: 0.82em;
  }
}

@media print {
  .saga-book-row {
    border-color: #ddd;
  }
}

/* ==========================================================================
   Scene content
   ========================================================================== */

.scene hr {
  margin: 2em 0;
  border: none;
  border-top: 2px solid #ddd;
}

article p {
  font-size: 1.1em;
}

.content p strong {
  font-weight: 800;
  letter-spacing: 0.01em;
}

/* ==========================================================================
   Blockquotes / in-world excerpts
   ========================================================================== */

.content blockquote {
  margin: 1.6rem 0;
  padding: 0.95rem 1.15rem 0.95rem 1.25rem;
  border-left: 4px solid color-mix(in srgb, currentColor 35%, #8fae9a);
  background: color-mix(in srgb, currentColor 7%, transparent);
  color: inherit;
  font-style: normal;
}

.content blockquote p {
  margin: 0.65rem 0;
}

.content blockquote p:first-child {
  margin-top: 0;
}

.content blockquote p:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
 *  Generic section contents
 *  ========================================================================== */

.toc-list {
  margin: 2rem 1.5rem;
}

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

.toc-list li {
  counter-increment: toc-list;
  display: grid;
  grid-template-columns: 2.5rem 1fr;
  gap: 1.25rem;
  padding: 1rem 0;
  border-top: 1px solid #999;
}

.toc-list li:first-child {
  border-top: none;
}

.toc-list li::before {
  content: counter(toc-list);
  color: #777;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding-top: 0.15rem;
}

.toc-list a {
  font-size: 1.15rem;
  font-weight: 700;
  text-decoration: none;
}

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

@media (prefers-color-scheme: dark) {
  .toc-list ol,
  .toc-list li {
    border-color: #777;
  }

  .toc-list li::before {
    color: #aaa;
  }
}

@media (max-width: 600px) {
  .toc-list li {
    grid-template-columns: 3rem 1fr;
    gap: 0.85rem;
  }
}

/* ==========================================================================
   Book table of contents
   ========================================================================== */

.chapter-list {
  margin: 0;
  padding-left: 1.5em;
}

.chapter-entry {
  margin: 1em 0;
}

.chapter-title {
  font-weight: 700;
}

.scene-list {
  margin: 0.35em 0 0.75em 0;
  padding-left: 1.5em;
}

.scene-list li {
  margin: 0.25em 0;
}

/* ==========================================================================
   Book status
   ========================================================================== */

.book-status {
  background-color: rgb(from Canvas calc(r * 0.94) calc(g * 0.94) calc(b * 0.94));
  border-bottom: 2px solid #ddd;
  border-top: 2px solid #ddd;
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.95em;
  letter-spacing: 0.02em;
  line-height: 1.4;
  margin: 0 auto 1.5em auto;
  max-width: 640px;
  padding: 0.5em 0;
  text-align: center;
  word-spacing: normal;
}

.book-status strong {
  text-transform: uppercase4
  letter-spacing: 0.08em;
  font-size: 0.9em;
}

@media (prefers-color-scheme: dark) {
  .book-status {
    border-color: #777;
  }
}

@media (max-width: 600px) {
  .book-status {
    max-width: none;
    margin-bottom: 2em;
    padding: 0.6em 0;
    font-size: 0.9em;
  }
}

@media print {
  .book-status {
    border-color: #ddd;
  }
}

/* ==========================================================================
 Character Sheets
 ========================================================================== */
main table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

main th,
main td {
  padding: 0.50rem 0.75rem;
  border-bottom: 1px solid #444;
  text-align: left;
  vertical-align: top;
}

main th {
  font-weight: 700;
}

main td:last-child,
main th:last-child {
  text-align: right;
}

main table th:empty {
  display: none;
}

main table tr:hover {
  background: #ddd;
}

@media (prefers-color-scheme: dark) {
  main table tr:hover {
    background: #555;
  }
}

@media (max-width: 600px) {
  main th,
  main td {
    padding: 0.4rem 0.6rem;
  }
}

/* ==========================================================================
   Attribution
   ========================================================================== */

.attribs {
  margin-top: 2em;
  padding-top: 0.75em;
  border-top: 2px solid #ddd;
}

.attribs p {
  opacity: 0.55;
  font-size: 0.72em;
  line-height: 1.25;
  text-align: justify;
  word-spacing: normal;
  letter-spacing: normal;
}


/* ==========================================================================
   Dark mode
   ========================================================================== */

@media (prefers-color-scheme: dark) {
  body {
    background: black;
    color: white;
  }

  main {
    background: #222;
    border-left-color: #444;
    border-right-color: #444;
  }

  nav.pagination,
  nav.languages {
    border-color: white;
  }

  body > nav.pagination:last-of-type {
    border-color: white;
  }

  h1,
  h2,
  .toc-list,
  .attribs,
  .scene hr {
    border-color: #777;
  }

  h1::before,
  h1::after {
    filter: invert(1);
  }
}


/* ==========================================================================
   Mobile
   ========================================================================== */

@media (max-width: 600px) {
  body {
    font-size: 1em;
  }

  main {
    max-width: none;
    padding: 0.85em;
    border-left: none;
    border-right: none;
  }

  nav.pagination {
    font-size: 0.95em;
  }

  h1 {
    font-size: 1.55em;
    gap: 0.4em;
  }

  h1::before {
    width: 1.15em;
    height: 1.15em;
  }

  h2 {
    font-size: 1.25em;
  }

  .attribs p {
    font-size: 0.78em;
  }
}


/* ==========================================================================
   Print
   ========================================================================== */

@media print {
  nav,
  .attribs {
    display: none;
  }

  body {
    background: white;
    color: black;
    font-size: 11pt;
  }

  main {
    max-width: none;
    border: none;
    background: white;
  }

  .scene hr {
    border-top-color: #ddd;
  }

  h1::before {
    filter: none;
  }
}
