:root {
  /* Idea: a receipt book. Everything pre-printed is in one dark ink. Everything filled in (the numbers
     you type, the result, the amount in words) is in pen blue. The result is the one white receipt,
     torn from its stub, and the date the rules were reviewed is stamped on it in red. */
  --desk: #e4e9f4;
  --paper: #ffffff;
  --ink: #14194a;
  --ink-soft: #545b8c;
  --pen: #2438c2;
  --rule: #b9c1de;
  --stamp: #c0352c;
  --copy: #fff0b3;
  --font-print: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --font-hand: "Aref Ruqaa", "IBM Plex Sans Arabic", "Segoe UI", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    /* The carbon sheet from the same book. */
    --desk: #0f1233;
    --paper: #191e4d;
    --ink: #e6e9ff;
    --ink-soft: #a4abd9;
    --pen: #9db0ff;
    --rule: #363d7a;
    --stamp: #ff8a7a;
    --copy: #3b3515;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--desk); color: var(--ink); font-family: var(--font-print); font-size: 16px; line-height: 1.75; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px; }
a { color: var(--pen); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--pen); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
[hidden] { display: none !important; }
mark { background: var(--copy); color: inherit; padding: 0 4px; }

/* Site bar: the letterhead */
.sitebar { border-bottom: 1.5px solid var(--ink); }
.sitebar .wrap { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 28px; padding-block: 8px 10px; }
.brand { font: 700 34px/1.4 var(--font-hand); color: var(--pen); text-decoration: none; }
.sitenav { display: flex; flex-wrap: wrap; gap: 0 18px; font-size: 14px; }
.sitenav a { color: var(--ink-soft); text-decoration: none; padding: 4px 0; white-space: nowrap; }
.sitenav a:hover { color: var(--ink); text-decoration: underline; }
.sitenav a[aria-current="page"] { color: var(--ink); font-weight: 600; box-shadow: 0 2px 0 var(--pen); }

/* Headings */
.crumbs { font-size: 13px; color: var(--ink-soft); padding-top: 22px; }
.crumbs a { color: var(--ink-soft); }
h1 { font-weight: 700; font-size: clamp(26px, 4.4vw, 40px); line-height: 1.4; margin: 6px 0 8px; text-wrap: balance; }
main > h1:first-child { margin-top: 28px; }
.lede { max-width: 62ch; margin: 0; }
.lede b { font-weight: 600; }

/* Home */
.hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 40px; align-items: center; padding-top: 36px; }
.hero h1 { font-size: clamp(32px, 5.6vw, 52px); line-height: 1.3; margin: 0; }
.hand { font: 400 clamp(26px, 3.6vw, 34px)/1.7 var(--font-hand); color: var(--pen); margin: 10px 0 14px; }
.sample { margin: 0; }
.sample .slip { rotate: 1.2deg; }
.sample figcaption { margin-top: 14px; font-size: 14px; color: var(--ink-soft); }

/* Calculator: a printed form on the desk beside the one white receipt */
.calc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 36px; align-items: start; margin-top: 28px; }
.form h2 { font-size: 17px; font-weight: 700; margin: 0 0 18px; padding-bottom: 8px; border-bottom: 1.5px solid var(--ink); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.field label, .field .label { font-weight: 600; font-size: 15px; }
.hint { font-size: 13px; color: var(--ink-soft); line-height: 1.6; margin: 0; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.row2 .field { margin-bottom: 6px; }
.row2 + .hint { margin-bottom: 20px; }
.money { display: flex; align-items: stretch; border: 1.5px solid var(--ink); border-radius: 2px; background: var(--paper); }
.money:focus-within { outline: 3px solid var(--pen); outline-offset: 2px; }
.money input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--pen); font: 600 22px var(--font-print); padding: 9px 14px; direction: ltr; text-align: right; font-variant-numeric: tabular-nums; }
.money input:focus { outline: none; }
.money span { display: grid; place-items: center; padding: 0 14px; color: var(--ink-soft); font-size: 14px; border-inline-start: 1px solid var(--rule); white-space: nowrap; }
select { border: 1.5px solid var(--ink); border-radius: 2px; background: var(--paper); color: var(--pen); font: 600 16px var(--font-print); padding: 10px 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 15px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--pen); }
.error { color: var(--stamp); font-size: 14px; font-weight: 600; min-height: 1.4em; margin: 0; }

/* A choice between options: tick boxes, the chosen one crossed in pen */
.seg { display: flex; flex-wrap: wrap; gap: 2px 20px; }
.seg button { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; color: var(--ink); font: 500 15px var(--font-print); padding: 6px 0; cursor: pointer; }
.seg button::before { content: ""; flex: none; width: 16px; height: 16px; border: 1.5px solid var(--ink); background: var(--paper); }
.seg button[aria-pressed="true"]::before {
  background:
    linear-gradient(45deg, transparent 42%, var(--pen) 42% 58%, transparent 58%),
    linear-gradient(-45deg, transparent 42%, var(--pen) 42% 58%, transparent 58%),
    var(--paper);
}

/* The receipt */
.slip { background: var(--paper); border-radius: 2px; }
.slip-top { position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px; padding: 12px 24px; border-bottom: 2px dashed var(--rule); }
.slip-top::before, .slip-top::after { content: ""; position: absolute; bottom: -9px; width: 16px; height: 16px; border-radius: 50%; background: var(--desk); }
.slip-top::before { inset-inline-start: -8px; }
.slip-top::after { inset-inline-end: -8px; }
.slip-top h2 { font-size: 16px; font-weight: 600; margin: 0; }
.slip-top .seg button { font-size: 14px; padding-block: 2px; }
.slip-body { padding: 18px 24px 22px; overflow: clip; }
.net { font-weight: 600; font-size: clamp(40px, 7vw, 58px); line-height: 1.3; color: var(--pen); overflow-wrap: anywhere; }
.net .num { display: inline-block; border-bottom: 5px double currentColor; }
.net small { font-size: 16px; font-weight: 500; color: var(--ink); margin-inline-start: 10px; }
.words, .out {
  font-family: var(--font-hand); color: var(--pen); line-height: 2; overflow-wrap: anywhere;
  background: repeating-linear-gradient(to bottom, transparent 0 calc(2em - 1px), var(--rule) calc(2em - 1px) 2em) 0 -0.32em;
}
.words { font-size: clamp(20px, 2.5vw, 23px); margin: 8px 0 0; }
.out { font-size: clamp(26px, 3.6vw, 34px); margin: 0 0 18px; }
.slip-sub { font-size: 14px; color: var(--ink-soft); margin: 14px 0 0; }
.bar { display: flex; height: 14px; border: 1.5px solid var(--ink); margin-top: 14px; }
.bar i { display: block; transition: width .25s ease; }
.bar i + i { box-shadow: inset -1.5px 0 0 var(--ink); }
/* One ink, so the parts differ by pattern, not colour: solid, hatched, blank. */
.bar .b1, .dot.d1 { background: var(--ink); }
.bar .b2, .dot.d2 { background: repeating-linear-gradient(135deg, var(--ink) 0 1.5px, transparent 1.5px 4.5px); }
.bar .b3, .dot.d3 { background: transparent; }
.lines { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 6px; }
.lines li { display: flex; align-items: baseline; gap: 8px; font-size: 15px; }
.lines .k { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; }
.lines .k::after { content: ""; flex: 1; min-width: 12px; border-bottom: 1.5px dotted var(--ink-soft); opacity: .7; translate: 0 -4px; }
.lines .dot { flex: none; align-self: center; width: 12px; height: 12px; border: 1.5px solid var(--ink); }
.lines .v { font-weight: 600; color: var(--pen); white-space: nowrap; display: inline-flex; align-items: baseline; gap: 8px; }
.lines .pct { color: var(--ink-soft); font-weight: 400; font-size: 13px; min-width: 3.2em; text-align: left; }
.lines .total { border-top: 1.5px solid var(--ink); padding-top: 8px; margin-top: 4px; }
.slip-note { font-size: 14px; margin: 14px 0 0; }
.slip-note b { color: var(--pen); font-weight: 600; }
.slip-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; min-height: 58px; }
.copy { border: 1.5px solid var(--ink); border-radius: 2px; background: var(--paper); color: var(--ink); font: 600 14px var(--font-print); padding: 7px 18px; cursor: pointer; }
.copy:hover { background: var(--ink); color: var(--paper); }
.stamp { flex: none; display: grid; justify-items: center; margin-inline-start: auto; padding: 5px 12px 4px; border: 2px solid var(--stamp); border-radius: 3px; box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--stamp); color: var(--stamp); font-size: 12px; font-weight: 600; line-height: 1.5; rotate: -5deg; opacity: .9; animation: stamp-press .32s cubic-bezier(.2, .9, .3, 1) .45s backwards; }
.stamp b { font-size: 15px; font-weight: 700; letter-spacing: .5px; padding-inline: 6px; border-block: 1px solid var(--stamp); }
@keyframes stamp-press { from { opacity: 0; scale: 1.7; } }

/* Sections */
section { margin-top: 44px; }
section > h2 { font-size: 22px; font-weight: 700; line-height: 1.5; margin: 0 0 6px; text-wrap: balance; }
section > p { max-width: 68ch; margin: 0 0 14px; }

/* Tables: ledger sheets. A total takes a single rule above and a double rule below its figures. */
.scroll { overflow-x: auto; background: var(--paper); border-radius: 2px; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { padding: 10px 14px; text-align: start; border-bottom: 1px solid var(--rule); white-space: nowrap; }
th { font-size: 13px; font-weight: 600; border-bottom: 1.5px solid var(--ink); }
tbody tr:last-child:not(.sum) td { border-bottom: 0; }
td.n, th.n { text-align: end; font-variant-numeric: tabular-nums; }
td.wrapcell { white-space: normal; min-width: 220px; font-size: 14px; }
tr:not(.sum) td.wrapcell { color: var(--ink-soft); }
tr.off td { color: var(--ink-soft); }
tr.sum td { font-weight: 700; border-top: 1.5px solid var(--ink); border-bottom: 0; padding-bottom: 14px; }
tr.sum td.n {
  background:
    linear-gradient(var(--ink), var(--ink)) 0 calc(100% + 3px) / 100% 1.5px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 calc(100% + 7px) / 100% 1.5px no-repeat;
  background-origin: content-box; background-clip: padding-box;
}
.stepno { display: inline-block; min-width: 1.2em; margin-inline-end: 8px; text-align: center; color: var(--ink-soft); font-weight: 600; }

/* A note: the yellow duplicate sheet */
.note { background: var(--copy); border-radius: 2px; padding: 10px 14px; font-size: 14px; margin-top: 12px; max-width: 72ch; }
.links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.links a { background: var(--paper); border-bottom: 1.5px solid var(--rule); border-radius: 2px; padding: 3px 12px; font-size: 14px; text-decoration: none; }
.links a:hover { border-bottom-color: var(--pen); }
.faq { max-width: 72ch; margin-top: 10px; border-top: 1.5px solid var(--ink); }
.faq div { padding: 14px 0; border-bottom: 1px solid var(--rule); }
.faq h3 { font-size: 17px; font-weight: 600; margin: 0 0 4px; line-height: 1.6; }
.faq p { margin: 0; font-size: 15px; }
.sources { font-size: 14px; padding-inline-start: 20px; margin: 0; }
.sources li { margin-bottom: 4px; }
.reviewed { font-size: 13px; color: var(--ink-soft); }

/* The index of tools: one ruled row each */
.toolgrid { margin-top: 10px; border-top: 1.5px solid var(--ink); }
.toolcard { display: grid; grid-template-columns: minmax(0, 21em) minmax(0, 1fr); align-items: baseline; gap: 0 24px; padding: 11px 0; border-bottom: 1px solid var(--rule); text-decoration: none; color: var(--ink); }
.toolcard b { font-size: 17px; font-weight: 600; color: var(--pen); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.toolcard:hover b { text-decoration-thickness: 2px; }
.toolcard span { font-size: 15px; color: var(--ink-soft); }

.ad { margin-top: 28px; min-height: 100px; }
.adslot { border: 1.5px dashed var(--rule); color: var(--ink-soft); font-size: 13px; text-align: center; padding: 26px 12px; margin-top: 28px; }

/* Text pages */
.prose { max-width: 68ch; padding-top: 6px; }
.prose h2 { font-size: 20px; margin: 28px 0 6px; }
.prose p { margin: 0 0 12px; }

/* Footer */
.sitefoot { margin-top: 56px; border-top: 1.5px solid var(--ink); padding: 18px 0 36px; font-size: 13px; color: var(--ink-soft); }
.sitefoot nav { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-bottom: 8px; }
.sitefoot p { margin: 0; max-width: 78ch; }

@media (min-width: 821px) {
  .calc > .slip { position: sticky; top: 16px; }
}
@media (max-width: 820px) {
  .calc, .hero { grid-template-columns: minmax(0, 1fr); }
  .calc { gap: 28px; }
  .hero { gap: 28px; padding-top: 24px; }
  .slip-top { padding-inline: 18px; }
  .slip-body { padding: 16px 18px 20px; }
}
@media (max-width: 640px) {
  .sitenav { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 2px; scrollbar-width: none; }
  .toolcard { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .bar i { transition: none; }
  .stamp { animation: none; }
}
