/* Light & Dark online reader. Horizontal scroll-snap; no library.
   Portrait: one page per screen. Landscape / wide: the printed spread. */

:root {
  --navy-deep: #0f1526;
  --gold-pale: #fff3c4;
  --bar: 2.75rem;
}

* { box-sizing: border-box; }

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

body {
  font-family: "Nunito", system-ui, sans-serif;
  background: var(--navy-deep);
  color: var(--gold-pale);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.bar {
  flex: 0 0 var(--bar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 max(12px, env(safe-area-inset-left)) 0 max(12px, env(safe-area-inset-right));
  padding-top: env(safe-area-inset-top);
  font-weight: 800;
  font-size: 0.95rem;
}
.bar__link {
  color: inherit;
  text-decoration: none;
  background: none;
  border: 0;
  font: inherit;
  padding: 0.5rem 0.25rem;
  min-width: 6.5rem;
  cursor: pointer;
}
.bar__link:last-child { text-align: right; }
.bar__count { font-weight: 600; opacity: 0.85; font-variant-numeric: tabular-nums; }

/* ---------- the scroller ---------- */

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

.page {
  flex: 0 0 auto;
  display: block;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

/* Portrait (phones): each page is a full-width snap point. */
@media (orientation: portrait) {
  .spread { display: contents; }
  .page {
    width: 100vw;
    height: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }
}

/* Landscape / wide: the spread is the snap point, pages sit side by side at full height. */
@media (orientation: landscape) {
  .spread {
    flex: 0 0 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    height: 100%;
  }
  .page {
    width: auto;
    height: 100%;
    max-width: 50%;
  }
  /* Single-page spreads (the covers) sit centred. */
  .spread--single .page { max-width: 100%; }
}

/* ---------- tap zones ---------- */

.turn {
  position: fixed;
  top: var(--bar);
  bottom: 0;
  width: 22%;
  background: transparent;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.turn--prev { left: 0; }
.turn--next { right: 0; }
.turn:focus-visible { outline: 3px solid var(--gold-pale); outline-offset: -6px; }

@media (prefers-reduced-motion: reduce) {
  .book { scroll-behavior: auto; }
}
