/**********
  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.svg");
  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.svg");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

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

nav.pagination {
  text-align: center;
  text-transform: uppercase;
  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;
}

.sep.bar {
  position: relative;
  font-size: 0.75em;
  top: -2px;
}

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

nav.pagination .prev > i {
  margin-inline-end: 0.25em;
}

nav.pagination .next > i {
  margin-inline-start: 0.25em;
}

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

nav.pagination.actual-play-nav a {
  text-decoration: underline;
}

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

/**********
  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: 240px;
  --cover-max-height: 240px;
}

.not-the-end {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 1rem;
  width: 100%;
  margin: 0 auto 1.5em;
}

.not-the-end img {
  display: block;
  width: min(calc(50% - 0.5rem), 16rem);
  height: auto;
}

.not-the-end img:first-child {
  margin-top: 0.25rem;
  width: min(calc(45% - 0.45rem), 12rem);
}

.popover-img-trigger.book-cover-trigger,
.book-cover-trigger .cover {
  width: 100%;
  max-width: 100%;
}

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

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

/**********
  More
**********/

.more {
  margin: 1.75rem 0 2rem;
  padding: 0.9rem;
  border: 1px solid color-mix(in srgb, currentColor 80%, transparent);
  border-radius: 0.2em;
  font-size: 1em;
  background-color:rgba(0, 0, 0, 0.25);
}

.more .more__title {
  margin: 0 0 0.45rem;
  font-size: 0.9em;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.more p {
  font-size: inherit;
}

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

/**********
  Homepage Saga Book Rows
**********/

.saga-heading ~ h3 {
  margin-bottom: 0.5em;
}

.saga-book-row {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  width: 100%;
  margin: 0.3em 0;
  padding: 0.45em 0;
  text-align: left;
  text-decoration: none;
  font-size: 1em;
}

.saga-book-row--title-only {
  grid-template-columns: minmax(0, 1fr);
}

.saga-book-number {
  align-self: start;
  opacity: 0.8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.8em;
  text-transform: uppercase;
  word-spacing: normal;
  text-decoration: none;
}

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

.saga-book-awesome {
  margin-right: 0.4em;
  text-decoration: none;
}

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

/**********
  Release Status
**********/

.play-sheets-row {
  grid-template-columns: 8rem minmax(0, 1fr);
}

/**********
  Release Status
**********/

.release-status {
  box-sizing: border-box;
  max-width: none;
  margin: 0;
  padding: 0.5em 0.5em 0.25em;

  border: 2px dashed rgb(0 0 0 / 0.24);
  background: linear-gradient(135deg, rgb(0 0 0 / 0.05), rgb(0 0 0 / 0.015));
  box-shadow: 0 0 0.25em rgb(0 0 0 / 0.06);

  color: rgb(0 0 0 / 0.90);
  font-size: 1.25rem;
  text-align: center;
  word-spacing: normal;
  letter-spacing: normal;
}

.release-status--grey {
  border-color: rgb(92 107 120 / 0.62);
  background: linear-gradient(
    115deg,
    rgb(87 105 120 / 0.10) 0%,
    rgb(184 197 207 / 0.24) 44%,
    rgb(232 238 242 / 0.44) 52%,
    rgb(77 96 112 / 0.12) 100%
  );
  box-shadow: 0 0 0.25em rgb(54 70 82 / 0.10);
  color: rgb(43 53 61 / 0.92);
}

.release-status--silver {
  border-color: rgb(112 122 134 / 0.76);
  border-style: solid;
  background: linear-gradient(
    115deg,
    rgb(168 178 190 / 0.20) 0%,
    rgb(230 234 239 / 0.52) 44%,
    rgb(250 251 252 / 0.72) 52%,
    rgb(157 168 181 / 0.24) 100%
  );
  box-shadow: 0 0 0.3em rgb(71 82 94 / 0.14);
  color: rgb(45 52 60 / 0.94);
}

.release-status--gold {
  border-color: rgb(186 147 48 / 0.80);
  border-style: solid;
  background: linear-gradient(
    115deg,
    rgb(190 145 35 / 0.18) 0%,
    rgb(228 188 78 / 0.38) 44%,
    rgb(255 226 139 / 0.58) 52%,
    rgb(181 132 27 / 0.22) 100%
  );
  box-shadow: 0 0 0.3em rgb(153 111 24 / 0.16);
  color: rgb(66 47 12 / 0.94);
}

.release-status__label {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 1em;
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1.2;
  text-transform: uppercase;
}

.release-progress {
  box-sizing: border-box;
  max-width: none;
  margin: 0;
  padding: 0.7em 0.85em 0.8em;

  border: 2px solid rgb(0 0 0 / 0.24);
  background: rgb(0 0 0 / 0.05);
  box-shadow: 0 0 0.25em rgb(0 0 0 / 0.08);

  color: rgb(0 0 0 / 0.90);
  font-size: 1rem;
  text-align: center;
}

.release-notices {
  display: grid;
  gap: 0.5rem;
  margin: 0 0 1rem;
}

.scene-header + .popover-img-trigger,
.release-notices + .popover-img-trigger {
  margin-top: -0.3em;
}

.scene-header + .release-notices {
  margin-top: -0.6em;
}

@media (max-width: 600px) {
  .scene-header + .popover-img-trigger,
  .release-notices + .popover-img-trigger {
    margin-top: -0.5em;
  }
}

@media (min-width: 601px) {
  .scene-header + .release-notices {
    margin-top: -1em;
  }
}

.release-progress__track {
  height: 0.65rem;
  margin: 0;
  border: 1px solid rgb(0 0 0 / 0.20);
  overflow: hidden;
  background: rgb(0 0 0 / 0.10);
}

.release-progress__fill {
  display: block;
  width: var(--release-progress);
  height: 100%;
  background: repeating-linear-gradient(
    135deg,
    rgb(0 0 0 / 0.42) 0,
    rgb(0 0 0 / 0.42) 0.4rem,
    rgb(0 0 0 / 0.28) 0.4rem,
    rgb(0 0 0 / 0.28) 0.8rem
  );
}

.release-progress__label {
  margin: 0 0 0.45rem;
  font-size: 0.78em;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

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

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

article p,
article > .saga-book-row {
  font-size: 1.1em;
}

article p {
  line-height: 1.6;
}

/*
  Keep main's bottom padding as the page's consistent final gutter.

  Paragraphs and tables have their own bottom margins; when either is the final
  direct article child, that margin would be added to main's padding and make
  the bottom gap larger than the other edges. A terminal component such as
  .next-book is a wrapper, so its final paragraph needs the same treatment.
  Give future terminal wrapper components an equivalent final-child rule.
*/
article > :last-child,
article > .next-book:last-child > p:last-child {
  margin-bottom: 0;
}

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

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

.site-footer-inner {
  max-width: min(740px, 66ch);
  margin: 0 auto;
}

.site-community-links {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  width: fit-content;
  box-sizing: border-box;
  max-width: 100%;
  gap: 0.4em 1em;
  margin: 0 auto;
  position: relative;
  padding: 0.75em 0.5em calc(0.75em + 4px);
}

.site-community-links::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 100vw;
  border-bottom: 2px solid rgba(0, 0, 0, 0.5);
  transform: translateX(-50%);
}

.community-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  white-space: nowrap;
  font-size: 0.92em;
  line-height: 1.55;
  text-decoration: none;
  opacity: 0.9;
}

.community-link > span {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.community-link > i {
  font-size: 1.15em;
}

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

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

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

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

@media (prefers-color-scheme: dark) {
  .not-the-end img {
    filter: invert(1) brightness(0.9);
  }

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

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

  .release-status {
    border-color: rgb(255 255 255 / 0.24);
    background: linear-gradient(135deg, rgb(255 255 255 / 0.065), rgb(255 255 255 / 0.02));
    box-shadow: 0 0 0.25em rgb(0 0 0 / 0.16);
    color: rgb(255 255 255 / 0.90);
  }

  .release-status--grey {
    border-color: rgb(164 181 194 / 0.62);
    background: linear-gradient(
      115deg,
      rgb(107 128 144 / 0.12) 0%,
      rgb(174 194 207 / 0.18) 44%,
      rgb(222 232 238 / 0.26) 52%,
      rgb(92 113 130 / 0.12) 100%
    );
    box-shadow: 0 0 0.25em rgb(0 0 0 / 0.22);
    color: rgb(228 235 240 / 0.92);
  }

  .release-status--silver {
    border-color: rgb(184 194 206 / 0.76);
    background: linear-gradient(
      115deg,
      rgb(132 144 158 / 0.18) 0%,
      rgb(211 218 226 / 0.25) 44%,
      rgb(242 245 248 / 0.32) 52%,
      rgb(119 132 147 / 0.18) 100%
    );
    box-shadow: 0 0 0.3em rgb(0 0 0 / 0.28);
    color: rgb(236 240 244 / 0.94);
  }

  .release-status--gold {
    border-color: rgb(234 198 101 / 0.80);
    background: linear-gradient(
      115deg,
      rgb(172 125 25 / 0.20) 0%,
      rgb(224 181 67 / 0.30) 44%,
      rgb(255 224 132 / 0.40) 52%,
      rgb(155 109 18 / 0.20) 100%
    );
    box-shadow: 0 0 0.3em rgb(0 0 0 / 0.28);
    color: rgb(255 245 207 / 0.94);
  }

  .release-progress {
    border-color: rgb(255 255 255 / 0.24);
    background: rgb(255 255 255 / 0.05);
    box-shadow: 0 0 0.25em rgb(0 0 0 / 0.20);
    color: rgb(255 255 255 / 0.90);
  }

  .release-progress__track {
    border-color: rgb(255 255 255 / 0.22);
    background: rgb(255 255 255 / 0.12);
  }

  .release-progress__fill {
    background: repeating-linear-gradient(
      135deg,
      rgb(255 255 255 / 0.56) 0,
      rgb(255 255 255 / 0.56) 0.4rem,
      rgb(255 255 255 / 0.34) 0.4rem,
      rgb(255 255 255 / 0.34) 0.8rem
    );
  }

  .site-community-links::after {
    border-bottom-color: rgba(255, 255, 255, 0.5);
  }

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

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

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

}

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

@media (max-width: 600px) {
  .not-the-end {
    gap: 0.5rem;
  }

  .not-the-end img {
    width: min(calc(50% - 0.25rem), 10rem);
  }

  .not-the-end img:first-child {
    width: min(calc(45% - 0.225rem), 7.25rem);
  }

  .release-status {
    padding: 0.35em 0.4em 0.2em;
    font-size: 1.05rem;
  }

  .release-progress {
    padding: 0.5em 0.65em 0.55em;
    font-size: 0.9rem;
  }

  .logo {
    width: 200px;
    height: 140px;
    margin: 0 auto;
  }

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

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

  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,
  article > .saga-book-row {
    font-size: 1.15em;
  }

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

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

/**********
  Saga Row Collapse
**********/

/* Keep saga rows in two columns until the viewport is genuinely narrow. */
@media (max-width: 300px) {
  .saga-book-row {
    grid-template-columns: 1fr;
    gap: 0.09em;
    padding: 0.55em 0;
  }

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

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

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

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

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

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

  .release-status--grey,
  .release-status--silver {
    border-color: #777;
    background: white;
    color: black;
    box-shadow: none;
    break-inside: avoid;
  }

  nav,
  .site-footer,
  .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;
  }
}
