/* ============================================================
   Magazine Library Pro v2.2 — Public Stylesheet
   Standard layout: cover LEFT, spine LEFT, advance = swipe left
   ============================================================ */
.mlp-shell *, .mlp-modal * { box-sizing: border-box; }
.mlp-shell { direction: rtl; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; }

/* ── Library Grid ── */
.mlp-categories {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px; margin-bottom: 28px;
}
.mlp-magazines {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 20px;
}

/* ── Cards ── */
.mlp-card {
  position: relative; background: #fff; border-radius: 8px;
  overflow: hidden; cursor: pointer; outline: none;
  transition: transform .22s ease, box-shadow .22s ease;
  box-shadow: 0 4px 14px rgba(0,0,0,.09);
}
.mlp-card:hover, .mlp-card:focus-visible {
  transform: translateY(-5px); box-shadow: 0 14px 34px rgba(0,0,0,.16);
}
.mlp-card.is-active { box-shadow: 0 0 0 3px #3d6bff, 0 10px 28px rgba(61,107,255,.25); }
.mlp-card-media {
  position: relative; width: 100%; aspect-ratio: 335 / 459;
  background: #f0f0ee; overflow: hidden;
}
.mlp-card-media img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .35s ease;
}
.mlp-card:hover .mlp-card-media img { transform: scale(1.04); }
.mlp-card-placeholder { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; font-size: 48px; opacity: .25; }
.mlp-card-media::before, .mlp-card-media::after {
  content: ''; position: absolute; top: 4px; bottom: 4px; left: 0; right: 0;
  border: 1px solid rgba(0,0,0,.07); pointer-events: none; border-radius: 2px;
}
.mlp-card-media::before { transform: translateX(-3px); }
.mlp-card-media::after  { transform: translateX(-6px); }
.mlp-card-title { padding: 10px 10px 12px; font-size: 13px; line-height: 1.45; text-align: center; color: #1a1a1a; font-weight: 500; }

.mlp-loading-row, .mlp-error-row { grid-column: 1 / -1; padding: 32px; text-align: center; color: #666; }
.mlp-empty { grid-column: 1 / -1; padding: 48px 24px; text-align: center; color: #888; font-size: 16px; }
.mlp-error { color: #c00; }
.mlp-spinner-sm {
  display: inline-block; width: 28px; height: 28px;
  border: 3px solid rgba(0,0,0,.1); border-top-color: #3d6bff;
  border-radius: 50%; animation: mlp-spin .7s linear infinite;
}
@keyframes mlp-spin { to { transform: rotate(360deg); } }
.mlp-load-more-wrap { text-align: center; margin-top: 28px; }
.mlp-load-more {
  padding: 10px 30px; background: #f5f6fa; border: 1px solid #dde;
  border-radius: 6px; cursor: pointer; font-size: 14px; transition: background .18s;
}
.mlp-load-more:hover { background: #eaedf8; }

/* ── Modal overlay ── */
.mlp-no-scroll { overflow: hidden !important; }
.mlp-modal[hidden] { display: none; }
.mlp-modal { position: fixed; inset: 0; z-index: 999999; }
.mlp-modal-backdrop {
  position: absolute; inset: 0;
  background: radial-gradient(circle at center, rgba(22,25,44,.30) 0%, rgba(5,7,18,.92) 55%, rgba(2,3,9,.98) 100%);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.mlp-modal-inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* ── Top bar ── */
.mlp-topbar {
  position: relative; z-index: 10; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: rgba(0,0,0,.35); backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.mlp-topbar-title {
  color: rgba(255,255,255,.88); font-size: 15px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: calc(100% - 280px); direction: rtl;
}
.mlp-topbar-controls { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.mlp-ctrl-btn {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px; color: rgba(255,255,255,.80); cursor: pointer; padding: 0; flex-shrink: 0;
  transition: background .18s, transform .12s, color .18s;
}
.mlp-ctrl-btn svg { width: 18px; height: 18px; }
.mlp-ctrl-btn:hover { background: rgba(255,255,255,.18); color: #fff; transform: scale(1.06); }
.mlp-ctrl-btn:active { transform: scale(.96); }
.mlp-zoom-label { color: rgba(255,255,255,.65); font-size: 12px; min-width: 38px; text-align: center; }

/* ── Stage — no overflow:hidden so flip shadows render fully ── */
.mlp-stage-wrap {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  position: relative; padding: 0;
  overflow: visible;
}

/* ── Nav buttons — standard layout: NEXT on RIGHT, PREV on LEFT ── */
.mlp-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 20; width: 52px; height: 52px;
  background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.15);
  border-radius: 50%; color: #fff; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px); box-shadow: 0 6px 18px rgba(0,0,0,.28);
  transition: background .18s, transform .18s, opacity .18s; flex-shrink: 0;
}
.mlp-nav svg { width: 22px; height: 22px; }
.mlp-nav:hover { background: rgba(255,255,255,.22); transform: translateY(-50%) scale(1.08); }
.mlp-nav:disabled { opacity: .28; cursor: not-allowed; }
.mlp-nav:disabled:hover { transform: translateY(-50%) scale(1); background: rgba(255,255,255,.10); }

/* Arabic RTL: NEXT (go deeper) on LEFT, PREV (back toward cover) on RIGHT */
.mlp-nav-next { left: 14px; }
.mlp-nav-prev { right: 14px; }

/* ── Flipbook zone ── */
.mlp-flipbook-zone {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  transition: transform .2s ease;
}


/* ── Skeleton ── */
.mlp-skeleton {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; gap: 0;
}
.mlp-skeleton-page {
  flex: 0 0 calc(50% - 4px); height: 82%; max-width: 520px;
  border-radius: 4px;
  background: linear-gradient(90deg, #2a2a3a 25%, #33334a 50%, #2a2a3a 75%);
  background-size: 200% 100%; animation: mlp-shimmer 1.4s infinite;
}
.mlp-skeleton-spine { width: 8px; height: 82%; background: rgba(255,255,255,.06); flex-shrink: 0; }
@keyframes mlp-shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ── StPageFlip container fixes ────────────────────────────────────
   - NO overflow:hidden on stf__item  (was causing page cropping)
   - object-fit: fill on images       (no cropping)
   - Stage overflow:visible           (allows shadow to render)
   ────────────────────────────────────────────────────────────────── */
#mlp-flipbook {
  position: relative;
  width: 100%;           /* ensures StPageFlip reads correct blockWidth for 2-page layout */
  min-width: 0;
}

.stf__parent {
  margin: 0 auto;
}

.stf__item {
  background: #05070f;
  /* NO overflow:hidden — critical fix for page cropping */
}
#mlp-flipbook,
.stf__parent,
.stf__block,
.stf__wrapper,
.stf__canvas {
  background: #05070f !important;
}

.mlp-stage-wrap,
.mlp-flipbook-zone {
  background: #05070f;
}
.stf__item img {
  width: 100%; height: 100%;
  object-fit: fill;          /* fill exactly — no cropping */
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

/* ── Generation indicator — HIDDEN (removed from UX per feedback) ── */
.mlp-gen-indicator { display: none !important; }

/* ── Bottom bar ── */
.mlp-bottombar {
  position: relative; z-index: 10; flex-shrink: 0;
  background: rgba(0,0,0,.40); backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255,255,255,.07);
  padding: 8px 16px 10px;
}
.mlp-progress-wrap { margin-bottom: 8px; }
.mlp-progress-track { width: 100%; height: 4px; background: rgba(255,255,255,.12); border-radius: 999px; overflow: hidden; }
.mlp-progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, #5d7fff, #a5b4ff); border-radius: 999px; transition: width .35s ease; }
.mlp-bottombar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mlp-counter { color: rgba(255,255,255,.65); font-size: 13px; white-space: nowrap; }
.mlp-jump-wrap { display: flex; align-items: center; gap: 6px; }
.mlp-jump-input {
  width: 72px; padding: 5px 8px;
  background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.18);
  border-radius: 6px; color: #fff; font-size: 13px; text-align: center;
  outline: none; transition: border-color .16s;
}
.mlp-jump-input:focus { border-color: rgba(160,180,255,.55); }
.mlp-jump-input::placeholder { color: rgba(255,255,255,.35); }
.mlp-jump-input::-webkit-outer-spin-button,
.mlp-jump-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.mlp-jump-input[type=number] { -moz-appearance: textfield; }
.mlp-jump-btn {
  padding: 5px 12px; background: rgba(100,130,255,.25);
  border: 1px solid rgba(100,130,255,.35); border-radius: 6px; color: #fff;
  font-size: 13px; cursor: pointer; transition: background .16s;
}
.mlp-jump-btn:hover { background: rgba(100,130,255,.40); }

.mlp-viewer-error { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 340px; gap: 16px; color: rgba(255,255,255,.65); font-size: 16px; }
.mlp-btn-retry { padding: 8px 20px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); border-radius: 6px; color: #fff; cursor: pointer; font-size: 14px; transition: background .16s; }
.mlp-btn-retry:hover { background: rgba(255,255,255,.22); }

/* ── Fullscreen tweaks ── */
.mlp-modal.is-fullscreen .mlp-topbar { padding: 6px 12px; }
.mlp-modal.is-fullscreen .mlp-bottombar { padding: 6px 12px 8px; }
.mlp-modal.is-fullscreen .mlp-flipbook-zone { width: 100%; }

/* ============================================================ MOBILE ≤ 768px */
@media (max-width: 768px) {
  .mlp-categories { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
  .mlp-magazines  { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; }

  .mlp-topbar-title { max-width: calc(100% - 160px); font-size: 13px; }
  .mlp-ctrl-btn { width: 34px; height: 34px; }
  .mlp-ctrl-btn svg { width: 15px; height: 15px; }
  .mlp-zoom-label, .mlp-btn-zoom-in, .mlp-btn-zoom-out { display: none; }

  /* Mobile: hide nav buttons entirely — use swipe only */
  .mlp-nav { display: none !important; }

  /* Mobile: full-width zone — no room wasted on hidden nav buttons */
  .mlp-flipbook-zone {
    width: 100%;
    max-width: 100%;
    padding: 0 2px;
  }

  /* Stage: full height, minimal padding */
  .mlp-stage-wrap { padding: 4px 0; }

  /* Single-page skeleton: full width */
  .mlp-skeleton-page { flex: 0 0 92%; max-width: 100%; height: 90%; }
  .mlp-skeleton-spine, .mlp-skeleton-right { display: none; }

  /* Jump to page: too small on mobile, hide */
  .mlp-jump-wrap { display: none; }

  /* Center the single-page book */
  .stf__parent { margin: 0 auto !important; }
}

/* ============================================================ TABLET 769px – 1024px */
@media (min-width: 769px) and (max-width: 1024px) {
  .mlp-flipbook-zone { width: 100%; }
  .mlp-nav { width: 46px; height: 46px; }
  .mlp-nav-next { left: 10px; }
  .mlp-nav-prev { right: 10px; }
}

/* ============================================================ DESKTOP ≥ 1025px */
@media (min-width: 1025px) {
  .mlp-flipbook-zone { width: 100%; }
  .mlp-nav-next { left: 16px; }
  .mlp-nav-prev { right: 16px; }
}
/* ===== Force all viewer layers to dark background ===== */
.mlp-modal,
.mlp-modal-inner,
.mlp-stage-wrap,
.mlp-flipbook-zone,
#mlp-flipbook,
#mlp-flipbook > div,
.stf__parent,
.stf__wrapper,
.stf__block,
.stf__item,
.stf__canvas,
canvas {
  background: #060914 !important;
}

/* Keep only the page images visible without white side areas */
.stf__item {
  box-shadow: none !important;
}

.stf__item img {
  background: transparent !important;
  display: block;
}

/* In case an inner page element is painted white by the library */
[class*="stf__"] {
  background-color: #060914 !important;
}

.mlp-modal,
.mlp-viewer,
.mlp-flipbook-zone {
    background: #000 !important;
}