/* Pennycalc - shared styles.
   Colour idea: the four deductions borrow the colours of the polymer notes
   (£20 purple, £10 orange, £5 turquoise, £50 red) so each slice of a payslip
   is recognisable at a glance. Take-home is the one green. */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/assets/fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("/assets/fonts/source-serif-4-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;

  --paper: #f1f4f5;
  --surface: #ffffff;
  --ink: #16262b;
  --ink-soft: #485b61;
  --line: #d3dcdf;
  --field: #6f868d;

  --take-home: #0c7a52;
  --tax: #6a3fa0;
  --ni: #e0731f;
  --loan: #0e8da1;
  --pension: #b8243c;

  --sans: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;

  --gutter: clamp(16px, 4vw, 40px);
  --measure: 38rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.65;
}

img,
svg {
  max-width: 100%;
}

a {
  color: var(--take-home);
  text-underline-offset: 0.18em;
}
a:hover {
  color: var(--ink);
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  background: var(--ink);
  color: #fff;
  padding: 0.6rem 1rem;
  font-family: var(--sans);
  z-index: 10;
}
.skip-link:focus {
  top: 0.75rem;
}

.wrap {
  width: 100%;
  max-width: 72rem;
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

/* ---------- header / footer ---------- */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--sans);
  font-weight: 800;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-decoration: none;
}
.wordmark:hover {
  color: var(--ink);
}
.wordmark svg {
  width: 1.5rem;
  height: 1.5rem;
  flex: none;
}
.site-nav {
  display: flex;
  gap: 1.4rem;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 1rem;
}
.site-nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover,
.site-nav a[aria-current="page"] {
  border-bottom-color: var(--ink);
}

.site-footer {
  margin-top: 4rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--ink-soft);
}
.site-footer__inner {
  padding-top: 1.75rem;
  padding-bottom: 2.5rem;
  display: grid;
  gap: 0.75rem;
}
.site-footer p {
  margin: 0;
  max-width: 46rem;
}
.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
}
.site-footer a {
  color: var(--ink);
}

/* ---------- page heading ---------- */

.page-head {
  padding-top: clamp(1.75rem, 4vw, 3rem);
  padding-bottom: clamp(1.25rem, 3vw, 2rem);
}
.page-head h1 {
  margin: 0;
  max-width: 20ch;
  font-family: var(--sans);
  font-weight: 750;
  font-size: clamp(2.1rem, 5vw, 3.3rem);
  line-height: 1.04;
  letter-spacing: -0.03em;
}
.page-head p {
  margin: 0.9rem 0 0;
  max-width: var(--measure);
  color: var(--ink-soft);
}

/* ---------- calculator ---------- */

.calc {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}
@media (min-width: 900px) {
  .calc {
    grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
    gap: 2.5rem;
  }
  .payslip {
    position: sticky;
    top: 1rem;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: clamp(1.1rem, 3vw, 1.75rem);
}

.form {
  display: grid;
  gap: 1.35rem;
  font-family: var(--sans);
}
.field {
  display: grid;
  gap: 0.4rem;
}
.field > label,
.field > .label,
.fieldset > label,
.fieldset > .label,
.fieldset legend {
  font-weight: 600;
  font-size: 1rem;
  padding: 0;
}
.hint {
  font-size: 0.9rem;
  color: var(--ink-soft);
  font-weight: 400;
}
.fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
  min-width: 0;
}

.input,
.select {
  width: 100%;
  min-height: 2.9rem;
  padding: 0.55rem 0.8rem;
  font: 500 1.1rem var(--sans);
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--field);
  border-radius: 7px;
}
.select {
  appearance: none;
  padding-right: 2.4rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1.5l6 6 6-6' fill='none' stroke='%2316262b' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
}
.input:focus-visible,
.select:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 1px;
}
.input[aria-invalid="true"] {
  border-color: var(--pension);
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr);
  gap: 0.6rem;
}
.input-row--stack {
  grid-template-columns: minmax(0, 1fr);
}
.input-row--stack > .suffix {
  max-width: 11rem;
}
.prefix {
  position: relative;
}
.prefix > span {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  font: 500 1.1rem var(--sans);
  color: var(--ink-soft);
  pointer-events: none;
}
.prefix > .input {
  padding-left: 1.7rem;
}
.suffix {
  position: relative;
}
.suffix > span {
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  font: 500 1.1rem var(--sans);
  color: var(--ink-soft);
  pointer-events: none;
}
.suffix > .input {
  padding-right: 2rem;
}

.error {
  margin: 0;
  color: var(--pension);
  font-size: 0.95rem;
  font-weight: 500;
}

.check {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  font-weight: 500;
  font-size: 1rem;
}
.check input {
  width: 1.25rem;
  height: 1.25rem;
  margin: 0.15rem 0 0;
  accent-color: var(--ink);
  flex: none;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- payslip (results) ---------- */

.payslip {
  font-family: var(--sans);
}
.payslip__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.payslip h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.seg {
  display: inline-flex;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  overflow: hidden;
}
.seg label {
  position: relative;
  cursor: pointer;
}
.seg input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}
.seg span {
  display: block;
  padding: 0.4rem 0.85rem;
  font-weight: 600;
  font-size: 0.95rem;
}
.seg input:checked + span {
  background: var(--ink);
  color: #fff;
}
.seg input:focus-visible + span {
  outline: 3px solid var(--ink);
  outline-offset: -5px;
  box-shadow: inset 0 0 0 2px #fff;
}

.takehome {
  margin: 1.1rem 0 0.2rem;
  font-weight: 800;
  font-size: clamp(2.7rem, 7vw, 4rem);
  line-height: 1;
  letter-spacing: -0.035em;
  color: var(--take-home);
  font-variant-numeric: tabular-nums;
}
.takehome small {
  font-size: 0.5em;
  letter-spacing: -0.01em;
}
.takehome-note {
  margin: 0.35rem 0 0;
  color: var(--ink-soft);
  font-size: 1rem;
}

.empty {
  margin: 1.25rem 0 0;
  color: var(--ink-soft);
}

.split {
  display: flex;
  gap: 2px;
  height: 2.75rem;
  margin: 1.4rem 0 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--line);
}
.split > i {
  display: block;
  height: 100%;
  min-width: 0;
  transition: flex-grow 0.35s ease;
}
@media (prefers-reduced-motion: reduce) {
  .split > i {
    transition: none;
  }
}

.ledger {
  width: 100%;
  margin: 1rem 0 0;
  border-collapse: collapse;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}
.ledger caption {
  text-align: left;
  font-weight: 600;
  padding-bottom: 0.3rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
}
.ledger th,
.ledger td {
  padding: 0.6rem 0;
  border-top: 1px solid var(--line);
  text-align: right;
  font-weight: 500;
}
.ledger th[scope="row"] {
  text-align: left;
  font-weight: 500;
}
.ledger .pct {
  color: var(--ink-soft);
  width: 4.5rem;
}
.ledger tr.total th,
.ledger tr.total td {
  border-top: 2px solid var(--ink);
  font-weight: 700;
}
.chip {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 3px;
  margin-right: 0.6rem;
  vertical-align: -0.05em;
}
.chip--take-home { background: var(--take-home); }
.chip--tax { background: var(--tax); }
.chip--ni { background: var(--ni); }
.chip--loan { background: var(--loan); }
.chip--pension { background: var(--pension); }

.keep {
  margin: 1rem 0 0;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  font-size: 1rem;
}

/* ---------- article text ---------- */

.article {
  margin-top: clamp(2.5rem, 6vw, 4.5rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2.75rem;
}
.article section {
  max-width: var(--measure);
}
.article h2 {
  margin: 0 0 0.6rem;
  font-family: var(--sans);
  font-weight: 700;
  font-size: clamp(1.5rem, 3vw, 1.9rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.article h3 {
  margin: 1.6rem 0 0.4rem;
  font-family: var(--sans);
  font-weight: 650;
  font-size: 1.15rem;
}
.article p {
  margin: 0 0 1rem;
}
.article ul {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
}
.article li {
  margin-bottom: 0.4rem;
}
.article .wide {
  max-width: none;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.table-scroll table {
  width: 100%;
  min-width: 24rem;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}
.table-scroll .table-wide {
  min-width: 40rem;
}
.table-scroll caption {
  text-align: left;
  padding: 0.9rem 1rem 0.3rem;
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 0.95rem;
}
.table-scroll th,
.table-scroll td {
  padding: 0.65rem 1rem;
  text-align: right;
  border-top: 1px solid var(--line);
  font-weight: 500;
}
.table-scroll th[scope="col"] {
  font-weight: 600;
  background: var(--paper);
}
.table-scroll th:first-child,
.table-scroll td:first-child {
  text-align: left;
}
.table-scroll tbody th {
  font-weight: 600;
  text-align: left;
}
.tables-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
}
@media (min-width: 900px) {
  .tables-2 {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.faq details {
  border-top: 1px solid var(--line);
  padding: 0.2rem 0;
}
.faq details:last-child {
  border-bottom: 1px solid var(--line);
}
.faq summary {
  cursor: pointer;
  list-style: none;
  padding: 0.85rem 2rem 0.85rem 0;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.1rem;
  position: relative;
}
.faq summary::-webkit-details-marker {
  display: none;
}
.faq summary::after {
  content: "+";
  position: absolute;
  right: 0.25rem;
  top: 0.55rem;
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1;
}
.faq details[open] summary::after {
  content: "\2212";
}
.faq details > div {
  padding: 0 0 0.6rem;
}
.faq details > div p:last-child {
  margin-bottom: 0.4rem;
}

.note {
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--ink-soft);
}

/* ---------- home ---------- */

.tool-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 46rem;
  border-top: 1px solid var(--ink);
}
.tool-list li {
  border-bottom: 1px solid var(--line);
  padding: 1.1rem 0;
}
.tool-list a.tool-link {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-decoration-thickness: 2px;
  text-decoration-color: var(--take-home);
}
.tool-list p {
  margin: 0.25rem 0 0;
  color: var(--ink-soft);
}
.tool-list .soon {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--ink-soft);
}
