:root {
  color-scheme: dark;
  --bg: #030304;
  --surface: #0a0a0d;
  --surface-soft: #111116;
  --ink: #f0eee6;
  --muted: #b9b2a6;
  --rule: #d6cfbf;
  --link: #9fcfff;
  --link-hover: #ffb0a4;
  --tome-link: #9fcfff;
  --tome-link-hover: #ffb0a4;
  --author-saint: #e8c878;
  --author-christian: #9fcfff;
  --author-classical: #c9a7eb;
  --author-collection: #b9b2a6;
  --night-text: #d7d2c8;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--night-text);
  background-color: var(--bg);
  background-image: url("../images/johannes_lingelbach.webp");
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: cover;
  font-family: Verdana, Tahoma, "Trebuchet MS", sans-serif;
}

a {
  color: var(--link);
  font-weight: 700;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

a:hover,
a:focus-visible {
  color: var(--link-hover);
}

a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 0.16rem;
}

.app-shell {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 1.25rem 1.5rem;
}

.site-footer {
  padding: 2.5rem 1.5rem 1.5rem;
  background: linear-gradient(
    to bottom,
    rgba(3, 3, 4, 0),
    rgba(3, 3, 4, 0.82) 58%,
    rgba(3, 3, 4, 0.96)
  );
}

.site-footer p {
  margin: 0 auto;
  width: min(100%, 70rem);
  padding-top: 0.85rem;
  border-top: 1px solid rgba(214, 207, 191, 0.26);
  color: var(--night-text);
  font-size: 0.95rem;
  text-align: center;
}

.site-footer a {
  color: var(--link);
}

.tome {
  position: relative;
  width: min(100%, 70rem);
  margin: auto 0;
  padding: clamp(1rem, 3vw, 2rem);
  border: 0.22rem double rgba(214, 207, 191, 0.78);
  color: var(--ink);
  background: var(--surface);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    0 1.25rem 3rem rgba(0, 0, 0, 0.78),
    inset 0 0 3.5rem rgba(0, 0, 0, 0.58);
}

.tome a {
  color: var(--tome-link);
}

.tome a:hover,
.tome a:focus-visible {
  color: var(--tome-link-hover);
}

.tome::before,
.tome::after {
  position: absolute;
  top: 0.7rem;
  bottom: 0.7rem;
  width: 0.18rem;
  content: "";
  background: linear-gradient(transparent, rgba(214, 207, 191, 0.62), transparent);
}

.tome::before {
  left: 0.7rem;
}

.tome::after {
  right: 0.7rem;
}

.breadcrumbs {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.breadcrumbs li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
  max-width: 100%;
}

.breadcrumbs a {
  min-width: 0;
  overflow-wrap: anywhere;
}

.breadcrumb-separator {
  flex-shrink: 0;
}

.tome-masthead {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.35rem 0.45rem 0.85rem;
  text-align: center;
}

.site-place {
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.85rem, 2vw, 1rem);
  font-weight: 700;
  text-transform: uppercase;
}

.tome h1 {
  margin: 0.1rem 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.85rem, 5vw, 3.2rem);
  font-weight: 700;
  line-height: 1;
  text-shadow:
    0 0 0.65rem rgba(255, 255, 255, 0.14),
    2px 2px 0 #000;
}

.tome-rule {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.1rem 0 1rem;
  color: var(--rule);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.95rem;
  letter-spacing: 0;
  text-align: center;
}

.tome-rule::before,
.tome-rule::after {
  flex: 1;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--rule), transparent);
}

.tome-grid {
  display: grid;
  gap: 0.85rem;
}

.tome-grid.commonplaces-grid {
  grid-template-columns: minmax(0, 1fr);
}

.tome-panel {
  position: relative;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(214, 207, 191, 0.48);
  background: var(--surface-soft);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.055),
    0 0 1.35rem rgba(0, 0, 0, 0.18);
}

.tome-panel-wide {
  grid-column: 1 / -1;
}

.tome-panel h2 {
  position: absolute;
  top: -0.58rem;
  left: 50%;
  max-width: calc(100% - 1.5rem);
  margin: 0;
  padding: 0 0.45rem;
  overflow: hidden;
  color: var(--ink);
  background: var(--surface);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  transform: translateX(-50%);
}

.tome-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.52;
}

.tome-panel p + p {
  margin-top: 0.65rem;
}

.link-panel ul {
  margin: 0;
  padding-left: 1.25rem;
}

.link-panel li {
  line-height: 1.35;
}

.link-panel li + li {
  margin-top: 0.3rem;
}

.author-key {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  min-width: 0;
  margin: 0 0 0.75rem;
  padding: 0;
  border: 0;
  color: var(--muted);
  font-size: 0.8rem;
}


.author-key label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.author-key input {
  margin: 0;
}

.tome .author-link--saint {
  color: var(--author-saint);
}

.tome .author-link--christian {
  color: var(--author-christian);
}

.tome .author-link--classical {
  color: var(--author-classical);
}

.tome .author-link--collection {
  color: var(--author-collection);
}

.author-key--saint input {
  accent-color: var(--author-saint);
}

.author-key--christian input {
  accent-color: var(--author-christian);
}

.author-key--classical input {
  accent-color: var(--author-classical);
}

.author-key--collection input {
  accent-color: var(--author-collection);
}

.library-texts:has(#show-saints:not(:checked)) .author-list > .author-link--saint,
.library-texts:has(#show-christian:not(:checked)) .author-list > .author-link--christian,
.library-texts:has(#show-classical:not(:checked)) .author-list > .author-link--classical,
.library-texts:has(#show-collections:not(:checked)) .author-list > .author-link--collection,
.library-empty {
  display: none;
}

.library-texts:not(:has(.author-key input:checked)) .library-empty {
  display: block;
  color: var(--muted);
}

.contents-panel-body,
.web-portal-panel-body,
.council-panel-body,
.local-panel-body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 1rem;
}

.council-panel-body,
.local-panel-body {
  grid-template-columns: minmax(0, 1fr) auto;
}

.panel-icon {
  display: block;
  width: clamp(5.25rem, 9.5vw, 6.5rem);
  height: auto;
  padding: 0.15rem;
  border: 1px solid rgba(214, 207, 191, 0.62);
  background: #050506;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 0.45rem 1.2rem rgba(0, 0, 0, 0.55);
}

.council-panel-body .panel-icon {
  width: clamp(4.5rem, 8vw, 5.5rem);
}

.web-portal-panel-body .panel-icon {
  width: clamp(7rem, 13vw, 9rem);
}

.link-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.45rem;
  justify-content: center;
}

.web-button {
  display: inline-flex;
  width: 88px;
  height: 31px;
  line-height: 0;
}

.web-button img {
  display: block;
  width: 88px;
  height: 31px;
  image-rendering: pixelated;
}

.book-author {
  color: var(--muted);
}

.book-author::before {
  content: "- ";
}

.game-profile {
  display: grid;
  justify-items: center;
  gap: 0.65rem;
  margin: 0;
}

.game-profile-image {
  display: block;
  width: min(100%, 374px);
  height: auto;
  border: 1px solid rgba(214, 207, 191, 0.62);
  image-rendering: pixelated;
}

.game-profile figcaption {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.manuscript-reader {
  max-width: 52rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.manuscript-masthead {
  justify-content: center;
  padding: 0 0.45rem 0.65rem;
}

.manuscript-masthead > div {
  width: 100%;
  margin-inline: auto;
}

.manuscript-masthead h1 {
  text-align: center;
}

.manuscript-source {
  margin-top: 0.85rem;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.45;
  text-align: center;
}

.manuscript-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  justify-content: center;
  margin: 0.15rem 0 0.9rem;
  font-size: 0.95rem;
}

.manuscript-body {
  user-select: text;
}

.manuscript-contents {
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.manuscript-contents summary {
  width: fit-content;
  cursor: pointer;
  font-weight: 700;
}

.manuscript-contents summary:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 0.16rem;
}

.manuscript-contents ol {
  margin: 0.75rem 0 0;
  padding-left: 1.5rem;
  list-style: none;
}

.manuscript-contents li + li {
  margin-top: 0.4rem;
}

.manuscript-contents a {
  font-weight: 400;
}

.manuscript-contents .manuscript-section-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0;
}

.manuscript-section-list li + li {
  margin-top: 0;
}

.manuscript-section-list a {
  display: block;
  min-width: 2rem;
  padding: 0.25rem;
  text-align: center;
}

.manuscript-body p[id] {
  scroll-margin-top: 1.5rem;
}

.manuscript-body h2 {
  margin: 2rem 0 0.7rem;
  scroll-margin-top: 1.5rem;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  line-height: 1.25;
}

.manuscript-body h2 a,
.manuscript-body .manuscript-section-number {
  color: inherit;
  text-decoration: none;
}

.manuscript-body h2 a:hover,
.manuscript-body h2 a:focus-visible,
.manuscript-body .manuscript-section-number:hover,
.manuscript-body .manuscript-section-number:focus-visible {
  text-decoration: underline;
}

.manuscript-body h2:first-child {
  margin-top: 0;
}

.manuscript-body p {
  margin: 0;
  color: var(--ink);
  font-size: 1.08rem;
  line-height: 1.68;
}

.manuscript-body p + p {
  margin-top: 0.9rem;
}

.manuscript-body .manuscript-indent {
  margin-left: 1.5rem;
}

.manuscript-large {
  font-size: 1.15em;
}

.manuscript-gray {
  color: var(--muted);
}

.manuscript-table {
  width: 100%;
  margin: 0.9rem 0;
  border-collapse: collapse;
  font-size: 1.08rem;
  line-height: 1.68;
}

.manuscript-table td {
  padding: 0.15rem 0.5rem 0.15rem 0;
  vertical-align: top;
}

.manuscript-table td:last-child {
  width: 35%;
}

.character-reference {
  min-width: 0;
}

.character-reference p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.character-blocks {
  padding-left: 1.25rem;
  columns: 2 20rem;
  column-gap: 2rem;
  line-height: 1.5;
}

.character-blocks li {
  margin-bottom: 0.5rem;
  break-inside: avoid;
}

.character-blocks small {
  display: block;
  color: var(--muted);
}

.character-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.character-table caption {
  padding: 0.6rem 0;
  color: var(--muted);
  text-align: left;
}

.character-table th,
.character-table td {
  padding: 0.55rem clamp(0.2rem, 1vw, 0.75rem);
  border-bottom: 1px solid rgba(214, 207, 191, 0.25);
  text-align: left;
  overflow-wrap: anywhere;
}

.character-table code,
.character-table td:first-child {
  white-space: nowrap;
}

.character-glyph bdi {
  font-family: sans-serif;
  font-size: 1.5rem;
}

.character-glyph small {
  color: var(--muted);
  font-size: 0.8rem;
}

.character-pagination,
.character-pagination form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.character-pagination {
  margin: 1rem 0;
  font-size: 0.9rem;
}

.character-pagination input,
.character-pagination button {
  padding: 0.35rem;
  border: 1px solid var(--muted);
  color: var(--ink);
  background: var(--surface-soft);
  font: inherit;
}

.character-pagination input {
  width: 4.5rem;
}

.character-pagination button {
  cursor: pointer;
}

.character-source {
  margin-top: 1.5rem;
}

@media (min-width: 900px) {
  .tome-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .gaming-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .button-panel,
  .local-panel {
    grid-column: 1 / -1;
  }

  .local-panel ul {
    columns: 2;
    column-gap: 2rem;
  }

  .local-panel li {
    break-inside: avoid;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 0.9rem 0.75rem;
  }

  .site-footer {
    padding: 0 0.75rem 1rem;
  }

  .tome {
    margin: 0;
    padding: 0.9rem;
  }

  .tome::before,
  .tome::after {
    display: none;
  }

  .tome-masthead {
    justify-content: center;
  }

  .panel-icon {
    width: 5rem;
  }

  .council-panel-body .panel-icon {
    width: 4.25rem;
  }

  .web-portal-panel-body .panel-icon {
    width: 6.5rem;
  }

  .tome h1 {
    font-size: clamp(1.7rem, 11vw, 2.6rem);
  }
}

@media print {
  @page {
    margin: 20mm;
  }

  body:has(.manuscript-reader) {
    color-scheme: light;
    --ink: #000;
    --muted: #333;
    display: block;
    min-height: auto;
    color: #000;
    background: #fff;
  }

  .app-shell:has(.manuscript-reader) {
    display: block;
    padding: 0;
  }

  .manuscript-reader {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    font-family: Georgia, "Times New Roman", serif;
  }

  body:has(.manuscript-reader) .site-footer,
  .manuscript-reader::before,
  .manuscript-reader::after,
  .manuscript-reader .breadcrumbs,
  .manuscript-reader .tome-rule,
  .manuscript-nav,
  .manuscript-contents {
    display: none;
  }

  .manuscript-masthead {
    display: block;
    padding: 0 0 1rem;
  }

  .manuscript-reader h1 {
    font-size: 24pt;
    line-height: 1.15;
    text-shadow: none;
  }

  .manuscript-source {
    font-size: 10pt;
  }

  .manuscript-body h2 {
    font-size: 14pt;
    break-after: avoid;
  }

  .manuscript-body h2 a,
  .manuscript-body .manuscript-section-number {
    color: #000;
    text-decoration: none;
  }

  .manuscript-body p {
    font-size: 11pt;
    line-height: 1.5;
    orphans: 3;
    widows: 3;
  }
}
