/*
VOICE   formal, scholarly, warm: an institute of Islamic learning, not a startup
IDEA    the illuminated manuscript page: generous margins, a ruled frame, a geometric border
PICTURE an arched window filled with an eight-point star lattice, the Arabic name inside it
COLOUR  from the logo: slate ink #3f4f5a, deep maroon #781417, paper white, a quiet stone band
TYPE    Marcellus (inscriptional capitals, like the logo) / Source Sans 3 / Amiri for Arabic
LAYOUT  one column on phones; bands full-width; content max 1180px
*/
:root {
  color-scheme: light;
  --ink: #26323a; --slate: #3f4f5a; --slate-2: #5d6f7b; --maroon: #781417; --maroon-2: #9a1f23;
  --paper: #ffffff; --stone: #f3f1ec; --stone-2: #e7e3da; --line: #d9d4c8; --gold: #a8833a;
  --ok: #1d6b45; --warn: #9a5b00; --bad: #a11d1d;
  --radius: 10px; --shadow: 0 1px 2px rgba(20,30,40,.06), 0 6px 20px rgba(20,30,40,.06);
  --head: 'Marcellus', 'Cinzel', 'Trajan Pro', Georgia, serif;
  --body: 'Source Sans 3', 'Segoe UI', Roboto, system-ui, sans-serif;
  --arabic: 'Amiri', 'Noto Naskh Arabic', 'Traditional Arabic', serif;
  --star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.13' stroke-width='1'%3E%3Cpath d='M32 6l7.6 18.4L58 32l-18.4 7.6L32 58l-7.6-18.4L6 32l18.4-7.6z'/%3E%3Cpath d='M13.6 13.6h36.8v36.8H13.6z' transform='rotate(45 32 32)'/%3E%3Ccircle cx='32' cy='32' r='6'/%3E%3C/g%3E%3C/svg%3E");
  --star-ink: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%233f4f5a' stroke-opacity='.08' stroke-width='1'%3E%3Cpath d='M32 6l7.6 18.4L58 32l-18.4 7.6L32 58l-7.6-18.4L6 32l18.4-7.6z'/%3E%3Cpath d='M13.6 13.6h36.8v36.8H13.6z' transform='rotate(45 32 32)'/%3E%3Ccircle cx='32' cy='32' r='6'/%3E%3C/g%3E%3C/svg%3E");
}
* { box-sizing: border-box; min-width: 0; }
html { scroll-padding-top: 84px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 17px/1.6 var(--body); overflow-x: clip; }
[hidden] { display: none !important; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--maroon); text-underline-offset: 3px; }
a:hover { color: var(--maroon-2); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--head); font-weight: 400; line-height: 1.12; color: var(--slate); text-wrap: balance; margin: 0 0 .5em; letter-spacing: .01em; }
h1 { font-size: clamp(32px, 4.6vw, 50px); }
h2 { font-size: clamp(26px, 3.2vw, 36px); }
h3 { font-size: 21px; }
p { margin: 0 0 1em; max-width: 70ch; }
.ar { font-family: var(--arabic); direction: rtl; unicode-bidi: isolate; }
.muted { color: var(--slate-2); }
.small { font-size: 14px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 max(4vw, 16px); }
.band { padding: clamp(36px, 5vw, 72px) 0; }
.band.stone { background: var(--stone); }
.band.ink { background: var(--slate) var(--star); color: #fff; }
.band.ink h2, .band.ink h3 { color: #fff; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- header ---------- */
.skip { position: absolute; left: -999px; top: 8px; background: #fff; padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
header.site { position: sticky; top: 0; z-index: 40; background: rgba(255,255,255,.96); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
header.site .wrap { display: flex; align-items: center; gap: 16px; min-height: 72px; }
.brand { display: flex; align-items: center; flex: none; }
.brand img { height: 46px; width: auto; }
nav.main { margin-left: auto; display: flex; align-items: center; gap: 2px; flex-wrap: wrap; justify-content: flex-end; }
nav.main a { color: var(--slate); text-decoration: none; padding: 8px 9px; border-radius: 6px; font-size: 15px; white-space: nowrap; }
nav.main a:hover, nav.main a[aria-current="page"] { background: var(--stone); color: var(--maroon); }
.portal-btn { margin-left: 8px; }
nav.main a.btn, nav.main a.btn:hover { color: #fff; background: var(--maroon); }
nav.main a.btn:hover { background: var(--maroon-2); }
.menu-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line); border-radius: 8px; min-height: 44px; min-width: 44px; font-size: 15px; color: var(--slate); }
@media (max-width: 1060px) {
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 12px; }
  nav.main { display: none; position: absolute; left: 0; right: 0; top: 100%; background: #fff; border-bottom: 1px solid var(--line); flex-direction: column; align-items: stretch; padding: 8px max(4vw,16px) 16px; gap: 0; }
  nav.main.open { display: flex; }
  nav.main a { padding: 12px 8px; font-size: 17px; border-bottom: 1px solid var(--stone); }
  .portal-btn { margin: 12px 0 0; text-align: center; }
  .brand img { height: 40px; }
}

/* ---------- buttons, forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: 8px; border: 1px solid transparent; font: 600 15px/1 var(--body); letter-spacing: .04em; text-transform: uppercase; text-decoration: none; cursor: pointer; background: var(--maroon); color: #fff; }
.btn:hover { background: var(--maroon-2); color: #fff; }
.btn.slate { background: var(--slate); } .btn.slate:hover { background: var(--ink); }
.btn.ghost { background: transparent; color: var(--slate); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--slate); color: var(--maroon); }
.btn.light { background: #fff; color: var(--maroon); }
.btn.wa { background: #1b7b45; } .btn.wa:hover { background: #14653a; }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 13px; }
.btn[disabled] { opacity: .6; cursor: wait; }
.btns { display: flex; flex-wrap: wrap; gap: 10px; }
form.stack { display: grid; gap: 16px; max-width: 640px; }
.field { display: grid; gap: 6px; }
.field label, .legend { font-weight: 600; font-size: 15px; color: var(--slate); }
.hint { font-size: 14px; color: var(--slate-2); }
input, select, textarea { font: 16px/1.4 var(--body); padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); width: 100%; min-height: 46px; }
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.check input { width: 22px; min-height: 22px; margin-top: 2px; flex: none; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: minmax(0,1fr); } }
.hp { position: absolute; left: -5000px; }
.notice { padding: 14px 16px; border-radius: 8px; background: var(--stone); border-left: 4px solid var(--slate); margin: 0 0 16px; }
.notice.ok { border-color: var(--ok); background: #eef7f1; }
.notice.bad { border-color: var(--bad); background: #fbefef; }
.notice.warn { border-color: var(--warn); background: #fdf5e8; }

/* ---------- hero ---------- */
.hero { background: var(--slate) var(--star); color: #fff; overflow: hidden; }
.hero .wrap { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: clamp(24px, 4vw, 56px); align-items: center; padding-top: clamp(36px, 6vw, 80px); padding-bottom: clamp(36px, 6vw, 80px); }
.hero h1 { color: #fff; }
.hero .kicker { font-family: var(--head); letter-spacing: .14em; font-size: 15px; color: #e7d9b8; margin-bottom: 14px; }
.hero p.lead { font-size: 19px; color: #e9eef1; }
.hero .btns { margin-top: 24px; }
.hero .btn.ghost { color: #fff; border-color: rgba(255,255,255,.45); }
.hero .btn.ghost:hover { border-color: #fff; color: #fff; background: rgba(255,255,255,.08); }
.arch { position: relative; aspect-ratio: 3 / 4; max-height: 520px; justify-self: center; width: min(100%, 390px); }
.arch svg { width: 100%; height: 100%; display: block; }
@media (max-width: 760px) { .hero .wrap { grid-template-columns: minmax(0,1fr); } .arch { width: min(56vw, 230px); order: -1; } }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 18px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.card h3 { margin: 0; }
.card .meta { font-size: 14px; color: var(--slate-2); }
.card .foot { margin-top: auto; padding-top: 8px; }
a.card { text-decoration: none; color: inherit; }
a.card:hover { border-color: var(--slate); }
.card.level { border-top: 5px solid var(--slate); }
.card.level.adv { border-top-color: var(--maroon); }
.card .ar-name { font-size: 24px; color: var(--maroon); }
.tag { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 4px 8px; border-radius: 999px; background: var(--stone); color: var(--slate); }
.tag.ok { background: #e2f2e8; color: var(--ok); } .tag.bad { background: #f8e3e3; color: var(--bad); } .tag.warn { background: #fbecd2; color: var(--warn); }
.thumb { aspect-ratio: 4 / 3; background: var(--stone-2) var(--star-ink); border-radius: 8px; overflow: hidden; display: grid; place-items: center; color: var(--slate-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- page head ---------- */
.pagehead { background: var(--stone) var(--star-ink); border-bottom: 1px solid var(--line); }
.pagehead .wrap { padding-top: clamp(28px, 4vw, 52px); padding-bottom: clamp(22px, 3vw, 36px); }
.pagehead .crumb { font-size: 14px; color: var(--slate-2); margin-bottom: 8px; }
.pagehead .ar { font-size: 26px; color: var(--maroon); margin: 4px 0 0; text-align: left; }

/* ---------- prose and tables ---------- */
.prose h2 { margin-top: 1.2em; } .prose ul { padding-left: 1.2em; } .prose li { margin: .3em 0; }
.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: clamp(20px, 4vw, 48px); align-items: start; }
@media (max-width: 860px) { .cols { grid-template-columns: minmax(0,1fr); } }
.aside { background: var(--stone); border-radius: var(--radius); padding: 20px; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--slate-2); font-weight: 700; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }
@media (max-width: 640px) {
  table.stack thead { display: none; }
  table.stack tr { display: grid; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.stack td { border: 0; padding: 3px 0 3px 8.5em; position: relative; text-align: left; }
  table.stack td::before { content: attr(data-l); position: absolute; left: 0; width: 8em; font-size: 13px; color: var(--slate-2); }
  table.stack td.num { text-align: left; }
}

/* ---------- steps, faq, gallery ---------- */
ol.steps { counter-reset: s; list-style: none; padding: 0; display: grid; gap: 14px; }
ol.steps li { counter-increment: s; position: relative; padding-left: 52px; min-height: 40px; }
ol.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 38px; height: 38px; border-radius: 50%; background: var(--maroon); color: #fff; display: grid; place-items: center; font-family: var(--head); font-size: 18px; }
details.faq { border-bottom: 1px solid var(--line); padding: 12px 0; }
details.faq summary { cursor: pointer; font-weight: 600; color: var(--slate); min-height: 32px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 10px; }
.gallery figure { margin: 0; }
.gallery figcaption { font-size: 14px; color: var(--slate-2); padding-top: 4px; }
.video { aspect-ratio: 16 / 9; width: 100%; border: 0; border-radius: 8px; background: #000; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.filters select { width: auto; }

/* ---------- CTA strip, footer ---------- */
.cta { background: var(--maroon); color: #fff; }
.cta .wrap { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; padding-top: 28px; padding-bottom: 28px; }
.cta h2 { color: #fff; margin: 0; font-size: clamp(22px, 2.6vw, 30px); }
footer.site { background: var(--ink) var(--star); color: #d8dee2; font-size: 15px; }
footer.site .wrap { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 28px; padding-top: 44px; padding-bottom: 28px; }
footer.site h3 { color: #fff; font-size: 18px; }
footer.site a { color: #fff; }
footer.site .logo-plate { background: #fff; border-radius: 8px; padding: 10px 12px; display: inline-block; margin-bottom: 12px; }
footer.site .logo-plate img { height: 50px; width: auto; }
footer.site ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
footer.site .base { grid-column: 1 / -1; border-top: 1px solid rgba(255,255,255,.15); padding-top: 16px; font-size: 13px; color: #aab5bc; }
@media (max-width: 760px) { footer.site .wrap { grid-template-columns: minmax(0,1fr); } }

/* ---------- portals ---------- */
.portal { background: var(--stone); min-height: 70vh; }
.portal .wrap { padding-top: 26px; padding-bottom: 48px; }
.portal-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.portal-head h1 { font-size: clamp(26px, 3vw, 36px); margin: 0; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 18px; padding-bottom: 4px; }
.tabs a { flex: none; text-decoration: none; padding: 10px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--slate); font-size: 15px; }
.tabs a[aria-current="page"] { background: var(--slate); color: #fff; border-color: var(--slate); }
.dash { display: grid; grid-template-columns: repeat(12, minmax(0,1fr)); gap: 16px; }
.dash > .card { grid-column: span 6; }
.dash > .card.wide { grid-column: 1 / -1; }
.dash > .card.third { grid-column: span 4; }
@media (max-width: 900px) { .dash > .card, .dash > .card.third { grid-column: 1 / -1; } }
.profile { display: flex; gap: 16px; align-items: center; }
.avatar { width: 84px; height: 104px; border-radius: 8px; object-fit: cover; background: var(--stone-2); flex: none; display: grid; place-items: center; font-family: var(--head); font-size: 30px; color: var(--slate); }
.kv { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 4px 14px; font-size: 15px; margin: 0; }
.kv dt { color: var(--slate-2); } .kv dd { margin: 0; font-weight: 600; }
.stat { font-family: var(--head); font-size: clamp(28px, 3vw, 38px); color: var(--slate); line-height: 1; }
.meter { height: 10px; border-radius: 99px; background: var(--stone-2); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--slate); }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--stone-2); display: flex; gap: 10px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.empty { color: var(--slate-2); font-style: italic; }
.loading { padding: 40px 0; color: var(--slate-2); text-align: center; }

/* children's section: friendly and bright, same brand */
body.theme-children .portal { background: #fff7ea; }
body.theme-children .card { border-radius: 18px; border-width: 2px; border-color: #f1d9a9; }
body.theme-children .portal-head h1 { font-family: var(--body); font-weight: 800; color: #b5541b; }
body.theme-children .stat { color: #b5541b; font-family: var(--body); font-weight: 800; }
body.theme-children .tabs a[aria-current="page"] { background: #b5541b; border-color: #b5541b; }
body.theme-children .meter i { background: #e39b2e; }
/* advanced section: scholarly */
body.theme-scholarly .portal { background: #f1efe9; }
body.theme-scholarly .card { border-top: 3px solid var(--maroon); }

/* transcript / receipt print layout */
.doc { background: #fff; max-width: 860px; margin: 0 auto; padding: 36px; border: 1px solid var(--line); }
.doc header { display: flex; justify-content: space-between; gap: 16px; align-items: center; border-bottom: 3px double var(--slate); padding-bottom: 14px; margin-bottom: 18px; }
.doc header img.logo { height: 64px; width: auto; }
.doc .addr { font-size: 13px; text-align: right; color: var(--slate-2); }
@media print {
  header.site, footer.site, .no-print, .tabs, .cta { display: none !important; }
  .portal { background: #fff; } .doc { border: 0; padding: 0; }
  body { font-size: 12pt; }
}
@media (prefers-reduced-motion: no-preference) { .fade { animation: fade .35s ease-out both; } @keyframes fade { from { opacity: 0; transform: translateY(6px); } } }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 8px; z-index: 60; max-width: 90vw; box-shadow: var(--shadow); }
.toast.bad { background: var(--bad); }
