/* Bookdesign — how a printed page looks. Shared by the editor, the reader
   and the PDF; see assets/book.js. Everything is in inches and points so
   the printed page is the page designed. */

.bk-frame { position: relative; overflow: hidden; flex: none; }
.bk-frame > .bk-page { position: absolute; left: 0; top: 0; }

.bk-page {
  position: relative;
  width: var(--bk-w); height: var(--bk-h);
  background: var(--bk-bg); color: var(--bk-ink);
  font-family: var(--bk-body); font-size: var(--bk-size); line-height: 1.45;
  overflow: hidden; box-sizing: border-box;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
  font-kerning: normal; font-variant-ligatures: common-ligatures;
}
.bk-page * { box-sizing: border-box; }

.bk-img { position: absolute; overflow: hidden; }
.bk-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.bk-lay-framed .bk-img { border-radius: 0.06in; box-shadow: 0 0 0 0.012in color-mix(in srgb, var(--bk-ink) 22%, transparent); }

.bk-ph {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  background:
    repeating-linear-gradient(135deg, color-mix(in srgb, var(--bk-ink) 4%, transparent) 0 0.08in, transparent 0.08in 0.16in),
    color-mix(in srgb, var(--bk-ink) 5%, var(--bk-bg));
  color: color-mix(in srgb, var(--bk-ink) 45%, transparent);
  font: 600 11pt/1.2 "DM Sans", system-ui, sans-serif; letter-spacing: 0.02em;
}

.bk-text { position: absolute; display: flex; align-items: center; justify-content: center; text-align: center; }
.bk-fit { white-space: pre-line; text-wrap: pretty; hyphens: manual; max-width: 100%; }
.bk-large .bk-fit { font-size: 1.15em; line-height: 1.55; }
.bk-blurb .bk-fit { font-style: italic; }

.bk-panel {
  position: absolute; left: 8%; right: 8%; bottom: 5%;
  max-height: 34%;
  padding: 0.18in 0.3in; border-radius: 0.14in; text-align: center;
  background: color-mix(in srgb, var(--bk-bg) 90%, transparent);
  box-shadow: 0 0.04in 0.2in rgba(0,0,0,0.12);
}

.bk-folio {
  position: absolute; left: 0; right: 0; bottom: 0.28in; text-align: center;
  font-size: 0.55em; letter-spacing: 0.08em; opacity: 0.55;
}

/* the cover */
.bk-cover-blank .bk-ph, .bk-cover .bk-cover-blank {
  background:
    radial-gradient(120% 80% at 50% 110%, color-mix(in srgb, var(--bk-ink) 14%, var(--bk-bg)), var(--bk-bg));
}
.bk-cover-title {
  position: absolute; left: 0; right: 0; top: 0; padding: 0.55in 0.5in 1in; text-align: center;
}
.bk-scrim { background: linear-gradient(to bottom, color-mix(in srgb, var(--bk-bg) 88%, transparent) 0%, color-mix(in srgb, var(--bk-bg) 60%, transparent) 55%, transparent 100%); }
.bk-title {
  font-family: var(--bk-head); font-weight: 600; font-size: 2.6em; line-height: 1.02;
  letter-spacing: -0.01em; white-space: nowrap; overflow: visible;
}
.bk-cover .bk-title { white-space: normal; text-wrap: balance; }
.bk-subtitle { font-family: var(--bk-head); font-style: italic; font-size: 1.1em; margin-top: 0.12in; opacity: 0.85; }
.bk-author { font-size: 0.85em; letter-spacing: 0.16em; text-transform: uppercase; margin-top: 0.22in; opacity: 0.85; }

/* the title page */
.bk-titlepage { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 0.8in; }
.bk-titlepage .bk-title { white-space: normal; text-wrap: balance; font-size: 2.2em; }
.bk-rule { width: 0.6in; height: 0.012in; background: currentColor; opacity: 0.35; margin: 0.3in 0 0.05in; }
.bk-dedication { position: absolute; bottom: 0.9in; left: 1in; right: 1in; font-style: italic; font-size: 0.8em; opacity: 0.8; white-space: pre-line; }

/* the back cover */
.bk-colophon { position: absolute; left: 0; right: 0; bottom: 0.45in; text-align: center; }
.bk-colophon-title { font-family: var(--bk-head); font-size: 0.9em; opacity: 0.75; }
.bk-made { font: 600 6.5pt/1.4 "DM Sans", system-ui, sans-serif; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.4; margin-top: 0.08in; }

/* drawing, in the editor only */
.bk-pending {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 0.12in; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--bk-bg) 55%, transparent); backdrop-filter: blur(2px);
  font: 600 12pt "DM Sans", system-ui, sans-serif; color: var(--bk-ink);
}
.bk-pending i {
  width: 0.4in; height: 0.4in; border-radius: 50%;
  border: 0.04in solid color-mix(in srgb, var(--bk-ink) 18%, transparent); border-top-color: var(--bk-ink);
  animation: bk-spin 0.9s linear infinite;
}
@keyframes bk-spin { to { transform: rotate(360deg); } }

/* print: only the book, one page per sheet, nothing else */
#bk-print { display: none; }
@media print {
  html, body { margin: 0 !important; padding: 0 !important; background: none !important; }
  body > *:not(#bk-print) { display: none !important; }
  #bk-print { display: block !important; }
  #bk-print .bk-page { break-after: page; page-break-after: always; }
  #bk-print .bk-page:last-child { break-after: auto; page-break-after: auto; }
}
