/* ==========================================================
   موقع الشيخ وائل عطية — Islamic theme
   ألوان مستوحاة من غلاف الكتاب: رقّ عتيق + ذهبي + أخضر زمردي
   ========================================================== */

:root {
  --parchment: #f6efe0;
  --parchment-2: #efe4cc;
  --paper: #fffaf0;
  --ink: #3b2a1a;
  --ink-soft: #6b5640;
  --gold: #b08a3e;
  --gold-light: #d9bf7f;
  --emerald: #1f5a46;
  --emerald-dark: #133b2e;
  --line: rgba(122, 92, 46, .22);
  --shadow: 0 10px 30px rgba(59, 42, 26, .12);
  --radius: 14px;

  --font-ar: "Amiri", "Noto Naskh Arabic", serif;
  --font-ar-head: "Aref Ruqaa", "Amiri", serif;
  --font-en: "Cormorant Garamond", Georgia, serif;
  --font-ui-en: "Inter", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --parchment: #15140f;
    --parchment-2: #1d1b14;
    --paper: #1f1d16;
    --ink: #efe6d2;
    --ink-soft: #c2b597;
    --gold: #d4b26a;
    --gold-light: #8f7440;
    --emerald: #5fae8d;
    --emerald-dark: #0d241c;
    --line: rgba(212, 178, 106, .2);
    --shadow: 0 10px 30px rgba(0, 0, 0, .4);
  }
}
:root[data-theme="dark"] {
  --parchment: #15140f;
  --parchment-2: #1d1b14;
  --paper: #1f1d16;
  --ink: #efe6d2;
  --ink-soft: #c2b597;
  --gold: #d4b26a;
  --gold-light: #8f7440;
  --emerald: #5fae8d;
  --emerald-dark: #0d241c;
  --line: rgba(212, 178, 106, .2);
  --shadow: 0 10px 30px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--font-ar);
  font-size: 19px;
  line-height: 1.9;
  -webkit-font-smoothing: antialiased;
}
html[lang="en"] body { font-family: var(--font-en); font-size: 20px; line-height: 1.7; }

/* ---- bilingual switching: <span lang="ar"> / <span lang="en"> ---- */
html[lang="ar"] [lang="en"]:not(html) { display: none !important; }
html[lang="en"] [lang="ar"]:not(html):not(.keep-ar) { display: none !important; }

a { color: var(--emerald); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

.container { width: min(1120px, 100% - 32px); margin-inline: auto; }

/* ---- geometric 8-point star pattern ---- */
.pattern {
  background-color: var(--emerald-dark);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='none' stroke='%23d9bf7f' stroke-opacity='.22' stroke-width='1'%3E%3Cpath d='M40 8l9.4 22.6L72 40l-22.6 9.4L40 72l-9.4-22.6L8 40l22.6-9.4z'/%3E%3Cpath d='M17.4 17.4h45.2v45.2H17.4z'/%3E%3Ccircle cx='40' cy='40' r='9'/%3E%3Cpath d='M0 0l17.4 17.4M80 0L62.6 17.4M0 80l17.4-17.4M80 80L62.6 62.6'/%3E%3C/g%3E%3C/svg%3E");
}

/* ================= Header ================= */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--parchment) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .bar { display: flex; align-items: center; gap: 16px; height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand .star { width: 34px; height: 34px; color: var(--gold); flex: none; }
.brand .name { font-family: var(--font-ar-head); font-size: 1.25rem; line-height: 1.2; }
html[lang="en"] .brand .name { font-family: var(--font-en); font-size: 1.3rem; }
.nav { display: flex; gap: 4px; margin-inline-start: auto; }
.nav a { color: var(--ink-soft); padding: 6px 12px; border-radius: 999px; font-size: .95rem; }
.nav a:hover, .nav a.active { background: var(--parchment-2); color: var(--ink); text-decoration: none; }
html[lang="en"] .nav a { font-family: var(--font-ui-en); font-size: .85rem; }
.tools { display: flex; gap: 8px; align-items: center; }
.btn-icon, .lang-btn {
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  border-radius: 999px; height: 38px; min-width: 38px; padding: 0 12px;
  cursor: pointer; font: inherit; font-size: .85rem; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.lang-btn { font-family: var(--font-ui-en); font-weight: 600; }
.btn-icon:hover, .lang-btn:hover { border-color: var(--gold); }
.menu-toggle { display: none; }

@media (max-width: 860px) {
  .nav {
    position: fixed; inset: 68px 0 auto 0; flex-direction: column; gap: 0;
    background: var(--paper); border-bottom: 1px solid var(--line); padding: 8px 16px 16px;
    display: none;
  }
  .nav.open { display: flex; }
  .nav a { padding: 12px; border-radius: 10px; }
  .menu-toggle { display: inline-flex; }
  .tools { margin-inline-start: auto; }
}

/* ================= Hero ================= */
.hero { position: relative; color: #f6efe0; overflow: hidden; }
.hero::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 60px;
  background: linear-gradient(to bottom, transparent, var(--parchment));
}
.hero-inner { position: relative; z-index: 1; text-align: center; padding: 72px 0 110px; }
.arch {
  width: min(640px, 100%); margin: 0 auto; padding: 64px 28px 44px;
  border: 1.5px solid rgba(217, 191, 127, .55);
  border-radius: 320px 320px 18px 18px;
  background: radial-gradient(ellipse at top, rgba(217,191,127,.12), rgba(19,59,46,.55) 70%);
  box-shadow: inset 0 0 0 8px rgba(19,59,46,.6), inset 0 0 0 9.5px rgba(217,191,127,.35);
}
.bismillah { font-family: var(--font-ar); font-size: clamp(1.6rem, 4vw, 2.3rem); color: var(--gold-light); margin: 0 0 18px; }
.hero h1 { font-family: var(--font-ar-head); font-size: clamp(2.2rem, 6vw, 3.6rem); margin: 0; line-height: 1.4; color: #fff; }
html[lang="en"] .hero h1 { font-family: var(--font-en); font-weight: 600; }
.hero .subtitle { font-size: 1.1rem; color: #e8dcc0; margin: 6px 0 26px; }
.ayah {
  display: inline-block; font-family: var(--font-ar); font-size: clamp(1.25rem, 3vw, 1.6rem);
  color: #fff; padding: 10px 18px; border-top: 1px solid rgba(217,191,127,.5); border-bottom: 1px solid rgba(217,191,127,.5);
}
.ayah small { display: block; font-size: .8rem; color: var(--gold-light); }
.ayah-en { font-family: var(--font-en); font-style: italic; color: #e8dcc0; font-size: 1.05rem; margin-top: 8px; }
.hero .cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 30px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 22px; border-radius: 999px;
  font: inherit; font-size: 1rem; cursor: pointer; border: 1px solid transparent; transition: .2s;
}
html[lang="en"] .btn { font-family: var(--font-ui-en); font-size: .9rem; font-weight: 500; }
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: #9a7731; }
.btn-ghost { border-color: rgba(217,191,127,.6); color: #f6efe0; }
.btn-ghost:hover { background: rgba(217,191,127,.12); }
.btn-outline { border-color: var(--gold); color: var(--ink); background: transparent; }
.btn-outline:hover { background: var(--parchment-2); }

/* ================= Sections ================= */
section { padding: 72px 0; }
.section-head { text-align: center; margin-bottom: 40px; }
.section-head .ornament { color: var(--gold); width: 120px; height: 20px; margin: 0 auto 8px; }
.section-head h2 { font-family: var(--font-ar-head); font-size: clamp(1.8rem, 4vw, 2.4rem); margin: 0; font-weight: 400; }
html[lang="en"] .section-head h2 { font-family: var(--font-en); font-weight: 600; }
.section-head p { color: var(--ink-soft); margin: 6px auto 0; max-width: 620px; }

.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}

/* about */
.about-grid { display: grid; grid-template-columns: 280px 1fr; gap: 40px; align-items: center; }
.portrait {
  aspect-ratio: 4/5; border-radius: 160px 160px 14px 14px; overflow: hidden;
  border: 1px solid var(--line); background: var(--parchment-2);
  display: grid; place-items: center; color: var(--gold); box-shadow: var(--shadow);
}
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.portrait svg { width: 40%; opacity: .7; }
.about-text h3 { font-family: var(--font-ar-head); font-weight: 400; font-size: 1.7rem; margin: 0 0 8px; }
html[lang="en"] .about-text h3 { font-family: var(--font-en); font-weight: 600; }
.about-text p { margin: 0 0 12px; }
.placeholder-note {
  font-size: .85rem; color: var(--ink-soft); border: 1px dashed var(--gold); border-radius: 10px; padding: 8px 12px; display: inline-block;
}
@media (max-width: 760px) { .about-grid { grid-template-columns: 1fr; } .portrait { max-width: 240px; margin: 0 auto; } }

/* book */
.book-feature { display: grid; grid-template-columns: 320px 1fr; gap: 48px; align-items: center; padding: 36px; }
.book-cover { border-radius: 6px 12px 12px 6px; box-shadow: -8px 12px 30px rgba(59,42,26,.25); transform: rotate(-1.5deg); transition: .3s; }
html[lang="en"] .book-cover { transform: rotate(1.5deg); }
.book-cover:hover { transform: rotate(0) scale(1.02); }
.book-info h3 { font-family: var(--font-ar-head); font-weight: 400; font-size: 2rem; margin: 0; line-height: 1.5; }
html[lang="en"] .book-info h3 { font-family: var(--font-en); font-weight: 600; line-height: 1.25; }
.book-info .by { color: var(--gold); margin: 4px 0 16px; }
.book-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 22px; padding: 0; list-style: none; }
.book-meta li { background: var(--parchment-2); border-radius: 999px; padding: 2px 14px; font-size: .85rem; color: var(--ink-soft); }
html[lang="en"] .book-meta li { font-family: var(--font-ui-en); font-size: .78rem; }
.book-actions { display: flex; flex-wrap: wrap; gap: 10px; }
@media (max-width: 820px) { .book-feature { grid-template-columns: 1fr; padding: 24px; } .book-cover { max-width: 240px; margin: 0 auto; } }

.topics { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 28px; }
.topic { padding: 20px; text-align: center; }
.topic .ic { width: 42px; height: 42px; margin: 0 auto 6px; color: var(--gold); }
.topic h4 { margin: 0 0 4px; font-size: 1.1rem; }
.topic p { margin: 0; font-size: .92rem; color: var(--ink-soft); line-height: 1.7; }

/* khutab */
.tabs { display: flex; justify-content: center; gap: 8px; margin-bottom: 28px; flex-wrap: wrap; }
.tab { border: 1px solid var(--line); background: var(--paper); color: var(--ink); padding: 6px 20px; border-radius: 999px; cursor: pointer; font: inherit; font-size: .95rem; }
html[lang="en"] .tab { font-family: var(--font-ui-en); font-size: .85rem; }
.tab.active { background: var(--emerald); color: #fff; border-color: var(--emerald); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.media-card { overflow: hidden; display: flex; flex-direction: column; }
.media-thumb { aspect-ratio: 16/9; background: var(--emerald-dark); position: relative; cursor: pointer; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; opacity: .9; }
.media-thumb iframe { width: 100%; height: 100%; border: 0; display: block; }
.media-thumb .play {
  position: absolute; inset: 0; margin: auto; width: 64px; height: 64px; border-radius: 50%;
  background: rgba(176,138,62,.92); display: grid; place-items: center; color: #fff;
}
.media-thumb.audio { display: grid; place-items: center; cursor: default; }
.media-thumb.audio svg { width: 54px; color: var(--gold-light); }
.media-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.media-body h4 { margin: 0; font-size: 1.1rem; line-height: 1.5; }
.media-body .meta { font-size: .82rem; color: var(--ink-soft); }
html[lang="en"] .media-body .meta { font-family: var(--font-ui-en); }
.media-body audio { width: 100%; margin-top: auto; }
.badge { display: inline-block; font-size: .75rem; padding: 0 10px; border-radius: 999px; background: var(--parchment-2); color: var(--gold); }
.empty { text-align: center; padding: 40px; color: var(--ink-soft); }

/* quote band */
.quote-band { color: #f6efe0; text-align: center; padding: 64px 0; }
.quote-band blockquote { margin: 0 auto; max-width: 760px; font-size: clamp(1.3rem, 3vw, 1.7rem); line-height: 1.9; }
.quote-band cite { display: block; font-style: normal; color: var(--gold-light); font-size: .95rem; margin-top: 10px; }

/* contact / footer */
.contact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.contact-item { padding: 22px; display: flex; gap: 14px; align-items: center; color: var(--ink); }
.contact-item:hover { text-decoration: none; border-color: var(--gold); }
.contact-item svg { width: 30px; height: 30px; color: var(--emerald); flex: none; }
.contact-item small { display: block; color: var(--ink-soft); font-size: .8rem; }

.site-footer { color: #e8dcc0; padding: 40px 0 28px; text-align: center; font-size: .9rem; }
.site-footer .dua { font-size: 1.15rem; color: var(--gold-light); margin-bottom: 10px; }

/* ================= Book reader ================= */
.reader-layout { display: grid; grid-template-columns: 300px 1fr; gap: 32px; padding: 32px 0 80px; align-items: start; }
.toc { position: sticky; top: 88px; max-height: calc(100vh - 110px); overflow: auto; padding: 18px; }
.toc h3 { margin: 0 0 8px; font-size: 1.05rem; color: var(--gold); }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li a { display: block; padding: 5px 10px; border-radius: 8px; color: var(--ink-soft); font-size: .92rem; line-height: 1.5; }
.toc li a:hover, .toc li a.active { background: var(--parchment-2); color: var(--ink); text-decoration: none; }
.toc li.sub a { padding-inline-start: 24px; font-size: .85rem; }
html[lang="en"] .toc li a { font-family: var(--font-ui-en); font-size: .82rem; }
html[lang="en"] .toc li.sub a { font-size: .78rem; }

.reader-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.reader-tools .spacer { flex: 1; }
.book-page { padding: clamp(22px, 5vw, 56px); font-size: var(--reader-size, 1.15rem); }
.book-page h1 { font-family: var(--font-ar-head); font-weight: 400; text-align: center; font-size: 2.2rem; margin: 0 0 4px; line-height: 1.5; }
html[lang="en"] .book-page h1 { font-family: var(--font-en); font-weight: 600; line-height: 1.25; }
.book-page .book-by { text-align: center; color: var(--gold); margin-bottom: 30px; }
.book-page h2 {
  font-family: var(--font-ar-head); font-weight: 400; font-size: 1.7em; text-align: center; color: var(--emerald);
  margin: 2.2em 0 .8em; padding-top: 1.2em; border-top: 1px solid var(--line); scroll-margin-top: 90px;
}
.book-page h2::before { content: "۞"; display: block; color: var(--gold); font-size: .7em; }
html[lang="en"] .book-page h2 { font-family: var(--font-en); font-weight: 600; }
.book-page h3 { font-size: 1.25em; color: var(--gold); margin: 1.6em 0 .5em; scroll-margin-top: 90px; }
html[lang="en"] .book-page h3 { font-family: var(--font-en); }
.book-page p { margin: 0 0 1em; text-align: justify; }
.book-page blockquote {
  margin: 1.2em 0; padding: .8em 1.2em; background: var(--parchment-2); border-inline-start: 4px solid var(--gold);
  border-radius: 8px; font-size: 1.05em;
}
.book-page blockquote p { margin: 0 0 .4em; text-align: start; }
.book-page blockquote p:last-child { margin: 0; }
.book-page .quran, .book-page [lang="ar"] { font-family: var(--font-ar); }
html[lang="en"] .book-page .ar-inline { font-family: var(--font-ar); font-size: 1.15em; direction: rtl; unicode-bidi: isolate; }
.book-page sup a { font-size: .75em; padding: 0 2px; }
.book-page .footnotes { margin-top: 2em; padding-top: 1em; border-top: 1px solid var(--line); font-size: .82em; color: var(--ink-soft); }
.book-page .footnotes ol { padding-inline-start: 1.4em; }
.book-page .footnotes li:target { background: var(--parchment-2); }
.book-page em { color: var(--ink-soft); }
.page-mark { display: inline-block; font-size: .7rem; color: var(--gold); opacity: .6; font-family: var(--font-ui-en); }
.reading-progress { position: fixed; top: 0; inset-inline-start: 0; height: 3px; background: var(--gold); width: 0; z-index: 60; }
.trans-note { font-size: .85rem; color: var(--ink-soft); background: var(--parchment-2); padding: 10px 14px; border-radius: 10px; margin-bottom: 24px; }
html[lang="en"] .trans-note { font-family: var(--font-ui-en); }

@media (max-width: 900px) {
  .reader-layout { grid-template-columns: 1fr; }
  .toc { position: static; max-height: 300px; }
}

/* fade-in */
.reveal { opacity: 0; transform: translateY(14px); transition: .7s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } html { scroll-behavior: auto; } }

/* view / listen counters (shown only when > 1) */
.views { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--ink-soft); }
.views[hidden] { display: none !important; }
.views svg { width: 16px; height: 16px; opacity: .8; }
html[lang="en"] .views { font-family: var(--font-ui-en); font-size: .78rem; }
.hero .views { color: var(--gold-light); margin-top: 18px; }
.book-page .views { display: flex; justify-content: center; margin: -18px 0 24px; color: var(--gold); }
.media-body .plays { margin-inline-start: 8px; }
