/* Zakat: the calculator, laid out as the app's screen is: groups of light cards on sandstone, each amount
   on its own ruled row, and the result in deep green. Tokens only, from styles.css. */

/* Without JavaScript the calculator can't work, so it isn't shown; the noscript note says so. */
html:not(.js) .calc { display: none; }


/* ── The calculator ──────────────────────────────── */
.calc { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr); gap: 28px 56px; align-items: start; }
.calc-form { grid-column: 1; grid-row: 1; display: grid; gap: 28px; }
.calc-result { grid-column: 2; grid-row: 1; position: sticky; top: 92px; }

/* A group: its title above a light card, as in the app */
.grp { border: 0; margin: 0; padding: 0; min-width: 0; }
.grp > legend { float: left; width: 100%; padding: 0 4px; margin: 0 0 10px; }
.grp > legend + * { clear: both; }
.card { background: var(--sheet); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 24px 48px -44px rgba(36, 33, 28, 0.45); }
.card.pad { padding: 16px; }

/* One amount: what it is on the left, the unit and the field on the right */
.amt { display: grid; grid-template-columns: minmax(0, 1fr) auto 128px; align-items: center; gap: 10px; padding: 14px 16px; }
.card > * + .amt { border-top: 1px solid var(--line); }
.amt label { display: grid; gap: 1px; cursor: text; }
.amt label span { font-weight: 500; }
.amt label small { font-size: 13.5px; line-height: 1.4; color: var(--muted); }
.amt .unit { font-size: 14px; color: var(--muted); text-align: right; }
.amt input { font: 500 16px var(--body); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; width: 100%; min-width: 0; text-align: right; font-variant-numeric: tabular-nums; }
.amt input::placeholder { color: var(--muted); opacity: 1; }
.amt input:focus-visible { outline: 2px solid var(--brass); outline-offset: 1px; border-color: var(--brass); }

/* A choice inside a card: the nisab, the carat */
.opt { border: 0; border-top: 1px solid var(--line); margin: 0; padding: 14px 16px 16px; min-width: 0; }
.opt > legend { float: left; width: 100%; padding: 0; margin: 0 0 10px; font-weight: 500; }
.opt > legend + * { clear: both; }
.opt > small { display: block; margin-top: 10px; font-size: 13.5px; line-height: 1.45; color: var(--muted); }
.opt > small:empty { display: none; }
.cur-note { display: block; margin-top: 12px; font-size: 13.5px; line-height: 1.45; color: var(--muted); }
/* The carat belongs to the gold above it, so no rule between them */
.opt.carat { border-top: 0; padding-top: 0; }
.opt.carat > legend { font-weight: 400; font-size: 13.5px; color: var(--muted); margin-bottom: 8px; }
.calc .choice span { font-size: 14px; padding: 6px 13px; }
.calc .choice input:checked + span { border-color: var(--deep); }

.calc-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; font-size: 14px; color: var(--muted); }

/* The result, in the app's deep green card */
.calc-result { background: var(--deep); color: var(--on-deep); border-radius: 26px; padding: 26px 26px 24px; box-shadow: 0 34px 60px -40px rgba(23, 77, 64, 0.7); }
/* "Put this example in the calculator" moves focus here; keep the card's own corners for the ring */
.calc-result:focus { outline: none; }
.calc-result:focus-visible { outline: 2px solid var(--brass); outline-offset: 4px; }
.calc-result .label { color: var(--on-deep); opacity: 0.75; }
.calc-result .due { font-family: var(--display); font-size: clamp(40px, 4.6vw, 58px); line-height: 1.12; margin-top: 8px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.calc-result .msg { margin-top: 8px; font-size: 15.5px; line-height: 1.5; opacity: 0.9; }
.calc-result .state { margin-top: 18px; display: inline-flex; align-items: center; gap: 9px; font-family: var(--display); font-size: 11.5px; letter-spacing: 0.2em; text-transform: uppercase; border: 1px solid color-mix(in srgb, var(--on-deep) 30%, transparent); border-radius: 999px; padding: 6px 13px 6px 10px; }
.calc-result .state::before { content: ''; flex: none; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid currentColor; opacity: 0.7; }
.calc-result[data-state='price'] .state::before { background: var(--sunrise); border-color: var(--sunrise); opacity: 1; }
.calc-result[data-state='below'] .state::before { background: currentColor; opacity: 0.6; }
.calc-result[data-state='above'] .state::before { background: var(--sunrise); border-color: var(--sunrise); opacity: 1; box-shadow: 0 0 0 4px color-mix(in srgb, var(--sunrise) 28%, transparent); }
.sums { margin: 20px 0 0; padding-top: 6px; border-top: 1px solid color-mix(in srgb, var(--on-deep) 22%, transparent); display: grid; font-size: 14.5px; }
.sums[hidden] { display: none; }
.sums div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 6px 0; }
.sums dt { opacity: 0.8; }
.sums dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 500; text-align: right; }
.sums .sum { border-top: 1px solid color-mix(in srgb, var(--on-deep) 22%, transparent); margin-top: 4px; padding-top: 10px; }

.ruling { margin-top: 40px; max-width: 760px; }
.nojs { max-width: 760px; }

/* The hero above is on the same sandstone, so the calculator needn't wait a whole section's gap */
#calculator { padding-top: 40px; scroll-margin-top: 72px; }
/* A focused field stays clear of the sticky header above and the phone's small total below */
.calc input { scroll-margin: 96px 0 110px; }

/* A phone's small total, kept at the foot of the screen while the result card is scrolled away */
.calc-peek { display: none; }

@media (max-width: 920px) {
  .calc { grid-template-columns: minmax(0, 1fr); }
  .calc-form, .calc-result { grid-column: auto; grid-row: auto; }
  .calc-result { position: static; }
  .calc-peek { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; position: sticky; bottom: max(12px, env(safe-area-inset-bottom, 0px)); z-index: 5; background: var(--deep); color: var(--on-deep); border-radius: 18px; padding: 12px 18px; box-shadow: 0 18px 40px -16px rgba(23, 77, 64, 0.75); opacity: 0; transform: translateY(10px); transition: opacity 0.25s, transform 0.25s; pointer-events: none; }
  .calc-peek.show { opacity: 1; transform: none; }
  .calc-peek .label { color: var(--on-deep); opacity: 0.75; font-size: 11px; }
  .calc-peek b { font-family: var(--display); font-weight: 400; font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; }
  .calc-peek .peek-state { margin-left: auto; font-size: 13px; opacity: 0.85; }
}
@media (max-width: 480px) {
  .amt { grid-template-columns: minmax(0, 1fr) auto 108px; gap: 8px; padding: 13px 14px; }
  .opt { padding-left: 14px; padding-right: 14px; }
  .card.pad { padding: 14px; }
  .calc .choice span { padding: 6px 11px; font-size: 13.5px; }
  .calc-result { padding: 22px 20px 20px; border-radius: 22px; }
}
@media (prefers-reduced-motion: reduce) { .calc-peek { transition: none; transform: none; } }

/* ── The worked example and the steps ────────────── */
.example dl { margin: 0; }
.example dd { margin: 0; }
.example .line:not(:has(.else)) .ours { grid-row: auto; }
.example .line.strong { border-bottom: 1px solid var(--ink); }
.example .line.strong .what { font-weight: 600; }
.example .line .ours.minus { color: var(--ink); }
.example .try { margin-top: 18px; }
.how { list-style: none; counter-reset: step; margin: 22px 0 0; padding: 0; display: grid; gap: 16px; }
.how li { counter-increment: step; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 14px; font-size: 16px; color: var(--muted); }
.how li::before { content: counter(step); width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--gold); display: grid; place-items: center; font-family: var(--display); font-size: 14px; color: var(--ink); margin-top: -2px; }
.how b { color: var(--ink); font-weight: 600; }
.ledger aside .aside-note { margin-top: 24px; border-left: 2px solid var(--gold); padding-left: 16px; font-size: 15.5px; color: var(--ink); }
