/* ==========================================================================
   PiPO HRIS — LAYER 22 · CALCULATORS
   The brief: simple, not clever. Someone who has never run a payroll should be
   able to open one of these, type one number, and understand the answer.

   So: one question at a time, plain words, big readable fields, and a result
   panel that leads with the single figure that was actually wanted. Anything
   that is not needed to get an answer is behind a disclosure. Notes sit below
   the calculator, never beside it.
   ========================================================================== */

.calc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.06fr);
  gap: clamp(20px, 2.4vw, 40px);
  align-items: start;
  margin-top: clamp(20px, 2.4vw, 32px);
}
@media (max-width: 960px) { .calc { grid-template-columns: 1fr; } }
.calc > * { min-width: 0; }

/* ── The form ───────────────────────────────────────────────────────────── */
.calc__form {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: clamp(18px, 2.2vw, 28px);
  box-shadow: 0 1px 2px rgba(11,26,22,.04), 0 8px 24px -16px rgba(11,26,22,.18);
}
.calc__legend {
  display: block; width: 100%;
  font-family: var(--font-mono); font-size: .62rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--gold-ink);
  padding-bottom: .7rem; margin-bottom: 1rem;
  border-bottom: 2px solid var(--gold);
}
.calc__grid + .calc__legend, .calc__seg + .calc__legend { margin-top: 1.7rem; }

/* One column by default — two only where the pair genuinely belongs together. */
.calc__grid { display: grid; grid-template-columns: 1fr; gap: 14px 16px; }
.calc__grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 460px) { .calc__grid--2 { grid-template-columns: 1fr; } }

.calc__f { display: grid; gap: .3rem; min-width: 0; }
.calc__f--full { grid-column: 1 / -1; }
.calc__f label {
  font-size: .87rem; font-weight: 600; color: var(--ink);
  line-height: 1.35;
}
.calc__f .hint { font-size: .76rem; line-height: 1.45; color: var(--muted); }

/* A money field wears its currency, so nobody wonders what unit to type in. */
.calc__in { position: relative; display: block; }
.calc__in::before {
  content: 'KES'; position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%); pointer-events: none;
  font-family: var(--font-mono); font-size: .66rem; letter-spacing: .06em;
  color: var(--muted-2);
}
.calc__in--pct::before { content: '%'; font-size: .82rem; letter-spacing: 0; }
.calc__in--n::before { content: none; }
.calc__in > input { padding-left: 46px !important; }
.calc__in--pct > input, .calc__in--n > input { padding-left: .85rem !important; }

.calc__f input, .calc__f select {
  font: inherit; font-size: 1rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
  width: 100%; min-height: 48px; padding: .6rem .85rem;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-btn);
  transition: border-color var(--t-fast) var(--e-out),
              background var(--t-fast) var(--e-out);
}
.calc__f select { font-weight: 500; }
.calc__f input:hover, .calc__f select:hover { border-color: var(--emerald-300); }
.calc__f input:focus, .calc__f select:focus {
  outline: 2px solid var(--emerald); outline-offset: 1px;
  border-color: var(--emerald); background: #fff;
}

/* ── The switch ─────────────────────────────────────────────────────────── */
.calc__seg { display: block; margin-bottom: 1.15rem; }
.calc__seg > span {
  display: block; font-size: .87rem; font-weight: 600;
  color: var(--ink); margin-bottom: .45rem;
}
.calc__segs {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  gap: 4px; padding: 4px; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--r-btn);
}
@media (max-width: 460px) {
  .calc__segs--wrap { grid-auto-flow: row; grid-auto-columns: auto; }
}
.calc__segs label {
  position: relative; display: flex; align-items: center; justify-content: center;
  text-align: center; min-height: 42px; padding: .4rem .5rem;
  font-size: .85rem; font-weight: 600; color: var(--muted);
  border-radius: calc(var(--r-btn) - 3px); cursor: pointer;
  transition: background var(--t-fast) var(--e-out), color var(--t-fast) var(--e-out);
}
.calc__segs input {
  position: absolute; inset: 0; margin: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; appearance: none; min-height: 0;
}
.calc__segs label:hover { color: var(--ink); }
.calc__segs label:has(input:checked) { background: var(--emerald); color: #fff; }
.calc__segs label:has(input:focus-visible) { outline: 2px solid var(--emerald); outline-offset: 2px; }

/* ── Disclosure. NOTE: it must not introduce a grid of its own — a grid
   inside a grid makes every field a single cell of the outer one, which is
   what squeezed the inputs into half their column. ─────────────────────── */
.calc__more { margin-top: 1.2rem; border-top: 1px solid var(--line-soft); }
.calc__more > summary {
  list-style: none; cursor: pointer; padding: .85rem 0 .1rem;
  font-size: .87rem; font-weight: 600; color: var(--emerald-700);
  display: flex; align-items: center; gap: .55rem;
}
.calc__more > summary::-webkit-details-marker { display: none; }
.calc__more > summary::before {
  content: ''; width: 8px; height: 8px; flex: none;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform var(--t-fast) var(--e-out);
}
.calc__more[open] > summary::before { transform: rotate(-135deg) translate(-3px, -3px); }
.calc__more > summary:focus-visible { outline: 2px solid var(--emerald); outline-offset: 2px; }
.calc__more > .calc__grid { margin-top: .9rem; }

.calc__check {
  grid-column: 1 / -1; display: flex; align-items: center; gap: .6rem;
  font-size: .87rem; color: var(--ink); line-height: 1.4;
  min-height: 24px; cursor: pointer;
}
.calc__check input {
  width: 24px; height: 24px; min-height: 24px; flex: none;
  margin: 0; padding: 3px; accent-color: var(--emerald); cursor: pointer;
}

/* ── The answer ─────────────────────────────────────────────────────────── */
.calc__out { position: sticky; top: calc(var(--hdr-h) + 16px); }
@media (max-width: 960px) { .calc__out { position: static; } }
.calc__card {
  background: var(--ground); color: rgba(255,255,255,.82);
  border-radius: var(--r-lg); overflow: hidden;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 18px 44px -28px rgba(6,52,42,.7);
}
.calc__head {
  padding: clamp(20px, 2.4vw, 28px);
  border-bottom: 1px solid rgba(255,255,255,.12);
  background:
    radial-gradient(520px 260px at 90% 0%, rgba(63,50,141,.36), transparent 66%),
    radial-gradient(420px 220px at 6% 100%, rgba(153,42,144,.18), transparent 66%);
}
.calc__k {
  font-family: var(--font-mono); font-size: .62rem; letter-spacing: .15em;
  text-transform: uppercase; color: var(--gold-lt);
}
.calc__big {
  font-family: var(--font-display); font-size: clamp(2.1rem, 4vw, 3rem);
  font-weight: 800; letter-spacing: -.045em; line-height: 1; color: #fff;
  margin-top: .5rem; font-variant-numeric: tabular-nums;
}
.calc__big .cur { font-size: .4em; font-weight: 600; color: var(--gold-lt); margin-right: .35rem; letter-spacing: 0; }
.calc__sub { font-size: .88rem; line-height: 1.55; color: rgba(255,255,255,.66); margin-top: .65rem; }

.calc__bar { height: 8px; border-radius: 100px; background: rgba(255,255,255,.14); margin-top: 1rem; overflow: hidden; }
.calc__bar i {
  display: block; height: 100%; border-radius: 100px;
  background: linear-gradient(90deg, var(--emerald-400), var(--gold));
  transition: width var(--t-std) var(--e-out);
}
.calc__barl {
  display: flex; justify-content: space-between; gap: 1rem;
  font-family: var(--font-mono); font-size: .62rem; letter-spacing: .08em;
  text-transform: uppercase; color: rgba(255,255,255,.55); margin-top: .45rem;
}

.calc__rows { padding: clamp(12px, 1.6vw, 18px) clamp(20px, 2.4vw, 28px) clamp(18px, 2.2vw, 26px); }
.calc__r {
  display: grid; grid-template-columns: 1fr auto; gap: 1rem;
  align-items: baseline; padding: .5rem 0;
  border-bottom: 1px solid rgba(255,255,255,.08);
  font-size: .92rem;
}
.calc__r:last-child { border-bottom: 0; }
.calc__r > span:first-child { color: rgba(255,255,255,.76); }
.calc__r b {
  font-family: var(--font-mono); font-size: .93rem; font-weight: 500;
  color: #fff; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.calc__r small { display: block; font-size: .73rem; color: rgba(255,255,255,.5); margin-top: .1rem; }
.calc__r--sum { border-top: 1px solid rgba(255,255,255,.22); border-bottom: 0; margin-top: .35rem; padding-top: .75rem; }
.calc__r--sum > span:first-child { color: #fff; font-weight: 600; }
.calc__r--gold b, .calc__r--gold > span:first-child { color: var(--gold-lt); }
.calc__r--minus b { color: rgba(255,255,255,.88); }
.calc__r--minus b::before { content: '\2212'; opacity: .55; margin-right: .1em; }
.calc__r--minus[data-zero] b::before { content: none; }

.calc__rh {
  display: block;
  font-family: var(--font-mono); font-size: .58rem; letter-spacing: .15em;
  text-transform: uppercase; color: var(--gold-lt);
  padding: 1rem 0 .35rem; border-bottom: 1px solid rgba(255,255,255,.12);
}
.calc__rows > .calc__rh:first-child { padding-top: 0; }
.calc__r[hidden], .calc__f[hidden], .calc__rh[hidden], .calc__seg[hidden] { display: none; }

/* Employee or employer is a state on the card, not an attribute on each row —
   otherwise it fights the rule above that hides a row with nothing in it. */
[data-showing="employee"] [data-view="employer"],
[data-showing="employer"] [data-view="employee"] { display: none; }

/* ── Two figures set against each other ─────────────────────────────────── */
.calc__pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: rgba(255,255,255,.12); }
@media (max-width: 420px) { .calc__pair { grid-template-columns: 1fr; } }
.calc__pair > div { background: var(--ground); padding: .95rem clamp(16px, 2vw, 22px); }
.calc__pair span {
  display: block;
  font-family: var(--font-mono); font-size: .58rem; letter-spacing: .13em;
  text-transform: uppercase; color: rgba(255,255,255,.55);
}
.calc__pair b {
  display: block; margin-top: .25rem;
  font-family: var(--font-display); font-size: 1.35rem; font-weight: 700;
  color: #fff; letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}
.calc__pair small { display: block; font-size: .72rem; color: rgba(255,255,255,.5); margin-top: .2rem; }
.calc__pair--vs > div:first-child { background: rgba(255,255,255,.05); }

/* ── A verdict — one line, plain words ──────────────────────────────────── */
.calc__verdict {
  margin: 0; padding: .9rem clamp(20px, 2.4vw, 28px);
  font-size: .92rem; line-height: 1.5; font-weight: 600;
  border-top: 1px solid rgba(255,255,255,.12);
}
.calc__verdict[hidden] { display: none; }
.calc__verdict--ok  { background: rgba(19,185,129,.20); color: var(--emerald-300); }
.calc__verdict--bad { background: rgba(176,134,43,.24); color: var(--gold-lt); }
.calc__verdict small { display: block; font-weight: 400; margin-top: .2rem; color: rgba(255,255,255,.74); }

/* ── A note that appears only when its rule has fired ───────────────────── */
.calc__why {
  margin: 0; padding: .75rem clamp(20px, 2.4vw, 28px);
  background: rgba(19,185,129,.12);
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: .84rem; line-height: 1.55; color: rgba(255,255,255,.84);
}
.calc__why[hidden] { display: none; }
.calc__why b { color: var(--emerald-300); font-weight: 600; }

.calc__floor {
  margin: 0; padding: .8rem clamp(20px, 2.4vw, 28px);
  background: rgba(176,134,43,.2);
  border-top: 1px solid var(--st-warning);
  font-size: .84rem; line-height: 1.55; color: var(--gold-lt);
}
.calc__floor[hidden] { display: none; }

.calc__err {
  padding: 1.2rem; font-size: .94rem; line-height: 1.6;
  color: var(--st-error); background: var(--st-error-bg);
  border-radius: var(--r); border-left: 3px solid var(--st-error);
}

/* ── Below the calculator ───────────────────────────────────────────────── */
.calc__notes {
  margin-top: clamp(28px, 3.2vw, 46px);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: clamp(14px, 1.6vw, 22px);
}
.calc__note {
  background: var(--mist); border: 1px solid var(--line-soft);
  border-radius: var(--r-lg); padding: clamp(16px, 1.9vw, 24px);
}
.calc__note h2 {
  font-family: var(--font-mono); font-size: .6rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--emerald-700); margin: 0 0 .7rem;
}
.calc__note p { font-size: .89rem; line-height: 1.65; color: var(--ink-3); margin: 0 0 .6rem; }
.calc__note p:last-child { margin-bottom: 0; }
.calc__note b { color: var(--ink); font-weight: 600; }
.calc__note ul { margin: 0; padding-left: 1.05rem; }
.calc__note li { font-size: .89rem; line-height: 1.6; color: var(--ink-3); margin-bottom: .4rem; }
.calc__note li:last-child { margin-bottom: 0; }
.calc__note--ask { background: var(--gold-tint); border-color: var(--gold-line); }
.calc__note--ask h2 { color: var(--gold-ink); }
.calc__note--ask a {
  color: var(--gold-ink); font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px;
}

/* ── The line that says where the figures come from ─────────────────────── */
.calc__src {
  margin-top: clamp(18px, 2vw, 26px); padding: .85rem 1.1rem;
  background: var(--paper); border-left: 3px solid var(--line);
  border-radius: 0 var(--r) var(--r) 0;
  font-size: .82rem; line-height: 1.6; color: var(--muted); max-width: 88ch;
}
.calc__src b { color: var(--ink-3); font-weight: 600; }
.calc__src a { color: var(--emerald-700); text-decoration: underline; text-underline-offset: 2px; }
.calc__src time { font-family: var(--font-mono); font-size: .94em; }

.calc__prov {
  margin: 0 0 clamp(16px, 2vw, 24px); padding: .9rem 1.1rem;
  background: var(--st-warning-bg); border: 1px solid var(--st-warning);
  border-left-width: 4px; border-radius: var(--r);
  font-size: .9rem; line-height: 1.6; color: var(--st-warning-ink); max-width: 84ch;
}
.calc__prov b { color: var(--st-warning-ink); }
.calc__prov[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) { .calc__bar i { transition: none; } }

/* ── The lead-in above a calculator ──────────────────────────────────── */

/* The lead-in above a calculator is one short paragraph, not an essay. */
.calc-sec { padding-block: clamp(26px, 3vw, 48px); }
.tpl-hero--tight + .tpl-intro { padding-block: clamp(20px, 2.2vw, 32px); }
.tpl-hero--tight + .tpl-intro p { font-size: 1rem; max-width: 74ch; }

/* The percentage sits after the figure, where a person would write it. */
.calc__in--pct::before { content: none; }
.calc__in--pct::after {
  content: '%'; position: absolute; right: 14px; top: 50%;
  transform: translateY(-50%); pointer-events: none;
  font-size: .9rem; font-weight: 600; color: var(--muted-2);
}
.calc__in--pct > input { padding-right: 32px !important; }

/* A one-line recommendation under a switch, where one option is the better
   default but the other is legitimate. */
.calc__rec {
  margin: -.55rem 0 1.1rem; font-size: .78rem; line-height: 1.5;
  color: var(--emerald-700);
}
