@font-face { font-family: "EB Garamond"; src: url("../fonts/eb-garamond-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "EB Garamond"; src: url("../fonts/eb-garamond-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "EB Garamond"; src: url("../fonts/eb-garamond-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Fira Sans"; src: url("../fonts/fira-sans-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Fira Sans"; src: url("../fonts/fira-sans-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --ink: #191815;
  --muted: #6d675d;
  --paper: #fffdf8;
  --ground: #e9e4da;
  --line: #d8d0c2;
  --accent: #7e2039;
  --gold: #a68143;
  --font-size: 19px;
  --line-height: 1.65;
  --text-width: 760px;
  --page-padding: 72px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--ground); font-family: "Fira Sans", Arial, sans-serif; }
button, select, input { font: inherit; }
button, select { color: inherit; }
a { color: inherit; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 20; padding: 10px 14px; color: #fff; background: var(--accent); transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }

.topbar { position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 64px; padding: 0 28px; color: #f8f5ee; background: #171716; border-bottom: 1px solid #34322e; }
.back-link { justify-self: start; font-size: 14px; text-decoration: none; }
.back-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.topbar-title { display: flex; align-items: baseline; gap: 12px; }
.topbar-title strong { font-family: "EB Garamond", Georgia, serif; font-size: 22px; font-weight: 600; letter-spacing: .02em; }
.topbar-title span { color: #bdb7ad; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.settings-button { display: none; justify-self: end; padding: 8px 12px; color: #fff; background: transparent; border: 1px solid #77736c; border-radius: 2px; }

.reader-layout { display: grid; grid-template-columns: 310px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.settings { border-right: 1px solid #cdc5b8; background: #f7f3eb; }
.settings-inner { position: sticky; top: 64px; max-height: calc(100vh - 64px); overflow: auto; padding: 35px 30px 28px; }
.eyebrow { margin: 0 0 7px; color: var(--accent); font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; }
.settings h1 { margin: 0; font-family: "EB Garamond", Georgia, serif; font-size: 35px; font-weight: 600; }
.settings-intro { margin: 7px 0 26px; color: var(--muted); font-family: "EB Garamond", Georgia, serif; font-size: 17px; line-height: 1.4; }
fieldset { margin: 0 0 24px; padding: 0; border: 0; }
legend { width: 100%; margin-bottom: 12px; padding: 0 0 7px; color: var(--accent); border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
label:not(.check-row) { display: flex; justify-content: space-between; gap: 10px; margin: 13px 0 6px; color: #49453e; font-size: 13px; }
output { color: var(--muted); font-variant-numeric: tabular-nums; }
select { width: 100%; min-height: 40px; padding: 7px 9px; background: #fff; border: 1px solid #bdb5a8; border-radius: 2px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.check-row { display: flex; align-items: center; gap: 9px; font-family: "EB Garamond", Georgia, serif; font-size: 17px; }
.check-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.chapter-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.chapter-buttons button, .print-button { min-height: 40px; padding: 8px; background: transparent; border: 1px solid #aaa194; border-radius: 2px; cursor: pointer; }
.chapter-buttons button:hover, .print-button:hover { border-color: var(--accent); color: var(--accent); }
.chapter-buttons button:disabled { opacity: .4; cursor: default; }
.print-button { width: 100%; color: #fff; background: var(--accent); border-color: var(--accent); }
.print-button:hover { color: #fff; background: #65172c; }
.imprint { margin: 24px 0 0; color: var(--muted); font-family: "EB Garamond", Georgia, serif; font-size: 14px; text-align: center; }

.book-stage { min-width: 0; padding: 54px 32px 90px; }
.book { width: min(100%, calc(var(--text-width) + (var(--page-padding) * 2))); margin: 0 auto; background: var(--paper); box-shadow: 0 18px 55px rgba(44, 38, 29, .16); }
.frontmatter { display: grid; grid-template-columns: minmax(190px, 260px) 1fr; gap: 54px; align-items: center; min-height: 570px; padding: var(--page-padding); border-bottom: 1px solid var(--line); }
.cover-panel img { display: block; width: 100%; height: auto; box-shadow: 11px 13px 24px rgba(27, 24, 20, .24); }
.frontmatter h2, .contents h2 { margin: 0 0 22px; font-family: "EB Garamond", Georgia, serif; font-size: clamp(38px, 5vw, 58px); font-weight: 400; }
.frontmatter-text > p:not(.eyebrow, .publisher) { margin: 0 0 13px; font-family: "EB Garamond", Georgia, serif; font-size: 20px; line-height: 1.55; }
.publisher { margin-top: 35px; color: var(--muted); font-size: 13px; letter-spacing: .12em; }
.contents { padding: var(--page-padding); border-bottom: 1px solid var(--line); }
.contents-books { display: grid; gap: 30px; }
.contents-group h3 { margin: 0 0 10px; font-family: "EB Garamond", Georgia, serif; font-size: 24px; font-weight: 600; }
.chapter-links { display: flex; flex-wrap: wrap; gap: 7px; }
.chapter-links a { display: grid; width: 37px; height: 37px; place-items: center; color: #454039; background: #f7f2e9; border: 1px solid #ded5c6; border-radius: 50%; font-size: 13px; text-decoration: none; }
.chapter-links a:hover, .chapter-links a[aria-current="page"] { color: #fff; background: var(--accent); border-color: var(--accent); }

.chapter { min-height: 600px; padding: var(--page-padding); font-family: "EB Garamond", Georgia, serif; font-size: var(--font-size); line-height: var(--line-height); }
.chapter-head { margin: 0 auto 42px; text-align: center; }
.chapter-head > p:first-child { margin: 0; color: var(--accent); font-family: "Fira Sans", Arial, sans-serif; font-size: 11px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; }
.chapter-head h1 { margin: 4px 0 22px; font-size: 72px; font-weight: 400; line-height: 1; }
.chapter-intro { max-width: 38em; margin: 0 auto; color: var(--muted); font-size: .84em; font-style: italic; line-height: 1.5; }
.scripture { max-width: var(--text-width); margin: 0 auto; }
.verse { display: inline; margin: 0; text-align: justify; }
.verse-number { margin: 0 .32em 0 .12em; color: var(--accent); font-family: "Fira Sans", Arial, sans-serif; font-size: .58em; font-weight: 600; vertical-align: .55em; }
.verse-text::after { content: " "; }
.verse-text i { font-style: italic; }
.note-marker { margin-left: .08em; color: var(--accent); font-family: "Fira Sans", Arial, sans-serif; font-size: .55em; font-weight: 600; vertical-align: .65em; }
.god-speaks { color: #32271c; }
.notes { max-width: var(--text-width); margin: 62px auto 0; padding-top: 28px; border-top: 2px solid var(--ink); }
.notes h2 { margin: 0 0 24px; font-size: 30px; font-weight: 400; }
.notes ol { display: grid; gap: 13px; margin: 0; padding: 0; list-style: none; }
.note { display: grid; grid-template-columns: 28px 1fr; gap: 10px; color: #3f3a34; font-size: .8em; line-height: 1.45; }
.note-marker-label { color: var(--accent); font-family: "Fira Sans", Arial, sans-serif; font-size: .8em; font-weight: 600; }
.note-kind { display: block; margin-bottom: 2px; color: var(--muted); font-family: "Fira Sans", Arial, sans-serif; font-size: .66em; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; }
.note--crossref { color: #5d574f; }
.loading, .error { margin: 0; color: var(--muted); font-size: 18px; text-align: center; }
.error { color: var(--accent); }
.noscript { margin: 24px; padding: 15px; background: #fff; }

body[data-margins="compact"] { --page-padding: 42px; }
body[data-margins="ruim"] { --page-padding: 98px; }

@media (max-width: 920px) {
  .topbar { grid-template-columns: 1fr auto; padding: 0 18px; }
  .topbar-title { display: none; }
  .settings-button { display: block; }
  .reader-layout { display: block; }
  .settings { display: none; border-right: 0; border-bottom: 1px solid #c8c0b3; }
  .settings.is-open { display: block; }
  .settings-inner { position: static; max-height: none; padding: 24px 22px; }
  .settings-inner fieldset { max-width: 620px; }
  .book-stage { padding: 24px 14px 60px; }
  .book { box-shadow: 0 8px 30px rgba(44, 38, 29, .13); }
  .frontmatter { grid-template-columns: 170px 1fr; gap: 32px; min-height: 0; }
}

@media (max-width: 620px) {
  :root { --page-padding: 28px; --font-size: 18px; }
  .topbar { min-height: 56px; }
  .reader-layout { min-height: calc(100vh - 56px); }
  .book-stage { padding: 12px 0 45px; }
  .book { width: 100%; }
  .frontmatter { grid-template-columns: 1fr; gap: 30px; padding: 34px 28px 42px; }
  .cover-panel { width: min(64vw, 235px); margin: 0 auto; }
  .frontmatter h2, .contents h2 { font-size: 40px; }
  .frontmatter-text > p:not(.eyebrow, .publisher) { font-size: 18px; }
  .contents, .chapter { padding: 42px 28px; }
  .chapter-head h1 { font-size: 60px; }
  .chapter-intro { text-align: left; }
  body[data-margins="compact"] { --page-padding: 20px; }
  body[data-margins="ruim"] { --page-padding: 42px; }
  body[data-margins] .chapter, body[data-margins] .contents { padding-left: var(--page-padding); padding-right: var(--page-padding); }
}

@media print {
  @page { size: A5; margin: 16mm 14mm 18mm; }
  :root { --font-size: 10pt; --line-height: 1.45; --text-width: 100%; --page-padding: 0; }
  body { background: #fff; }
  .topbar, .settings { display: none !important; }
  .reader-layout { display: block; }
  .book-stage { padding: 0; }
  .book { width: auto; box-shadow: none; }
  .frontmatter, .contents { min-height: 0; padding: 0; border: 0; break-after: page; }
  .frontmatter { grid-template-columns: 38mm 1fr; gap: 12mm; }
  .frontmatter h2, .contents h2 { font-size: 24pt; }
  .contents { padding-top: 18mm; }
  .chapter { padding: 0; }
  .chapter-head { break-after: avoid; }
  .chapter-head h1 { font-size: 38pt; }
  .notes { break-before: page; }
  .chapter-links a { width: 7mm; height: 7mm; }
}
