/**
 * Quran Reciter Page Styles - Coran 3D
 * Islamic-inspired verse-by-verse recitation
 * ==========================================
 */

/* Surah calligraphy icon font */
@font-face {
    font-family: 'surah-icons';
    src: url('../fonts/QWBWSurah.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* Uthmanic HAFS Mushaf font */
@font-face {
    font-family: 'Uthmanic HAFS';
    src: url('../fonts/UthmanicHafs.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* =============================================
   PAGE CONTAINER
   ============================================= */

.qr-page {
    min-height: 100vh;
    padding: var(--space-8) var(--space-6);
    position: relative;
    overflow: hidden;
}

/* Islamic geometric background */
.qr-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(ellipse at 50% 20%, rgba(212, 175, 125, 0.03) 0%, transparent 50%),
        url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23D4AF7D' stroke-opacity='0.025'%3E%3Crect x='25' y='25' width='50' height='50' transform='rotate(0 50 50)' stroke-width='0.5'/%3E%3Crect x='25' y='25' width='50' height='50' transform='rotate(45 50 50)' stroke-width='0.5'/%3E%3Ccircle cx='50' cy='50' r='15' stroke-width='0.3'/%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

.qr-page--player {
    padding: 0;
}

/* =============================================
   HEADER (Calligraphic)
   ============================================= */

.qr-header {
    position: relative;
    z-index: 1;
    text-align: center;
    margin-bottom: var(--space-8);
    padding-top: var(--space-6);
}

.qr-header__calligraphy {
    font-family: var(--font-arabic);
    font-size: clamp(2.5rem, 8vw, 4.5rem);
    color: var(--accent-primary);
    margin-bottom: var(--space-2);
    text-shadow:
        0 0 40px var(--accent-glow),
        0 2px 20px rgba(0, 0, 0, 0.3);
    letter-spacing: 0;
    line-height: 1.2;
    animation: qrGlow 4s ease-in-out infinite;
}

@keyframes qrGlow {
    0%, 100% {
        text-shadow:
            0 0 40px var(--accent-glow),
            0 2px 20px rgba(0, 0, 0, 0.3);
    }
    50% {
        text-shadow:
            0 0 60px var(--accent-glow),
            0 0 80px var(--accent-softer),
            0 2px 20px rgba(0, 0, 0, 0.3);
    }
}

.qr-header__ornament {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    margin: var(--space-4) auto;
    max-width: 400px;
}

.qr-header__ornament-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--accent-primary) 50%,
        transparent 100%);
}

.qr-header__ornament-icon {
    width: 40px;
    height: 40px;
    color: var(--accent-primary);
    animation: ornamentSpin 30s linear infinite;
}

@keyframes ornamentSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.qr-header__title {
    font-size: var(--text-xl);
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    margin-bottom: var(--space-2);
}

.qr-header__subtitle {
    font-size: var(--text-base);
    color: var(--text-tertiary);
    max-width: 500px;
    margin: 0 auto;
    line-height: var(--leading-relaxed);
}

/* =============================================
   LOADING
   ============================================= */

.qr-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-12) 0;
    position: relative;
    z-index: 1;
    color: var(--text-tertiary);
}

.qr-loading__spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: var(--space-4);
}

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

/* =============================================
   CONTROLS (Reciter + Search)
   ============================================= */

.qr-controls {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto var(--space-8);
    display: flex;
    gap: var(--space-4);
    align-items: flex-end;
}

.qr-controls__reciter {
    flex: 1;
    min-width: 0;
}

.qr-controls__label {
    display: block;
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    margin-bottom: var(--space-2);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
}

.qr-controls__select {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: var(--text-base);
    cursor: pointer;
    transition: border-color var(--duration-fast) var(--ease-default);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23D4AF7D' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.qr-controls__select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.qr-controls__select option {
    background-color: #1E1A16;
    color: #FFF8F0;
    padding: 8px;
}

[data-theme="light"] .qr-controls__select option {
    background-color: #fff;
    color: #1a1a1a;
}

.qr-controls__search {
    flex: 1;
    position: relative;
}

.qr-controls__search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    pointer-events: none;
}

.qr-controls__input {
    width: 100%;
    padding: var(--space-3) var(--space-4) var(--space-3) 40px;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: var(--text-base);
    transition: border-color var(--duration-fast) var(--ease-default);
}

.qr-controls__input::placeholder {
    color: var(--text-muted);
}

.qr-controls__input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* =============================================
   SURAH GRID
   ============================================= */

.qr-surah-grid {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-4);
}

.qr-surah-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-4);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-default);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--space-2);
    animation: qrFadeIn 0.4s ease-out both;
}

@keyframes qrFadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.qr-surah-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2), 0 0 0 1px var(--accent-tertiary);
    border-color: var(--accent-tertiary);
}

.qr-surah-card__number {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    border: 1px solid var(--accent-tertiary);
    border-radius: 50%;
    font-family: var(--font-arabic);
    font-size: var(--text-lg);
    color: var(--accent-primary);
    font-weight: 700;
    flex-shrink: 0;
}

.qr-surah-card__info {
    min-width: 0;
}

.qr-surah-card__calligraphy {
    font-family: 'surah-icons' !important;
    font-size: 6.6rem;
    line-height: 1;
    color: var(--accent-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin-bottom: 2px;
}

.qr-surah-card__name-ar {
    font-family: var(--font-arabic);
    font-size: 1.3rem;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 2px;
}

.qr-surah-card__name-fr {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

.qr-surah-card__meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

.qr-surah-card__dot {
    width: 3px;
    height: 3px;
    background: var(--text-muted);
    border-radius: 50%;
}

/* =============================================
   RESUME BANNER
   ============================================= */

.qr-resume-banner {
    position: relative;
    z-index: 1;
    max-width: 600px;
    margin: 0 auto var(--space-6);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    background: var(--accent-soft);
    border: 1px solid var(--accent-tertiary);
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-default);
}

.qr-resume-banner:hover {
    background: var(--accent-softer);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.qr-resume-banner__icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-primary), var(--ochre));
    border-radius: var(--radius-full);
    color: var(--bg-primary);
    flex-shrink: 0;
}

.qr-resume-banner__info {
    flex: 1;
    min-width: 0;
}

.qr-resume-banner__title {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 2px;
}

.qr-resume-banner__detail {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.qr-resume-banner__arrow {
    width: 20px;
    height: 20px;
    color: var(--accent-primary);
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    flex-shrink: 0;
}

/* Last played surah card highlight */
.qr-surah-card--last-played {
    border-color: var(--accent-tertiary);
    box-shadow: 0 0 0 1px var(--accent-softer);
}

/* =============================================
   EMPTY STATE
   ============================================= */

.qr-empty {
    text-align: center;
    padding: var(--space-12) var(--space-6);
    color: var(--text-tertiary);
    position: relative;
    z-index: 1;
}

/* =============================================
   PLAYER VIEW
   ============================================= */

.qr-player {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

.qr-player__header {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-6);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.qr-player__back {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: none;
    border: none;
    color: var(--accent-primary);
    font-size: var(--text-sm);
    cursor: pointer;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    transition: background var(--duration-fast) var(--ease-default);
    flex-shrink: 0;
}

.qr-player__back:hover {
    background: var(--accent-soft);
}

.qr-player__back svg {
    width: 20px;
    height: 20px;
}

.qr-player__title {
    flex: 1;
    text-align: center;
    min-width: 0;
}

.qr-player__surah-name {
    font-family: var(--font-arabic);
    font-size: clamp(1.4rem, 4vw, 2rem);
    color: var(--accent-primary);
    line-height: 1.3;
    text-shadow: 0 0 20px var(--accent-glow);
}

.qr-player__surah-icon {
    font-family: 'surah-icons' !important;
    font-size: clamp(3rem, 8vw, 5rem);
    line-height: 1;
    color: var(--accent-primary);
    text-shadow: 0 0 20px var(--accent-glow);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.qr-player__reciter-name {
    font-family: var(--font-arabic);
    font-size: var(--text-sm);
    color: var(--text-tertiary);
}

/* =============================================
   VERSES CONTAINER
   ============================================= */

.qr-verses-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-6) var(--space-4);
    direction: rtl;
    scroll-behavior: smooth;
}

.qr-verses-empty {
    text-align: center;
    color: var(--text-tertiary);
    padding: var(--space-8);
    direction: ltr;
}

.qr-verse {
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-3);
    border-radius: var(--radius-lg);
    transition: all 0.35s ease;
    cursor: pointer;
    border-right: 3px solid transparent;
}

.qr-verse:hover {
    background: var(--accent-softer);
}

.qr-verse--active {
    background: var(--accent-soft);
    box-shadow: 0 0 20px var(--accent-glow), 0 0 40px rgba(212, 175, 125, 0.08);
    border-right-color: var(--accent-primary);
}

.qr-verse--active .qr-verse__text {
    font-size: clamp(1.4rem, 3.5vw, 2rem);
}

.qr-verse__number {
    display: inline;
    font-family: var(--font-arabic);
    font-size: 0.85em;
    color: var(--accent-primary);
    margin-left: var(--space-2);
    opacity: 0.8;
}

.qr-word--glyph {
    font-size: 1.8em;
    line-height: 1.8;
    color: var(--text-primary);
}

/* Dark mode: invert COLRv1 tajweed font (black→white) and restore hues */
[data-theme="dark"] .qr-verses--tajweed .qr-word--glyph {
    filter: invert(1) hue-rotate(180deg);
}

.qr-verse--active .qr-word--glyph {
    font-size: 2.2em;
}

.qr-word--glyph.qr-word--active {
    color: var(--accent-primary) !important;
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

[data-theme="dark"] .qr-verses--tajweed .qr-word--glyph.qr-word--active {
    filter: invert(1) hue-rotate(180deg) drop-shadow(0 0 8px var(--accent-glow));
}

.qr-word--end {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Uthmanic HAFS', 'Amiri Quran', 'Amiri', var(--font-arabic);
    font-size: 0.75em;
    color: var(--accent-primary);
    opacity: 0.9;
    min-width: 1.8em;
    vertical-align: middle;
}

.qr-verse__text {
    font-family: 'Uthmanic HAFS', 'Amiri Quran', 'Amiri', var(--font-arabic);
    font-size: clamp(1.5rem, 3.5vw, 2.2rem);
    color: var(--text-primary);
    line-height: 2.2;
    transition: font-size 0.35s ease;
}

/* =============================================
   WORD-BY-WORD HIGHLIGHTING
   ============================================= */

.qr-word {
    display: inline;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.qr-verse--active .qr-word {
    color: var(--text-primary);
}

.qr-word--active {
    color: var(--accent-primary) !important;
    background: rgba(212, 175, 125, 0.18);
    text-shadow: 0 0 12px var(--accent-glow);
}

/* Repeat button */
.qr-verse {
    position: relative;
}

/* Loop button in audio bar */
.qr-loop-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 2px solid var(--border-default);
    border-radius: var(--radius-full);
    color: var(--text-tertiary);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.qr-loop-btn:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    background: var(--accent-soft);
}

.qr-loop-btn:focus {
    outline: none;
}

.qr-loop-btn--active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #0D0B09;
    animation: loopPulse 1.5s ease-in-out infinite;
}

.qr-loop-btn--active:hover {
    background: var(--accent-secondary, var(--accent-primary));
    border-color: var(--accent-secondary, var(--accent-primary));
    color: #0D0B09;
}

@keyframes loopPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(212, 175, 125, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(212, 175, 125, 0); }
}

/* Hint-mode: gentle attention ring on the loop button */
.qr-loop-btn--hint {
    animation: loopHintRing 1.2s ease-in-out infinite;
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

@keyframes loopHintRing {
    0%, 100% { box-shadow: 0 0 0 0 rgba(212, 175, 125, 0.5); }
    50% { box-shadow: 0 0 0 10px rgba(212, 175, 125, 0); }
}

/* Loop Hint Tooltip */
.qr-loop-hint {
    position: absolute;
    bottom: calc(100% + 14px);
    right: -8px;
    z-index: 100;
    animation: loopHintAppear 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.qr-loop-hint__bubble {
    background: linear-gradient(135deg, var(--accent-primary), var(--ochre, #C7A359));
    color: #1a1610;
    border-radius: var(--radius-lg, 16px);
    padding: var(--space-4, 16px);
    width: 230px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3, 12px);
    text-align: center;
}

.qr-loop-hint__icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.12);
    border-radius: var(--radius-full, 50%);
    animation: loopHintSpin 2s ease-in-out infinite;
}

@keyframes loopHintSpin {
    0% { transform: rotate(0deg); }
    30% { transform: rotate(360deg); }
    100% { transform: rotate(360deg); }
}

.qr-loop-hint__text {
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 0;
}

.qr-loop-hint__text strong {
    font-weight: 700;
}

.qr-loop-hint__close {
    background: rgba(0, 0, 0, 0.15);
    border: none;
    color: #1a1610;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: var(--radius-full, 20px);
    cursor: pointer;
    transition: background 0.2s ease;
}

.qr-loop-hint__close:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* Arrow pointing down to the button */
.qr-loop-hint__arrow {
    width: 14px;
    height: 14px;
    background: var(--ochre, #C7A359);
    transform: rotate(45deg);
    position: absolute;
    bottom: -6px;
    right: 20px;
    border-radius: 0 0 3px 0;
}

/* Appear animation */
@keyframes loopHintAppear {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Dismiss animation */
.qr-loop-hint--hiding {
    animation: loopHintHide 0.3s ease-in forwards;
}

@keyframes loopHintHide {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(8px) scale(0.95);
    }
}

/* Mobile: position hint above the bar, more compact */
@media (max-width: 768px) {
    .qr-loop-hint {
        right: -4px;
    }

    .qr-loop-hint__bubble {
        width: 200px;
        padding: var(--space-3, 12px);
    }

    .qr-loop-hint__text {
        font-size: 0.8rem;
    }
}

/* =============================================
   TAJWEED TOGGLE
   ============================================= */

.qr-tajweed-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: none;
    border: 2px solid var(--border-default);
    color: var(--text-secondary);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-full);
    font-size: var(--text-xl);
    font-family: var(--font-arabic);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--duration-fast) var(--ease-default);
    flex-shrink: 0;
}

.qr-tajweed-toggle:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.qr-tajweed-toggle--active {
    background: var(--accent-soft);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* =============================================
   TAJWEED COLORS
   ============================================= */

.qr-verses--tajweed rule {
    color: inherit;
}

.qr-verses--tajweed .ham_wasl,
.qr-verses--tajweed .slnt {
    color: #999 !important;
}

.qr-verses--tajweed .laam_shamsiyah {
    color: #f4a243 !important;
}

.qr-verses--tajweed .madda_normal,
.qr-verses--tajweed .madda_permissible {
    color: #6e8fff !important;
}

.qr-verses--tajweed .madda_obligatory_monfasel,
.qr-verses--tajweed .madda_obligatory_mottasel,
.qr-verses--tajweed .madda_necessary {
    color: #ff4444 !important;
}

.qr-verses--tajweed .qalaqah {
    color: #ff5555 !important;
}

.qr-verses--tajweed .ikhafa,
.qr-verses--tajweed .ikhafa_shafawi {
    color: #e54ec4 !important;
}

.qr-verses--tajweed .iqlab {
    color: #42d4ff !important;
}

.qr-verses--tajweed .idgham_ghunnah,
.qr-verses--tajweed .idgham_shafawi,
.qr-verses--tajweed .ghunnah {
    color: #2ecc71 !important;
}

.qr-verses--tajweed .idgham_wo_ghunnah,
.qr-verses--tajweed .idgham_mutajanisayn,
.qr-verses--tajweed .idgham_mutaqaribayn {
    color: #bb5cf8 !important;
}

.qr-verses--tajweed .custom-alef-maksora {
    color: #f4a243 !important;
}

/* Translation line */
.qr-verse__translation {
    display: block;
    direction: ltr;
    text-align: right;
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    margin-top: var(--space-2);
    line-height: 1.5;
    font-style: italic;
}

/* Footnote markers in translation */
.qr-footnote {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65em;
    font-style: normal;
    font-weight: 700;
    color: var(--accent-primary);
    background: var(--accent-soft, rgba(212, 175, 125, 0.15));
    width: 1.3em;
    height: 1.3em;
    border-radius: 50%;
    cursor: pointer;
    vertical-align: super;
    margin: 0 1px;
    transition: all var(--duration-fast) var(--ease-default);
    line-height: 1;
}

.qr-footnote:hover {
    background: var(--accent-primary);
    color: var(--bg-primary);
    transform: scale(1.2);
}

.qr-footnote--loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Footnote popup */
.qr-footnote-popup {
    position: fixed;
    z-index: 9999;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: none;
}

.qr-footnote-popup--visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.qr-footnote-popup--above {
    transform: translateY(-100%) translateY(-20px);
}

.qr-footnote-popup--above.qr-footnote-popup--visible {
    transform: translateY(-100%) translateY(-20px);
}

.qr-footnote-popup__arrow {
    width: 12px;
    height: 12px;
    background: var(--bg-elevated, #1E1A16);
    border: 1px solid var(--border-subtle);
    border-right: none;
    border-bottom: none;
    transform: rotate(45deg);
    position: absolute;
    top: -6px;
    left: 50%;
    margin-left: -6px;
}

.qr-footnote-popup--above .qr-footnote-popup__arrow {
    top: auto;
    bottom: -6px;
    border: 1px solid var(--border-subtle);
    border-left: none;
    border-top: none;
}

.qr-footnote-popup__body {
    position: relative;
    background: var(--bg-elevated, #1E1A16);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.qr-footnote-popup__body p {
    font-family: var(--font-sans, 'Inter', sans-serif);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
    direction: ltr;
    text-align: left;
}

.qr-footnote-popup__close {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 18px;
    cursor: pointer;
    border-radius: 50%;
    transition: all var(--duration-fast) var(--ease-default);
}

.qr-footnote-popup__close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* =============================================
   AUDIO BAR
   ============================================= */

.qr-audio-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-6);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    backdrop-filter: blur(12px);
}

.qr-audio-bar__controls {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

.qr-audio-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-full);
    transition: all var(--duration-fast) var(--ease-default);
}

.qr-audio-btn:hover {
    color: var(--accent-primary);
    background: var(--accent-soft);
}

.qr-audio-btn svg {
    width: 18px;
    height: 18px;
}

.qr-play-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--ochre) 100%);
    border: none;
    color: var(--bg-primary);
    cursor: pointer;
    border-radius: var(--radius-full);
    transition: all var(--duration-normal) var(--ease-default);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.qr-play-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px var(--accent-glow);
}

.qr-play-btn svg {
    width: 22px;
    height: 22px;
}

.qr-audio-bar__progress {
    flex: 1;
    height: 6px;
    background: var(--border-default);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.qr-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--ochre));
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
}

.qr-time-display {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    white-space: nowrap;
    min-width: 80px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    direction: ltr;
}

/* =============================================
   MOBILE BOTTOM SHEET OVERLAY
   ============================================= */

.qr-bottom-sheet {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    background: var(--bg-primary);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
    overflow: hidden;
}

.qr-bottom-sheet--open {
    transform: translateY(0);
}

.qr-bottom-sheet .qr-player {
    height: 100vh;
    height: 100dvh;
}

.qr-bottom-sheet .qr-player__header {
    padding: var(--space-3) var(--space-4);
    padding-top: max(var(--space-3), env(safe-area-inset-top));
}

.qr-bottom-sheet .qr-audio-bar {
    padding: var(--space-3) var(--space-4);
    padding-bottom: max(var(--space-4), env(safe-area-inset-bottom));
    flex-wrap: wrap;
    gap: var(--space-3);
}

.qr-bottom-sheet .qr-audio-bar__controls {
    order: 1;
}

.qr-bottom-sheet .qr-audio-bar__progress {
    order: 3;
    flex-basis: 100%;
}

.qr-bottom-sheet .qr-time-display {
    order: 2;
}

.qr-bottom-sheet .qr-loop-btn {
    order: 2;
    margin-left: auto;
}

.qr-bottom-sheet .qr-verses-container {
    padding: var(--space-4) var(--space-3);
}

.qr-bottom-sheet .qr-verse {
    padding: var(--space-3) var(--space-4);
}

/* =============================================
   RESPONSIVE
   ============================================= */

@media (max-width: 768px) {
    .qr-page {
        padding: var(--space-6) var(--space-3);
    }

    .qr-header__calligraphy {
        font-size: clamp(2rem, 10vw, 3rem);
    }

    .qr-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .qr-surah-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: var(--space-3);
    }

    .qr-surah-card {
        padding: var(--space-3);
    }

    .qr-surah-card__calligraphy {
        font-size: 5.4rem;
    }

    .qr-surah-card__name-ar {
        font-size: 1.1rem;
    }

    /* Desktop player still needs these on small screens if no bottom sheet */
    .qr-player__header {
        padding: var(--space-3) var(--space-4);
    }

    .qr-verses-container {
        padding: var(--space-4) var(--space-3);
    }

    .qr-verse {
        padding: var(--space-3) var(--space-4);
    }

    .qr-audio-bar {
        padding: var(--space-3) var(--space-4);
        gap: var(--space-3);
        flex-wrap: wrap;
    }

    .qr-audio-bar__controls {
        order: 1;
    }

    .qr-audio-bar__progress {
        order: 3;
        flex-basis: 100%;
    }

    .qr-time-display {
        order: 2;
    }

    .qr-loop-btn {
        order: 2;
        margin-left: auto;
    }

    .qr-player {
        height: calc(100vh - 60px);
        height: calc(100dvh - 60px);
    }
}

@media (max-width: 480px) {
    .qr-surah-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* =============================================
   LIGHT MODE
   ============================================= */

[data-theme="light"] .qr-page::before {
    background-image:
        radial-gradient(ellipse at 50% 20%, rgba(212, 175, 125, 0.06) 0%, transparent 50%),
        url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23D4AF7D' stroke-opacity='0.05'%3E%3Crect x='25' y='25' width='50' height='50' transform='rotate(0 50 50)' stroke-width='0.5'/%3E%3Crect x='25' y='25' width='50' height='50' transform='rotate(45 50 50)' stroke-width='0.5'/%3E%3Ccircle cx='50' cy='50' r='15' stroke-width='0.3'/%3E%3C/g%3E%3C/svg%3E");
}

[data-theme="light"] .qr-header__calligraphy {
    text-shadow:
        0 0 30px rgba(212, 175, 125, 0.3),
        0 2px 10px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .qr-surah-card {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .qr-surah-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1), 0 0 0 1px var(--accent-tertiary);
}

[data-theme="light"] .qr-verse--active {
    background: rgba(212, 175, 125, 0.12);
    box-shadow: 0 0 20px rgba(212, 175, 125, 0.15);
}

[data-theme="light"] .qr-controls__select,
[data-theme="light"] .qr-controls__input {
    background: rgba(255, 255, 255, 0.9);
}

[data-theme="light"] .qr-player__header,
[data-theme="light"] .qr-audio-bar {
    background: rgba(255, 255, 255, 0.95);
}

[data-theme="light"] .qr-word--active {
    background: rgba(212, 175, 125, 0.22);
}

/* Light mode tajweed colors */
[data-theme="light"] .qr-verses--tajweed .laam_shamsiyah { color: #d47700 !important; }
[data-theme="light"] .qr-verses--tajweed .madda_normal,
[data-theme="light"] .qr-verses--tajweed .madda_permissible { color: #3050dd !important; }
[data-theme="light"] .qr-verses--tajweed .madda_obligatory_monfasel,
[data-theme="light"] .qr-verses--tajweed .madda_obligatory_mottasel,
[data-theme="light"] .qr-verses--tajweed .madda_necessary { color: #cc0000 !important; }
[data-theme="light"] .qr-verses--tajweed .qalaqah { color: #cc0000 !important; }
[data-theme="light"] .qr-verses--tajweed .ikhafa,
[data-theme="light"] .qr-verses--tajweed .ikhafa_shafawi { color: #b800a0 !important; }
[data-theme="light"] .qr-verses--tajweed .iqlab { color: #0090cc !important; }
[data-theme="light"] .qr-verses--tajweed .idgham_ghunnah,
[data-theme="light"] .qr-verses--tajweed .idgham_shafawi,
[data-theme="light"] .qr-verses--tajweed .ghunnah { color: #0e8e00 !important; }
[data-theme="light"] .qr-verses--tajweed .idgham_wo_ghunnah,
[data-theme="light"] .qr-verses--tajweed .idgham_mutajanisayn,
[data-theme="light"] .qr-verses--tajweed .idgham_mutaqaribayn { color: #8b00d0 !important; }
[data-theme="light"] .qr-verses--tajweed .custom-alef-maksora { color: #d47700 !important; }

[data-theme="light"] .qr-bottom-sheet {
    background: var(--bg-primary);
}

[data-theme="light"] .qr-bottom-sheet .qr-player__header,
[data-theme="light"] .qr-bottom-sheet .qr-audio-bar {
    background: rgba(255, 255, 255, 0.95);
}
