/* Come, Follow Me — reverent, quiet, bookish. Ivory paper, deep navy ink, muted gold. */

@font-face { font-family: 'Cormorant Garamond'; font-weight: 500; font-style: normal; font-display: swap; src: url('/static/fonts/cormorant-garamond-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 600; font-style: normal; font-display: swap; src: url('/static/fonts/cormorant-garamond-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 500; font-style: italic; font-display: swap; src: url('/static/fonts/cormorant-garamond-latin-500-italic.woff2') format('woff2'); }
@font-face { font-family: 'Source Serif 4'; font-weight: 400; font-style: normal; font-display: swap; src: url('/static/fonts/source-serif-4-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Source Serif 4'; font-weight: 400; font-style: italic; font-display: swap; src: url('/static/fonts/source-serif-4-latin-400-italic.woff2') format('woff2'); }
@font-face { font-family: 'Source Serif 4'; font-weight: 600; font-style: normal; font-display: swap; src: url('/static/fonts/source-serif-4-latin-600-normal.woff2') format('woff2'); }

:root {
  --bg: #f7f4ed;
  --surface: #fdfbf7;
  --tint: #f1ebdf;
  --ink: #1b2233;
  --ink-soft: #3a4256;
  --muted: #73705f;
  --line: #e3dccd;
  --gold: #9a7a3c;
  --gold-soft: #c9b48a;
  --navy: #1d2a44;
  --navy-ink: #f5efe2;
  --link: #6f5521;
  --display: 'Cormorant Garamond', 'Iowan Old Style', Palatino, Georgia, serif;
  --text: 'Source Serif 4', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --radius: 4px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1320;
    --surface: #141b2b;
    --tint: #1a2235;
    --ink: #ebe5d8;
    --ink-soft: #cfc8b8;
    --muted: #9c978a;
    --line: #283149;
    --gold: #cbad6b;
    --gold-soft: #8d7646;
    --navy: #1a2541;
    --navy-ink: #f1ead9;
    --link: #d9bd7e;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 64px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 18px/1.7 var(--text);
  font-feature-settings: 'kern', 'liga', 'onum';
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--link); text-decoration-color: var(--gold-soft); text-underline-offset: 3px; text-decoration-thickness: 1px; }
.wrap { max-width: 680px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.15; letter-spacing: 0.005em; }
p { margin: 0 0 0.85em; }
p:last-child { margin-bottom: 0; }
strong { font-weight: 600; }
code { font: 0.85em ui-monospace, monospace; background: var(--tint); padding: 0.1em 0.35em; border-radius: 3px; }

/* Small-caps labels used throughout */
.eyebrow, .list-h, .label-sc, .walk-ref, .badge, .ready, .toc a, .btn, .chapters > summary, .setting > summary {
  font-family: var(--text);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* Section headings: centered with a fine gold rule */
.summary h2, .list-h {
  text-align: center;
  font-size: 1.7rem;
  margin: 2.6rem 0 1.2rem;
}
.summary h2::after {
  content: '';
  display: block;
  width: 36px;
  height: 1px;
  margin: 0.7rem auto 0;
  background: var(--gold);
}
.ornament { display: block; text-align: center; color: var(--gold); letter-spacing: 0.8em; padding-left: 0.8em; font-size: 0.8rem; margin: 2.4rem 0; }

/* ---------- Index ---------- */
.top { padding: 44px 0 12px; text-align: center; }
.top .ornament { margin: 0 0 14px; }
.top h1 { margin: 0; font-size: 2.6rem; font-weight: 500; }
.top .sub { margin: 6px 0 0; color: var(--muted); font-style: italic; }

.hero {
  display: block;
  position: relative;
  margin: 28px 0 12px;
  padding: 30px 26px 26px;
  border-radius: var(--radius);
  background: var(--navy);
  color: var(--navy-ink);
  text-decoration: none;
  text-align: center;
}
.hero::before { content: ''; position: absolute; inset: 7px; border: 1px solid color-mix(in srgb, var(--gold-soft) 55%, transparent); border-radius: 2px; pointer-events: none; }
.hero > span { display: block; position: relative; }
a.hero .eyebrow { color: var(--gold-soft); margin: 0; }
@media (prefers-color-scheme: dark) { a.hero .eyebrow { color: var(--gold); } }
.hero-title { font-family: var(--display); font-weight: 500; font-size: 2.1rem; line-height: 1.1; margin: 12px 0 6px; }
.hero-sub { font-style: italic; opacity: 0.85; }
.hero-tldr { margin: 18px auto 0; max-width: 32em; font-size: 0.98rem; line-height: 1.65; opacity: 0.92; text-align: left; }
.hero-tldr a { color: inherit; }
.hero-cta { margin-top: 20px; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold-soft); }
@media (prefers-color-scheme: dark) { .hero-cta { color: var(--gold); } }

.next-up {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: inherit; text-decoration: none;
}
.next-up small { display: block; color: var(--muted); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; }
.next-up strong { font-family: var(--display); font-weight: 600; font-size: 1.3rem; line-height: 1.2; display: inline-block; margin: 2px 0; }
.next-up .ns { font-style: italic; color: var(--ink-soft); font-size: 0.95rem; }
.next-up .arrow { color: var(--gold); font-size: 1.3rem; }

.list-h { color: var(--muted); font-size: 0.75rem; margin-top: 44px; }
.list-h::before, .list-h::after { content: '—'; color: var(--gold); margin: 0 0.8em; letter-spacing: 0; }
.lessons { list-style: none; margin: 0 0 64px; padding: 0; border-top: 1px solid var(--line); }
.lessons li a {
  display: grid; grid-template-columns: 1fr auto; gap: 0 12px;
  padding: 14px 6px; border-bottom: 1px solid var(--line);
  color: inherit; text-decoration: none;
}
.lessons .dates { grid-column: 1; font-size: 0.8rem; color: var(--muted); font-variant-numeric: oldstyle-nums; }
.lessons .scripture { grid-column: 1; font-family: var(--display); font-weight: 600; font-size: 1.25rem; line-height: 1.25; }
.lessons .quote { grid-column: 1; font-style: italic; color: var(--ink-soft); font-size: 0.95rem; line-height: 1.4; margin-top: 2px; }
.lessons .ready { grid-column: 2; grid-row: 1 / span 3; align-self: center; color: var(--gold); font-size: 0.62rem; }
.lessons li.current a { background: var(--surface); box-shadow: inset 2px 0 0 var(--gold); padding-left: 14px; }
.badge { display: inline-block; margin-left: 8px; color: var(--gold); font-size: 0.62rem; }

/* ---------- Who's studying ---------- */
.who { margin: 10px 0 0; font-size: 0.85rem; color: var(--muted); }
.lesson-head .who { margin: 4px 0 0; }
.who a { color: var(--gold); }
.who-main { text-align: center; padding-top: 18vh; padding-bottom: 64px; max-width: 420px; }
.who-main .ornament { margin: 0 0 14px; }
.who-main h1 { font-size: 2.4rem; font-weight: 500; margin: 0 0 8px; }
.who-sub { color: var(--muted); font-style: italic; margin-bottom: 28px; }
.who-list { display: grid; gap: 10px; }
.who-list .btn { width: 100%; font-size: 0.8rem; }
.who-or { margin: 22px 0 12px; color: var(--muted); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; }
.who-or::before, .who-or::after { content: '—'; color: var(--gold); margin: 0 0.8em; }
.who-form { display: flex; gap: 8px; }
.who-form input {
  flex: 1; min-width: 0; min-height: 46px; padding: 10px 14px; border-radius: 2px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: 16px var(--text);
}
.who-form input:focus { outline: none; border-color: var(--gold); }
.who-err { color: #a8432f; font-style: italic; min-height: 1.5em; margin-top: 10px; }
.btn.wide { width: 100%; }
.who-sub.small { font-size: 0.9rem; margin-top: 18px; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--gold); cursor: pointer; text-decoration: underline; text-decoration-color: var(--gold-soft); text-underline-offset: 3px; }
.account { text-align: center; color: var(--muted); font-size: 0.85rem; font-style: italic; margin: -32px 0 64px; }
.account-status { display: block; margin-top: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- Lesson header ---------- */
.lesson-head { padding: 10px 0 4px; text-align: center; }
.crumbs { display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; text-align: left; }
.crumbs a { text-decoration: none; padding: 10px 0; display: inline-block; color: var(--ink-soft); }
.crumbs .pn a { margin-left: 18px; }
.eyebrow { margin: 22px 0 0; color: var(--gold); }
.lesson-head h1 { font-size: 2.5rem; font-weight: 500; margin: 8px 0 8px; }
.scripture-ref { font-style: italic; font-size: 1.1rem; color: var(--ink-soft); margin: 0 0 20px; }
.links { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 20px;
  border-radius: 2px; border: 1px solid var(--gold-soft);
  background: transparent; color: var(--ink);
  text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--navy); color: var(--navy-ink); border-color: var(--navy); }
.chapters { margin-top: 12px; }
.chapters > summary { list-style: none; cursor: pointer; color: var(--muted); padding: 10px 0; }
.chapters > summary::-webkit-details-marker { display: none; }
.chapters > summary::after { content: ' ▾'; color: var(--gold); }
.chapters[open] > summary::after { content: ' ▴'; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; padding: 4px 0 10px; }
.chip { padding: 5px 12px; border: 1px solid var(--line); border-radius: 2px; background: var(--surface); color: var(--ink); text-decoration: none; font-size: 0.9rem; }

/* ---------- Summary ---------- */
.summary { padding-bottom: 130px; }
/* Section bar: sticky. Touch screens swipe it sideways (one compact line);
   wide screens and mouse/trackpad screens wrap it instead, since sideways scrolling is clumsy there. */
.toc {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 22px; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain;
  margin: 18px -16px 0; padding: 14px 20px;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  /* soft fade at the right edge hints there is more to swipe */
  mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
}
.toc::-webkit-scrollbar { display: none; }
.toc a { flex: none; color: var(--ink-soft); text-decoration: none; font-size: 0.66rem; }
@media (min-width: 760px), (hover: hover) and (pointer: fine) {
  .toc { flex-wrap: wrap; justify-content: center; gap: 6px 24px; overflow: visible; mask-image: none; margin-left: 0; margin-right: 0; padding: 12px 8px; }
  .toc a:hover { color: var(--gold); }
}

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 20px; }
section.card { margin-top: 28px; }
section.card h2 { margin-top: 0.2rem; }

.nutshell { font-size: 1.12rem; line-height: 1.7; }
.nutshell h2 { font-size: 1.4rem; }
.setting { margin-top: 16px; padding-top: 6px; border-top: 1px solid var(--line); font-size: 0.98rem; color: var(--ink-soft); }
.setting > summary { list-style: none; cursor: pointer; color: var(--gold); padding: 10px 0 4px; text-align: center; }
.setting > summary::-webkit-details-marker { display: none; }

.ideas { list-style: none; padding: 0; margin: 0; counter-reset: idea; }
.idea { counter-increment: idea; position: relative; padding: 22px 0 22px 52px; border-bottom: 1px solid var(--line); background: none; border-radius: 0; }
.idea:first-child { border-top: 1px solid var(--line); }
.idea::before {
  content: counter(idea, upper-roman);
  position: absolute; left: 0; top: 20px; width: 40px;
  font-family: var(--display); font-size: 1.5rem; font-weight: 500; color: var(--gold); text-align: center;
}
.idea.card { border-left: 0; border-right: 0; }
.idea h3 { margin: 0 0 8px; font-size: 1.4rem; }
.refs { font-size: 0.85rem; color: var(--muted); font-style: italic; }

.verse { margin: 0 0 18px; padding: 18px 22px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); position: relative; }
.verse::before { content: '“'; display: block; height: 1.9rem; margin-bottom: 4px; text-align: center; font-family: var(--display); font-size: 3.4rem; line-height: 1; color: var(--gold); }
.verse blockquote { margin: 0; font-family: var(--display); font-weight: 500; font-size: 1.42rem; line-height: 1.45; color: var(--ink); text-align: center; }
.verse figcaption { margin: 12px 0 16px; text-align: center; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; }
.verse figcaption a { text-decoration: none; color: var(--gold); }
.verse .plain { margin-bottom: 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.verse .label { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 2px; }
.verse .why { color: var(--ink-soft); font-style: italic; font-size: 0.97rem; }

details.walk, details.qa { border-bottom: 1px solid var(--line); }
#story details.walk:first-of-type, #tricky details.qa:first-of-type { border-top: 1px solid var(--line); }
details.walk > summary, details.qa > summary {
  list-style: none; cursor: pointer; padding: 16px 40px 16px 2px; position: relative; min-height: 44px;
}
details > summary::-webkit-details-marker { display: none; }
details.walk > summary::after, details.qa > summary::after {
  content: '+'; position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  font-family: var(--display); font-size: 1.6rem; color: var(--gold); font-weight: 500;
}
details[open].walk > summary::after, details[open].qa > summary::after { content: '−'; }
.walk-ref { display: block; color: var(--gold); font-size: 0.66rem; margin-bottom: 2px; }
.walk-h { font-family: var(--display); font-weight: 600; font-size: 1.3rem; line-height: 1.25; }
.walk-body { padding: 0 2px 18px; }
details.qa > summary { font-family: var(--display); font-weight: 600; font-size: 1.2rem; line-height: 1.3; }
details.qa > p { padding: 0 2px; }
details.qa > p:last-child { padding-bottom: 18px; }

.christ { background: var(--navy); color: var(--navy-ink); border-color: var(--navy); position: relative; padding: 30px 26px; }
.christ::before { content: ''; position: absolute; inset: 7px; border: 1px solid color-mix(in srgb, var(--gold-soft) 50%, transparent); pointer-events: none; }
.christ h2 { color: var(--navy-ink); }
.christ h2::after { background: var(--gold-soft); }
.christ a { color: var(--gold-soft); }
.christ p { position: relative; font-size: 1.05rem; }

.live { background: var(--tint); border-color: transparent; }
.todo { list-style: none; padding: 0; margin: 0; }
.todo li + li { border-top: 1px solid var(--line); }
.todo label { display: flex; gap: 14px; padding: 12px 0; cursor: pointer; align-items: flex-start; }
.todo input {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 20px; height: 20px; margin-top: 5px; border: 1px solid var(--gold); border-radius: 50%; background: var(--surface); display: grid; place-items: center; cursor: pointer;
}
.todo input:checked { background: var(--gold); }
.todo input:checked::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--surface); }
.todo input:checked + span { color: var(--muted); }
.gen { margin-top: 10px; text-align: center; font-size: 0.8rem; font-style: italic; color: var(--muted); }
.empty { text-align: center; }
.empty .status { color: var(--muted); margin-top: 12px; font-style: italic; }
a.ref { text-decoration-color: var(--gold-soft); }

.hist { padding: 22px 0; border-bottom: 1px solid var(--line); }
.hist:first-of-type { border-top: 1px solid var(--line); }
.hist h3 { margin: 0 0 8px; font-size: 1.35rem; }
.sources { list-style: none; margin: 12px 0 0; padding: 12px 14px; background: var(--tint); border-radius: var(--radius); font-size: 0.88rem; line-height: 1.45; }
.sources::before { content: 'Sources'; display: block; margin-bottom: 6px; font-size: 0.64rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.sources li + li { margin-top: 6px; }
.sources a { color: var(--link); }
.sources .pub { display: block; color: var(--muted); font-style: italic; font-size: 0.82rem; }

/* ---------- Chat ---------- */
.ask-fab {
  position: fixed; z-index: 20;
  right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  min-height: 50px; padding: 0 22px; border: 1px solid color-mix(in srgb, var(--gold-soft) 60%, transparent); border-radius: 2px;
  background: var(--navy); color: var(--navy-ink);
  font: 600 0.72rem var(--text); letter-spacing: 0.16em; text-transform: uppercase;
  box-shadow: 0 8px 28px rgb(10 15 30 / 28%); cursor: pointer;
}
.ask-fab .star { color: var(--gold-soft); margin-right: 8px; }
.chat { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; background: var(--bg); height: 100dvh; }
.chat[hidden] { display: none; }
@media (min-width: 760px) {
  .chat { inset: auto 24px 24px auto; width: 430px; height: min(700px, calc(100dvh - 48px)); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 16px 56px rgb(10 15 30 / 30%); overflow: hidden; }
}
.chat-head { display: flex; align-items: center; gap: 2px; padding: max(10px, env(safe-area-inset-top)) 6px 10px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.chat-head h2 { flex: 1; margin: 0; font-size: 1.25rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon { width: 44px; height: 44px; border: 0; background: none; color: var(--ink-soft); font-size: 1.15rem; border-radius: 50%; cursor: pointer; }
.chat-log { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain; }
.msg { max-width: 90%; padding: 12px 16px; border-radius: 3px; line-height: 1.6; overflow-wrap: anywhere; font-size: 1rem; }
.msg.user { align-self: flex-end; background: var(--navy); color: var(--navy-ink); white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); }
.msg.assistant :is(p, ul, ol) { margin: 0 0 0.65em; }
.msg.assistant :is(p, ul, ol):last-child { margin-bottom: 0; }
.msg.assistant ul, .msg.assistant ol { padding-left: 1.2em; }
.msg.assistant li::marker { color: var(--gold); }
.msg.assistant pre, .msg.assistant code { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.assistant table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 0.9rem; }
.msg.assistant :is(td, th) { padding: 4px 6px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; vertical-align: top; }
.msg.assistant blockquote { margin: 0 0 0.65em; padding-left: 12px; border-left: 1px solid var(--gold); font-family: var(--display); font-size: 1.15rem; font-weight: 500; }
.msg.error { align-self: center; background: none; color: #a8432f; font-size: 0.92rem; font-style: italic; text-align: center; }
@media (prefers-color-scheme: dark) { .msg.error { color: #e08b74; } }
.msg.typing::after { content: '· · ·'; letter-spacing: 2px; color: var(--gold); animation: breathe 1.4s infinite; }
@keyframes breathe { 50% { opacity: 0.3; } }
.chat-empty { margin: auto 0 4px; color: var(--muted); text-align: center; font-style: italic; font-size: 0.98rem; padding: 0 16px; }
.chat-empty::before { content: '✦'; display: block; color: var(--gold); font-style: normal; margin-bottom: 10px; }
.starters { display: flex; flex-direction: column; gap: 8px; padding: 0 16px 12px; }
.starters[hidden] { display: none; }
.starter { width: 100%; text-align: left; padding: 10px 14px; border-radius: 2px; border: 1px solid var(--gold-soft); background: var(--surface); color: var(--ink); font: italic 0.92rem/1.4 var(--text); cursor: pointer; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.chat-form textarea {
  flex: 1; resize: none; max-height: 140px; min-height: 46px;
  padding: 11px 14px; border-radius: 2px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font: 16px/1.45 var(--text); /* 16px stops iOS zoom */
}
.chat-form textarea:focus { outline: none; border-color: var(--gold); }
.send { width: 46px; height: 46px; border-radius: 2px; border: 0; background: var(--navy); color: var(--gold-soft); font-size: 1.2rem; cursor: pointer; flex: none; }
.send:disabled { opacity: 0.5; }
body.chat-open { overflow: hidden; }
body.chat-open .ask-fab { display: none; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
