/* ===== hasibah — Saudi money calculators. Mobile first, RTL first. =====
   Same skeleton as alhijri.com (its sister site), different palette. */

@font-face {
  font-family: 'JF Flat';
  src: url('/font/JF-Flat-regular.woff') format('woff'),
       url('/font/JF-Flat-regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

:root {
  --paper:   #f3f4f8;
  --card:    #ffffff;
  --ink:     #151a2e;
  --ink-mid: #4f5770;
  --ink-dim: #7d8499;
  --line:    #e0e3ec;
  --accent:  #2346c4;
  --on-accent: #ffffff;
  --accent-soft: #e8edfc;
  --gold:    #9a5d0c;
  --gold-soft: #fbf0df;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(21,26,46,.05), 0 8px 24px -12px rgba(21,26,46,.16);
  --sans: 'JF Flat', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans Arabic', Tahoma, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:   #0e1120;
    --card:    #171b2e;
    --ink:     #e8eaf3;
    --ink-mid: #a9afc4;
    --ink-dim: #737a94;
    --line:    #272c44;
    --accent:  #8ea5ff;
    --on-accent: #0e1120;
    --accent-soft: #1b2346;
    --gold:    #e0a95a;
    --gold-soft: #2a2114;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper:   #0e1120;
  --card:    #171b2e;
  --ink:     #e8eaf3;
  --ink-mid: #a9afc4;
  --ink-dim: #737a94;
  --line:    #272c44;
  --accent:  #8ea5ff;
  --on-accent: #0e1120;
  --accent-soft: #1b2346;
  --gold:    #e0a95a;
  --gold-soft: #2a2114;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  padding: 0 16px 48px;
  overflow-x: hidden;
}

.wrap { max-width: 640px; margin: 0 auto; }
a { color: var(--accent); }

/* ---------- header ---------- */

.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 18px 0 12px;
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: inherit; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 auto;
  background: #2346c4; display: grid; place-items: center;
}
.brand .mark svg { width: 22px; height: 22px; display: block; }
.brand b { font-size: 19px; font-weight: 400; letter-spacing: .2px; }
.brand span { color: var(--ink-dim); font-size: 13px; display: block; margin-top: -3px; }

.themebtn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-mid);
  width: 40px; height: 40px; border-radius: 12px; font-size: 17px;
  cursor: pointer; flex: 0 0 auto; display: grid; place-items: center;
}
.themebtn:active { transform: scale(.94); }

/* ---------- calculator nav (chips, scrolls sideways on phones) ---------- */

.calcnav {
  display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 12px;
  margin-bottom: 6px; scrollbar-width: none;
}
.calcnav::-webkit-scrollbar { display: none; }
.calcnav a {
  flex: 0 0 auto; padding: 7px 13px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card);
  color: var(--ink-mid); font-size: 14px; text-decoration: none; white-space: nowrap;
}
.calcnav a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ---------- page head ---------- */

.pagehead { margin: 6px 0 16px; }
.pagehead h1 { font-size: clamp(23px, 6.4vw, 30px); font-weight: 400; line-height: 1.3; margin: 0 0 6px; }
.pagehead p { margin: 0; color: var(--ink-mid); font-size: 15px; }

/* ---------- cards ---------- */

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px;
}
.card > h2 {
  margin: 0 0 14px; font-size: 17px; font-weight: 400; color: var(--ink);
  display: flex; align-items: center; gap: 8px;
}
.card > h2 i { color: var(--accent); font-style: normal; }
.hint { font-size: 13px; color: var(--ink-dim); margin: 6px 0 0; }

/* ---------- form controls ---------- */

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
label.fl, .fl { display: block; font-size: 13px; color: var(--ink-mid); margin-bottom: 6px; }

input[type="date"], input[type="text"], input[type="number"], select {
  width: 100%; padding: 12px; font-family: inherit; font-size: 16px;
  color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 12px;
  min-height: 48px; appearance: none;
}
input[type="date"] { text-align: start; }
/* amounts: digits read left-to-right even inside an RTL page */
input.num { direction: ltr; text-align: right; font-variant-numeric: tabular-nums; }
.withunit { position: relative; }
.withunit input { padding-inline-end: 52px; }
.withunit .unit {
  position: absolute; inset-inline-end: 12px; top: 50%; transform: translateY(-50%);
  color: var(--ink-dim); font-size: 13px; pointer-events: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-mid) 50%),
                    linear-gradient(135deg, var(--ink-mid) 50%, transparent 50%);
  background-position: left 14px center, left 19px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-inline-end: 32px;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input[aria-invalid="true"] { border-color: var(--gold); }

.duo  { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.trio { display: grid; grid-template-columns: 1fr 1.5fr 1fr; gap: 8px; }

.seg { display: flex; gap: 4px; padding: 3px; background: var(--paper);
  border: 1px solid var(--line); border-radius: 11px; margin-bottom: 14px; }
.seg button {
  flex: 1; padding: 9px 6px; border: 0; background: transparent;
  color: var(--ink-mid); font-family: inherit; font-size: 14px;
  border-radius: 8px; cursor: pointer; min-height: 40px;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; color: var(--ink-mid); cursor: pointer; padding: 4px 0; }
.check input { width: 20px; height: 20px; margin: 3px 0 0; accent-color: var(--accent); flex: 0 0 auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 16px; min-height: 46px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--paper); color: var(--ink-mid);
  font-family: inherit; font-size: 15px; cursor: pointer;
}
.btn:active { transform: scale(.98); }
.btn.wide { width: 100%; }

/* ---------- results ---------- */

.out {
  margin-top: 16px; padding: 16px; border-radius: 13px;
  background: var(--accent-soft); text-align: center;
}
.out:empty { display: none; }
.out .lbl { font-size: 13px; color: var(--ink-mid); }
.out .big {
  font-size: clamp(24px, 7vw, 32px); color: var(--accent); line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.out .sub { font-size: 14px; color: var(--ink-mid); margin-top: 5px; }
.out.bad { background: var(--gold-soft); }
.out.bad .big { font-size: 16px; color: var(--gold); }

.rows { margin-top: 14px; border-top: 1px solid var(--line); }
.rows:empty { display: none; }
.rows > div {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.rows > div > span:first-child { color: var(--ink-mid); }
.rows > div > span:last-child { color: var(--ink); text-align: end; font-variant-numeric: tabular-nums; }
.rows > div.total > span { color: var(--accent) !important; }
.rows > div.note > span { color: var(--ink-dim) !important; font-size: 13px; }

.basis {
  margin-top: 14px; padding: 12px 14px; border-radius: 12px;
  background: var(--paper); border: 1px solid var(--line);
  font-size: 13.5px; color: var(--ink-mid);
}
.basis:empty { display: none; }
.basis b { color: var(--ink); font-weight: 400; }

table.sched { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 14px; }
table.sched th, table.sched td { padding: 9px 6px; border-bottom: 1px solid var(--line); text-align: start; font-variant-numeric: tabular-nums; }
table.sched th { color: var(--ink-dim); font-weight: 400; font-size: 12px; }
.tblwrap { overflow-x: auto; }

/* ---------- home ---------- */

.tiles { display: grid; gap: 12px; }
.tile {
  display: block; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px;
}
.tile b { display: block; font-weight: 400; font-size: 18px; color: var(--accent); }
.tile span { display: block; font-size: 14px; color: var(--ink-mid); margin-top: 3px; }
@media (min-width: 560px) { .tiles { grid-template-columns: 1fr 1fr; } }

/* ---------- sources + checked stamp ---------- */

.sources { font-size: 14px; color: var(--ink-mid); }
.sources ul { margin: 6px 0 0; padding-inline-start: 18px; }
.sources li { margin: 4px 0; }
.checked {
  display: inline-block; margin-top: 10px; padding: 3px 11px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; font-size: 12.5px;
}

/* ---------- prose / FAQ ---------- */

.prose { margin-top: 26px; }
.prose h2 { font-size: 18px; font-weight: 400; color: var(--ink); margin: 22px 0 10px; }
.prose p, .prose li { font-size: 15px; color: var(--ink-mid); }
.prose p { margin: 0 0 12px; }
.prose ul, .prose ol { padding-inline-start: 20px; margin: 0 0 12px; }
.prose details {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 0 14px; margin-bottom: 8px;
}
.prose details[open] { padding-bottom: 4px; }
.prose summary {
  cursor: pointer; padding: 13px 0; font-size: 15px; color: var(--ink);
  list-style: none; display: flex; justify-content: space-between; align-items: center;
  gap: 10px; min-height: 46px;
}
.prose summary::-webkit-details-marker { display: none; }
.prose summary::after { content: '+'; color: var(--accent); font-size: 19px; flex: 0 0 auto; }
.prose details[open] summary::after { content: '−'; }
.prose details p { font-size: 14.5px; margin: 0 0 12px; }

/* ---------- footer ---------- */

footer {
  margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line);
  font-size: 13px; color: var(--ink-dim); line-height: 1.8;
}
footer p { margin: 0 0 9px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- shared bits promoted from page styles ---------- */

/* grid/flex classes would otherwise override the hidden attribute */
[hidden] { display: none !important; }
/* amounts never break across lines on a phone */
.rows > div > span:last-child { white-space: nowrap; }
.rows > div.warn > span { color: var(--gold) !important; }
table.sched tr.now td { color: var(--accent); background: var(--accent-soft); }
.sub-h { font-size: 13px; color: var(--ink-dim); margin: 18px 0 10px; padding-top: 14px; border-top: 1px solid var(--line); }

/* ---------- consent banner (EU visitors only; see js/consent.js) ---------- */
.consent { position: fixed; inset-inline: 0; bottom: 0; z-index: 60;
  background: #151a2e; color: #f3f4f8; padding: 14px 16px;
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  box-shadow: 0 -4px 24px rgba(0,0,0,.25); font-size: 14px; }
.consent p { margin: 0; line-height: 1.6; max-width: 60ch; }
.consent a { color: #ffc861; }
.consent-actions { display: flex; gap: 8px; flex-shrink: 0; }
/* refusing is exactly as prominent as accepting */
.consent button { font: inherit; cursor: pointer; border: 1px solid transparent; border-radius: 10px;
  padding: 9px 20px; background: #ffc861; color: #151a2e; min-height: 42px; }
.consent button.ghost { background: transparent; color: #f3f4f8; border-color: rgba(255,255,255,.45); }
@media (max-width: 560px) { .consent { flex-direction: column; align-items: stretch; }
  .consent button { flex: 1; } }
