/* Quran Miracles: one stylesheet, light + dark */
:root {
  --bg: #fbf8f1;
  --surface: #ffffff;
  --surface-2: #f5f0e4;
  --ink: #1b2422;
  --ink-2: #33403c;
  --muted: #5f6a66;
  --line: #e7dfcc;
  --brand: #0f4c45;
  --brand-2: #17695f;
  --gold: #7f5916;
  --gold-soft: #f4ead3;
  --gold-line: #dcc58f;
  --caution: #8a4b12;
  --caution-bg: #fbf1e3;
  --note-bg: #eef5f3;
  --shadow: 0 1px 2px rgba(20, 30, 28, .05), 0 8px 24px rgba(20, 30, 28, .06);
  --radius: 14px;
  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --arabic: "Amiri Quran", "KFGQPC Uthmanic Script HAFS", "Scheherazade New", serif;
  --pattern-ink: rgba(15, 76, 69, .09);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1211; --surface: #111b19; --surface-2: #15211f; --ink: #ebe6da; --ink-2: #cfd2cb; --muted: #9ea8a3;
    --line: #233230; --brand: #6cc2b1; --brand-2: #8fd3c5; --gold: #d8b469; --gold-soft: #221d12; --gold-line: #5d4b25;
    --caution: #e7b47a; --caution-bg: #221a10; --note-bg: #12221f; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    --pattern-ink: rgba(216, 180, 105, .08); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1211; --surface: #111b19; --surface-2: #15211f; --ink: #ebe6da; --ink-2: #cfd2cb; --muted: #9ea8a3;
  --line: #233230; --brand: #6cc2b1; --brand-2: #8fd3c5; --gold: #d8b469; --gold-soft: #221d12; --gold-line: #5d4b25;
  --caution: #e7b47a; --caution-bg: #221a10; --note-bg: #12221f; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  --pattern-ink: rgba(216, 180, 105, .08); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 84px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 17px/1.7 var(--sans); text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; }
img, svg { max-width: 100%; }
a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--brand-2); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 28px; } }
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--brand); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 50; background: var(--bg); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; gap: 20px; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 600 22px/1 var(--serif); letter-spacing: .01em; white-space: nowrap; }
.logo-mark { width: 30px; height: 30px; color: var(--gold); flex: none; }
.main-nav { display: flex; gap: 4px; margin-left: auto; }
.main-nav a { color: var(--ink-2); text-decoration: none; font-size: 14.5px; font-weight: 500; padding: 8px 12px; border-radius: 999px; }
.main-nav a:hover { background: var(--surface-2); color: var(--ink); }
.main-nav a[aria-current="page"] { color: var(--brand); background: var(--gold-soft); }
.header-actions { display: flex; gap: 4px; }
.icon-btn { width: 40px; height: 40px; border: 0; background: transparent; color: var(--ink-2); border-radius: 999px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.menu-btn { display: none; }
@media (max-width: 960px) {
  .menu-btn { display: grid; }
  .header-actions { margin-left: auto; }
  .main-nav { display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; background: var(--bg); border-bottom: 1px solid var(--line); padding: 8px 16px 16px; margin: 0; }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 12px; font-size: 16px; border-radius: 10px; }
}

/* Hero & page head */
.hero, .page-head { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); background: radial-gradient(1200px 500px at 50% -10%, var(--gold-soft), transparent 70%), var(--bg); }
.hero-pattern { position: absolute; inset: 0; opacity: 1; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%23000' stroke-width='1'%3E%3Crect x='30' y='30' width='60' height='60'/%3E%3Crect x='30' y='30' width='60' height='60' transform='rotate(45 60 60)'/%3E%3Ccircle cx='60' cy='60' r='16'/%3E%3Cpath d='M0 0l30 30M120 0L90 30M0 120l30-30M120 120L90 90'/%3E%3C/g%3E%3C/svg%3E");
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 75%); mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 75%);
  filter: opacity(.08); }
:root[data-theme="dark"] .hero-pattern { filter: invert(1) opacity(.07); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero-pattern { filter: invert(1) opacity(.07); } }
.hero-inner { position: relative; text-align: center; padding: 72px 16px 56px; max-width: 900px; }
.eyebrow { font: 600 12.5px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--gold); margin: 0 0 16px; }
h1, h2, h3, h4 { font-family: var(--serif); color: var(--ink); line-height: 1.15; font-weight: 600; }
h1 { font-size: clamp(40px, 6.4vw, 72px); margin: 0 0 18px; letter-spacing: -.01em; }
.lede { font-size: clamp(17px, 2vw, 19.5px); color: var(--ink-2); max-width: 760px; margin: 0 auto 8px; }
.hero-ar { font: 400 clamp(26px, 4vw, 38px)/2 var(--arabic); color: var(--brand); margin: 32px auto 4px; max-width: 820px; }
.hero-tr { color: var(--muted); font-style: italic; font-family: var(--serif); font-size: 20px; max-width: 700px; margin: 0 auto; }
.hero-tr a { font-style: normal; font-family: var(--sans); font-size: 13px; white-space: nowrap; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 32px 0 40px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 22px; border-radius: 999px; background: var(--brand); color: #fff; border: 1px solid var(--brand); font: 600 15px/1 var(--sans); text-decoration: none; cursor: pointer; }
:root[data-theme="dark"] .btn { color: #0b1211; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn { color: #0b1211; } }
.btn:hover { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn-ghost, :root .btn-ghost { background: transparent; color: var(--brand); border-color: var(--gold-line); }
.btn-ghost:hover { background: var(--gold-soft); color: var(--brand); border-color: var(--gold); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 0 auto; max-width: 820px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.stats div { padding: 18px 12px; border-left: 1px solid var(--line); }
.stats div:first-child { border-left: 0; }
.stats dt { font: 600 32px/1 var(--serif); color: var(--brand); }
.stats dd { margin: 6px 0 0; font-size: 13px; color: var(--muted); line-height: 1.35; }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, 1fr); } .stats div:nth-child(3) { border-left: 0; } .stats div:nth-child(n+3) { border-top: 1px solid var(--line); } }
.page-head .wrap { position: relative; padding-top: 40px; padding-bottom: 44px; max-width: 900px; }
.page-head h1 { font-size: clamp(36px, 5.5vw, 60px); }
.page-head .lede { margin: 0; }
.meta { font-size: 13px; color: var(--muted); margin: 18px 0 0; }
.crumbs { font-size: 13.5px; color: var(--muted); margin-bottom: 26px; }
.crumbs a { color: var(--muted); }

/* Layout */
.layout { display: block; padding-top: 40px; padding-bottom: 72px; }
.layout.has-toc { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 56px; }
.prose-wrap { padding-top: 40px; padding-bottom: 72px; max-width: 880px; }
.prose { max-width: 780px; min-width: 0; }
.toc { position: sticky; top: 88px; align-self: start; max-height: calc(100vh - 110px); overflow: auto; font-size: 14px; }
.toc-title { font: 600 12px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); margin-bottom: 14px; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc a { display: block; padding: 6px 0 6px 14px; margin-left: -1px; border-left: 2px solid transparent; color: var(--muted); text-decoration: none; line-height: 1.4; }
.toc a:hover { color: var(--ink); }
.toc a.active { color: var(--brand); border-left-color: var(--gold); }
@media (max-width: 960px) { .layout.has-toc { display: block; } .toc { display: none; } }

.prose > section { margin: 0 0 56px; }
.prose h2 { font-size: clamp(30px, 3.6vw, 40px); margin: 0 0 18px; padding-top: 8px; }
.prose h3 { font-size: 25px; margin: 32px 0 12px; }
.prose p, .prose li { color: var(--ink-2); }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: 8px 0; }
.prose li::marker { color: var(--gold); }

.takeaways { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 26px; margin: 0 0 48px; box-shadow: var(--shadow); position: relative; }
.takeaways::before { content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 3px; background: var(--gold); border-radius: 0 3px 3px 0; }
.takeaways h2 { font-size: 15px !important; font-family: var(--sans); text-transform: uppercase; letter-spacing: .14em; color: var(--gold); margin: 0 0 8px !important; padding: 0 !important; }
.takeaways ul { margin: 0; }
.takeaways li { font-size: 16px; }

/* Verse card */
.verse { margin: 26px 0; padding: 28px 28px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); position: relative; }
.verse::before { content: ""; position: absolute; inset: 6px; border: 1px solid var(--gold-soft); border-radius: 10px; pointer-events: none; }
.verse-ar { font: 400 clamp(24px, 3.2vw, 31px)/2.15 var(--arabic); color: var(--ink); text-align: right; margin: 0 0 14px; position: relative; word-spacing: .06em; }
.ayah-no { color: var(--gold); font-size: .95em; margin: 0 .15em; white-space: nowrap; }
.verse-en { margin: 0; padding: 14px 0 0; border-top: 1px dashed var(--line); position: relative; }
.verse-en p { margin: 0; font: 500 21px/1.55 var(--serif); color: var(--ink-2); }
.verse-en sup { font: 600 11px var(--sans); color: var(--gold); margin-right: 3px; }
.verse figcaption { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; font-size: 13.5px; position: relative; flex-wrap: wrap; }
.verse figcaption a { text-decoration: none; color: var(--brand); font-weight: 500; }
.verse figcaption a:hover .surah { text-decoration: underline; }
.vref { display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: var(--gold-soft); color: var(--gold); font-weight: 600; font-variant-numeric: tabular-nums; }
.copy { border: 1px solid var(--line); background: transparent; color: var(--muted); font: 500 12.5px var(--sans); padding: 5px 12px; border-radius: 999px; cursor: pointer; }
.copy:hover { color: var(--ink); border-color: var(--gold-line); }
.copy.done { color: var(--brand); border-color: var(--brand); }
@media (max-width: 560px) { .verse { padding: 22px 18px 14px; } .verse-en p { font-size: 19px; } }

/* Hadith */
.hadith { margin: 22px 0; padding: 18px 22px; background: var(--note-bg); border-radius: var(--radius); border: 1px solid var(--line); }
.hadith-label { font: 600 11.5px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--brand); margin-bottom: 8px; }
.hadith p { margin: 0 0 10px; font: 500 19px/1.55 var(--serif); color: var(--ink); }
.hadith footer { font-size: 13px; color: var(--muted); }

/* Callouts */
.callout { margin: 26px 0; padding: 18px 22px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2); }
.callout-title { font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.callout p:last-child, .callout ol:last-child { margin-bottom: 0; }
.callout p:first-of-type { margin-top: 0; }
.callout-caution { background: var(--caution-bg); border-color: color-mix(in srgb, var(--caution) 30%, transparent); }
.callout-caution .callout-title { color: var(--caution); }
.callout-key { background: var(--gold-soft); border-color: var(--gold-line); }
.callout-key .callout-title { color: var(--gold); }
.callout-note { background: var(--note-bg); }

/* Terms */
.terms { margin: 22px 0; display: grid; gap: 10px; }
.term { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: 16px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.term dt { margin: 0; }
.term dt span { display: block; font: 400 25px/1.6 var(--arabic); color: var(--brand); text-align: left; }
.term dt em { font-size: 14px; color: var(--gold); font-weight: 500; }
.term dd { margin: 0; color: var(--ink-2); font-size: 15.5px; align-self: center; }
@media (max-width: 560px) { .term { grid-template-columns: 1fr; gap: 4px; } }

/* Lens (classical / modern / caution) */
.lens { display: grid; gap: 12px; margin: 22px 0; }
.lens-item { padding: 16px 20px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.lens-item h3 { margin: 0 0 4px; font: 600 12px/1.2 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--brand); }
.lens-item p { margin: 0; font-size: 16px; }
.lens-item:last-child:not(:first-child) { background: var(--caution-bg); border-color: color-mix(in srgb, var(--caution) 25%, transparent); }
.lens-item:last-child:not(:first-child) h3 { color: var(--caution); }

/* Timeline */
.timeline { list-style: none; padding: 0 !important; margin: 22px 0; border-left: 2px solid var(--gold-line); }
.timeline li { position: relative; padding: 0 0 18px 22px; margin: 0; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 8px; width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 2px solid var(--gold); }
.timeline time { display: block; font-weight: 600; color: var(--brand); font-size: 14px; letter-spacing: .02em; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; margin: 24px 0; }
.card { display: flex; flex-direction: column; padding: 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); box-shadow: var(--shadow); transition: transform .18s ease, border-color .18s ease; }
.card:hover { transform: translateY(-2px); border-color: var(--gold-line); color: var(--ink); }
.card-icon { width: 34px; height: 34px; fill: none; stroke: var(--gold); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 12px; }
.card h3 { margin: 0 0 6px; font-size: 24px; }
.card p { margin: 0 0 14px; font-size: 15px; color: var(--muted); flex: 1; }
.card-more { font-size: 14px; font-weight: 600; color: var(--brand); }
@media (prefers-reduced-motion: reduce) { .card { transition: none; } html { scroll-behavior: auto; } }

/* FAQ */
.faq { margin-top: 56px; }
.faq h2 a { color: inherit; text-decoration: none; }
.faq-item { border-bottom: 1px solid var(--line); }
.faq-item:first-of-type { border-top: 1px solid var(--line); }
.faq-item summary { cursor: pointer; list-style: none; padding: 16px 36px 16px 0; position: relative; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; position: absolute; right: 6px; top: 50%; transform: translateY(-50%); font-size: 24px; color: var(--gold); }
.faq-item[open] summary::after { content: "–"; }
.faq-item summary h3 { margin: 0; font-size: 21px; font-family: var(--serif); }
.faq-item p { margin: 0 0 18px; }

/* Sources & next */
.sources { border-top: 1px solid var(--line); padding-top: 28px; margin-top: 56px; }
.sources h2 { font-size: 26px !important; }
.sources li { font-size: 15px; }
.next-page { display: flex; flex-direction: column; gap: 4px; margin-top: 48px; padding: 22px 26px; border-radius: var(--radius); background: var(--gold-soft); border: 1px solid var(--gold-line); text-decoration: none; }
.next-page strong { font: 600 26px var(--serif); color: var(--brand); }

/* Verse index */
.verse-index { list-style: none; padding: 0 !important; }
.verse-index li { padding: 16px 0; border-bottom: 1px solid var(--line); }
.vi-ref { font-weight: 600; font-size: 14px; text-decoration: none; background: var(--gold-soft); color: var(--gold); padding: 2px 10px; border-radius: 999px; }
.vi-ar { font: 400 24px/2 var(--arabic); text-align: right; margin: 6px 0 2px; color: var(--ink); }
.vi-en { margin: 0; font: 500 18px/1.55 var(--serif); }
.sname { font-family: var(--arabic); font-weight: 400; color: var(--gold); float: right; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface-2); padding: 48px 0 24px; font-size: 14.5px; }
.footer-grid { display: grid; grid-template-columns: 1.2fr .8fr 1.4fr; gap: 40px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; columns: 2; }
.site-footer li { margin: 0 0 8px; }
.site-footer a { color: var(--ink-2); }
.attrib p { margin: 0 0 8px; color: var(--muted); }
.footer-base { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
@media (max-width: 860px) { .footer-grid { grid-template-columns: 1fr; gap: 24px; } }

/* Consent */
.consent { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 60; max-width: 560px; margin: 0 auto; display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 14px 16px 14px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0,0,0,.18); font-size: 14px; }
.consent[hidden] { display: none; }
.consent p { margin: 0; color: var(--ink-2); }
.consent div { display: flex; gap: 8px; flex: none; }
.consent .btn { min-height: 38px; padding: 0 16px; font-size: 14px; }
@media (max-width: 520px) { .consent { flex-direction: column; align-items: stretch; } .consent div { justify-content: flex-end; } }

@media print {
  .site-header, .site-footer, .toc, .consent, .copy, .hero-pattern, .hero-cta { display: none !important; }
  body { background: #fff; color: #000; }
  .verse, .takeaways { box-shadow: none; break-inside: avoid; }
}

/* Honorific ﷺ: system Arabic face, sized to sit on the text line */
.saw { font-family: "Geeza Pro", "Noto Naskh Arabic", "Segoe UI", Tahoma, sans-serif; font-size: 1.05em; line-height: 1; font-style: normal; font-weight: 400; }

/* Science topic groups */
.group-divider { display: flex; align-items: center; gap: 14px; margin: 72px 0 28px; font: 600 12.5px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--gold); scroll-margin-top: 84px; }
.group-divider::before, .group-divider::after { content: ""; flex: 1; height: 1px; background: var(--gold-line); }
.toc .toc-group { font: 600 11px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--gold); padding: 16px 0 6px 14px; }
.toc .toc-group:first-child { padding-top: 0; }

/* Ghost buttons keep brand-coloured text in every theme (the dark .btn rule would otherwise win) */
:root .btn.btn-ghost, :root[data-theme="dark"] .btn.btn-ghost { background: transparent; color: var(--brand); border-color: var(--gold-line); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.btn-ghost { color: var(--brand); } }
:root .btn.btn-ghost:hover { background: var(--gold-soft); color: var(--brand); border-color: var(--gold); }

/* Keep verse references like "Quran 23:12–14" on one line */
a.ref { white-space: nowrap; }

/* Corrections link: a clear, tappable row in the footer that opens WhatsApp. */
.report { display: flex; align-items: center; gap: 12px; margin-top: 28px; padding: 13px 16px; border: 1px solid var(--gold-line); border-radius: 12px; background: var(--gold-soft); color: var(--ink-2); text-decoration: none; font-size: 15px; }
.report:hover { border-color: var(--brand); }
.report > span:nth-child(2) { flex: 1; }
.report strong { color: var(--brand); }
.report-icon { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; }
