/* حاسبتك — hasibatak.com */
:root {
  --ink: #13302f;          /* headings, primary text */
  --text: #24322f;
  --muted: #5b6b67;
  --paper: #f5f7f6;        /* page */
  --sheet: #ffffff;        /* panels */
  --line: #d6dfdc;
  --teal: #1d5c57;         /* brand, buttons */
  --teal-hover: #164b47;
  --gold: #b9862a;         /* totals, key figures */
  --gold-soft: #f6ecd7;
  --danger: #a3372b;
  --focus: #2f7fd1;
  --radius-s: 6px;
  --radius-l: 14px;
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --display: "Reem Kufi", "IBM Plex Sans Arabic", sans-serif;
  --lh: 1.75;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e7efec; --text: #d3dddA; --muted: #9aaba6;
    --paper: #0f1716; --sheet: #172221; --line: #2a3a38;
    --teal: #3f9a91; --teal-hover: #4fb0a6;
    --gold: #e0b45a; --gold-soft: #2c2616;
    --danger: #e0786b; --focus: #7ab4f0;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: var(--lh);
}
img, svg { max-width: 100%; }
a { color: var(--teal); text-underline-offset: 3px; }
a:hover { color: var(--teal-hover); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* header */
.site-head { border-bottom: 1px solid var(--line); background: var(--sheet); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { width: 34px; height: 34px; }
.brand-name { font-family: var(--display); font-size: 26px; font-weight: 600; line-height: 1; }
.site-nav { display: flex; gap: 20px; flex-wrap: wrap; }
.site-nav a { color: var(--muted); text-decoration: none; font-size: 15px; padding: 6px 0; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); }
.site-nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--gold); }

/* headings */
h1, h2, h3 { color: var(--ink); line-height: 1.35; }
h1 { font-family: var(--display); font-weight: 600; font-size: clamp(30px, 5vw, 44px); margin: 0 0 12px; }
h2 { font-size: 24px; margin: 48px 0 12px; }
h3 { font-size: 19px; margin: 28px 0 6px; }
p { margin: 0 0 14px; max-width: 68ch; }
.lead { font-size: 19px; color: var(--muted); max-width: 60ch; }

/* page intro */
.intro { padding: 40px 0 28px; }
.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--muted); }
.law-ref { display: inline-block; margin-top: 4px; font-size: 14px; color: var(--muted); border-inline-start: 3px solid var(--gold); padding-inline-start: 10px; }

/* calculator layout */
.calc { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 28px; align-items: start; }
@media (max-width: 860px) { .calc { grid-template-columns: 1fr; } }

.panel { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 24px; }
.panel h2 { margin-top: 0; font-size: 20px; }

fieldset { border: 0; margin: 0 0 22px; padding: 0; min-width: 0; }
legend { font-weight: 600; color: var(--ink); margin-bottom: 10px; padding: 0; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 15px; margin-bottom: 4px; color: var(--ink); }
.hint { display: block; font-size: 13.5px; color: var(--muted); line-height: 1.6; margin-top: 4px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }

input[type="number"], input[type="date"], input[type="text"], select {
  width: 100%;
  font: inherit;
  font-size: 17px;
  color: var(--text);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 10px 12px;
  min-height: 46px;
}
input[type="number"], input.num-in { direction: ltr; text-align: left; font-variant-numeric: tabular-nums; }
[dir="rtl"] input[type="number"], [dir="rtl"] input.num-in { text-align: right; }
input:focus, select:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 25%, transparent); }
input[aria-invalid="true"] { border-color: var(--danger); }

/* segmented choice */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; margin-bottom: 14px; }
.seg button { font: inherit; font-size: 15px; background: transparent; color: var(--muted); border: 0; padding: 8px 16px; cursor: pointer; min-height: 40px; }
.seg button[aria-pressed="true"] { background: var(--teal); color: #fff; }

/* reason options */
.choices { display: grid; gap: 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 12px; cursor: pointer; background: var(--paper); }
.choice input { margin-top: 7px; accent-color: var(--teal); width: 18px; height: 18px; flex: none; }
.choice strong { display: block; font-weight: 600; color: var(--ink); font-size: 15.5px; }
.choice span { font-size: 13.5px; color: var(--muted); line-height: 1.6; }
.choice:has(input:checked) { border-color: var(--teal); background: color-mix(in srgb, var(--teal) 7%, var(--sheet)); }

.btn { font: inherit; font-weight: 600; font-size: 17px; background: var(--teal); color: #fff; border: 0; border-radius: var(--radius-s); padding: 12px 22px; cursor: pointer; min-height: 48px; }
.btn:hover { background: var(--teal-hover); }
.btn-quiet { font: inherit; font-size: 15px; background: none; border: 0; color: var(--teal); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; padding: 8px 4px; }
.error { color: var(--danger); font-size: 14.5px; margin: 8px 0 0; min-height: 1em; }

/* the statement: a settlement sheet (مخالصة) */
.statement {
  position: sticky; top: 16px;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-top: 6px solid var(--teal);
  border-radius: var(--radius-s) var(--radius-s) var(--radius-l) var(--radius-l);
  padding: 22px 24px 18px;
}
@media (max-width: 860px) { .statement { position: static; } }
.statement-title { font-family: var(--display); font-size: 21px; color: var(--ink); margin: 0 0 2px; }
.statement-sub { font-size: 13.5px; color: var(--muted); margin: 0 0 14px; }
.statement .empty { color: var(--muted); font-size: 15px; padding: 18px 0; }
.lines { list-style: none; margin: 0; padding: 0; }
.lines li { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 15.5px; }
.lines li .k { color: var(--muted); }
.lines li .v { color: var(--ink); font-weight: 600; white-space: nowrap; }
.lines li.minus .v { color: var(--danger); }
.total { margin-top: 14px; background: var(--gold-soft); border-radius: var(--radius-s); padding: 14px 16px; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.total .k { color: var(--ink); font-weight: 600; }
.total .v { font-size: clamp(28px, 4.4vw, 36px); font-weight: 700; color: var(--gold); line-height: 1.1; }
.total .cur { font-size: 16px; font-weight: 600; margin-inline-start: 4px; }
.basis { font-size: 13.5px; color: var(--muted); margin: 12px 0 0; line-height: 1.7; }
.statement-actions { display: flex; gap: 12px; margin-top: 10px; flex-wrap: wrap; }

/* article content */
.content { padding-bottom: 32px; }
.content ol, .content ul { max-width: 68ch; padding-inline-start: 22px; }
.content li { margin-bottom: 6px; }
.table-wrap { overflow-x: auto; max-width: 760px; }
table { border-collapse: collapse; width: 100%; font-size: 15.5px; background: var(--sheet); }
th, td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink); font-weight: 600; background: var(--paper); }
blockquote { margin: 0 0 14px; padding: 12px 16px; background: var(--sheet); border-inline-start: 3px solid var(--gold); max-width: 68ch; font-size: 16px; }
.example { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 18px 20px; max-width: 760px; margin-bottom: 16px; }
.example h3 { margin-top: 0; }

.content details { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 0 16px; margin-bottom: 8px; max-width: 760px; }
.content summary { cursor: pointer; font-weight: 600; color: var(--ink); padding: 12px 0; }
.content details[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 10px; }

.note { font-size: 14.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px; margin-top: 32px; max-width: 760px; }

/* home */
.hero { padding: 56px 0 36px; }
.hero h1 { font-size: clamp(34px, 6vw, 56px); max-width: 16ch; }
.tools { list-style: none; padding: 0; margin: 0 0 40px; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0; border-top: 1px solid var(--line); }
.tools li { border-bottom: 1px solid var(--line); }
.tools a, .tools .tool-row { display: grid; grid-template-columns: 48px 1fr; gap: 14px; padding: 20px 4px; text-decoration: none; color: var(--text); align-items: start; }
.tools a:hover .tool-name { color: var(--teal); text-decoration: underline; text-underline-offset: 4px; }
.tool-icon { width: 48px; height: 48px; border-radius: 12px; background: var(--gold-soft); color: var(--gold); display: grid; place-items: center; font-family: var(--display); font-size: 22px; }
.tool-name { display: block; font-weight: 600; color: var(--ink); font-size: 18px; }
.tool-desc { display: block; font-size: 15px; color: var(--muted); line-height: 1.6; }
.soon .tool-icon { background: var(--paper); color: var(--muted); border: 1px dashed var(--line); }
.soon .tool-name { color: var(--muted); }
.section-label { font-size: 15px; color: var(--muted); margin: 0 0 8px; font-weight: 600; }

/* ad slot placeholder: hidden until ads are switched on */
.ad-slot { display: none; }

/* footer */
.site-foot { border-top: 1px solid var(--line); background: var(--sheet); margin-top: 48px; padding: 24px 0 32px; font-size: 14.5px; color: var(--muted); }
.site-foot .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.site-foot nav { display: flex; gap: 18px; flex-wrap: wrap; }
.site-foot a { color: var(--muted); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: no-preference) {
  .total.flash { animation: flash .6s ease-out; }
  @keyframes flash { from { box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 45%, transparent); } to { box-shadow: 0 0 0 0 transparent; } }
}

@media print {
  .site-head, .site-foot, form, .content, .intro .crumbs, .statement-actions, .ad-slot { display: none !important; }
  .calc { display: block; }
  .statement { border: 1px solid #999; position: static; }
  body { background: #fff; }
}

/* تفقيط output */
.words-out { font-size: clamp(21px, 2.6vw, 26px); line-height: 1.9; color: var(--ink); font-weight: 600; background: var(--gold-soft); border-radius: var(--radius-s); padding: 18px 20px; min-height: 96px; margin: 0; overflow-wrap: anywhere; }
.words-out.muted { color: var(--muted); font-weight: 400; font-size: 16px; background: var(--paper); }
.checks { display: grid; gap: 6px; margin: 4px 0 8px; }
.checks label { display: flex; gap: 10px; align-items: center; font-size: 15.5px; cursor: pointer; }
.checks input { width: 18px; height: 18px; accent-color: var(--teal); flex: none; }

/* related tools */
.related { max-width: 760px; margin-top: 40px; }
.related ul { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.related li { border-bottom: 1px solid var(--line); margin: 0; }
.related a { display: block; padding: 12px 2px; text-decoration: none; font-weight: 600; }
.related a span { display: block; font-weight: 400; font-size: 14.5px; color: var(--muted); }

/* home groups */
.group-title { font-size: 20px; margin: 36px 0 4px; }
.group-title + .tools { margin-bottom: 8px; }
.total .v.date-v { font-size: clamp(22px, 3vw, 28px); }
.row-date { grid-template-columns: minmax(70px, 0.8fr) minmax(150px, 2fr) minmax(90px, 1fr); }
@media (max-width: 600px) {
  .row-date { grid-template-columns: 1fr 1fr; }
  .row-date .field:nth-child(2) { grid-column: span 2; order: -1; }
  .site-nav .nav-about { display: none; }
}

/* language menu */
.head-end { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.lang-menu { position: relative; }
.lang-menu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 5px 10px; min-height: 36px; background: var(--paper); }
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary svg { width: 16px; height: 16px; flex: none; }
.lang-menu ul { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 20; list-style: none; margin: 0; padding: 6px; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-s); box-shadow: 0 8px 24px rgba(19, 48, 47, .14); min-width: 190px; }
.lang-menu li a { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 4px; text-decoration: none; color: var(--text); font-size: 15px; line-height: 1.5; }
.lang-menu li a:hover { background: var(--paper); }
.lang-menu li a[aria-current="true"] { font-weight: 600; color: var(--teal); }
.lang-menu li a span { color: var(--muted); font-size: 13px; }
.translated-note { font-size: 14px; color: var(--muted); max-width: 760px; }
