/* mushaf.css */
/* Google Fonts */
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Noto+Naskh+Arabic:wght@400;500;600;700&display=swap");

/* Base CSS variables (mirrors style.css :root so mushaf.html works standalone) */
:root {
    --primary: #10b981;
    --dark: #0f172a;
    --dark-light: #1e293b;
    --white: #ffffff;
    --text: #cbd5e1;
    --border: rgba(255, 255, 255, 0.08);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: "Poppins", sans-serif;
    background: var(--dark);
    color: var(--white);
    overflow: auto;
}

/* Light mode variable overrides — when body.light-mode is active,
   the whole page (including mushaf) switches to light theme */
body.light-mode {
    --dark: #f8fafc;
    --dark-light: #ffffff;
    --white: #0f172a;
    --text: #475569;
    --border: rgba(0, 0, 0, 0.08);
    background: var(--dark);
    color: var(--white);
}

/* CRITICAL: Ensure the HTML [hidden] attribute always hides elements,
   even when a display rule (like display: flex) would override it.
   Without this, .word-modal-overlay and .word-modal-nav would be
   visible on page load and intercept all clicks. */
[hidden] {
    display: none !important;
}

/* MINIMAL TOP BAR (Back button only — replaces full navbar) */

.mushaf-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.2rem;
    background: var(--mushaf-toolbar-bg, rgba(15, 23, 42, 0.88));
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

body.light-mode .mushaf-topbar {
    background: rgba(255, 255, 255, 0.92);
}

.topbar-spacer {
    flex: 1;
}

.topbar-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    padding: 0.2rem 0;
    transition: transform 0.2s;
}

.topbar-logo:hover {
    transform: scale(1.03);
}

.baca-logo-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(16, 185, 129, 0.25));
    transition: filter 0.3s;
}

.topbar-logo:hover .baca-logo-icon {
    filter: drop-shadow(0 3px 8px rgba(16, 185, 129, 0.4));
}

.topbar-logo-text {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.8px;
    background: linear-gradient(135deg, #10b981 0%, #06b6d4 50%, #6366f1 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-family: "Poppins", sans-serif;
}

body.light-mode .topbar-logo-text {
    background: linear-gradient(135deg, #059669 0%, #0891b2 50%, #4f46e5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Theme-specific gradient adjustments for the SVG logo */
body[data-mushaf-theme="warm"] .baca-logo-icon {
    filter: drop-shadow(0 2px 4px rgba(212, 169, 78, 0.25));
}

body[data-mushaf-theme="olive"] .baca-logo-icon {
    filter: drop-shadow(0 2px 4px rgba(45, 212, 191, 0.25));
}

body[data-mushaf-theme="sapphire"] .baca-logo-icon {
    filter: drop-shadow(0 2px 4px rgba(129, 140, 248, 0.25));
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 12px;
    background: var(--mushaf-tool-bg, rgba(255, 255, 255, 0.05));
    border: 1px solid var(--border);
    color: var(--mushaf-text, #fff);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.back-btn:hover {
    background: var(--mushaf-accent, #10b981);
    color: #fff;
    border-color: var(--mushaf-accent, #10b981);
}

.back-btn svg {
    width: 16px;
    height: 16px;
}

/* GLOBAL — Arabic text rendering */

:root {
    --mushaf-accent: var(--primary);
    --mushaf-accent-rgb: 16, 185, 129;
    --mushaf-text: #ffffff;
    --mushaf-subtext: #cbd5e1;
    --mushaf-arabic: #ffffff;
    --mushaf-card-bg: rgba(255, 255, 255, 0.04);
    --mushaf-card-border: rgba(255, 255, 255, 0.08);
    --mushaf-page-bg: #f8f4ea;
    /* Cream paper (Mushaf Madinah look) */
    --mushaf-page-text: #1a1a1a;
    --mushaf-page-shadow: rgba(0, 0, 0, 0.35);
    --mushaf-page-border: #d4c9a8;
    --mushaf-toolbar-bg: rgba(15, 23, 42, 0.88);
    --mushaf-tool-bg: rgba(255, 255, 255, 0.05);
    --mushaf-drawer-bg: #111827;
    --mushaf-overlay: rgba(0, 0, 0, 0.65);

    /* Tajweed colors — distinct, accessible palette
       (chosen to be distinguishable from each other AND from accent green #10b981) */
    --taj-ghunnah: #E67E22;
    /* orange  — nasal sound (meem/nun shaddah) */
    --taj-ikhfa: #95A5A6;
    /* gray    — hidden sound (nun sakinah) */
    --taj-idgham: #F1C40F;
    /* yellow  — merged sound */
    --taj-iqlab: #3498DB;
    /* blue    — converted to meem */
    --taj-qalqalah: #E74C3C;
    /* red     — echo/bounce (qaf/ba/jeem/dal/ta) */
    --taj-madd: #9B59B6;
    /* purple  — prolongation */
}

body.light-mode {
    --mushaf-toolbar-bg: rgba(255, 255, 255, 0.92);
    --mushaf-tool-bg: rgba(0, 0, 0, 0.05);
    --mushaf-card-bg: #ffffff;
    --mushaf-card-border: rgba(0, 0, 0, 0.07);
    --mushaf-drawer-bg: #ffffff;
    --mushaf-overlay: rgba(0, 0, 0, 0.4);
    --mushaf-overlay: rgba(0, 0, 0, 0.35);
}

/* Reader theme variants: applied to BODY so all UI (modal, drawers, floating
   player, read area) inherits the same theme variables.
   The .mushaf-read-area also gets data-theme for backwards-compat with the
   rules above, but the canonical source of theme variables is now body. */
body[data-mushaf-theme="dark"] {
    --mushaf-accent: #10b981;
    --mushaf-accent-rgb: 16, 185, 129;
    --mushaf-card-bg: rgba(255, 255, 255, 0.04);
    --mushaf-card-border: rgba(255, 255, 255, 0.08);
    --mushaf-text: #ffffff;
    --mushaf-subtext: #cbd5e1;
    --mushaf-arabic: #ffffff;
    --mushaf-page-bg: linear-gradient(180deg, #0f172a, #111827);
    --mushaf-page-text: #ffffff;
    --mushaf-page-shadow: rgba(0, 0, 0, 0.4);
    --mushaf-page-border: rgba(255, 255, 255, 0.08);
    --mushaf-drawer-bg: #111827;
    --mushaf-tool-bg: rgba(255, 255, 255, 0.05);
    --mushaf-toolbar-bg: rgba(15, 23, 42, 0.88);
    --mushaf-overlay: rgba(0, 0, 0, 0.65);
    background: #0f172a;
    color: #fff;
}

body[data-mushaf-theme="warm"] {
    --mushaf-accent: #d4a94e;
    --mushaf-accent-rgb: 212, 169, 78;
    --mushaf-card-bg: rgba(255, 220, 120, 0.05);
    --mushaf-card-border: rgba(255, 200, 80, 0.1);
    --mushaf-text: #f5e6c8;
    --mushaf-subtext: #c4a97a;
    --mushaf-arabic: #f5e6c8;
    --mushaf-page-bg: linear-gradient(180deg, #1a1208, #231a0c);
    --mushaf-page-text: #f5e6c8;
    --mushaf-page-shadow: rgba(0, 0, 0, 0.5);
    --mushaf-page-border: rgba(212, 169, 78, 0.15);
    --mushaf-drawer-bg: #231a0c;
    --mushaf-tool-bg: rgba(255, 220, 120, 0.08);
    --mushaf-toolbar-bg: rgba(26, 18, 8, 0.88);
    --mushaf-overlay: rgba(0, 0, 0, 0.65);
    background: #1a1208;
    color: #f5e6c8;
}

body[data-mushaf-theme="olive"] {
    --mushaf-accent: #2dd4bf;
    --mushaf-accent-rgb: 45, 212, 191;
    --mushaf-card-bg: rgba(45, 212, 191, 0.04);
    --mushaf-card-border: rgba(45, 212, 191, 0.1);
    --mushaf-text: #e8f5f4;
    --mushaf-subtext: #8fb5b2;
    --mushaf-arabic: #f0faf9;
    --mushaf-page-bg: linear-gradient(180deg, #0a1918, #0d1f1e);
    --mushaf-page-text: #e8f5f4;
    --mushaf-page-shadow: rgba(0, 0, 0, 0.45);
    --mushaf-page-border: rgba(45, 212, 191, 0.15);
    --mushaf-drawer-bg: #0d1f1e;
    --mushaf-tool-bg: rgba(45, 212, 191, 0.07);
    --mushaf-toolbar-bg: rgba(10, 25, 24, 0.88);
    --mushaf-overlay: rgba(0, 0, 0, 0.65);
    background: #0a1918;
    color: #e8f5f4;
}

body[data-mushaf-theme="sapphire"] {
    --mushaf-accent: #818cf8;
    --mushaf-accent-rgb: 129, 140, 248;
    --mushaf-card-bg: rgba(129, 140, 248, 0.05);
    --mushaf-card-border: rgba(129, 140, 248, 0.12);
    --mushaf-text: #e0e7ff;
    --mushaf-subtext: #7c86b5;
    --mushaf-arabic: #f0f4ff;
    --mushaf-page-bg: linear-gradient(180deg, #080c1a, #0e1225);
    --mushaf-page-text: #e0e7ff;
    --mushaf-page-shadow: rgba(0, 0, 0, 0.5);
    --mushaf-page-border: rgba(129, 140, 248, 0.15);
    --mushaf-drawer-bg: #0e1225;
    --mushaf-tool-bg: rgba(129, 140, 248, 0.08);
    --mushaf-toolbar-bg: rgba(8, 12, 26, 0.88);
    --mushaf-overlay: rgba(0, 0, 0, 0.65);
    background: #080c1a;
    color: #e0e7ff;
}

body[data-mushaf-theme="light"] {
    --mushaf-accent: #059669;
    --mushaf-accent-rgb: 5, 150, 105;
    --mushaf-card-bg: #ffffff;
    --mushaf-card-border: rgba(0, 0, 0, 0.07);
    --mushaf-text: #0f172a;
    --mushaf-subtext: #475569;
    --mushaf-arabic: #0f172a;
    --mushaf-page-bg: #ffffff;
    --mushaf-page-text: #0f172a;
    --mushaf-page-shadow: rgba(0, 0, 0, 0.15);
    --mushaf-page-border: rgba(0, 0, 0, 0.08);
    --mushaf-drawer-bg: #ffffff;
    --mushaf-tool-bg: rgba(0, 0, 0, 0.05);
    --mushaf-toolbar-bg: rgba(255, 255, 255, 0.92);
    --mushaf-overlay: rgba(0, 0, 0, 0.35);
    background: #f8fafc;
    color: #0f172a;
}

/* When the reader theme is dark/warm/olive/sapphire we hide the cream-paper look
   and use the themed page background. Only the "light" theme keeps the cream paper. */

/* TOOLBAR (sticky, below navbar) */

.mushaf-toolbar {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    z-index: 950;
    background: var(--mushaf-toolbar-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0.7rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.mushaf-toolbar .view-toggle-wrap {
    display: flex;
    background: var(--mushaf-tool-bg);
    border-radius: 14px;
    padding: 4px;
    border: 1px solid var(--border);
}

.view-toggle-btn {
    border: none;
    background: transparent;
    color: var(--mushaf-subtext);
    padding: 0.55rem 1rem;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    transition: background 0.2s, color 0.2s;
}

.view-toggle-btn:hover {
    color: var(--mushaf-accent);
}

.view-toggle-btn.active {
    background: var(--mushaf-accent);
    color: #fff;
}

.view-toggle-btn svg {
    width: 16px;
    height: 16px;
}

/* Navigator (prev / dropdown / next) */

.nav-navigator {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.nav-arrow {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--mushaf-tool-bg);
    color: var(--mushaf-text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.nav-arrow:hover {
    background: var(--mushaf-accent);
    color: #fff;
}

.nav-selector-wrap {
    position: relative;
}

.nav-selector-btn {
    min-width: 160px;
    background: var(--mushaf-tool-bg);
    border: 1px solid var(--border);
    color: var(--mushaf-text);
    padding: 0.55rem 1rem;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.88rem;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.nav-selector-btn:hover {
    border-color: var(--mushaf-accent);
}

.nav-selector-btn svg {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

.nav-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 280px;
    background: var(--mushaf-drawer-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    z-index: 980;
    padding: 0.6rem;
    overflow: hidden;
}

body.light-mode .nav-dropdown {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.1);
}

.nav-dropdown-tabs {
    display: flex;
    gap: 4px;
    background: var(--mushaf-tool-bg);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 0.6rem;
}

.nav-tab {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--mushaf-subtext);
    padding: 0.45rem 0.2rem;
    border-radius: 7px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
    text-align: center;
}

.nav-tab.active {
    background: var(--mushaf-accent);
    color: #fff;
}

.nav-search-input {
    width: 100%;
    padding: 0.55rem 0.85rem;
    background: var(--mushaf-tool-bg);
    border: 1px solid var(--border);
    color: var(--mushaf-text);
    border-radius: 10px;
    outline: none;
    font-family: inherit;
    font-size: 0.88rem;
    margin-bottom: 0.5rem;
}

body.light-mode .nav-search-input {
    background: #f8fafc;
}

.nav-search-input:focus {
    border-color: var(--mushaf-accent);
}

.nav-list {
    max-height: 320px;
    overflow-y: auto;
    padding-right: 4px;
}

/* Ayah navigation panel */
.nav-ayah-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.25rem 0.1rem;
}

.nav-ayah-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.nav-ayah-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-ayah-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--mushaf-subtext);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.nav-ayah-range {
    font-size: 0.75rem;
    color: var(--mushaf-accent);
    font-weight: 600;
}

.nav-ayah-select,
.nav-ayah-input {
    width: 100%;
    padding: 0.55rem 0.8rem;
    background: var(--mushaf-tool-bg);
    border: 1px solid var(--border);
    color: var(--mushaf-text);
    border-radius: 10px;
    outline: none;
    font-family: inherit;
    font-size: 0.88rem;
    transition: border-color 0.2s;
}

body.light-mode .nav-ayah-select,
body.light-mode .nav-ayah-input {
    background: #f8fafc;
}

.nav-ayah-select:focus,
.nav-ayah-input:focus {
    border-color: var(--mushaf-accent);
}

.nav-ayah-select option {
    background: var(--mushaf-drawer-bg);
    color: var(--mushaf-text);
}

body.light-mode .nav-ayah-select option {
    background: #ffffff;
    color: #0f172a;
}

.nav-ayah-go-btn {
    width: 100%;
    padding: 0.6rem;
    background: var(--mushaf-accent);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.2s, transform 0.1s;
    margin-top: 0.25rem;
}

.nav-ayah-go-btn:hover {
    filter: brightness(1.1);
}

.nav-ayah-go-btn:active {
    transform: scale(0.98);
}

.nav-list-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.65rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
}

.nav-list-item:hover {
    background: rgba(var(--mushaf-accent-rgb), 0.12);
}

.nav-list-item.active {
    background: rgba(var(--mushaf-accent-rgb), 0.18);
}

.nav-list-num {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(var(--mushaf-accent-rgb), 0.15);
    color: var(--mushaf-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.nav-list-info {
    flex: 1;
    min-width: 0;
}

.nav-list-name {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--mushaf-text);
}

.nav-list-meta {
    font-size: 0.75rem;
    color: var(--mushaf-subtext);
}

.nav-list-arabic {
    font-family: "Amiri", "Noto Naskh Arabic", serif;
    color: var(--mushaf-text);
    font-size: 1.1rem;
}

/* Tools group on the right */

.tools-group {
    margin-left: auto;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tool-btn {
    border: 1px solid var(--border);
    background: var(--mushaf-tool-bg);
    color: var(--mushaf-text);
    padding: 0.55rem 0.9rem;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.82rem;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.tool-btn:hover {
    border-color: var(--mushaf-accent);
    color: var(--mushaf-accent);
}

.tool-btn.active {
    background: rgba(var(--mushaf-accent-rgb), 0.18);
    color: var(--mushaf-accent);
    border-color: rgba(var(--mushaf-accent-rgb), 0.4);
}

.tool-btn svg {
    width: 16px;
    height: 16px;
}

.tool-indicator {
    background: rgba(var(--mushaf-accent-rgb), 0.15);
    color: var(--mushaf-accent);
    padding: 0.1rem 0.45rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
}

.tool-indicator.active {
    background: var(--mushaf-accent);
    color: #fff;
}

/* READ AREA */

.mushaf-read-area {
    margin-top: 56px;
    padding: 5rem 1.5rem 6rem;
    min-height: 100vh;
    color: var(--mushaf-text);
    transition: background 0.3s, color 0.3s;
}

/* LOADER */

.mushaf-loader {
    text-align: center;
    padding: 6rem 1rem;
    color: var(--mushaf-subtext);
}

.loader-circle {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: rgba(var(--mushaf-accent-rgb), 0.12);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--mushaf-accent);
}

.loader-circle svg {
    width: 24px;
    height: 24px;
}

/* PAGE VIEW — single page at a time, book-like layout */

.page-view {
    max-width: 720px;
    margin: 0 auto;
}

.page-container {
    position: relative;
    cursor: pointer;
    user-select: none;
}

.mushaf-page {
    background: var(--mushaf-page-bg);
    color: var(--mushaf-page-text);
    border: 2px solid var(--mushaf-page-border);
    border-radius: 8px;
    padding: 2rem 1.8rem 2.5rem;
    min-height: 75vh;
    box-shadow: none;
    font-family: "Amiri Quran", "Amiri", "Noto Naskh Arabic", serif;
    font-size: 1.6rem;
    line-height: 2.2;
    direction: rtl;
    text-align: justify;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Decorative inner border (like traditional Mushaf) */
.mushaf-page::before {
    content: "";
    position: absolute;
    inset: 8px;
    border: 1px solid var(--mushaf-page-border);
    border-radius: 4px;
    pointer-events: none;
    opacity: 0.5;
}

/* Decorative surah banner — shown when a surah starts (at top OR mid-page).
   Centered surah name with ornamental lines on both sides, like quran.com. */
.surah-banner-decorative {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 1.5rem 0 0.5rem;
    padding: 0.8rem 0;
    text-align: center;
}

.surah-banner-decorative .sbd-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0 1rem;
}

.surah-banner-decorative .sbd-arabic {
    font-family: "Amiri", "Scheherazade New", serif;
    font-size: 1.5rem;
    color: var(--mushaf-accent);
    line-height: 1.4;
    font-weight: 700;
}

.surah-banner-decorative .sbd-name {
    font-family: "Poppins", sans-serif;
    font-size: 0.7rem;
    color: var(--mushaf-subtext);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.surah-banner-decorative .sbd-ornament {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--mushaf-page-border), transparent);
    max-width: 120px;
    position: relative;
}

.surah-banner-decorative .sbd-ornament::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--mushaf-page-border);
}

/* Bismillah — shown after the surah banner, clearly separated from ayah text.
   (Previously defined twice with overlapping properties that merged via
   cascade order — consolidated here into one rule with the same final
   computed values: font-size/margin from the later rule, padding/
   line-height from the earlier one, since neither overrode those.) */
.page-bismillah {
    text-align: center;
    font-family: "Amiri Quran", "Amiri", serif;
    font-size: 1.7rem;
    color: var(--mushaf-page-text);
    margin: 1rem 0 1.5rem;
    padding: 0.3rem 0;
    line-height: 1.8;
}

/* Simple info bar at top of mid-surah pages */
.page-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0.5rem 0.8rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--mushaf-page-border);
    font-family: "Poppins", sans-serif;
    font-size: 0.75rem;
    color: var(--mushaf-subtext);
    flex-shrink: 0;
}

.page-info-surah,
.page-info-juz {
    font-weight: 600;
}

/* Ayah text flow container — takes up remaining space, content flows naturally */
.mushaf-page .ayah-text-flow {
    flex: 1;
    font-family: "Amiri Quran", "Amiri", "Noto Naskh Arabic", serif;
    color: var(--mushaf-page-text);
    line-height: 2.4;  /* generous spacing so ayah lines don't jam together */
}

/* On mobile, increase line spacing even more to prevent text from feeling cramped */
@media (max-width: 768px) {
    .mushaf-page .ayah-text-flow {
        line-height: 2.6;
    }
}

/* Short surah pages (≤ 15 ayahs) — center-align the text for a cleaner look,
   like quranwbw.com does for short surahs. Each ayah on its own line. */
.mushaf-page.short-surah-page .ayah-text-flow {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    line-height: 2;
}

.mushaf-page.short-surah-page .ayah-flow {
    display: block;
    text-align: center;
    line-height: 2.2;
    margin-bottom: 0.3rem;
    font-size: 1.15em;
    /* Slightly larger for short surahs */
}

/* Surah separator within a page */
.surah-separator {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin: 1rem 0;
    text-align: center;
}

.surah-separator .sep-line {
    flex: 1;
    height: 1px;
    background: var(--mushaf-page-border);
    max-width: 80px;
}

.surah-separator .sep-arabic {
    font-family: "Amiri", serif;
    font-size: 1.3rem;
    color: var(--mushaf-accent);
}

.surah-separator .sep-name {
    font-family: "Poppins", sans-serif;
    font-size: 0.7rem;
    color: var(--mushaf-subtext);
    text-transform: uppercase;
}

/* Page number at the bottom center (traditional Mushaf style) */
.page-number-footer {
    padding-top: 1rem;
    text-align: center;
    flex-shrink: 0;
}

.page-number-circle {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--mushaf-page-border);
    color: var(--mushaf-page-text);
    font-family: "Poppins", sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
    opacity: 0.7;
}

.mushaf-page .ayah-text-flow .word {
    cursor: pointer;
    padding: 0 0.05em;
    border-radius: 4px;
    display: inline;
    transition: background 0.15s;
}

/* Inner tajweed color spans should NOT intercept pointer events —
   clicks must pass through to the parent .word span */
.mushaf-page .ayah-text-flow .word>span,
.verse-arabic .word>span {
    pointer-events: none;
}

.mushaf-page .ayah-text-flow .word:hover {
    background: rgba(var(--mushaf-accent-rgb), 0.22);
}

.mushaf-page .ayah-text-flow .word:hover>* {
    filter: brightness(1.15);
}

/* Traditional Quran ayah marker — ornamental 8-pointed star/rosette design.
   Uses CSS to create a decorative flower-like shape with the number inside.
   Inspired by the markers in the Madinah Mushaf print. */
.mushaf-page .ayah-text-flow .ayah-marker {
    display: inline-grid;
    place-items: center;
    margin: 0 0.25em;
    color: var(--mushaf-accent);
    font-family: "Amiri", "Poppins", sans-serif;
    font-weight: 700;
    font-size: 0.55em;
    cursor: pointer;
    /* Use an SVG background for the ornamental flower shape */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cg fill='none' stroke='%2310b981' stroke-width='2'%3E%3Ccircle cx='50' cy='50' r='38'/%3E%3Ccircle cx='50' cy='50' r='32' stroke-width='1' opacity='0.5'/%3E%3C/g%3E%3Cg fill='%2310b981' opacity='0.15'%3E%3Cpath d='M50 8 L56 30 L78 22 L66 42 L88 50 L66 58 L78 78 L56 70 L50 92 L44 70 L22 78 L34 58 L12 50 L34 42 L22 22 L44 30 Z'/%3E%3C/g%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: transparent;
    border: none;
    border-radius: 0;
    width: 2.4em;
    height: 2.4em;
    line-height: 1;
    text-align: center;
    vertical-align: middle;
    box-sizing: border-box;
    padding: 0;
    outline: none;
    user-select: none;
    position: relative;
    top: -0.1em;
}

.mushaf-page .ayah-text-flow .ayah-marker:hover {
    filter: brightness(1.2) saturate(1.3);
    transform: scale(1.1);
    transition: transform 0.15s, filter 0.15s;
}

.mushaf-page .ayah-text-flow .ayah-marker.playing {
    filter: brightness(1.3) saturate(1.5);
    transform: scale(1.15);
}

/* Brief highlight flash when jumping to a specific ayah in Page View
   (e.g. from a bookmark) — same visual language as .verse-card.active-ayah
   in Surah View, adapted for the smaller inline marker glyph. */
.mushaf-page .ayah-text-flow .ayah-marker.active-ayah {
    filter: brightness(1.4) saturate(1.6);
    transform: scale(1.25);
    box-shadow: 0 0 0 4px rgba(var(--mushaf-accent-rgb), 0.3);
    border-radius: 50%;
}

/* .page-bismillah is defined once, above, in the "SURAH VIEW" section. */

/* Page bottom bar (page slider) */

.page-bottom-bar {
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--mushaf-subtext);
    font-size: 0.85rem;
    font-family: "Poppins", sans-serif;
}

.page-num-label {
    font-weight: 600;
    color: var(--mushaf-text);
}

.page-jump-bar {
    flex: 1;
}

#page-slider {
    width: 100%;
    accent-color: var(--mushaf-accent);
}

/* SURAH VIEW — continuous ayah-by-ayah */

.surah-view {
    max-width: 800px;
    margin: 0 auto;
}

.surah-banner {
    text-align: center;
    padding: 1.5rem 1rem 2rem;
    border-bottom: 1px solid var(--mushaf-card-border);
    margin-bottom: 2rem;
}

.surah-banner-arabic {
    font-family: "Amiri", serif;
    font-size: 3rem;
    color: var(--mushaf-accent);
    margin-bottom: 0.4rem;
    direction: rtl;
}

.surah-banner-title {
    font-size: 1.6rem;
    color: var(--mushaf-text);
    margin-bottom: 0.4rem;
    font-weight: 700;
}

.surah-banner-meta {
    color: var(--mushaf-subtext);
    font-size: 0.92rem;
}

.bismillah-header {
    text-align: center;
    font-family: "Amiri Quran", "Amiri", serif;
    font-size: 2.2rem;
    color: var(--mushaf-accent);
    margin: 1.5rem 0 2rem;
    letter-spacing: 1px;
}

.surah-verses {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Verse card (used in Surah view) */

.verse-card {
    background: var(--mushaf-card-bg);
    border: 1px solid var(--mushaf-card-border);
    border-radius: 22px;
    padding: 1.8rem 2rem 1.4rem;
    transition: border-color 0.3s, transform 0.3s;
    position: relative;
}

.verse-card:hover {
    border-color: rgba(var(--mushaf-accent-rgb), 0.35);
    transform: translateY(-2px);
}

.verse-card.active-ayah {
    border-color: var(--mushaf-accent);
    box-shadow: 0 0 0 1px var(--mushaf-accent), 0 15px 40px rgba(0, 0, 0, 0.25);
}

.verse-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.verse-number {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--mushaf-accent);
    color: #0f172a;
    display: inline-grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.9rem;
    font-family: "Poppins", sans-serif;
    flex-shrink: 0;
    line-height: 1;
    padding: 0;
    box-sizing: border-box;
}

.verse-actions {
    display: flex;
    gap: 0.4rem;
}

.verse-action {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: var(--mushaf-tool-bg);
    color: var(--mushaf-subtext);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s, transform 0.15s;
}

.verse-action:hover {
    background: rgba(var(--mushaf-accent-rgb), 0.15);
    color: var(--mushaf-accent);
    transform: translateY(-1px);
}

.verse-action.active {
    background: rgba(var(--mushaf-accent-rgb), 0.25);
    color: var(--mushaf-accent);
}

.verse-action svg {
    width: 16px;
    height: 16px;
}

.verse-arabic {
    font-family: "Amiri Quran", "Amiri", "Noto Naskh Arabic", serif;
    font-size: 2.2rem;
    line-height: 2.1;
    text-align: right;
    direction: rtl;
    color: var(--mushaf-arabic);
    margin: 0.4rem 0 1rem;
    cursor: text;
    word-spacing: 0.05em;
}

.verse-arabic .word {
    cursor: pointer;
    padding: 0 0.1em;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}

.verse-arabic .word:hover {
    background: rgba(var(--mushaf-accent-rgb), 0.25);
}

.verse-arabic .ayah-marker {
    display: inline-block;
    margin: 0 0.15em;
    color: var(--mushaf-accent);
    font-family: "Amiri Quran", "Amiri", serif;
    font-weight: 700;
    font-size: 0.8em;
    cursor: pointer;
    background: rgba(var(--mushaf-accent-rgb), 0.12);
    border-radius: 50%;
    width: 1.5em;
    height: 1.5em;
    line-height: 1.5em;
    text-align: center;
    vertical-align: middle;
}

.verse-translations {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    margin-top: 0.4rem;
}

.verse-translation-block {
    padding: 0.7rem 0.9rem;
    background: var(--mushaf-tool-bg);
    border-left: 3px solid var(--mushaf-accent);
    border-radius: 8px;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--mushaf-subtext);
}

.verse-translation-block .vt-lang {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--mushaf-accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.verse-translit {
    font-style: italic;
    color: var(--mushaf-subtext);
    font-size: 0.95rem;
    margin-bottom: 0.6rem;
    padding-left: 0.5rem;
    border-left: 2px solid var(--mushaf-card-border);
}

/* Tajweed color classes (applied via spans in JS) */

.taj-ghunnah {
    color: var(--taj-ghunnah);
}

.taj-ikhfa {
    color: var(--taj-ikhfa);
}

.taj-idgham {
    color: var(--taj-idgham);
}

.taj-iqlab {
    color: var(--taj-iqlab);
}

.taj-qalqalah {
    color: var(--taj-qalqalah);
}

.taj-madd {
    color: var(--taj-madd);
}

.tajweed-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-top: 0.8rem;
}

.tajweed-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--mushaf-subtext);
}

.taj-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* Tajweed guide — detailed explanations in settings drawer */
.tajweed-guide {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.tajweed-guide-item {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.6rem 0.7rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.tajweed-guide-item .taj-dot {
    margin-top: 3px;
    width: 14px;
    height: 14px;
}

.tajweed-guide-item .sign-icon {
    margin-top: 2px;
    min-width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.tajweed-guide-item div {
    flex: 1;
}

.tajweed-guide-item strong {
    display: block;
    font-size: 0.82rem;
    color: var(--mushaf-text, #fff);
    margin-bottom: 0.2rem;
}

.tajweed-guide-item p {
    font-size: 0.72rem;
    color: var(--mushaf-subtext, #94a3b8);
    line-height: 1.5;
    margin: 0;
}

body.light-mode .tajweed-guide-item,
[data-mushaf-theme="light"] .tajweed-guide-item {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.06);
}

[data-mushaf-theme="light"] .tajweed-guide-item strong {
    color: #0f172a;
}

/* When tajweed is OFF, hide all colors */

.mushaf-read-area.tajweed-off .taj-ghunnah,
.mushaf-read-area.tajweed-off .taj-ikhfa,
.mushaf-read-area.tajweed-off .taj-idgham,
.mushaf-read-area.tajweed-off .taj-iqlab,
.mushaf-read-area.tajweed-off .taj-qalqalah,
.mushaf-read-area.tajweed-off .taj-madd {
    color: inherit !important;
}

/* SIDE DRAWERS (right side) */

.side-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(420px, 92vw);
    background: var(--mushaf-drawer-bg);
    border-left: 1px solid var(--border);
    box-shadow: none;
    /* No shadow when closed — prevents shadow bleed on right edge */
    z-index: 2000;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.side-drawer.open {
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.4);
}

.side-drawer.open {
    transform: translateX(0);
}

.drawer-head {
    padding: 1.3rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.drawer-head h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--mushaf-text);
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}

.drawer-head svg {
    width: 18px;
    height: 18px;
    color: var(--mushaf-accent);
}

.drawer-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: var(--mushaf-tool-bg);
    color: var(--mushaf-text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s, transform 0.15s;
}

.drawer-close:hover {
    background: rgba(var(--mushaf-accent-rgb), 0.2);
    color: var(--mushaf-accent);
    transform: rotate(90deg);
}

.drawer-body {
    padding: 1.2rem 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.drawer-hint {
    color: var(--mushaf-subtext);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.drawer-section {
    margin-top: 1.5rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--border);
}

.drawer-section:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.drawer-label {
    display: block;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--mushaf-subtext);
    margin-bottom: 0.7rem;
    font-weight: 600;
}

.drawer-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.drawer-buttons button,
.toggle-btn {
    border: none;
    background: var(--mushaf-tool-bg);
    color: var(--mushaf-text);
    padding: 0.55rem 0.95rem;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.82rem;
    transition: background 0.2s, color 0.2s;
}

.drawer-buttons button:hover,
.toggle-btn:hover {
    background: rgba(var(--mushaf-accent-rgb), 0.15);
    color: var(--mushaf-accent);
}

.drawer-buttons button.active,
.toggle-btn.active {
    background: var(--mushaf-accent);
    color: #fff;
}

#replay-tour-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#replay-tour-btn svg {
    width: 15px;
    height: 15px;
}

/* Translation list inside drawer */

.translation-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.translation-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.translation-item:hover {
    border-color: var(--mushaf-accent);
}

.translation-item.active {
    background: rgba(var(--mushaf-accent-rgb), 0.12);
    border-color: var(--mushaf-accent);
}

.translation-checkbox {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 2px solid var(--border);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: transparent;
    transition: background 0.15s;
}

.translation-item.active .translation-checkbox {
    background: var(--mushaf-accent);
    border-color: var(--mushaf-accent);
}

.translation-info {
    flex: 1;
    min-width: 0;
}

.translation-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--mushaf-text);
}

.translation-author {
    font-size: 0.75rem;
    color: var(--mushaf-subtext);
}

/* Theme swatches */

.theme-swatches {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.8rem;
    margin-top: 0.5rem;
}

.theme-swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.theme-swatch:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.theme-swatch.active {
    border-color: var(--mushaf-accent);
    transform: scale(1.1);
    box-shadow: 0 0 0 2px rgba(var(--mushaf-accent-rgb), 0.3), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.theme-swatch.active::after {
    content: "✓";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.swatch-dark {
    background: linear-gradient(135deg, #0f172a, #111827);
}

.swatch-warm {
    background: linear-gradient(135deg, #1a1208, #231a0c);
    border: 3px solid #d4a94e;
}

.swatch-olive {
    background: linear-gradient(135deg, #0a1918, #0d1f1e);
    border: 3px solid #2dd4bf;
}

.swatch-sapphire {
    background: linear-gradient(135deg, #080c1a, #0e1225);
    border: 3px solid #818cf8;
}

.swatch-light {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border: 3px solid #059669;
}

/* BOOKMARKS (inside drawer) */

.bookmarks-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.bookmarks-toolbar #bookmarks-count {
    color: var(--mushaf-subtext);
    font-size: 0.85rem;
    font-weight: 600;
}

.danger-btn {
    border: none;
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.78rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.danger-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

.danger-btn svg {
    width: 14px;
    height: 14px;
}

.bookmarks-list {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.bookmarks-empty {
    text-align: center;
    padding: 2rem 1rem;
    border-radius: 14px;
    border: 1px dashed var(--border);
    color: var(--mushaf-subtext);
}

.bookmarks-empty svg {
    width: 32px;
    height: 32px;
    color: var(--mushaf-accent);
    margin-bottom: 0.6rem;
}

.bookmarks-empty p {
    font-size: 0.85rem;
    margin: 0;
}

.bookmark-item {
    padding: 0.8rem 0.9rem;
    background: var(--mushaf-card-bg);
    border: 1px solid var(--mushaf-card-border);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.15s;
}

.bookmark-item:hover {
    border-color: var(--mushaf-accent);
    transform: translateY(-1px);
}

.bookmark-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.bookmark-tag {
    background: rgba(var(--mushaf-accent-rgb), 0.15);
    color: var(--mushaf-accent);
    padding: 0.18rem 0.55rem;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.bookmark-date {
    font-size: 0.72rem;
    color: var(--mushaf-subtext);
}

.bookmark-arabic {
    font-family: "Amiri", serif;
    font-size: 1.2rem;
    line-height: 1.7;
    direction: rtl;
    text-align: right;
    color: var(--mushaf-text);
    margin: 0.3rem 0;
}

.bookmark-translation {
    font-size: 0.82rem;
    color: var(--mushaf-subtext);
    line-height: 1.6;
    /* clamp 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* TAFSIR DRAWER */

.tafsir-drawer {
    width: min(540px, 94vw);
}

.tafsir-tabs {
    display: flex;
    gap: 4px;
    background: var(--mushaf-tool-bg);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 1rem;
}

.tafsir-tab {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--mushaf-subtext);
    padding: 0.5rem;
    border-radius: 7px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.78rem;
    transition: background 0.18s, color 0.18s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    flex-direction: column;
    line-height: 1.3;
}

.tafsir-tab small {
    font-size: 0.65rem;
    font-weight: 500;
    opacity: 0.7;
}

.tafsir-tab.active {
    background: var(--mushaf-accent);
    color: #fff;
}

.tafsir-tab.active small {
    opacity: 0.85;
}

.tafsir-content {
    line-height: 1.85;
    color: var(--mushaf-text);
    font-size: 0.95rem;
}

.tafsir-content p {
    margin-bottom: 0.8rem;
}

.tafsir-content-arabic {
    font-family: "Amiri", "Noto Naskh Arabic", serif;
    font-size: 1.2rem !important;
    line-height: 2;
}

.tafsir-content-english {
    /* default — uses .tafsir-content styles */
}

.tafsir-empty {
    color: var(--mushaf-subtext);
    text-align: center;
    padding: 2rem 1rem;
    font-style: italic;
}

.tafsir-loading {
    color: var(--mushaf-subtext);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tafsir-verse-head {
    background: var(--mushaf-tool-bg);
    padding: 0.8rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    border-left: 3px solid var(--mushaf-accent);
}

.tafsir-verse-head .tv-arabic {
    font-family: "Amiri", serif;
    font-size: 1.3rem;
    direction: rtl;
    text-align: right;
    margin-bottom: 0.3rem;
    color: var(--mushaf-text);
}

.tafsir-verse-head .tv-ref {
    font-size: 0.78rem;
    color: var(--mushaf-accent);
    font-weight: 700;
}

/* RECITER LIST (drawer) */

.drawer-search {
    width: 100%;
    padding: 0.6rem 0.9rem;
    background: var(--mushaf-tool-bg);
    border: 1px solid var(--border);
    color: var(--mushaf-text);
    border-radius: 10px;
    outline: none;
    font-family: inherit;
    font-size: 0.88rem;
    margin-bottom: 0.8rem;
}

.drawer-search:focus {
    border-color: var(--mushaf-accent);
}

.reciter-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.reciter-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.65rem 0.8rem;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.reciter-item:hover {
    background: rgba(var(--mushaf-accent-rgb), 0.1);
}

.reciter-item.active {
    background: rgba(var(--mushaf-accent-rgb), 0.15);
}

.reciter-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(var(--mushaf-accent-rgb), 0.15);
    border: 1.5px solid rgba(var(--mushaf-accent-rgb), 0.35);
    color: var(--mushaf-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
}

.reciter-info {
    flex: 1;
    min-width: 0;
}

.reciter-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--mushaf-text);
}

.reciter-country {
    font-size: 0.75rem;
    color: var(--mushaf-subtext);
}

.reciter-check {
    color: var(--mushaf-accent);
    opacity: 0;
}

.reciter-item.active .reciter-check {
    opacity: 1;
}

/* WORD-BY-WORD MODAL */

.word-modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--mushaf-overlay);
    backdrop-filter: blur(8px);
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.word-modal {
    background: var(--mushaf-drawer-bg);
    border: 1px solid var(--border);
    border-radius: 22px;
    width: min(460px, 96vw);
    padding: 2rem 1.8rem 1.4rem;
    position: relative;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
    animation: popIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.92);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.word-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: var(--mushaf-tool-bg);
    color: var(--mushaf-text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.word-modal-body {
    text-align: center;
}

.word-modal .wm-arabic {
    font-family: "Amiri Quran", "Amiri", serif;
    font-size: 3rem;
    direction: rtl;
    color: var(--mushaf-text);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.word-modal .wm-translit {
    color: var(--mushaf-accent);
    font-style: italic;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--border);
}

.word-modal .wm-translation {
    color: var(--mushaf-subtext);
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.word-modal .wm-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 0.8rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--border);
}

.wm-chip {
    background: var(--mushaf-tool-bg);
    color: var(--mushaf-subtext);
    padding: 0.3rem 0.7rem;
    border-radius: 8px;
    font-size: 0.78rem;
}

.wm-chip strong {
    color: var(--mushaf-accent);
    margin-left: 0.3rem;
}

.word-modal-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 1rem;
}

.word-modal-nav button {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    background: var(--mushaf-tool-bg);
    color: var(--mushaf-text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.word-modal-nav button:hover {
    background: var(--mushaf-accent);
    color: #fff;
}

/* SEARCH MODAL */

.search-modal {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 100px;
}

.search-modal.open {
    display: flex;
}

.search-modal-overlay {
    position: absolute;
    inset: 0;
    background: var(--mushaf-overlay);
    backdrop-filter: blur(8px);
}

.search-modal-content {
    position: relative;
    z-index: 2;
    width: min(700px, 92%);
    background: var(--mushaf-drawer-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
}

.search-modal-head {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 1.1rem 1.3rem;
    border-bottom: 1px solid var(--border);
}

.search-modal-head svg {
    color: var(--mushaf-accent);
    width: 20px;
    height: 20px;
}

.search-modal-head input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--mushaf-text);
    font-family: inherit;
    font-size: 1rem;
}

#search-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: var(--mushaf-tool-bg);
    color: var(--mushaf-text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.search-modal-results {
    padding: 0.7rem;
    max-height: 60vh;
    overflow-y: auto;
}

.search-hint {
    text-align: center;
    color: var(--mushaf-subtext);
    padding: 2rem 1rem;
    font-size: 0.9rem;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.7rem 0.9rem;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.search-result-item:hover {
    background: rgba(var(--mushaf-accent-rgb), 0.1);
}

.search-result-num {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(var(--mushaf-accent-rgb), 0.15);
    color: var(--mushaf-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-name {
    font-weight: 600;
    color: var(--mushaf-text);
    font-size: 0.92rem;
}

.search-result-meta {
    font-size: 0.78rem;
    color: var(--mushaf-subtext);
}

.search-result-arabic {
    font-family: "Amiri", serif;
    font-size: 1.1rem;
    color: var(--mushaf-text);
}

/* FLOATING MINI PLAYER */

.floating-player {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: min(95%, 540px);
    background: var(--mushaf-drawer-bg);
    border: 1px solid var(--border);
    backdrop-filter: blur(18px);
    border-radius: 18px;
    padding: 0.9rem 1.2rem 0.8rem;
    z-index: 3000;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.floating-player[hidden] {
    display: none !important;
}

.floating-player-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
}

.floating-info {
    min-width: 0;
}

#floating-surah {
    color: var(--mushaf-text);
    font-weight: 700;
    font-size: 0.95rem;
}

#floating-ayah {
    color: var(--mushaf-subtext);
    font-size: 0.82rem;
}

.floating-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.floating-controls button {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 10px;
    background: var(--mushaf-tool-bg);
    color: var(--mushaf-text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.floating-controls button:hover {
    background: var(--mushaf-accent);
    color: #fff;
}

#mini-close:hover {
    background: #ef4444;
    color: #fff;
}

#mini-play {
    width: 46px;
    height: 46px;
    background: var(--mushaf-accent);
    color: #fff;
}

#mini-play:hover {
    background: var(--mushaf-accent);
    filter: brightness(1.1);
}

.floating-player-progress {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

#mini-progress {
    flex: 1;
    accent-color: var(--mushaf-accent);
}

#mini-time {
    color: var(--mushaf-subtext);
    font-size: 0.72rem;
    font-family: "Poppins", sans-serif;
    min-width: 90px;
    text-align: right;
}

/* AYAH POPOVER (mobile fallback for verse actions) */

.ayah-popover {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    width: min(94%, 420px);
    background: var(--mushaf-drawer-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 0.8rem 1rem 1rem;
    z-index: 3500;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.ayah-popover[hidden] {
    display: none;
}

.ayah-popover-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
}

#ayah-popover-ref {
    color: var(--mushaf-accent);
    font-weight: 700;
    font-size: 0.85rem;
}

#ayah-popover-close {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 7px;
    background: var(--mushaf-tool-bg);
    color: var(--mushaf-text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ayah-popover-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 0.5rem;
}

.popover-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.7rem 0.5rem;
    background: var(--mushaf-tool-bg);
    border: none;
    border-radius: 10px;
    color: var(--mushaf-text);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.78rem;
    transition: background 0.2s;
}

.popover-action:hover {
    background: rgba(var(--mushaf-accent-rgb), 0.15);
    color: var(--mushaf-accent);
}

.popover-action svg {
    width: 18px;
    height: 18px;
}

/* TOAST (already in style.css, override here to be sure) */

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(15, 23, 42, 0.95);
    color: var(--mushaf-accent);
    padding: 12px 18px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s ease;
    z-index: 99999;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* RESPONSIVE */

@media (max-width: 1119px) {
    .mushaf-toolbar {
        gap: 0.5rem;
    }

    .tools-group .tool-label {
        display: none;
    }

    .tool-btn {
        padding: 0.55rem 0.6rem;
    }
}

@media (max-width: 900px) {
    .page-view {
        max-width: 100%;
    }

    .mushaf-page {
        min-height: auto;
        padding: 1.5rem 1.2rem 2rem;
        font-size: 1.4rem;
        line-height: 2.1;
        aspect-ratio: auto;
    }

    .surah-header-arabic {
        font-size: 1.3rem;
    }

    .page-bismillah {
        font-size: 1.2rem;
    }
}

@media (max-width: 768px) {
    .mushaf-toolbar {
        top: 60px;
        padding: 0.5rem 0.8rem;
        gap: 0.4rem;
    }

    .mushaf-read-area {
        margin-top: 60px;
        padding: 6rem 0.8rem 5rem;
    }

    .view-toggle-btn .tool-label,
    .view-toggle-btn span:not(.tool-indicator) {
        display: none;
    }

    .view-toggle-btn {
        padding: 0.55rem 0.7rem;
    }

    .nav-selector-btn {
        min-width: 110px;
        padding: 0.5rem 0.7rem;
        font-size: 0.8rem;
    }

    .verse-card {
        padding: 1.4rem 1rem 1.2rem;
    }

    .verse-arabic {
        font-size: 1.8rem;
        line-height: 2;
    }

    .surah-banner-arabic {
        font-size: 2.2rem;
    }

    .surah-banner-title {
        font-size: 1.3rem;
    }

    .bismillah-header {
        font-size: 1.6rem;
    }

    .floating-player {
        bottom: 12px;
        width: calc(100% - 24px);
    }
}

@media (max-width: 540px) {
    .tool-btn {
        padding: 0.5rem;
    }

    .tool-indicator {
        display: none;
    }

    .mushaf-page {
        font-size: 1.3rem;
        padding: 1.5rem 1rem 2rem;
    }

    .verse-arabic {
        font-size: 1.55rem;
    }
}

/* SCROLLBAR (subtle, theme-aware) */

.mushaf-read-area ::-webkit-scrollbar,
.drawer-body::-webkit-scrollbar,
.nav-list::-webkit-scrollbar,
.search-modal-results::-webkit-scrollbar {
    width: 8px;
}

.mushaf-read-area ::-webkit-scrollbar-track,
.drawer-body::-webkit-scrollbar-track,
.nav-list::-webkit-scrollbar-track,
.search-modal-results::-webkit-scrollbar-track {
    background: transparent;
}

.mushaf-read-area ::-webkit-scrollbar-thumb,
.drawer-body::-webkit-scrollbar-thumb,
.nav-list::-webkit-scrollbar-thumb,
.search-modal-results::-webkit-scrollbar-thumb {
    background: rgba(var(--mushaf-accent-rgb), 0.3);
    border-radius: 4px;
}

.mushaf-read-area ::-webkit-scrollbar-thumb:hover,
.drawer-body::-webkit-scrollbar-thumb:hover {
    background: var(--mushaf-accent);
}

/* ANIMATION — spin (already in style.css but re-defined locally) */

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.spin {
    animation: spin 1s linear infinite;
    display: inline-block;
}

/* Highlight (for in-page search) */

.search-highlight {
    background: rgba(255, 213, 79, 0.55);
    color: #1a1a1a;
    padding: 0 2px;
    border-radius: 3px;
}

/* POPOVER TRANSLATIONS (shown in page view when ayah marker clicked) */

.popover-translations {
    grid-column: 1 / -1;
    margin-top: 0.8rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--border);
    max-height: 200px;
    overflow-y: auto;
}

.popover-translations-loading,
.popover-translations-empty {
    color: var(--mushaf-subtext);
    font-size: 0.8rem;
    text-align: center;
    padding: 0.5rem;
    font-style: italic;
}

.popover-translation-block {
    padding: 0.5rem 0.7rem;
    background: var(--mushaf-tool-bg);
    border-left: 3px solid var(--mushaf-accent);
    border-radius: 6px;
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--mushaf-subtext);
    margin-bottom: 0.4rem;
    text-align: left;
}

.popover-translation-block .vt-lang {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--mushaf-accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.2rem;
}

/* GLOW BACKGROUND — removed (was causing visual noise). Kept as hidden so any leftover refs don't break. */

.bg-glow {
    display: none !important;
}

/* Word modal play button */
.wm-play-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.2rem;
    margin: 0.5rem 0 1rem;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, rgba(var(--mushaf-accent-rgb), 1), rgba(var(--mushaf-accent-rgb), 0.8));
    color: #fff;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, filter 0.2s;
}

.wm-play-btn:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.wm-play-btn svg {
    width: 16px;
    height: 16px;
}