/* ---------------- E-Paper reader: plain HTML + CSS Grid, no app shell ---------------- */

/* Story highlights: horizontal CSS grid of circular-avatar cards */
.reader-stories{display:grid;grid-auto-flow:column;grid-auto-columns:max-content;gap:22px;overflow-x:auto;padding-bottom:6px}
.reader-story{display:flex;flex-direction:column;align-items:center;width:96px;text-decoration:none;color:var(--text);text-align:center}
.reader-story-avatar{width:64px;height:64px;border-radius:50%;overflow:hidden;border:2px solid var(--brand-red);padding:2px;display:flex;align-items:center;justify-content:center;background:var(--bg-soft);flex-shrink:0}
.reader-story-avatar img{width:100%;height:100%;object-fit:cover;border-radius:50%}
.reader-story-avatar i{font-size:20px;color:#9ca3af}
.reader-story-title{font-size:12.5px;font-weight:600;margin-top:8px;line-height:1.25;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.reader-story:hover .reader-story-avatar{border-color:var(--brand-red-dark)}

/* Layout: large view + page grid. Mobile/tablet stack (large on top, grid at
   the bottom); desktop places the page grid beside the large view on the left. */
/* The full page gets the reading width; thumbnails are available on demand. */
.reader-layout{display:flex;flex-direction:column;gap:22px}
.reader-large-section{min-width:0}
.reader-grid-section{min-width:0;border:1px solid var(--border);border-radius:6px;background:#fff}
.reader-grid-section summary{cursor:pointer;display:flex;align-items:center;gap:10px;padding:13px 18px;font-size:14px;font-weight:600;list-style:none}
.reader-grid-section summary::-webkit-details-marker{display:none}
.reader-grid-section summary::after{content:'+';font-size:20px;margin-left:auto;color:var(--brand-red)}
.reader-grid-section[open] summary::after{content:'\2212'}
.reader-grid-section summary span{font-size:12px;font-weight:400;color:var(--text-muted)}
.reader-grid-section .reader-grid{padding:0 18px 18px;grid-template-columns:repeat(auto-fill,minmax(90px,1fr));gap:14px}

/* Large view: current page, with overlay prev/next so it never squeezes the image width */
.reader-large{position:relative;display:flex;justify-content:center}
.reader-large-viewport{width:100%;max-width:1000px}
.reader-large-viewport.zoomed{overflow:auto;max-height:80vh;border-radius:10px;cursor:grab;background:#e4e5e9}
.reader-large-viewport.zoomed:active{cursor:grabbing}
.reader-large-frame{width:100%;border-radius:10px;overflow:hidden;background:#fff;box-shadow:0 20px 50px rgba(16,24,40,.14);transition:width .2s ease}
.reader-large-frame img{width:100%;display:block;-webkit-user-select:none;user-select:none}
.reader-nav-btn{position:absolute;top:50%;transform:translateY(-50%);width:44px;height:44px;border-radius:50%;
  background:#fff;box-shadow:0 4px 14px rgba(0,0,0,.16);display:flex;align-items:center;justify-content:center;
  color:var(--text);text-decoration:none;transition:.15s;font-size:18px;z-index:2}
.reader-nav-btn:hover{color:var(--brand-red)}
.reader-nav-btn.disabled{opacity:.3;pointer-events:none}
.reader-nav-btn.prev{left:max(4px, calc(50% - 400px))}
.reader-nav-btn.next{right:max(4px, calc(50% - 400px))}

.reader-toolbar-mini{display:flex;align-items:center;justify-content:center;gap:10px;margin-top:18px;flex-wrap:wrap}
.reader-mini-btn{width:36px;height:36px;border-radius:8px;background:var(--bg-soft);display:inline-flex;align-items:center;justify-content:center;
  color:var(--text);text-decoration:none;border:none;cursor:pointer;flex-shrink:0}
.reader-mini-btn:hover{background:#fde8e8;color:var(--brand-red)}
.reader-mini-btn:disabled{opacity:.35;cursor:default;pointer-events:none}
.reader-toolbar-sep{width:1px;height:22px;background:var(--border);margin:0 2px;flex-shrink:0}
.reader-zoom-level{width:auto;padding:0 10px;font-size:12.5px;font-weight:700}
.reader-zoom-hint{text-align:center;font-size:12px;color:var(--text-muted);margin:10px 0 0}
.reader-jump{display:flex;align-items:center;gap:6px;font-size:14px;color:var(--text-muted);background:var(--bg-soft);padding:4px 6px 4px 12px;border-radius:8px}
.reader-jump input{width:52px;text-align:center;border:1px solid #d1d5db;border-radius:6px;padding:5px 2px;background:#fff}
.reader-jump input::-webkit-outer-spin-button,.reader-jump input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}

/* All Pages: responsive CSS grid, no manual breakpoints needed - auto-fill handles it */
.reader-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(110px,1fr));gap:16px}
.reader-grid-item{display:block;text-decoration:none;color:var(--text);border-radius:10px;overflow:hidden;
  background:var(--bg-soft);border:2px solid transparent;transition:.15s;box-shadow:0 1px 4px rgba(16,24,40,.06)}
.reader-grid-item:hover{transform:translateY(-2px);box-shadow:0 8px 18px rgba(16,24,40,.12)}
.reader-grid-item img{width:100%;aspect-ratio:3/4;object-fit:contain;display:block;background:#f3f4f6}
.reader-grid-item.active{border-color:var(--brand-red)}
.reader-grid-item.active .reader-grid-label{color:var(--brand-red)}
.reader-grid-label{display:block;text-align:center;font-size:12px;font-weight:700;padding:7px 4px;background:#fff}

@media(max-width:576px){
  .ep-hide-xs{display:none !important}
  .reader-grid{grid-template-columns:repeat(auto-fill,minmax(90px,1fr));gap:10px}
}

@media(max-width:767px){
  /* Mobile turns pages by swiping the image (see _bindSwipe in epaper.js)
     instead of tapping arrows, which otherwise sit on top of the page. */
  .reader-nav-btn{display:none}
}

/* ---------------- Fullscreen / distraction-free reading mode ---------------- */
.reader-focus-bar{display:none}
.reader-focus-exit{width:40px;height:40px;border-radius:50%;border:none;background:rgba(255,255,255,.12);color:#fff;
  display:flex;align-items:center;justify-content:center;font-size:16px;cursor:pointer;transition:.15s;flex-shrink:0}
.reader-focus-exit:hover{background:rgba(255,255,255,.22)}
.reader-focus-counter{color:rgba(255,255,255,.75);font-size:13px;font-weight:600}

body.reader-focus-active{overflow:hidden}
body.reader-focus-active .site-utility-bar,
body.reader-focus-active .site-header,
body.reader-focus-active .page-hero,
body.reader-focus-active .reader-stories,
body.reader-focus-active .container > .section-heading,
body.reader-focus-active .reader-grid-section,
body.reader-focus-active .site-footer{display:none !important}

body.reader-focus-active main,
body.reader-focus-active .container{padding:0;margin:0;max-width:none}
body.reader-focus-active .reader-layout{display:block}
body.reader-focus-active .reader-large-section{
  position:fixed;inset:0;z-index:2000;background:#111318;
  display:flex;flex-direction:column;padding:10px 10px calc(10px + env(safe-area-inset-bottom));
}
body.reader-focus-active .reader-focus-bar{display:flex;align-items:center;justify-content:space-between;padding:6px 8px 12px;flex-shrink:0}
body.reader-focus-active .reader-large{flex:1;min-height:0}
body.reader-focus-active .reader-large-viewport{max-width:100%;max-height:100%;height:100%;display:flex;align-items:center;justify-content:center}
body.reader-focus-active .reader-large-viewport.zoomed{display:block;height:100%;max-height:100%;text-align:center}
body.reader-focus-active .reader-large-frame{width:auto;max-width:100%;height:100%;display:inline-block;vertical-align:middle}
body.reader-focus-active .reader-large-frame img{width:auto;height:100%;max-width:100%;display:block}
body.reader-focus-active .reader-large-viewport.zoomed .reader-large-frame,
body.reader-focus-active .reader-large-viewport.zoomed .reader-large-frame img{max-width:none}
body.reader-focus-active .reader-toolbar-mini{flex-shrink:0;padding-top:12px}
body.reader-focus-active .reader-toolbar-mini .reader-mini-btn,
body.reader-focus-active .reader-jump{background:rgba(255,255,255,.1);color:#fff}
body.reader-focus-active .reader-jump input{background:rgba(255,255,255,.9)}
body.reader-focus-active .reader-zoom-hint{display:none}

.reader-grid-section:not([open]) > .reader-grid{display:none}
.reader-grid-item{border-radius:4px}
.reader-large-frame{border:1px solid var(--border);border-radius:5px;box-shadow:0 4px 22px rgba(16,24,40,.08)}

/* Keep page navigation and zoom available above the paper on every screen. */
.reader-toolbar-mini{position:sticky;top:8px;z-index:5;background:#fff;border:1px solid var(--border);border-radius:6px;padding:10px;margin:0 auto 18px;max-width:1000px;gap:8px}
.reader-mini-btn.disabled{opacity:.35;pointer-events:none}
body.reader-focus-active .reader-toolbar-mini{position:static;background:transparent;border:0;margin:0 0 10px;max-width:none;padding:0}
@media(max-width:380px){.reader-toolbar-mini{gap:5px;padding:8px 4px}.reader-mini-btn{width:32px;height:32px}.reader-jump{padding-left:7px;gap:4px;font-size:12px}.reader-jump input{width:38px}}
