/* Basic Biblical Truths
   Set like one of Bill's printed workbooks: black text on warm paper, with one rubric red (the red
   that Bibles and church books use for headings and numbers) for links, numbers and labels. One
   typeface, Source Serif 4, for everything: its optical sizes for titles, true small caps for labels,
   oldstyle figures in the text and lining tabular figures in file details. Centred title pages and a
   numbered contents list, like a book. No cards, no icons, no blue. */

/* Fonts: Source Serif 4, cut down for readers on slow phone connections: weights 400 to 700, the
   optical size fixed at text size, small caps and figures kept, Latin and Cyrillic in separate files.
   Every page shows a few Russian words, so it loads the small Cyrillic file too: about 130 KB of fonts
   for a page in all (it was 430 KB). See the project README, Look. */
@font-face { font-family: "Source Serif 4"; src: url("/fonts/SourceSerif4-Latin.woff2") format("woff2");
  font-weight: 400 700; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2190-2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Source Serif 4"; src: url("/fonts/SourceSerif4-Cyrillic.woff2") format("woff2");
  font-weight: 400 700; font-style: normal; font-display: swap;
  unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Source Serif 4"; src: url("/fonts/SourceSerif4-Italic-Latin.woff2") format("woff2");
  font-weight: 400 700; font-style: italic; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2190-2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Source Serif 4"; src: url("/fonts/SourceSerif4-Italic-Cyrillic.woff2") format("woff2");
  font-weight: 400 700; font-style: italic; font-display: swap;
  unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }

/* Colors. Every text pair meets WCAG AA; the figures are contrast on the page color. */
:root {
  --paper: #F6F1E7;        /* warm, unbleached paper */
  --ink: #231F1A;          /* text, 14.6:1 */
  --muted: #5E5549;        /* secondary text, 6.5:1 */
  --rule: #D8CDB9;         /* hairlines */
  --red: #9B2C1F;          /* rubric red: links, numbers, labels, 6.7:1 */
  --red-strong: #7A2016;   /* hover, 9.1:1 */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1B1815; --ink: #EDE6DA; --muted: #B6AC9C; --rule: #3D362E;
    --red: #E07A64; --red-strong: #EE9C88;   /* lamp-lit: text 14.3, muted 7.9, red 6.0:1 */
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1B1815; --ink: #EDE6DA; --muted: #B6AC9C; --rule: #3D362E;
  --red: #E07A64; --red-strong: #EE9C88;
  color-scheme: dark;
}

:root {
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --measure: 38rem;
  --body: 1.1875rem;       /* 19px */
  --small: 1rem;
  --title: 1.375rem;
  --h2: 1.75rem;
  --h1: clamp(2.125rem, 1.55rem + 2.5vw, 3.25rem);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--paper); color: var(--ink);
  font-family: var(--serif); font-size: var(--body); line-height: 1.65;
  font-optical-sizing: auto; font-variant-numeric: oldstyle-nums proportional-nums;
  -webkit-font-smoothing: antialiased;
}
main { flex: 1; width: 100%; max-width: calc(var(--measure) + 2.5rem); margin-inline: auto;
  padding: 2.5rem max(1.25rem, env(safe-area-inset-right, 0px)) 4.5rem max(1.25rem, env(safe-area-inset-left, 0px)); }
main:focus { outline: none; }
p { margin: 0 0 1em; }

a { color: var(--red); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--red-strong); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; border-radius: 2px; }

.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 1rem; top: 0.75rem; z-index: 5; background: var(--paper); padding: 0.5rem 0.75rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Small caps, the way a book sets its running heads: only for the title and each page's series line,
   so they keep meaning something. They work in Russian too. */
.series, .title-name {
  font-variant-caps: all-small-caps; letter-spacing: 0.06em; font-variant-numeric: lining-nums;
}

/* ---------- Masthead: a title page's head, centred, over a double rule ---------- */
.masthead { text-align: center; padding: 1.75rem 1.25rem 0; }
.title { display: inline-flex; flex-direction: column; align-items: center; color: var(--ink); text-decoration: none; line-height: 1.2; }
.title:hover { color: var(--ink); }
.title-name { font-size: 1.5rem; font-weight: 600; letter-spacing: 0.09em; }
.title:hover .title-name { color: var(--red); }
.nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 0 1.75rem; margin: 0.75rem auto 0; padding: 0.2rem 0;
  max-width: var(--measure); border-top: 3px double var(--rule); border-bottom: 1px solid var(--rule); font-size: 1.0625rem; font-style: italic; }
.nav a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); text-decoration: none; }
.nav a:hover { color: var(--red); }
.nav a[aria-current="page"] { color: var(--red); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.3em; }

/* ---------- Headings ---------- */
h1, h2, h3 { font-weight: 600; line-height: 1.15; letter-spacing: -0.012em; text-wrap: balance; margin: 0; }
h1 { font-size: var(--h1); font-weight: 560; }
h2 { font-size: var(--h2); margin: 3rem 0 1rem; }
.label-head { font-size: 1.5rem; font-weight: 600; margin: 3rem 0 0.75rem; }

/* ---------- Title page (home) and study heads: centred ---------- */
.title-page, .study-head { text-align: center; margin: 1.5rem 0 2.5rem; }
.series { color: var(--red); font-size: 1.125rem; font-weight: 600; margin: 0 0 0.75rem; }
.title-page h1 { max-width: 15em; margin-inline: auto; }
.lede { font-size: 1.3125rem; line-height: 1.55; margin: 1.5rem auto 0.75rem; max-width: 32rem; text-wrap: pretty; }
.title-note { color: var(--muted); max-width: 32rem; margin: 0 auto; text-wrap: pretty; }
.byline { font-style: italic; color: var(--muted); margin: 1.25rem 0 0; text-wrap: balance; }

.crumb { margin: 0 0 1rem; font-size: 1.0625rem; font-style: italic; text-align: center; }
.crumb a { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; }
.crumb a::before { content: "\2190\00a0"; content: "\2190\00a0" / ""; }
.crumb a:hover { text-decoration: underline; }

/* ---------- Prose: Bill's text ---------- */
.prose { max-width: var(--measure); }
.prose p, .prose ul { text-wrap: pretty; }
.prose ul { padding-left: 1.25em; margin: 0 0 1em; }
.prose li { margin-bottom: 0.35em; }
.prose em, .dl-desc em { font-style: italic; }

/* ---------- Contents (home): numbered like a book's contents page ---------- */
.contents { counter-reset: study; }
.contents > .label-head { text-align: center; }
.part { margin-top: 2.25rem; }
.part-head { font-size: 1.1875rem; font-weight: 600; font-style: italic; color: var(--muted); margin: 0 0 0.25rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--rule); }
.toc { list-style: none; margin: 0; padding: 0; }
.toc-entry { position: relative; counter-increment: study; padding: 1.1rem 0 1.1rem 3rem; border-bottom: 1px solid var(--rule); }
.toc-entry::before { content: counter(study); position: absolute; left: 0; top: 0.95rem; width: 2rem; text-align: right;
  font-size: 1.75rem; font-weight: 600; line-height: 1.2; color: var(--red); font-variant-numeric: oldstyle-nums; }
.toc-line { display: flex; align-items: baseline; gap: 0.5rem; margin: 0; }
.toc-title { font-size: var(--title); font-weight: 600; line-height: 1.3; color: var(--ink); text-decoration: none; }
/* The title is the link, stretched over the entry, so the whole entry can be tapped and a screen
   reader hears just the title. The Russian edition's link sits above it. */
.toc-title::after { content: ""; position: absolute; inset: 0; }
.toc-title:hover { color: var(--red); }
.toc-entry:hover .toc-title { color: var(--red); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
.toc-title:focus-visible { outline: none; }
.toc-title:focus-visible::after { outline: 3px solid var(--red); outline-offset: 2px; border-radius: 2px; }
.toc-leader { flex: 1; min-width: 1.5rem; border-bottom: 2px dotted var(--rule); transform: translateY(-0.3em); }
.toc-count { flex: none; font-size: var(--small); color: var(--muted); font-variant-numeric: lining-nums tabular-nums; }
.toc-blurb { margin: 0.3rem 0 0; color: var(--muted); font-size: 1.0625rem; line-height: 1.55; max-width: 34rem; }
.toc-ru { position: relative; z-index: 1; margin: 0.2rem 0 0; font-size: var(--small); color: var(--muted); width: fit-content; pointer-events: none; }
/* Taps on "In Russian:" fall through to the study; only the Russian title is its own link. */
.toc-ru a, .lang-switch a, .next a { display: inline-block; padding-block: 0.35rem; pointer-events: auto; }


/* ---------- Downloads: each file a ruled row with its size first, and one clear button ---------- */
.files .label-head { margin-bottom: 0.75rem; }
.downloads { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.dl { position: relative; padding: 1.25rem 0; border-bottom: 1px solid var(--rule); }
.dl-title { margin: 0; font-size: var(--title); font-weight: 600; line-height: 1.3; }
.dl-title a::after { content: ""; position: absolute; inset: 0; }
.dl-title a:focus-visible { outline: none; }
.dl-title a:focus-visible::after { outline: 3px solid var(--red); outline-offset: 2px; border-radius: 2px; }
.dl:hover .dl-title a { color: var(--red-strong); text-decoration-thickness: 2px; }
.dl-meta { margin: 0.15rem 0 0; font-size: var(--small); color: var(--muted); font-variant-numeric: lining-nums tabular-nums; }
.dl-meta b { color: var(--ink); font-weight: 600; }
.dl-desc { margin: 0.5rem 0 0; max-width: var(--measure); text-wrap: pretty; }
.dl-note { margin: 0.4rem 0 0; font-size: var(--small); font-style: italic; color: var(--muted); }
.next { margin: 2.5rem 0 0; color: var(--muted); }
.next a { font-weight: 600; }

/* The same study in the other language: right under the title, so a reader finds it at once. */
.lang-switch { margin: 0.75rem 0 0; }
.lang-switch a { font-weight: 600; }


/* ---------- About: Bill's closing words, set apart and signed ---------- */
.closing { margin: 2.5rem auto 0; padding: 1.75rem 0 0; max-width: 32rem; border-top: 1px solid var(--rule); text-align: center; font-style: italic; }
.closing p { margin: 0; font-size: 1.25rem; line-height: 1.55; text-wrap: balance; }
.closing .closing-sign { margin-top: 1rem; font-size: 1.0625rem; color: var(--muted); }

/* ---------- Colophon: centred, on the page color ---------- */
.colophon { text-align: center; padding: 0 1.25rem 2.5rem; font-size: var(--small); line-height: 1.55; }
.colophon::before { content: ""; display: block; max-width: var(--measure); margin: 0 auto 2rem; border-top: 3px double var(--rule); }
.colophon p { margin: 0; }
.colophon-name { font-size: 1.125rem; font-weight: 600; }
.colophon-nav { font-style: italic; }
.colophon-nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 0 1.5rem; margin: 0.75rem 0 1.25rem; }
.colophon-nav a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); text-decoration: none; }
.colophon-nav a:hover { color: var(--red); text-decoration: underline; }
/* The Kindwright Studio sign-off (brand/README.md, section 9, at the repo root), quiet in the muted color. */
.foot-signoff { margin: 0; }
.kw-signoff { display: inline-flex; align-items: baseline; gap: .35em; min-height: 24px; font-size: .875rem; line-height: 1.2; color: var(--muted); text-decoration: none; }
.kw-signoff svg { height: 1.05em; width: auto; display: block; align-self: baseline; position: relative; top: 0.234em; }
.kw-signoff:hover { color: var(--ink); }
.kw-signoff:hover span:last-child { text-decoration: underline; text-underline-offset: .18em; }

@media (max-width: 30rem) {
  :root { --body: 1.125rem; }
  main { padding-top: 1.75rem; padding-bottom: 3.5rem; }
  .masthead { padding-top: 1.25rem; }
  .title-name { font-size: 1.3125rem; }
  .nav { gap: 0 1.25rem; }
  .toc-entry { padding-left: 2.5rem; }
  .toc-entry::before { width: 1.6rem; font-size: 1.5rem; }
  .toc-leader { display: none; }
  .toc-line { flex-direction: column; gap: 0; }
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
