@import url("fonts/fonts.css");

/* ------------------------------------------------------------------
   Scriptorium: a page set like a folio. Text column, a margin for notes,
   rubric (red) for numbers and initials, hairline rules. No cards, no
   gradients, one typeface.
   ------------------------------------------------------------------ */

:root {
  --paper: #F5F0E6;
  --paper-2: #EDE6D8;          /* slips, form fields */
  --ink: #1F1B17;
  --ink-2: #4F473F;
  --ink-3: #6B6258;            /* 5.0:1 on paper */
  --rule: #D6CBB8;
  --rubric: #9A2A1E;           /* 6.9:1 on paper */
  --rubric-2: #7E2117;
  --on-rubric: #FBF6EE;
  --focus: #1F5FBF;
  --serif: "EB Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --hebrew: "Frank Ruhl Libre", "SBL Hebrew", "Times New Roman", serif;
  --measure: 34rem;
  --margin: 13rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15120F;
    --paper-2: #211C18;
    --ink: #ECE3D3;
    --ink-2: #C9BEAD;
    --ink-3: #A1968A;
    --rule: #3A322B;
    --rubric: #E27A63;
    --rubric-2: #EE927D;
    --on-rubric: #1A0F0B;
    --focus: #8DB4FF;
    color-scheme: dark;
  }
}
@media (prefers-contrast: more) {
  :root { --ink-2: var(--ink); --ink-3: var(--ink-2); --rule: var(--ink-3); }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 1.25rem/1.55 var(--serif);
  font-feature-settings: "onum" 1, "kern" 1, "liga" 1;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--rubric); text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { color: var(--rubric-2); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 2px; }
::selection { background: color-mix(in srgb, var(--rubric) 22%, transparent); }

.skip { position: absolute; left: .75rem; top: -3rem; padding: .5rem .9rem; background: var(--ink); color: var(--paper);
  z-index: 100; text-decoration: none; border-radius: 3px; }
.skip:focus { top: .75rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.sc { font-variant-caps: all-small-caps; letter-spacing: .08em; }
.rubric { color: var(--rubric); }

/* Page frame ------------------------------------------------------- */
.page { width: min(72rem, 100% - 2rem); margin-inline: auto; }

.runhead { border-bottom: 1px solid var(--rule); }
.runhead .page { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: 1.1rem 0 .9rem; }
.wordmark { display: inline-flex; align-items: center; gap: .55rem; font-size: 1.5rem; font-weight: 500; letter-spacing: .02em;
  color: var(--ink); text-decoration: none; }
.nib { display: inline-block; width: .95rem; height: 1.25rem; background: var(--rubric);
  -webkit-mask: url(img/mark.svg) center / contain no-repeat; mask: url(img/mark.svg) center / contain no-repeat; }
.wordmark:hover { color: var(--ink); }
.runhead nav { display: flex; gap: 1.6rem; align-items: baseline; font-size: 1.05rem; }
.runhead nav a { color: var(--ink-2); text-decoration: none; }
.runhead nav a:hover { color: var(--rubric); }
.runhead nav a.join { color: var(--rubric); }

/* A folio: margin column + text column */
.folio { display: grid; grid-template-columns: var(--margin) minmax(0, 1fr); column-gap: 3rem; }
.margin { font-size: 1rem; line-height: 1.45; color: var(--ink-3); padding-top: .35rem; }
.margin .num { display: block; font-size: 2.2rem; line-height: 1; color: var(--rubric); font-weight: 500; margin-bottom: .6rem; }
.margin p { margin: 0 0 .8rem; }
.text { max-width: var(--measure); }
.wide { max-width: none; }

section.chapter { padding: 5.5rem 0 1rem; }
section.chapter + section.chapter { position: relative; margin-top: 4rem; }
/* The rule between chapters is drawn in, left to right, as the chapter arrives. */
section.chapter + section.chapter::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: var(--rule); transform-origin: left; transform: scaleX(var(--drawn, 1)); transition: transform 1.1s cubic-bezier(.2, .7, .1, 1); }
h1, h2, h3 { font-weight: 500; margin: 0; }
h2 { font-size: clamp(2rem, 1.4rem + 2vw, 2.9rem); line-height: 1.08; letter-spacing: -.01em; margin-bottom: 1.2rem; }
h2 .sc { display: block; font-size: 1.05rem; color: var(--rubric); letter-spacing: .12em; margin-bottom: .6rem; }
p { margin: 0 0 1.1rem; }
.lede { font-size: 1.45rem; line-height: 1.45; color: var(--ink); }
.muted { color: var(--ink-2); }

/* Drop cap */
.initial::first-letter { float: left; font-size: 4.6em; line-height: .8; margin: .07em .08em 0 0; color: var(--rubric); font-weight: 500; }

/* Buttons: one kind, set like a rubricated label */
.btn { display: inline-flex; align-items: center; gap: .55rem; font: 500 1.15rem/1 var(--serif); letter-spacing: .02em;
  padding: .85rem 1.35rem .8rem; background: var(--rubric); color: var(--on-rubric); border: 0; border-radius: 3px;
  text-decoration: none; cursor: pointer; transition: background .15s ease; }
.btn:hover { background: var(--rubric-2); color: var(--on-rubric); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.quiet { background: transparent; color: var(--rubric); padding-inline: 0; }
.btn.quiet:hover { color: var(--rubric-2); text-decoration: underline; }
.actions { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: center; margin-top: 1.8rem; }

/* Hero ------------------------------------------------------------- */
.incipit { padding: 4.5rem 0 3rem; }
.kicker { font-size: 1.1rem; color: var(--ink-3); margin: 0 0 1.1rem; }
.incipit h1 { font-size: clamp(2.5rem, 1.5rem + 3.6vw, 4.4rem); line-height: 1.02; letter-spacing: -.015em; max-width: 15ch; margin-bottom: 2.6rem; }

.verse-tabs { display: flex; gap: 1.6rem; border-bottom: 1px solid var(--rule); margin-bottom: 1.6rem; }
.verse-tabs button { font: inherit; font-size: 1.05rem; background: none; border: 0; padding: .4rem 0 .6rem; color: var(--ink-3);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.verse-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--rubric); }

.study { display: grid; grid-template-columns: minmax(0, 1fr) 19rem; gap: 2.5rem; align-items: start; }
.original { font-size: clamp(2rem, 1.2rem + 2.8vw, 3.35rem); line-height: 1.35; margin: 0 0 1.2rem; }
.original[lang="he"] { font-family: var(--hebrew); font-size: clamp(2.2rem, 1.3rem + 3vw, 3.6rem); line-height: 1.5; }
.w { font: inherit; color: inherit; background: none; border: 0; padding: 0 .06em; margin: 0; cursor: pointer; border-radius: 2px;
  text-decoration: underline; text-decoration-color: transparent; text-underline-offset: .22em; text-decoration-thickness: 2px;
  transition: color .15s ease, text-decoration-color .15s ease; }
.w:hover { text-decoration-color: color-mix(in srgb, var(--rubric) 45%, transparent); }
.w[aria-pressed="true"] { color: var(--rubric); text-decoration-color: var(--rubric); }
.english { font-size: 1.35rem; font-style: italic; color: var(--ink-2); margin: 0; }
.english span { transition: color .15s ease, background-color .15s ease; border-radius: 2px; }
.english span.on { color: var(--ink); background: color-mix(in srgb, var(--rubric) 14%, transparent); font-style: normal; }
.hint { font-size: 1rem; color: var(--ink-3); margin-top: 1rem; }

/* The lexicon slip */
.slip { background: var(--paper-2); border-top: 3px solid var(--rubric); padding: 1.2rem 1.3rem 1.1rem; font-size: 1.05rem; line-height: 1.45; }
.slip .lemma { font-size: 2.2rem; line-height: 1.1; margin: 0; }
.slip .lemma[lang="he"] { font-family: var(--hebrew); }
.slip .tr { font-style: italic; color: var(--ink-2); margin: .1rem 0 .8rem; }
.slip dl { display: grid; grid-template-columns: auto 1fr; gap: .25rem .9rem; margin: 0 0 .8rem; }
.slip dt { color: var(--ink-3); font-variant-caps: all-small-caps; letter-spacing: .08em; }
.slip dd { margin: 0; }
.slip .def { color: var(--ink-2); margin: 0; border-top: 1px solid var(--rule); padding-top: .7rem; }
.slip .src { font-size: .88rem; color: var(--ink-3); margin: .7rem 0 0; }
.slip.swap > * { animation: ink .28s ease both; }
@keyframes ink { from { opacity: 0; } to { opacity: 1; } }

/* Figures ---------------------------------------------------------- */
figure { margin: 0; }
.fig img { border: 1px solid var(--rule); border-radius: 10px; background: #fff; }
.fig.phone img { border-radius: 26px; }
figcaption { font-size: .98rem; color: var(--ink-3); margin-top: .6rem; }
figcaption b { font-weight: 500; color: var(--rubric); font-variant-caps: all-small-caps; letter-spacing: .08em; }
.with-fig { display: grid; grid-template-columns: minmax(0, var(--measure)) minmax(0, 1fr); gap: 3rem; align-items: start; }

/* The quoted source */
blockquote.source { margin: 1.8rem 0; padding: 0 0 0 1.4rem; border-left: 2px solid var(--rubric); font-size: 1.3rem; line-height: 1.5; }
blockquote.source p { margin: 0 0 .6rem; }
blockquote.source footer { font-size: 1rem; color: var(--ink-3); }

/* A plain list set as a register of items */
ol.register { list-style: none; padding: 0; margin: 1.4rem 0 0; counter-reset: r; }
ol.register li { counter-increment: r; display: grid; grid-template-columns: 2.4rem 1fr; padding: .8rem 0; border-top: 1px solid var(--rule); }
ol.register li:last-child { border-bottom: 1px solid var(--rule); }
ol.register li::before { content: counter(r, lower-roman) "."; color: var(--rubric); }
ol.register b { font-weight: 500; }

/* Maker's note */
.letter { font-size: 1.4rem; line-height: 1.55; }
.letter .sig { font-style: italic; color: var(--ink-2); font-size: 1.2rem; }

/* The register (form) ---------------------------------------------- */
form.sign { max-width: var(--measure); }
.field { margin: 0 0 1.4rem; }
.field label, .legend { display: block; font-size: 1rem; color: var(--ink-2); margin-bottom: .3rem; font-variant-caps: all-small-caps; letter-spacing: .08em; }
.field .opt { font-variant-caps: normal; letter-spacing: 0; color: var(--ink-3); font-style: italic; }
input[type=text], input[type=email], select, textarea {
  width: 100%; font: inherit; font-size: 1.25rem; color: var(--ink); background: transparent; border: 0;
  border-bottom: 1px solid var(--ink-3); border-radius: 0; padding: .35rem 0 .45rem; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(-45deg, transparent 50%, var(--ink-3) 50%);
  background-position: right .4rem center, right .05rem center; background-size: .35rem .35rem; background-repeat: no-repeat; padding-right: 1.5rem; }
textarea { min-height: 5.5rem; resize: vertical; border: 1px solid var(--ink-3); padding: .6rem .7rem; border-radius: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--rubric); box-shadow: 0 2px 0 0 var(--rubric); }
textarea:focus-visible { box-shadow: 0 0 0 1px var(--rubric); }
input[aria-invalid="true"] { border-bottom-color: var(--rubric); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }
.check { display: grid; grid-template-columns: 1.4rem 1fr; gap: .6rem; align-items: start; margin: .2rem 0 1.4rem; cursor: pointer; }
.check input { width: 1.15rem; height: 1.15rem; margin: .3rem 0 0; accent-color: var(--rubric); }
fieldset { border: 0; padding: 0; margin: 0 0 1.4rem; }
.pick { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; margin-top: .2rem; }
.pick label { display: inline-flex; gap: .45rem; align-items: center; cursor: pointer; }
.pick input { accent-color: var(--rubric); width: 1.05rem; height: 1.05rem; margin: 0; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.status { min-height: 1.6em; margin: .9rem 0 0; color: var(--ink-2); }
.status.err { color: var(--rubric); }
.done h3 { font-size: 2rem; margin-bottom: .6rem; }

/* Questions */
dl.qa { margin: 0; max-width: var(--measure); }
dl.qa dt { font-weight: 500; font-size: 1.3rem; margin-top: 1.6rem; }
dl.qa dd { margin: .35rem 0 0; color: var(--ink-2); }

/* Colophon --------------------------------------------------------- */
.colophon { border-top: 1px solid var(--rule); margin-top: 6rem; padding: 3rem 0 4rem; font-size: 1rem; color: var(--ink-3); }
.colophon .folio { row-gap: 1rem; }
.colophon p { margin: 0 0 .7rem; max-width: 44rem; }
.colophon nav { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; margin-top: 1.2rem; }
.colophon a { color: var(--ink-2); }

/* Legal and statement pages ---------------------------------------- */
.doc { padding: 3.5rem 0 2rem; }
.doc h1 { font-size: clamp(2.4rem, 1.6rem + 2.6vw, 3.6rem); line-height: 1.05; margin-bottom: 1rem; }
.doc .meta { color: var(--ink-3); font-size: 1.05rem; margin-bottom: 2.5rem; }
.toc { position: sticky; top: 1.5rem; font-size: 1rem; line-height: 1.4; }
.toc ol { list-style: none; padding: 0; margin: .6rem 0 0; counter-reset: t; }
.toc li { counter-increment: t; margin: 0 0 .45rem; display: grid; grid-template-columns: 1.8rem 1fr; }
.toc li::before { content: counter(t) "."; color: var(--rubric); }
.toc a { color: var(--ink-2); text-decoration: none; }
.toc a:hover { color: var(--rubric); text-decoration: underline; }
.prose { max-width: 40rem; font-size: 1.18rem; }
.prose section { padding-top: 1.2rem; scroll-margin-top: 1rem; }
.prose h2 { font-size: 1.7rem; margin: 1.6rem 0 .7rem; }
.prose h3 { font-size: 1.3rem; margin: 1.3rem 0 .5rem; }
.prose ul, .prose ol { padding-left: 1.3rem; margin: 0 0 1.1rem; }
.prose li { margin-bottom: .35rem; }
.prose table { width: 100%; border-collapse: collapse; margin: .6rem 0 1.4rem; font-size: 1.02rem; line-height: 1.4; }
.prose th, .prose td { text-align: left; vertical-align: top; padding: .55rem .6rem .55rem 0; border-top: 1px solid var(--rule); }
.prose th { font-weight: 500; color: var(--ink); }
.prose thead th { border-top: 0; border-bottom: 1px solid var(--ink-3); font-variant-caps: all-small-caps; letter-spacing: .06em; color: var(--ink-2); }
.prose dl dt { font-weight: 500; margin-top: .8rem; }
.prose dl dd { margin: .2rem 0 0 0; color: var(--ink-2); }
.table-wrap { overflow-x: auto; }

/* Motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Narrow screens --------------------------------------------------- */
@media (max-width: 62rem) {
  :root { --margin: 9rem; }
  .study { grid-template-columns: minmax(0, 1fr); }
  .with-fig { grid-template-columns: minmax(0, 1fr); }
  .with-fig .fig { max-width: 26rem; }
}
@media (max-width: 46rem) {
  body { font-size: 1.15rem; }
  .folio { grid-template-columns: minmax(0, 1fr); }
  .margin { display: flex; gap: 1rem; align-items: baseline; padding: 0 0 .8rem; }
  .margin .num { font-size: 1.6rem; margin: 0; }
  .margin p { margin: 0; }
  .runhead nav a:not(.join) { display: none; }
  .incipit { padding-top: 2.5rem; }
  section.chapter { padding-top: 3.5rem; }
  .row2 { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .slip dl { grid-template-columns: auto minmax(0, 1fr); }
  .english, .original { overflow-wrap: anywhere; }
  .toc { position: static; border-bottom: 1px solid var(--rule); padding-bottom: 1rem; margin-bottom: 1rem; }
  .fig.phone { max-width: 17rem; }
}

/* ------------------------------------------------------------------
   Motion. Everything here is quiet, and all of it switches off under
   prefers-reduced-motion (the rule at the end of the file).
   ------------------------------------------------------------------ */

/* The pen writes the rule under the headline, then lifts away. */
.writing { position: relative; height: 1.6rem; margin: -1.4rem 0 1.6rem; max-width: 30rem; }
.writing::before { content: ""; position: absolute; left: 0; right: 0; bottom: .3rem; height: 2px; background: var(--rubric);
  transform-origin: left; transform: scaleX(0); animation: write 1.5s cubic-bezier(.55, .1, .25, 1) .35s forwards; }
.writing .pen { position: absolute; bottom: .3rem; left: 0; width: 1.05rem; height: 1.4rem; background: var(--rubric);
  -webkit-mask: url(img/mark.svg) center / contain no-repeat; mask: url(img/mark.svg) center / contain no-repeat;
  transform: translate(-50%, 0) rotate(-24deg); transform-origin: 50% 100%; opacity: 0;
  animation: pen 1.5s cubic-bezier(.55, .1, .25, 1) .35s forwards, lift .6s ease 1.9s forwards; }
@keyframes write { to { transform: scaleX(1); } }
@keyframes pen { 0% { left: 0; opacity: 0; } 8% { opacity: 1; } 100% { left: 100%; opacity: 1; } }
@keyframes lift { to { opacity: 0; transform: translate(-30%, -.6rem) rotate(-10deg); } }

/* The Greek and Hebrew arrive word by word, as if inked. */
.original.inking .w { animation: ink-in .7s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--i) * 70ms + 150ms); }
@keyframes ink-in { from { opacity: 0; filter: blur(5px); transform: translateY(.18em); } to { opacity: 1; filter: none; transform: none; } }

/* Things that arrive as you read down the page. */
.js .rise { opacity: 0; transform: translateY(18px); transition: opacity .9s ease, transform .9s cubic-bezier(.2, .7, .2, 1); }
.js .rise.in { opacity: 1; transform: none; }
.margin .num { transition: color .8s ease, transform .8s cubic-bezier(.2, .7, .2, 1); }
.js .chapter:not(.in) .margin .num { color: var(--rule); transform: translateY(6px); }
.js .chapter:not(.in)::before { --drawn: 0; }
.chapter .initial::first-letter { transition: color 1s ease; }
.js .chapter:not(.in) .initial::first-letter { color: var(--ink-3); }
blockquote.source { position: relative; border-left: 0; }
blockquote.source::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--rubric);
  transform-origin: top; transform: scaleY(var(--drawn, 1)); transition: transform 1.2s cubic-bezier(.2, .7, .1, 1) .2s; }
.js .chapter:not(.in) blockquote.source::before { --drawn: 0; }

/* The phone: a plain frame around a real recording of the app. */
.device-fig { display: grid; justify-items: center; gap: .9rem; }
.device { width: min(18.5rem, 100%); aspect-ratio: 1206 / 2622; padding: 3.2%; border-radius: 16.8% / 7.8%;
  background: linear-gradient(145deg, #2b2623, #0f0d0c 55%); position: relative;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .07), 0 1px 1px rgba(31, 27, 23, .12),
              0 22px 40px -16px rgba(31, 27, 23, .38), 0 44px 80px -40px rgba(31, 27, 23, .35); }
.device .screen { width: 100%; height: 100%; overflow: hidden; border-radius: 13.6% / 6.3%; background: #FCFCFA; }
.device video { width: 100%; height: 100%; object-fit: cover; display: block; }
.device-fig figcaption { text-align: center; }
.clip-toggle { font: inherit; font-size: .9rem; color: var(--ink-2); background: none; border: 0; border-bottom: 1px solid var(--rule);
  padding: 0 .1rem; margin-left: .5rem; cursor: pointer; }
.clip-toggle:hover { color: var(--rubric); border-color: var(--rubric); }
@media (prefers-color-scheme: dark) {
  .device { background: linear-gradient(145deg, #3a332e, #121010 55%);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1), 0 30px 60px -24px rgba(0, 0, 0, .8); }
}
/* A slow drift as the phone passes through the window, where the browser can tie it to scrolling. */
@supports (animation-timeline: view()) {
  .device[data-parallax] { animation: drift linear both; animation-timeline: view(); animation-range: cover 0% cover 100%; }
  @keyframes drift { from { transform: translateY(28px) rotate(-1.4deg); } to { transform: translateY(-28px) rotate(1.1deg); } }
}

/* Three recordings side by side; a swipeable row on phones. */
.triptych { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.6rem; margin-top: 2.6rem; }
.triptych .device { width: 100%; }
.triptych figcaption { font-size: .92rem; }

@media (max-width: 46rem) {
  .device { width: min(15.5rem, 78vw); }
  .triptych { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 1rem; margin-inline: -1rem;
    padding: 0 1rem 1rem; scrollbar-width: none; }
  .triptych::-webkit-scrollbar { display: none; }
  .triptych .device-fig { flex: 0 0 72vw; scroll-snap-align: center; }
  .writing { margin-top: -1.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  .js .rise, .js .chapter:not(.in) .margin .num { opacity: 1 !important; transform: none !important; }
  .js .chapter:not(.in)::before, .js .chapter:not(.in) blockquote.source::before { --drawn: 1; }
  .writing::before { transform: scaleX(1); }
  .writing .pen { display: none; }
  .device[data-parallax] { animation: none; }
}
