/* =========================================================
   296 Qur'an — Design tokens
   Krem hangat, hijau zamrud gelap, gading, aksen emas tipis.
   ========================================================= */
:root {
  --cream: #F4EEDF;
  --ivory: #FBF8F0;
  --emerald-900: #0E3B2E;
  --emerald-800: #154A3A;
  --emerald-700: #1D5C48;
  --gold: #B8923F;
  --gold-soft: #D9BE7C;
  --ink: #22281F;
  --ink-soft: #55584B;
  --line: rgba(34, 40, 31, 0.12);
  --shadow: 0 6px 20px rgba(20, 30, 22, 0.07);

  --bg: var(--cream);
  --bg-elevated: var(--ivory);
  --text: var(--ink);
  --text-muted: var(--ink-soft);
  --accent: var(--emerald-900);
  --accent-contrast: var(--ivory);
  --gold-line: var(--gold);
  --border: var(--line);
  --shadow-elevated: var(--shadow);

  --font-display: 'Lora', 'Source Serif 4', Georgia, serif;
  --font-body: 'Source Sans 3', system-ui, -apple-system, sans-serif;
  --font-arabic: 'Amiri', 'Traditional Arabic', 'Scheherazade New', serif;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;

  --arabic-size: 34px;

  color-scheme: light;
}

[data-theme='dark'] {
  --bg: #0B2A21;
  --bg-elevated: #123A2D;
  --text: #F3EEDD;
  --text-muted: #B9C4B8;
  --accent: #E7D9AE;
  --accent-contrast: #0B2A21;
  --gold-line: #D9BE7C;
  --border: rgba(243, 238, 221, 0.14);
  --shadow-elevated: 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  transition: background 0.25s ease, color 0.25s ease;
}

a { color: inherit; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: 12px; top: -48px;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  z-index: 100;
  transition: top 0.2s ease;
  font-family: var(--font-body);
  font-size: 14px;
}
.skip-link:focus { top: 12px; }

:focus-visible {
  outline: 2px solid var(--gold-line);
  outline-offset: 2px;
}

button { font-family: inherit; cursor: pointer; }

/* ---------- Header ---------- */
.site-header {
  background: var(--accent);
  color: var(--accent-contrast);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow-elevated);
}

.header-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 14px 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 34px; height: 34px;
  border: 1px solid var(--gold-line);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-arabic);
  font-size: 19px;
  color: var(--gold-line);
}

.brand-text {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.header-tools { display: flex; gap: 6px; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.22);
  background: transparent;
  color: inherit;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s ease, transform 0.15s ease;
}
.icon-btn:hover { background: rgba(255,255,255,0.1); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.small { width: 30px; height: 30px; border-radius: 8px; font-size: 13px; }
.icon-btn.active { color: var(--gold-line); border-color: var(--gold-line); }

.search-bar-wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 6px 16px 16px;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 999px;
  padding: 10px 16px;
}
.search-icon { flex-shrink: 0; opacity: 0.8; }

.search-bar input {
  background: transparent;
  border: none;
  outline: none;
  color: inherit;
  font-size: 15px;
  width: 100%;
  font-family: var(--font-body);
}
.search-bar input::placeholder { color: rgba(255,255,255,0.65); }

/* ---------- Main / layout ---------- */
main {
  max-width: 880px;
  margin: 0 auto;
  padding: 22px 16px 64px;
  min-height: 60vh;
}

.view-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  margin: 4px 4px 16px;
}

/* ---------- Last read banner ---------- */
.last-read-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold-line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-elevated);
}
.last-read-banner .lr-text { font-size: 14px; color: var(--text-muted); }
.last-read-banner .lr-text strong { color: var(--text); font-family: var(--font-display); font-size: 16px; }
.last-read-banner .lr-link {
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}
[data-theme='dark'] .last-read-banner .lr-link { color: var(--gold-line); }

/* ---------- Surah grid ---------- */
.surah-grid {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 620px) {
  .surah-grid { grid-template-columns: 1fr 1fr; }
}

.surah-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-elevated);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.surah-card:hover { border-color: var(--gold-line); transform: translateY(-1px); }
.surah-card:active { transform: translateY(0); }

.surah-num {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border: 1px solid var(--gold-line);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--gold-line);
  transform: rotate(45deg);
}
.surah-num span { transform: rotate(-45deg); }

.surah-info { flex: 1; min-width: 0; }
.surah-name-row { display: flex; align-items: baseline; gap: 8px; }
.surah-name-latin { font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.surah-meta { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.surah-name-arabic { font-family: var(--font-arabic); font-size: 22px; color: var(--text); flex-shrink: 0; margin-left: 8px; }

/* ---------- Skeletons ---------- */
.surah-grid.is-skeleton .surah-card,
#listSkeleton .skel-card,
#detailSkeleton .skel-line {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--border) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
#listSkeleton { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 620px) { #listSkeleton { grid-template-columns: 1fr 1fr; } }
#listSkeleton .skel-card { height: 68px; border-radius: var(--radius-md); border: 1px solid var(--border); }

.detail-skeleton { display: flex; flex-direction: column; gap: 12px; }
.detail-skeleton .skel-line { height: 18px; border-radius: 6px; }
.detail-skeleton .skel-line.w-60 { width: 60%; }
.detail-skeleton .skel-line.w-40 { width: 40%; }
.detail-skeleton .skel-line.h-100 { height: 100px; border-radius: var(--radius-md); }

/* ---------- Empty / error states ---------- */
.empty-state, .error-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 15px;
}
.error-state p { margin-bottom: 16px; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  padding: 11px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
}
.btn-primary:hover { opacity: 0.92; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--gold-line);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.btn-outline:hover { background: var(--gold-line); color: var(--accent-contrast); }

/* ---------- Back button ---------- */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 4px;
  margin-bottom: 10px;
}
.back-btn:hover { color: var(--text); }

/* ---------- Surah header (detail) ---------- */
.surah-header {
  text-align: center;
  padding: 26px 16px 22px;
  margin-bottom: 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-elevated);
  position: relative;
}
.surah-header::before,
.surah-header::after {
  content: '';
  position: absolute;
  left: 50%; transform: translateX(-50%);
  width: 46px; height: 1px;
  background: var(--gold-line);
}
.surah-header::before { top: 12px; }
.surah-header::after { bottom: 12px; }

.surah-header .sh-arabic {
  font-family: var(--font-arabic);
  font-size: 30px;
  margin-bottom: 6px;
}
.surah-header .sh-latin {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
}
.surah-header .sh-arti { color: var(--text-muted); font-size: 14px; margin-top: 2px; }
.surah-header .sh-meta {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.surah-header .sh-desc {
  margin-top: 16px;
  font-size: 13.5px;
  color: var(--text-muted);
  text-align: left;
  max-height: 4.5em;
  overflow: hidden;
  line-height: 1.6;
}
.surah-header .sh-desc.expanded { max-height: none; }
.surah-header .sh-desc-toggle {
  margin-top: 8px;
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 12.5px;
  padding: 0;
}
[data-theme='dark'] .surah-header .sh-desc-toggle { color: var(--gold-line); }

.basmalah {
  font-family: var(--font-arabic);
  font-size: calc(var(--arabic-size) * 0.85);
  text-align: center;
  padding: 20px 10px 26px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

/* ---------- Reader toolbar ---------- */
.reader-toolbar {
  position: sticky;
  top: 118px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg);
  padding: 8px 4px 14px;
  flex-wrap: wrap;
}

.font-size-control {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px;
}
.font-size-label { font-size: 12px; color: var(--text-muted); min-width: 40px; text-align: center; }

.play-surah-btn.is-playing { background: var(--gold-line); color: var(--accent-contrast); }
.play-surah-btn .play-icon { transition: none; }

/* ---------- Ayat list ---------- */
.ayat-list { list-style: none; margin: 0; padding: 0; }

.ayat-item {
  padding: 26px 0;
  border-bottom: 1px solid var(--border);
}
.ayat-item:last-child { border-bottom: none; }

.ayat-toprow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.ayat-num-badge {
  width: 30px; height: 30px;
  border: 1px solid var(--gold-line);
  border-radius: 8px;
  transform: rotate(45deg);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ayat-num-badge span {
  transform: rotate(-45deg);
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--gold-line);
}

.ayat-actions { display: flex; gap: 4px; }

.ayat-arabic {
  font-family: var(--font-arabic);
  font-size: var(--arabic-size);
  line-height: 2.15;
  text-align: right;
  direction: rtl;
  color: var(--text);
  margin-bottom: 14px;
}

.ayat-translit {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 14.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.65;
}

.ayat-translation {
  font-family: var(--font-display);
  font-size: 15.5px;
  color: var(--text);
  line-height: 1.75;
}

.bookmark-btn.is-active { color: var(--gold-line); }
.bookmark-btn.is-active svg path { fill: var(--gold-line); }
.play-btn.is-active { color: var(--gold-line); border-color: var(--gold-line); }

/* ---------- Bookmark view ---------- */
.bookmark-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.bookmark-card {
  display: block;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-elevated);
}
.bookmark-card .bm-ref { font-family: var(--font-display); font-weight: 600; font-size: 14.5px; margin-bottom: 4px; }
.bookmark-card .bm-snippet {
  font-family: var(--font-arabic);
  direction: rtl;
  text-align: right;
  font-size: 20px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 28px 16px 40px;
  font-size: 12.5px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.site-footer p { margin: 4px 0; }
.site-footer a { text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Utility ---------- */
[hidden] { display: none !important; }

@media (max-width: 380px) {
  .surah-name-arabic { display: none; }
  .brand-text { font-size: 17px; }
}
