/* Property tax calculator.
 *
 * Loaded only by /property-tax-calculator/. Kept out of styles.css so the
 * generated production stylesheet stays a pure product of the transform, and
 * so shipping this page cannot alter any existing page.
 *
 * Every colour here resolves through an existing custom property. No hex,
 * rgb, or hsl literal appears below -- the five-colour system is the source.
 */

.calc-form {
  margin: 1.5rem 0 0;
  padding: 1.5rem;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

/* Each fieldset is one year's assumptions. The grouping is the correction:
 * the seller's certified bill and the buyer's intended filing are separate
 * questions, and a legend is what tells a reader which year an answer lands in.
 * Native fieldset chrome is removed; the rule above the legend carries it. */
.calc-fieldset {
  border: 0;
  border-top: 1px solid var(--line);
  padding: 1.25rem 0 0;
  margin: 1.5rem 0 0;
  min-inline-size: 0;
}

.calc-fieldset:first-of-type {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.calc-fieldset legend {
  padding: 0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.calc-legend-note {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.5rem 0 1rem;
  max-width: 46ch;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem 1.25rem;
  margin: 0;
}

.calc-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
}

.calc-field label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.calc-hint {
  font-weight: 400;
  color: var(--muted);
}

.calc-field input,
.calc-field select {
  /* 999px is the pill radius the released design system uses for controls. */
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
  padding: 0.6rem 1rem;
  font: inherit;
  font-size: 1rem;
  width: 100%;
}

.calc-field input:focus-visible,
.calc-field select:focus-visible,
.calc-checks input:focus-visible {
  outline: 2px solid var(--champagne);
  outline-offset: 2px;
}

.calc-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin: 1.25rem 0 1rem;
}

.calc-checks label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: var(--ink);
}

/* Errors are marked by weight, a rule, and a glyph rather than by colour.
 * The five-colour system has no error red, and inventing one would fork it --
 * but the more useful consequence is that the state does not depend on colour
 * perception, which is what WCAG 1.4.1 asks for anyway. */
.calc-error {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  border-left: 3px solid var(--line-strong);
  padding-left: 0.6rem;
  margin-top: 0.15rem;
}

.calc-error::before {
  content: "! ";
  font-weight: 700;
}

.calc-field input[aria-invalid="true"],
.calc-field select[aria-invalid="true"] {
  border-width: 2px;
  border-color: var(--line-strong);
}

.calc-scope-error {
  font-weight: 600;
  color: var(--ink);
  background: var(--surface-soft);
  border-left: 3px solid var(--line-strong);
  padding: 0.9rem 1.1rem;
  margin: 0 0 1.25rem;
  max-width: 68ch;
}

.calc-scope-error:focus-visible {
  outline: 2px solid var(--champagne);
  outline-offset: 2px;
}

/* The results container takes focus when it is revealed, so it needs a visible
 * focus ring like any other focus target. */
.calc-result:focus-visible {
  outline: 2px solid var(--champagne);
  outline-offset: 4px;
}

/* Announced, not shown. */
.calc-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.calc-note,
.calc-provenance,
.calc-disclaimer {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.75rem 0 0;
}

.calc-disclaimer {
  margin-top: 1.25rem;
  max-width: 68ch;
}

.calc-result {
  margin-top: 2rem;
}

.calc-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0 1.5rem;
  /* Rows stay square; only controls take the pill radius. */
  border: 1px solid var(--line);
}

.calc-table caption {
  caption-side: top;
  text-align: left;
  font-size: 0.85rem;
  color: var(--muted);
  padding-bottom: 0.5rem;
}

.calc-table th,
.calc-table td {
  padding: 0.65rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}

.calc-table thead th {
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.calc-table tbody th {
  font-weight: 500;
  color: var(--ink);
}

.calc-table td {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

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

/* The escrow reset is the number the page exists for, so it is the only row
 * that carries the gold rule. Gold never carries text on cream -- it fails
 * contrast at 2.16:1 -- so it is used here as a border only. */
.calc-row-emphasis th,
.calc-row-emphasis td {
  border-top: 2px solid var(--line-strong);
  border-bottom: 2px solid var(--line-strong);
  font-weight: 700;
}

/* The assumptions table carries sentences, not figures, so it opts out of the
 * right-aligned tabular-numeral treatment the money tables use. */
.calc-table-assumptions td {
  text-align: left;
  font-variant-numeric: normal;
  color: var(--muted);
}

@media (max-width: 30rem) {
  .calc-table-breakdown {
    display: block;
    overflow-x: auto;
  }
}
