/*
 * Base: reset, typography, layout primitives, Arabic setting, ornaments, reveal + split-text system,
 * focus handling and screen transitions. Shared by the website, the learner portal and the admin.
 */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
  background: var(--bg);
  overflow-x: clip; /* nothing may scroll the page sideways (clip keeps position: sticky working) */
}
html.reduce-motion { scroll-behavior: auto; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font-family: var(--font-ui); font-size: var(--fs-16); line-height: 1.6;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden; overflow-x: clip;
}
html.is-locked, html.is-locked body { overflow: hidden; }
html.is-locked body { padding-right: var(--sb, 0px); }
img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
svg { overflow: visible; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
p, h1, h2, h3, h4, h5, figure, blockquote, dl, dd, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
table { border-collapse: collapse; width: 100%; }
[hidden] { display: none !important; }
::selection { background: var(--brand-gold-border); color: #1D1503; }

/* Focus: brand-coloured, and only for keyboard users. */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* ── Typography ─────────────────────────────────────────────────── */
h1, h2, h3, h4, .display {
  font-family: var(--font-display); font-weight: 600; line-height: 1.04; letter-spacing: -0.035em;
  font-optical-sizing: auto; text-wrap: balance; color: var(--text);
}
h1, .h1 { font-size: var(--fs-60); }
h2, .h2 { font-size: var(--fs-44); }
h3, .h3 { font-size: var(--fs-24); line-height: 1.18; letter-spacing: -0.025em; }
h4, .h4 { font-size: var(--fs-20); line-height: 1.25; letter-spacing: -0.02em; }
.display em, h1 em, h2 em, h3 em, h4 em { font-family: var(--font-accent); font-style: normal; font-stretch: var(--accent-stretch); font-weight: 400; letter-spacing: -0.01em; color: var(--accent-text); padding-right: 0.04em; }
p { text-wrap: pretty; }
.lede { font-size: var(--fs-20); line-height: 1.55; color: var(--text-2); max-width: 60ch; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
small, .small { font-size: var(--fs-14); }
strong { font-weight: 650; }
.num { font-variant-numeric: tabular-nums lining-nums; }
.serif { font-family: var(--font-display); }

/* Eyebrow: small caps label with a fine gold rule — used above section headings. */
.eyebrow {
  display: inline-flex; align-items: center; gap: 12px;
  font-size: var(--fs-12); font-weight: 650; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent-text);
}
.eyebrow::before { content: ''; width: 28px; height: 1px; background: currentColor; opacity: 0.7; }
.eyebrow--center::after { content: ''; width: 28px; height: 1px; background: currentColor; opacity: 0.7; }
/* Gate eyebrow: a small notched ticket chip before the label. */
.eyebrow--gate::before { display: none; }
.eyebrow--gate.eyebrow--center::after { display: none; }
.gate { display: inline-flex; flex: none; white-space: nowrap; align-items: center; height: 22px; padding: 0 10px; margin-right: 2px; border-radius: 4px; background: var(--accent); color: var(--on-accent); font-family: var(--font-mono, monospace); font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em;
  -webkit-mask: radial-gradient(circle 4px at 0 50%, #0000 96%, #000) left / 51% 100% no-repeat, radial-gradient(circle 4px at 100% 50%, #0000 96%, #000) right / 51% 100% no-repeat;
          mask: radial-gradient(circle 4px at 0 50%, #0000 96%, #000) left / 51% 100% no-repeat, radial-gradient(circle 4px at 100% 50%, #0000 96%, #000) right / 51% 100% no-repeat; }

.link { color: var(--accent-text); text-decoration: underline; text-decoration-color: var(--accent-line); text-underline-offset: 3px; text-decoration-thickness: 1px; transition: text-decoration-color var(--t-2); }
.link:hover { text-decoration-color: currentColor; }

/* ── Arabic: a visual feature, never squeezed or clipped ─────────── */
.ar, [lang='ar'] {
  font-family: var(--font-arabic); direction: rtl; unicode-bidi: isolate;
  line-height: 2.35; letter-spacing: 0; font-weight: 400; word-spacing: 0.08em;
  font-feature-settings: 'liga' 1, 'calt' 1, 'kern' 1; text-wrap: balance;
  padding-block: 0.12em; /* room for tall marks above and below */
}
.ar--xl { font-size: clamp(2.1rem, 1.2rem + 4.4vw, 4.2rem); }
.ar--lg { font-size: clamp(1.7rem, 1.2rem + 2.2vw, 2.6rem); }
.ar--md { font-size: clamp(1.4rem, 1.2rem + 1vw, 1.8rem); }
.ar--gold { color: var(--accent-text); }

/* ── Layout ─────────────────────────────────────────────────────── */
.wrap { width: min(100% - var(--gutter) * 2, var(--wrap)); margin-inline: auto; }
.wrap--narrow, .wrap-narrow { width: min(100% - var(--gutter) * 2, var(--wrap-narrow)); margin-inline: auto; }
.section { padding-block: var(--section); position: relative; }
.section--tint { background: linear-gradient(180deg, var(--bg), var(--bg-tint) 140px, var(--bg-tint) calc(100% - 140px), var(--bg)); }
.section--ink { background: var(--ink-1); color: #F2ECDD; --text: #F2ECDD; --text-2: #BDB5A2; --text-3: #8A8373; --line: #2E2A22; --line-2: #423C30; --accent-text: #E5C568; --surface: #211D16; --surface-2: #2A261E; --pattern-ink: rgba(229, 197, 104, 0.1); --accent-line: #6B5420; --accent-soft: #2A2210; }
[data-theme='dark'] .section--ink { background: #08090B; }
.stack > * + * { margin-top: var(--gap, 16px); }
.row { display: flex; align-items: center; gap: var(--gap, 12px); flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.center { text-align: center; }
.center .lede, .center .eyebrow { margin-inline: auto; }
.grid { display: grid; gap: var(--gap, 24px); }
.sr-only { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 12px; top: -80px; z-index: 300; padding: 10px 16px; background: var(--inverse); color: var(--on-inverse); border-radius: var(--r-2); font-weight: 600; transition: top var(--t-2); }
.skip-link:focus { top: 12px; }

/* ── Ornaments ──────────────────────────────────────────────────── */
/* Fine dot grid, tinted through a mask so it follows the theme. */
.pattern { position: absolute; inset: 0; pointer-events: none; background: var(--pattern-ink);
  -webkit-mask: var(--tile) 0 0 / 24px 24px; mask: var(--tile) 0 0 / 24px 24px;
  --tile: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='1.15' fill='%23000'/%3E%3C/svg%3E"); }
.pattern--fade-b { -webkit-mask-image: var(--tile), linear-gradient(#000, transparent); mask-image: var(--tile), linear-gradient(#000, transparent); -webkit-mask-composite: source-in; mask-composite: intersect; -webkit-mask-size: 24px 24px, 100% 100%; mask-size: 24px 24px, 100% 100%; }
.pattern--fade-r { -webkit-mask-image: var(--tile), radial-gradient(closest-side, #000 20%, transparent); mask-image: var(--tile), radial-gradient(closest-side, #000 20%, transparent); -webkit-mask-composite: source-in; mask-composite: intersect; -webkit-mask-size: 24px 24px, 100% 100%; mask-size: 24px 24px, 100% 100%; }

/* A fine rule with a small pair of light-bars at its centre. */
.rule-orn { display: flex; align-items: center; gap: 10px; color: var(--accent); width: min(100%, var(--w, 320px)); margin-inline: auto; }
.rule-orn::before, .rule-orn::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, currentColor); }
.rule-orn::after { transform: scaleX(-1); }
.rule-orn i { width: 3px; height: 12px; border-radius: 3px; background: currentColor; flex: none; }
.rule-orn i + i { height: 7px; margin-left: -6px; opacity: 0.6; }
.rule-orn--left { margin-inline: 0; }

/* Gold leaf text: only for large display moments. */
.leaf-text { background: var(--leaf); -webkit-background-clip: text; background-clip: text; color: transparent; }
[data-theme='dark'] .leaf-text, .section--ink .leaf-text { background-image: linear-gradient(135deg, #C6952F 0%, #F3D98B 30%, #FFF4CC 48%, #E5C568 62%, #C6952F 100%); }

/* Ticket mark used as a number holder (levels, steps, ayahs). */
.ayah-mark { position: relative; display: inline-grid; place-items: center; width: var(--size, 44px); height: var(--size, 44px); color: var(--accent); flex: none; }
.ayah-mark svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.ayah-mark b { position: relative; font-family: var(--font-display); font-weight: 700; letter-spacing: -0.03em; font-size: calc(var(--size, 44px) * 0.29); color: var(--text); line-height: 1; font-variant-numeric: lining-nums tabular-nums; }

/* ── Icons ──────────────────────────────────────────────────────── */
.i { width: 1.25em; height: 1.25em; flex: none; stroke-width: 1.6; }

/* ── Reveal on scroll (transform + opacity only) ─────────────────── */
.js [data-reveal] { opacity: 0; transform: translate3d(0, 22px, 0); transition: opacity var(--t-4) var(--ease-out), transform var(--t-5) var(--ease-out); transition-delay: calc(var(--i, 0) * 70ms); will-change: opacity, transform; }
.js [data-reveal='fade'] { transform: none; }
.js [data-reveal='left'] { transform: translate3d(-28px, 0, 0); }
.js [data-reveal='right'] { transform: translate3d(28px, 0, 0); }
.js [data-reveal='scale'] { transform: scale(0.94); }
/* Phones: sideways reveals would push past the screen edge, so they rise like the rest. */
@media (max-width: 720px) { .js [data-reveal='left'], .js [data-reveal='right'] { transform: translate3d(0, 22px, 0); } }
.js [data-reveal].is-in { opacity: 1; transform: none; will-change: auto; }

/* Split-text headlines: each word rises out of a clipped line. */
.split .w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: 0.14em; margin-bottom: -0.14em; }
.split .w > span { display: inline-block; transform: translate3d(0, 108%, 0); transition: transform 1s var(--ease-out); transition-delay: calc(var(--wi, 0) * 55ms + var(--d, 0ms)); will-change: transform; }
.split.is-in .w > span { transform: none; will-change: auto; }

/* Anything decorative that loops is paused while off-screen. */
[data-anim]:not(.is-live) *, [data-anim]:not(.is-live) { animation-play-state: paused !important; }

.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; transition-delay: 0ms !important; scroll-behavior: auto !important; }
.reduce-motion .js [data-reveal], .reduce-motion [data-reveal], .reduce-motion .split .w > span { opacity: 1 !important; transform: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; transition-delay: 0ms !important; scroll-behavior: auto !important; }
  .js [data-reveal], .split .w > span { opacity: 1 !important; transform: none !important; }
}

/* ── Screen transitions ─────────────────────────────────────────── */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out 220ms var(--ease-soft) both; }
::view-transition-new(root) { animation: vt-in 380ms var(--ease-out) both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translate3d(0, 10px, 0); } }
.view-enter { animation: vt-in 420ms var(--ease-out) both; }

/* ── Live logo ──────────────────────────────────────────────────── */
.logo { display: inline-flex; align-items: center; gap: calc(var(--logo-h, 40px) * 0.26); color: var(--brand-gold); line-height: 1; }
.logo__mark { height: var(--logo-h, 40px); width: var(--logo-h, 40px); flex: none; }
.logo__word { height: calc(var(--logo-h, 40px) * 0.34); width: auto; flex: none; }
.logo__word--title { height: calc(var(--logo-h, 40px) * 0.72); }
.logo svg { overflow: visible; }
.logo__tile { fill: var(--brand-gold); }
.logo__disc { fill: #FDFBF5; }
.logo__cal { fill: var(--brand-gold); }
.logo__ink { fill: #15130F; }
.logo__word path { fill: var(--brand-gold); }
.logo:hover .logo__sheen { transform: translateX(560px); transition: transform 1.1s var(--ease-in-out); }
.logo__sheen { transform: translateX(-560px); }

/* ── Scrollbars ─────────────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
