/* ===== Iqra Digital — pembaca statik, laju, mobile-first ===== */
:root {
  --green: #0f6b52;
  --green-dark: #0a4d3a;
  --green-light: #14856a;
  --gold: #d4a02a;
  --gold-soft: #ffd464;
  --bg: #f4f6f4;
  --card: #ffffff;
  --ink: #16241f;
  --muted: #6b7d76;
  --line: #e2e8e4;
  --shadow: 0 4px 18px rgba(15, 107, 82, .10);
  --topbar-h: 56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overscroll-behavior: none;
}
img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ===== TOP BAR ===== */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 10px;
  background: linear-gradient(120deg, var(--green-dark), var(--green-light));
  color: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
}
.tb-btn {
  width: 42px; height: 42px; border-radius: 12px; color: #fff; font-size: 20px;
  display: grid; place-items: center; transition: background .15s;
}
.tb-btn:active { background: rgba(255, 255, 255, .18); }
.tb-logo { font-size: 19px; font-weight: 700; color: var(--gold-soft); line-height: 1; }
.tb-title {
  flex: 1; text-align: center; font-weight: 700; font-size: 16px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ===== SCREENS ===== */
.screen { display: none; }
.screen.active { display: block; }

/* ===== COVER / HOME ===== */
.cover {
  min-height: 100dvh; padding: calc(var(--topbar-h) + 8px) 16px 40px;
  max-width: 780px; margin: 0 auto;
}
.cover-hero {
  text-align: center; padding: 22px 14px 26px; margin-bottom: 20px;
  background: linear-gradient(150deg, var(--green), var(--green-dark));
  border-radius: 22px; color: #fff; box-shadow: var(--shadow);
}
.cover-badge {
  width: 76px; height: 76px; margin: 0 auto 12px; border-radius: 20px;
  background: rgba(255, 255, 255, .12); border: 2px solid var(--gold-soft);
  display: grid; place-items: center;
  font-size: 30px; font-weight: 700; color: var(--gold-soft);
}
.cover-hero h1 { margin: 0 0 8px; font-size: 30px; font-weight: 800; letter-spacing: -.5px; }
.cover-hero p { margin: 0 auto; max-width: 460px; font-size: 15px; line-height: 1.6; color: #dff0ea; }

.btn-primary {
  display: inline-block; margin-top: 18px; padding: 13px 26px;
  background: var(--gold-soft); color: var(--green-dark);
  font-weight: 700; font-size: 15px; border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .18); transition: transform .12s;
}
.btn-primary:active { transform: scale(.97); }

/* Book grid */
.book-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
}
@media (max-width: 480px) { .book-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; } }

.book-card {
  background: var(--card); border-radius: 16px; overflow: hidden;
  box-shadow: var(--shadow); border: 1px solid var(--line);
  transition: transform .14s, box-shadow .14s; text-align: center;
}
.book-card:active { transform: translateY(2px) scale(.98); }
.bc-cover {
  position: relative; aspect-ratio: 3 / 4; background: #eef2ef; overflow: hidden;
}
.bc-cover img { width: 100%; height: 100%; object-fit: cover; }
.bc-num {
  position: absolute; top: 8px; left: 8px;
  background: var(--green-dark); color: var(--gold-soft);
  font-weight: 700; font-size: 12px; padding: 3px 9px; border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}
.bc-body { padding: 9px 6px 11px; }
.bc-title { font-weight: 700; font-size: 14px; margin: 0; }
.bc-meta { font-size: 12px; color: var(--muted); margin: 2px 0 0; }

.notice {
  display: flex; gap: 12px; align-items: flex-start;
  margin-top: 24px; padding: 14px 16px; border-radius: 14px;
  background: #fff8e6; border: 1px solid #f0dca0; border-left: 4px solid var(--gold);
  box-shadow: 0 2px 10px rgba(212, 160, 42, .08);
}
.notice-icon { font-size: 20px; line-height: 1.3; flex-shrink: 0; }
.notice-body b { color: #7a5c00; }
.notice-body > b { display: block; font-size: 14px; margin-bottom: 4px; }
.notice-body p { margin: 0; font-size: 12.5px; line-height: 1.6; color: #6b5a2e; }
.notice-body a { color: var(--green); font-weight: 700; text-decoration: none; white-space: nowrap; }
.notice-body a:active { text-decoration: underline; }

.cover-note {
  text-align: center; margin-top: 20px; font-size: 12px; color: var(--muted); line-height: 1.5;
}

/* ===== READER ===== */
.reader { height: 100dvh; padding-top: var(--topbar-h); display: flex; flex-direction: column; }
.stage {
  position: relative; flex: 1; min-height: 0;
  display: grid; place-items: center; overflow: hidden;
  background: #e9ece9; padding: 8px;
}
.page-img {
  max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain;
  border-radius: 8px; background: #fff; box-shadow: 0 2px 12px rgba(0, 0, 0, .14);
  opacity: 0; transition: opacity .2s; cursor: zoom-in;
}
.page-img.loaded { opacity: 1; }

.stage-spinner {
  position: absolute; width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(15, 107, 82, .2); border-top-color: var(--green);
  animation: spin .8s linear infinite; opacity: 0; pointer-events: none;
}
.stage-spinner.show { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

.edge {
  position: absolute; top: 0; bottom: 0; width: 22%; max-width: 120px;
  display: grid; place-items: center; font-size: 30px; color: rgba(15, 107, 82, .0);
  transition: color .15s, background .15s;
}
.edge-prev { left: 0; }
.edge-next { right: 0; }
.edge:active { background: rgba(15, 107, 82, .06); color: rgba(15, 107, 82, .55); }
.edge:disabled { display: none; }

.reader-bar {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  padding-bottom: calc(9px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, .05);
}
.rb-btn {
  flex: 1; padding: 12px 8px; border-radius: 12px; font-weight: 600; font-size: 14px;
  background: var(--green); color: #fff; transition: opacity .15s, transform .1s;
}
.rb-btn:active { transform: scale(.97); }
.rb-btn:disabled { opacity: .35; }
.rb-counter {
  min-width: 78px; text-align: center; font-weight: 700; font-size: 14px;
  color: var(--green-dark); background: #eaf3ef; border-radius: 10px; padding: 10px 6px;
}

/* ===== DRAWER ===== */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity .22s;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(340px, 86vw); z-index: 51;
  background: var(--bg); transform: translateX(100%); transition: transform .26s ease;
  display: flex; flex-direction: column; box-shadow: -6px 0 24px rgba(0, 0, 0, .2);
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px; background: var(--green-dark); color: #fff; font-weight: 700;
}
.drawer-close { color: #fff; font-size: 18px; width: 34px; height: 34px; border-radius: 8px; }
.drawer-close:active { background: rgba(255, 255, 255, .15); }
.drawer-body { flex: 1; overflow-y: auto; padding: 12px; -webkit-overflow-scrolling: touch; }

.dg-books { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.dg-book {
  flex: 1 1 46px; padding: 9px 4px; border-radius: 10px; font-weight: 700; font-size: 13px;
  background: var(--card); border: 1px solid var(--line); color: var(--ink); text-align: center;
}
.dg-book.active { background: var(--green); color: #fff; border-color: var(--green); }

.dg-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin: 6px 2px 8px; }
.dg-pages { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.dg-page {
  aspect-ratio: 1; border-radius: 9px; font-weight: 600; font-size: 13px;
  background: var(--card); border: 1px solid var(--line); color: var(--ink);
  display: grid; place-items: center; transition: background .12s;
}
.dg-page.current { background: var(--gold-soft); border-color: var(--gold); color: var(--green-dark); }
.dg-page.cover { color: var(--muted); font-size: 11px; }

/* ===== LIGHTBOX ===== */
.lightbox {
  position: fixed; inset: 0; z-index: 60; background: rgba(10, 20, 16, .94);
  display: none; flex-direction: column;
}
.lightbox.open { display: flex; }
.lb-close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 44px; height: 44px; border-radius: 50%; color: #fff; font-size: 20px;
  background: rgba(255, 255, 255, .14);
}
.lb-scroll { flex: 1; overflow: auto; display: grid; place-items: center; -webkit-overflow-scrolling: touch; touch-action: pinch-zoom; }
.lb-scroll img { max-width: none; width: auto; min-width: 100%; }
.lb-hint {
  text-align: center; color: rgba(255, 255, 255, .7); font-size: 12px;
  padding: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom));
}

@media (min-width: 700px) {
  .page-img { max-width: 620px; }
}
