/* Noor Garden — static pages design system ("Noor's Night Garden") */

:root {
  --bg: #F6EBD9; --surface: #FFF8EC; --surface-2: #F9EEDB;
  --ink: #2B2140; --ink-soft: #6B5E73;
  --primary: #1F7A6D; --primary-ink: #FFFFFF;
  --accent: #E8A33D; --clay: #C8553D; --garden: #5E9C4B; --lapis: #2C4A8A;
  --line: #E3CFAE; --shadow: #D9C3A0;
  --sky: #111833; --sky-ink: #F4E9D4; --glow: #FFC861;
  --answer-bg: #FFF1CF; --challenge-bg: #E9F3E2;
  --radius: 18px; --radius-sm: 12px;
  --f-quran: "Amiri Quran", "Scheherazade New", "Amiri", serif;
  --f-ar-text: "Scheherazade New", "Amiri", serif;
  --f-ar-ui: "Baloo Bhaijaan 2", "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --f-head: "Fredoka", "Baloo Bhaijaan 2", system-ui, sans-serif;
  --f-body: "Nunito", "Baloo Bhaijaan 2", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111833; --surface: #1B2547; --surface-2: #222D55;
    --ink: #F4E9D4; --ink-soft: #B9AFC9;
    --primary: #4FC1AE; --primary-ink: #0E1530;
    --accent: #FFC861; --clay: #E98A6F; --garden: #8CC976; --lapis: #8FA9E8;
    --line: #2E3A66; --shadow: #0A0F22;
    --sky: #0B1029;
    --answer-bg: #2A2A4A; --challenge-bg: #1E3341;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 500 18px/1.65 var(--f-body);
  overflow-wrap: break-word; overflow-x: hidden;
  min-height: 100vh; display: flex; flex-direction: column;
}
body > main { flex: 1 0 auto; width: 100%; }
body > header.top, body > footer.foot { flex: none; }
html[dir="rtl"] body { font-family: var(--f-ar-ui); line-height: 1.8; }
img, svg { max-width: 100%; height: auto; }
a { color: var(--primary); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--clay); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
h1, h2, h3 { font-family: var(--f-head); font-weight: 600; line-height: 1.25; margin: 0 0 .5em; color: var(--ink); }
html[dir="rtl"] :is(h1, h2, h3) { font-family: var(--f-ar-ui); font-weight: 700; line-height: 1.5; }
h1 { font-size: clamp(1.9rem, 6vw, 2.6rem); }
h2 { font-size: clamp(1.35rem, 4vw, 1.7rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
.muted { color: var(--ink-soft); }
.wrap { max-width: 900px; margin-inline: auto; padding-inline: 16px; }
main.wrap { padding-block: 8px 48px; }

/* bidi: isolate mixed-direction snippets */
[lang]:not(html) { unicode-bidi: isolate; }
:is(span, a, b, em, strong, i, cite, small)[lang] { unicode-bidi: isolate; }
html[dir="ltr"] [lang="ar"] { font-family: var(--f-ar-ui); }
html[dir="rtl"] [lang="en"] { font-family: var(--f-body); direction: ltr; }
html[dir="rtl"] p[lang="en"], html[dir="rtl"] div[lang="en"] { text-align: start; }

.skip {
  position: absolute; inset-inline-start: 8px; top: -60px; z-index: 10;
  background: var(--glow); color: #111833; padding: 10px 16px; border-radius: 10px; font-weight: 800;
}
.skip:focus { top: 8px; }

/* ---------- header (night sky) ---------- */
header.top { background: var(--sky); color: var(--sky-ink); border-block-end: 3px solid var(--accent); }
header.top .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; padding-block: 10px; }
.brand {
  display: inline-flex; align-items: center; gap: 10px; color: var(--sky-ink); text-decoration: none;
  font: 600 1.3rem/1 var(--f-head); white-space: nowrap;
}
html[dir="rtl"] .brand { font-family: var(--f-ar-ui); font-weight: 700; }
.brand img { filter: drop-shadow(0 0 6px rgba(255, 200, 97, .55)); }
.brand:hover { color: var(--glow); }
.nav { display: flex; flex-wrap: wrap; gap: 2px 4px; align-items: center; }
.nav a {
  color: var(--sky-ink); text-decoration: none; font-weight: 700; font-size: .95rem;
  padding: 8px 10px; border-radius: 999px; min-height: 40px; display: inline-flex; align-items: center;
}
.nav a:hover { background: rgba(244, 233, 212, .1); color: var(--glow); }
.nav a.lang { border: 2px solid var(--glow); color: var(--glow); padding-block: 4px; margin-inline-start: 4px; }
.nav a.lang:hover { background: var(--glow); color: #111833; }
.nav a.lang[lang="ar"] { font-family: var(--f-ar-ui); }
.nav a.lang[lang="en"] { font-family: var(--f-body); }

/* ---------- breadcrumbs ---------- */
nav.crumbs { margin-block: 14px 6px; font-size: .9rem; color: var(--ink-soft); }
nav.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px 0; }
nav.crumbs li { display: inline-flex; align-items: center; }
nav.crumbs li + li::before { content: "/"; margin-inline: 8px; color: var(--line); font-weight: 800; }
nav.crumbs a { color: var(--ink-soft); }
nav.crumbs a:hover { color: var(--primary); }
nav.crumbs li:last-child { color: var(--ink); font-weight: 700; }

/* ---------- hero ---------- */
.hero {
  position: relative; text-align: center; margin-block: 12px 22px; padding: 34px 18px 26px;
  background: var(--surface); border: 2px solid var(--line); border-radius: 160px 160px var(--radius) var(--radius);
  box-shadow: 0 5px 0 var(--shadow); overflow: hidden; isolation: isolate;
}
.hero::before { /* lantern glow */
  content: ""; position: absolute; z-index: -1; inset-inline: 0; top: -60px; margin-inline: auto;
  width: 260px; height: 200px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 200, 97, .45), rgba(255, 200, 97, 0));
}
.hero h1 { margin-block-end: .25em; }
.hero .sub { color: var(--ink-soft); font-size: 1.05rem; margin: 0 auto; max-width: 60ch; }
.hero .ar-title {
  font-family: var(--f-quran); font-size: clamp(2.4rem, 10vw, 3.4rem); line-height: 1.6;
  color: var(--primary); margin: 0 0 .1em; direction: rtl;
}
.hero .cta { margin-block: 18px 0; }

/* ---------- answer / lead / blocks ---------- */
.answer {
  background: var(--answer-bg); border: 2px solid var(--accent); border-inline-start-width: 8px;
  border-radius: var(--radius); padding: 16px 18px; margin-block: 0 22px; font-size: 1.05rem;
  box-shadow: 0 5px 0 var(--shadow);
}
.answer > :last-child { margin-block-end: 0; }
.answer strong:first-child { color: var(--clay); }
.lead { font-size: 1.2rem; line-height: 1.6; }

section.block {
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 20px 18px; margin-block: 0 22px; box-shadow: 0 5px 0 var(--shadow);
}
section.block > h2 { display: flex; align-items: center; gap: 10px; }
section.block > h2::before {
  content: ""; flex: none; width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px rgba(232, 163, 61, .22);
}
section.block > :last-child { margin-block-end: 0; }

/* ---------- start button ---------- */
.cta { margin-block: 8px 24px; text-align: center; }
.btn-start {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  min-height: 56px; padding: 12px 28px; border-radius: 999px; max-width: 100%;
  background: var(--primary); color: var(--primary-ink); text-decoration: none;
  font: 600 1.2rem/1.2 var(--f-head); box-shadow: 0 5px 0 #13544B;
  transition: transform .12s ease, box-shadow .12s ease;
}
html[dir="rtl"] .btn-start { font-family: var(--f-ar-ui); font-weight: 700; }
@media (prefers-color-scheme: dark) { .btn-start { box-shadow: 0 5px 0 #237062; } }
.btn-start:hover { color: var(--primary-ink); transform: translateY(-2px); box-shadow: 0 7px 0 #13544B; }
.btn-start:active { transform: translateY(4px); box-shadow: 0 1px 0 #13544B; }
.btn-start .play {
  width: 0; height: 0; border-block: 9px solid transparent; border-inline-start: 14px solid currentColor;
}
.btn-start:focus-visible { outline-color: var(--accent); outline-offset: 4px; border-radius: 999px; }

/* ---------- Quran text ---------- */
.qtext, .basmala {
  font-family: var(--f-quran); direction: rtl; text-align: right;
  font-size: clamp(30px, 7vw, 40px); line-height: 2.2; font-weight: 400; color: var(--ink);
}
.basmala {
  text-align: center; margin: 0 0 18px; padding: 8px 12px; color: var(--primary);
  border-block: 2px dashed var(--line);
}
.ayat { list-style: none; margin: 0 0 22px; padding: 0; display: grid; gap: 16px; }
.ayah {
  position: relative; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px 16px; box-shadow: 0 5px 0 var(--shadow);
}
.ayah .num {
  display: inline-grid; place-items: center; min-width: 38px; height: 38px; padding-inline: 6px;
  border-radius: 50%; background: var(--surface-2); border: 2px solid var(--accent); color: var(--ink);
  font: 700 .95rem/1 var(--f-body); float: inline-end; margin-inline-start: 10px;
}
html[dir="rtl"] .ayah .num { font-family: var(--f-ar-ui); }
.ayah .qtext { margin: 0 0 6px; clear: none; }
.ayah .tr { margin: 0; color: var(--ink-soft); clear: both; padding-block-start: 8px; border-block-start: 1px dashed var(--line); }
.ayah .tr + .tr { border: 0; padding-block-start: 4px; }
.ayah .tr[lang="ar"] { font-family: var(--f-ar-ui); }

/* ---------- word by word ---------- */
.wbw-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch; margin-block: 0 22px; max-width: 100%;
  border: 2px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
  box-shadow: 0 5px 0 var(--shadow);
}
table.wbw { border-collapse: collapse; width: 100%; min-width: 420px; font-size: 1rem; }
table.wbw th, table.wbw td { padding: 10px 12px; border-block-end: 1px solid var(--line); text-align: start; vertical-align: middle; }
table.wbw th { background: var(--surface-2); font-family: var(--f-head); font-weight: 600; color: var(--ink-soft); font-size: .9rem; white-space: nowrap; }
html[dir="rtl"] table.wbw th { font-family: var(--f-ar-ui); }
table.wbw tr:last-child td { border-block-end: 0; }
table.wbw td.ar { font-family: var(--f-quran); font-size: 1.8rem; line-height: 1.9; direction: rtl; text-align: right; color: var(--primary); white-space: nowrap; }

/* ---------- facts / steps ---------- */
dl.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 22px; }
dl.facts > div, dl.facts dt { margin: 0; }
dl.facts > div { background: var(--surface-2); border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px; }
dl.facts dt { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); font-weight: 800; }
html[dir="rtl"] dl.facts dt { text-transform: none; letter-spacing: 0; font-size: .9rem; }
dl.facts dd { margin: 2px 0 0; font: 600 1.15rem/1.35 var(--f-head); color: var(--ink); }
html[dir="rtl"] dl.facts dd { font-family: var(--f-ar-ui); font-weight: 700; }
/* plain dt/dd pairs without wrappers */
dl.facts:not(:has(> div)) { grid-template-columns: max-content 1fr; gap: 8px 16px; background: var(--surface-2); border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; }

ol.steps { list-style: none; counter-reset: step; margin: 0 0 22px; padding: 0; display: grid; gap: 12px; }
ol.steps > li {
  counter-increment: step; position: relative; padding-inline-start: 56px; min-height: 42px;
  padding-block: 6px;
}
ol.steps > li::before {
  content: counter(step); position: absolute; inset-inline-start: 0; top: 0;
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #2B2140; font: 600 1.15rem/1 var(--f-head); box-shadow: 0 3px 0 var(--shadow);
}
html[dir="rtl"] ol.steps > li::before { content: counter(step, arabic-indic); font-family: var(--f-ar-ui); }

/* ---------- FAQ ---------- */
.faq { display: grid; gap: 10px; margin-block: 0 22px; }
.faq details { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius-sm); box-shadow: 0 4px 0 var(--shadow); }
.faq summary {
  cursor: pointer; list-style: none; padding: 14px 16px; font-weight: 800; display: flex; gap: 12px;
  justify-content: space-between; align-items: center; min-height: 52px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); color: var(--primary); font: 700 1.3rem/1 var(--f-head);
}
.faq details[open] summary::after { content: "\2212"; }
.faq details[open] summary { border-block-end: 1px dashed var(--line); }
.faq details > div { padding: 12px 16px 14px; }
.faq details > div > :last-child { margin-block-end: 0; }

/* ---------- hub cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 14px; margin-block: 0 24px; }
a.card {
  position: relative; display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 14px 16px 12px;
  box-shadow: 0 5px 0 var(--shadow); transition: transform .12s ease, box-shadow .12s ease, border-color .12s;
}
a.card:hover { color: var(--ink); border-color: var(--accent); transform: translateY(-3px); box-shadow: 0 8px 0 var(--shadow); }
a.card:has(.badge) .t { padding-inline-end: 56px; }
a.card .t { font: 600 1.1rem/1.3 var(--f-head); }
html[dir="rtl"] a.card .t { font-family: var(--f-ar-ui); font-weight: 700; }
a.card .ar { font-family: var(--f-quran); font-size: 1.7rem; line-height: 1.7; color: var(--primary); direction: rtl; }
a.card .m { font-size: .88rem; color: var(--ink-soft); margin-block-start: auto; }
a.card .badge {
  position: absolute; top: 10px; inset-inline-end: 10px; background: var(--accent); color: #2B2140;
  font: 800 .75rem/1 var(--f-body); padding: 5px 9px; border-radius: 999px;
}
html[dir="rtl"] a.card .badge { font-family: var(--f-ar-ui); }

/* ---------- prev / next ---------- */
.prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-block: 8px 24px; }
.prevnext a {
  display: block; padding: 12px 16px; min-height: 56px; border-radius: var(--radius-sm); text-decoration: none;
  background: var(--surface); border: 2px solid var(--line); box-shadow: 0 4px 0 var(--shadow); font-weight: 800; color: var(--primary);
}
.prevnext a:hover { border-color: var(--primary); }
.prevnext a.prev::before { content: "\2190\00a0"; }
.prevnext a.next { text-align: end; grid-column: 2; }
.prevnext a.next::after { content: "\00a0\2192"; }
html[dir="rtl"] .prevnext a.prev::before { content: "\2192\00a0"; }
html[dir="rtl"] .prevnext a.next::after { content: "\00a0\2190"; }

/* ---------- meta lines ---------- */
.reviewed, .src { font-size: .88rem; color: var(--ink-soft); margin-block: 6px; }
.src { border-inline-start: 3px solid var(--line); padding-inline-start: 10px; }
.reviewed time { font-weight: 700; }

/* ---------- hadith ---------- */
blockquote.hadith-ar {
  font-family: var(--f-ar-text); direction: rtl; text-align: center; font-size: clamp(26px, 6vw, 34px); line-height: 2;
  margin: 0 0 14px; padding: 22px 18px; background: var(--surface); color: var(--ink);
  border: 2px solid var(--line); border-radius: var(--radius); box-shadow: 0 5px 0 var(--shadow);
  border-block-start: 6px solid var(--garden);
}
p.hadith-en { font-size: 1.12rem; font-style: italic; text-align: center; color: var(--ink); max-width: 62ch; margin-inline: auto; }
html[dir="rtl"] p.hadith-en { font-style: normal; }

/* ---------- quiz / challenge ---------- */
.quiz, .challenge {
  border-radius: var(--radius); padding: 18px; margin-block: 0 22px; box-shadow: 0 5px 0 var(--shadow);
}
.quiz { background: var(--surface); border: 2px solid var(--lapis); }
.quiz > :last-child, .challenge > :last-child { margin-block-end: 0; }
.quiz ol { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; counter-reset: opt; }
.quiz ol > li {
  counter-increment: opt; background: var(--surface-2); border: 2px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 14px; display: flex; gap: 10px; align-items: baseline;
}
.quiz ol > li::before { content: counter(opt, upper-alpha); font: 600 1rem/1 var(--f-head); color: var(--lapis); flex: none; }
html[dir="rtl"] .quiz ol > li::before { content: counter(opt, arabic-indic); font-family: var(--f-ar-ui); }
.quiz details summary { cursor: pointer; font-weight: 800; color: var(--lapis); min-height: 44px; display: inline-flex; align-items: center; }
.quiz details[open] > :not(summary) { background: var(--challenge-bg); border-radius: var(--radius-sm); padding: 10px 14px; margin: 6px 0 0; }
.challenge { background: var(--challenge-bg); border: 2px dashed var(--garden); border-inline-start: 8px solid var(--garden); }
.challenge h2, .challenge h3 { color: var(--garden); }

/* ---------- guide prose ---------- */
article.guide { max-width: 68ch; margin-inline: auto; }
article.guide h2 { margin-block-start: 1.4em; }
article.guide ul, article.guide ol:not(.steps) { padding-inline-start: 1.4em; }
article.guide li { margin-block-end: .4em; }
article.guide blockquote:not(.hadith-ar) { margin: 0 0 1em; padding: 10px 16px; border-inline-start: 4px solid var(--accent); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
html[dir="rtl"] article.guide blockquote:not(.hadith-ar) { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }

/* ---------- footer ---------- */
footer.foot { background: var(--sky); color: var(--sky-ink); padding-block: 28px 36px; margin-block-start: 24px; border-block-start: 3px solid var(--accent); font-size: .95rem; text-align: center; }
footer.foot p { margin: 0 0 12px; }
footer.foot .links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 6px; }
footer.foot .links a { color: var(--glow); font-weight: 700; padding: 6px 10px; text-decoration: none; border-radius: 999px; }
footer.foot .links a:hover { background: rgba(255, 200, 97, .12); }
footer.foot .credits { font-size: .82rem; opacity: .8; margin: 0; }

/* ---------- larger screens ---------- */
@media (min-width: 640px) {
  .hero { padding: 48px 32px 32px; }
  section.block { padding: 24px 26px; }
  .ayah { padding: 16px 24px 18px; }
}
@media (max-width: 420px) {
  .prevnext { grid-template-columns: 1fr; }
  .prevnext a.next { grid-column: auto; }
  .nav a { padding-inline: 8px; font-size: .9rem; }
}

/* ---------- motion / print ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  a.card:hover, .btn-start:hover { transform: none; }
}
@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #fff; --ink: #000; --ink-soft: #333; --line: #bbb; --shadow: transparent; }
  header.top .nav, .skip, .cta, .prevnext, nav.crumbs { display: none !important; }
  header.top, footer.foot { background: none; color: #000; border: 0; }
  .brand { color: #000; }
  .hero::before { display: none; }
  .hero, section.block, .ayah, .answer, .quiz, .challenge, a.card, blockquote.hadith-ar, .faq details { box-shadow: none; break-inside: avoid; }
  .faq details > div { display: block !important; }
  a { color: #000; }
  .wbw-wrap { overflow: visible; }
}
