/* ============================================================
   Beyond — book design system.
   Shared by the WYSIWYG editor, wiki views, and the print/PDF
   pipeline. Change values here and the whole book follows.
   ============================================================ */

:root {
  --ink: #211505;
  --accent: #58180d;        /* chapter red */
  --accent-2: #7a200d;
  --gold: #c9ad6a;
  --parchment: #f4ecd8;
  --parchment-deep: #e9dcbd;
  --table-tint: #e8e0c8;
  --sidebar-bg: #e0e5c1;    /* PHB sidebar green */
  --statblock-bg: #fdf1dc;
}

/* ---------- the page sheet (editor + print) ---------- */

.sheet {
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.35), transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(120, 90, 40, 0.12), transparent 55%),
    var(--parchment);
  color: var(--ink);
  box-shadow: inset 0 0 90px rgba(120, 90, 40, 0.18);
}

/* ---------- typography ---------- */

.book-content {
  font-family: 'Alegreya', 'Palatino Linotype', Georgia, serif;
  font-size: 10.5pt;
  line-height: 1.35;
  color: var(--ink);
  text-align: justify;
  hyphens: auto;
}

.book-content p {
  margin: 0 0 0.45em 0;
}

.book-content h1,
.book-content h2,
.book-content h3,
.book-content h4 {
  font-family: 'Alegreya SC', 'Alegreya', serif;
  font-weight: 700;
  color: var(--accent);
  text-align: left;
  break-after: avoid;
  line-height: 1.1;
}

.book-content h1 {
  font-size: 26pt;
  margin: 0 0 0.35em 0;
  column-span: all;
}

.book-content h1::after {
  content: '';
  display: block;
  height: 4px;
  margin-top: 0.15em;
  background: linear-gradient(to right, var(--accent) 0%, var(--gold) 60%, transparent 100%);
}

.book-content h2 {
  font-size: 17pt;
  margin: 0.7em 0 0.25em 0;
  border-bottom: 1.5px solid var(--gold);
}

.book-content h3 {
  font-size: 13pt;
  margin: 0.6em 0 0.2em 0;
}

.book-content h4 {
  font-size: 11pt;
  font-style: italic;
  margin: 0.5em 0 0.15em 0;
}

.book-content a {
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 500;
}

.book-content ul,
.book-content ol {
  margin: 0 0 0.5em 0;
  padding-left: 1.4em;
}

.book-content li p {
  margin: 0;
}

.book-content blockquote {
  margin: 0.6em 0;
  padding: 0.4em 0.9em;
  border-left: 3px solid var(--gold);
  font-style: italic;
}

.book-content hr {
  border: none;
  height: 3px;
  margin: 0.9em auto;
  width: 70%;
  background: linear-gradient(to right, transparent, var(--gold), transparent);
}

.book-content code {
  font-family: 'PT Sans Narrow', sans-serif;
  background: var(--parchment-deep);
  padding: 0 0.25em;
  border-radius: 2px;
}

/* ---------- tables ---------- */

.book-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.6em 0 0.9em 0;
  font-size: 9.5pt;
  break-inside: avoid;
  text-align: left;
}

.book-content th {
  font-family: 'Alegreya SC', serif;
  font-weight: 700;
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  padding: 0.25em 0.5em;
  text-align: left;
}

.book-content td {
  padding: 0.22em 0.5em;
  vertical-align: top;
}

.book-content tbody tr:nth-child(even) td,
.book-content tr:nth-child(even) td {
  background: var(--table-tint);
}

.book-content th p,
.book-content td p {
  margin: 0;
}

/* Wide tables (class progressions etc.) span both print columns. */
.book-content table.wide {
  column-span: all;
  font-size: 8.5pt;
}

/* ---------- sidebar / read-aloud note ---------- */

.sidebar-note {
  background: var(--sidebar-bg);
  border-top: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.25);
  padding: 0.6em 0.9em;
  margin: 0.8em 0;
  break-inside: avoid;
  font-size: 9.8pt;
}

.sidebar-note > :first-child {
  margin-top: 0;
}

.sidebar-note h3,
.sidebar-note h4 {
  color: var(--ink);
  font-family: 'Alegreya SC', serif;
}

/* ---------- diegetic images ---------- */

.diegetic {
  margin: 0.5em 0;
  break-inside: avoid;
}

.diegetic img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

.diegetic figcaption {
  font-size: 8.5pt;
  font-style: italic;
  text-align: center;
  color: var(--accent-2);
  margin-top: 0.2em;
}

.diegetic.float-left {
  float: left;
  width: 45%;
  margin: 0.3em 0.9em 0.4em 0;
}

.diegetic.float-right {
  float: right;
  width: 45%;
  margin: 0.3em 0 0.4em 0.9em;
}

.diegetic.full-width {
  width: 100%;
  column-span: all;
}

.diegetic.full-page {
  column-span: all;
  break-before: page;
  break-after: page;
  width: 100%;
  margin: 0;
}

.diegetic.full-page img {
  height: 100%;
  object-fit: cover;
}

/* ---------- stat block ---------- */

.stat-block {
  background: var(--statblock-bg);
  border-top: 4px solid var(--gold);
  border-bottom: 4px solid var(--gold);
  box-shadow: 1px 2px 5px rgba(0, 0, 0, 0.3);
  padding: 0.55em 0.8em 0.7em 0.8em;
  margin: 0.8em 0;
  font-family: 'PT Sans Narrow', 'Arial Narrow', sans-serif;
  font-size: 9.5pt;
  line-height: 1.25;
  break-inside: avoid;
  text-align: left;
  hyphens: none;
}

.stat-block .sb-name {
  font-family: 'Alegreya SC', serif;
  font-size: 15pt;
  font-weight: 700;
  color: var(--accent);
  margin: 0;
  line-height: 1;
}

.stat-block .sb-meta {
  font-style: italic;
  margin: 0.1em 0 0.3em 0;
}

.stat-block .sb-rule {
  height: 3px;
  border: none;
  margin: 0.35em 0;
  background: linear-gradient(to right, var(--accent), transparent);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.stat-block .sb-line {
  margin: 0.1em 0;
  color: var(--accent);
}

.stat-block .sb-line strong {
  color: var(--accent);
}

.stat-block .sb-abilities {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  text-align: center;
  color: var(--accent);
  margin: 0.4em 0;
  gap: 0.15em;
}

.stat-block .sb-abilities .lbl {
  font-weight: 700;
  font-size: 9pt;
}

.stat-block .sb-section {
  font-family: 'Alegreya SC', serif;
  font-size: 12pt;
  font-weight: 400;
  color: var(--accent);
  border-bottom: 1.5px solid var(--accent);
  margin: 0.55em 0 0.25em 0;
}

.stat-block .sb-trait {
  margin: 0.25em 0;
  color: var(--ink);
}

.stat-block .sb-trait .tname {
  font-weight: 700;
  font-style: italic;
}

/* ---------- spell entry ---------- */

.spell-entry {
  break-inside: avoid-column;
  margin-bottom: 0.7em;
}

.spell-entry .sp-name {
  font-family: 'Alegreya SC', serif;
  font-size: 11.5pt;
  font-weight: 700;
  color: var(--accent);
  margin: 0;
}

.spell-entry .sp-meta {
  font-style: italic;
  font-size: 9.5pt;
  margin: 0 0 0.2em 0;
}

.spell-entry .sp-prop {
  margin: 0;
  font-size: 9.5pt;
}

.spell-entry p {
  margin: 0.2em 0;
}

/* ============================================================
   PRINT / PAGED OUTPUT
   ============================================================ */

@page {
  size: 8.5in 11in;
  margin: 0.75in 0.7in 0.8in 0.7in;

  @bottom-center {
    content: counter(page);
    font-family: 'Alegreya SC', serif;
    font-size: 10pt;
    color: #58180d;
  }

  @top-center {
    content: string(chaptertitle);
    font-family: 'Alegreya SC', serif;
    font-size: 9pt;
    color: #7a200d;
  }
}

.print-chapter {
  break-before: page;
}

.print-chapter > .book-content {
  columns: 2;
  column-gap: 0.3in;
  column-fill: auto;
}

.print-chapter h1 {
  string-set: chaptertitle content(text);
}

.print-single-col > .book-content {
  columns: 1;
}

/* Paged.js paints each generated page */
.pagedjs_page {
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.35), transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(120, 90, 40, 0.12), transparent 55%),
    #f4ecd8;
  box-shadow: inset 0 0 90px rgba(120, 90, 40, 0.18);
}

@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}
