/* konta.md/instrumente: the form beside its result, then the notes under them, for the salary calculator and the other tools. */

.calc {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(300px, 1.35fr);
  gap: clamp(24px, 4vw, 56px);
  align-items: start;
}

.calc__form {
  display: grid;
  gap: 18px;
}

.calc__hint {
  font-size: 0.8125rem;
  color: var(--ink-3);
}

.calc__error {
  font-size: 0.875rem;
  color: var(--down);
}

.calc__error[hidden],
.calc__capped[hidden] {
  display: none;
}

.field input[aria-invalid='true'] {
  border-color: var(--down);
}

.calc__check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.9375rem;
  color: var(--ink);
  cursor: pointer;
}

.calc__check input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--accent);
  flex: none;
}

.calc__check input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* A results table is a panel like the register: rounded corners, which a table only draws when
   its cells keep their own borders (separate, no spacing) and the corner cells are rounded too, so
   a row's background (the total) follows the corner. */
.calc__results {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  /* On dark, a panel like the register (--results-bg); on light, the page's own ground. */
  background: var(--results-bg, var(--bg));
  border: 1px solid var(--rule);
  border-top: 3px solid var(--gold-rule);
  border-radius: var(--radius);
  font-size: 0.9375rem;
}

.calc__results caption {
  caption-side: top;
  text-align: left;
  font-size: 0.8125rem;
  color: var(--ink-3);
  padding-bottom: 8px;
}

.calc__results th,
.calc__results td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--rule);
  vertical-align: baseline;
}

.calc__results th {
  text-align: left;
  font-weight: 400;
  color: var(--ink-2);
}

.calc__results td {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.calc__results tr:last-child th,
.calc__results tr:last-child td {
  border-bottom: 0;
}

.calc__results tr:first-child > :first-child {
  border-top-left-radius: calc(var(--radius) - 3px);
}

.calc__results tr:first-child > :last-child {
  border-top-right-radius: calc(var(--radius) - 3px);
}

.calc__results tr:last-child > :first-child {
  border-bottom-left-radius: calc(var(--radius) - 1px);
}

.calc__results tr:last-child > :last-child {
  border-bottom-right-radius: calc(var(--radius) - 1px);
}

.calc__results .calc__total th,
.calc__results .calc__total td {
  color: var(--ink);
  font-weight: 600;
  background: var(--sunken);
}

.calc__results--stale td {
  color: var(--ink-3);
}

/* Rolling digits (assets/roll.js): while a result changes, each digit is a wheel of 0 to 9 one
   line tall, turned to the new digit. The line's height comes from the cell (--roll-h), so the
   row keeps its size and the digits sit where the plain text sits once the wheels stop. */
.roll {
  display: inline-flex;
  vertical-align: top;
  height: var(--roll-h);
  line-height: var(--roll-h);
  user-select: none;
}

.roll__c,
.roll__d {
  display: block;
  height: var(--roll-h);
}

/* The space between thousands is a box of its own while the digits roll: kept, not collapsed,
   so the figure has its final width from the first frame. */
.roll__c {
  white-space: pre;
}

.roll__d {
  overflow: hidden;
  /* The digits rolling past fade at the wheel's edges rather than being cut by them. */
  -webkit-mask-image: linear-gradient(transparent, #000 18%, #000 82%, transparent);
  mask-image: linear-gradient(transparent, #000 18%, #000 82%, transparent);
}

.roll__strip,
.roll__strip > span {
  display: block;
}

.roll__strip > span {
  height: var(--roll-h);
  text-align: center;
}

.roll__d--go .roll__strip {
  /* A spring's settle: quick out of the old digit, a slight run past the new one, back. */
  transition: transform var(--roll-time, 650ms) cubic-bezier(0.22, 1.18, 0.36, 1);
}

.roll__d--new {
  animation: roll-in var(--roll-time, 650ms) ease-out;
}

@keyframes roll-in {
  from {
    opacity: 0;
  }
}

/* What screen readers are given while the wheels turn. */
.roll__said {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.calc__capped {
  margin-top: 14px;
  padding: 11px 15px;
  border-left: 2px solid var(--gold-rule);
  border-radius: var(--radius);
  background: var(--sunken);
  font-size: 0.9375rem;
  color: var(--ink);
}

.calc__not {
  padding-left: 1.2em;
}

.calc__not li + li {
  margin-top: 8px;
}

.calc__values td.calc__act {
  font-size: 0.8125rem;
  color: var(--ink-3);
}

@media (max-width: 760px) {
  .calc {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .calc__results th,
  .calc__results td {
    padding: 9px 10px;
  }

  .calc__results td {
    white-space: normal;
  }

  /* Each value on one line with its act under it, rather than three cramped columns. */
  .calc__values thead {
    display: none;
  }

  .calc__values tr {
    display: grid;
    grid-template-columns: 1fr auto;
    border-bottom: 1px solid var(--rule);
  }

  .calc__values tr:last-child {
    border-bottom: 0;
  }

  .calc__values td {
    border-bottom: 0;
  }

  .calc__values td.calc__act {
    grid-column: 1 / -1;
    padding-top: 0;
  }
}
