/* The book preview dialog (book-reader.js). */
html.rd-lock { overflow: hidden; }

.rd {
  --rd-bar: rgba(6, 16, 31, 0.0);
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  display: none; color: var(--on-night); font-family: var(--sans); overflow: hidden;
  background:
    radial-gradient(1200px 700px at 50% 45%, #15294a 0%, #0a1830 45%, #050c18 100%);
}
.rd[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); }
.rd-top { grid-area: 1 / 1; }
.rd-stage { grid-area: 2 / 1; }
.rd-bottom { grid-area: 3 / 1; }
.rd::backdrop { background: rgba(3, 8, 16, 0.86); }
.rd:fullscreen { width: 100%; height: 100%; }

/* Top bar */
.rd-top {
  display: flex; align-items: center; gap: 16px; padding: 12px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  padding-top: max(12px, env(safe-area-inset-top));
}
.rd-heading { flex: 1; min-width: 0; }
.rd-kicker { font-size: 11.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--trace); }
.rd-title { margin-top: 3px; font-family: var(--serif); font-size: clamp(16px, 1.6vw, 20px); font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.005em; }
.rd-tools { display: flex; align-items: center; gap: 6px; flex: none; }
.rd-icon, .rd-nav {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 1px solid transparent; padding: 0;
  background: rgba(255, 255, 255, 0.06); color: var(--on-night); cursor: pointer; transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.rd-icon:hover:not(:disabled), .rd-nav:hover:not(:disabled) { background: rgba(255, 255, 255, 0.14); color: #fff; }
.rd-icon:active:not(:disabled), .rd-nav:active:not(:disabled) { transform: scale(0.94); }
.rd-icon:disabled, .rd-nav:disabled { opacity: 0.32; cursor: default; }
.rd-icon[aria-pressed="true"] { background: var(--trace); color: #04231f; }
.rd svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rd-close { margin-left: 4px; }
.rd-buy {
  display: inline-flex; align-items: center; gap: 2px; height: 40px; padding: 0 16px; margin-right: 6px; border-radius: 999px;
  background: var(--trace); color: #04231f; font-size: 14.5px; font-weight: 700; text-decoration: none; white-space: nowrap; transition: background 0.15s ease;
}
.rd-buy:hover { background: #8df3e2; }
.rd-buy svg { width: 16px; height: 16px; margin-left: 6px; }
.rd :focus-visible { outline: 3px solid #f4b740; outline-offset: 2px; }
.rd-icon:focus-visible, .rd-nav:focus-visible { border-radius: 50%; }

/* Stage and pages */
.rd .rd-stage:focus-visible { outline: none; }
.rd-stage { position: relative; min-height: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; outline: none; }
.rd-stage[data-zone="next"], .rd-stage[data-zone="prev"] { cursor: pointer; }
.rd-stage[data-zone="page"] { cursor: zoom-in; }
.rd-book { position: absolute; inset: 0; }
.rd-page {
  position: absolute; overflow: hidden; background: #fdfcf9 center / cover no-repeat;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}
.rd-page > img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; opacity: 0; transition: opacity 0.35s ease; pointer-events: none; }
.rd-page > img.is-loaded { opacity: 1; }
/* The low-resolution page shows blurred until the full page arrives. */
.rd-page:not(:has(> img.is-loaded))::before { content: ""; position: absolute; inset: 0; backdrop-filter: blur(6px); }
/* The gutter: pages darken slightly toward the spine. */
.is-spread .rd-page::after { content: ""; position: absolute; top: 0; bottom: 0; width: 9%; pointer-events: none; }
.is-spread .rd-left::after { right: 0; background: linear-gradient(270deg, rgba(16, 24, 38, 0.20), rgba(16, 24, 38, 0.07) 35%, rgba(16, 24, 38, 0)); }
.is-spread .rd-right::after { left: 0; background: linear-gradient(90deg, rgba(16, 24, 38, 0.20), rgba(16, 24, 38, 0.07) 35%, rgba(16, 24, 38, 0)); }
.rd-page.is-end { background: #fdfcf9; }
.rd-page.is-end::before { display: none; }
.rd-page.is-end::after { display: none; }
.rd-book.is-turning .rd-page { visibility: hidden; }
.rd-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; visibility: hidden; }
.rd-canvas.is-on { visibility: visible; }

/* End of the preview */
.rd-end {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 8% 9%; color: var(--ink); overflow: auto;
}
.rd-end > * { animation: rd-rise 0.5s cubic-bezier(.2, .7, .2, 1) both; }
.rd-end > :nth-child(2) { animation-delay: 0.05s; }
.rd-end > :nth-child(3) { animation-delay: 0.1s; }
.rd-end > :nth-child(4) { animation-delay: 0.15s; }
.rd-end > :nth-child(5) { animation-delay: 0.2s; }
.rd-end > :nth-child(6) { animation-delay: 0.25s; }
@keyframes rd-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.rd-end-cover { width: clamp(56px, 18%, 84px); height: auto; border-radius: 2px 4px 4px 2px; box-shadow: 0 10px 22px -8px rgba(16, 29, 46, 0.45), 0 0 0 1px rgba(16, 29, 46, 0.08); }
.rd-end-kicker { margin-top: clamp(12px, 3%, 22px); font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--blue); }
.rd-end h3 { margin-top: 8px; font-size: clamp(22px, 2.4vw, 30px); max-width: 12em; }
.rd-end-text { margin-top: 10px; color: var(--muted); font-size: clamp(14px, 1.2vw, 16px); max-width: 22em; }
.rd-end-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: clamp(16px, 4%, 26px); }
.rd-end .btn { min-height: 44px; padding: 0 18px; font-size: 15px; gap: 8px; cursor: pointer; font-family: var(--sans); }
.rd-end .btn svg { width: 17px; height: 17px; }
.rd-end-buy { background: var(--ink); color: #fff; }
.rd-end-buy:hover { background: var(--blue-deep); }
.rd-end-again { background: #fff; color: var(--ink); border-color: var(--line); }
.rd-end-again:hover { border-color: var(--ink); }
.rd-end-other { margin-top: 14px; border: 0; background: none; padding: 6px 4px; font: 650 14px var(--sans); color: var(--blue); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.rd-end :focus-visible { outline-color: var(--blue); }

/* Bottom bar: status, page buttons and the scrubber */
.rd-bottom {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "status status status" "prev scrub next";
  align-items: center; column-gap: 14px; row-gap: 6px;
  padding: 4px max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  width: min(100%, 1040px); margin: 0 auto;
}
.rd-status { grid-area: status; text-align: center; font-size: 13.5px; font-weight: 650; color: var(--on-night-muted); font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.rd-bottom > .rd-nav:first-of-type { grid-area: prev; }
.rd-bottom > .rd-nav:last-of-type { grid-area: next; }
.rd-scrub { grid-area: scrub; position: relative; height: 44px; display: flex; align-items: center; }
.rd-film { display: none; }
.rd-range {
  -webkit-appearance: none; appearance: none; width: 100%; height: 44px; margin: 0; background: transparent; cursor: pointer;
}
.rd-range::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.16); }
.rd-range::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.16); }
.rd-range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: var(--trace); border: 3px solid #0a1830; box-shadow: 0 0 0 1px var(--trace); }
.rd-range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--trace); border: 3px solid #0a1830; }
.rd-range:focus-visible { outline: none; }
.rd-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px #f4b740; }
.rd-range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px #f4b740; }

/* Wide screens: the scrubber is a strip of page thumbnails with a window on the current view. */
@media (min-width: 760px) and (min-height: 560px) {
  .rd-scrub { height: 52px; }
  .rd-film { position: absolute; inset: 4px 0; display: flex; align-items: center; justify-content: space-between; gap: 3px; pointer-events: none; }
  .rd-film-view { display: flex; gap: 1px; height: 100%; flex: 2 1 0; justify-content: center; min-width: 0; }
  .rd-film-view.is-half { flex-grow: 1; }
  .rd-film-view img, .rd-film-view .rd-film-end {
    height: 100%; width: auto; aspect-ratio: var(--rd-aspect, 0.77); min-width: 0; object-fit: cover; border-radius: 1px; opacity: 0.5; background: #fdfcf9;
  }
  .rd-film-end { display: block; background: linear-gradient(160deg, #1e3a62, #0f2442) !important; }
  .rd-film-window {
    position: absolute; top: -4px; bottom: -4px; border-radius: 5px; border: 2px solid var(--trace);
    box-shadow: 0 0 0 4px rgba(94, 234, 212, 0.16), 0 6px 18px rgba(0, 0, 0, 0.4); transition: left 0.3s cubic-bezier(.2, .7, .2, 1), width 0.3s ease;
  }
  .rd-range { position: relative; z-index: 1; height: 52px; opacity: 0; }
  .rd-scrub:has(.rd-range:focus-visible) .rd-film-window { border-color: #f4b740; box-shadow: 0 0 0 4px rgba(244, 183, 64, 0.3), 0 6px 18px rgba(0, 0, 0, 0.4); }
  .rd-scrub:hover .rd-film-view img { opacity: 0.75; }
}
.rd-bubble {
  position: absolute; bottom: calc(100% + 10px); left: 50%; translate: -50% 0; z-index: 2; pointer-events: none;
  display: grid; justify-items: center; gap: 6px; padding: 8px 8px 7px; border-radius: 12px;
  background: #0d1d36; border: 1px solid rgba(255, 255, 255, 0.12); box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
}
.rd-bubble-pages { display: flex; gap: 2px; }
.rd-bubble img, .rd-bubble .rd-film-end { width: 72px; height: auto; aspect-ratio: var(--rd-aspect, 0.77); border-radius: 2px; background: #fdfcf9; display: block; }
.rd-bubble .rd-film-end { background: linear-gradient(160deg, #1e3a62, #0f2442); }
.rd-bubble span { font-size: 12.5px; font-weight: 650; color: #fff; font-variant-numeric: tabular-nums; }

/* Zoom */
.rd-zoom { grid-row: 2 / 4; grid-column: 1; position: relative; z-index: 3; display: grid; grid-template-rows: minmax(0, 1fr) auto; background: #07111f; }
.rd-zoom-scroll { overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; outline: none; padding: 12px; }
.rd-zoom-img { display: block; margin: 0 auto; max-width: none; background: #fdfcf9; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55); }
.rd-zoom-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 18px;
  padding: 10px max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  border-top: 1px solid rgba(255, 255, 255, 0.08); background: #0a1830;
}
.rd-zoom-group { display: flex; align-items: center; gap: 6px; }
.rd-zoom-label { min-width: 104px; text-align: center; font-size: 14px; font-weight: 650; color: var(--on-night); font-variant-numeric: tabular-nums; }
.rd-zoom-done {
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--trace); color: #04231f; font: 700 14.5px var(--sans);
}
.rd-zoom-done:hover { background: #8df3e2; }
.rd-zoom-scroll:focus-visible { outline: 3px solid #f4b740; outline-offset: -3px; }
.rd.is-zoomed .rd-bottom { visibility: hidden; }

@media (max-width: 640px) {
  .rd-top { gap: 8px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .rd-tools { gap: 2px; }
  .rd-icon { width: 40px; height: 40px; background: transparent; }
  .rd-buy { height: 36px; padding: 0 12px; margin-right: 2px; font-size: 14px; }
  .rd-buy-more { display: none; }
  .rd-title { font-size: 15px; white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-height: 1.2; }
  .rd-kicker { font-size: 10.5px; }
  .rd-bottom { column-gap: 8px; }
  .rd-nav { width: 42px; height: 42px; }
  .rd-zoom-bar { gap: 8px 10px; }
  .rd-zoom-label { min-width: 88px; font-size: 13px; }
}
@media (max-width: 359px) {
  .rd-kicker { display: none; }
  .rd-buy { padding: 0 10px; }
  .rd-buy svg { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .rd-page > img, .rd-film-window, .rd-icon, .rd-nav { transition: none; }
  .rd-end > * { animation: none; }
}
