/* =========================================================
   Tafsir App — Scoped under .tafsir-app
   Matches XenForo + Hadith app color palette
   ========================================================= */

/* Self-hosted Amiri (bold) — /styles/fonts/amiri/ */
@font-face {
    font-family: 'Amiri';
    src: url('/styles/fonts/amiri/amiri-v30-arabic-700.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* Noor-e-Hira — Quran Arabic verses (self-hosted on tohed.com) */
@font-face {
    font-family: 'NooreHira';
    src: url('https://tohed.com/wp-content/uploads/2025/09/noorehira.woff2') format('woff2');
    font-display: swap;
    unicode-range: U+0600-06FF;
}

/* --- Dropdown menus (XenForo nav compat) --- */
.p-navEl[data-has-children] { position: relative; }
.p-navEl[data-has-children] .menu { display: none; position: absolute; top: 100%; left: 0; z-index: 1000; min-width: 180px; background: #fff; border: 1px solid #d4dce5; border-radius: 4px; box-shadow: 0 4px 16px rgba(0,0,0,.13); }
.p-navEl[data-has-children]:hover .menu { display: block; }
.menu-linkRow { display: block; padding: 8px 16px; color: #333; text-decoration: none; white-space: nowrap; }
.menu-linkRow:hover { background: #f0f5fa; color: #0f578a; }

/* --- App container --- */
.tafsir-app {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
}

/* --- Page header --- */
.tafsir-page-header {
    text-align: center;
    margin-bottom: 28px;
    padding-bottom: 18px;
    border-bottom: 2px solid #0f578a;
}
.tafsir-page-header h1 {
    font-size: 1.6em;
    color: #0f578a;
    margin: 0 0 6px;
}
.tafsir-page-header p {
    color: #666;
    margin: 0;
    font-size: 0.95em;
}
.tafsir-page-header-arabic {
    font-family: 'NooreHira', 'Amiri', serif;
    font-size: 1.8em;
    color: #3b1f7a;
    direction: rtl;
    margin-bottom: 6px;
}

/* --- Surah card grid (home page) --- */
.tafsir-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}
.tafsir-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 18px 14px;
    background: #fff;
    border: 1px solid #e8ecf0;
    border-top: 4px solid #0f578a;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    position: relative;
}
.tafsir-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(15, 87, 138, 0.15);
}
.tafsir-card-num {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #0f578a;
    color: #fff;
    font-size: 0.78em;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    min-width: 24px;
    text-align: center;
}
.tafsir-card-arabic {
    font-family: 'NooreHira', 'Amiri', serif;
    font-size: 1.4em;
    color: #3b1f7a;
    direction: rtl;
    margin: 4px 0 2px;
}
.tafsir-card-name {
    font-size: 1.05em;
    font-weight: 600;
    color: #0f578a;
    margin: 2px 0;
}
.tafsir-card-english {
    font-size: 0.88em;
    color: #555;
}
.tafsir-card-meta {
    font-size: 0.8em;
    color: #888;
    margin-top: 4px;
}

/* --- Surah page: ayah list --- */
.tafsir-surah-content {
    max-width: 850px;
    margin: 0 auto;
}

.tafsir-bismillah {
    text-align: center;
    padding: 16px 0 20px;
    font-family: 'NooreHira', 'Amiri', serif;
    font-size: 1.8em;
    color: #3b1f7a;
    direction: rtl;
}

.tafsir-ayah-row {
    display: flex;
    gap: 14px;
    padding: 16px 0;
    border-bottom: 1px solid #edf0f3;
    align-items: flex-start;
}
.tafsir-ayah-row:last-child {
    border-bottom: none;
}

.tafsir-ayah-num-badge {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tafsir-ayah-num-badge a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: #0f578a;
    color: #fff;
    font-size: 0.85em;
    font-weight: 700;
    border-radius: 50%;
    text-decoration: none;
    transition: background 0.15s;
}
.tafsir-ayah-num-badge a:hover {
    background: #0a3d60;
}

.tafsir-ayah-content {
    flex: 1;
    min-width: 0;
}

.tafsir-ayah-arabic {
    font-family: 'NooreHira', 'Amiri', serif;
    font-size: 1.5em;
    line-height: 2;
    color: #1a1a2e;
    margin-bottom: 8px;
}
.tafsir-ayah-arabic a {
    color: inherit;
    text-decoration: none;
}
.tafsir-ayah-arabic a:hover {
    color: #3b1f7a;
}

.tafsir-ayah-translation {
    font-size: 0.98em;
    line-height: 1.7;
    color: #444;
}

/* --- Single ayah page --- */
.tafsir-single {
    max-width: 850px;
    margin: 0 auto;
}

.tafsir-single-header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #0f578a;
}
.tafsir-single-surah-name {
    font-family: 'NooreHira', 'Amiri', serif;
    font-size: 1.6em;
    color: #3b1f7a;
    margin-bottom: 4px;
}
.tafsir-single-header h1 {
    font-size: 1.35em;
    color: #0f578a;
    margin: 0 0 4px;
}
.tafsir-single-surah-meta {
    color: #666;
    font-size: 0.9em;
    margin: 0;
}

/* Arabic text block */
.tafsir-arabic-block {
    font-family: 'NooreHira', 'Amiri', serif;
    font-size: 1.7em;
    line-height: 2.2;
    color: #1a1a2e;
    background: #f8f6f1;
    padding: 24px 28px;
    border-radius: 8px;
    border-right: 5px solid #3b1f7a;
    margin-bottom: 24px;
    text-align: right;
}
.tafsir-ayah-marker {
    font-size: 0.75em;
    color: #0f578a;
    margin-right: 4px;
}

/* Section containers */
.tafsir-section {
    margin-bottom: 24px;
    background: #fff;
    border: 1px solid #e8ecf0;
    border-radius: 8px;
    overflow: hidden;
    content-visibility: auto;
    contain-intrinsic-size: auto 400px;
}
h2.tafsir-section-label,
.tafsir-section-label {
    background: #0f578a;
    color: #fff;
    font-size: 0.9em;
    font-weight: 600;
    padding: 8px 16px;
    margin: 0;
    line-height: 1.6;
}
.tafsir-range-note {
    font-weight: 400;
    opacity: 0.85;
    font-size: 0.9em;
    margin-left: 6px;
}
.tafsir-info-toggle {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.1em;
    cursor: pointer;
    opacity: 0.8;
    padding: 0 4px;
    vertical-align: middle;
}
.tafsir-info-toggle:hover { opacity: 1; }
.tafsir-info-box {
    display: none;
    background: #f0f5f9;
    border-left: 3px solid #0f578a;
    padding: 12px 16px;
    font-size: 0.88em;
    line-height: 1.7;
    color: #444;
}
.tafsir-info-box p { margin: 0; }
.tafsir-info-box.tafsir-info-visible { display: block; }

/* Translation text */
.tafsir-translation-text {
    padding: 16px 20px;
    font-size: 1.05em;
    line-height: 1.85;
    color: #333;
}

/* Word by word grid */
.tafsir-wbw-grid {
    display: flex;
    flex-wrap: wrap;
    direction: rtl;
    justify-content: center;
    gap: 8px;
    padding: 16px;
}
.tafsir-wbw-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 12px;
    background: #f8fafb;
    border: 1px solid #e8ecf0;
    border-radius: 6px;
    min-width: 80px;
    text-align: center;
}
.tafsir-wbw-arabic {
    font-family: 'NooreHira', 'Amiri', serif;
    font-size: 1.25em;
    color: #3b1f7a;
    margin-bottom: 4px;
    line-height: 1.6;
}
.tafsir-wbw-translit {
    font-size: 0.78em;
    color: #888;
    font-style: italic;
    margin-bottom: 2px;
}
.tafsir-wbw-meaning {
    font-size: 0.82em;
    color: #0f578a;
    font-weight: 600;
    direction: ltr;
}

/* --- Tafsir Source Tabs --- */
.tafsir-source-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    border-bottom: 2px solid #e8ecf0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tafsir-source-tabs::-webkit-scrollbar { display: none; }
.tafsir-source-tab {
    flex-shrink: 0;
    padding: 10px 20px;
    font-size: 0.9em;
    font-weight: 500;
    color: #666;
    text-decoration: none;
    background: #f8fafb;
    border: 1px solid #e8ecf0;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    margin-bottom: -2px;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.tafsir-source-tab:hover {
    background: #edf2f7;
    color: #0f578a;
}
.tafsir-source-tab.active {
    background: #fff;
    color: #0f578a;
    font-weight: 600;
    border-color: #e8ecf0;
    border-top: 3px solid #0f578a;
    padding-top: 8px;
}

/* Tafsir text */
.tafsir-tafsir-text {
    padding: 16px 20px;
    font-size: 0.98em;
    line-height: 1.8;
    color: #333;
}

/* Arabic text wrappers inside tafsir (matches tohed.com Urdu site) */
.tafsir-tafsir-text .ar-phrase {
    unicode-bidi: isolate;
}
.tafsir-tafsir-text .ar-inline {
    font-family: 'Amiri', serif;
    font-size: 1.15em;
    line-height: 2;
    color: #3b1f7a;
    font-weight: 600;
}
.tafsir-tafsir-text .fontarabic {
    font-family: 'Amiri', serif;
    font-size: 1.15em;
    line-height: 2;
    color: #3b1f7a;
    font-weight: 600;
    unicode-bidi: isolate;
}
.tafsir-tafsir-text .reference {
    color: #c9302c;
    font-weight: 700;
    unicode-bidi: isolate;
}
.tafsir-tafsir-text .reference.fontarabic {
    font-size: 1.1em;
}
.tafsir-tafsir-text .uarabicfwaz {
    color: #3b1f7a;
    unicode-bidi: isolate;
}
.tafsir-tafsir-text .quot {
    font-style: normal;
}

/* --- Jump Bar --- */
.tafsir-jump-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 24px;
    background: #f8fafb;
    border: 1px solid #e8ecf0;
    border-radius: 10px;
    overflow: hidden;
}
.tafsir-jump-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    min-height: 50px;
    font-size: 1.6em;
    font-weight: 700;
    color: #0f578a;
    text-decoration: none;
    background: #edf2f7;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    user-select: none;
}
.tafsir-jump-arrow:hover:not(.disabled) {
    background: #0f578a;
    color: #fff;
}
.tafsir-jump-arrow.disabled {
    color: #c0c8d0;
    cursor: default;
    pointer-events: none;
}
.tafsir-jump-form {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    flex: 1;
    justify-content: center;
}
.tafsir-jump-form select {
    padding: 8px 12px;
    border: 1px solid #d4dce5;
    border-radius: 6px;
    font-size: 0.95em;
    background: #fff;
    color: #333;
    min-width: 200px;
    cursor: pointer;
}
.tafsir-jump-form select:focus {
    border-color: #0f578a;
    outline: none;
    box-shadow: 0 0 0 2px rgba(15, 87, 138, 0.15);
}
.tafsir-jump-form input[type="number"] {
    width: 70px;
    padding: 8px 10px;
    border: 1px solid #d4dce5;
    border-radius: 6px;
    font-size: 0.95em;
    text-align: center;
    background: #fff;
    color: #333;
}
.tafsir-jump-form input[type="number"]:focus {
    border-color: #0f578a;
    outline: none;
    box-shadow: 0 0 0 2px rgba(15, 87, 138, 0.15);
}
.tafsir-jump-form button {
    padding: 8px 20px;
    background: #0f578a;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.92em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.tafsir-jump-form button:hover {
    background: #0a3d60;
}

/* --- Navigation --- */
.tafsir-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 28px 0 10px;
    padding-top: 16px;
    border-top: 1px solid #e8ecf0;
}
.tafsir-nav a {
    display: inline-block;
    padding: 10px 22px;
    background: #fff;
    color: #0f578a;
    border: 2px solid #0f578a;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.92em;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.tafsir-nav a:hover {
    background: #0f578a;
    color: #fff;
}
.tafsir-nav a.tafsir-nav-index {
    background: #0f578a;
    color: #fff;
    border-color: #0f578a;
}
.tafsir-nav a.tafsir-nav-index:hover {
    background: #0a3d60;
    border-color: #0a3d60;
}
.tafsir-nav span {
    width: 120px;
}

/* --- Play Button (top-left of Arabic block) --- */
.tafsir-arabic-block {
    position: relative;
}
.tafsir-play-btn {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background: #0f578a;
    color: #fff;
    font-size: 14px;
    padding: 0;
    box-shadow: 0 2px 8px rgba(15,87,138,.25);
    transition: all .25s ease;
    z-index: 1;
    line-height: 1;
}
.tafsir-play-btn:hover {
    background: #0a3d60;
    transform: scale(1.1);
    box-shadow: 0 4px 14px rgba(15,87,138,.35);
}
.tafsir-play-btn:active {
    transform: scale(.95);
}
.tafsir-play-btn.is-playing {
    background: #c0392b;
}
.tafsir-play-btn.is-playing:hover {
    background: #a93226;
}
.tafsir-arabic-block.is-playing {
    background: rgba(15,87,138,.06);
    border-right-color: #0f578a;
}
.tafsir-audio-status {
    display: block;
    text-align: left;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.78em;
    color: #888;
    margin-top: 8px;
    direction: ltr;
}
.tafsir-audio-status:empty {
    display: none;
}

/* --- Copy Button --- */
.tafsir-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 2px solid #d4dce5;
    border-radius: 8px;
    cursor: pointer;
    background: linear-gradient(145deg, #f0f5fa 0%, #d4dce5 100%);
    box-shadow: 0 2px 6px rgba(15,87,138,.08);
    transition: all .25s ease;
    position: relative;
    vertical-align: middle;
}
.tafsir-copy-btn:hover {
    transform: translateY(-2px);
    border-color: #0f578a;
    background: linear-gradient(145deg, #d4dce5 0%, #b8c8d4 100%);
    box-shadow: 0 4px 12px rgba(15,87,138,.18);
}
.tafsir-copy-btn:active {
    transform: translateY(0) scale(.95);
}
.tafsir-copy-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: #0f578a;
    stroke-width: 2;
}
.tafsir-copy-btn.copied {
    background: linear-gradient(145deg, #0f578a 0%, #0a3d60 100%);
    border-color: #0a3d60;
    animation: tafsir-copy-pop .4s ease;
}
.tafsir-copy-btn.copied svg { display: none; }
.tafsir-copy-btn.copied::after {
    content: '\2713';
    color: #fff;
    font-size: 16px;
    font-weight: 700;
}
@keyframes tafsir-copy-pop {
    0%,100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.tafsir-section-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.tafsir-section-label .tafsir-copy-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-color: rgba(255,255,255,.35);
    background: rgba(255,255,255,.15);
    box-shadow: none;
}
.tafsir-section-label .tafsir-copy-btn svg {
    width: 15px;
    height: 15px;
    stroke: #fff;
}
.tafsir-section-label .tafsir-copy-btn:hover {
    background: rgba(255,255,255,.3);
    border-color: rgba(255,255,255,.6);
}
.tafsir-section-label .tafsir-copy-btn.copied {
    background: rgba(255,255,255,.3);
    border-color: rgba(255,255,255,.5);
}
.tafsir-section-label .tafsir-copy-btn.copied::after {
    color: #fff;
    font-size: 14px;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .tafsir-app {
        padding: 12px;
    }
    .tafsir-card-grid {
        grid-template-columns: 1fr;
    }
    .tafsir-ayah-row {
        flex-direction: column;
        gap: 8px;
    }
    .tafsir-ayah-num-badge {
        width: auto;
        height: auto;
    }
    .tafsir-arabic-block {
        font-size: 1.4em;
        padding: 16px 18px 16px 56px;
    }
    .tafsir-wbw-item {
        min-width: 65px;
    }
    .tafsir-nav {
        flex-direction: column;
    }
    .tafsir-nav a {
        width: 100%;
        text-align: center;
    }
    .tafsir-nav span {
        display: none;
    }
    .tafsir-single-header h1 {
        font-size: 1.15em;
    }
    .tafsir-source-tab {
        padding: 8px 14px;
        font-size: 0.84em;
    }
    .tafsir-jump-bar {
        flex-wrap: wrap;
        border-radius: 8px;
    }
    .tafsir-jump-arrow {
        width: 44px;
        min-height: 44px;
        font-size: 1.4em;
    }
    .tafsir-jump-form {
        flex-wrap: wrap;
        padding: 8px 10px;
        gap: 8px;
        order: 2;
        width: 100%;
        border-top: 1px solid #e8ecf0;
    }
    .tafsir-jump-form select {
        min-width: 0;
        flex: 1;
    }
    .tafsir-jump-form input[type="number"] {
        width: 60px;
    }
}
