/**
 * Mushaf Page Mode Styles
 * Styling for traditional Quran page (Mushaf) layout display
 */

/* ============================================
 * Quran Fonts - Google Fonts Import
 * ============================================ */

/* Import Arabic fonts from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&family=Lateef&family=Noto+Naskh+Arabic:wght@400;500;600;700&family=Scheherazade+New:wght@400;500;600;700&display=swap');

/* Local Amiri fallback */
@font-face {
    font-family: 'Amiri';
    src: url('fonts/Amiri-Regular.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* KFGQPC Uthmanic Script - Traditional Mushaf font (locally added) */
@font-face {
    font-family: 'KFGQPC Uthmanic Script HAFS';
    src: url('fonts/KFGQPC Uthmanic Script HAFS Regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ============================================
 * Page Container - Traditional Mushaf Style
 * ============================================ */
.quran-page {
    direction: rtl;
    text-align: justify;
    font-family: 'KFGQPC Uthmanic Script HAFS', 'Amiri', serif;
    line-height: 1.8;
    padding: 12px 10px;
    /* Reduced padding for tighter layout */
    /* Cream/off-white background like traditional Mushaf */
    background: linear-gradient(180deg,
            #fdfcf5 0%,
            #f9f6eb 50%,
            #f5f2e6 100%);
    border: 1px solid #e8e4d4;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: relative;
    min-height: 400px;
    max-width: 100%;
    margin: 0 auto;
    overflow-x: hidden;
    /* Prevent horizontal overflow */
}

body.dark-mode .quran-page {
    background: linear-gradient(180deg,
            #1a1d1a 0%,
            #1f221f 50%,
            #181b18 100%);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* Page number badge - HIDDEN (using bottom controls instead) */
.quran-page-number {
    display: none;
}

/* ============================================
 * Mushaf Line Structure - Traditional Centered Text
 * Each line from JSON = exactly one physical line
 * Words are centered like traditional Mushaf
 * ============================================ */
.mushaf-line {
    display: block;
    text-align: center;
    margin-bottom: 0;
    padding: 4px 0;
    font-size: 1.6rem; /* Fixed size for consistency */
    position: relative;
    line-height: 2.4;
    width: 100%;
    white-space: nowrap; /* Prevent word wrapping */
}

/* Text lines specifically */
.mushaf-line.text-line {
    word-spacing: 0.15em; /* Small consistent spacing between words */
    letter-spacing: normal;
}

/* ============================================
 * Surah Header Styling
 * ============================================ */
.surah-header-line {
    display: inline-block;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 20px auto 12px;
    padding: 12px 40px;
    background: linear-gradient(135deg,
            hsla(var(--primary-hue), 50%, 92%, 0.9),
            hsla(var(--primary-hue), 45%, 88%, 0.95));
    border: 1px solid hsla(var(--primary-hue), 40%, 80%, 0.5);
    border-radius: 8px;
    color: var(--primary-dark, var(--primary-color));
    position: relative;
    white-space: nowrap;
}

body.dark-mode .surah-header-line {
    background: linear-gradient(135deg,
            hsla(var(--primary-hue), 30%, 22%, 0.9),
            hsla(var(--primary-hue), 25%, 18%, 0.95));
    border-color: hsla(var(--primary-hue), 30%, 35%, 0.5);
    color: var(--primary-color);
}

/* Decorative flourishes */
.surah-header-line::before,
.surah-header-line::after {
    content: '❦';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-color);
    opacity: 0.6;
    font-size: 1.2em;
}

.surah-header-line::before {
    right: 16px;
}

.surah-header-line::after {
    left: 16px;
}

/* ============================================
 * Basmala Styling
 * ============================================ */
.basmala-line {
    display: block;
    text-align: center;
    font-size: 1.4rem; /* Fixed size */
    margin: 16px auto;
    padding: 8px 16px;
    color: var(--primary-dark, var(--text-color));
    font-weight: 500;
    white-space: nowrap;
    width: fit-content;
}

body.dark-mode .basmala-line {
    color: var(--primary-color);
}

/* ============================================
 * Words in Mushaf Mode - Natural Inline Flow
 * ============================================ */
.quran-page .word,
.mushaf-page-content .word {
    display: inline;
    padding: 2px 4px;
    margin: 0 2px;
    border-radius: 3px;
    position: relative;
    transition:
        background-color 0.3s ease,
        color 0.2s ease;
    cursor: default;
    white-space: nowrap;
}

/* Unrevealed state - subtle hint */
.quran-page .word.unrevealed,
.mushaf-page-content .word.unrevealed {
    color: var(--text-color);
    opacity: 0.85;
}

/* Current expected word - gentle highlight */
.quran-page .word.current-expected,
.mushaf-page-content .word.current-expected {
    background: hsla(var(--primary-hue), 50%, 85%, 0.4);
    border-bottom: 2px solid var(--primary-color);
}

body.dark-mode .quran-page .word.current-expected,
body.dark-mode .mushaf-page-content .word.current-expected {
    background: hsla(var(--primary-hue), 40%, 30%, 0.4);
}

/* Revealed word - matched successfully */
.quran-page .word.revealed,
.mushaf-page-content .word.revealed {
    color: var(--primary-color);
    background: linear-gradient(135deg,
            hsla(var(--primary-hue), 60%, 92%, 0.9),
            hsla(var(--primary-hue), 50%, 88%, 0.8));
    animation: mushafWordReveal 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.dark-mode .quran-page .word.revealed,
body.dark-mode .mushaf-page-content .word.revealed {
    background: linear-gradient(135deg,
            hsla(var(--primary-hue), 40%, 28%, 0.9),
            hsla(var(--primary-hue), 35%, 24%, 0.8));
}

@keyframes mushafWordReveal {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }

    50% {
        transform: scale(1.08);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================
 * Ayah End Marker (Verse Number) - Traditional Style
 * ============================================ */
.ayah-end-marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Amiri', 'KFGQPC Uthmanic Script HAFS', serif;
    color: var(--primary-color, #3a9d74);
    width: 1.6em;
    height: 1.6em;
    margin: 0 3px;
    font-size: 0.85em;
    font-weight: 600;
    position: relative;
    vertical-align: middle;
}

/* Circular border using pseudo-element */
.ayah-end-marker::before {
    content: '';
    position: absolute;
    inset: 0;
    background: hsla(var(--primary-hue, 150), 50%, 95%, 0.8);
    border: 1.5px solid var(--primary-color, #3a9d74);
    border-radius: 50%;
}

/* Number text sits above the decorations */
.ayah-end-marker span {
    position: relative;
    z-index: 1;
    line-height: 1;
}

body.dark-mode .ayah-end-marker {
    color: var(--primary-color, #4eba8a);
}

body.dark-mode .ayah-end-marker::before {
    background: hsla(var(--primary-hue, 150), 30%, 20%, 0.8);
    border-color: var(--primary-color, #4eba8a);
}

/* Group last word with verse marker to prevent wrapping */
.word-marker-group {
    display: inline;
    white-space: nowrap;
}

.word-marker-group .word {
    /* Inherits inline display */
}

.word-marker-group .ayah-end-marker {
    margin-left: 2px;
    margin-right: 4px;
}

/* ============================================
 * Font Controls (Size + Style)
 * ============================================ */
.mushaf-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 0;
    margin-bottom: 12px;
    border-bottom: 1px solid hsla(var(--primary-hue), 30%, 80%, 0.3);
}

.mushaf-font-size-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mushaf-font-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    background: var(--card-bg, #fff);
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.mushaf-font-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.mushaf-font-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

body.dark-mode .mushaf-font-btn {
    background: var(--card-bg-dark, #2a2f2d);
    border-color: rgba(255, 255, 255, 0.15);
}

.mushaf-font-size-label {
    font-size: 0.8rem;
    color: var(--muted-text);
    min-width: 40px;
    text-align: center;
}

/* Font style toggle */
.mushaf-font-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mushaf-font-toggle-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    background: var(--card-bg, #fff);
    color: var(--text-color);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mushaf-font-toggle-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.mushaf-font-toggle-btn:hover:not(.active) {
    border-color: var(--primary-color);
}

body.dark-mode .mushaf-font-toggle-btn {
    background: var(--card-bg-dark, #2a2f2d);
    border-color: rgba(255, 255, 255, 0.15);
}

body.dark-mode .mushaf-font-toggle-btn.active {
    background: var(--primary-color);
}

/* ============================================
 * Font Family Classes
 * ============================================ */

.quran-page.font-amiri {
    font-family: 'Amiri', serif;
}

.quran-page.font-scheherazade {
    font-family: 'Scheherazade New', 'Amiri', serif;
}

.quran-page.font-lateef {
    font-family: 'Lateef', 'Amiri', serif;
}

.quran-page.font-noto-naskh {
    font-family: 'Noto Naskh Arabic', 'Amiri', serif;
}

.quran-page.font-kfgqpc-uthmanic {
    font-family: 'KFGQPC Uthmanic Script HAFS', 'Amiri', serif;
}

/* ============================================
 * Font Dropdown Selector
 * ============================================ */
.mushaf-font-select {
    padding: 6px 12px;
    padding-right: 30px;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    background: var(--card-bg, #fff);
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    min-width: 140px;
}

.mushaf-font-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px hsla(var(--primary-hue), 50%, 50%, 0.15);
}

body.dark-mode .mushaf-font-select {
    background-color: var(--card-bg-dark, #2a2f2d);
    border-color: rgba(255, 255, 255, 0.15);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23aaa' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}

/* ============================================
 * Layout Scale Classes - Scale entire container
 * ============================================ */
.quran-page.layout-scale-xs {
    transform: scale(0.75);
    transform-origin: top center;
    margin-bottom: -25%;
    /* Compensate for scaled height */
}

.quran-page.layout-scale-sm {
    transform: scale(0.85);
    transform-origin: top center;
    margin-bottom: -15%;
}

.quran-page.layout-scale-md {
    transform: scale(1);
    transform-origin: top center;
}

.quran-page.layout-scale-lg {
    transform: scale(1.1);
    transform-origin: top center;
    margin-bottom: 10%;
}

.quran-page.layout-scale-xl {
    transform: scale(1.2);
    transform-origin: top center;
    margin-bottom: 20%;
}

/* Scale controls styling */
.mushaf-scale-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mushaf-scale-label {
    font-size: 0.8rem;
    color: var(--muted-text);
    min-width: 40px;
    text-align: center;
}

/* ============================================
 * Page Navigation
 * ============================================ */
.mushaf-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 12px 0;
    border-top: 1px solid hsla(var(--primary-hue), 30%, 80%, 0.3);
}

.mushaf-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 1px solid var(--primary-color);
    border-radius: 8px;
    background: transparent;
    color: var(--primary-color);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mushaf-nav-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
}

.mushaf-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.mushaf-page-indicator {
    font-size: 0.9rem;
    color: var(--text-muted, var(--muted-text));
    font-weight: 500;
}

/* Page input field */
.mushaf-page-input {
    width: 60px;
    padding: 6px 10px;
    text-align: center;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
}

.mushaf-page-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px hsla(var(--primary-hue), 50%, 50%, 0.15);
}

/* ============================================
 * Progress Bar for Page
 * ============================================ */
.mushaf-progress {
    margin-top: 16px;
}

.mushaf-progress-bar {
    height: 6px;
    background: hsla(var(--primary-hue), 30%, 90%, 0.6);
    border-radius: 3px;
    overflow: hidden;
}

.mushaf-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color, var(--primary-dark)));
    border-radius: 3px;
    transition: width 0.4s ease;
}

.mushaf-progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ============================================
 * Loading State
 * ============================================ */
.quran-page.loading {
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quran-page.loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 3px solid hsla(var(--primary-hue), 50%, 80%, 0.3);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
 * Responsive Adjustments
 * ============================================ */
@media (max-width: 767px) {
    .quran-page {
        padding: 8px 6px;
        border-radius: 8px;
        overflow-x: hidden;
    }

    .mushaf-line {
        font-size: clamp(0.55rem, 2.5vw, 0.85rem);
        line-height: 1.7;
        margin-bottom: 1px;
        flex-wrap: nowrap;
        padding: 2px 0;
    }

    .surah-header-line {
        font-size: clamp(0.9rem, 3.5vw, 1.1rem);
        padding: 8px 12px;
        margin: 12px 0 8px;
    }

    .surah-header-line::before,
    .surah-header-line::after {
        display: none;
    }

    .basmala-line {
        font-size: clamp(0.8rem, 3vw, 1rem);
    }

    .mushaf-nav {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }

    .mushaf-nav-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .mushaf-controls {
        flex-wrap: wrap;
        gap: 6px;
        padding: 8px 0;
    }

    /* Disable scale transforms on mobile */
    .quran-page.layout-scale-xs,
    .quran-page.layout-scale-sm,
    .quran-page.layout-scale-md,
    .quran-page.layout-scale-lg,
    .quran-page.layout-scale-xl {
        transform: none;
        margin-bottom: 0;
    }
}

/* ============================================
 * Hidden State for Mushaf Mode
 * ============================================ */
.quran-page.ayah-hidden .word.unrevealed {
    filter: blur(6px);
    user-select: none;
}

.quran-page.ayah-hidden .word.revealed {
    filter: none;
}

body.dark-mode .quran-page.ayah-hidden .word.unrevealed {
    filter: blur(5px);
}

/* ============================================
 * IMMERSIVE MUSHAF MODE - Full Screen Experience
 * ============================================ */

/* Full-screen overlay container */
.mushaf-immersive-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg,
            #faf9f4 0%,
            #f5f3ea 30%,
            #f0ede4 70%,
            #ebe8df 100%);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    overflow: hidden;
}

.mushaf-immersive-overlay.active {
    opacity: 1;
    visibility: visible;
}

body.dark-mode .mushaf-immersive-overlay {
    background: linear-gradient(180deg,
            #141614 0%,
            #181a18 30%,
            #1c1f1c 70%,
            #1a1d1a 100%);
}

/* Subtle paper texture overlay */
.mushaf-immersive-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
}

body.dark-mode .mushaf-immersive-overlay::before {
    opacity: 0.05;
}

/* ============================================
 * Immersive Header
 * ============================================ */
.mushaf-immersive-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 6px;
    /* Ultra minimal padding */
    background: linear-gradient(180deg,
            rgba(255, 255, 255, 0.95) 0%,
            rgba(255, 255, 255, 0.8) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    z-index: 10;
    flex-shrink: 0;
}

body.dark-mode .mushaf-immersive-header {
    background: linear-gradient(180deg,
            rgba(26, 29, 26, 0.95) 0%,
            rgba(26, 29, 26, 0.8) 100%);
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

.mushaf-close-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: hsla(var(--primary-hue, 150), 15%, 90%, 0.8);
    color: var(--text-color, #333);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.mushaf-close-btn:hover {
    background: hsla(var(--primary-hue, 150), 20%, 85%, 1);
    transform: scale(1.05);
}

body.dark-mode .mushaf-close-btn {
    background: hsla(var(--primary-hue, 150), 15%, 25%, 0.8);
    color: #e0e0e0;
}

.mushaf-immersive-title {
    text-align: center;
    flex: 1;
}

.mushaf-title-surah {
    font-family: 'KFGQPC Uthmanic Script HAFS', 'Amiri', serif;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary-dark, #2a7556);
    margin-bottom: 2px;
}

body.dark-mode .mushaf-title-surah {
    color: var(--primary-color, #4eba8a);
}

.mushaf-title-info {
    font-size: 0.8rem;
    color: var(--muted-text, #666);
    font-weight: 500;
}

.mushaf-settings-btn {
    display: none;
    /* Hidden by user request */
}

.mushaf-settings-btn:hover {
    background: hsla(var(--primary-hue, 150), 15%, 90%, 0.8);
    color: var(--primary-color);
}

/* ============================================
 * Page Frame Container
 * ============================================ */
.mushaf-page-frame {
    flex: 1;
    /* Takes remaining space between header and footer */
    display: flex;
    align-items: flex-start;
    /* Revert to start to ensure top alignment */
    justify-content: center;
    padding: 20px 0;
    /* Add vertical padding so scaled content doesn't hit header */
    width: 100%;
    overflow: auto;
    /* Scroll if content overflows */
    position: relative;
    -webkit-overflow-scrolling: touch;
}

/* The scalable content wrapper */
.mushaf-scalable-content {
    position: relative;
    width: 100%;
    max-width: none;
    /* Full width - no constraint */
    /* Use Uthmani font */
    font-family: 'KFGQPC Uthmanic Script HAFS', 'Amiri', serif;
    background: linear-gradient(180deg,
            #fffefa 0%,
            #fdfbf5 50%,
            #fbf8f0 100%);
    border-radius: 0;
    box-shadow: none;
    border-radius: 0;
    box-shadow: none;
    padding: 2px 0px;
    margin: 0;
    transform-origin: top center;
    /* Scale from top to avoid pushing up into header */
    transition: transform 0.3s ease;
    border: none;
    /* Remove border */
}

body.dark-mode .mushaf-scalable-content {
    background: linear-gradient(180deg,
            #1e211e 0%,
            #1c1f1c 50%,
            #1a1d1a 100%);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.3),
        0 8px 40px rgba(0, 0, 0, 0.2),
        inset 0 0 60px rgba(0, 0, 0, 0.1);
}

/* Remove ornamental corners to save space */
/*
.mushaf-scalable-content::before,
.mushaf-scalable-content::after {
    content: '';
    position: absolute;
    width: 40px;
    height: 40px;
    border: 2px solid hsla(var(--primary-hue, 150), 40%, 50%, 0.3);
    pointer-events: none;
}

.mushaf-scalable-content::before {
    top: 8px;
    right: 8px;
    border-left: none;
    border-bottom: none;
    border-top-right-radius: 8px;
}

.mushaf-scalable-content::after {
    bottom: 8px;
    left: 8px;
    border-right: none;
    border-top: none;
    border-bottom-left-radius: 8px;
}
*/

/* ============================================
 * Immersive Line Styling
 * ============================================ */
/* ============================================
 * Immersive Line Styling
 * ============================================ */
.mushaf-immersive-overlay .mushaf-line {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: baseline;
    text-align: justify;
    padding: 2px 0;
    margin-bottom: 0;
    /* Larger Uthmani font size - maximized */
    font-family: 'KFGQPC Uthmanic Script HAFS', 'Amiri', serif;
    font-size: clamp(1.1rem, 5.2vw, 2.2rem);
    /* Significantly increased */
    position: relative;
    min-height: 1.6em;
    /* Tighter line height */
    line-height: 1.7;
}

/* Line guides - subtle horizontal lines */
.mushaf-immersive-overlay .mushaf-line.text-line::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(180, 160, 130, 0.2) 10%,
            rgba(180, 160, 130, 0.2) 90%,
            transparent 100%);
}

body.dark-mode .mushaf-immersive-overlay .mushaf-line.text-line::after {
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.08) 10%,
            rgba(255, 255, 255, 0.08) 90%,
            transparent 100%);
}

/* Immersive Surah Header - Compact */
.mushaf-immersive-overlay .surah-header-line {
    text-align: center;
    font-size: clamp(0.95rem, 3.5vw, 1.4rem);
    /* Smaller */
    font-weight: 600;
    color: var(--primary-dark, #2a7556);
    margin: 6px 0;
    /* Reduced margin */
    padding: 8px 16px;
    /* Reduced padding */
    background: linear-gradient(135deg,
            hsla(var(--primary-hue), 45%, 92%, 0.8),
            hsla(var(--primary-hue), 40%, 88%, 0.9));
    border-radius: 8px;
    border: 1px solid hsla(var(--primary-hue), 35%, 80%, 0.4);
    position: relative;
    justify-content: center;
}

body.dark-mode .mushaf-immersive-overlay .surah-header-line {
    background: linear-gradient(135deg,
            hsla(var(--primary-hue), 30%, 20%, 0.8),
            hsla(var(--primary-hue), 25%, 16%, 0.9));
    border-color: hsla(var(--primary-hue), 25%, 35%, 0.4);
    color: var(--primary-color);
}

/* Decorative flourishes for surah header - smaller */
.mushaf-immersive-overlay .surah-header-line::before,
.mushaf-immersive-overlay .surah-header-line::after {
    content: '❦';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-color);
    opacity: 0.4;
    font-size: 0.9em;
}

.mushaf-immersive-overlay .surah-header-line::before {
    right: 8px;
}

.mushaf-immersive-overlay .surah-header-line::after {
    left: 8px;
}

/* Immersive Basmala - Wider, less spacing */
.mushaf-immersive-overlay .basmala-line {
    text-align: center;
    font-size: clamp(0.9rem, 3vw, 1.3rem);
    color: var(--primary-dark, #2a7556);
    margin: 4px 0;
    /* Reduced margin */
    padding: 4px 0;
    /* Reduced padding */
    font-weight: 500;
    justify-content: center;
    letter-spacing: 0.05em;
    /* Wider letter spacing */
}

body.dark-mode .mushaf-immersive-overlay .basmala-line {
    color: var(--primary-color);
}

/* ============================================
 * Enhanced Word Styling in Immersive Mode
 * ============================================ */
.mushaf-immersive-overlay .word {
    display: inline-block;
    /* Changed from inline to inline-block for transforms */
    vertical-align: middle;
    /* Fix vertical alignment */
    padding: 0 1px;
    /* Remove vertical padding */
    /* Minimal spacing between words */
    margin: 0 1px;
    border-radius: 4px;
    position: relative;
    transition:
        background-color 0.35s ease,
        color 0.25s ease,
        transform 0.25s ease;
    cursor: default;
}

/* Unrevealed words - subtle appearance */
.mushaf-immersive-overlay .word.unrevealed {
    color: #3a3a3a;
    opacity: 0.9;
}

body.dark-mode .mushaf-immersive-overlay .word.unrevealed {
    color: #c8c8c8;
}

/* Current expected word - gentle pulsing highlight */
.mushaf-immersive-overlay .word.current-expected {
    background: hsla(var(--primary-hue, 150), 50%, 85%, 0.5);
    border-bottom: 2px solid var(--primary-color);
}

body.dark-mode .mushaf-immersive-overlay .word.current-expected {
    background: hsla(var(--primary-hue, 150), 40%, 30%, 0.5);
}

@keyframes gentlePulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 hsla(var(--primary-hue, 150), 50%, 50%, 0);
    }

    50% {
        box-shadow: 0 0 12px 2px hsla(var(--primary-hue, 150), 50%, 50%, 0.25);
    }
}

/* Revealed words - success state with glow */
.mushaf-immersive-overlay .word.revealed {
    color: var(--primary-color);
    background: linear-gradient(135deg,
            hsla(var(--primary-hue, 150), 55%, 90%, 0.9),
            hsla(var(--primary-hue, 150), 50%, 86%, 0.8));
    animation: immersiveReveal 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.dark-mode .mushaf-immersive-overlay .word.revealed {
    background: linear-gradient(135deg,
            hsla(var(--primary-hue, 150), 40%, 26%, 0.9),
            hsla(var(--primary-hue, 150), 35%, 22%, 0.8));
}

@keyframes immersiveReveal {
    0% {
        transform: scale(1);
        opacity: 0.6;
        box-shadow: 0 0 0 0 hsla(var(--primary-hue, 150), 50%, 50%, 0.4);
    }

    50% {
        transform: scale(1.08);
        box-shadow: 0 0 20px 4px hsla(var(--primary-hue, 150), 50%, 50%, 0.3);
    }

    100% {
        transform: scale(1);
        opacity: 1;
        box-shadow: 0 0 0 0 hsla(var(--primary-hue, 150), 50%, 50%, 0);
    }
}

/* ============================================
 * Enhanced Ayah End Markers in Immersive Mode - Compact
 * ============================================ */
.mushaf-immersive-overlay .ayah-end-marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--body-font, sans-serif);
    color: var(--primary-color, #3a9d74);
    width: 1.5em;
    /* Smaller */
    height: 1.5em;
    margin: 0 2px;
    /* Reduced margin */
    font-size: 0.6em;
    font-weight: 700;
    position: relative;
    vertical-align: middle;
}

/* Ornate circular border */
.mushaf-immersive-overlay .ayah-end-marker::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg,
            hsla(var(--primary-hue), 50%, 50%, 0.1),
            hsla(var(--primary-hue), 60%, 45%, 0.15));
    border: 2px solid var(--primary-color, #3a9d74);
    border-radius: 50%;
}

/* Inner decorative ring */
.mushaf-immersive-overlay .ayah-end-marker::after {
    content: '';
    position: absolute;
    inset: 4px;
    border: 1px solid hsla(var(--primary-hue), 50%, 50%, 0.25);
    border-radius: 50%;
}

/* ============================================
 * Controls Bar - Floating with Edges
 * ============================================ */
.mushaf-floating-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    margin: 0 auto 0 auto;
    background: rgba(255, 255, 255, 0.1);
    /* Semi-transparent background */
    backdrop-filter: blur(10px);
    /* Add blur effect */
    -webkit-backdrop-filter: blur(10px);
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    width: fit-content;
    z-index: 20;
}

.mushaf-floating-controls:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.15),
        inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}



body.dark-mode .mushaf-floating-controls {
    background: transparent;
    /* Transparent dark mode */
    box-shadow: none;
    border-color: rgba(255, 255, 255, 0.05);
}

/* Recording indicator */
.mushaf-recording-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-color);
}

.mushaf-recording-indicator.active {
    background: hsla(0, 70%, 50%, 0.1);
    color: hsl(0, 70%, 45%);
}

.mushaf-recording-indicator .rec-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: hsl(0, 70%, 50%);
    animation: recPulse 1.2s ease-in-out infinite;
}

@keyframes recPulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(0.85);
    }
}

/* Control buttons */
.mushaf-control-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: hsla(var(--primary-hue, 150), 45%, 45%, 1);
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px hsla(var(--primary-hue, 150), 50%, 40%, 0.3);
    margin: 0 5px 5px 5px;
    /* Top:0, Right:5px, Bottom:5px, Left:5px */
}

/* Mushaf Start Button - Green idle, Red recording */
#mushafStartBtn {
    background: linear-gradient(135deg, hsl(var(--primary-hue, 150), 50%, 45%), hsl(var(--primary-hue, 150), 55%, 35%));
    box-shadow: 0 2px 10px hsla(var(--primary-hue, 150), 50%, 40%, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

#mushafStartBtn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 18px hsla(var(--primary-hue, 150), 50%, 45%, 0.5);
    background: linear-gradient(135deg, hsl(var(--primary-hue, 150), 55%, 50%), hsl(var(--primary-hue, 150), 50%, 40%));
}

/* Recording dot - hidden by default */
#mushafStartBtn .record-dot {
    display: none;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

/* Loading spinner for mushaf button */
#mushafStartBtn .loading-spinner {
    display: none;
    width: 22px;
    height: 22px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: mushaf-spinner 0.8s linear infinite;
    position: absolute;
    inset: 0;
    margin: auto;
}

/* Loading state - show spinner, hide mic icon */
#mushafStartBtn.is-loading {
    background: linear-gradient(135deg, hsl(var(--primary-hue, 150), 55%, 45%), hsl(var(--primary-hue, 150), 60%, 35%)) !important;
    cursor: wait;
}

#mushafStartBtn.is-loading i {
    display: none !important;
}

#mushafStartBtn.is-loading .loading-spinner {
    display: block;
}

#mushafStartBtn.is-loading .record-dot {
    display: none;
}

@keyframes mushaf-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* Recording state - hide mic, show pulsing dot */
#mushafStartBtn.is-recording {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    animation: mushaf-glow 1.5s ease-in-out infinite;
}

#mushafStartBtn.is-recording i {
    display: none;
}

#mushafStartBtn.is-recording .record-dot {
    display: block;
    animation: mushaf-dot-pulse 1s ease-in-out infinite;
}

@keyframes mushaf-glow {
    0%, 100% {
        box-shadow: 0 2px 12px rgba(220, 38, 38, 0.5);
    }
    50% {
        box-shadow: 0 2px 25px rgba(239, 68, 68, 0.75), 0 0 40px rgba(239, 68, 68, 0.3);
    }
}

@keyframes mushaf-dot-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
    }
    50% {
        transform: scale(1.25);
        box-shadow: 0 0 16px rgba(255, 255, 255, 1);
    }
}

.mushaf-control-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px hsla(var(--primary-hue, 150), 50%, 40%, 0.4);
}

.mushaf-control-btn:active {
    transform: scale(0.95);
}

.mushaf-control-btn.secondary {
    background: hsla(var(--primary-hue, 150), 20%, 92%, 1);
    color: var(--text-color);
    box-shadow: none;
}

body.dark-mode .mushaf-control-btn.secondary {
    background: hsla(var(--primary-hue, 150), 15%, 25%, 1);
    color: #e0e0e0;
}

/* Page navigation in floating bar */
.mushaf-page-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
    border-left: 1px solid rgba(0, 0, 0, 0.08);
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    margin: 0 4px;
}

body.dark-mode .mushaf-page-nav {
    border-color: rgba(255, 255, 255, 0.08);
}

.mushaf-page-nav-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-color);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.mushaf-page-nav-btn:hover:not(:disabled) {
    background: hsla(var(--primary-hue, 150), 20%, 90%, 0.8);
}

.mushaf-page-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.mushaf-page-num {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
    min-width: 50px;
    text-align: center;
}

/* Progress in floating bar */
.mushaf-floating-progress {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-left: 8px;
    border-left: 1px solid rgba(0, 0, 0, 0.08);
}

body.dark-mode .mushaf-floating-progress {
    border-color: rgba(255, 255, 255, 0.08);
}

.mushaf-floating-progress-text {
    font-size: 0.8rem;
    color: var(--muted-text);
    font-weight: 500;
}

/* ============================================
 * Immersive Mode Page Turn Animation
 * ============================================ */
.mushaf-scalable-content.page-exit {
    animation: pageExit 0.3s ease-in forwards;
}

.mushaf-scalable-content.page-enter {
    animation: pageEnter 0.35s ease-out forwards;
}

@keyframes pageExit {
    0% {
        opacity: 1;
        transform: scale(1) translateX(0);
    }

    100% {
        opacity: 0;
        transform: scale(0.95) translateX(-30px);
    }
}

@keyframes pageEnter {
    0% {
        opacity: 0;
        transform: scale(0.95) translateX(30px);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateX(0);
    }
}

/* ============================================
 * Responsive Adjustments for Immersive Mode
 * ============================================ */
@media (max-width: 767px) {
    .mushaf-immersive-header {
        padding: 10px 16px;
    }

    .mushaf-close-btn,
    .mushaf-settings-btn {
        width: 36px;
        height: 36px;
    }

    .mushaf-title-surah {
        font-size: 1.1rem;
    }

    .mushaf-page-frame {
        padding: 12px;
    }

    .mushaf-scalable-content {
        padding: 16px 12px;
        max-width: 100%;
    }

    .mushaf-scalable-content::before,
    .mushaf-scalable-content::after {
        width: 24px;
        height: 24px;
    }

    .mushaf-immersive-overlay .mushaf-line {
        font-size: clamp(0.7rem, 4vw, 1.1rem);
        line-height: 2.0;
        padding: 4px 0;
    }

    .mushaf-floating-controls {
        bottom: 12px;
        padding: 10px 16px;
        gap: 8px;
        max-width: calc(100% - 24px);
    }

    .mushaf-control-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .mushaf-page-nav {
        padding: 0 4px;
        margin: 0 2px;
    }

    .mushaf-recording-indicator {
        display: none;
    }
}

/* Landscape mode adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .mushaf-immersive-header {
        padding: 8px 16px;
    }

    .mushaf-page-frame {
        padding: 8px;
    }

    .mushaf-scalable-content {
        max-height: calc(100vh - 120px);
    }

    .mushaf-floating-controls {
        bottom: 8px;
        padding: 8px 16px;
    }
}

/* ============================================
 * STANDALONE MUSHAF PAGE STYLES
 * For mushaf.html - self-contained page
 * ============================================ */

/* Main App Container */
.mushaf-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    background: linear-gradient(180deg, #fdfcf5 0%, #f9f6eb 50%, #f5f2e6 100%);
    overflow: hidden;
}

body.dark-mode .mushaf-app {
    background: linear-gradient(180deg, #141614 0%, #181a18 50%, #1c1f1c 100%);
}

/* Header */
.mushaf-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
    z-index: 10;
}

body.dark-mode .mushaf-header {
    background: rgba(26, 29, 26, 0.9);
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

.mushaf-back-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: hsla(var(--primary-hue, 150), 15%, 90%, 0.8);
    color: var(--text-color, #333);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.2s ease;
}

.mushaf-back-btn:hover {
    background: hsla(var(--primary-hue, 150), 20%, 85%, 1);
    transform: scale(1.05);
}

body.dark-mode .mushaf-back-btn {
    background: hsla(var(--primary-hue, 150), 15%, 25%, 0.8);
    color: #e0e0e0;
}

.mushaf-header-title {
    text-align: center;
    flex: 1;
}

.mushaf-surah-name {
    font-family: 'KFGQPC Uthmanic Script HAFS', 'Amiri', serif;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary-dark, #2a7556);
    margin: 0;
}

body.dark-mode .mushaf-surah-name {
    color: var(--primary-color, #4eba8a);
}

.mushaf-page-info {
    font-size: 0.8rem;
    color: var(--muted-text, #666);
    margin: 2px 0 0 0;
}

.mushaf-header-actions {
    display: flex;
    gap: 8px;
}

.mushaf-action-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-color, #333);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.mushaf-action-btn:hover {
    background: hsla(var(--primary-hue, 150), 15%, 90%, 0.8);
}

body.dark-mode .mushaf-action-btn {
    color: #e0e0e0;
}

body.dark-mode .mushaf-action-btn:hover {
    background: hsla(var(--primary-hue, 150), 15%, 25%, 0.8);
}

/* Main Content Area */
.mushaf-main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    justify-content: center;
    -webkit-overflow-scrolling: touch;
}

.mushaf-page-content {
    width: 100%;
    max-width: 700px;
    min-width: 320px;
    font-family: 'KFGQPC Uthmanic Script HAFS', 'Amiri', serif;
    direction: rtl;
    text-align: center; /* Center all content */
    line-height: 2.2;
    padding: 20px 16px;
    /* Traditional Mushaf cream background */
    background: linear-gradient(180deg,
            #fdfcf5 0%,
            #f9f6eb 50%,
            #f5f2e6 100%);
    border: 1px solid #e8e4d4;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    overflow-x: auto; /* Allow horizontal scroll on very small screens */
}

body.dark-mode .mushaf-page-content {
    background: linear-gradient(180deg,
            #1a1d1a 0%,
            #1f221f 50%,
            #181b18 100%);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* Footer / Controls */
.mushaf-footer {
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    padding: 0;
}

body.dark-mode .mushaf-footer {
    background: rgba(26, 29, 26, 0.95);
    border-top-color: rgba(255, 255, 255, 0.06);
}

.mushaf-progress-bar {
    height: 4px;
    background: hsla(var(--primary-hue, 150), 30%, 90%, 0.6);
    overflow: hidden;
}

.mushaf-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
    transition: width 0.3s ease;
}

.mushaf-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    gap: 12px;
}

.mushaf-nav-group,
.mushaf-action-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mushaf-nav-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color, #e0e5e8);
    border-radius: 50%;
    background: var(--card-bg, #fff);
    color: var(--text-color, #333);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.mushaf-nav-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.mushaf-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

body.dark-mode .mushaf-nav-btn {
    background: var(--card-bg, #252a28);
    border-color: var(--border-color, #3a3f3d);
    color: var(--text-color, #e8f0ec);
}

.mushaf-page-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-color, #e0e5e8);
    border-radius: 20px;
    background: var(--card-bg, #fff);
    color: var(--text-color, #333);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.mushaf-page-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

body.dark-mode .mushaf-page-btn {
    background: var(--card-bg, #252a28);
    border-color: var(--border-color, #3a3f3d);
    color: var(--text-color, #e8f0ec);
}

.mushaf-page-separator {
    color: var(--muted-text);
    margin: 0 2px;
}

/* Record Button */
.mushaf-record-btn {
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 4px 15px hsla(var(--primary-hue, 150), 50%, 40%, 0.3);
    transition: all 0.3s ease;
}

.mushaf-record-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px hsla(var(--primary-hue, 150), 50%, 40%, 0.4);
}

.mushaf-record-btn.recording {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    animation: record-pulse 1.5s ease-in-out infinite;
}

.mushaf-record-btn.recording .record-pulse {
    display: block;
}

.record-pulse {
    display: none;
    position: absolute;
    inset: -4px;
    border: 2px solid #ef4444;
    border-radius: 50%;
    animation: pulse-ring 1.5s ease-out infinite;
}

@keyframes record-pulse {
    0%, 100% { box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 4px 25px rgba(239, 68, 68, 0.6); }
}

@keyframes pulse-ring {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.4); opacity: 0; }
}

/* Control Buttons */
.mushaf-ctrl-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color, #e0e5e8);
    border-radius: 50%;
    background: var(--card-bg, #fff);
    color: var(--text-color, #333);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.mushaf-ctrl-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

body.dark-mode .mushaf-ctrl-btn {
    background: var(--card-bg, #252a28);
    border-color: var(--border-color, #3a3f3d);
    color: var(--text-color, #e8f0ec);
}

.mushaf-progress-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-color);
    min-width: 40px;
    text-align: center;
}

/* Modals */
.mushaf-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.mushaf-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.mushaf-modal-content {
    position: relative;
    background: var(--card-bg, #fff);
    border-radius: 16px;
    padding: 24px;
    min-width: 300px;
    max-width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: modal-appear 0.3s ease;
}

body.dark-mode .mushaf-modal-content {
    background: var(--card-bg, #252a28);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

@keyframes modal-appear {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.mushaf-modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 16px 0;
    text-align: center;
}

.mushaf-modal-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color, #e0e5e8);
    border-radius: 10px;
    font-size: 1.1rem;
    text-align: center;
    background: var(--card-bg, #fff);
    color: var(--text-color);
    margin-bottom: 16px;
}

.mushaf-modal-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

body.dark-mode .mushaf-modal-input {
    background: #1a1d1c;
    border-color: var(--border-color, #3a3f3d);
}

.mushaf-modal-actions {
    display: flex;
    gap: 10px;
}

.mushaf-modal-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mushaf-modal-btn.primary {
    background: var(--primary-color);
    color: white;
}

.mushaf-modal-btn.primary:hover {
    background: var(--primary-dark);
}

.mushaf-modal-btn.secondary {
    background: var(--border-color, #e0e5e8);
    color: var(--text-color);
}

.mushaf-modal-btn.secondary:hover {
    background: #d0d5d8;
}

body.dark-mode .mushaf-modal-btn.secondary {
    background: #3a3f3d;
}

body.dark-mode .mushaf-modal-btn.secondary:hover {
    background: #4a4f4d;
}

/* Settings Groups */
.mushaf-setting-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color, #e0e5e8);
}

.mushaf-setting-group:last-of-type {
    border-bottom: none;
}

.mushaf-setting-label {
    font-size: 0.95rem;
    color: var(--text-color);
}

.mushaf-setting-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mushaf-setting-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.mushaf-setting-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.mushaf-setting-value {
    min-width: 40px;
    text-align: center;
    font-weight: 600;
    color: var(--primary-color);
}

.mushaf-setting-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 0.9rem;
    cursor: pointer;
}

body.dark-mode .mushaf-setting-select {
    background: #1a1d1c;
    border-color: var(--border-color, #3a3f3d);
}

/* Toggle Switch */
.mushaf-toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.mushaf-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.mushaf-toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border-color, #e0e5e8);
    border-radius: 26px;
    transition: 0.3s;
}

.mushaf-toggle-slider:before {
    content: '';
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.mushaf-toggle input:checked + .mushaf-toggle-slider {
    background: var(--primary-color);
}

.mushaf-toggle input:checked + .mushaf-toggle-slider:before {
    transform: translateX(22px);
}

/* Toast */
.mushaf-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 12px 24px;
    border-radius: 25px;
    background: var(--card-bg, #fff);
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1001;
}

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

.mushaf-toast.success {
    background: #10b981;
    color: white;
}

.mushaf-toast.error {
    background: #ef4444;
    color: white;
}

.mushaf-toast.info {
    background: var(--primary-color);
    color: white;
}

body.dark-mode .mushaf-toast {
    background: var(--card-bg, #252a28);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Responsive */
@media (max-width: 780px) {
    /* Keep consistent line layout on smaller screens */
    .mushaf-line {
        font-size: 1.4rem; /* Slightly smaller but still readable */
        white-space: nowrap;
        overflow-x: visible;
    }
    
    .mushaf-line.text-line {
        word-spacing: 0.12em;
    }
    
    .surah-header-line {
        font-size: 1.3rem;
        padding: 10px 20px;
        min-width: 180px;
    }
    
    .basmala-line {
        font-size: 1.2rem;
    }
    
    .mushaf-page-content {
        padding: 16px 12px;
        overflow-x: auto;
    }
    
    .mushaf-page-content .word {
        padding: 2px 3px;
        margin: 0 1px;
    }
}

@media (max-width: 480px) {
    .mushaf-header {
        padding: 10px 12px;
    }

    .mushaf-surah-name {
        font-size: 1.1rem;
    }

    .mushaf-main {
        padding: 12px;
    }
    
    /* Keep same layout structure on mobile */
    .mushaf-line {
        font-size: 1.2rem;
        white-space: nowrap;
    }
    
    .surah-header-line {
        font-size: 1.1rem;
        padding: 8px 16px;
        min-width: 150px;
    }
    
    .basmala-line {
        font-size: 1.1rem;
    }

    .mushaf-controls {
        padding: 10px 12px;
    }

    .mushaf-record-btn {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    .mushaf-nav-btn,
    .mushaf-ctrl-btn {
        width: 36px;
        height: 36px;
    }
}