@font-face {
    font-family: 'KFGQPC Uthmanic Script HAFS';
    src: url('../fonts/UthmanicHafs.otf') format('opentype');
    font-display: swap;
}

:root {
    --bg: #0a0a2e;
    --panel: #10103d;
    --border: #232357;
    --ink: #ffffff;
    --ink-soft: #b8b8d0;
    --blue: #f5c518;
    --blue-ink: #1a1a1a;
    --blue-deep: #f5c518;
    --blue-bright: #f5c518;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0a0a2e; --panel: #10103d; --border: #232357;
        --ink: #ffffff; --ink-soft: #b8b8d0;
        --blue: #f5c518; --blue-ink: #1a1a1a; --blue-deep: #f5c518; --blue-bright: #f5c518;
    }
}
:root[data-theme="dark"] {
    --bg: #0a0a2e; --panel: #10103d; --border: #232357;
    --ink: #ffffff; --ink-soft: #b8b8d0;
    --blue: #f5c518; --blue-ink: #1a1a1a; --blue-deep: #f5c518; --blue-bright: #f5c518;
}
:root[data-theme="light"] {
    --bg: #0a0a2e; --panel: #10103d; --border: #232357;
    --ink: #ffffff; --ink-soft: #b8b8d0;
    --blue: #f5c518; --blue-ink: #1a1a1a; --blue-deep: #f5c518; --blue-bright: #f5c518;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

.tab-nav { display: flex; gap: 6px; padding: 10px 3vw 0; }
.tab-btn {
    background: transparent; border: none; color: var(--ink-soft); padding: 10px 18px;
    border-radius: 8px 8px 0 0; cursor: pointer; font-weight: 600; font-size: 15px;
    font-family: inherit; border-bottom: 2px solid transparent; margin-bottom: -1px;
    display: inline-block; text-decoration: none;
}
.tab-btn.active { color: #fff; border-bottom-color: var(--blue); }
.tab-btn:hover:not(.active) { color: #fff; }

body {
    background: var(--bg);
    color: var(--ink);
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 3vw;
    background: var(--bg);
    border-bottom: 2px solid var(--border);
    flex-wrap: wrap;
}
.topbar .title { font-weight: 700; font-size: 16px; color: var(--blue-deep); }
.topbar select {
    font-size: 13px; font-weight: 600; padding: 7px 10px;
    border: 1.5px solid var(--border); border-radius: 8px;
    background: var(--panel); color: var(--ink);
    flex: 1 1 auto; min-width: 0; max-width: 60vw;
}

.surah { padding: 0 2vw 30px; max-width: 1400px; margin: 0 auto; }

.surah-header {
    text-align: center;
    padding: 34px 10px 18px;
    scroll-margin-top: 58px;
}
.surah-header .arabic-name {
    font-family: 'KFGQPC Uthmanic Script HAFS', serif;
    font-weight: bold;
    font-size: clamp(32px, 8vw, 50px);
    color: var(--blue-deep);
    margin: 0 0 6px;
    direction: rtl;
}
.surah-header .meta-line {
    font-size: 13px; font-weight: 700; letter-spacing: 0.04em;
    text-transform: uppercase; color: var(--ink-soft);
}

.ayah-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px 26px 20px;
    margin: 0 0 16px;
    background: var(--panel);
}
.ayah-card .ref {
    display: inline-block;
    font-size: 14px;
    font-weight: 800;
    color: var(--blue);
    background: none;
    padding: 0;
    margin-bottom: 16px;
    font-variant-numeric: tabular-nums;
}

.interlinear {
    display: flex;
    flex-wrap: wrap;
    gap: 20px 26px;
    direction: rtl;
}
.word-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.word-unit .ar {
    font-family: 'KFGQPC Uthmanic Script HAFS', serif;
    font-weight: bold;
    font-size: clamp(26px, 5vw, 34px);
    white-space: nowrap;
    color: var(--ink);
    text-decoration: none;
    padding: 1px 5px;
    border-radius: 5px;
    transition: background-color 0.12s ease, color 0.12s ease;
}
.word-unit .ar:hover,
.word-unit .ar:focus-visible {
    background-color: var(--blue);
    color: var(--blue-ink);
}
.word-unit .gloss {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-soft);
    text-align: center;
    direction: ltr;
    max-width: 16ch;
    line-height: 1.3;
}

/* ---- Dictionary entry modal (triggered by clicking a rooted word) ---- */
.dict-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 100;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 40px 16px; overflow-y: auto;
}
.dict-modal {
    background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
    max-width: 700px; width: 100%; padding: 24px 26px; position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,.5); animation: dictModalIn .18s ease;
}
@keyframes dictModalIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.dict-modal-close {
    position: absolute; top: 10px; right: 14px; cursor: pointer; font-size: 26px;
    color: var(--ink-soft); line-height: 1; font-family: sans-serif;
}
.dict-modal-close:hover, .dict-modal-close:focus-visible { color: #fff; }
.dict-entry-arabic {
    font-family: 'KFGQPC Uthmanic Script HAFS', serif; font-weight: bold;
    font-size: 32px; direction: rtl; color: var(--blue); margin: 0 30px 8px 0;
}
.dict-entry-desc { font-family: sans-serif; font-size: 13px; color: var(--ink-soft); margin-bottom: 10px; line-height: 1.6; }
.dict-section-heading {
    font-family: sans-serif; font-size: 13px; font-weight: 700; color: #fff;
    margin: 14px 0 6px; padding-bottom: 4px; border-bottom: 1px dashed var(--border);
}
.dict-occ { padding: 8px 0; border-bottom: 1px dotted var(--border); font-family: sans-serif; }
.dict-occ:last-child { border-bottom: none; }
.dict-occ .meta { font-size: 12px; color: var(--ink-soft); }
.dict-occ .translit { font-style: italic; color: #ccc; font-size: 13px; }
.dict-occ .gloss { font-weight: 600; color: var(--ink); }
.dict-occ .arabic-line {
    font-family: 'KFGQPC Uthmanic Script HAFS', serif; direction: rtl; text-align: right;
    font-size: 17px; color: #ddd; margin-top: 6px;
}
.quran-ref-link { color: var(--blue); text-decoration: none; border-bottom: 1px dotted var(--blue); }
.quran-ref-link:hover { color: #fff; border-bottom-color: #fff; }
.dict-view-full {
    display: inline-block; margin-top: 16px; font-family: sans-serif; font-size: 13px;
    color: var(--blue); text-decoration: none; border-bottom: 1px dotted var(--blue);
}
.dict-view-full:hover { color: #fff; }
.hidden { display: none !important; }

footer {
    text-align: center;
    padding: 30px 20px 60px;
    font-size: 12px;
    color: var(--ink-soft);
}
footer a { color: var(--blue-bright); }

@media (max-width: 560px) {
    .ayah-card { padding: 14px 12px 12px; }
    .interlinear { gap: 10px 12px; }
}
