:root {
  --bg: #16110e;
  --surface: #241b16;
  --line: #3a2d24;
  --ink: #f1e3cb;
  --muted: #c4ad8c;
  --accent: #e8b870;
  --dot: #4a3a2f;
  --bible-bg: #0e1418;
  --bible-paper: #18232a;
  --bible-gold: #cfae66;
  --bible-gold-soft: #6f5e3c;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: clamp(1.3rem, 1.1rem + 1vw, 1.6rem);
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

.book {
  flex: 1;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  outline: none;
}

.book::-webkit-scrollbar {
  display: none;
}

.page {
  flex: 0 0 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.sheet {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.how-to-read {
  max-width: 36rem;
  margin: 0;
  padding: 0.5rem 16px;
  color: var(--muted);
  font-family: system-ui, sans-serif;
  font-size: max(0.62em, 12px);
  line-height: 1.4;
  text-align: center;
}

.art {
  display: block;
  width: 100%;
  max-width: min(900px, calc(55dvh * 4 / 3));
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--surface);
}

.words {
  width: 100%;
  max-width: 36rem;
  padding: 1.25rem 16px 2rem;
}

.heading {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.8em;
  font-style: italic;
  font-weight: normal;
}

.text {
  margin: 0 0 1.25rem;
}

.do {
  margin: 0;
  padding: 0.8rem 1rem;
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  background: var(--surface);
  font-size: 0.92em;
}

.do-label,
.end h2 {
  display: block;
  margin: 0 0 0.3rem;
  color: var(--accent);
  font-family: system-ui, sans-serif;
  font-size: 0.62em;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Pages 2–4: the Bible story Mom tells, framed as a storybook inside the story. */
.page.bible {
  background: var(--bible-bg);
}

.bible .sheet {
  width: min(calc(100% - 24px), 40rem);
  margin: 12px 12px 20px;
  padding: 10px 10px 0;
  border: 2px solid var(--bible-gold);
  border-radius: 8px;
  background: var(--bible-paper);
  box-shadow:
    inset 0 0 0 4px var(--bible-paper),
    inset 0 0 0 5px var(--bible-gold-soft),
    0 10px 30px rgb(0 0 0 / 0.45);
}

.sheet-label {
  margin: 4px 0 0;
  color: var(--bible-gold);
  font-family: system-ui, sans-serif;
  font-size: 0.55em;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.sheet-label::before,
.sheet-label::after {
  content: "✦";
  margin: 0 0.6em;
  font-size: 0.9em;
}

.sheet-ref {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.7em;
  font-style: italic;
}

.bible .art {
  max-width: min(100%, calc(48dvh * 4 / 3));
  border-radius: 4px;
}

.bible .words {
  padding: 1rem 8px 1.25rem;
}

.bible .heading,
.bible .do-label {
  color: var(--bible-gold);
}

.bible .do {
  border-left-color: var(--bible-gold);
  background: rgb(0 0 0 / 0.22);
}

.end .words {
  padding-top: 2rem;
}

.end h2:not(:first-child) {
  margin-top: 2rem;
}

.verse {
  margin: 0;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.verse p {
  margin: 0 0 0.6rem;
  font-size: 1.08em;
}

.verse footer {
  color: var(--muted);
  font-size: 0.75em;
}

.verse cite {
  font-style: normal;
  font-weight: 700;
}

.talk {
  margin: 0;
  padding-left: 1.2em;
}

.talk li + li {
  margin-top: 0.6rem;
}

.pray {
  margin: 0;
}

.finish {
  flex: 0 1 auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.35rem 1.1rem;
  border-radius: 24px;
  background: var(--accent);
  color: #1d1510;
  font: 700 0.95rem/1.2 system-ui, sans-serif;
  text-align: center;
  text-decoration: none;
}

.finish[hidden] {
  display: none;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0.5rem 16px calc(0.5rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}

.turn {
  flex: none;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font: 1.8rem/1 system-ui, sans-serif;
  cursor: pointer;
}

.turn:disabled {
  opacity: 0.25;
  cursor: default;
}

.dots {
  display: flex;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dots li {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--dot);
  transition: background 0.2s, transform 0.2s;
}

.dots li.on {
  background: var(--accent);
  transform: scale(1.3);
}

.invite {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line, rgba(255,255,255,.12));
  font-family: system-ui, sans-serif;
  font-size: 0.8em;
  text-align: center;
}
.invite p { margin: 0 0 0.75rem; }
.next-btn {
  display: inline-block;
  padding: 0.7rem 1.2rem;
  border-radius: 10px;
  background: var(--accent);
  color: #1d1510;
  font-weight: 700;
  text-decoration: none;
}
.learn-more {
  display: block;
  width: fit-content;
  margin: 0.5rem auto 0;
  padding: 0.5rem;
  color: var(--muted);
  text-underline-offset: 3px;
}

/* A family's nightly story is read in a dark bedroom, so its pictures are dimmed and a page turn doesn't flash
   bright. One button on the first page switches to a light page with the pictures as drawn. */
[data-bedtime]:not([data-light]) .art {
  filter: brightness(0.7);
}

:root[data-light] {
  --bg: #fbf5ea;
  --surface: #f1e7d6;
  --line: #d8c9b0;
  --ink: #1d1510;
  --muted: #5e4b35;
  --accent: #8a5a12;
  --dot: #d8c9b0;
  --bible-bg: #f1e7d6;
  --bible-paper: #fffaf0;
  --bible-gold: #8a6d2c;
  --bible-gold-soft: #d3bf94;
  color-scheme: light;
}

[data-light] .finish {
  color: #fffaf0;
}

[data-light] .bible .sheet {
  box-shadow:
    inset 0 0 0 4px var(--bible-paper),
    inset 0 0 0 5px var(--bible-gold-soft),
    0 6px 18px rgb(60 40 20 / 0.18);
}

[data-light] .bible .do {
  background: var(--surface);
}

.home-link {
  align-self: flex-start;
  padding: calc(12px + env(safe-area-inset-top)) 20px 10px 16px;
  color: var(--muted);
  font: 14px/1.4 system-ui, sans-serif;
  text-decoration: none;
}

.light-switch {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

@media (max-width: 480px) {
  .controls.at-end .dots {
    display: none;
  }
}

@media (max-height: 860px) {
  body {
    font-size: clamp(1.05rem, 0.9rem + 1vw, 1.3rem);
  }

  .words {
    padding: 0.9rem 16px 1.25rem;
  }

  .bible .sheet {
    margin: 8px 8px 12px;
    padding-top: 6px;
  }

  .sheet-ref {
    margin-bottom: 6px;
  }

  .bible .words {
    padding: 0.6rem 6px 0.9rem;
  }
}

/* Turned sideways, each page opens like a book: the picture on the left, the words on the right. */
@media screen and (orientation: landscape) and (min-aspect-ratio: 4/3) {
  .page {
    container-type: size;
  }

  .sheet {
    --art: min(calc((100cqh - 24px) * 4 / 3), 46cqw, 900px);
    display: grid;
    grid-template-columns: var(--art) minmax(0, 34rem);
    grid-template-rows: 1fr auto auto auto 1fr;
    justify-content: center;
    column-gap: clamp(16px, 3vw, 48px);
    margin-block: auto;
    padding: 12px clamp(16px, 3vw, 48px);
  }

  .sheet-label {
    grid-area: 2 / 1;
  }

  .sheet-ref {
    grid-area: 3 / 1;
  }

  .art {
    grid-area: 4 / 1;
    max-width: none;
  }

  .words,
  .bible .words {
    grid-area: 1 / 2 / 6;
    align-self: center;
    padding: 0;
  }

  .how-to-read {
    grid-area: 2 / 2;
    max-width: none;
    padding: 0 0 0.6rem;
    text-align: left;
  }

  .page:first-child .art {
    grid-area: 1 / 1 / 6;
    align-self: center;
  }

  .page:first-child .words {
    grid-area: 3 / 2;
  }

  .bible .sheet {
    --art: min(calc((100cqh - 90px) * 4 / 3), 44cqw, 900px);
    width: auto;
    margin: auto 12px;
    padding: 8px clamp(12px, 2vw, 32px) 12px;
  }
}

/* A phone on its side has very little height, so everything gets tighter. */
@media screen and (orientation: landscape) and (max-height: 500px) {
  body {
    font-size: 0.95rem;
    line-height: 1.45;
  }

  .text {
    margin-bottom: 0.7rem;
  }

  .do {
    padding: 0.5rem 0.8rem;
  }

  .sheet {
    padding-block: 4px;
  }

  .bible .sheet {
    padding-top: 4px;
    padding-bottom: 8px;
  }

  .sheet-ref {
    margin-bottom: 4px;
  }

  .how-to-read {
    padding-block: 0 4px;
  }

  .controls {
    padding-block: 4px calc(4px + env(safe-area-inset-bottom));
  }

  .turn {
    width: 40px;
    height: 40px;
  }

  .finish {
    min-height: 40px;
  }
}

@media print {
  :root {
    --bg: #fff;
    --surface: #f7f1e6;
    --line: #d8c9b0;
    --ink: #1d1510;
    --muted: #5e4b35;
    --accent: #8a5a12;
    --bible-bg: #fff;
    --bible-paper: #fff;
    --bible-gold: #8a6d2c;
    --bible-gold-soft: #d3bf94;
    color-scheme: light;
  }

  html,
  body {
    height: auto;
  }

  body {
    display: block;
    overflow: visible;
    font-size: 15pt;
  }

  .controls,
  .invite,
  .light-switch,
  .home-link {
    display: none;
  }

  .art {
    filter: none !important;
  }

  .book,
  .page {
    display: block;
    overflow: visible;
  }

  .page {
    break-after: page;
  }

  .page:last-child {
    break-after: auto;
  }

  .art {
    max-width: 15cm !important;
  }

  .bible .art {
    max-width: 12cm !important;
  }

  .words,
  .bible .sheet {
    margin-inline: auto;
  }

  .bible .sheet {
    box-shadow: none;
  }

  .bible .do {
    background: var(--surface);
  }
}
