/* Quran reader — shared styles (extracted from per-surah pages) */
/* Toolbar with translation/reciter switchers + reading mode */
.toolbar {
  max-width: 900px;
  margin: 2rem auto 1rem;
  padding: 0 2rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}
.tool-select {
  background: rgba(var(--surface-rgb), 0.55);
  border: 0.5px solid rgba(201, 169, 110, 0.35);
  color: var(--parchment);
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  padding: 0.6rem 1rem;
  border-radius: 50px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
}
.tool-select:hover { border-color: var(--gold); }
.tool-button {
  background: rgba(var(--surface-rgb), 0.55);
  border: 0.5px solid rgba(201, 169, 110, 0.35);
  color: var(--linen);
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.65rem 1.2rem;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.2s;
}
.tool-button:hover { border-color: var(--gold); color: var(--parchment); }
.tool-button.active {
  background: rgba(201, 169, 110, 0.15);
  border-color: var(--gold);
  color: var(--gold);
}

/* Loading state */
.verses-loading {
  max-width: 800px;
  margin: 4rem auto;
  text-align: center;
  color: var(--gold);
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.7;
}
.verses-loading::after {
  content: '...';
  animation: dots 1.4s infinite;
}
@keyframes dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

.verses-error {
  max-width: 700px;
  margin: 3rem auto;
  padding: 2rem;
  background: rgba(212, 165, 116, 0.08);
  border: 0.5px solid rgba(212, 165, 116, 0.4);
  border-radius: 8px;
  color: #d4a574;
  text-align: center;
  line-height: 1.7;
  display: none;
}
.verses-error.visible { display: block; }

/* Verses container */
.verses {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem 2rem 4rem;
}
.verse {
  padding: 2.5rem 0;
  border-bottom: 0.5px dashed rgba(201, 169, 110, 0.18);
}
.verse:last-child { border-bottom: none; }
.verse-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.verse-num {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(201, 169, 110, 0.12);
  border: 0.5px solid rgba(201, 169, 110, 0.5);
  color: var(--gold);
  font-family: var(--serif);
  font-size: 0.9rem;
  border-radius: 50%;
  flex-shrink: 0;
}
.verse-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}
.verse-action {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--surface-rgb), 0.5);
  border: 0.5px solid rgba(201, 169, 110, 0.3);
  color: var(--gold);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.85rem;
}
.verse-action:hover {
  background: rgba(201, 169, 110, 0.15);
  border-color: var(--gold);
}
.verse-action.playing {
  background: rgba(127, 194, 153, 0.18);
  border-color: #7fc299;
  color: #7fc299;
}

.verse-arabic {
  font-family: 'Amiri', var(--serif);
  font-size: calc(2.4rem * var(--ar-scale, 1));
  line-height: 2.2;
  color: var(--parchment);
  text-align: right;
  direction: rtl;
  margin-bottom: 1.5rem;
  font-weight: 400;
}

.verse-translation {
  color: var(--linen);
  font-size: calc(1.05rem * var(--tr-scale, 1));
  line-height: 1.85;
  margin-bottom: 0.85rem;
  font-family: var(--serif);
}
.verse-translation-source {
  color: var(--gold);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-bottom: 1.25rem;
}

/* Navigation between sūrahs at bottom */
.surah-nav {
  position: static;
  max-width: 900px;
  margin: 1.5rem auto 0;
  padding: 1.25rem 2rem 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  background: transparent;
  border: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.surah-nav.single { grid-template-columns: minmax(0, 420px); justify-content: center; }
.surah-nav-link {
  background: rgba(var(--surface-rgb), 0.4);
  border: 0.5px solid rgba(201, 169, 110, 0.25);
  border-radius: 8px;
  padding: 1.5rem 1.75rem;
  text-decoration: none;
  transition: all 0.25s;
  display: block;
}
.surah-nav-link:hover {
  border-color: var(--gold);
  background: rgba(var(--surface-rgb), 0.65);
}
.surah-nav-link.disabled {
  opacity: 0.3;
  pointer-events: none;
}
.surah-nav-direction {
  color: var(--gold);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-bottom: 0.5rem;
}
.surah-nav-name {
  font-family: var(--serif);
  font-size: 1.2rem;
  color: var(--parchment);
}
.surah-nav-link.next { text-align: right; }

/* Reading mode hides nav, footer, breadcrumb, surah header — focuses on the verses */
body.reading-mode .nav,
body.reading-mode .breadcrumb,
body.reading-mode .surah-header,
body.reading-mode .footer,
body.reading-mode .surah-nav {
  display: none !important;
}
body.reading-mode .toolbar { margin-top: 3rem; }
body.reading-mode .verses { max-width: 720px; }
body.reading-mode .verse-arabic { font-size: calc(2.6rem * var(--ar-scale, 1)); }

/* Floating exit-reading-mode button */
.exit-reading-btn {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(var(--midnight-rgb), 0.92);
  border: 0.5px solid var(--gold);
  color: var(--gold);
  padding: 0.85rem 1.75rem;
  border-radius: 50px;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  z-index: 1000;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  display: none;
  transition: all 0.25s;
}
.exit-reading-btn:hover {
  background: var(--gold);
  color: var(--midnight);
}
@media (max-width: 700px) {
  .exit-reading-btn { bottom: 1.25rem; padding: 0.75rem 1.5rem; font-size: 0.65rem; }
}
body.reading-mode .exit-reading-btn { display: block; }

@media (max-width: 700px) {
  .surah-header { padding: 3rem 1.5rem 2rem; }
  .surah-header h1 { font-size: 3rem; }
  .surah-header h2 { font-size: 1.5rem; }
  .verses { padding: 1rem 1.25rem 3rem; }
  .verse-arabic { font-size: calc(1.95rem * var(--ar-scale, 1)); line-height: 2; }
  .verse-translation { font-size: calc(0.98rem * var(--tr-scale, 1)); }
  .surah-nav { grid-template-columns: 1fr; padding: 1.25rem; }
  .toolbar { padding: 0 1rem; }
}

.verse-transliteration {
  font-family: var(--serif); font-style: italic; font-size: 1.05rem;
  color: var(--gold); opacity: 0.8; line-height: 1.7; margin-bottom: 0.5rem;
  display: none;
}
body.show-transliteration .verse-transliteration { display: block; }
.tool-button.active { background: rgba(201,169,110,0.2); border-color: var(--gold); color: var(--gold); }

/* ── Phase 3: follow-along, tafsir, copy/share, settings ── */
.verse-action svg { display: block; }
.verse-action.active { background: rgba(201,169,110,0.18); border-color: var(--gold); color: var(--gold); }

.verse { scroll-margin-top: 90px; transition: background 0.4s; border-radius: 6px; }
.verse.active { background: rgba(201,169,110,0.07); box-shadow: inset 3px 0 0 var(--gold); padding-left: 1rem; padding-right: 1rem; }
.verse.flash { background: rgba(201,169,110,0.16); }

/* Tafsir panel */
.verse-tafsir {
  margin-top: 1.25rem;
  border: 0.5px solid rgba(201,169,110,0.25);
  border-radius: 6px;
  background: rgba(var(--surface-rgb), 0.4);
  padding: 1.25rem 1.4rem;
}
.verse-tafsir-name {
  font-size: 0.62rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 0.85rem;
}
.verse-tafsir-head { margin-bottom: 0.85rem; }
.verse-tafsir-head .tafsir-src {
  background: rgba(var(--surface-rgb), 0.6); border: 0.5px solid rgba(201,169,110,0.3);
  color: var(--gold); border-radius: 50px; padding: 0.3rem 0.7rem;
  font-size: 0.72rem; cursor: pointer;
}
.verse-tafsir-body { color: var(--linen); font-size: 0.95rem; line-height: 1.85; }
.verse-tafsir-body h1, .verse-tafsir-body h2, .verse-tafsir-body h3 {
  font-family: var(--serif); color: var(--parchment); font-size: 1.05rem; margin: 1rem 0 0.5rem;
}
.verse-tafsir-body p { margin-bottom: 0.85rem; }
.verse-tafsir-body sup { display: none; }
.verse-tafsir-loading { color: var(--gold); opacity: 0.75; font-size: 0.9rem; }

/* Toast */
.reader-toast {
  position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%) translateY(1rem);
  background: rgba(var(--midnight-rgb), 0.95); color: var(--parchment);
  border: 0.5px solid var(--gold); padding: 0.7rem 1.4rem; border-radius: 50px;
  font-size: 0.78rem; letter-spacing: 0.04em; z-index: 1200;
  opacity: 0; pointer-events: none; transition: all 0.25s;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.reader-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Settings drawer */
.reader-settings {
  position: fixed; inset: 0; z-index: 1100; display: none;
  background: rgba(0,0,0,0.45); align-items: stretch; justify-content: flex-end;
}
.reader-settings.open { display: flex; }
.rs-panel {
  width: 340px; max-width: 88vw; height: 100%; overflow-y: auto;
  background: var(--midnight); border-left: 0.5px solid rgba(201,169,110,0.25);
  padding: 1.5rem 1.5rem 3rem;
}
.rs-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.rs-head h3 { font-family: var(--serif); color: var(--parchment); font-size: 1.3rem; font-weight: 400; }
.rs-close { background: none; border: none; color: var(--gold); font-size: 1.6rem; line-height: 1; cursor: pointer; }
.rs-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.9rem 0; border-bottom: 0.5px solid rgba(201,169,110,0.12); }
.rs-row > span { color: var(--linen); font-size: 0.85rem; }
.rs-seg, .rs-step { display: flex; gap: 0.4rem; }
.rs-seg button, .rs-step button, #rs-speed {
  background: rgba(var(--surface-rgb), 0.5); border: 0.5px solid rgba(201,169,110,0.3);
  color: var(--linen); border-radius: 6px; padding: 0.4rem 0.7rem; font-size: 0.78rem; cursor: pointer;
}
.rs-step span { color: var(--gold); font-size: 0.8rem; min-width: 3ch; text-align: center; align-self: center; }
.rs-seg button.active { background: rgba(201,169,110,0.2); border-color: var(--gold); color: var(--gold); }
.rs-seg button:hover, .rs-step button:hover { border-color: var(--gold); }
@media (max-width: 700px) { .rs-panel { width: 100%; max-width: 100%; } }

/* Mushaf-style continuous layout */
.mushaf {
  font-family: 'Amiri', var(--serif);
  font-size: calc(2rem * var(--ar-scale, 1));
  line-height: 2.6;
  color: var(--parchment);
  direction: rtl;
  text-align: justify;
  text-align-last: center;
  padding: 1rem 0.5rem 2rem;
}
.mushaf-ayah { cursor: pointer; transition: background 0.3s; border-radius: 4px; }
.mushaf-ayah:hover { background: rgba(201,169,110,0.08); }
.mushaf-ayah.active { background: rgba(201,169,110,0.14); }
.mushaf-end {
  font-family: var(--sans); font-size: 0.5em; color: var(--gold);
  border: 0.5px solid rgba(201,169,110,0.5); border-radius: 50%;
  padding: 0.15em 0.1em; margin: 0 0.15em; display: inline-block;
  min-width: 1.7em; text-align: center; vertical-align: middle;
}
/* In Mushaf view, the toolbar/modes still apply but per-verse chrome is gone */
body.mushaf-layout .reader-modes { opacity: 0.9; }

/* Word-level audio highlight (word-by-word view) */
.qword.word-active { background: rgba(201,169,110,0.28); border-radius: 6px; }

/* Word-by-word */
.verse-arabic.wbw {
  display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem;
  justify-content: flex-start; line-height: 1.8;
}
.qword {
  display: inline-flex; flex-direction: column; align-items: center;
  cursor: pointer; padding: 0.35rem 0.5rem 0.45rem; border-radius: 8px;
  transition: background 0.15s;
}
.qword:hover { background: rgba(201,169,110,0.1); }
.qword-ar { font-family: 'Amiri', var(--serif); color: var(--parchment); }
.qword-m {
  font-family: var(--sans); font-size: 0.62rem; color: var(--gold);
  opacity: 0.85; margin-top: 0.4rem; max-width: 11ch; text-align: center; line-height: 1.3;
}
.qword-pop {
  position: absolute; z-index: 1300; display: none; min-width: 160px; max-width: 240px;
  background: rgba(var(--midnight-rgb), 0.98); border: 0.5px solid var(--gold);
  border-radius: 8px; padding: 0.9rem 1rem; text-align: center;
  box-shadow: 0 12px 36px rgba(0,0,0,0.4);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.qword-pop.open { display: block; }
.qword-pop .qp-ar { font-family: 'Amiri', var(--serif); color: var(--parchment); font-size: 1.6rem; margin-bottom: 0.4rem; }
.qword-pop .qp-tr { font-family: var(--serif); font-style: italic; color: var(--gold); font-size: 0.9rem; margin-bottom: 0.2rem; }
.qword-pop .qp-m { color: var(--linen); font-size: 0.85rem; margin-bottom: 0.6rem; }
.qword-pop .qp-play {
  background: rgba(201,169,110,0.15); border: 0.5px solid var(--gold); color: var(--gold);
  border-radius: 50px; padding: 0.35rem 0.9rem; font-size: 0.72rem; cursor: pointer;
}
.qword-pop .qp-play:hover { background: var(--gold); color: var(--midnight); }

/* Notes (per ayah) */
.verse-note { margin-top: 1.1rem; }
.verse-note .vn-input {
  width: 100%; min-height: 90px; resize: vertical;
  background: rgba(var(--surface-rgb), 0.5); border: 0.5px solid rgba(201,169,110,0.3);
  border-radius: 8px; padding: 0.8rem 0.9rem; color: var(--parchment);
  font-family: var(--sans); font-size: 0.95rem; line-height: 1.6; outline: none;
}
.verse-note .vn-input:focus { border-color: var(--gold); }
.verse-note .vn-actions { display: flex; gap: 0.5rem; margin-top: 0.6rem; }
.verse-note .vn-save, .verse-note .vn-del {
  border: 0.5px solid var(--gold); border-radius: 50px; padding: 0.4rem 1rem;
  font-size: 0.72rem; letter-spacing: 0.08em; cursor: pointer;
}
.verse-note .vn-save { background: var(--gold); color: var(--midnight); }
.verse-note .vn-del { background: none; color: var(--gold); }

/* Reading modes bar */
.reader-modes {
  max-width: 850px; margin: 0 auto 0.5rem; padding: 0 2rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.25rem;
}
/* Mode and Repeat each form their own group so they wrap as whole units
   (the Repeat group drops to a new line intact on narrow screens rather than
   splitting its chips across the Mode row). */
.rm-group { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.rm-group-repeat { position: relative; }
@media (min-width: 701px) {
  .rm-group-repeat::before {
    content: ""; position: absolute; left: -0.65rem; top: 15%; bottom: 15%;
    width: 1px; background: rgba(201,169,110,0.25);
  }
}
.reader-modes .rm-label {
  font-size: 0.6rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--gold); opacity: 0.7; margin-right: 0.3rem;
}
.rm-chip {
  background: rgba(var(--surface-rgb), 0.5); border: 0.5px solid rgba(201,169,110,0.3);
  color: var(--linen); border-radius: 50px; padding: 0.35rem 0.85rem;
  font-size: 0.72rem; letter-spacing: 0.04em; cursor: pointer; transition: all 0.2s;
}
.rm-chip:hover { border-color: var(--gold); }
.rm-chip.active { background: rgba(201,169,110,0.2); border-color: var(--gold); color: var(--gold); }
@media (max-width: 700px) { .reader-modes { padding: 0 1rem; } }

/* Memorise: hide translation/transliteration to test recall */
body.hide-translation .verse-translation,
body.hide-translation .verse-translation-source,
body.hide-translation .verse-transliteration { display: none; }

/* Beginner: declutter — hide advanced per-verse actions + larger Arabic */
body.beginner .copy-btn,
body.beginner .share-btn { display: none; }
body.beginner .verse-arabic { line-height: 2.4; }

/* Sepia reading overlay (overrides theme on reader pages) */
html.sepia-reading {
  --midnight: #f4ecd9; --indigo: #efe4cc; --surface: #fbf5e7;
  --parchment: #3a3221; --linen: #5a4f38; --gold: #9a6f2e;
  --midnight-rgb: 244, 236, 217; --surface-rgb: 250, 243, 226; --footer-bg: #e9ddc2;
}
