/* Treasures of the Catholic Faith — site styles.
   Layout: a printed library. A burgundy band carries the masthead, framed like a pamphlet cover;
   pages below are cream paper, set like the contents pages of a book; pamphlets lie on a reading table.
   One deliberate light "paper" look, matching the printed series. */

@import url("fonts.css");

:root {
  --paper: #F5EEDC;
  --paper-deep: #EFE3C8;
  --table: #E4D9C2;
  --table-edge: #D3C6AC;
  --ink: #2A1F1A;
  --ink-soft: #5E4E40;
  --burgundy: #6E1A24;
  --burgundy-deep: #4A1018;
  --gold: #B8913F;
  --gold-soft: #D9B96A;
  --gold-ink: #7A5C22;
  --rule: #D8C49A;
  --on-burgundy: #F5EEDC;
  --on-burgundy-soft: #EBDDBA;
  --shadow: rgba(58, 30, 18, 0.30);
  --draft: #8C2F1F;

  --f-mast: 'Cinzel', 'Trajan Pro', 'Times New Roman', serif;
  --f-head: 'Cormorant Garamond', 'Garamond', Georgia, serif;
  --f-body: 'EB Garamond', 'Garamond', Georgia, serif;

  --measure: 64ch;
  --wide: 1120px;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 1.1875rem;
  line-height: 1.55;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
}
@media (max-width: 600px) { body { font-size: 1.125rem; } }

img { max-width: 100%; height: auto; }
a { color: var(--burgundy); text-decoration-thickness: 1px; text-underline-offset: 0.16em; }
a:hover { color: var(--burgundy-deep); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.wrap {
  width: 100%;
  max-width: calc(var(--wide) + 64px);
  margin-inline: auto;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
}
@media (min-width: 700px) { .wrap { padding-left: max(32px, env(safe-area-inset-left, 0px)); padding-right: max(32px, env(safe-area-inset-right, 0px)); } }

.skip { position: absolute; left: -9999px; top: 0; }
.skip:focus { left: 16px; top: 16px; z-index: 20; background: var(--paper); padding: 8px 12px; }

/* ---------- Header band ---------- */
.band { background: var(--burgundy); color: var(--on-burgundy); }
.site-header .wrap {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 24px; padding-block: 14px;
}
.brand {
  display: inline-flex; align-items: center; gap: 12px;
  color: var(--gold-soft); text-decoration: none;
  font-family: var(--f-mast); font-weight: 600; font-size: 0.8125rem; letter-spacing: 0.2em; line-height: 1.3;
}
.brand:hover { color: var(--on-burgundy); }
.brand svg { flex: none; }
.nav { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 0; padding: 0; list-style: none; }
.nav a {
  color: var(--on-burgundy-soft); text-decoration: none;
  font-family: var(--f-head); font-weight: 600; font-size: 1.1875rem;
  padding-block: 6px; border-bottom: 1px solid transparent;
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--on-burgundy); border-bottom-color: var(--gold-soft); }

.preview-bar {
  background: var(--draft); color: #FFF4EC;
  font-size: 0.9375rem; line-height: 1.4;
}
.preview-bar .wrap { padding-block: 8px; }

/* ---------- Home hero: the masthead framed like a cover ---------- */
.hero .wrap { padding-block: 8px 44px; }
.cover-frame {
  border: 1px solid var(--gold);
  outline: 1px solid var(--gold); outline-offset: -7px;
  padding: clamp(36px, 7vw, 72px) clamp(20px, 5vw, 64px);
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 18px;
}
.hero h1 {
  margin: 0;
  font-family: var(--f-mast); font-weight: 600;
  font-size: clamp(1.6rem, 5.2vw, 3.5rem); line-height: 1.25; letter-spacing: 0.14em;
  color: var(--gold-soft); text-wrap: balance;
}
.hero h1 span { display: block; }
.hero .lede {
  margin: 0; max-width: 40ch;
  font-family: var(--f-head); font-style: italic; font-weight: 500;
  font-size: clamp(1.25rem, 2.6vw, 1.625rem); line-height: 1.3; color: var(--on-burgundy-soft); text-wrap: balance;
}
.divider { display: flex; align-items: center; gap: 12px; color: var(--gold-soft); }
.divider::before, .divider::after { content: ""; width: 64px; height: 1px; background: var(--gold); }
.hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 20px; margin-top: 6px; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 44px; padding: 8px 20px;
  font-family: var(--f-head); font-weight: 600; font-size: 1.1875rem; line-height: 1.2;
  text-decoration: none; border-radius: 2px; cursor: pointer;
  border: 1px solid var(--burgundy); background: var(--burgundy); color: var(--on-burgundy);
}
.button:hover { background: var(--burgundy-deep); color: var(--on-burgundy); }
.button.on-band { background: transparent; border-color: var(--gold-soft); color: var(--on-burgundy); }
.button.on-band:hover { background: var(--burgundy-deep); }
.button.quiet { background: transparent; color: var(--burgundy); }
.button.quiet:hover { background: var(--paper-deep); }
.button[aria-disabled="true"] { opacity: 0.55; pointer-events: none; }
.text-link { color: var(--on-burgundy-soft); font-size: 1.0625rem; }
.text-link:hover { color: var(--on-burgundy); }

/* ---------- Generic page furniture ---------- */
main { display: block; }
.page { padding-block: 40px 72px; display: flex; flex-direction: column; gap: 56px; }
.page-head { display: flex; flex-direction: column; gap: 12px; max-width: var(--measure); }
h1.title, h2.title {
  margin: 0; font-family: var(--f-head); font-weight: 600; color: var(--burgundy);
  line-height: 1.05; text-wrap: balance;
}
h1.title { font-size: clamp(2.25rem, 5vw, 3.5rem); }
h2.title { font-size: clamp(1.875rem, 3.6vw, 2.5rem); }
.title .sub { display: block; font-style: italic; font-weight: 500; font-size: 0.66em; margin-top: 6px; color: var(--burgundy); }
.lead { margin: 0; font-size: 1.25rem; color: var(--ink-soft); max-width: var(--measure); text-wrap: pretty; }
.prose { max-width: var(--measure); display: flex; flex-direction: column; gap: 14px; }
.prose p, .prose ul, .prose ol { margin: 0; text-wrap: pretty; }
.prose h2 { margin: 18px 0 0; font-family: var(--f-head); font-weight: 600; font-size: 1.875rem; line-height: 1.1; color: var(--burgundy); text-wrap: balance; }
.prose h3 { margin: 8px 0 0; font-family: var(--f-head); font-weight: 600; font-size: 1.4375rem; line-height: 1.15; color: var(--burgundy); }
.prose li + li { margin-top: 6px; }
.gold-rule { width: 64px; height: 2px; background: var(--gold); border: 0; margin: 0; }
.crumbs { margin: 0; font-size: 1rem; color: var(--ink-soft); }
.crumbs a { color: var(--ink-soft); }
.no {
  font-family: var(--f-mast); font-weight: 600; letter-spacing: 0.12em; color: var(--gold-ink);
  font-variant-numeric: lining-nums tabular-nums;
}

/* ---------- Cover shelf ---------- */
.shelf-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px; }
.shelf-head p { margin: 0; color: var(--ink-soft); max-width: 46ch; }
.shelf {
  list-style: none; margin: 28px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 32px 22px;
  padding-bottom: 18px; border-bottom: 6px solid var(--table-edge);
}
@media (min-width: 900px) { .shelf { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
.shelf li { min-width: 0; }
.book { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: var(--ink); }
.book .cover-img {
  position: relative; display: block; aspect-ratio: 374 / 794;
  box-shadow: 0 14px 26px -12px var(--shadow), 0 2px 4px rgba(58, 30, 18, 0.18);
  transition: transform 200ms ease, box-shadow 200ms ease;
  background: var(--burgundy);
}
.book .cover-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.book:hover .cover-img { transform: translateY(-4px); box-shadow: 0 20px 30px -12px var(--shadow), 0 2px 4px rgba(58, 30, 18, 0.18); }
.book .no { font-size: 0.75rem; }
.book .name { font-family: var(--f-head); font-weight: 600; font-size: 1.1875rem; line-height: 1.12; color: var(--burgundy); text-wrap: balance; }
.book.pending .cover-img {
  display: grid; place-items: center; text-align: center; padding: 14px;
  background: var(--paper-deep); box-shadow: none; border: 1px dashed var(--gold);
  font-family: var(--f-head); font-style: italic; font-size: 1rem; color: var(--ink-soft);
}
.badge-draft {
  position: absolute; top: 8px; right: -6px; z-index: 1;
  background: var(--draft); color: #FFF4EC;
  font-family: var(--f-body); font-size: 0.75rem; line-height: 1; padding: 5px 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}
@media (prefers-reduced-motion: reduce) { .book .cover-img { transition: none; } .book:hover .cover-img { transform: none; } }

/* ---------- Section index (home) ---------- */
.sections {
  list-style: none; margin: 24px 0 0; padding: 0; max-width: 820px;
  border-top: 1px solid var(--rule);
}
.sections li { border-bottom: 1px solid var(--rule); min-width: 0; }
.sections a {
  display: grid; grid-template-columns: 3.2rem minmax(0, 1fr) auto; gap: 4px 16px; align-items: baseline;
  padding: 14px 0; text-decoration: none; color: var(--ink);
}
@media (max-width: 560px) { .sections a { grid-template-columns: 3.2rem minmax(0, 1fr); } .sec-count { grid-column: 2; } }
.sections a:hover .sec-name { text-decoration: underline; }
.sec-numeral { font-family: var(--f-head); font-weight: 600; font-size: 1.75rem; line-height: 1; color: var(--gold); text-align: right; }
.sec-name { font-family: var(--f-head); font-weight: 600; font-size: 1.3125rem; line-height: 1.15; color: var(--burgundy); }
.sec-count { font-size: 0.9375rem; font-style: italic; color: var(--ink-soft); text-align: right; }
@media (max-width: 560px) { .sec-count { text-align: left; } }

.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 24px 56px; }
.two-col > * { min-width: 0; }
.two-col h3 { margin: 0 0 6px; font-family: var(--f-head); font-weight: 600; font-size: 1.4375rem; line-height: 1.15; color: var(--burgundy); }
.two-col p { margin: 0; text-wrap: pretty; }

/* ---------- Contents (The Faith) ---------- */
.jump { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.jump a {
  display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; padding: 0 10px;
  font-family: var(--f-head); font-weight: 600; font-size: 1.1875rem; text-decoration: none;
  border: 1px solid var(--rule); color: var(--burgundy); background: var(--paper);
}
.jump a:hover { border-color: var(--gold); background: var(--paper-deep); }
.contents-section { display: flex; flex-direction: column; gap: 6px; scroll-margin-top: 16px; }
.contents-section header { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 14px; padding-bottom: 10px; border-bottom: 2px solid var(--gold); }
.contents-section .numeral { font-family: var(--f-head); font-weight: 600; font-size: 2.75rem; line-height: 1; color: var(--gold); }
.contents-section h2 { margin: 0; font-family: var(--f-head); font-weight: 600; font-size: clamp(1.625rem, 3vw, 2.125rem); line-height: 1.1; color: var(--burgundy); text-wrap: balance; }
.toc { list-style: none; margin: 0; padding: 0; }
.toc li { border-bottom: 1px solid var(--rule); }
.toc .row {
  display: grid; grid-template-columns: 3.4rem minmax(0, 1fr) auto; gap: 4px 18px; align-items: start;
  padding-block: 14px; color: var(--ink); text-decoration: none;
}
.toc .row .no { font-size: 0.875rem; text-align: right; padding-top: 0.45em; }
.toc .t { font-family: var(--f-head); font-weight: 600; font-size: 1.375rem; line-height: 1.15; color: var(--ink-soft); text-wrap: balance; }
.toc .b { display: block; margin-top: 3px; font-size: 1rem; line-height: 1.4; color: var(--ink-soft); text-wrap: pretty; }
.toc .state { padding-top: 0.3em; font-size: 0.9375rem; font-style: italic; color: var(--ink-soft); white-space: nowrap; }
.toc .ft { display: inline-block; margin-left: 8px; font-family: var(--f-body); font-style: italic; font-weight: 400; font-size: 0.875rem; color: var(--gold-ink); vertical-align: 0.15em; }
.toc a.row .t { color: var(--burgundy); }
.toc a.row:hover .t { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.14em; }
.toc .thumb { position: relative; width: 44px; aspect-ratio: 374 / 794; box-shadow: 0 6px 12px -6px var(--shadow); }
.toc .thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.toc .thumb .badge-draft { top: 4px; right: -10px; font-size: 0.625rem; padding: 3px 5px; }
@media (max-width: 520px) {
  .toc .row { grid-template-columns: 2.6rem minmax(0, 1fr) auto; gap: 4px 12px; }
  .toc .state { white-space: normal; text-align: right; max-width: 6.5em; }
  .toc .b { display: none; }
}

/* ---------- Pamphlet page ---------- */
.pamphlet-head { padding-block: 22px 18px; display: flex; flex-direction: column; gap: 8px; }
.pamphlet-head h1.title { font-size: clamp(2.125rem, 4.2vw, 3rem); }
.pamphlet-head .no { margin: 4px 0 -2px; font-size: 0.875rem; }
.pamphlet-head .tagline { margin: 0; max-width: var(--measure); color: var(--ink-soft); font-size: 1.1875rem; text-wrap: pretty; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; margin-top: 6px; }
.switch { display: inline-flex; border: 1px solid var(--burgundy); border-radius: 2px; }
.switch button {
  min-height: 44px; padding: 0 16px; border: 0; background: transparent; cursor: pointer;
  font-family: var(--f-head); font-weight: 600; font-size: 1.125rem; color: var(--burgundy);
}
.switch button + button { border-left: 1px solid var(--burgundy); }
.switch button[aria-pressed="true"] { background: var(--burgundy); color: var(--on-burgundy); }

.table {
  background: radial-gradient(ellipse at 50% 42%, var(--table) 55%, var(--table-edge) 100%);
  background-color: var(--table);
  border-block: 1px solid var(--table-edge);
  overflow-x: clip;
}

/* Fold-out viewer */
.viewer .wrap { padding-block: 18px 16px; display: flex; flex-direction: column; gap: 12px; }
.stage {
  position: relative; height: clamp(420px, calc(100svh - 130px), 900px);
  perspective: 2600px; perspective-origin: 50% 40%;
  cursor: pointer; outline: none; touch-action: pan-y;
}
.stage:focus-visible { box-shadow: inset 0 0 0 2px var(--gold); }
.scaler { position: absolute; left: 50%; top: 50%; width: 1123px; height: 794px; transform-style: preserve-3d; transition: transform 800ms cubic-bezier(.45,.05,.25,1); }
.sheet { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 1000ms cubic-bezier(.45,.05,.25,1); }
.leaf { position: absolute; top: 0; width: 374.333px; height: 794px; transform-style: preserve-3d; transition: transform 900ms cubic-bezier(.45,.05,.25,1); }
.leaf.left { left: 0; transform-origin: right center; }
.leaf.center { left: 374.333px; }
.leaf.right { left: 748.667px; transform-origin: left center; }
.face {
  position: absolute; inset: 0; overflow: hidden; background: #F5EEDC;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 18px 40px -12px var(--shadow), 0 2px 6px rgba(40, 24, 16, 0.18);
}
.face.back { transform: rotateY(180deg); }
.face::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: rgba(30, 18, 12, 0); transition: background 900ms ease; }
.leaf.folding .face::after { background: rgba(30, 18, 12, 0.05); }
.controls { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.steps { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 0; padding: 0; list-style: none; }
.steps button {
  min-height: 44px; padding: 0 16px; border-radius: 22px; cursor: pointer;
  font-family: var(--f-head); font-weight: 600; font-size: 1.0625rem;
  border: 1px solid var(--rule); background: var(--paper); color: var(--ink);
}
.steps button[aria-current="step"] { background: var(--burgundy); border-color: var(--burgundy); color: var(--on-burgundy); }
.step-nav { display: flex; align-items: center; gap: 12px; }
.step-nav button {
  width: 44px; height: 44px; flex: none; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--rule); background: var(--paper); color: var(--ink);
  display: grid; place-items: center;
}
.step-nav button:disabled { opacity: 0.4; cursor: default; }
.caption { margin: 0; font-size: 1rem; font-style: italic; color: var(--ink-soft); text-align: center; min-height: 2.8em; max-width: 46ch; display: grid; place-items: center; }
@media (prefers-reduced-motion: reduce) { .scaler, .sheet, .leaf, .face::after { transition-duration: 1ms; } }

/* Panel-by-panel reader */
.reader .wrap { padding-block: 24px 32px; }
.reader ol { list-style: none; margin: 0 auto; padding: 0; max-width: 580px; display: flex; flex-direction: column; gap: 22px; }
.reader li { display: flex; flex-direction: column; gap: 8px; }
.reader .label { margin: 0; font-size: 0.9375rem; font-style: italic; color: var(--ink-soft); }
.reader .panel-box { position: relative; width: 100%; aspect-ratio: 374.333 / 794; overflow: hidden; box-shadow: 0 14px 30px -14px var(--shadow); }
.reader .panel-scale { position: absolute; left: 0; top: 0; width: 374.333px; height: 794px; transform-origin: 0 0; background: #F5EEDC; }

/* Details under the pamphlet */
.details { padding-block: 40px 64px; display: flex; flex-direction: column; gap: 44px; }
.facts { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 22px; }
.facts dt { font-style: italic; color: var(--ink-soft); }
.facts dd { margin: 0; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; border-top: 1px solid var(--rule); padding-top: 18px; }
.pager a { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--ink); min-width: 0; }
.pager a .t { font-family: var(--f-head); font-weight: 600; font-size: 1.25rem; line-height: 1.15; color: var(--burgundy); }
.pager a:hover .t { text-decoration: underline; }
.pager .next { text-align: right; grid-column: 2; }
.pager .dir { font-size: 0.9375rem; color: var(--ink-soft); }

/* ---------- About ---------- */
.credits { width: 100%; border-collapse: collapse; font-size: 1rem; }
.credits-wrap { overflow-x: auto; max-width: 100%; }
.credits th, .credits td { text-align: left; vertical-align: top; padding: 9px 14px 9px 0; border-bottom: 1px solid var(--rule); }
.credits th { font-weight: 600; color: var(--ink-soft); font-style: italic; font-weight: 400; }
.credits td:first-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.fold-steps { padding-left: 1.4em; }

/* ---------- Footer ---------- */
.site-footer { background: var(--burgundy-deep); color: var(--on-burgundy-soft); font-size: 1rem; }
.site-footer .wrap { padding-block: 32px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 32px; }
.site-footer p { margin: 0; max-width: 60ch; }
.site-footer a { color: var(--on-burgundy); }
.site-footer .brand { font-size: 0.75rem; }
