/* Athariyah — midnight blue, gold and silver, with glass. */
@font-face { font-family: "Amiri"; src: url("/assets/fonts/amiri-regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Amiri"; src: url("/assets/fonts/amiri-bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Aref Ruqaa"; src: url("/assets/fonts/arefruqaa-bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --midnight: #0f1733;
  --deep: #060914;
  --soft: #21305f;
  --gold: #dbb566;
  --gold-light: #f7e0a3;
  --gold-deep: #9e7833;
  --silver: #ccd4e0;
  --silver-deep: #808ca1;
  --text: #e9edf5;
  --muted: #9aa5ba;
  --card: rgba(19, 24, 45, 0.72);
  --card-solid: #13182d;
  --chip: rgba(41, 49, 77, 0.85);
  --hairline: rgba(204, 212, 224, 0.16);
  --heading: #ebcc8a;
  --glass: rgba(18, 24, 48, 0.55);
  --radius: 22px;
  --ar: "Amiri", "Geeza Pro", "Noto Naskh Arabic", serif;
  --ar-size: 1.55rem;
  --en-size: 1.02rem;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "New York", ui-serif, "Iowan Old Style", Georgia, serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --text: #18203a;
  --muted: #5b6680;
  --card: rgba(255, 255, 255, 0.82);
  --card-solid: #ffffff;
  --chip: rgba(232, 235, 242, 0.95);
  --hairline: rgba(48, 58, 82, 0.14);
  --heading: #85611f;
  --glass: rgba(255, 255, 255, 0.62);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 84px; }
body {
  margin: 0; font-family: var(--sans); color: var(--text); line-height: 1.55;
  background: var(--deep);
  min-height: 100vh;
}
:root[data-theme="light"] body { background: #eef0f6; }
/* Night sky with a faint hex lattice, fixed behind everything. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1200px 700px at 80% -10%, rgba(52, 76, 160, 0.35), transparent 60%),
    radial-gradient(900px 600px at -10% 30%, rgba(219, 181, 102, 0.08), transparent 60%),
    linear-gradient(180deg, var(--midnight), var(--deep));
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .08;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='97' viewBox='0 0 56 97'%3E%3Cpath d='M28 0 L56 16 L56 48 L28 64 L0 48 L0 16 Z M28 64 L28 97' fill='none' stroke='%23dbb566' stroke-width='0.8'/%3E%3C/svg%3E");
}
:root[data-theme="light"] body::before { background: radial-gradient(1000px 600px at 80% -10%, rgba(219, 181, 102, 0.18), transparent 60%), linear-gradient(180deg, #f5f6fa, #e9ecf4); }
:root[data-theme="light"] body::after { opacity: .05; }

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:root[data-theme="light"] a { color: #8a6420; }
img { max-width: 100%; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 18px; }
.narrow { max-width: 760px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }

/* ---------- Glass ---------- */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(160%); backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--hairline);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 10px 30px rgba(0,0,0,.25);
}

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 10px; z-index: 50; margin: 10px auto 0; max-width: 980px; padding: 0 12px; }
.topbar .bar { display: flex; align-items: center; gap: 14px; padding: 8px 10px 8px 16px; border-radius: 999px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 650; letter-spacing: .2px; }
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.brand .ar { font-family: "Aref Ruqaa", var(--ar); font-size: 1.35rem; color: var(--gold); line-height: 1; }
.nav { display: flex; gap: 2px; margin-left: auto; }
.nav a { color: var(--text); padding: 7px 12px; border-radius: 999px; font-size: .93rem; }
.nav a:hover, .nav a[aria-current="page"] { background: var(--chip); text-decoration: none; }
.iconbtn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 999px; border: 0; background: var(--chip); color: var(--text); cursor: pointer; }
.iconbtn svg { width: 18px; height: 18px; }
@media (max-width: 760px) {
  .nav { display: none; }
  .topbar .bar { justify-content: space-between; }
}

/* ---------- Bottom tab bar (phones) ---------- */
.tabbar { display: none; }
@media (max-width: 760px) {
  .tabbar { display: flex; position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 60; border-radius: 999px; padding: 6px; justify-content: space-around; }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 999px; color: var(--muted); font-size: .68rem; font-weight: 600; }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a[aria-current="page"] { color: var(--gold); background: var(--chip); }
  .tabbar a:hover { text-decoration: none; }
  body { padding-bottom: 96px; }
}

/* ---------- Type ---------- */
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 28px 0 8px; }
h2 { font-size: 1.45rem; margin: 34px 0 12px; }
.ar { font-family: var(--ar); direction: rtl; }
.heading-ar { font-family: var(--ar); font-weight: 700; color: var(--heading); }
.calli { font-family: "Aref Ruqaa", var(--ar); font-weight: 700; color: var(--gold); line-height: 1.6; }
.gold-text { background: linear-gradient(135deg, var(--gold-light), var(--gold) 45%, var(--gold-deep)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 38px 0 14px; }
.section-title h2 { margin: 0; }
.section-title .heading-ar { font-size: 1.3rem; }
.crumbs { font-size: .88rem; color: var(--muted); margin-top: 22px; }
.crumbs a { color: var(--muted); }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 18px; box-shadow: 0 8px 26px rgba(0,0,0,.18); }
.card-link { display: block; color: inherit; transition: transform .25s cubic-bezier(.2,.8,.2,1), border-color .25s; }
.card-link:hover { text-decoration: none; transform: translateY(-2px); border-color: rgba(219,181,102,.45); }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.rows { border-radius: var(--radius); overflow: hidden; background: var(--card); border: 1px solid var(--hairline); }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; color: inherit; border-bottom: 1px solid var(--hairline); }
.row:last-child { border-bottom: 0; }
.row:hover { background: rgba(219,181,102,.06); text-decoration: none; }
.row .grow { flex: 1; min-width: 0; }
.row .num { width: 34px; text-align: center; font-variant-numeric: tabular-nums; color: var(--gold); font-weight: 650; }
.row .ar { font-size: 1.15rem; color: var(--heading); font-weight: 700; text-align: right; }
.row .chev { color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--chip); font-size: .78rem; font-weight: 600; color: var(--text); }
a.chip:hover { text-decoration: none; filter: brightness(1.15); }
.chip.gold { color: var(--gold); }
.chip.sahih { color: #7fd1a4; }
.chip.hasan { color: #e6c26a; }
.chip.daif { color: #ef8d84; }
.chip.mawdu { color: #f06a6a; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--hairline); background: var(--chip); color: var(--text); font-weight: 600; cursor: pointer; font-size: .92rem; }
.btn:hover { text-decoration: none; filter: brightness(1.12); }
.btn.gold { background: linear-gradient(135deg, var(--gold-light), var(--gold)); color: #1a1406; border: 0; }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 46px 0 14px; }
.hero .calli { font-size: clamp(3.4rem, 12vw, 6rem); display: block; filter: drop-shadow(0 6px 24px rgba(219,181,102,.25)); }
.hero p { color: var(--muted); max-width: 560px; margin: 4px auto 22px; }
.searchbox { display: flex; align-items: center; gap: 10px; max-width: 620px; margin: 0 auto; padding: 8px 8px 8px 18px; border-radius: 999px; }
.searchbox input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--text); font-size: 1rem; font-family: var(--sans); }
.searchbox input::placeholder { color: var(--muted); }

/* ---------- Book tiles ---------- */
.book { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 6px; min-height: 150px; }
.book .ar { font-size: 1.5rem; font-weight: 700; color: var(--heading); }
.book .en { font-weight: 650; }
.book .meta { color: var(--muted); font-size: .82rem; margin-top: auto; }
.book.featured { background: linear-gradient(160deg, rgba(33,48,95,.92), rgba(6,9,20,.92)); }
.book.featured::after { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; background: radial-gradient(400px 120px at 90% 0%, rgba(219,181,102,.18), transparent 70%); }
.scroller { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 2px 14px; scrollbar-width: none; }
.scroller::-webkit-scrollbar { display: none; }
.scroller > * { scroll-snap-align: start; flex: 0 0 230px; }

/* ---------- Hadith ---------- */
.hadith { background: var(--card); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 18px 20px; margin: 14px 0; scroll-margin-top: 90px; }
.hadith:target { border-color: rgba(219,181,102,.7); box-shadow: 0 0 0 4px rgba(219,181,102,.12); }
.hadith header { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.hadith h3 { font-family: var(--sans); font-size: .92rem; font-weight: 700; margin: 0; color: var(--gold); letter-spacing: .2px; }
.hadith h3 a { color: inherit; }
.hadith .actions { margin-left: auto; display: flex; gap: 6px; }
.hadith .actions button { border: 0; background: var(--chip); color: var(--text); width: 34px; height: 34px; border-radius: 999px; cursor: pointer; display: grid; place-items: center; }
.hadith .actions button svg { width: 16px; height: 16px; }
.hadith .actions button.on { color: var(--gold); }
.hadith .text-ar { font-family: var(--ar); direction: rtl; text-align: right; font-size: var(--ar-size); line-height: 2.05; margin: 6px 0; }
.hadith .isnad { color: var(--muted); }
.hadith .matn { color: var(--text); }
.hadith .text-en { font-size: var(--en-size); line-height: 1.65; margin: 12px 0 4px; padding-top: 12px; border-top: 1px solid var(--hairline); }
.hadith .source-note { font-size: .76rem; color: var(--muted); }
.hadith footer { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; }
.hadith footer .label { font-size: .76rem; color: var(--muted); margin-right: 2px; }
.sharh-btn { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; border: 1px solid rgba(219,181,102,.35); background: rgba(219,181,102,.08); color: var(--heading); cursor: pointer; font-family: var(--ar); font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.sharh-btn .en { font-family: var(--sans); font-size: .78rem; font-weight: 600; color: var(--text); }
.sharh { margin-top: 14px; padding: 16px; border-radius: 18px; background: rgba(219,181,102,.06); border: 1px solid rgba(219,181,102,.25); }
.sharh h4 { margin: 14px 0 6px; font-family: var(--sans); font-size: .82rem; text-transform: uppercase; letter-spacing: .8px; color: var(--gold); }
.sharh h4:first-child { margin-top: 0; }
.sharh .ar { font-size: 1.25rem; line-height: 1.95; text-align: right; }
.sharh ul { margin: 6px 0; padding-left: 20px; }
.sharh ul.ar { padding: 0 20px 0 0; }
.bab { margin: 30px 0 6px; text-align: right; font-family: var(--ar); font-weight: 700; font-size: 1.35rem; color: var(--heading); }
.divider { height: 1px; margin: 22px 0; background: linear-gradient(90deg, transparent, rgba(219,181,102,.6), transparent); }
.pager { display: flex; justify-content: space-between; gap: 10px; margin: 24px 0; }
.wording { border: 1px solid rgba(219,181,102,.4); background: rgba(219,181,102,.07); border-radius: 18px; padding: 16px 18px; margin: 18px 0 -4px; }
.wording .text-ar { font-family: var(--ar); direction: rtl; text-align: right; font-size: 1.4rem; line-height: 2; }
.wording .notes { direction: rtl; text-align: right; font-family: var(--ar); font-size: 1.08rem; color: var(--muted); border-top: 1px solid rgba(219,181,102,.25); margin-top: 10px; padding-top: 8px; }
.wording .notes b { color: var(--heading); }

/* ---------- Scholar ---------- */
.profile-head { text-align: center; padding: 26px 18px; margin-top: 20px; }
.profile-head .calli { font-size: clamp(2.6rem, 9vw, 3.6rem); display: block; }
.profile-head .full { font-family: var(--ar); font-size: 1.15rem; color: var(--heading); margin: 4px 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
details.classic { margin: 12px 0; }
details.classic summary { cursor: pointer; list-style: none; padding: 14px 18px; border-radius: 18px; background: var(--card); border: 1px solid var(--hairline); display: flex; justify-content: space-between; gap: 10px; align-items: center; }
details.classic summary::-webkit-details-marker { display: none; }
details.classic[open] summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
details.classic .body { padding: 16px 20px; background: var(--card); border: 1px solid var(--hairline); border-top: 0; border-radius: 0 0 18px 18px; font-family: var(--ar); direction: rtl; text-align: right; font-size: 1.2rem; line-height: 2; max-height: 70vh; overflow: auto; }
.timeline { position: relative; margin: 20px 0; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: linear-gradient(var(--gold), rgba(219,181,102,.1)); }
.timeline .century { margin: 26px 0 10px; color: var(--gold); font-weight: 700; }
.timeline .century .heading-ar { margin-left: 8px; }
.timeline .item { position: relative; margin: 8px 0; }
.timeline .item::before { content: ""; position: absolute; left: -23px; top: 20px; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 4px rgba(219,181,102,.2); }

/* ---------- Map ---------- */
#atlas { height: calc(100vh - 220px); min-height: 460px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--hairline); }
.maplibregl-popup-content { background: var(--card-solid) !important; color: var(--text); border-radius: 14px !important; border: 1px solid var(--hairline); }
.maplibregl-popup-tip { display: none; }
.pin { border-radius: 50%; background: rgba(219,181,102,.4); border: 1.5px solid var(--gold); display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700; cursor: pointer; }

/* ---------- Footer ---------- */
.site-footer { margin: 60px 0 30px; padding-top: 24px; border-top: 1px solid var(--hairline); color: var(--muted); font-size: .86rem; }
.site-footer .cols { display: flex; flex-wrap: wrap; gap: 18px 34px; }
.site-footer a { color: var(--muted); }
.site-footer .built { margin-top: 18px; }

/* ---------- Pagefind ---------- */
#search .pagefind-ui { --pagefind-ui-scale: .95; --pagefind-ui-primary: var(--gold); --pagefind-ui-text: var(--text); --pagefind-ui-background: var(--card-solid); --pagefind-ui-border: var(--hairline); --pagefind-ui-tag: var(--chip); --pagefind-ui-border-width: 1px; --pagefind-ui-border-radius: 16px; --pagefind-ui-font: var(--sans); }
#search .pagefind-ui__result-excerpt { font-size: 1.12rem !important; unicode-bidi: plaintext; font-family: var(--ar), var(--sans); line-height: 1.9; }
#search mark { background: rgba(219,181,102,.28); color: var(--gold-light); border-radius: 4px; padding: 0 2px; }
:root[data-theme="light"] #search mark { color: #5a3f0c; }
#search .pagefind-ui__result-link { color: var(--gold); }
#search .pagefind-ui__search-input { background: var(--glass); }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%) translateY(20px); opacity: 0; transition: .3s; padding: 10px 18px; border-radius: 999px; z-index: 99; font-weight: 600; font-size: .9rem; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media print { .topbar, .tabbar, .actions, .site-footer, .sharh-btn { display: none !important; } body::before, body::after { display: none; } .hadith { break-inside: avoid; border: 1px solid #ccc; } }
