/* Visual identity follows reba.fi: Bitter (text), Montserrat (headings/UI),
   watercolour tree illustration, soft sage/sand accents on white. */

@font-face { font-family: "Bitter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("assets/fonts/bitter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Bitter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("assets/fonts/bitter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Bitter"; font-style: italic; font-weight: 100 900; font-display: swap;
  src: url("assets/fonts/bitter-latin-italic.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Bitter"; font-style: italic; font-weight: 100 900; font-display: swap;
  src: url("assets/fonts/bitter-latin-ext-italic.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("assets/fonts/montserrat-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("assets/fonts/montserrat-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --bg: #ffffff;
  --paper: #fbfaf7;
  --ink: #2f3133;
  --heading: #0f253a;
  --muted: #6b6b6b;
  --faint: #a4a4a4;
  --line: #e6e2d9;
  --sand: #c2a990;
  --sand-soft: #f3eee6;
  --sage: #b1c5a4;
  --sage-soft: #eef3ea;
  --stone: #b5bdbc;
  --accent: #d8613c;
  --eyebrow: #3d6b5f;
  --link: #2f5f6e;
  --link-hover: #0f253a;

  --font-text: "Bitter", "Iowan Old Style", Georgia, serif;
  --font-ui: "Montserrat", -apple-system, "Segoe UI", Roboto, sans-serif;
  --measure: 40rem;
  --gutter: 16px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 1.125rem;
  line-height: 1.7;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--link); text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent); text-underline-offset: 0.18em; }
a:hover { color: var(--link-hover); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.topbar-inner {
  max-width: 64rem;
  margin: 0 auto;
  padding: 0.35rem var(--gutter);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  font-family: var(--font-ui);
}
.brand { justify-self: start; display: inline-flex; border-radius: 8px; }
.brand img { display: block; width: 44px; height: 44px; mix-blend-mode: multiply; }
.topbar-title {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--heading);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
}
.topbar-title:hover { background: var(--sage-soft); color: var(--heading); }

.ref-toggle {
  justify-self: end;
  font: 600 0.72rem/1 var(--font-ui);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 0.9rem 0.55rem 0.75rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.ref-toggle::before {
  content: "";
  width: 0.55rem; height: 0.55rem;
  border-radius: 50%;
  border: 1.5px solid currentColor;
}
.ref-toggle[aria-pressed="true"] { color: var(--heading); border-color: var(--sage); background: var(--sage-soft); }
.ref-toggle[aria-pressed="true"]::before { background: var(--accent); border-color: var(--accent); }

/* ---------- Hero illustration ---------- */

.hero { position: relative; overflow: hidden; background: var(--bg); }
.hero img { display: block; width: 100%; object-fit: cover; }
.hero-full img { height: clamp(220px, 38vw, 530px); object-position: center top; }
.hero-slim img { height: clamp(120px, 16vw, 200px); object-position: center 62%; opacity: 0.9; }
.hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 45%;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), var(--bg));
}

/* ---------- Page sheet ---------- */

.sheet {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter) 2rem;
  position: relative;
}
.page-chapter .sheet { margin-top: -2.5rem; }

.eyebrow {
  margin: 0 0 0.6rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--eyebrow);
  text-shadow: 0 0 2px #fff, 0 0 8px #fff, 0 0 14px rgba(255, 255, 255, 0.9);
}

.ornament {
  width: 4.5rem;
  height: 10px;
  margin: 1.25rem auto 0;
  background:
    radial-gradient(circle, var(--sand) 2.5px, transparent 3px) center / 10px 10px no-repeat,
    linear-gradient(var(--sand), var(--sand)) left center / 40% 1px no-repeat,
    linear-gradient(var(--sand), var(--sand)) right center / 40% 1px no-repeat;
}

/* ---------- Index ---------- */

.book-head { text-align: center; margin: -3rem 0 2.5rem; position: relative; }
.book-head h1 {
  margin: 0;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: clamp(1.7rem, 4.6vw, 2.6rem);
  line-height: 1.2;
  color: var(--heading);
  text-wrap: balance;
}
.book-head h1 span {
  display: block;
  margin-top: 0.4rem;
  font-family: var(--font-text);
  font-style: italic;
  font-weight: 400;
  font-size: 0.62em;
  color: var(--muted);
}
.editors {
  margin: 1rem 0 0;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--muted);
}

.toc { display: grid; gap: 2rem; }
.toc-group h2 {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin: 0 0 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-text);
  font-weight: 500;
  font-size: 1.35rem;
  line-height: 1.3;
  color: var(--heading);
}
.toc-group h2 small {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}
.toc-list { list-style: none; margin: 0; padding: 0; }
.toc-list a {
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
  padding: 0.5rem 0.6rem;
  margin: 0 -0.6rem;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.4;
  transition: background-color 0.15s ease;
}
.toc-list a:hover { background: var(--sage-soft); color: var(--heading); }
.toc-num {
  flex: 0 0 1.9rem;
  height: 1.9rem;
  display: inline-grid;
  place-items: center;
  align-self: center;
  border-radius: 50%;
  background: var(--sand-soft);
  color: var(--heading);
  font: 600 0.78rem/1 var(--font-ui);
  font-variant-numeric: tabular-nums;
}
.toc-list a:hover .toc-num { background: var(--sage); }
.toc-caps .toc-label {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.08em;
}
.toc-caps a { padding-left: 1.6rem; position: relative; }
.toc-caps a::before {
  content: "";
  position: absolute;
  left: 0.6rem;
  top: 50%;
  width: 6px; height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--sage);
}
.toc-caps a, .toc-caps a::before { margin-left: 0; }
.toc-caps a { margin: 0 -0.6rem; }

/* ---------- Chapter ---------- */

.chapter-head { text-align: center; margin-bottom: 2.25rem; }
.chapter-head h1 {
  margin: 0;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: clamp(1.6rem, 4.4vw, 2.3rem);
  line-height: 1.2;
  color: var(--heading);
  text-wrap: balance;
}
.section-catechism .chapter-head h1,
.section-appendix .chapter-head h1 {
  font-size: clamp(1.25rem, 3.6vw, 1.7rem);
  letter-spacing: 0.08em;
}

.chapter-body > p, .chapter-body > .p { margin: 0 0 1.15em; hyphens: auto; -webkit-hyphens: auto; }
.chapter-body h2 {
  margin: 2.5rem 0 1rem;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--heading);
}
.section-catechism .chapter-body h2 { text-align: center; letter-spacing: 0.1em; font-size: 1rem; }
.chapter-body ul { margin: 0.5rem 0 1rem; padding-left: 1.25rem; }
.chapter-body li { margin: 0.2rem 0; }
.chapter-body li::marker { color: var(--sand); }

/* Numbered confession paragraphs */
p.numbered { position: relative; }
.para-num {
  float: left;
  margin: 0.32em 0.6em 0 0;
  min-width: 1.7em;
  height: 1.7em;
  padding: 0 0.3em;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--sand-soft);
  color: var(--heading);
  font: 600 0.72rem/1 var(--font-ui);
  font-variant-numeric: tabular-nums;
}

/* Inline Bible cross references */
.note-crossReference {
  font-family: var(--font-ui);
  font-size: 0.68em;
  line-height: 1.5;
  font-weight: 500;
  color: var(--muted);
  background: var(--sage-soft);
  border-radius: 4px;
  padding: 0.1em 0.45em;
  margin: 0 0.15em 0 0.1em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  white-space: normal;
  vertical-align: 0.1em;
}
.note-crossReference a { color: var(--link); text-decoration: none; }
.note-crossReference a:hover { text-decoration: underline; }
.hide-refs .note-crossReference { display: none; }

.note-explanation { font-style: italic; }
.note-explanation::before { content: " ("; }
.note-explanation::after { content: ")"; }

.bold { font-weight: 700; }
.italic { font-style: italic; }
.divineName { font-variant: small-caps; letter-spacing: 0.03em; }

/* ---------- Catechism Q&A cards ---------- */

.qa {
  margin: 0 0 1.5rem;
  padding: 1.4rem 1.5rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
}
.qa p { margin: 0 0 1rem; }
.qa-label {
  display: block;
  margin-bottom: 0.2rem;
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.qa-question { font-size: 1.2rem; line-height: 1.45; color: var(--heading); font-weight: 500; }
.qa-question .qa-label { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; color: var(--accent); }
.qa-num {
  display: inline-grid;
  place-items: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--heading);
  color: #fff;
  font-size: 0.8rem;
  letter-spacing: 0;
}
.qa-answer {
  padding-left: 1rem;
  border-left: 3px solid var(--sage);
  font-weight: 500;
}
.qa-scripture, .qa-see-also { font-size: 0.95rem; color: var(--ink); }
.qa-scripture .italic { color: #4a4d50; }
.qa-comment {
  font-size: 0.95rem;
  color: #46494c;
  background: #fff;
  margin-left: -0.6rem !important;
  margin-right: -0.6rem !important;
  padding: 0 0.6rem;
}
.qa-comment:not(.qa-comment-cont) { padding-top: 0.8rem; border-top: 1px dashed var(--line); background: transparent; }
.qa-comment-cont { background: transparent; }

/* ---------- Prayers and hymns ---------- */

.verse .chapter-body > p {
  white-space: pre-line;
  text-align: center;
  font-size: 1.15rem;
  line-height: 1.75;
  hyphens: manual;
}
.verse .chapter-body > p:first-child { font-family: var(--font-ui); font-size: 0.85rem; color: var(--muted); }

/* ---------- Pager ---------- */

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 3rem 0 1rem;
}
.pager-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--heading);
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.35;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  min-width: 0;
}
.pager-link span { min-width: 0; overflow-wrap: anywhere; }
.pager-link small {
  display: block;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.15rem;
}
.pager-link svg { flex: 0 0 auto; color: var(--sand); }
.pager-next { justify-content: flex-end; text-align: right; }
.pager-link:hover { background: var(--sage-soft); border-color: var(--sage); color: var(--heading); }
.pager-link:hover svg { color: var(--heading); }

/* ---------- Footer ---------- */

.site-footer { margin-top: 3rem; }
.footer-art {
  height: clamp(110px, 14vw, 210px);
  display: grid;
  place-items: center;
  background: var(--bg) url("assets/img/footer-tausta.webp") center top / auto 100% no-repeat;
}
.footer-art img { display: block; width: clamp(90px, 11vw, 150px); height: auto; filter: drop-shadow(0 1px 6px rgba(15, 37, 58, 0.25)); }
.footer-body {
  color: var(--muted);
  text-align: center;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  line-height: 1.6;
  padding: 1.25rem var(--gutter) 2.5rem;
}
.footer-body p { margin: 0 0 0.35rem; }
.footer-body a { color: var(--heading); }
.footer-reba { margin-top: 1rem !important; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.72rem; }

/* ---------- Small screens ---------- */

@media (max-width: 560px) {
  body { font-size: 1.05rem; line-height: 1.65; }
  .topbar-inner { gap: 0.5rem; }
  .brand img { width: 38px; height: 38px; }
  .topbar-title span { display: none; }
  .topbar-title { padding: 0.55rem; }
  .qa { padding: 1.1rem 1rem 0.2rem; border-radius: 12px; }
  .qa-question { font-size: 1.1rem; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { order: -1; }
  .verse .chapter-body > p { font-size: 1.05rem; }
}

@media print {
  .topbar, .hero, .pager, .footer-art { display: none; }
  .page-chapter .sheet { margin-top: 0; }
  .note-crossReference { background: none; }
  .qa { break-inside: avoid; background: none; }
}
