/* Quran Points — calm, respectful, mobile-first styles */
@font-face {
  font-family: "Noto Nastaliq Urdu";
  src: url("../fonts/NotoNastaliqUrdu.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "Noto Naskh Arabic";
  src: url("../fonts/NotoNaskhArabic.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --green-900: #143f30;
  --green-800: #1f5c46;
  --green-700: #2a7158;
  --green-100: #e3efe6;
  --cream: #faf6ec;
  --cream-2: #f3ecdb;
  --gold: #b8955a;
  --gold-soft: #e7d6b2;
  --ink: #23302a;
  --muted: #6b7a72;
  --card: #fffdf7;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 63, 48, .06), 0 6px 18px rgba(20, 63, 48, .08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--cream);
  color: var(--ink);
  font-family: "Noto Naskh Arabic", "Noto Nastaliq Urdu", "Segoe UI", Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-tap-highlight-color: transparent;
}
.nastaliq { font-family: "Noto Nastaliq Urdu", "Noto Naskh Arabic", serif; font-weight: 400; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
button { font: inherit; color: inherit; }
.ltr { direction: ltr; unicode-bidi: isolate; }

/* ---------- Hero header ---------- */
.hero {
  position: relative;
  overflow: hidden;
  color: var(--cream);
  background: linear-gradient(160deg, var(--green-700), var(--green-900));
  padding: calc(28px + var(--safe-top)) 20px 38px;
  text-align: center;
  border-bottom-left-radius: 28px;
  border-bottom-right-radius: 28px;
}
.hero-pattern {
  position: absolute; inset: 0;
  opacity: .16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%23f3e3bf' stroke-width='1.3'%3E%3Crect x='17' y='17' width='30' height='30'/%3E%3Crect x='17' y='17' width='30' height='30' transform='rotate(45 32 32)'/%3E%3Ccircle cx='32' cy='32' r='6'/%3E%3Cpath d='M0 0l10 10M64 0L54 10M0 64l10-10M64 64L54 54'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 64px 64px;
}
.hero::after { /* thin gold rule */
  content: ""; position: absolute; left: 22%; right: 22%; bottom: 16px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-soft), transparent);
  opacity: .8;
}
.hero-inner { position: relative; }
.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 9vw, 2.8rem);
  line-height: 2;
  text-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.hero .subtitle { margin: 0; font-size: clamp(1rem, 4.4vw, 1.25rem); line-height: 2.1; color: var(--gold-soft); }

/* ---------- Layout ---------- */
.container { max-width: 760px; margin: 0 auto; padding: 18px 16px 8px; }

.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--card);
  border: 1px solid var(--gold-soft);
  border-radius: 999px;
  padding: 6px 16px;
  box-shadow: var(--shadow);
  margin-top: -36px; position: relative; z-index: 2;
}
.search svg { color: var(--green-800); flex: none; }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 1rem; padding: 8px 0; color: var(--ink);
}
.search:focus-within { border-color: var(--green-700); box-shadow: 0 0 0 3px rgba(42,113,88,.15), var(--shadow); }
#result-count { margin: 10px 4px 4px; min-height: 1.4em; }

/* ---------- Cards ---------- */
.card-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
@media (min-width: 640px) { .card-list { grid-template-columns: 1fr 1fr; } }

.card {
  display: flex; gap: 14px; align-items: stretch;
  width: 100%; text-align: start;
  background: var(--card);
  border: 1px solid #ece3cf;
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-decoration: none; color: inherit;
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:active { transform: scale(.985); }
.card:focus-visible { outline: 3px solid var(--green-700); outline-offset: 2px; }
.thumb {
  flex: none; width: 84px; aspect-ratio: 2 / 3;
  border-radius: 10px; overflow: hidden;
  background: var(--cream-2);
  border: 1px solid #eadfc6;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.card-title { margin: 0; font-family: "Noto Nastaliq Urdu", serif; font-size: 1.3rem; line-height: 2.05; color: var(--green-900); font-weight: 400; }
.card-en { margin: 0; direction: ltr; text-align: right; font-family: system-ui, "Segoe UI", Roboto, sans-serif; font-size: .9rem; color: var(--muted); line-height: 1.4; }
.card-sub { margin: 0; font-family: "Noto Naskh Arabic", serif; font-size: .95rem; line-height: 1.8; color: #4d5c55; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  font-size: .78rem; line-height: 1.6; padding: 1px 10px; border-radius: 999px;
  background: var(--green-100); color: var(--green-800); white-space: nowrap;
}
.chip.gold { background: #f5ead2; color: #7d5f2b; }
.num-badge {
  flex: none; align-self: center;
  width: 42px; height: 42px; display: grid; place-items: center;
  color: var(--green-800); font-weight: 700; font-size: .95rem;
  background:
    linear-gradient(var(--card), var(--card)) padding-box,
    linear-gradient(135deg, var(--gold), var(--green-700)) border-box;
  border: 2px solid transparent; border-radius: 12px; transform: rotate(45deg);
}
.num-badge span { transform: rotate(-45deg); }
.card.soon { cursor: default; opacity: .7; border-style: dashed; box-shadow: none; background: #fbf8ef; }
.card.soon:active { transform: none; }
.soon-thumb {
  display: block;
  background: repeating-linear-gradient(45deg, #f3ecdb 0 8px, #ece3cf 8px 16px);
}
.empty { text-align: center; color: var(--muted); padding: 30px 0; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + var(--safe-top)) 10px 8px;
  background: rgba(250, 246, 236, .94);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid #ece3cf;
}
.topbar-title { flex: 1; min-width: 0; text-align: center; }
.topbar-title h2 { margin: 0; font-size: 1.15rem; line-height: 2; color: var(--green-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title p { margin: 0; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn, .icon-btn-spacer {
  flex: none; width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
}
.icon-btn { border: 0; background: transparent; color: var(--green-800); cursor: pointer; text-decoration: none; }
.icon-btn:hover, .icon-btn:focus-visible { background: var(--green-100); outline: none; }

/* ---------- Viewer ---------- */
.viewer { position: fixed; inset: 0; display: flex; flex-direction: column; background: #f1ebdc; z-index: 10; }
.viewer-bar { position: relative; }
.stage {
  position: relative; flex: 1; overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none;
  outline: none;
  background:
    radial-gradient(ellipse at center, #fbf7ee 0%, #ece4d2 100%);
}
.stage img {
  position: absolute; top: 0; left: 0;
  transform-origin: 0 0;
  will-change: transform;
  max-width: none;
  box-shadow: 0 4px 24px rgba(20,63,48,.18);
  border-radius: 6px;
  opacity: 0; transition: opacity .25s ease;
}
.stage img.ready { opacity: 1; }
.stage.animating img { transition: transform .22s ease, opacity .25s ease; }
.loader {
  position: absolute; top: 50%; left: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border: 3px solid var(--green-100); border-top-color: var(--green-700); border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.viewer-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px calc(8px + var(--safe-bottom));
  background: rgba(250, 246, 236, .96);
  border-top: 1px solid #ece3cf;
}
.nav-btn {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 44px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--gold-soft); background: var(--card); color: var(--green-800);
  cursor: pointer; font-size: .95rem;
}
.nav-btn:disabled { opacity: .35; cursor: default; }
.nav-btn:not(:disabled):active { background: var(--green-100); }
#zoom-hint { text-align: center; }

/* ---------- Footer ---------- */
.footer { max-width: 760px; margin: 18px auto 0; padding: 18px 16px calc(28px + var(--safe-bottom)); text-align: center; }
.disclaimer {
  margin: 0 0 10px; padding: 10px 14px; border-radius: 12px;
  background: var(--cream-2); border: 1px dashed var(--gold-soft);
  color: #5d5135; font-size: .92rem;
}
.link-btn { background: none; border: 0; color: var(--green-800); text-decoration: underline; cursor: pointer; font-size: .88rem; padding: 6px; }
body.viewer-open .footer { display: none; }
body.viewer-open { overflow: hidden; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-bottom)); transform: translateX(-50%);
  background: var(--green-900); color: var(--cream); padding: 8px 18px; border-radius: 999px;
  font-size: .9rem; z-index: 50; box-shadow: var(--shadow); max-width: 90vw; text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: .01ms !important; }
}

/* Author's note */
.intro{position:fixed;inset:0;z-index:1000;background:#f6f1e3;overflow-y:auto;display:flex;justify-content:center;align-items:flex-start;padding:18px 12px}
.intro[hidden]{display:none}
.intro-card{max-width:520px;width:100%;padding:22px 22px 20px;background:#fffdf6;border:3px solid #c9a227;border-radius:18px;box-shadow:0 0 0 6px #1f5e3b inset,0 4px 14px #0002;text-align:center;color:#1f3d2b}
.intro-bism{font-family:"Noto Naskh Arabic",serif;font-size:26px;color:#1f5e3b;margin:6px 0 4px}
.intro-card h2{margin:4px 0 14px;font-size:22px;color:#8a6a10;border-bottom:1px solid #e3d29a;padding-bottom:10px}
.intro-card p{font-size:15px;line-height:2.3;text-align:justify;margin:0 0 8px}
.intro-sig{text-align:left;color:#8a6a10;font-size:15px;margin-top:6px}
.intro-btn{margin-top:14px;background:#1f5e3b;color:#fff;border:0;padding:8px 30px;border-radius:22px;font:inherit;font-size:16px;cursor:pointer}
.intro-link{margin-top:6px;background:transparent;border:1px solid currentColor;color:inherit;opacity:.85;border-radius:16px;padding:2px 14px;font-size:13px;cursor:pointer}

/* Bismillah opening page */
.splash{position:fixed;inset:0;z-index:1000;background:#f6efdc;display:flex;flex-direction:column;align-items:center;justify-content:center;cursor:pointer;transition:opacity .35s ease}
.splash.out{opacity:0}
.splash picture{display:flex;max-height:88vh;max-width:96vw}
.splash img{max-height:88vh;max-width:96vw;width:auto;height:auto;object-fit:contain;border-radius:6px;box-shadow:0 4px 18px rgba(0,0,0,.12)}
.splash-hint{margin-top:10px;color:#1f5b3f;font-size:15px;opacity:.8;animation:sph 1.8s ease-in-out infinite}
@keyframes sph{0%,100%{opacity:.45}50%{opacity:.95}}
