/* ============================================================
   Buku Yasin Digital — Gaya Islami (hijau & emas)
   Font: Amiri / Scheherazade New (Arab) + Poppins (Latin)
   ============================================================ */

:root {
  --green-900: #064e3b;
  --green-800: #065f46;
  --green-700: #0e6b4f;
  --green-600: #15803d;
  --green-100: #d1fae5;
  --green-50: #ecfdf5;
  --gold: #b8860b;
  --gold-light: #d4a017;
  --cream: #faf6ec;
  --ink: #1f2937;
  --ink-soft: #4b5563;
  --card: #ffffff;
  --line: #e5e0d2;
  --shadow: 0 4px 18px rgba(6, 78, 59, 0.12);
  --radius: 16px;
  --font-ar: "Scheherazade New", "Amiri", "Traditional Arabic", "Times New Roman", serif;
  --font-lat: "Poppins", "Segoe UI", system-ui, sans-serif;
  --arab-size: 2.15rem;
}

[data-theme="dark"] {
  --cream: #0b1220;
  --ink: #e7edf5;
  --ink-soft: #aab6c8;
  --card: #101b2e;
  --line: #1f2d45;
  --green-700: #17a674;
  --green-100: #0d3b2e;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-lat);
  background: var(--cream);
  color: var(--ink);
  min-height: 100dvh;
  transition: background 0.4s ease, color 0.4s ease;
  padding-bottom: 84px; /* ruang untuk nav bawah (read) */
}

/* ===== Layar (mode) ===== */
.screen { display: none; }
.screen.active { display: block; animation: fadeIn 0.35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== HERO (home) ===== */
.hero {
  position: relative;
  background: linear-gradient(160deg, var(--green-800), var(--green-700) 55%, #0b5d44);
  color: #fff;
  text-align: center;
  padding: 52px 20px 44px;
  border-radius: 0 0 34px 34px;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 12% 20%, rgba(212,160,23,0.25), transparent 42%),
    radial-gradient(circle at 88% 78%, rgba(255,255,255,0.10), transparent 45%);
  pointer-events: none;
}
.hero-ornament {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  width: 210px; height: 44px;
  opacity: 0.35;
  background:
    radial-gradient(circle at 0 50%, transparent 6px, rgba(255,255,255,0.9) 6.5px, transparent 8px) 0 50%/22px 44px repeat-x;
  -webkit-mask: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
          mask: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
}
.hero-bismillah {
  font-family: var(--font-ar);
  font-size: 1.55rem;
  color: #f4d97a;
  margin-bottom: 10px;
  line-height: 1.6;
}
.hero-title {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.hero-title span { color: #f4d97a; }
.hero-sub { margin-top: 8px; font-size: 0.95rem; color: #d8efe4; }
.hero-stats { margin-top: 16px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.stat-chip {
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.25);
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* ===== Menu home ===== */
.home-menu { padding: 22px 16px; display: grid; gap: 14px; max-width: 560px; margin: 0 auto; }
.menu-card {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  color: var(--ink);
  font-family: var(--font-lat);
  width: 100%;
}
.menu-card:active { transform: scale(0.985); }
.menu-card:hover { box-shadow: 0 8px 24px rgba(6,78,59,0.18); }
.menu-icon {
  font-size: 1.9rem;
  width: 58px; height: 58px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--acc) 14%, transparent);
  border-radius: 14px;
  flex-shrink: 0;
}
.menu-title { display: block; font-size: 1.12rem; font-weight: 700; }
.menu-desc { display: block; font-size: 0.82rem; color: var(--ink-soft); margin-top: 3px; }

.home-footer { text-align: center; padding: 26px 18px 30px; color: var(--ink-soft); font-size: 0.86rem; }
.home-footer .tiny { margin-top: 8px; font-size: 0.75rem; opacity: 0.75; }

/* ===== Sub-header (layar dalam) ===== */
.sub-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px;
  background: color-mix(in srgb, var(--cream) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.sub-header-titles { flex: 1; min-width: 0; }
.sub-header-titles h2 { font-size: 1.12rem; font-weight: 800; }
.sub-header-info { font-size: 0.74rem; color: var(--ink-soft); }
.icon-btn {
  width: 42px; height: 42px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 1.25rem;
  cursor: pointer;
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: background 0.2s ease;
}
.icon-btn:active { background: var(--green-100); }

/* ===== Toolbar baca + pencarian ===== */
.read-toolbar { padding: 12px 14px 4px; max-width: 820px; margin: 0 auto; }
.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 4px 6px 4px 14px;
  box-shadow: var(--shadow);
}
.search-icon { font-size: 1rem; opacity: 0.7; }
.search-wrap input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-lat);
  font-size: 0.95rem;
  padding: 10px 0;
}
.search-wrap input::placeholder { color: var(--ink-soft); opacity: 0.7; }
.search-clear {
  width: 34px; height: 34px;
  border: none; border-radius: 50%;
  background: var(--green-100);
  color: var(--green-700);
  font-size: 0.95rem;
  cursor: pointer;
  display: none;
}
.search-meta { padding: 8px 6px 2px; font-size: 0.78rem; color: var(--ink-soft); }

/* ===== Judul bab ===== */
.chapter-heading { text-align: center; padding: 18px 16px 6px; }
.ornament-line {
  width: 120px; height: 2px;
  margin: 8px auto;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.chapter-heading h3 {
  font-family: var(--font-ar);
  font-size: 1.9rem;
  color: var(--green-700);
  line-height: 1.7;
}
.chapter-sub { font-size: 0.82rem; color: var(--ink-soft); font-style: italic; }

/* ===== Daftar ayat ===== */
.ayah-list { max-width: 820px; margin: 0 auto; padding: 10px 14px 20px; display: grid; gap: 14px; }

.ayah-card {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px 14px;
  box-shadow: var(--shadow);
  scroll-margin-top: 76px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.ayah-card.highlight { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(184,134,11,0.22); }

.ayah-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ayah-num {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--green-700), var(--green-800));
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: grid; place-items: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(6,78,59,0.35);
}
.ayah-mark { font-size: 1.05rem; cursor: pointer; opacity: 0.45; transition: opacity 0.2s ease, transform 0.15s ease; }
.ayah-mark.on { opacity: 1; transform: scale(1.12); }

.ayah-ar {
  font-family: var(--font-ar);
  font-size: var(--arab-size);
  line-height: 2.1;
  text-align: right;
  direction: rtl;
  color: #0d1b2a;
  word-spacing: 0.06em;
  padding: 4px 2px 10px;
}
[data-theme="dark"] .ayah-ar { color: #f2f6fb; }

.ayah-id {
  border-top: 1px dashed var(--line);
  padding-top: 10px;
  font-size: 0.98rem;
  line-height: 1.75;
  color: var(--ink-soft);
}
.ayah-id b { color: var(--ink); }

/* ===== Navigasi naik-turun ayat ===== */
.read-nav {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  background: color-mix(in srgb, var(--green-800) 94%, #000);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: 0 6px 22px rgba(0,0,0,0.35);
  max-width: calc(100vw - 24px);
}
.read-nav-info { font-size: 0.82rem; font-weight: 600; white-space: nowrap; }
.nav-arrow {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.16);
  color: #fff;
  font-size: 1.15rem;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}
.nav-arrow:active { transform: scale(0.92); background: rgba(255,255,255,0.3); }

/* ===== FAB ke atas ===== */
.fab {
  position: fixed;
  right: 16px;
  bottom: 88px;
  z-index: 40;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--gold);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(184,134,11,0.45);
  display: none;
  transition: transform 0.15s ease;
}
.fab.show { display: grid; place-items: center; }
.fab:active { transform: scale(0.92); }

/* ===== Menu game ===== */
.game-menu-list { padding: 20px 16px; display: grid; gap: 14px; max-width: 560px; margin: 0 auto; }
.game-card {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  cursor: pointer;
  box-shadow: var(--shadow);
  color: var(--ink);
  font-family: var(--font-lat);
  width: 100%;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.game-card:active { transform: scale(0.985); }
.game-card-icon {
  font-size: 1.8rem;
  width: 56px; height: 56px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--acc) 14%, transparent);
  border-radius: 14px;
  flex-shrink: 0;
}
.game-card-body { flex: 1; min-width: 0; }
.game-card-title { display: block; font-size: 1.08rem; font-weight: 700; }
.game-card-desc { display: block; font-size: 0.8rem; color: var(--ink-soft); margin-top: 3px; line-height: 1.5; }
.game-card-arrow { font-size: 1.3rem; color: var(--gold); flex-shrink: 0; }

.game-best { max-width: 560px; margin: 6px auto 0; padding: 0 16px; }
.game-best h3 { font-size: 1rem; color: var(--ink-soft); margin-bottom: 10px; }
.best-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.best-box {
  background: linear-gradient(150deg, var(--card), color-mix(in srgb, var(--green-100) 60%, var(--card)));
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.best-num { display: block; font-size: 1.7rem; font-weight: 800; color: var(--gold); }
.best-label { font-size: 0.78rem; color: var(--ink-soft); }

/* ===== Kuis / Tebak ===== */
.quiz-body { max-width: 640px; margin: 0 auto; padding: 16px 16px 30px; }
.quiz-score-pill {
  background: linear-gradient(140deg, var(--gold), var(--gold-light));
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 6px 14px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(184,134,11,0.4);
}
.timer-wrap { max-width: 640px; margin: 4px auto 0; padding: 0 16px; }
.timer-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--green-100);
  overflow: hidden;
  position: relative;
}
.timer-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: var(--fill, 100%);
  background: linear-gradient(90deg, var(--green-600), var(--gold));
  border-radius: 999px;
  transition: width 0.15s linear;
}
.timer-bar.danger::after { background: linear-gradient(90deg, #dc2626, #f59e0b); }

.quiz-prompt-label { font-size: 0.92rem; font-weight: 600; color: var(--ink-soft); margin: 14px 0 10px; }
.quiz-ayat-arabic {
  font-family: var(--font-ar);
  font-size: 1.9rem;
  line-height: 2;
  text-align: right;
  direction: rtl;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  color: #0d1b2a;
}
[data-theme="dark"] .quiz-ayat-arabic { color: #f2f6fb; }
.quiz-ayat-ref { text-align: center; font-size: 0.8rem; color: var(--ink-soft); margin-top: 8px; }

.quiz-options { display: grid; gap: 10px; margin-top: 16px; }
.quiz-option {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  width: 100%;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 14px 14px;
  font-family: var(--font-lat);
  font-size: 0.95rem;
  color: var(--ink);
  cursor: pointer;
  line-height: 1.5;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.1s ease;
}
.quiz-option:active { transform: scale(0.99); }
.quiz-option .opt-key {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--green-100);
  color: var(--green-700);
  font-weight: 800;
  font-size: 0.85rem;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.quiz-option.correct { border-color: #16a34a; background: color-mix(in srgb, #dcfce7 70%, var(--card)); }
.quiz-option.wrong { border-color: #dc2626; background: color-mix(in srgb, #fee2e2 70%, var(--card)); }
.quiz-option:disabled { cursor: default; opacity: 0.92; }

.quiz-feedback { margin-top: 14px; font-size: 0.92rem; font-weight: 600; min-height: 22px; text-align: center; }
.quiz-feedback.ok { color: #16a34a; }
.quiz-feedback.no { color: #dc2626; }

.btn-primary {
  display: inline-block;
  border: none;
  border-radius: 999px;
  background: linear-gradient(140deg, var(--green-700), var(--green-800));
  color: #fff;
  font-family: var(--font-lat);
  font-size: 1rem;
  font-weight: 700;
  padding: 13px 30px;
  cursor: pointer;
  box-shadow: 0 5px 16px rgba(6,78,59,0.35);
  transition: transform 0.12s ease;
  margin-top: 16px;
}
.btn-primary:active { transform: scale(0.96); }
.btn-secondary {
  display: inline-block;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-family: var(--font-lat);
  font-size: 1rem;
  font-weight: 600;
  padding: 12px 26px;
  cursor: pointer;
}

/* ===== Hasil ===== */
#screen-result { display: none; padding: 40px 16px; }
#screen-result.active { display: grid; place-items: center; min-height: 100dvh; }
.result-card {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 34px 26px;
  text-align: center;
  max-width: 420px;
  width: 100%;
}
.result-icon { font-size: 3.2rem; }
.result-card h2 { font-size: 1.5rem; margin-top: 8px; }
.result-sub { color: var(--ink-soft); font-size: 0.9rem; margin-top: 4px; }
.result-score {
  font-size: 3rem;
  font-weight: 800;
  color: var(--gold);
  margin: 12px 0 4px;
  line-height: 1;
}
.result-stats { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin: 14px 0 4px; }
.result-stats span {
  background: var(--green-100);
  color: var(--green-700);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 6px 14px;
  border-radius: 999px;
}
.result-msg { margin: 12px 0 6px; font-size: 0.95rem; color: var(--ink-soft); line-height: 1.6; }
.result-actions { display: flex; gap: 12px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 92px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--green-800);
  color: #fff;
  padding: 11px 22px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 90;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Audio Murottal ===== */
.audio-bar {
  max-width: 720px;
  margin: 10px auto 4px;
  padding: 12px 16px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.audio-bar-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.audio-status { font-size: 0.85rem; font-weight: 700; color: var(--green-700); }
.audio-ayah-label { font-size: 0.8rem; color: var(--ink-soft); background: var(--green-100); padding: 3px 10px; border-radius: 999px; }
.audio-controls { display: flex; gap: 10px; justify-content: center; align-items: center; }
.audio-btn {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--green-50);
  color: var(--green-800);
  font-size: 1.15rem;
  cursor: pointer;
  display: grid; place-items: center;
  transition: transform 0.12s ease, background 0.2s ease;
}
.audio-btn:active { transform: scale(0.92); }
.audio-btn.audio-play {
  width: 58px; height: 58px;
  background: var(--green-700);
  color: #fff;
  font-size: 1.35rem;
  border-color: var(--green-700);
  box-shadow: 0 4px 14px rgba(14,107,79,0.4);
}
.audio-vol-row { display: flex; align-items: center; gap: 10px; }
.audio-vol-row input[type="range"] { flex: 1; accent-color: var(--green-700); }
.vol-icon { font-size: 0.9rem; color: var(--ink-soft); }
.audio-err {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 0.82rem;
  padding: 8px 12px;
  border-radius: 10px;
  line-height: 1.5;
}
[data-theme="dark"] .audio-err { background: #2a1414; border-color: #7f1d1d; color: #fca5a5; }

/* Tombol play per ayat */
.ayah-audio {
  border: none;
  background: var(--green-100);
  color: var(--green-700);
  width: 30px; height: 30px;
  border-radius: 50%;
  font-size: 0.72rem;
  cursor: pointer;
  display: grid; place-items: center;
  transition: transform 0.12s ease, background 0.2s ease;
}
.ayah-audio:active { transform: scale(0.9); }
.ayah-card.playing {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(184,134,11,0.35), var(--shadow);
  background: color-mix(in srgb, var(--gold-light) 7%, var(--card));
}
.ayah-card.playing .ayah-audio { background: var(--gold); color: #fff; }

/* ===== Game Tebak Kata ===== */
.kata-sentence {
  font-size: 1.12rem;
  line-height: 1.9;
  background: var(--green-50);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  margin: 8px 0 12px;
}
.kata-blank {
  display: inline-block;
  min-width: 96px;
  border-bottom: 3px dashed var(--gold);
  color: var(--gold);
  font-weight: 800;
  text-align: center;
  padding: 0 8px;
  margin: 0 2px;
}
.kata-hint-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.btn-hint { padding: 8px 16px; font-size: 0.85rem; }
.kata-hint-text { font-size: 0.9rem; color: var(--ink-soft); letter-spacing: 2px; font-weight: 700; }
.kata-input-row { display: flex; gap: 10px; margin-bottom: 6px; }
.kata-input-row input {
  flex: 1;
  padding: 13px 16px;
  border: 2px solid var(--line);
  border-radius: 14px;
  font-size: 1.05rem;
  font-family: var(--font-lat);
  background: var(--card);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease;
}
.kata-input-row input:focus { border-color: var(--green-600); }
.kata-input-row .btn-primary { border-radius: 14px; }

/* ===== Responsif ===== */
@media (min-width: 720px) {
  :root { --arab-size: 2.5rem; }
  .hero { padding: 64px 24px 54px; }
  .hero-title { font-size: 2.7rem; }
  .home-menu, .game-menu-list { grid-template-columns: 1fr; }
  .ayah-card { padding: 22px 22px 16px; }
  .quiz-option { padding: 16px 18px; font-size: 1rem; }
}

@media (max-width: 420px) {
  :root { --arab-size: 1.85rem; }
  .hero-title { font-size: 1.85rem; }
  .hero-bismillah { font-size: 1.3rem; }
  .quiz-ayat-arabic { font-size: 1.6rem; }
  .read-nav-info { font-size: 0.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
