/* ============================================================
   ePaper Viewer v4 — Dark Editorial Minimal
   Fonts: Noto Serif Bengali + Hind Siliguri
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Hind+Siliguri:wght@400;500;600&family=Noto+Serif+Bengali:wght@600;700&display=swap');

:root {
  --bg:      #181818;
  --surface: #212121;
  --border:  rgba(255,255,255,0.09);
  --accent:  #e03030;
  --text:    #ede9e5;
  --muted:   #7a7470;
  --strip:   #b52020;
}

/* Wrapper */
.epv-wrap {
  font-family: 'Hind Siliguri', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow: hidden;
}

/* ── TOOLBAR ── */
.epv-toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 54px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 5px;
  flex-shrink: 0;
  z-index: 30;
  /* KEY: no overflow hidden, but flex-wrap prevention */
}

.epv-brand {
  display: flex; align-items: center; gap: 9px;
  flex-shrink: 0; margin-right: 6px;
}
.epv-brand-icon {
  width: 32px; height: 32px;
  background: var(--accent); border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: #fff; flex-shrink: 0;
}
.epv-brand-texts { display: flex; flex-direction: column; line-height: 1.25; }
.epv-brand-name {
  font-family: 'Noto Serif Bengali', serif;
  font-size: 13.5px; font-weight: 700; color: var(--text); white-space: nowrap;
}
.epv-brand-sub {
  font-size: 9px; color: var(--muted);
  letter-spacing: .05em; text-transform: uppercase;
}

.epv-sep { width: 1px; height: 22px; background: var(--border); flex-shrink: 0; margin: 0 4px; }

/* Date select */
.epv-date-wrap { position: relative; flex-shrink: 0; min-width: 0; }
.epv-date-sel {
  appearance: none;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 26px 6px 10px;
  border-radius: 7px;
  font-family: 'Hind Siliguri', sans-serif;
  font-size: 12px;
  cursor: pointer;
  min-width: 185px;
  max-width: 100%;
  outline: none;
  transition: border-color .2s;
}
.epv-date-sel:focus { border-color: var(--accent); }
.epv-date-sel option { background: #222; }
.epv-date-wrap::after {
  content: '▾'; position: absolute; right: 8px; top: 50%;
  transform: translateY(-50%); pointer-events: none;
  color: var(--muted); font-size: 10px;
}

.epv-spacer { flex: 1 1 0; min-width: 4px; }

/* Page counter */
.epv-counter { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.epv-counter b { color: var(--text); font-weight: 600; }

/* Icon btn */
.epv-ibtn {
  width: 32px; height: 32px;
  background: transparent; border: 1px solid transparent; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--muted); font-size: 13px;
  transition: all .15s; text-decoration: none; flex-shrink: 0;
}
.epv-ibtn:hover { background: rgba(255,255,255,0.07); border-color: var(--border); color: var(--text); }
.epv-ibtn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.epv-ibtn:disabled,.epv-ibtn[disabled] { opacity: .28; pointer-events: none; }

/* Zoom group */
.epv-zoom-grp {
  display: flex; align-items: center;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 7px; overflow: hidden; margin: 0 3px;
}
.epv-zoom-grp .epv-ibtn { border: none; border-radius: 0; width: 28px; height: 28px; margin: 2px; }
.epv-zoom-grp .epv-ibtn:hover { background: rgba(255,255,255,0.1); }
.epv-zoom-val { font-size: 11px; color: var(--muted); min-width: 36px; text-align: center; white-space: nowrap; }

/* ── EDITION STRIP ── */
.epv-strip {
  background: var(--strip);
  padding: 5px 16px;
  display: flex; align-items: center; gap: 9px;
  font-family: 'Noto Serif Bengali', serif;
  font-size: 12px; font-weight: 600; color: #fff;
  flex-shrink: 0;
}
.epv-strip-dot { width: 4px; height: 4px; background: rgba(255,255,255,0.4); border-radius: 50%; flex-shrink: 0; }
.epv-strip-title { flex: 1; }
.epv-strip-date { font-size: 11px; opacity: .8; white-space: nowrap; }

/* ── CANVAS AREA ──
   CRITICAL: no padding, no fixed height.
   Overflow:auto so zoomed PDF can scroll.
   Canvas logical size = area width * zoom.
   Canvas pixel size  = logical * devicePixelRatio (sharp on retina).
*/
.epv-canvas-area {
  position: relative;
  background: var(--bg);
  overflow: auto;
  flex: 1 1 auto;
  min-height: 220px;
  display: block; /* block, not flex — canvas fills naturally */
}

/* Inner wrap — centred, no extra padding */
.epv-canvas-inner {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100%;
}

/* Loading */
.epv-loading {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg); z-index: 10; gap: 16px;
}
.epv-spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(255,255,255,0.07);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.epv-loading p { font-size: 13px; color: var(--muted); font-family: 'Noto Serif Bengali', serif; }

/* Canvas — CSS width = logical px (set by JS). Height = auto from aspect ratio.
   JS sets canvas.width/height = logical * dpr for pixel-perfect sharpness. */
#epv-canvas {
  display: block;
  /* width and height are set inline by JS */
  box-shadow: 0 6px 50px rgba(0,0,0,0.75), 0 0 0 1px rgba(0,0,0,0.3);
  background: #fff;
  cursor: grab;
  flex-shrink: 0;
}
#epv-canvas:active { cursor: grabbing; }

/* Page flip */
#epv-canvas.fp-out-l  { animation: foL .17s ease-in  forwards; }
#epv-canvas.fp-in-r   { animation: fiR .17s ease-out forwards; }
#epv-canvas.fp-out-r  { animation: foR .17s ease-in  forwards; }
#epv-canvas.fp-in-l   { animation: fiL .17s ease-out forwards; }
@keyframes foL { from{opacity:1;transform:perspective(900px) rotateY(0) scaleX(1)} to{opacity:0;transform:perspective(900px) rotateY(-18deg) scaleX(.9)} }
@keyframes fiR { from{opacity:0;transform:perspective(900px) rotateY(18deg) scaleX(.9)} to{opacity:1;transform:perspective(900px) rotateY(0) scaleX(1)} }
@keyframes foR { from{opacity:1;transform:perspective(900px) rotateY(0) scaleX(1)} to{opacity:0;transform:perspective(900px) rotateY(18deg) scaleX(.9)} }
@keyframes fiL { from{opacity:0;transform:perspective(900px) rotateY(-18deg) scaleX(.9)} to{opacity:1;transform:perspective(900px) rotateY(0) scaleX(1)} }

/* Empty/error */
.epv-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 70px 30px; text-align: center; color: var(--muted); min-height: 260px;
}
.epv-empty i { font-size: 42px; opacity: .2; }
.epv-empty h3 { font-family: 'Noto Serif Bengali', serif; font-size: 18px; color: var(--text); margin: 0; }
.epv-empty p  { font-size: 12.5px; margin: 0; }

/* ── NAV ARROWS — absolute over canvas ── */
.epv-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 20; pointer-events: none; }
.epv-nav-prev { left: 12px; }
.epv-nav-next { right: 12px; }
.epv-nav-btn {
  width: 44px; height: 44px;
  background: rgba(10,10,10,0.7);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #fff; font-size: 15px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  transition: background .16s, transform .13s, box-shadow .16s;
  pointer-events: all; user-select: none;
}
.epv-nav-btn:hover:not(:disabled) {
  background: var(--accent); border-color: var(--accent);
  transform: scale(1.1); box-shadow: 0 6px 22px rgba(224,48,48,0.5);
}
.epv-nav-btn:disabled { opacity: .12; cursor: default; pointer-events: none; }

/* Zoom hint */
.epv-hint {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.7); color: #fff;
  font-size: 11px; padding: 5px 14px; border-radius: 999px;
  pointer-events: none; opacity: 0; transition: opacity .3s;
  white-space: nowrap; z-index: 25;
}
.epv-hint.show { opacity: 1; }

/* ── THUMBNAIL CAROUSEL ── */
.epv-car-wrap { background: #101010; border-top: 1px solid rgba(255,255,255,0.06); padding: 10px 12px 13px; flex-shrink: 0; }
.epv-car-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.epv-car-label { font-size: 9.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.epv-car-nav { display: flex; gap: 4px; }
.epv-car-btn { width: 24px; height: 24px; border: 1px solid rgba(255,255,255,0.09); border-radius: 5px; background: rgba(255,255,255,0.03); cursor: pointer; color: var(--muted); display: flex; align-items: center; justify-content: center; font-size: 9px; transition: all .16s; }
.epv-car-btn:hover:not(:disabled) { background: var(--accent); color: #fff; border-color: var(--accent); }
.epv-car-btn:disabled { opacity: .2; cursor: default; }
.epv-track-clip { overflow: hidden; }
.epv-track { display: flex; gap: 7px; transition: transform .35s cubic-bezier(.4,0,.2,1); will-change: transform; }
.epv-thumb { flex-shrink: 0; cursor: pointer; }
.epv-thumb-frame { background: #1c1c1c; border: 2px solid rgba(255,255,255,0.07); border-radius: 4px; overflow: hidden; aspect-ratio: 3/4; position: relative; transition: border-color .16s, box-shadow .16s; display: flex; align-items: center; justify-content: center; }
.epv-thumb:hover .epv-thumb-frame { border-color: var(--accent); box-shadow: 0 2px 12px rgba(224,48,48,0.25); }
.epv-thumb.active .epv-thumb-frame { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(224,48,48,0.25); }
.epv-thumb canvas { display: block; width: 100% !important; height: 100% !important; }
.epv-thumb-num { text-align: center; font-size: 9px; margin-top: 3px; color: var(--muted); font-weight: 500; }
.epv-thumb.active .epv-thumb-num { color: var(--accent); font-weight: 700; }
.epv-thumb-skel { width: 100%; height: 100%; background: linear-gradient(90deg,#181818 25%,#252525 50%,#181818 75%); background-size: 200% 100%; animation: skel 1.5s infinite; }
@keyframes skel { to { background-position: -200% 0; } }

/* ══════════════════════════════════════════
   MOBILE — toolbar never overflows
══════════════════════════════════════════ */
@media (max-width: 640px) {
  .epv-brand-sub { display: none; }
  .epv-sep { display: none; }
  .epv-zoom-grp { display: none; }
  .epv-toolbar { height: 48px; padding: 0 8px; gap: 4px; }
  .epv-brand-icon { width: 28px; height: 28px; font-size: 12px; }
  .epv-brand-name { font-size: 12px; }
  .epv-date-sel { min-width: 0; width: 132px; font-size: 11px; padding: 5px 20px 5px 8px; }
  .epv-ibtn { width: 28px; height: 28px; font-size: 12px; }
  .epv-counter { font-size: 10.5px; }
}
@media (max-width: 400px) {
  .epv-counter { display: none; }
  .epv-date-sel { width: 115px; }
  .epv-toolbar { gap: 3px; }
}
@media (max-width: 340px) {
  .epv-date-sel { width: 95px; font-size: 10px; }
}
