:root {
  --paper: #eee9dc;
  --paper-light: #f8f4e9;
  --ink: #292c2c;
  --muted: #6b6d67;
  --rule: #aaa594;
  --red: #6f2928;
  --blue: #283f4c;
  --gold: #8d7446;
  --sans: "Segoe UI", Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  --mono: Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, transparent 0 4px, rgba(44, 39, 30, .015) 5px),
    var(--paper);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.76;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 100px rgba(56, 43, 23, .12);
  z-index: 20;
}

a { color: inherit; text-decoration-color: var(--gold); text-underline-offset: .25em; }
button, input { font: inherit; }
button { cursor: pointer; }

.reading-progress {
  position: fixed;
  inset: 0 0 auto;
  height: 3px;
  background: rgba(41, 44, 44, .12);
  z-index: 100;
}
.reading-progress span { display: block; width: 0; height: 100%; background: var(--red); }

.masthead {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.1rem clamp(1.25rem, 5vw, 5rem);
  border-bottom: 1px solid var(--rule);
  background: rgba(238, 233, 220, .94);
}
.institution { display: flex; align-items: center; gap: 1rem; }
.seal {
  width: 46px; height: 46px; border: 1px solid var(--red); border-radius: 50%;
  display: grid; place-items: center; color: var(--red); position: relative;
}
.seal::before { content: ""; position: absolute; inset: 4px; border: 1px dotted currentColor; border-radius: inherit; }
.seal span { font: 700 .8rem var(--mono); letter-spacing: .1em; }
.eyebrow, .folio, .procedure, .index, footer { font-family: var(--sans); }
.eyebrow, .folio { margin: 0; color: var(--red); font-size: .68rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.institution-name { margin: .08rem 0 0; font-size: .92rem; line-height: 1.35; }
.procedure { align-self: center; border-left: 1px solid var(--rule); padding-left: 1.3rem; line-height: 1.3; }
.procedure-label { display: block; color: var(--muted); font-size: .66rem; text-transform: uppercase; letter-spacing: .13em; }
.procedure strong { color: var(--blue); font-size: .86rem; font-weight: 600; }

.index {
  position: fixed;
  top: 9rem;
  left: max(1rem, calc(50% - 39rem));
  width: 13.5rem;
  font-size: .72rem;
  line-height: 1.35;
  z-index: 5;
}
.index ol { margin: 1rem 0; padding-left: 1.7rem; color: var(--muted); }
.index li { margin: .52rem 0; }
.index a { text-decoration: none; }
.index a:hover, .index a:focus-visible { color: var(--red); text-decoration: underline; }
.ceremonial-toggle {
  width: 100%; padding: .65rem .8rem; color: var(--blue); background: transparent;
  border: 1px solid var(--rule); font: 700 .64rem var(--sans); letter-spacing: .1em; text-transform: uppercase;
}
.ceremonial-toggle:hover, .ceremonial-toggle:focus-visible { background: var(--paper-light); }

main { width: min(46rem, calc(100% - 2rem)); margin: 5rem auto 8rem; }
.manual { background: rgba(248, 244, 233, .74); border: 1px solid rgba(141, 116, 70, .42); box-shadow: 0 1.7rem 4rem rgba(52, 42, 24, .12); }
.manual > header, .manual > section { position: relative; padding: clamp(3rem, 7vw, 6rem) clamp(1.5rem, 7vw, 5.5rem); border-bottom: 1px solid var(--rule); }
.title-page { min-height: 85vh; }
.folio { padding-bottom: 3rem; }
h1, h2 { font-weight: 400; line-height: 1.08; letter-spacing: -.025em; }
h1 { margin: 1rem 0; font-size: clamp(2.8rem, 8vw, 5.8rem); text-transform: uppercase; }
h1 span { display: block; margin-top: 1rem; color: var(--red); font: 700 clamp(.7rem, 2vw, .95rem) var(--sans); letter-spacing: .3em; }
.subtitle { max-width: 26rem; margin: 2rem 0 4rem; color: var(--blue); font-size: 1.35rem; font-style: italic; }
.opening-mark { width: 5rem; height: 1px; margin: 2rem 0 3rem; background: var(--red); }
h2 { margin: .25rem 0 3.2rem; font-size: clamp(2.1rem, 5vw, 3.5rem); }
.section-number { position: absolute; top: 3.3rem; right: clamp(1.5rem, 5vw, 3.5rem); margin: 0; color: var(--gold); font: 400 2.5rem var(--serif); opacity: .65; }
.lead { margin-top: 0; color: var(--blue); font-size: 1.32rem; line-height: 1.45; }
.directive { margin: 2.7rem 0; padding: 1.4rem 1.7rem; border: solid var(--red); border-width: 1px 0; color: var(--red); text-align: center; font-size: 1.1rem; }
.paired { margin-top: 2.7rem; color: var(--blue); font-size: 1.12rem; }
.paired span { display: block; color: var(--muted); font-size: .85rem; font-style: italic; }
aside { margin: 3rem 0 0; padding: 1.5rem; border: 1px solid var(--rule); color: var(--blue); }
aside small { color: var(--muted); }
blockquote { margin: 2.8rem 0; padding: 1.5rem 0 1.5rem 2rem; border-left: 3px double var(--gold); color: var(--blue); font-size: 1.14rem; }
.protocol-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 2.7rem 0; background: var(--rule); border: 1px solid var(--rule); }
.protocol-grid p { margin: 0; padding: 1.4rem; background: var(--paper-light); }
.protocol-grid b, .protocol-grid span { display: block; }
.protocol-grid b { color: var(--red); font: 700 .7rem var(--sans); letter-spacing: .08em; text-transform: uppercase; }

.preference-form { margin: 2.5rem 0; padding: 1.5rem; border: 1px solid var(--rule); background: rgba(238, 233, 220, .55); }
.preference-form fieldset { display: flex; gap: 2rem; margin: 0 0 1rem; padding: 1rem; border: 1px solid var(--rule); }
.preference-form legend { padding: 0 .5rem; font: 700 .68rem var(--sans); letter-spacing: .1em; text-transform: uppercase; }
.preference-form p { margin-bottom: 0; color: var(--muted); font-size: .84rem; line-height: 1.55; }
.preference-form input { accent-color: var(--red); }

.door-panel { margin: 3.5rem auto; text-align: center; }
.door { position: relative; width: 8rem; height: 12rem; margin: 0 auto 1rem; border: 5px double var(--gold); background: linear-gradient(90deg, rgba(40,63,76,.09), transparent); }
.door::before { content: ""; position: absolute; inset: .65rem; border: 1px solid var(--rule); }
.door span { position: absolute; right: 1.2rem; top: 52%; width: .48rem; height: .48rem; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 3px rgba(111,41,40,.15); }
.door-panel button, .confirmation button { padding: .8rem 1.4rem; border: 1px solid var(--red); color: var(--red); background: transparent; font: 700 .7rem var(--sans); letter-spacing: .13em; text-transform: uppercase; }
.door-panel button:hover, .door-panel button:focus-visible, .confirmation button:hover, .confirmation button:focus-visible { color: var(--paper-light); background: var(--red); }
.door-panel p { min-height: 2.5rem; color: var(--muted); font-size: .78rem; }

.declaration { text-align: center; }
.declaration > p:not(.section-number) { max-width: 33rem; margin-left: auto; margin-right: auto; }
.final-sequence { margin: 4rem -1rem -1rem; padding: 2.5rem 1rem; border: 1px solid var(--red); color: var(--red); }
.final-sequence p { margin: .35rem; }
.confirmation { text-align: center; background: rgba(141, 116, 70, .07); }
.confirmation h2 { margin-bottom: 1.5rem; }
.confirmation button { margin-top: 1.5rem; padding: 1rem 1.7rem; }
.confirmation-message { min-height: 2rem; color: var(--muted); font: .8rem var(--sans); }
.confirmation.recorded { box-shadow: inset 0 0 0 4px rgba(111,41,40,.13); }

footer { display: flex; justify-content: center; gap: 2rem; flex-wrap: wrap; padding: 2rem; color: var(--muted); border-top: 1px solid var(--rule); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; }
.doctrinal-link { opacity: .48; text-decoration-color: transparent; }
.doctrinal-link:hover, .doctrinal-link:focus-visible { opacity: .82; text-decoration-color: var(--gold); }

.residue-note {
  display: block;
  margin-top: .75rem;
  font: .68rem var(--mono);
  letter-spacing: .04em;
  opacity: .16;
}
.residue-note::selection { color: var(--paper-light); background: var(--red); }
.term-shift { position: relative; cursor: default; }
.term-shift:hover::after {
  content: " / " attr(data-shift);
  opacity: .45;
  font-size: .82em;
  font-style: italic;
}
.minor-link { opacity: .28; text-decoration: none; }
.minor-link:hover, .minor-link:focus-visible { opacity: .85; text-decoration: underline; }

.appendix-page { min-height: 100vh; }
.appendix {
  width: min(42rem, calc(100% - 1rem));
  margin: clamp(1rem, 7vw, 5rem) auto;
  padding: clamp(2rem, 7vw, 5rem);
  border: 1px solid rgba(141, 116, 70, .42);
  background: rgba(248, 244, 233, .74);
  box-shadow: 0 1.7rem 4rem rgba(52, 42, 24, .12);
}
.appendix h1 { margin-bottom: 3rem; font-size: clamp(2.1rem, 7vw, 4rem); }
.appendix dl { margin: 0; }
.appendix dt { margin-top: 1.6rem; color: var(--red); font: 700 .72rem var(--sans); letter-spacing: .12em; text-transform: uppercase; }
.appendix dd { margin: .35rem 0 0; }
.appendix-return { display: inline-block; margin-top: 3.5rem; font: .7rem var(--sans); letter-spacing: .08em; text-transform: uppercase; }

body.ceremonial .index, body.ceremonial .masthead .institution, body.ceremonial footer { opacity: 0; pointer-events: none; }
body.ceremonial main { margin-top: 2rem; }
body.ceremonial .masthead { justify-content: flex-end; border-color: transparent; background: transparent; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; }
@media (max-width: 1100px) { .index { display: none; } }
@media (max-width: 650px) {
  body { font-size: 16px; line-height: 1.7; }
  .masthead { align-items: flex-start; padding-top: 1.4rem; }
  .institution-name { display: none; }
  .seal { width: 38px; height: 38px; }
  .procedure { max-width: 10rem; }
  main { width: calc(100% - 1rem); margin-top: 2.5rem; }
  .manual > header, .manual > section { padding: 3.5rem 1.35rem; }
  .protocol-grid { grid-template-columns: 1fr; }
  .preference-form fieldset { flex-direction: column; gap: .6rem; }
  .section-number { top: 1rem; right: 1.25rem; font-size: 1.7rem; }
  h1 { font-size: clamp(2.35rem, 11.5vw, 3.1rem); }
  footer { flex-direction: column; align-items: center; gap: .4rem; text-align: center; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
@media print {
  .reading-progress, .index, .procedure, .door-panel button, .confirmation button { display: none; }
  body { background: white; font-size: 11pt; }
  body::before { display: none; }
  .masthead { background: white; }
  main { width: 100%; margin: 0; }
  .manual { border: 0; box-shadow: none; }
  .manual > header, .manual > section { break-inside: avoid; }
}
