/* ===== الخطوط (مستضافة محلياً — رخصة OFL) ===== */
@font-face {
  font-family: "Amiri Quran";
  src: url("../fonts/AmiriQuran.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "Amiri";
  src: url("../fonts/Amiri-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Amiri";
  src: url("../fonts/Amiri-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

/* ===== الألوان: ورق المصحف، حبر، لازورد، ذهب التذهيب ===== */
:root {
  --paper: #FAFAF7;
  --ink: #1D1C1A;
  --muted: #64625A;
  --rule: #E2DFD5;
  --tint: #EEF3F2;
  --lapis: #1F4E5F;
  --gold: #A5803A;
  --hl: rgba(165, 128, 58, .17);
  --read: 44rem;
  --wide: 70rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111615;
    --ink: #E8E6DF;
    --muted: #A09E95;
    --rule: #2A3331;
    --tint: #18211F;
    --lapis: #8CBBC9;
    --gold: #C9A45C;
    --hl: rgba(201, 164, 92, .2);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5rem; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Amiri", "Noto Naskh Arabic", "Traditional Arabic", serif;
  font-size: 1.15rem;
  line-height: 1.9;
}
a { color: var(--lapis); text-underline-offset: .25em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--lapis); outline-offset: 3px; border-radius: 2px; }
h1, h2 { font-weight: 700; line-height: 1.4; margin: 0; }

.wrap { max-width: var(--wide); margin-inline: auto; padding-inline: 1.25rem; }
.wrap--read { max-width: var(--read); }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .95rem; }
.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; inset-inline-start: 1rem; top: -4rem; background: var(--lapis); color: var(--paper); padding: .4rem 1rem; z-index: 10; }
.skip:focus { top: .5rem; }

/* ===== نص القرآن: لا تباعد حروف ولا تحويلات — الخط وحده يرسم ===== */
.quran {
  font-family: "Amiri Quran", "Amiri", serif;
  letter-spacing: normal;
  word-spacing: normal;
  font-feature-settings: normal;
  text-transform: none;
}
.mushaf {
  font-size: clamp(1.55rem, 1.05rem + 1.6vw, 2.15rem);
  line-height: 2.5;
  text-align: justify;
  text-align-last: center;
  margin: 1.5rem 0 2rem;
}
.mushaf--single { text-align: center; font-size: clamp(1.8rem, 1.2rem + 2vw, 2.6rem); }
.ayah { border-radius: .3rem; box-decoration-break: clone; -webkit-box-decoration-break: clone; transition: background-color .25s; }
.ayah.is-playing { background: var(--hl); }
.am { color: var(--gold); text-decoration: none; white-space: nowrap; font-family: "Amiri Quran", "Amiri", serif; }
a.am:hover { color: var(--lapis); }
.basmala { text-align: center; font-size: clamp(1.6rem, 1.1rem + 1.6vw, 2.2rem); margin: 1.25rem 0 0; line-height: 2.2; }

/* ===== الرأس ===== */
.site-head { border-bottom: 1px solid var(--rule); }
.site-head__in { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 4rem; flex-wrap: wrap; }
.brand { font-size: 1.6rem; font-weight: 700; color: var(--lapis); text-decoration: none; }
.nav { display: flex; gap: 1.5rem; list-style: none; margin: 0; padding: 0; }
.nav a { color: var(--ink); text-decoration: none; }
.nav a:hover { color: var(--lapis); }

/* ===== الصفحة الرئيسية ===== */
.hero { padding: 3.5rem 0 2.5rem; text-align: center; background: var(--tint); border-bottom: 1px solid var(--rule); }
.hero__basmala { font-size: clamp(2rem, 1.2rem + 3vw, 3.4rem); line-height: 2; margin: 0 0 1.5rem; color: var(--lapis); }
.search { display: flex; gap: .5rem; max-width: 34rem; margin-inline: auto; }
.search input {
  flex: 1; min-width: 0; font: inherit; padding: .55rem 1rem;
  border: 1px solid var(--rule); border-radius: .5rem; background: var(--paper); color: var(--ink);
}
.search input:focus { border-color: var(--lapis); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--lapis) 25%, transparent); }
.search button, .btn {
  font: inherit; padding: .45rem 1.3rem; border-radius: .5rem; cursor: pointer;
  border: 1px solid var(--lapis); background: var(--lapis); color: var(--paper);
}
.btn { background: transparent; color: var(--lapis); padding: .25rem 1rem; }
.btn:hover { background: var(--tint); }
.resume { margin: 1.25rem 0 0; }

.block { padding-block: 3rem 1rem; }
.block__title { font-size: 1.7rem; margin-bottom: 1.25rem; padding-bottom: .5rem; border-bottom: 1px solid var(--rule); }

.surah-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(16.5rem, 1fr)); column-gap: 2rem; }
.surah-list a {
  display: grid; grid-template-columns: 2.6rem 1fr; grid-template-rows: auto auto; column-gap: .9rem;
  align-items: center; padding: .7rem .25rem; border-bottom: 1px solid var(--rule);
  color: var(--ink); text-decoration: none;
}
.surah-list a:hover .surah-list__name { color: var(--lapis); }
.surah-list .num { grid-row: 1 / 3; }
.surah-list__name { font-size: 1.3rem; font-weight: 700; line-height: 1.5; }
.surah-list__meta { font-size: .95rem; color: var(--muted); line-height: 1.4; }

/* رقم السورة داخل معيّن مذهّب */
.num { display: grid; place-items: center; width: 2.3rem; height: 2.3rem; position: relative; font-size: .95rem; color: var(--gold); }
.num::before { content: ""; position: absolute; inset: .3rem; border: 1px solid var(--gold); transform: rotate(45deg); }
.num span { position: relative; }

.juz-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .75rem; }
.juz-list a { display: block; padding: .6rem .9rem; border: 1px solid var(--rule); border-radius: .5rem; text-decoration: none; color: var(--ink); line-height: 1.5; }
.juz-list a:hover { border-color: var(--gold); }
.juz-list__n { display: block; font-weight: 700; color: var(--lapis); }
.juz-list__from { font-size: .9rem; color: var(--muted); }

/* ===== إطار اسم السورة (العنصر المميّز) ===== */
.cartouche {
  position: relative; text-align: center; margin: 2.5rem 1.4rem 1rem;
  padding: 1rem 2.5rem .8rem;
  border: 1px solid var(--gold); outline: 1px solid var(--gold); outline-offset: 5px;
  border-radius: 3rem;
}
.cartouche::before, .cartouche::after {
  content: ""; position: absolute; top: 50%; width: .9rem; height: .9rem;
  background: var(--paper); border: 1px solid var(--gold); transform: translateY(-50%) rotate(45deg);
}
.cartouche::before { inset-inline-start: -1.05rem; }
.cartouche::after { inset-inline-end: -1.05rem; }
.cartouche h1, .cartouche h2 { font-size: clamp(1.8rem, 1.3rem + 1.6vw, 2.5rem); color: var(--lapis); }
.cartouche h2 a { color: inherit; text-decoration: none; }
.cartouche--sm { margin-top: 2rem; padding-block: .6rem .5rem; }
.cartouche--sm h2 { font-size: 1.7rem; }
.cartouche__meta, .ayah-head__meta, .page-head__meta { margin: .2rem 0 0; color: var(--muted); font-size: 1rem; display: flex; justify-content: center; flex-wrap: wrap; gap: .25rem 1.25rem; }

.ayah-head, .page-head { text-align: center; margin-top: 1.5rem; }
.ayah-head h1, .page-head h1, .page-title { font-size: clamp(1.6rem, 1.2rem + 1.2vw, 2.1rem); color: var(--lapis); }
.page-title { margin: 2rem 0 1rem; }

/* ===== المشغّل ===== */
.player {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; flex-wrap: wrap; gap: .5rem 1rem;
  padding: .6rem .25rem; margin-top: 1rem;
  background: var(--paper); border-bottom: 1px solid var(--rule);
}
.player__play { font: inherit; min-width: 6rem; padding: .3rem 1rem; border-radius: 2rem; border: 1px solid var(--lapis); background: var(--lapis); color: var(--paper); cursor: pointer; }
.player__play[aria-pressed="true"] { background: transparent; color: var(--lapis); }
.player__reciter { font: inherit; font-size: 1rem; padding: .25rem .5rem; border: 1px solid var(--rule); border-radius: .4rem; background: var(--paper); color: var(--ink); max-width: 100%; }
.player__repeat { font-size: 1rem; color: var(--muted); display: inline-flex; gap: .35rem; align-items: center; cursor: pointer; }
.player__status { font-size: .95rem; color: #B42318; }

/* ===== التنقل ===== */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 1rem 0 3rem; border-top: 1px solid var(--rule); }
.pager__jump { display: flex; gap: .4rem; align-items: center; }
.pager__jump input { width: 5rem; font: inherit; font-size: 1rem; padding: .2rem .4rem; border: 1px solid var(--rule); border-radius: .4rem; background: var(--paper); color: var(--ink); text-align: center; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; margin: 1.25rem 0 0; padding: 0; font-size: 1rem; color: var(--muted); }
.crumbs li + li::before { content: "‹"; margin-inline-end: .4rem; color: var(--rule); }
.note { font-size: .95rem; color: var(--muted); text-align: center; }
.tools { text-align: center; margin: 0 0 1.5rem; }

/* ===== التفسير ===== */
.tafsir { border-top: 3px double var(--gold); padding: 1.5rem 0 3rem; }
.tafsir h2 { font-size: 1.6rem; margin-bottom: 1rem; }
.tabs { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1.25rem; padding: 0; }
.tabs a { display: block; padding: .15rem 1rem; border: 1px solid var(--rule); border-radius: 2rem; text-decoration: none; color: var(--ink); font-size: 1.05rem; }
.tabs a[aria-current] { background: var(--lapis); border-color: var(--lapis); color: var(--paper); }
.tafsir__text { font-size: 1.25rem; line-height: 2.1; text-align: justify; }
.tafsir__range { color: var(--gold); font-size: 1rem; margin: 0 0 .5rem; }
.tafsir__src { color: var(--muted); font-size: .95rem; margin-top: 1rem; }

/* ===== البحث ===== */
.results { list-style: none; margin: 0; padding: 0; }
.results li { padding: 1rem 0; border-bottom: 1px solid var(--rule); }
.results__text { font-size: 1.6rem; line-height: 2.3; margin: 0; }
.results-count, .empty { margin-top: 1.5rem; }

.ok { color: #1E7B4A; } .bad { color: #B42318; }
.checks { list-style: none; padding: 0; }
.detail { background: var(--tint); padding: 1rem; overflow-x: auto; font-size: .9rem; text-align: left; }

/* ===== التذييل ===== */
.site-foot { border-top: 1px solid var(--rule); margin-top: 2rem; padding: 1.5rem 0 2.5rem; color: var(--muted); font-size: .95rem; }
.site-foot p { margin: .25rem 0; }

@media (max-width: 40rem) {
  .nav { gap: 1rem; font-size: 1.05rem; }
  .cartouche { padding-inline: 1.25rem; margin-inline: 1rem; }
  .mushaf { text-align: right; text-align-last: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .ayah { transition: none; }
}
@media print {
  .site-head, .site-foot, .player, .pager, .tools, .tabs { display: none; }
}

/* ===== ركن الأطفال ===== */
.kids-hero { background: var(--tint); border-bottom: 1px solid var(--rule); padding: 2.5rem 0 2rem; text-align: center; }
.kids-hero h1 { font-size: clamp(2rem, 1.4rem + 2vw, 2.8rem); color: var(--lapis); }
.kids-hero p { margin: .5rem 0 0; font-size: 1.25rem; }
.kids-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .9rem; }
.kids-list a {
  display: grid; gap: .1rem; padding: 1rem 1.1rem; min-height: 5.5rem;
  border: 2px solid var(--rule); border-radius: 1.2rem; text-decoration: none; color: var(--ink);
}
.kids-list a:hover { border-color: var(--gold); }
.kids-list__name { font-size: 1.45rem; font-weight: 700; color: var(--lapis); }
.kids-list__meta { color: var(--muted); font-size: 1rem; }
.kids-list__badge { color: var(--gold); font-size: 1rem; font-weight: 700; }

.kids { --guide: #DCE3E6; --guide-edge: #98A6AE; padding-bottom: 2rem; }
@media (prefers-color-scheme: dark) { .kids { --guide: #26312F; --guide-edge: #5E6E6A; } }
.kids__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.25rem; }
.kids__head h1 { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.2rem); color: var(--lapis); }
.kids__back { font-size: 1.05rem; }
.kids__stars { font-size: 1.4rem; font-weight: 700; color: var(--gold); white-space: nowrap; }
.kids__where { text-align: center; color: var(--muted); margin: .75rem 0 0; font-size: 1.05rem; }
.kids__line { text-align: center; font-size: clamp(1.35rem, 1rem + 1.2vw, 1.8rem); line-height: 2.3; margin: .25rem 0 .75rem; }
.kids__line .is-current { background: var(--hl); border-radius: .35rem; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.kids__line .is-done { color: var(--lapis); }
.kids__board {
  position: relative; width: 100%; height: clamp(230px, 46vh, 430px);
  border: 2px dashed var(--rule); border-radius: 1.4rem; background: var(--paper); overflow: hidden;
}
.kids__board canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.kids__draw { touch-action: none; cursor: crosshair; }
.kids__guide { transition: opacity .8s; }
.kids__guide.is-faded { opacity: .07; }
.kids__cheer {
  position: absolute; bottom: .4rem; inset-inline: 0; margin: 0; text-align: center;
  font-size: 1.8rem; font-weight: 700; color: var(--gold); pointer-events: none;
}
.kids__meter { height: .6rem; background: var(--tint); border-radius: 1rem; margin-top: .75rem; overflow: hidden; }
.kids__meter span { display: block; height: 100%; width: 0; background: var(--gold); border-radius: 1rem; transition: width .2s; }
.kids__hint { min-height: 1.9rem; margin: .4rem 0 0; text-align: center; color: #B45309; font-size: 1.1rem; }
.kids__tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-top: .5rem; }
.kids__colors { display: flex; gap: .5rem; flex-wrap: wrap; }
.kids__colors button { width: 2.8rem; height: 2.8rem; border-radius: 50%; border: 3px solid var(--paper); box-shadow: 0 0 0 2px var(--rule); cursor: pointer; }
.kids__colors button[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--ink); }
.kids__actions, .kids__nav { display: flex; gap: .5rem; flex-wrap: wrap; }
.kids__nav { justify-content: space-between; margin-top: 1rem; }
.kbtn {
  font: inherit; font-size: 1.15rem; min-height: 2.9rem; padding: .3rem 1.2rem; cursor: pointer;
  border-radius: 1.5rem; border: 2px solid var(--lapis); background: var(--paper); color: var(--lapis);
}
.kbtn--main { background: var(--lapis); color: var(--paper); }
.kbtn--ghost { border-color: var(--rule); color: var(--muted); font-size: 1rem; }
.kids__level { border: 1px solid var(--rule); border-radius: 1rem; margin: 1.5rem 0 0; padding: .5rem 1rem .75rem; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; }
.kids__level legend { padding: 0 .4rem; color: var(--muted); font-size: 1rem; }
.kids__level label { display: inline-flex; gap: .4rem; align-items: center; font-size: 1.1rem; cursor: pointer; }
.kids__panel {
  position: fixed; inset-inline: 1rem; bottom: 1rem; z-index: 20; max-width: 30rem; margin-inline: auto;
  background: var(--paper); border: 2px solid var(--gold); border-radius: 1.4rem; padding: 1rem 1.25rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .15); text-align: center;
}
.kids__panel-title { font-size: 1.4rem; font-weight: 700; color: var(--lapis); margin: 0 0 .75rem; }
.kids__panel-actions { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }
@media (prefers-reduced-motion: reduce) { .kids__guide, .kids__meter span { transition: none; } }

/* ===== صفحة التثبيت ===== */
.install__big { font-size: 1.35rem; font-weight: 700; }
.install__steps { padding-inline-start: 1.25rem; }
.install__steps code, .install code { background: var(--tint); padding: 0 .35rem; border-radius: .3rem; font-size: .95rem; }
.install__form { display: grid; gap: 1rem; margin: 1.5rem 0 3rem; padding: 1.25rem; border: 1px solid var(--rule); border-radius: .8rem; }
.install__file { display: grid; gap: .35rem; }
.install__file input { font: inherit; font-size: 1rem; }
.install__submit { font: inherit; font-size: 1.2rem; padding: .5rem 1.5rem; border-radius: .6rem; border: 0; background: var(--lapis); color: var(--paper); cursor: pointer; justify-self: start; }
.install__error { border: 1px solid #F1C0BA; background: color-mix(in srgb, #B42318 6%, var(--paper)); padding: .5rem 1rem; border-radius: .6rem; }
.install__msg { white-space: pre-line; }
