/* ==========================================================================
   GW ePaper — newspaper reader
   A full-viewport app shell: top bar, thumbnail rail, page stage, control bar.
   ========================================================================== */
:root {
  --r-bg: #24272e;          /* stage: neutral dark so the page is the brightest thing on screen */
  --r-bar: #15171c;
  --r-bar-line: #2f343d;
  --r-text: #e8eaee;
  --r-muted: #a3a9b4;
  --r-accent: #e0563f;
  --r-bar-h: 52px;
}
/* The reader sits in the normal page flow (site header above, footer below); the page itself scrolls. */
.reader { display: block; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: #fff; color: #000; padding: 8px 14px; border-radius: 3px; }
.skip-link:focus { top: 8px; }
:focus-visible { outline: 3px solid #8ab4ff; outline-offset: 2px; }

/* bars ------------------------------------------------------------------- */
.reader-bar { background: var(--r-bar); display: flex; align-items: center; gap: 6px; padding: 0 8px; min-height: var(--r-bar-h); flex-shrink: 0; z-index: 20; }
.reader-top { border-bottom: 1px solid var(--r-bar-line); }
.reader-bottom { border-top: 1px solid var(--r-bar-line); justify-content: space-between; padding-bottom: env(safe-area-inset-bottom); }
.reader-title { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.2; padding-inline: 6px; }
.reader-title strong { font-family: var(--font-display); font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-title span { font-size: .76rem; color: var(--r-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-preview { color: #f3c969; letter-spacing: .08em; }
.reader-actions, .reader-pager, .reader-zoom { display: flex; align-items: center; gap: 2px; }
.rbtn {
  width: 42px; height: 42px; display: inline-grid; place-items: center; flex-shrink: 0;
  background: transparent; border: 0; border-radius: 3px; color: var(--r-text); font-size: 1.12rem; text-decoration: none; cursor: pointer;
  transition: background-color .12s;
}
.rbtn:hover { background: #2b3038; color: #fff; }
.rbtn:disabled { opacity: .35; cursor: default; background: transparent; }
.rbtn[aria-pressed="true"] { color: var(--r-accent); }
.rbtn-sm { width: 34px; height: 34px; font-size: .95rem; }
.page-input {
  width: 3.6em; height: 36px; text-align: center; background: #0d0f12; color: #fff; border: 1px solid #3a404b; border-radius: 3px;
  font-size: .95rem; font-variant-numeric: tabular-nums; -moz-appearance: textfield;
}
.page-input::-webkit-outer-spin-button, .page-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.page-total { color: var(--r-muted); font-size: .9rem; font-variant-numeric: tabular-nums; padding-inline: 4px 2px; white-space: nowrap; }
.zoom-level { min-width: 3.4em; text-align: center; font-size: .84rem; color: var(--r-muted); font-variant-numeric: tabular-nums; }

/* progress --------------------------------------------------------------- */
.reader-progress { height: 3px; background: transparent; flex-shrink: 0; }
.reader-progress span { display: block; height: 100%; width: 0; background: var(--r-accent); transition: width .2s ease; }
.reader[data-state="ready"] .reader-progress span { width: 100% !important; opacity: 0; transition: opacity .4s .2s; }

/* main ------------------------------------------------------------------- */
.reader-main { flex: 1; display: flex; min-height: 0; position: relative; }
.reader-thumbs { width: 176px; background: #1b1e24; border-right: 1px solid var(--r-bar-line); display: none; flex-direction: column; flex-shrink: 0; }
.reader.thumbs-open .reader-thumbs { display: flex; }
.thumbs-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 14px; font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--r-muted); border-bottom: 1px solid var(--r-bar-line); }
.thumbs-list { list-style: none; margin: 0; padding: 12px; overflow-y: auto; display: grid; gap: 12px; flex: 1; }
.thumb { display: block; width: 100%; padding: 0; background: transparent; border: 2px solid transparent; border-radius: 3px; cursor: pointer; position: relative; color: var(--r-muted); }
.thumb img, .thumb-blank { display: block; width: 100%; aspect-ratio: 595 / 842; object-fit: cover; object-position: top; background: #fff; border-radius: 1px; }
.thumb-blank { display: grid; place-items: center; background: #2b3038; font-size: 1.6rem; color: #5a616d; }
.thumb-num { display: block; font-size: .76rem; padding: 4px 0 2px; font-variant-numeric: tabular-nums; }
.thumb:hover { border-color: #4a515d; }
.thumb[aria-current="true"] { border-color: var(--r-accent); color: #fff; }
.thumb.is-bookmarked::after { content: ""; position: absolute; top: 0; right: 8px; width: 12px; height: 18px; background: var(--r-accent); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%); }

.reader-stage { flex: 1; overflow: auto; position: relative; min-width: 0; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; }
.reader-stage:focus-visible { outline-offset: -3px; }
.reader-sheet { min-width: 100%; min-height: 100%; display: flex; align-items: flex-start; justify-content: center; padding: 16px; box-sizing: border-box; width: max-content; }
#page-canvas { display: block; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .45), 0 18px 40px -12px rgba(0, 0, 0, .6); opacity: 0; transition: opacity .18s ease; }
.reader[data-state="ready"] #page-canvas { opacity: 1; }
.reader[data-state="rendering"] #page-canvas { opacity: .55; }
.reader-ad { text-align: center; padding: 10px 12px 0; }
.reader-ad img { max-width: 100%; max-height: 90px; height: auto; }
.reader-ad .ad-label { display: block; font-size: .6rem; letter-spacing: .14em; text-transform: uppercase; color: var(--r-muted); margin-bottom: 3px; }

.reader-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 24px; background: var(--r-bg); color: var(--r-text); z-index: 5; }
.reader-overlay[hidden] { display: none; }
.reader-overlay .bi-exclamation-triangle { font-size: 2.4rem; color: #f3c969; }
.reader-overlay p { color: var(--r-muted); max-width: 44ch; margin: 0; }
.reader[data-state="ready"] #overlay-loading, .reader[data-state="rendering"] #overlay-loading, .reader[data-state="error"] #overlay-loading { display: none; }
.reader-spinner { width: 40px; height: 40px; border: 3px solid #3a404b; border-top-color: var(--r-accent); border-radius: 50%; animation: r-spin .8s linear infinite; }

.reader-edge { position: fixed; top: 50%; transform: translateY(-50%); width: 44px; height: 72px; border: 0; background: rgba(21, 23, 28, .55); color: #fff; font-size: 1.3rem; cursor: pointer; z-index: 6; opacity: 0; transition: opacity .15s; display: none; }
.reader-edge-prev { left: 0; border-radius: 0 4px 4px 0; }
.reader-edge-next { right: 0; border-radius: 4px 0 0 4px; }
.reader.thumbs-open .reader-edge-prev { left: 176px; }
@media (hover: hover) and (min-width: 768px) {
  .reader-edge { display: block; }
  .reader-stage:hover ~ .reader-edge, .reader-edge:hover, .reader-main:hover .reader-edge { opacity: .9; }
  .reader-edge:disabled { opacity: 0 !important; }
}

.reader-toast { position: fixed; left: 50%; bottom: calc(var(--r-bar-h) + 18px); transform: translateX(-50%); background: #fff; color: #15171c; padding: 9px 16px; border-radius: 3px; font-size: .9rem; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); z-index: 40; max-width: calc(100vw - 32px); }

/* fullscreen: chrome auto-hides until the pointer or a tap brings it back */
.reader.is-fullscreen.chrome-hidden .reader-bar { display: none; }

/* small screens ---------------------------------------------------------- */
@media (max-width: 767px) {
  .d-none-sm { display: none !important; }
  .reader-sheet { padding: 8px; }
  .reader-thumbs { position: absolute; inset: 0 auto 0 0; width: min(78vw, 300px); z-index: 30; box-shadow: 8px 0 30px rgba(0, 0, 0, .5); }
  .reader.thumbs-open .reader-thumbs { display: flex; }
  .thumbs-list { grid-template-columns: repeat(2, 1fr); }
  .reader.thumbs-open .reader-main::after { content: ""; position: absolute; inset: 0; background: rgba(0, 0, 0, .5); z-index: 25; }
  .rbtn { width: 40px; height: 44px; }
  .zoom-level { display: none; }
  .reader-bottom { gap: 2px; padding-inline: 4px; }
}
@media (min-width: 768px) { #btn-thumbs-close { display: none; } }

@keyframes r-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* Printing shows only the current page, and only where the publication allows printing. */
@media print {
  .reader-bar, .reader-thumbs, .reader-overlay, .reader-edge, .reader-toast, .reader-ad, .reader-progress { display: none !important; }
  .reader, .reader-main, .reader-stage { height: auto; overflow: visible; background: #fff; display: block; }
  .reader-sheet { padding: 0; width: auto; display: block; }
  #page-canvas { width: 100% !important; height: auto !important; box-shadow: none; opacity: 1 !important; }
  body.no-print-allowed * { display: none !important; }
}
