/* Self-hosted, latin subset. A fonts.googleapis.com link is permitted by the CSP but would
   disclose every reader's IP and user agent to a third party, which this page does not do.
   Both families are SIL OFL 1.1; the licences ship beside the files in /fsy/fonts/. */
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('/fsy/fonts/cormorant-garamond-600.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Source Serif 4';
  src: url('/fsy/fonts/source-serif-4-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Source Serif 4';
  src: url('/fsy/fonts/source-serif-4-600.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --sand: #d9c49a;
  --night: #1b2a4a;
  --night-deep: #101a30;
  --gold: #e8b84b;
  --ink: #f2ead8;
  --ink-dim: #cbbd9a;
  --danger: #c47a5a;
  --ok: #8fbf88;

  /* Boundaries are solid, never rgba(). An alpha border composites into the
     fill beneath it and lands at 2.07:1 against the page, under the WCAG
     1.4.11 3:1 floor for a boundary that is the sole separator between
     objects. Raising the card fill instead measures worse, not better: on a
     near-black ground the edge is the elevation cue. */
  --rule: #8b7a4f;        /* 4.12:1 vs --night-deep, 3.38:1 vs --night */
  --rule-strong: var(--gold);

  --radius: 10px;
  --radius-sm: 6px;

  --dur-1: 120ms;
  --dur-2: 180ms;
  --ease-out: cubic-bezier(0.2, 0.7, 0.3, 1);

  /* One token used to do two jobs: the reading measure and the page shell.
     Lesson pages keep the measure; the hub grid gets the shell. */
  --measure: 46rem;
  --shell: 72rem;
  --max: var(--measure);

  --font-display: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-text: 'Source Serif 4', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }

html {
  background: var(--night-deep);
}
body {
  margin: 0;
  padding: 0;
  position: relative;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-text);
  line-height: 1.6;
}

/* Live background. Two fixed, non-interactive layers behind everything: a slow dusk wash that
   drifts, and a still starfield that breathes. Both are transform/opacity only so they stay on
   the compositor, and both are switched off by the reduced-motion block at the end of the file. */
body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -1;
  pointer-events: none;
}
body::before {
  inset: -25%;
  background:
    radial-gradient(55% 40% at 50% 100%, rgba(232, 184, 75, 0.20), transparent 70%),
    radial-gradient(45% 35% at 12% 8%, rgba(70, 110, 180, 0.20), transparent 70%),
    radial-gradient(40% 30% at 88% 18%, rgba(150, 88, 56, 0.16), transparent 70%);
  animation: fsy-drift 54s ease-in-out infinite alternate;
  will-change: transform;
}
body::after {
  inset: 0;
  background-image:
    radial-gradient(1.4px 1.4px at 12% 18%, rgba(242, 234, 216, 0.55), transparent 60%),
    radial-gradient(1.2px 1.2px at 28% 9%, rgba(242, 234, 216, 0.40), transparent 60%),
    radial-gradient(1.6px 1.6px at 44% 24%, rgba(232, 184, 75, 0.45), transparent 60%),
    radial-gradient(1.2px 1.2px at 63% 12%, rgba(242, 234, 216, 0.45), transparent 60%),
    radial-gradient(1.5px 1.5px at 79% 27%, rgba(242, 234, 216, 0.38), transparent 60%),
    radial-gradient(1.2px 1.2px at 91% 14%, rgba(232, 184, 75, 0.40), transparent 60%),
    radial-gradient(1.3px 1.3px at 20% 41%, rgba(242, 234, 216, 0.30), transparent 60%),
    radial-gradient(1.1px 1.1px at 71% 45%, rgba(242, 234, 216, 0.26), transparent 60%);
  animation: fsy-breathe 11s ease-in-out infinite alternate;
}
@keyframes fsy-drift {
  from { transform: translate3d(-2%, -1.5%, 0) scale(1.02); }
  to { transform: translate3d(2%, 1.5%, 0) scale(1.09); }
}
@keyframes fsy-breathe {
  from { opacity: 0.45; }
  to { opacity: 1; }
}

a { color: var(--gold); }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--gold);
  color: var(--night-deep);
  padding: 0.5rem 0.8rem;
  z-index: 2;
}
.skip:focus { top: 1rem; }

/* The unofficial notice stays the first element in reading order. It is
   restyled as a designed note rather than relocated: its position is a
   prominence decision, not a layout one. */
/* The notice now sits in the footer rather than above the masthead. */
.banner {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  background: rgba(33, 22, 15, 0.75);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  color: var(--ink-dim);
  font-size: 0.82rem;
  line-height: 1.45;
}
.banner-label {
  display: block;
  color: var(--gold);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}
.banner-text { display: block; max-width: var(--measure); }

.wrap { max-width: var(--max); margin: 0 auto; padding: 1.25rem; }

/* .lesson-grid exists only on the hub, so :has() is a reliable hub-only hook
   and no flag has to be threaded through layout(). Without :has() support the
   shell stays at the measure, which still yields a usable single column. */
.wrap:has(.lesson-grid) { max-width: var(--shell); }
.wrap:has(.lesson-grid) main > :not(.lesson-grid):not(.grid-note):not(figure) {
  max-width: var(--measure);
}

header.site {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 1rem;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.4rem;
  letter-spacing: 0.02em;
}
.brand small {
  display: block;
  color: var(--ink-dim);
  font-size: 0.85rem;
  font-weight: normal;
}

nav.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
nav.site-nav a {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
}

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: 0.01em;
}
h1 {
  /* fluid: 32px was rendering at every viewport, too large at 360px and too
     small at 1440px */
  font-size: clamp(2rem, 1.5rem + 2.3vw, 3.25rem);
  margin: 0.4rem 0 0.8rem;
  text-wrap: balance;
}
h2 { font-size: clamp(1.25rem, 1.12rem + 0.6vw, 1.5rem); }
.lede { font-size: 1.15rem; color: var(--sand); }

/* The UA figure margin was indenting the art 40px, rendering it narrower than
   every text block around it. */
figure { margin: 0 0 1.5rem; }

.hero-art, .lesson-art {
  width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  display: block;
}
.search label { display: block; margin-bottom: 0.35rem; }
.search input {
  width: 100%;
  min-height: 48px;
  padding: 0.6rem 0.8rem;
  background: var(--night);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  font: inherit;
  transition: border-color var(--dur-2) var(--ease-out);
}
.search input:focus { border-color: var(--gold); }

.lesson-grid {
  display: grid;
  /* min() guard: a bare 19rem floor overflows a 320px viewport */
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  gap: clamp(0.75rem, 2vw, 1.25rem);
  margin: 1.5rem 0;
}
.lesson-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  background: var(--night);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
  min-height: 48px;
  box-shadow: inset 0 1px 0 rgb(242 234 216 / 0.06);
  transition:
    border-color var(--dur-2) var(--ease-out),
    background-color var(--dur-2) var(--ease-out),
    box-shadow var(--dur-2) var(--ease-out);
}
.lesson-card[hidden] { display: none; }
.card-art {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-bottom: 1px solid var(--rule);
}
.card-body { padding: 1rem; }
.card-body h2 { margin: 0.15rem 0 0.5rem; }
.card-body p:last-child { margin-bottom: 0; }

@media (hover: hover) and (pointer: fine) {
  .lesson-card:hover {
    border-color: var(--gold);
    background: #22345c;
    /* a black drop shadow is invisible on #101a30; the gold ring does the work */
    box-shadow: 0 6px 18px rgb(0 0 0 / 0.35), 0 0 0 1px rgb(232 184 75 / 0.35);
  }
}
/* hover never fires on touch, and sticks when it does; :active is the state
   that actually reaches a phone */
.lesson-card:active { border-color: var(--gold); background: #16233f; }

.grid-note {
  color: var(--ink-dim);
  font-size: 0.85rem;
  margin: 0 0 1.5rem;
}
.kicker {
  color: var(--gold);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0;
}
.lesson-card .kicker {
  color: var(--gold);
}
.empty-search { color: var(--ink-dim); }

.quote {
  background: var(--night);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.9rem 1.1rem;
  margin: 1rem 0;
  /* Scripture gets the largest body size on the page. Styling is applied to
     the blockquote only; the verse text itself carries no markup. */
  font-size: 1.05rem;
}
.quote p { margin: 0; }
.quote cite {
  display: block;
  margin-top: 0.5rem;
  color: var(--gold);
  font-style: normal;
  font-size: 0.95rem;
}

.chapter-list { padding-left: 1.2rem; }
.chapter-list { list-style: none; padding-left: 0; }
/* direct children only: the nested topic chips must not inherit the row rule */
.chapter-list > li {
  border-top: 1px solid var(--rule);
  padding: 0.75rem 0;
}
.chapter-list > li:last-child { border-bottom: 1px solid var(--rule); }
.chapter-ref {
  display: inline-block;
  font-weight: 700;
  color: var(--gold);
  text-decoration: none;
  margin-right: 0.4rem;
}
.chapter-ref:hover { text-decoration: underline; }

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin: 1.25rem 0;
}

/* The game's own control, matching #menu-play in src/ui/ui.css, so the
   companion and the product share one object rather than two similar ones. */
.cta-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.7rem 1.15rem;
  background: linear-gradient(180deg, #f5d98a, var(--gold));
  color: var(--night-deep);
  border: 0;
  border-radius: 7px;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.45), inset 0 1px 0 rgb(255 255 255 / 0.35);
  font-weight: 700;
  text-decoration: none;
  transition:
    transform var(--dur-1) var(--ease-out),
    box-shadow var(--dur-2) var(--ease-out);
}
.cta-primary::before {
  content: "";
  flex: none;
  width: 0;
  height: 0;
  border-left: 9px solid currentColor;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}
@media (hover: hover) and (pointer: fine) {
  .cta-primary:hover {
    box-shadow:
      0 8px 20px -10px rgb(232 184 75 / 0.65),
      inset 0 1px 0 rgb(255 255 255 / 0.35);
  }
}
.cta-primary:active { transform: translateY(0) scale(0.985); }

.official-link, .play-link, button.choice, .back {
  min-height: 48px;
  min-width: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 0.9rem;
  text-decoration: none;
}
.official-link {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  transition: border-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out);
}
.official-link:hover { border-color: var(--gold); color: var(--gold); }
.play-link {
  background: var(--gold);
  color: var(--night-deep);
  border-radius: var(--radius-sm);
  margin: 0.25rem 0.5rem 0.25rem 0;
  font-weight: 700;
}

/* The section the light does not reach: this is where the companion says what
   it could not substantiate, and it should read as a footnote apparatus. */
.join-notes {
  background: #0d1526;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin: 1.5rem 0;
  color: var(--ink-dim);
}
.join-notes h2 {
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 0 0 0.5rem;
}
.join-note-list { list-style: none; padding: 0; margin: 0; }
.join-note-list li {
  position: relative;
  padding-left: 1.4rem;
  margin-bottom: 0.5rem;
}
.join-note-list li:last-child { margin-bottom: 0; }
.join-note-list li::before {
  content: "\2020" / "";
  position: absolute;
  left: 0;
  color: var(--gold);
}

/* Cross-links between topics that share a playable chapter or a quoted chapter. */
.related {
  border-top: 1px solid var(--rule);
  padding-top: 1.25rem;
  margin: 2rem 0 0;
}
.related h2 {
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 0 0 0.6rem;
}
.related-list { list-style: none; padding: 0; margin: 0; }
.related-list li { margin-bottom: 0.45rem; color: var(--ink-dim); }
.related-list li:last-child { margin-bottom: 0; }
.related-list a { font-weight: 700; text-decoration: none; }
.related-list a:hover { text-decoration: underline; }

/* Topics that point at one chapter, on the chapter index. */
.chapter-topics {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.chapter-topics li { margin: 0; }
.chapter-topics a {
  display: inline-block;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--ink);
  text-decoration: none;
  transition: border-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out);
}
.chapter-topics a:hover { border-color: var(--gold); color: var(--gold); }

.quiz {
  background: var(--night);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: clamp(0.9rem, 3vw, 1.25rem);
  margin: 1.5rem 0;
}
.quiz fieldset {
  border: 0;
  margin: 0 0 1.5rem;
  padding: 0;
  min-inline-size: 0;
}
.quiz fieldset:last-of-type { margin-bottom: 0; }
/* float, not display:block: block is already the UA value and the legend still
   straddles the border box. Floating removes it from that model while keeping
   it as the fieldset's accessible name. */
.quiz legend {
  float: left;
  width: 100%;
  padding: 0;
  margin: 0 0 0.6rem;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
  text-wrap: balance;
}
.choices { clear: both; display: grid; gap: 0.6rem; margin: 0; }
button.choice {
  justify-content: flex-start;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  background: var(--night-deep);
  color: var(--ink);
  border: 1px solid var(--sand);
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  cursor: pointer;
  transition:
    border-color var(--dur-2) var(--ease-out),
    background-color var(--dur-2) var(--ease-out),
    opacity var(--dur-2) var(--ease-out);
}
button.choice[aria-pressed="true"] { border-color: var(--gold); }
button.choice:disabled { cursor: default; }
[data-graded] button.choice:disabled:not(.is-correct):not(.is-wrong) { opacity: 0.6; }
button.choice.is-correct {
  background: #1d3324;
  border-color: var(--ok);
  border-left-color: var(--ok);
}
button.choice.is-wrong {
  background: #33221c;
  border-color: var(--danger);
  border-left-color: var(--danger);
}
/* the mark survives greyscale and colour-vision deficiency; the empty alt text
   keeps it out of the accessibility tree, where the feedback line already says it */
button.choice.is-correct::after {
  content: "\2713" / "";
  margin-left: auto;
  color: var(--ok);
}
button.choice.is-wrong::after {
  content: "\2717" / "";
  margin-left: auto;
  color: var(--danger);
}
/* most of the dead space under each question was the empty paragraph's UA
   margins, not the reserved feedback height; reserve nothing until it is used */
.feedback { margin: 0; min-height: 0; }
[data-question][data-graded] .feedback { margin-top: 0.75rem; min-height: 1.5rem; }
.score {
  margin-top: 1rem;
  color: var(--sand);
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 2rem 0 1rem;
  border-top: 1px solid var(--rule);
  padding-top: 1.25rem;
}

footer {
  border-top: 1px solid var(--rule);
  padding-top: 1rem;
  color: var(--ink-dim);
  font-size: 0.95rem;
}

/* transform is not cancelled by transition:none, so motion that moves an
   element is gated positively rather than relying on the escape hatch below */
/* Thirteen full-width images make the phone hub 7,600px of scrolling. A
   horizontal card keeps the art and roughly halves the scroll. */
@media (max-width: 39.99rem) {
  .lesson-card { flex-direction: row; align-items: stretch; }
  .card-art {
    flex: none;
    width: 33%;
    max-width: 140px;
    aspect-ratio: 1 / 1;
    border-bottom: 0;
    border-right: 1px solid var(--rule);
  }
  .card-body { padding: 0.8rem 0.9rem; }
}

@media (prefers-reduced-motion: no-preference) {
  @media (hover: hover) and (pointer: fine) {
    .lesson-card { transition-property: border-color, background-color, box-shadow, transform; }
    .lesson-card:hover { transform: translateY(-2px); }
    .cta-primary:hover { transform: translateY(-2px); }
  }
  .lesson-card:active { transform: translateY(0); }
}

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