/* ======================================================================
   The Lay Folks' History of the Liturgy — shared reading edition

   One stylesheet for the landing page and every linked chapter file.
   Its paper, type, size, leading, and reading measure match the Library's
   other long-form works; its vocabulary follows tools/HOUSE-STYLE.md.
   ====================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500;600;700&family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&family=IM+Fell+English:ital@0;1&display=swap');

:root,
[data-theme="day"] {
  --bg: #f7f2e8;
  --surface: #fdfaf2;
  --surface-2: #eee8db;
  --ink: #2a2118;
  --ink-2: #4a3f31;
  --ink-3: #6b5a3e;
  --accent: #7a5c12;
  --on-accent: #ffffff;
  --rule: #c9b88a;
  --rubric: #7a2020;
  --on-rubric: #ffffff;
  --shadow: 0 2px 12px rgba(74, 63, 49, 0.08);
  --focus-ring: #7a5c12;
  --font-display: 'Cinzel', Georgia, serif;
  --font-body: 'EB Garamond', Georgia, serif;
  --font-italic: 'IM Fell English', 'EB Garamond', Georgia, serif;
}

[data-theme="night"] {
  --bg: #1a1612;
  --surface: #221c16;
  --surface-2: #2a221a;
  --ink: #ede4d2;
  --ink-2: #c8bca5;
  --ink-3: #a99a80;
  --accent: #c9a14a;
  --on-accent: #1a1612;
  --rule: #6b5a3e;
  --rubric: #e8736e;
  --on-rubric: #1a1612;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.28);
  --focus-ring: #d4af5a;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  background-image: radial-gradient(ellipse at top, var(--surface-2) 0%, var(--bg) 62%);
  font-family: var(--font-body);
  font-size: 19px;
  line-height: 1.7;
  font-feature-settings: 'liga' 1, 'kern' 1, 'onum' 1;
  transition: background-color 0.25s ease, color 0.25s ease;
}

::selection {
  color: var(--on-accent);
  background: var(--accent);
}

a {
  color: var(--accent);
  text-decoration: none;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

a:hover {
  color: var(--accent);
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible {
  border-radius: 2px;
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link:focus {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 1000;
  width: auto;
  height: auto;
  margin: 0;
  padding: 0.6rem 1rem;
  overflow: visible;
  clip: auto;
  clip-path: none;
  color: #faf5eb;
  background: #2a1a08;
  font: 600 0.8rem var(--font-display);
  letter-spacing: 0.08em;
  text-decoration: none;
  border-radius: 3px;
  outline: 2px solid #faf5eb;
  outline-offset: -4px;
  box-shadow: 0 0 0 2px #2a1a08, 0 0 0 4px #faf5eb;
}

/* The persistent masthead is fixed dark in both reading themes. */
.site-header .theme-toggle {
  min-width: 44px;
  min-height: 44px;
  margin-left: auto;
  padding: 0.4rem 0.7rem;
  color: #e8dcc4;
  background: transparent;
  border: 1px solid rgba(232, 220, 196, 0.42);
  border-radius: 999px;
  font: 500 0.66rem var(--font-display);
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.site-header .theme-toggle:hover {
  color: #fff8e8;
  border-color: #fff8e8;
}

main {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}

/* Compact identity block on the chapter files. */
.book-header {
  margin: -0.25rem 0 2.5rem;
  padding: 0 0 1.75rem;
  text-align: center;
  border-bottom: 1px solid var(--rule);
}

.book-crumb {
  margin: 0 0 1.25rem;
  color: var(--ink-3);
  font: 500 0.7rem var(--font-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.book-crumb a {
  color: var(--ink-3);
}

.book-crumb a:hover,
.book-crumb a:focus-visible {
  color: var(--accent);
}

.book-crumb-sep {
  margin: 0 0.45rem;
  color: var(--ink-3);
}

.book-header h1,
main > h1 {
  margin: 0 0 0.45rem;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 4vw, 2.2rem);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.045em;
  text-align: center;
}

.book-header .work-title {
  color: var(--ink-2);
  font-family: var(--font-italic);
  font-size: 1rem;
  font-style: italic;
}

/* Landing page: a title page followed by two restrained contents panels. */
.book-index main {
  width: 100%;
  max-width: none;
  padding: 0 0 5rem;
}

.page-banner {
  padding: 4.5rem 1.5rem 3.5rem;
  text-align: center;
  border-bottom: 1px solid var(--rule);
}

.page-banner::before {
  display: block;
  margin-bottom: 0.6rem;
  color: var(--accent);
  font-size: 2rem;
  line-height: 1;
  content: '✝';
}

.page-banner-eyebrow {
  margin: 0 0 0.65rem;
  color: var(--ink-3);
  font: 500 0.72rem var(--font-display);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.page-banner h1 {
  max-width: 900px;
  margin: 0 auto;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 600;
  line-height: 1.16;
  letter-spacing: 0.045em;
}

.page-banner-rule {
  width: 4rem;
  height: 1px;
  margin: 1.35rem auto 1.1rem;
  background: var(--accent);
}

.page-banner-sub {
  margin: 0;
  color: var(--ink-2);
  font-family: var(--font-italic);
  font-size: 1.2rem;
  font-style: italic;
}

.site-main {
  width: min(100%, 900px);
  margin: 0 auto;
  padding: 2.25rem 1.5rem 0;
}

.section-heading {
  margin-top: 2.2rem;
  color: var(--accent);
  font: 500 0.72rem var(--font-display);
  letter-spacing: 0.18em;
  text-align: center;
  text-transform: uppercase;
}

.section-title {
  margin: 0.25rem 0 0;
  color: var(--ink);
  font: 600 clamp(1.45rem, 3vw, 2rem) var(--font-display);
  letter-spacing: 0.04em;
  text-align: center;
}

.section-rule {
  width: 3rem;
  height: 1px;
  margin: 1rem auto 1.4rem;
  background: var(--accent);
}

.book-intro,
.book-download {
  max-width: 42rem;
  margin: 0 auto 1.35rem;
  text-align: center;
}

.book-intro {
  color: var(--ink-2);
  font-family: var(--font-italic);
  font-style: italic;
}

.toc-volume {
  margin: 2rem 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: var(--shadow);
}

.toc-volume-heading {
  padding: 0.75rem 1.1rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--rule);
}

.toc-volume-label {
  color: var(--accent);
  font: 600 0.72rem var(--font-display);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.doc-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.doc-list li + li {
  border-top: 1px solid var(--rule);
}

.doc-list a {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.75rem;
  align-items: start;
  padding: 1rem 1.1rem;
  color: var(--ink-2);
  line-height: 1.48;
  transition: background-color 0.15s ease;
}

.doc-list a:hover,
.doc-list a:focus-visible {
  color: var(--ink);
  background: var(--surface-2);
  text-decoration: none;
}

.doc-list strong {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.doc-list-icon {
  color: var(--accent);
  text-align: center;
}

/* Local contents panels on the chapter files. */
.local-nav {
  margin: 0 0 3rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: var(--shadow);
}

.local-nav .nav-label {
  margin-bottom: 0.65rem;
  color: var(--accent);
  font: 600 0.72rem var(--font-display);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.local-nav ol {
  display: grid;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.local-nav a {
  display: block;
  padding: 0.12rem 0;
  color: var(--ink-2);
  font-family: var(--font-italic);
  font-style: italic;
}

.local-nav a:hover,
.local-nav a:focus-visible,
.local-nav a.active {
  color: var(--accent);
}

.local-nav .num {
  margin-right: 0.55em;
  color: var(--accent);
  font: 500 0.78rem var(--font-display);
  letter-spacing: 0.06em;
}

article.chapter,
.front-matter {
  margin-bottom: 4.5rem;
  scroll-margin-top: 7rem;
}

article.chapter + article.chapter,
.front-matter + .front-matter {
  padding-top: 3.5rem;
  border-top: 1px solid var(--rule);
}

.chapter-header,
.front-matter-header {
  margin: 0 0 2rem;
  text-align: center;
}

.chapter-number,
.chapter-num {
  display: block;
  margin: 0 0 0.45rem;
  color: var(--accent);
  font: 500 0.78rem var(--font-display);
  letter-spacing: 0.2em;
  text-align: center;
  text-transform: uppercase;
}

.chapter-title,
.front-matter-title {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 4vw, 2.1rem);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.045em;
  text-align: center;
}

.chapter-title::after,
.front-matter-title::after {
  display: block;
  width: 3rem;
  height: 1px;
  margin: 1rem auto 0;
  background: var(--accent);
  content: '';
}

.chapter-subtitle,
.chapter-contents,
.synopsis {
  max-width: 40rem;
  margin: 1.15rem auto 2rem;
  padding: 0 0.35rem;
  color: var(--ink-2);
  font-family: var(--font-italic);
  font-size: 0.96rem;
  font-style: italic;
  line-height: 1.55;
  text-align: center;
}

p {
  margin: 0 0 1.08em;
}

article.chapter > p,
.front-matter > p {
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}

article.chapter > p + p,
.front-matter > p + p {
  text-indent: 1.5em;
}

article.chapter > p.first,
article.chapter > .chapter-header + p,
.front-matter > p:first-of-type,
.front-matter > p.signoff,
p.no-drop {
  text-indent: 0;
}

article.chapter > p.first::first-letter,
article.chapter > .chapter-header + p::first-letter,
.front-matter > p:first-of-type::first-letter,
.drop-cap {
  float: left;
  margin: 0.08em 0.1em -0.05em 0;
  padding: 0;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 3.4em;
  font-weight: 600;
  line-height: 0.82;
}

article.chapter > p.no-drop:first-of-type::first-letter,
article.chapter > p.no-drop::first-letter {
  float: none;
  margin: 0;
  color: inherit;
  font: inherit;
}

em,
i,
cite,
.foreign,
.latin,
.greek {
  font-family: var(--font-italic);
  font-style: italic;
}

.subsection-heading,
article.chapter h3 {
  margin: 2.5rem 0 1rem;
  color: var(--rubric);
  font: 500 1rem var(--font-display);
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

blockquote,
.latin-block,
.latin-quote {
  margin: 1.4rem 1.5rem;
  padding: 0.45rem 1.1rem;
  color: var(--ink-2);
  border-left: 2px solid var(--accent);
  font-family: var(--font-italic);
  font-style: italic;
}

blockquote p,
.latin-block p,
.latin-quote p {
  margin: 0.35rem 0;
  text-align: left;
  text-indent: 0;
}

.ordo-block {
  margin: 1.5rem 0;
  padding: 1.15rem 1.4rem;
  color: var(--ink-2);
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 0 4px 4px 0;
  font-family: var(--font-italic);
  font-size: 0.95rem;
}

.ordo-title {
  display: block;
  margin-bottom: 0.55rem;
  color: var(--accent);
  font: 600 0.7rem var(--font-display);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.ordo-block ul,
.list-plain,
.catchword {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ordo-block li,
.list-plain li,
.catchword li,
.order-list li {
  margin-bottom: 0.4rem;
}

.ordo-block .indent-1 {
  padding-left: 1.5em;
}

.ordo-block .section-head,
.catchword .marker {
  color: var(--ink);
  font-weight: 600;
}

.bibliography-list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.98rem;
  line-height: 1.58;
  column-count: 2;
  column-gap: 2.5rem;
}

.bibliography-list li {
  break-inside: avoid;
  margin-bottom: 0.35em;
  padding-left: 1.5em;
  text-indent: -1.5em;
}

.bibliography-list li.section-gap {
  margin-top: 0.9em;
}

.bibliography-list ul {
  margin: 0.2em 0 0;
  padding-left: 1.5em;
  list-style: none;
}

.chronology-list {
  font-size: 0.98rem;
  line-height: 1.55;
}

.chronology-entry {
  display: grid;
  grid-template-columns: 6em 1fr;
  gap: 1em;
  align-items: baseline;
  margin-bottom: 0.25em;
}

.chronology-date {
  color: var(--ink-2);
  font-weight: 600;
  white-space: nowrap;
}

.chronology-sub {
  grid-column: 2;
  font-size: 0.95em;
}

.chronology-note {
  margin-top: 2rem;
  padding-top: 1rem;
  color: var(--ink-3);
  border-top: 1px solid var(--rule);
  font-family: var(--font-italic);
  font-size: 0.88rem;
  font-style: italic;
}

.primer-table {
  width: 100%;
  margin: 1.5rem 0;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.primer-table th,
.primer-table td {
  padding: 0.6rem 0.7rem;
  text-align: left;
  vertical-align: top;
  border: 1px solid var(--rule);
}

.primer-table th {
  color: var(--accent);
  background: var(--surface-2);
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.figure-block {
  max-width: 300px;
  margin: 1.5rem auto;
  text-align: center;
}

.fraction-grid {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 0.5rem;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--rule);
  font-family: var(--font-italic);
  font-size: 0.78rem;
}

.fraction-grid span {
  padding: 0.15rem 0.3rem;
}

.fn-ref,
.fn-mark {
  padding: 0 0.1em;
  color: var(--rubric);
  font-size: 0.72em;
  font-weight: 600;
  line-height: 0;
  vertical-align: super;
}

.footnote,
.footnotes {
  margin-top: 2.5rem;
  padding-top: 1rem;
  color: var(--ink-2);
  border-top: 1px solid var(--rule);
  font-size: 0.88rem;
  line-height: 1.55;
}

.footnotes ol {
  margin: 0;
  padding-left: 1.4rem;
}

.footnotes li {
  margin-bottom: 0.5rem;
}

.fn-back {
  margin-left: 0.4em;
  color: var(--accent);
}

.front-matter .signoff {
  margin-top: 2rem;
  text-align: right;
  text-indent: 0;
}

.back-top {
  display: block;
  width: max-content;
  margin: 1.5rem auto 0;
  color: var(--accent);
  font: 500 0.72rem var(--font-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.part-nav,
.ch-jump {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  margin: 3rem 0 1rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font: 500 0.78rem var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.part-nav a,
.ch-jump a {
  padding: 0.45rem 0.7rem;
  color: var(--ink-2);
  border: 1px solid var(--rule);
  border-radius: 3px;
}

.part-nav a:hover,
.ch-jump a:hover {
  color: var(--accent);
  background: var(--surface);
  border-color: var(--accent);
  text-decoration: none;
}

.site-footer,
.independence-notice {
  color: var(--ink-3);
  border-top: 1px solid var(--rule);
  font-size: 0.78rem;
  line-height: 1.6;
  text-align: center;
}

.site-footer {
  margin-top: 3rem;
  padding: 2rem 1.5rem 3rem;
  background: var(--surface-2);
}

.site-footer p,
.independence-notice {
  margin: 0 auto;
  max-width: 44rem;
  text-align: center;
  text-indent: 0;
}

.independence-notice {
  margin-top: 2.5rem;
  padding-top: 1rem;
}

@media (max-width: 768px) {
  .site-header .theme-toggle {
    margin-left: auto;
  }

  .site-main,
  main {
    padding-right: 1.1rem;
    padding-left: 1.1rem;
  }

  .page-banner {
    padding: 3.25rem 1.1rem 2.75rem;
  }

  .bibliography-list {
    column-count: 1;
  }
}

@media (max-width: 540px) {
  body {
    font-size: 17.5px;
  }

  .doc-list a {
    grid-template-columns: 1.5rem 1fr;
    padding: 0.9rem;
  }

  .local-nav,
  .toc-volume {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .chronology-entry {
    grid-template-columns: 4.7em 1fr;
    gap: 0.65em;
    font-size: 0.92rem;
  }

  blockquote,
  .latin-block,
  .latin-quote {
    margin-right: 0.35rem;
    margin-left: 0.35rem;
  }

  .primer-table {
    display: block;
    overflow-x: auto;
  }
}

@media print {
  :root,
  [data-theme] {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #ffffff;
    --ink: #000000;
    --ink-2: #222222;
    --ink-3: #555555;
    --rule: #999999;
  }

  body {
    color: #000;
    background: #fff;
    background-image: none;
    font-size: 11pt;
    line-height: 1.45;
  }

  a,
  .chapter-number,
  .chapter-num,
  .chapter-title,
  .front-matter-title,
  .subsection-heading,
  article.chapter h3 {
    color: #000;
  }

  .site-header,
  .theme-toggle,
  .skip-link,
  .local-nav,
  .back-top,
  .part-nav,
  .ch-jump,
  .site-footer,
  .independence-notice {
    display: none !important;
  }

  main,
  .site-main {
    width: 100%;
    max-width: none;
    padding: 0;
  }

  article.chapter {
    break-before: page;
  }

  article.chapter:first-of-type {
    break-before: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
