/* The web reader (templates/reader.js): a bar fixed to the top of every edition, zoom that leaves the bar alone,
   and on wide screens a book you turn a spread at a time. Sizes here are in px on purpose: the paper's own rules
   change the root size, and the zoom tools scale only the paper, so the bar stays the same size whatever happens.
   Screen only; the print edition never sees any of it. */
@media screen {
  .reader-bar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000; height: 46px; box-sizing: border-box;
    display: flex; align-items: center; gap: 14px; padding: 0 14px;
    background: #1c1b18; color: #eeebe2; box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
    font-family: var(--f-head, "Oswald", system-ui, sans-serif); font-weight: 500; font-size: 13px; line-height: 1;
    letter-spacing: .1em; text-transform: uppercase;
  }
  .reader-bar a, .reader-bar button { color: #eeebe2; text-decoration: none; font: inherit; letter-spacing: inherit; text-transform: inherit; }
  .reader-bar a:hover { color: #f2b8a8; }
  .reader-bar .rb-title { white-space: nowrap; font-weight: 600; }
  .reader-bar .rb-title a { color: #fff; }
  .reader-bar .rb-links { display: flex; gap: 14px; white-space: nowrap; overflow-x: auto; scrollbar-width: none; flex: 1 1 auto; min-width: 0; }
  .reader-bar .rb-links::-webkit-scrollbar { display: none; }
  .reader-bar .rb-tools { display: flex; align-items: center; gap: 6px; margin-left: auto; flex: 0 0 auto; }
  .reader-bar button {
    background: #3a3833; border: 1px solid #55514a; border-radius: 4px; height: 30px; min-width: 30px; padding: 0 9px;
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  }
  .reader-bar button:hover:not(:disabled) { background: #4d4a43; }
  .reader-bar button:disabled { opacity: .35; cursor: default; }
  .reader-bar .rb-sep { width: 1px; height: 22px; background: #55514a; margin: 0 4px; }
  .reader-bar .rb-pages { min-width: 96px; text-align: center; white-space: nowrap; font-size: 12px; }
  .reader-bar .rb-zoom { min-width: 44px; text-align: center; font-size: 12px; }
  .reader-bar .rb-book-only { display: none; }
  html.reader-book .reader-bar .rb-book-only { display: inline-flex; }
  html.reader-wide .reader-bar .rb-wide-only { display: inline-flex; }
  .reader-bar .rb-wide-only { display: none; }

  /* The old bar above page one: its links now live in the fixed bar. */
  .edition-bar { display: none !important; }
  body { padding-top: 58px !important; }
  /* Anchors land below the bar, not under it. */
  .sheet, [id^="p"] { scroll-margin-top: 58px; }

  /* Narrow screens: the bar keeps the essentials, the links scroll sideways. */
  @media (max-width: 999px) {
    .reader-bar { height: auto; flex-wrap: wrap; gap: 8px 10px; padding: 8px 10px; font-size: 12px; letter-spacing: .06em; }
    .reader-bar .rb-title .rb-long { display: none; }
    .reader-bar .rb-links { order: 3; flex: 1 0 100%; padding-bottom: 2px; }
    .reader-bar button { height: 28px; min-width: 28px; padding: 0 8px; }
    body { padding-top: 92px !important; }
    html, body { overflow-x: hidden; }  /* a stray wide element must not widen the page past the phone (it did, to 724px) */
    .sheet, [id^="p"] { scroll-margin-top: 92px; }
  }

  /* ---------- The book (wide screens) ---------- */
  html.reader-book, html.reader-book body { overflow: hidden; height: 100%; }
  html.reader-book body { padding: 0 !important; }
  html.reader-book body > .sheet { display: none; }
  .reader-book-view { display: none; }
  html.reader-book .reader-book-view {
    display: block; position: fixed; top: 46px; left: 0; right: 0; bottom: 0; overflow: auto;
    background: var(--desk, #c8c3b7);
  }
  .rbv-frame { margin: 0 auto; position: relative; }
  .rbv-stage { position: absolute; top: 0; left: 0; transform-origin: 0 0; perspective: 3200px; }
  .rbv-slot, .rbv-leaf { position: absolute; top: 0; width: 210mm; height: 297mm; }
  .rbv-slot.l, .rbv-leaf.from-l { left: 0; }
  .rbv-slot.r, .rbv-leaf.from-r { left: 210mm; }
  .rbv-slot > .sheet, .rbv-face > .sheet {
    transform: none !important; margin: 0 !important;  /* display stays the paper's own (a flex column in print) */
    box-shadow: 0 14px 34px -20px var(--shadow, rgba(30, 25, 15, .35));
  }
  .rbv-slot.l > .sheet { box-shadow: inset -18px 0 22px -20px rgba(0, 0, 0, .35), 0 14px 34px -20px rgba(30, 25, 15, .35); }
  .rbv-slot.r > .sheet { box-shadow: inset 18px 0 22px -20px rgba(0, 0, 0, .35), 0 14px 34px -20px rgba(30, 25, 15, .35); }
  .rbv-leaf { transform-style: preserve-3d; z-index: 5; transition: transform var(--rbv-turn, 700ms) cubic-bezier(.45, .05, .3, 1); }
  .rbv-leaf.from-r { transform-origin: 0 50%; }
  .rbv-leaf.from-l { transform-origin: 100% 50%; }
  .rbv-leaf.from-r.turned { transform: rotateY(-180deg); }
  .rbv-leaf.from-l.turned { transform: rotateY(180deg); }
  .rbv-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; }
  .rbv-face.back { transform: rotateY(180deg); }
  .rbv-arrow {
    position: fixed; top: 50%; z-index: 900; transform: translateY(-50%);
    width: 44px; height: 88px; border: 0; border-radius: 6px; cursor: pointer;
    background: rgba(28, 27, 24, .55); color: #eeebe2; font-size: 28px; line-height: 88px; text-align: center;
  }
  .rbv-arrow:hover:not(:disabled) { background: rgba(28, 27, 24, .8); }
  .rbv-arrow:disabled { opacity: 0; cursor: default; }
  .rbv-arrow.prev { left: 10px; }
  .rbv-arrow.next { right: 10px; }
  @media (prefers-reduced-motion: reduce) { .rbv-leaf { transition: none; } }
}
@media print {
  .reader-bar, .reader-book-view, .rbv-arrow { display: none !important; }
}
