/* =====================================================================
   WINQURAN — Al-Qur'an Digital
   Semua aset lokal: tanpa CDN, tanpa Google Fonts.
   ===================================================================== */

@font-face {
    font-family: "WinQuranMushaf";
    src: url("../media/fonts/UthmanicHafs.woff2") format("woff2");
    font-display: swap;
}

:root {
    --bg: #f7f6f2;
    --surface: #ffffff;
    --surface-2: #f1efe8;
    --text: #1d2321;
    --muted: #66706c;
    --border: #e2dfd6;
    --accent: #0f766e;
    --accent-ink: #ffffff;
    --accent-soft: #dff1ee;
    --word-hover: #eef6f4;
    --word-active: #fde68a;
    --word-active-ink: #1d2321;
    --ayah-active: #f3faf8;
    --latin: #8a6a2b;
    --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .05);
    --radius: 14px;
    --ar-size: 32px;
    --font-ui: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-ar: "WinQuranMushaf", "KFGQPC HAFS Uthmanic Script", "KFGQPC Uthmanic Script HAFS", "Amiri Quran", "Scheherazade New", "Traditional Arabic", "Noto Naskh Arabic", serif;
    --topbar-h: 60px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="sepia"]) {
        --bg: #121614;
        --surface: #1a201d;
        --surface-2: #222a26;
        --text: #e7ece9;
        --muted: #9aa6a0;
        --border: #2d3732;
        --accent: #2dd4bf;
        --accent-ink: #062b27;
        --accent-soft: #163a35;
        --word-hover: #1f2d29;
        --word-active: #b45309;
        --word-active-ink: #fff7ed;
        --ayah-active: #18241f;
        --latin: #d8b46a;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #121614;
    --surface: #1a201d;
    --surface-2: #222a26;
    --text: #e7ece9;
    --muted: #9aa6a0;
    --border: #2d3732;
    --accent: #2dd4bf;
    --accent-ink: #062b27;
    --accent-soft: #163a35;
    --word-hover: #1f2d29;
    --word-active: #b45309;
    --word-active-ink: #fff7ed;
    --ayah-active: #18241f;
    --latin: #d8b46a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
}

:root[data-theme="sepia"] {
    --bg: #f4ecd8;
    --surface: #fbf5e6;
    --surface-2: #efe4cb;
    --text: #3b2f1e;
    --muted: #7a6a52;
    --border: #e2d4b4;
    --accent: #8a5a12;
    --accent-ink: #fffaf0;
    --accent-soft: #f1e2bf;
    --word-hover: #f3e7c9;
    --word-active: #f6c56b;
    --word-active-ink: #3b2f1e;
    --ayah-active: #f7eed8;
}

/* ------------------------------------------------------------------ dasar */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--topbar-h) + 72px); }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: Consolas, "Cascadia Mono", Menlo, monospace; font-size: .9em; }
pre { background: var(--surface-2); padding: 12px 14px; border-radius: 10px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.arabic { font-family: var(--font-ar); direction: rtl; }
svg { width: 20px; height: 20px; fill: currentColor; }

.page { max-width: 1040px; margin: 0 auto; padding: 24px 16px 96px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.prose h1 { margin-top: 0; }
.prose h2 { margin-top: 1.6em; font-size: 1.15rem; }

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; cursor: pointer;
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.icon-btn {
    display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 8px;
    border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--muted);
    font: inherit; font-weight: 600; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.icon-btn.big { width: 46px; height: 46px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); }
.icon-btn.big:hover { background: var(--accent); filter: brightness(1.08); }
.chip { font-size: .85rem; padding: 4px 12px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge { font-size: .7rem; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
select, input[type="search"] {
    font: inherit; color: var(--text); background: var(--surface);
    border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px;
}
input[type="search"]:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------ topbar */
.topbar { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1320px; margin: 0 auto; height: var(--topbar-h); padding: 0 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; }
.brand-mark rect { fill: none; stroke: var(--accent); stroke-width: 2.2; }
.brand-mark circle { fill: var(--accent); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { letter-spacing: .12em; font-size: 1.05rem; }
.brand-text small { color: var(--muted); font-size: .62rem; }
.mainnav { display: flex; gap: 2px; margin-left: 4px; }
.mainnav a { color: var(--muted); padding: 6px 9px; border-radius: 8px; font-size: .92rem; }
.mainnav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.mainnav { align-items: center; }
.navmenu { position: relative; }
.navmenu summary { list-style: none; cursor: pointer; color: var(--muted); padding: 6px 10px; border-radius: 8px; font-size: .92rem; user-select: none; white-space: nowrap; }
.navmenu summary::-webkit-details-marker { display: none; }
.navmenu summary::after { content: ""; display: inline-block; margin-left: 6px; border: 4px solid transparent; border-top-color: currentColor; transform: translateY(2px); }
.navmenu summary:hover, .navmenu[open] summary { background: var(--surface-2); color: var(--text); }
.navmenu-list { position: absolute; top: calc(100% + 6px); left: 0; min-width: 170px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; z-index: 50; }
.navmenu-list a { padding: 8px 10px; }
.mainnav > a { white-space: nowrap; }
.footer-links { font-size: .9rem; }
.topsearch { margin-left: auto; flex: 0 1 240px; min-width: 130px; }
.topsearch input { width: 100%; }
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 2px; background: var(--surface); flex: none; }
.lang-switch a { font-size: .78rem; font-weight: 600; letter-spacing: .03em; color: var(--muted); padding: 4px 9px; border-radius: 999px; line-height: 1.2; }
.lang-switch a:hover { color: var(--text); text-decoration: none; }
.lang-switch a.on { background: var(--accent); color: var(--accent-ink); }

/* ------------------------------------------------------------------ beranda */
.hero { text-align: center; padding: 24px 0 28px; }
.hero-bismillah { font-family: var(--font-ar); font-size: 2rem; margin: 0 0 6px; color: var(--accent); }
.hero h1 { margin: 0; font-size: 2rem; letter-spacing: -.01em; }
.hero-sub { color: var(--muted); margin: 6px auto 18px; max-width: 560px; }
.hero-search { display: flex; gap: 8px; max-width: 560px; margin: 0 auto; }
.hero-search input { flex: 1; padding: 10px 14px; border-radius: 999px; }
.continue { margin-top: 14px; font-size: .92rem; color: var(--muted); }
.continue a { font-weight: 600; margin-left: 4px; }

.daily { margin-bottom: 28px; }
.daily-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.eyebrow { font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
.daily-ref { font-size: .9rem; font-weight: 600; }
.daily-ar { font-size: 1.9rem; line-height: 2.2; margin: 12px 0 6px; }
.daily-tr { margin: 0; color: var(--muted); }

.index-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs { display: inline-flex; background: var(--surface-2); padding: 4px; border-radius: 999px; }
.tab { border: 0; background: transparent; padding: 6px 18px; border-radius: 999px; font: inherit; color: var(--muted); cursor: pointer; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.filter { width: 240px; }

.surah-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.surah-card {
    display: flex; align-items: center; gap: 14px; padding: 14px 16px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text);
    transition: border-color .15s, transform .15s;
}
.surah-card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.surah-no { width: 40px; height: 40px; flex: none; display: grid; place-items: center; position: relative; font-weight: 600; font-size: .85rem; }
.surah-no::before { content: ""; position: absolute; inset: 6px; border: 1.5px solid var(--accent); border-radius: 6px; transform: rotate(45deg); }
.surah-card:hover .surah-no::before { background: var(--accent-soft); }
.surah-no span { position: relative; }
.surah-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.surah-meta small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.surah-ar { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.surah-ar span { font-family: var(--font-ar); font-size: 1.35rem; line-height: 1.3; }
.surah-ar small { color: var(--muted); font-size: .75rem; white-space: nowrap; }

.juz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.juz-card { display: flex; flex-direction: column; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); }
.juz-card:hover { border-color: var(--accent); text-decoration: none; }
.juz-no { font-weight: 700; }
.juz-start { color: var(--muted); font-size: .85rem; }

/* ------------------------------------------------------------------ pembaca */
.surah-header { text-align: center; position: relative; margin-bottom: 16px; }
.surah-nav-mini { display: flex; justify-content: space-between; }
.surah-title-ar { font-family: var(--font-ar); font-size: 2.6rem; line-height: 1.4; margin: 6px 0 0; color: var(--accent); }
.surah-title { margin: 0; font-size: 1.5rem; }
.surah-sub { margin: 2px 0 0; color: var(--muted); }
.bismillah { font-size: 2rem; margin: 18px 0 4px; line-height: 2; }

.toolbar {
    position: sticky; top: var(--topbar-h); z-index: 30;
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
    padding: 10px 14px; margin: 0 -2px 16px;
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.toolbar-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qari-form select { max-width: 220px; }
.toggles { gap: 4px 12px; }
.lang-select { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.lang-select svg { width: 18px; height: 18px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; color: var(--muted); cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

.verses { display: flex; flex-direction: column; gap: 4px; }
.ayah {
    display: grid; grid-template-columns: 64px 1fr; gap: 12px;
    padding: 18px 14px; border-bottom: 1px solid var(--border); border-radius: 12px;
    transition: background-color .2s;
}
.ayah.active { background: var(--ayah-active); box-shadow: inset 3px 0 0 var(--accent); }
.ayah:target { background: var(--ayah-active); }
.ayah-side { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ayah-key { font-size: .8rem; font-weight: 600; color: var(--muted); }
.ayah-side .icon-btn svg { width: 18px; height: 18px; }
.ayah-body { min-width: 0; }

.words { display: flex; flex-wrap: wrap; gap: 6px 4px; align-items: flex-start; direction: rtl; }
.word {
    display: inline-flex; flex-direction: column; align-items: center; text-align: center;
    padding: 4px 6px 6px; border-radius: 10px; cursor: pointer; position: relative;
    transition: background-color .12s, color .12s;
}
.word:hover, .word:focus-visible { background: var(--word-hover); outline: none; }
.word.playing, .word.active { background: var(--word-active); color: var(--word-active-ink); }
.word.active .w-tr, .word.active .w-tl, .word.playing .w-tr, .word.playing .w-tl { color: inherit; }
.w-ar { font-family: var(--font-ar); font-size: var(--ar-size); line-height: 1.75; }
.w-tl { font-size: .74rem; color: var(--accent); font-style: italic; line-height: 1.3; display: none; }
.w-tr { font-size: .76rem; color: var(--muted); line-height: 1.3; max-width: 150px; }
body.show-translit .w-tl { display: block; }
body.hide-wbw .w-tr { display: none; }
.ayah-end { font-family: var(--font-ar); font-size: calc(var(--ar-size) * .8); color: var(--accent); align-self: center; padding: 0 4px; line-height: 1.75; }

/* tooltip arti saat arti per kata disembunyikan */
body.hide-wbw .word:hover::after {
    content: attr(data-tip); position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
    background: var(--text); color: var(--bg); font-family: var(--font-ui); font-size: .78rem; line-height: 1.3;
    padding: 5px 9px; border-radius: 8px; white-space: nowrap; z-index: 5; direction: ltr; pointer-events: none;
}

.ayah-tr { margin: 10px 0 0; font-size: 1rem; line-height: 1.7; }
body.hide-trans .ayah-tr { display: none; }
.ayah-latin { margin: 12px 0 0; color: var(--latin); font-size: 1.02rem; line-height: 1.7; }
body.hide-latin .ayah-latin { display: none; }

.juz-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 6px; color: var(--muted); font-size: .8rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.juz-divider::before, .juz-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.surah-pager { display: flex; justify-content: space-between; gap: 8px; margin-top: 28px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ pemutar */
.player { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; padding: 0 12px 12px; pointer-events: none; }
.player-inner {
    pointer-events: auto; max-width: 760px; margin: 0 auto;
    display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 8px 30px rgba(0, 0, 0, .15);
    padding: 10px 14px;
}
.player-info { display: flex; flex-direction: column; min-width: 0; }
.player-info strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-controls { display: flex; align-items: center; gap: 4px; }
.player-controls select { padding: 4px 6px; font-size: .85rem; }
.player .i-pause { display: none; }
.player.is-playing .i-pause { display: block; }
.player.is-playing .i-play { display: none; }
#seek { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); margin: 2px 0 0; }
body.has-player .page { padding-bottom: 160px; }

/* ------------------------------------------------------------------ cari & status */
.result-count { color: var(--muted); margin: 18px 4px 10px; }
.results { display: flex; flex-direction: column; gap: 10px; }
.result { display: flex; flex-direction: column; gap: 6px; color: var(--text); padding: 16px 18px; }
.result:hover { text-decoration: none; border-color: var(--accent); }
.result-ref { font-size: .85rem; font-weight: 600; color: var(--accent); }
.result-ar { font-size: 1.5rem; line-height: 2; }
.result-tr { color: var(--muted); }
mark { background: var(--word-active); color: var(--word-active-ink); border-radius: 3px; padding: 0 2px; }

.status-table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.status-table th, .status-table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.status-table th { width: 200px; font-weight: 600; }
.status-table tr.ok th::before { content: "●"; color: #16a34a; margin-right: 8px; }
.status-table tr.warn th::before { content: "●"; color: #d97706; margin-right: 8px; }
.status-table.meta th::before { content: none !important; }
.status-table.meta td { word-break: break-all; }

/* ------------------------------------------------------------------ pengunjung */
.visitor-hero h1 { margin: 0 0 4px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; }
.kpi { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; }
.kpi span { color: var(--muted); font-size: .8rem; }
.kpi strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-top: 16px; }
.stat-card h2 { font-size: 1rem; margin: 0 0 10px; }
.stat-card.wide { grid-column: 1 / -1; }
.stat-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.stat-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: .78rem; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.stat-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.stat-table .num { text-align: right; width: 1%; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar-label { display: flex; align-items: center; gap: 8px; }
.bar { display: block; height: 4px; margin-top: 5px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.flag { width: 24px; height: 18px; border-radius: 2px; box-shadow: 0 0 0 1px var(--border); flex: none; object-fit: cover; }
.flag-code { display: inline-grid; place-items: center; font-size: .6rem; font-weight: 700; color: var(--muted); background: var(--surface-2); }
.pager { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 12px; }
.pager a, .pager .current { min-width: 32px; padding: 4px 8px; text-align: center; border-radius: 8px; border: 1px solid var(--border); font-size: .85rem; }
.pager .current { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.attribution { text-align: center; margin-top: 16px; }
.visit-counter { margin: 4px 0 0; font-size: .8rem; }

.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px 16px 40px; }
body.has-player .footer { padding-bottom: 140px; }

.toast {
    position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%) translateY(20px);
    background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .9rem;
    opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------------------------------------------ layar kecil */
@media (max-width: 1240px) {
    .brand-text small { display: none; }
}
/* Layar sedang: menu pindah ke baris kedua bilah atas. */
@media (max-width: 1120px) {
    :root { --topbar-h: 100px; }
    .topbar-inner { flex-wrap: wrap; align-content: center; row-gap: 4px; }
    .mainnav { order: 10; width: 100%; margin-left: -9px; }
}
@media (max-width: 480px) {
    .brand-text { display: none; }
}
@media (max-width: 760px) {
    :root { --topbar-h: 60px; }
    .topbar-inner { flex-wrap: nowrap; }
    .mainnav { display: none; }
    .brand-text small { display: none; }
    .topbar-inner { gap: 8px; }
    .topsearch { flex: 1; min-width: 0; }
    .topsearch input { width: 100%; }
    .ayah { grid-template-columns: 1fr; gap: 6px; padding: 14px 6px; }
    .ayah-side { flex-direction: row; justify-content: flex-start; }
    .toolbar { position: static; }
    .surah-grid { grid-template-columns: 1fr; }
    .filter { width: 100%; }
    .hero h1 { font-size: 1.6rem; }
    :root { --ar-size: 28px; }
    .player-inner { grid-template-columns: 1fr; }
    .player-controls { justify-content: center; }
}
