/**********
  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;
}

main {
  max-width: min(740px, 66ch);
  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;
}

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 0.18em;
}

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;
}

/**********
  Navigation
**********/

nav.pagination {
  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-color: rgba(0, 0, 0, 0.5);
}

nav.pagination a,
nav.pagination span {
  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;
}

.language-switcher {
  padding: 0.15rem 0 0.2rem;
  border-bottom: 1px solid currentColor;
  font-size: 0.75rem;
  line-height: 1;
  text-align: center;
}

.language-switcher a {
  text-decoration: none;
}

.language-switcher a:hover,
.language-switcher a:focus-visible {
  text-decoration: underline;
}

/**********
  Actual Play
**********/

.actual-play-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.actual-play-nav-main,
.actual-play-nav-sheet {
  display: flex;
}

.actual-play-nav a {
  display: inline-block;
  margin: 0;
  padding: 0.35rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 0.5rem;
  text-decoration: none;
  line-height: 1.3;
}

.actual-play-nav-character {
  font-weight: 500;
}

/**********
  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;
}
.cover.avatar {
  --cover-max-width: 300px;
  --cover-max-height: 300px;
}

/**********
  Popover
**********/

.popover-img-trigger {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 0.5em auto;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.popover-img-panel {
  padding: 0;
  border: 0;
  background: transparent;
  max-width: 100vw;
  max-height: 100vh;
}

.popover-img-panel::backdrop {
  background: rgb(0 0 0 / 0.96);
}

.popover-img-close {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-out;
}

.popover-img-close img {
  display: block;
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
}

/**********
  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-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;
  border-bottom: 2px solid #eee;
  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.50em 0;
  padding: 0.70em 0;
  border-bottom: 2px solid #eee;
  text-align: left;
  text-decoration: none;
  font-size: 1em;
}

.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.8em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  word-spacing: normal;
}

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

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

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

/**********
  Live Release Warning
**********/

.live-release-warning {
  box-sizing: border-box;
  max-width: 640px;
  margin: 0 auto 1.75em auto;
  padding: 0.85em 1em;

  border: 2px solid #b8872b;
  border-radius: 0.10em;

  background: #fff7df;
  color: #2b1c00;

  box-shadow: 0 0.15em 0.45em rgba(0, 0, 0, 0.12);

  text-align: left;
  word-spacing: normal;
  letter-spacing: normal;
}

.live-release-warning strong {
  display: block;
  margin: 0 0 0.35em 0;

  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.85em;
  line-height: 1.25;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.live-release-warning p {
  margin: 0;
  font-size: 0.95em;
  line-height: 1.45;
  text-align: left;
}

/**********
  Scene Content
**********/

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

article p {
  font-size: 1.1em;
  line-height: 1.6;
}

article > p,
article > blockquote p {
  text-align: left;
  word-spacing: normal;
  letter-spacing: normal;
  hyphens: auto;
}

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

/**********
  Reader Footer
**********/

.reader-footer {
  border-top: 2px solid var(--border-color, #ddd);
  padding: 1rem 0 0.4rem 0;
}

.reader-footer p {
  margin: 0;
}

/**********
  Blockquotes / In-World Excerpts
**********/

.content blockquote {
  margin: 1.6rem 0;
  padding: 0.95rem 1.15rem 0.95rem 1.25rem;
  border-left: 4px solid #8fae9a;
  border-left: 4px solid color-mix(in srgb, currentColor 35%, #8fae9a);
  background: rgb(127 127 127 / 0.10);
  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: 0rem 1rem;
}

.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;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

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

/**********
  Book Table of Contents
**********/

.chapter-list {
  font-size: 1.1em;
  line-height: 1.55;
  margin: 0;
  padding-left: 1.5em;
}

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

.chapter-entry-unnumbered {
  list-style-type: disc;
}

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

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

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

/**********
  Book Status
**********/

.book-status {
  background-color: #f0f0f0;
  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: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.9em;
}

/**********
  Book Actions
**********/

.book-actions {
  border-top: 1px solid #444;
  font-size: 1em;
}

.book-actions th {
  text-transform: uppercase;
}

.book-actions th:first-child,
.book-actions td:first-child {
  padding-left: 0;
}

.book-actions th:last-child,
.book-actions td:last-child {
  padding-right: 0;
}

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

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;
}

/**********
  Attribution
**********/

.attribs {
  max-width: 760px;
  margin: 0 auto;
  padding: 0.75em 0.5em 0 0.5em;
}

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

/**********
  Dark Mode
**********/

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

  .actual-play-nav a {
    border-color: #777;
  }

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

  .saga-book-row {
    border-color: #444;
  }

  .live-release-warning {
    border-color: #c99a3c;
    background: #2f2611;
    color: #f7edd0;
    box-shadow: 0 0.15em 0.45em rgba(0, 0, 0, 0.45);
  }

  .reader-footer {
    border-top-color: #777;
  }

  .toc-list ol,
  .toc-list li {
    border-color: #777;
  }

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

  .book-status {
    background-color: #1f1f1f;
    border-color: #777;
  }

  .book-actions {
    border-top-color: #444;
  }

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

  body {
    background: black;
    color: white;
  }

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

  nav.pagination {
    border-color: white;
  }

  body > nav.pagination:last-of-type {
    border-color: white;
    border-bottom-color: rgba(255, 255, 255, 0.5);
  }

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

  h3 {
    border-color: #444;
  }

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

/**********
  Mobile
**********/

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

  .cover {
    --cover-max-width: 100%;
    --cover-max-height: 70vh;
    margin-bottom: 0.75em;
  }

  .saga-book-row {
    grid-template-columns: 1fr;
    gap: 0.2em;
    padding: 0.85em 0;
  }

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

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

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

  .live-release-warning {
    max-width: none;
    margin: 0 0 1.5em 0;
    padding: 0.8em 0.9em;
  }

  .live-release-warning strong {
    font-size: 0.8em;
  }

  .live-release-warning p {
    font-size: 0.92em;
    line-height: 1.4;
  }

  .toc-list li {
    grid-template-columns: 3rem 1fr;
    gap: 0.85rem;
  }

  .book-status {
    max-width: none;
    margin-bottom: 2em;
    padding: 0.6em 0;
    font-size: 0.9em;
  }

  main th,
  main td {
    padding: 0.4rem 0.6rem;
  }

  body {
    font-size: 1em;
  }

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

  article p {
    font-size: 1.15em;
  }

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

  nav.actual-play-nav {
    font-size: 1.1em;
  }

  .actual-play-nav a {
    padding-left: 0.55rem;
    padding-right: 0.55rem;
  }

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

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

  h2 {
    font-size: 1.35em;
  }

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

/**********
  Print
**********/

@media print {
  .logo {
    display: none;
  }

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

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

  .live-release-warning {
    border-color: #777;
    background: white;
    color: black;
    box-shadow: none;
    break-inside: avoid;
  }

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

  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;
  }
}
