/* Take-home pay calculator: page-specific styles, built on the shared tokens in /assets/css/site.css */

/* Step numbers in the panel headings, styled like spreadsheet row headers */
.thp-step {
  display: inline-grid;
  place-items: center;
  min-width: 2.1rem;
  height: 1.6rem;
  padding: 0 0.4rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.thp-rule {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 0.25rem 0 0;
}

/* Amount + period on one line, wrapping on narrow screens */
.thp-pay-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: stretch;
}
.thp-pay-amount { flex: 1 1 11rem; min-width: 0; }
.thp-period { flex: 1 1 8rem; max-width: 100%; }
@media (min-width: 420px) {
  .thp-period { flex: 0 0 9.5rem; }
}

.thp-pension-input { max-width: 11rem; }

.thp-examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: -0.5rem;
}
.thp-examples .btn { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.thp-form-foot { align-items: center; gap: 0.75rem; }

/* Results hero: label and the Year / Month / Week switch on one row */
.thp-hero-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.35rem;
}
.thp-view { border: 0; padding: 0; margin: 0; }
.thp-view .segmented-options span { min-height: 30px; padding: 0 0.75rem; font-size: 0.8125rem; }
#thp-hero { display: block; }

/* Stacked bar: where each pound goes */
.thp-chart { margin: 1.75rem 0 0; }
.thp-chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-bottom: 0.7rem;
}
.thp-bar {
  display: flex;
  gap: 2px;                 /* the surface gap between segments */
  height: 20px;
  border-radius: var(--radius-xs);
  overflow: hidden;
}
.thp-seg {
  flex: 1 1 0;
  min-width: 3px;
  background: var(--seg-colour, var(--chart-6));
  transition: flex-grow var(--dur-slow) var(--ease), opacity var(--dur) var(--ease), filter var(--dur) var(--ease);
  cursor: default;
}
.thp-seg:first-child { border-radius: var(--radius-xs) 0 0 var(--radius-xs); }
.thp-seg:last-child { border-radius: 0 var(--radius-xs) var(--radius-xs) 0; }
.thp-seg:only-child { border-radius: var(--radius-xs); }
.thp-seg.is-empty { background: var(--surface-2); border: 1px dashed var(--border-strong); }

.thp-chart[data-active] .thp-seg:not([data-key="x"]) { opacity: 0.35; }
.thp-chart[data-active="takeHome"] .thp-seg[data-key="takeHome"],
.thp-chart[data-active="incomeTax"] .thp-seg[data-key="incomeTax"],
.thp-chart[data-active="ni"] .thp-seg[data-key="ni"],
.thp-chart[data-active="loans"] .thp-seg[data-key="loans"],
.thp-chart[data-active="pension"] .thp-seg[data-key="pension"] { opacity: 1; filter: saturate(1.15); }

.thp-legend {
  list-style: none;
  margin: 0.9rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.1rem;
  font-size: var(--fs-sm);
}
.thp-legend li {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto 3.75rem;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.5rem;
  margin-inline: -0.5rem;
  border-radius: var(--radius-sm);
  transition: background-color var(--dur-fast) var(--ease);
}
.thp-legend li:hover { background: var(--surface-hover); }
.thp-legend li.is-zero { color: var(--text-faint); }
.thp-legend-name { color: var(--text-muted); min-width: 0; overflow-wrap: anywhere; }
.thp-legend-val { font-variant-numeric: tabular-nums; font-weight: 560; color: var(--text); text-align: right; }
.thp-legend-pct { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; }
.thp-legend li.is-zero .thp-legend-name,
.thp-legend li.is-zero .thp-legend-val { color: var(--text-faint); }
.thp-chart[data-active] .thp-legend li:not(:hover) { opacity: 0.7; }

@media (max-width: 359px) {
  .thp-legend li { grid-template-columns: 10px minmax(0, 1fr) auto; }
  .thp-legend-pct { display: none; }
}

/* Breakdown table */
.thp-table th[scope="row"] { font-weight: 520; }
.thp-table .thp-deduct td { color: var(--text-muted); }
.thp-table .thp-memo th,
.thp-table .thp-memo td { color: var(--text-faint); font-style: italic; }
.thp-memo-tag {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-style: normal;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  vertical-align: 1px;
}
.thp-table td.num, .thp-table tfoot td { white-space: nowrap; }

#thp-bands .thp-zero th,
#thp-bands .thp-zero td { color: var(--text-faint); }

.thp-trap { margin-bottom: 0; }

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

/* Compact stats: two or three across, even on small phones */
.thp-stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 7.25rem), 1fr)); gap: 0.6rem; }

@media (max-width: 479px) {
  .thp-table th, .thp-table td { padding-inline: 0.65rem; }
}

.thp-pension-note { margin: 0.75rem 0 0; }

/* Seven-figure take-home amounts step down a size so they stay on one line at 320px */
#thp-hero.is-long { font-size: clamp(1.75rem, 1.25rem + 2.4vw, 3rem); }
