/* Musolla Al-Raudah — shared design tokens and components.
   Layout concept: calm cream canvas, ink type, one gold accent, MYDS-style neutral
   components (8px radius, 40px controls, visible focus rings), faint khatam lattice. */
:root {
  --bg: #FAF9F4;
  --surface: #FFFFFF;
  --surface-2: #F3F1E8;
  --fg: #14120F;
  --muted: #5B5850;
  --border: #E3E0D4;
  --gold: #B08A3A;
  --gold-text: #876620;
  --gold-soft: #F4EEDC;
  --ink: #14120F;
  --on-ink: #FAF9F4;
  --link: #1D4ED8;
  --ring: #2563EB;
  --ok: #15803D;
  --ok-bg: #E6F5EB;
  --warn: #92600A;
  --warn-bg: #FDF3D6;
  --danger: #B91C1C;
  --danger-bg: #FCE9E9;
  --font-head: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-ar: 'Amiri', 'Noto Naskh Arabic', 'Traditional Arabic', serif;
  --r-s: 6px;
  --r-m: 8px;
  --r-l: 12px;
  --shadow: 0 1px 2px rgba(20,18,15,.05), 0 6px 20px rgba(20,18,15,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12100D; --surface: #1B1915; --surface-2: #23201B; --fg: #F4F1E8; --muted: #A9A396;
    --border: #37332B; --gold: #C9A65A; --gold-text: #DABB70; --gold-soft: #2A2416;
    --ink: #F4F1E8; --on-ink: #14120F; --link: #8DB0FF; --ring: #8DB0FF;
    --ok: #4ADE80; --ok-bg: #12261A; --warn: #F5C451; --warn-bg: #2C2410;
    --danger: #F87171; --danger-bg: #2E1717; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12100D; --surface: #1B1915; --surface-2: #23201B; --fg: #F4F1E8; --muted: #A9A396;
  --border: #37332B; --gold: #C9A65A; --gold-text: #DABB70; --gold-soft: #2A2416;
  --ink: #F4F1E8; --on-ink: #14120F; --link: #8DB0FF; --ring: #8DB0FF;
  --ok: #4ADE80; --ok-bg: #12261A; --warn: #F5C451; --warn-bg: #2C2410;
  --danger: #F87171; --danger-bg: #2E1717; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 88px; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 400 16px/1.65 var(--font-body);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
img { max-width: 100%; display: block; }
a { color: var(--link); text-underline-offset: 3px; }
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 600; line-height: 1.2; margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--ink); color: var(--on-ink); padding: 8px 14px; border-radius: var(--r-m); z-index: 100; }
.skip:focus { left: 16px; }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; }
.eyebrow { font: 600 12px/1 var(--font-body); letter-spacing: .14em; text-transform: uppercase; color: var(--gold-text); }
.muted { color: var(--muted); }
.ar { font-family: var(--font-ar); }

/* Buttons — 40px control height, 8px radius */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 18px; border-radius: var(--r-m); border: 1px solid transparent;
  font: 500 14px/1 var(--font-body); text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: var(--on-ink); }
.btn-primary:hover { filter: brightness(1.18); }
.btn-gold { background: var(--gold); color: #14120F; }
.btn-gold:hover { filter: brightness(1.06); }
.btn-outline { background: var(--surface); color: var(--fg); border-color: var(--border); }
.btn-outline:hover { border-color: var(--gold); }
.btn-ghost { background: transparent; color: var(--fg); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.btn-danger:hover { border-color: var(--danger); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Forms */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .label { font: 500 14px/1.3 var(--font-body); }
.hint { font-size: 13px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 9px 12px; border-radius: var(--r-m);
  border: 1px solid var(--border); background: var(--surface); color: var(--fg);
  font: 400 15px/1.4 var(--font-body);
}
.textarea { min-height: 112px; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--gold); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: 2px solid var(--ring); outline-offset: 0; border-color: var(--ring); }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; min-height: 32px; }
.check input { width: 18px; height: 18px; accent-color: var(--gold); margin: 0; }
.err { color: var(--danger); font-size: 13px; }

/* Badges */
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 10px; border-radius: 999px; font: 500 12px/1 var(--font-body); background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge-gold { background: var(--gold-soft); color: var(--gold-text); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l); }

/* Islamic lattice: eight-point khatam tile, drawn as a mask so it takes the gold token */
.lattice { position: relative; isolation: isolate; }
.lattice::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: var(--gold); opacity: .16;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg fill='none' stroke='black' stroke-width='1'%3E%3Crect x='18' y='18' width='36' height='36'/%3E%3Crect x='18' y='18' width='36' height='36' transform='rotate(45 36 36)'/%3E%3Ccircle cx='36' cy='36' r='8'/%3E%3Cpath d='M0 36h18M54 36h18M36 0v18M36 54v18'/%3E%3C/g%3E%3C/svg%3E");
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg fill='none' stroke='black' stroke-width='1'%3E%3Crect x='18' y='18' width='36' height='36'/%3E%3Crect x='18' y='18' width='36' height='36' transform='rotate(45 36 36)'/%3E%3Ccircle cx='36' cy='36' r='8'/%3E%3Cpath d='M0 36h18M54 36h18M36 0v18M36 54v18'/%3E%3C/g%3E%3C/svg%3E");
}

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--on-ink); padding: 10px 18px; border-radius: var(--r-m);
  font-size: 14px; box-shadow: var(--shadow); z-index: 200; max-width: calc(100vw - 32px);
}
.toast[hidden] { display: none; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); background: var(--surface); z-index: 60; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .btn { transition: none; } }

/* Banner colour families (light green / sky blue / teal), each with a dark-theme counterpart */
.bn-hijau { --bn-a: #E0F4E7; --bn-b: #BFE6CD; --bn-fg: #0F3D28; --bn-ink: #1E6B45; --bn-acc: #2F9E6B; }
.bn-biru  { --bn-a: #E1EDFC; --bn-b: #BDD6F5; --bn-fg: #0F3466; --bn-ink: #1D4F91; --bn-acc: #2F6FD0; }
.bn-teal  { --bn-a: #DCF3EF; --bn-b: #BEE2F1; --bn-fg: #0C434D; --bn-ink: #17606E; --bn-acc: #1F8A9A; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bn-hijau { --bn-a: #14301F; --bn-b: #1D4A33; --bn-fg: #E8F7EE; --bn-ink: #8FDDB1; --bn-acc: #4FBF86; }
  :root:not([data-theme="light"]) .bn-biru  { --bn-a: #12263F; --bn-b: #1B3C66; --bn-fg: #E6F0FF; --bn-ink: #9CC4FF; --bn-acc: #5B97F0; }
  :root:not([data-theme="light"]) .bn-teal  { --bn-a: #11302F; --bn-b: #17444E; --bn-fg: #E3F6F8; --bn-ink: #8CD8E4; --bn-acc: #4DB6C6; }
}
:root[data-theme="dark"] .bn-hijau { --bn-a: #14301F; --bn-b: #1D4A33; --bn-fg: #E8F7EE; --bn-ink: #8FDDB1; --bn-acc: #4FBF86; }
:root[data-theme="dark"] .bn-biru  { --bn-a: #12263F; --bn-b: #1B3C66; --bn-fg: #E6F0FF; --bn-ink: #9CC4FF; --bn-acc: #5B97F0; }
:root[data-theme="dark"] .bn-teal  { --bn-a: #11302F; --bn-b: #17444E; --bn-fg: #E3F6F8; --bn-ink: #8CD8E4; --bn-acc: #4DB6C6; }
html { -webkit-text-size-adjust: 100%; }
a, button, input, select, textarea, label { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior-y: none; }
