/* ==========================================================
   PageLab kit — shared by every full page
   Copy this file once per project, then each page adds only
   its own <style> block. Built from the house libraries:
   tokens (all labs) · .btx (ButtonLab) · header (NavLab) ·
   footer (FooterLab) · fields (FormLab) · toasts/dialogs (OverlayLab)
   ========================================================== */

/* ---------- tokens ---------- */
:root {
  --brand: #4338ca;
  --brand-rgb: 67, 56, 202;
  --brand-ink: #312a9e;
  --accent: #f2b33d;
  --accent-rgb: 242, 179, 61;
  --ink: #111827;
  --muted: #5b6475;
  --line: #e5e7ee;
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --page: #ffffff;
  --ok: #15803d;   --ok-bg: #e7f6ec;
  --warn: #5f4aa6; --warn-bg: #f7f5fd;
  --danger: #d92d20; --danger-bg: #fdecea;
  --info: #1d4ed8; --info-bg: #e6eeff;
  --radius: 22px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(17,24,39,.04), 0 10px 28px rgba(17,24,39,.06);
  --shadow-lg: 0 2px 4px rgba(17,24,39,.05), 0 28px 60px rgba(17,24,39,.14);
  --head-h: 76px;
  --ease: 220ms cubic-bezier(.2,.7,.3,1);
  --font: 'Cairo', system-ui, Tahoma, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
/* one block per site — the only thing that changes between brands */
[data-site="raseed"] { --brand: #0f766e; --brand-rgb: 15, 118, 110; --brand-ink: #0b5953; --accent: #f59e0b; --accent-rgb: 245, 158, 11; --surface-2: #f3f8f7; }
[data-site="madar"]  { --brand: #1e3a8a; --brand-rgb: 30, 58, 138; --brand-ink: #1e3a8a; --accent: #b8892d; --accent-rgb: 184, 137, 45; --page: #fbfaf6; --surface-2: #f4f1e9; --line: #e7e2d6; }
[data-site="khuta"]  { --brand: #e11d48; --brand-rgb: 225, 29, 72; --brand-ink: #be123c; --accent: #111827; --accent-rgb: 17, 24, 39; --surface-2: #f6f6f7; }

[data-bs-theme="dark"] {
  --ink: #eceef6;
  --muted: #a3aac0;
  --line: #2a3048;
  --surface: #141a2b;
  --surface-2: #1a2134;
  --page: #0c1020;
  --ok: #4ade80;   --ok-bg: rgba(74,222,128,.12);
  --warn: #b9a6ff; --warn-bg: rgba(167,139,250,.09);
  --danger: #f87171; --danger-bg: rgba(248,113,113,.12);
  --info: #93b4ff; --info-bg: rgba(147,180,255,.12);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 28px rgba(0,0,0,.28);
  --shadow-lg: 0 2px 4px rgba(0,0,0,.35), 0 28px 60px rgba(0,0,0,.5);
}
[data-site="raseed"][data-bs-theme="dark"] { --brand-ink: #5eead4; --surface-2: #17222a; }
[data-site="madar"][data-bs-theme="dark"]  { --brand: #3b5bcc; --brand-rgb: 59, 91, 204; --brand-ink: #a9bcff; --accent: #d8b05a; --page: #0d1120; --line: #2b3047; }
[data-site="khuta"][data-bs-theme="dark"]  { --brand-ink: #fb7185; --accent: #f3f4f6; --accent-rgb: 243, 244, 246; }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--head-h) + 16px); }
body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--font); font-size: 17px; line-height: 1.8; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5 { font-family: var(--font); line-height: 1.35; font-weight: 800; color: var(--ink); margin: 0 0 .5em; }
p { margin: 0 0 1em; }
a { color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid rgba(var(--brand-rgb), .55); outline-offset: 3px; border-radius: 8px; }
code { direction: ltr; unicode-bidi: isolate; font-family: var(--mono); font-size: .9em; }
.wrap { width: 100%; max-width: 1440px; margin-inline: auto; padding-inline: clamp(16px, 4vw, 56px); }
.num { direction: ltr; unicode-bidi: isolate; display: inline-block; }
td.num, th.num { display: table-cell; } /* .num on a cell must not break the table */
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; top: -60px; inset-inline-start: 16px; z-index: 100; padding: .5rem 1rem; border-radius: 10px; background: var(--ink); color: var(--surface); text-decoration: none; font-weight: 700; }
.skip:focus { top: 12px; }

/* sections */
.sec { padding-block: clamp(56px, 8vw, 112px); }
.sec-tight { padding-block: clamp(36px, 5vw, 64px); }
.sec-alt { background: var(--surface-2); }
.eyebrow { display: inline-flex; align-items: center; gap: .5rem; padding: .2rem .9rem; border-radius: 999px; background: rgba(var(--brand-rgb), .08); border: 1px solid rgba(var(--brand-rgb), .16); color: var(--brand-ink); font-size: 15px; font-weight: 700; }
.st { display: grid; align-content: start; gap: .6rem; margin-bottom: clamp(28px, 4vw, 48px); }
.st > .eyebrow { justify-self: start; }
.st h2 { font-size: clamp(28px, 3.4vw, 46px); margin: 0; }
.st p { color: var(--muted); font-size: clamp(17px, 1.4vw, 19px); margin: 0; }
.st-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem 4rem; align-items: end; }
@media (max-width: 767.98px) { .st-split { grid-template-columns: minmax(0, 1fr); } }
.pl-lead { font-size: clamp(18px, 1.6vw, 21px); color: var(--muted); }

/* ---------- buttons (ButtonLab) ---------- */
.btx { --h: 48px; position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: var(--h); padding: 0 1.25rem; border: 1.5px solid transparent; border-radius: var(--radius-sm); background: var(--brand); color: #fff; font: 700 16px var(--font); line-height: 1.2; white-space: nowrap; text-decoration: none; cursor: pointer; transition: background var(--ease), border-color var(--ease), filter var(--ease), transform 120ms ease, box-shadow var(--ease); }
.btx:hover { filter: brightness(1.08); color: #fff; }
.btx:active { transform: translateY(1px) scale(.98); }
.btx-soft { background: rgba(var(--brand-rgb), .1); color: var(--brand-ink); }
.btx-soft:hover { filter: none; background: rgba(var(--brand-rgb), .16); color: var(--brand-ink); }
.btx-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btx-ghost:hover { filter: none; background: var(--surface-2); color: var(--ink); }
.btx-dark { background: var(--ink); color: var(--surface); }
.btx-dark:hover { color: var(--surface); }
.btx-light { background: #fff; color: #111827; }
.btx-light:hover { color: #111827; filter: brightness(.96); }
.btx-line-light { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.btx-line-light:hover { color: #fff; background: rgba(255,255,255,.1); filter: none; }
.btx-sm { --h: 44px; padding: 0 1rem; font-size: 15px; }
.btx-lg { --h: 56px; padding: 0 1.6rem; font-size: 17px; border-radius: 14px; }
.btx-pill { border-radius: 999px; }
.btx-icon { width: var(--h); padding: 0; }
.btx-block { width: 100%; }
.btx[disabled] { opacity: .5; cursor: not-allowed; filter: none; transform: none; }
.btx.is-loading { color: transparent !important; pointer-events: none; }
.btx.is-loading::after { content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid #fff; border-inline-end-color: transparent; animation: pl-spin 700ms linear infinite; }
.btx-ghost.is-loading::after, .btx-soft.is-loading::after { border-color: var(--brand); border-inline-end-color: transparent; }
@keyframes pl-spin { to { transform: rotate(360deg); } }
.icon-btn { width: 44px; height: 44px; flex: 0 0 auto; display: inline-grid; place-items: center; border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--ink); font-size: 1.15rem; cursor: pointer; position: relative; text-decoration: none; }
.icon-btn:hover { background: var(--surface-2); border-color: var(--line); }
.icon-btn .badge-n { position: absolute; top: -2px; inset-inline-end: -2px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 15px; font-weight: 800; line-height: 22px; text-align: center; }
.text-link { display: inline-flex; align-items: center; gap: .4rem; color: var(--brand-ink); font-weight: 700; text-decoration: none; min-height: 44px; }
.text-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.flip-rtl { display: inline-block; transform: scaleX(-1); }

/* ---------- header (NavLab core) ---------- */
.ph { position: sticky; top: 0; z-index: 50; transition: box-shadow var(--ease), background var(--ease); }
.ph-in { display: flex; align-items: center; gap: 1.25rem; min-height: var(--head-h); }
.ph-logo { display: inline-flex; align-items: center; gap: .6rem; font-size: 22px; font-weight: 800; text-decoration: none; color: var(--ink); flex: 0 0 auto; }
.ph-logo .mk { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--brand); color: #fff; font-size: 1.15rem; }
.ph-nav { display: flex; align-items: center; gap: 2px; margin: 0; padding: 0; list-style: none; }
.ph-nav a { display: inline-flex; align-items: center; gap: .35rem; min-height: 44px; padding: 0 .9rem; border-radius: 10px; color: var(--muted); font-weight: 700; text-decoration: none; transition: color var(--ease), background var(--ease); }
.ph-nav a:hover { color: var(--ink); background: rgba(var(--brand-rgb), .06); }
.ph-nav a[aria-current="page"] { color: var(--brand-ink); }
.ph-act { display: flex; align-items: center; gap: .4rem; margin-inline-start: auto; }
.ph-burger { display: none; }
.ph.is-stuck { box-shadow: 0 1px 0 var(--line), 0 10px 30px rgba(17,24,39,.06); }
/* phone menu panel */
.ph-panel { position: fixed; inset: 0; z-index: 70; display: none; }
.ph-panel.is-open { display: block; }
.ph-panel .scrim { position: absolute; inset: 0; background: rgba(8,10,22,.5); backdrop-filter: blur(2px); animation: pl-fade 200ms ease; }
.ph-panel .sheet { position: absolute; top: 0; bottom: 0; inset-inline-end: 0; width: min(360px, 88vw); display: flex; flex-direction: column; gap: 1rem; padding: 18px; overflow-y: auto; background: var(--surface); box-shadow: var(--shadow-lg); animation: pl-in-end 260ms cubic-bezier(.2,.7,.3,1); }
.ph-panel .sheet-head { display: flex; align-items: center; justify-content: space-between; }
.ph-panel nav a { display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 0 .75rem; border-radius: 12px; text-decoration: none; font-weight: 700; font-size: 18px; }
.ph-panel nav a:hover, .ph-panel nav a[aria-current="page"] { background: rgba(var(--brand-rgb), .08); color: var(--brand-ink); }
@keyframes pl-fade { from { opacity: 0; } }
@keyframes pl-in-end { from { transform: translateX(-100%); } }
[dir="ltr"] .ph-panel .sheet { animation-name: pl-in-end-ltr; }
@keyframes pl-in-end-ltr { from { transform: translateX(100%); } }
@media (max-width: 991.98px) {
  .ph-nav, .ph-wide { display: none !important; }
  .ph-burger { display: inline-grid; }
}

/* ---------- footer core ---------- */
.pf { padding-top: clamp(48px, 6vw, 80px); }
.pf-cols { display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr)); gap: 2rem 3rem; }
.pf h4 { font-size: 16px; margin-bottom: .8rem; }
.pf ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.pf ul a { display: inline-flex; align-items: center; min-height: 40px; color: var(--muted); text-decoration: none; font-weight: 600; }
.pf ul a:hover { color: var(--ink); }
.pf-bottom { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem; margin-top: clamp(32px, 4vw, 56px); padding-block: 1.25rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 15px; }
.pf-social { display: flex; gap: .4rem; }
@media (max-width: 991.98px) { .pf-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); } .pf-cols > :first-child { grid-column: 1 / -1; } }
@media (max-width: 479.98px) { .pf-cols { grid-template-columns: minmax(0, 1fr); } }

/* ---------- card shell (CardKit) ---------- */
.pc { position: relative; display: flex; flex-direction: column; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(18px, 2vw, 26px); transition: transform var(--ease), box-shadow var(--ease), border-color var(--ease); }
.pc-hover:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: rgba(var(--brand-rgb), .25); }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: clamp(16px, 2vw, 24px); }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: clamp(16px, 2vw, 24px); }
.ico { width: 52px; height: 52px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 16px; background: rgba(var(--brand-rgb), .1); color: var(--brand-ink); font-size: 1.4rem; }
.tag { display: inline-flex; align-items: center; gap: .3rem; padding: .05rem .7rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-size: 15px; font-weight: 700; white-space: nowrap; }
.tag-brand { background: rgba(var(--brand-rgb), .1); border-color: transparent; color: var(--brand-ink); }
.tag-ok { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.stars { color: #f59e0b; letter-spacing: 1px; white-space: nowrap; }
.avatar { width: 48px; height: 48px; flex: 0 0 auto; border-radius: 50%; object-fit: cover; }

/* ---------- fields (FormLab core) ---------- */
.fm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; }
.fm-grid .full { grid-column: 1 / -1; }
.fm-field { display: grid; gap: .35rem; min-width: 0; }
.fm-label { font-weight: 700; font-size: 15px; }
.fm-label .opt { color: var(--muted); font-weight: 600; }
.fm-input { width: 100%; min-height: 52px; padding: .6rem 1rem; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: 500 16px var(--font); transition: border-color var(--ease), box-shadow var(--ease); }
textarea.fm-input { min-height: 140px; resize: vertical; line-height: 1.8; }
.fm-input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.fm-input:focus { outline: none; border-color: rgba(var(--brand-rgb), .7); box-shadow: 0 0 0 4px rgba(var(--brand-rgb), .14); }
.fm-input[dir="ltr"] { text-align: left; }
.fm-field.is-bad .fm-input { border-color: var(--danger); }
.fm-err { min-height: 0; color: var(--danger); font-size: 15px; font-weight: 600; }
.fm-err:empty { display: none; }
.fm-check { display: flex; align-items: flex-start; gap: .6rem; min-height: 44px; padding-top: .55rem; cursor: pointer; font-size: 15px; }
.fm-check input { width: 22px; height: 22px; margin-top: .15rem; accent-color: var(--brand); flex: 0 0 auto; }
.fm-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.fm-chips label { cursor: pointer; }
.fm-chips input { position: absolute; opacity: 0; pointer-events: none; }
.fm-chips input + span { display: inline-flex; align-items: center; gap: .35rem; min-height: 44px; padding: 0 1rem; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 700; font-size: 15px; transition: all var(--ease); }
.fm-chips input:checked + span { border-color: var(--brand); background: rgba(var(--brand-rgb), .08); color: var(--brand-ink); }
.fm-chips input:focus-visible + span { outline: 3px solid rgba(var(--brand-rgb), .55); outline-offset: 2px; }
.fm-done { display: none; text-align: center; padding: 2rem 1rem; }
[data-state="done"] .fm-done { display: block; }
[data-state="done"] .fm-body { display: none; }
.fm-done .ok-ring { width: 72px; height: 72px; margin: 0 auto 1rem; display: grid; place-items: center; border-radius: 50%; background: var(--ok-bg); color: var(--ok); font-size: 2rem; }
@media (max-width: 575.98px) { .fm-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- accordion (details) ---------- */
.acc { display: grid; gap: 10px; }
.acc details { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); transition: border-color var(--ease), box-shadow var(--ease); }
.acc details[open] { border-color: rgba(var(--brand-rgb), .3); box-shadow: var(--shadow); }
.acc summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 60px; padding: .75rem 1.25rem; cursor: pointer; font-weight: 700; font-size: 17px; list-style: none; }
.acc summary::-webkit-details-marker { display: none; }
.acc summary::after { content: "\F4FE"; font-family: "bootstrap-icons"; font-size: 1.1rem; color: var(--brand-ink); transition: transform var(--ease); flex: 0 0 auto; }
.acc details[open] summary::after { transform: rotate(45deg); }
.acc .acc-body { padding: 0 1.25rem 1.1rem; color: var(--muted); }

/* ---------- tabs ---------- */
.tabs-list { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.tabs-list button { min-height: 44px; padding: 0 1.1rem; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font: 700 15px var(--font); cursor: pointer; }
.tabs-list button[aria-selected="true"] { background: var(--surface); color: var(--brand-ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
[role="tabpanel"][hidden] { display: none; }

/* ---------- toasts + dialogs (OverlayLab core) ---------- */
.ov-toasts { position: fixed; z-index: 90; inset-inline: 16px; bottom: 16px; display: grid; justify-items: center; gap: 10px; pointer-events: none; }
.ov-toast { pointer-events: auto; display: flex; align-items: center; gap: .75rem; width: min(440px, 100%); padding: 10px 10px 10px 14px; padding-inline: 14px 10px; border-radius: 16px; background: #141a2b; color: #fff; box-shadow: 0 18px 40px rgba(0,0,0,.25); animation: pl-toast 300ms cubic-bezier(.2,.7,.3,1); }
.ov-toast .ti { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.12); }
.ov-toast.ok .ti { background: #16a34a; } .ov-toast.err .ti { background: #dc2626; } .ov-toast.info .ti { background: #2563eb; }
.ov-toast .tt { flex: 1; min-width: 0; line-height: 1.5; }
.ov-toast b { display: block; font-size: 15px; }
.ov-toast small { display: block; color: rgba(255,255,255,.75); font-size: 15px; }
.ov-toast .ta { min-height: 44px; padding: 0 .8rem; border: 0; border-radius: 10px; background: rgba(255,255,255,.12); color: #fff; font: 700 15px var(--font); cursor: pointer; }
.ov-toast.is-out { animation: pl-toast-out 200ms ease forwards; }
@keyframes pl-toast { from { opacity: 0; transform: translateY(16px) scale(.97); } }
@keyframes pl-toast-out { to { opacity: 0; transform: translateY(10px) scale(.97); } }
.ov-dialog { padding: 0; border: 0; border-radius: 24px; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.ov-dialog::backdrop { background: rgba(8,10,22,.55); backdrop-filter: blur(3px); }
.ov-dialog[open] { animation: pl-pop 260ms cubic-bezier(.2,.7,.3,1); }
@keyframes pl-pop { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.ov-dialog .dl-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.ov-dialog .dl-head h3 { margin: 0; font-size: 20px; }
.ov-dialog .dl-body { padding: 18px; }
.ov-drawer { margin: 0; margin-inline-start: auto; height: 100dvh; max-height: 100dvh; width: min(440px, 100vw); border-radius: 0; display: none; flex-direction: column; }
.ov-drawer[open] { display: flex; animation: pl-in-end 300ms cubic-bezier(.2,.7,.3,1); }
.ov-drawer .dl-body { flex: 1; overflow-y: auto; }
.ov-drawer .dl-foot { padding: 16px 18px; border-top: 1px solid var(--line); display: grid; gap: .6rem; }
@media (max-width: 575.98px) { .ov-sheet-sm { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 24px 24px 0 0; } }

/* ---------- reveal on scroll (only when JS is on) ---------- */
.js-rv .rv { opacity: 0; transform: translateY(18px); transition: opacity 600ms ease, transform 600ms cubic-bezier(.2,.7,.3,1); }
.js-rv .rv.is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .js-rv .rv { opacity: 1; transform: none; }
}
