/*
 * One idea carries the look: the answer is printed as a pay stub.
 * Colors come from a dollar bill: green-black ink on greenish paper, seal green for what you keep.
 * Everything around the stub stays quiet.
 */
@font-face {
  font-family: 'Public Sans';
  src: url('/assets/fonts/public-sans.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #edf0e7;
  --sheet: #fdfefb;
  --ink: #17301f;
  --ink-soft: #4a5d50;
  --seal: #1e6a45;
  --seal-wash: #e3eee6;
  --withheld: #9a2f2f;
  --rule: #c5cfc0;
  --tax-social: #b0752a;
  --tax-medicare: #5c7390;
  --focus: #0b57d0;
  --measure: 40rem;
  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.6rem;
  --step-3: clamp(1.9rem, 1.2rem + 3.4vw, 3rem);
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Public Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: var(--step-0);
  line-height: 1.55;
}

a {
  color: var(--seal);
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--ink);
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--ink);
  color: var(--sheet);
  padding: 0.6rem 1rem;
  z-index: 10;
}

.skip:focus {
  top: 0.5rem;
  color: var(--sheet);
}

.wrap {
  width: 100%;
  max-width: calc(var(--measure) + 2rem);
  margin-inline: auto;
  padding-inline: 1rem;
}

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

.masthead {
  border-bottom: 1px solid var(--rule);
}

.masthead .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1.25rem;
  padding-block: 0.9rem;
}

.brand {
  display: inline-block;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}

/*
 * The logo. Its box is 6.63 times as wide as it is high, and the letters stand 18.6% above the bottom
 * of the box (the tail of the "y" hangs below them). Lowering it by that much puts the letters on the
 * same line as the menu beside it.
 */
.logo {
  --logo-height: 1.375rem;
  display: inline-block;
  height: var(--logo-height);
  width: calc(var(--logo-height) * 6.63);
  vertical-align: calc(var(--logo-height) * -0.186);
  fill: currentColor;
}

.logo__face {
  fill: var(--seal);
}

.logo__hands {
  fill: var(--sheet);
}

/* high-contrast mode replaces the page colors: the clock follows, so it stays visible */
@media (forced-colors: active) {
  .logo__face {
    fill: currentColor;
  }

  .logo__hands {
    fill: Canvas;
  }
}

.nav {
  display: flex;
  gap: 1.1rem;
  font-size: var(--step--1);
}

.nav a {
  color: var(--ink-soft);
  text-decoration: none;
  padding-block: 0.35rem;
}

.nav a:hover,
.nav a[aria-current='page'] {
  color: var(--ink);
  text-decoration: underline;
}

.crumbs {
  font-size: var(--step--1);
  color: var(--ink-soft);
  margin: 1.1rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.crumbs li + li::before {
  content: '/';
  margin-right: 0.4rem;
  color: var(--rule);
}

.footer {
  margin-top: 4rem;
  border-top: 1px solid var(--rule);
  font-size: var(--step--1);
  color: var(--ink-soft);
}

.footer .wrap {
  padding-block: 1.5rem 2.5rem;
}

.footer ul {
  list-style: none;
  padding: 0;
  margin: 0 0 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
}

.footer p {
  margin: 0.4rem 0 0;
  max-width: 34rem;
}

/* ---------- headings and text ---------- */

h1 {
  font-size: var(--step-3);
  line-height: 1.05;
  letter-spacing: -0.025em;
  font-weight: 800;
  margin: 1.4rem 0 0.75rem;
  text-wrap: balance;
}

h2 {
  font-size: var(--step-2);
  line-height: 1.15;
  letter-spacing: -0.015em;
  font-weight: 750;
  margin: 3rem 0 0.75rem;
  text-wrap: balance;
}

h3 {
  font-size: 1.1rem;
  line-height: 1.3;
  font-weight: 700;
  margin: 1.6rem 0 0.35rem;
}

p,
ul,
ol {
  margin: 0 0 1rem;
}

.lead {
  font-size: var(--step-1);
  line-height: 1.4;
  margin-bottom: 1.5rem;
  max-width: 34rem;
}

.fine {
  font-size: var(--step--1);
  color: var(--ink-soft);
}

/* ---------- number tables ---------- */

table {
  border-collapse: collapse;
  width: 100%;
  font-variant-numeric: tabular-nums lining-nums;
}

.figures {
  background: var(--sheet);
  border: 1px solid var(--rule);
  margin: 0 0 0.6rem;
}

.figures th,
.figures td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--rule);
  text-align: right;
  white-space: nowrap;
}

.figures tr > :first-child {
  text-align: left;
  font-weight: 600;
  white-space: normal;
}

.figures thead th {
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--ink-soft);
  white-space: normal;
  vertical-align: bottom;
  line-height: 1.25;
}

.figures tbody tr:last-child > * {
  border-bottom: 0;
}

.figures .is-here > * {
  background: var(--seal-wash);
}

.figures a {
  font-weight: 600;
}

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

.tool {
  margin-block: 2rem 0;
}

.form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem 0.75rem;
  margin: 0;
}

.form__wide {
  grid-column: 1 / -1;
}

.form label {
  display: block;
  font-weight: 600;
  font-size: var(--step--1);
  margin-bottom: 0.3rem;
}

.form input,
.form select {
  width: 100%;
  min-height: 3rem;
  padding: 0.5rem 0.7rem;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  background: var(--sheet);
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

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

.money-field {
  position: relative;
}

.money-field::before {
  content: '$';
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-soft);
  pointer-events: none;
}

.money-field input {
  padding-left: 1.5rem;
}

.form__wage input {
  font-size: 1.5rem;
  font-weight: 700;
  min-height: 3.6rem;
}

.form__wage .money-field::before {
  font-size: 1.5rem;
  font-weight: 700;
}

.form__wage .money-field input {
  padding-left: 1.9rem;
}

.form__hint {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 0.25rem;
}

.form__error {
  color: var(--withheld);
  font-size: var(--step--1);
  font-weight: 600;
  margin: 0.3rem 0 0;
}

/* On a rate page the stub is the answer, so on a phone the fields wait behind this button. */
.tool__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.8rem;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tool__toggle::after {
  content: '+';
  font-size: 1.3rem;
  line-height: 1;
}

.tool__toggle[aria-expanded='true']::after {
  content: '\2212';
}

.tool__toggle[aria-expanded='true'] {
  margin-bottom: 1rem;
}

.is-collapsed > .form {
  display: none;
}

.tool__result {
  min-width: 0;
}

.ad-slot {
  margin-block: 2.5rem;
  min-height: 280px;
}

/* ---------- the pay stub: the one loud thing on the page ---------- */

.stub {
  margin-top: 1.5rem;
  background: var(--sheet);
  border: 1.5px solid var(--ink);
  /* the torn perforation along the top of a paycheck */
  border-top: 0;
  position: relative;
  padding: 0 1rem 1rem;
}

.stub::before {
  content: '';
  display: block;
  height: 10px;
  margin-inline: calc(-1rem - 1.5px);
  background:
    radial-gradient(circle at 6px 0, var(--paper) 4px, transparent 4.5px) 0 0 / 12px 10px repeat-x,
    linear-gradient(var(--ink), var(--ink)) 0 0 / 100% 1.5px no-repeat;
}

.stub--stale {
  opacity: 0.45;
}

.stub__head {
  /* the fine engraved lines printed behind the amount on a check */
  margin-inline: -1rem;
  padding: 0.9rem 1rem 0.8rem;
  background: repeating-linear-gradient(-58deg, transparent 0 5px, rgb(30 106 69 / 0.09) 5px 6px), var(--seal-wash);
  border-bottom: 1px solid var(--rule);
}

.stub__wage {
  font-size: var(--step-2);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0;
}

.stub__terms {
  font-size: var(--step--1);
  color: var(--ink-soft);
  margin: 0.25rem 0 0;
}

.stub table {
  margin-top: 0.4rem;
}

.stub th,
.stub td {
  padding: 0.5rem 0;
  text-align: right;
  border-bottom: 1px dotted var(--rule);
  white-space: nowrap;
}

.stub td + td,
.stub th + th,
.stub td + th {
  padding-left: 0.75rem;
}

.stub tbody th,
.stub tfoot th {
  text-align: left;
  font-weight: 500;
  white-space: normal;
}

.stub thead th {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--ink);
  white-space: normal;
  line-height: 1.2;
  vertical-align: bottom;
}

.stub thead td {
  border-bottom: 1px solid var(--ink);
}

.stub__hint {
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.stub__minus td {
  color: var(--withheld);
}

/* a ledger total: single rule above, double rule below */
.stub .stub__total > * {
  border-top: 1px solid var(--ink);
  border-bottom: 3px double var(--ink);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--seal);
  padding-block: 0.65rem;
}

.stub .stub__total th {
  color: var(--ink);
  font-weight: 800;
}

/* under the total: what one hour pays once the commute is counted. A memo line, printed on the check paper. */
.stub__real {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 0.15rem 0.75rem;
  margin: 0.9rem -1rem 0;
  padding: 0.75rem 1rem 0.8rem;
  background: var(--seal-wash);
  border-block: 1px solid var(--rule);
}

.stub__real p {
  margin: 0;
}

.stub__real-label {
  font-weight: 700;
  line-height: 1.25;
}

.stub__real-figure {
  font-size: var(--step--1);
  color: var(--ink-soft);
  white-space: nowrap;
  font-variant-numeric: tabular-nums lining-nums;
}

.stub__real-figure strong {
  font-size: var(--step-2);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--seal);
}

.stub__real-terms {
  grid-column: 1 / -1;
  font-size: var(--step--1);
  color: var(--ink-soft);
  line-height: 1.4;
}

.stub__real-terms a {
  font-weight: 600;
  white-space: nowrap;
}

.share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
  margin: 0.9rem 0 0;
}

.share__button {
  min-height: 2.75rem;
  padding: 0.5rem 1.1rem;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  background: var(--ink);
  color: var(--sheet);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.share__button:hover {
  background: var(--seal);
  border-color: var(--seal);
}

.share__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.9rem;
  margin: 0;
  font-size: var(--step--1);
  color: var(--ink-soft);
}

.share__links[hidden] {
  display: none;
}

.share__links a {
  font-weight: 600;
  padding-block: 0.6rem;
}

.share__status {
  flex-basis: 100%;
  font-size: var(--step--1);
  color: var(--ink-soft);
}

.share__status:empty {
  display: none;
}

/* where each dollar goes: one bar, drawn to scale */
.split {
  margin-top: 1.4rem;
}

.split__title {
  font-size: var(--step--1);
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.split__bar {
  display: flex;
  gap: 2px;
  height: 1.5rem;
}

.split__seg {
  flex: 0 0 0;
  min-width: 3px;
}

.split__seg--net {
  background: var(--seal);
}

.split__seg--federal {
  background: var(--withheld);
}

.split__seg--social {
  background: var(--tax-social);
}

.split__seg--medicare {
  background: var(--tax-medicare);
}

.split__legend {
  list-style: none;
  padding: 0;
  margin: 0.6rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.1rem;
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
}

.split__legend li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.split__key {
  flex: none;
  width: 0.7rem;
  height: 0.7rem;
}

.stub__periods {
  margin-top: 1.4rem;
}

.stub__note {
  font-size: var(--step--1);
  color: var(--ink-soft);
  margin: 0.9rem 0 0;
}

.real {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

.real h2 {
  margin-top: 0;
  font-size: 1.3rem;
}

.real__out {
  margin: 1rem 0 0;
  padding: 0.9rem 1rem;
  background: var(--seal-wash);
  border-left: 4px solid var(--seal);
}

/* ---------- links to the other rates ---------- */

.neighbors {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem 0;
  font-weight: 600;
}

.chips {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(4.4rem, 1fr));
  gap: 0.5rem;
}

.chips a,
.chips span {
  display: block;
  text-align: center;
  padding: 0.6rem 0.25rem;
  border: 1px solid var(--rule);
  background: var(--sheet);
  border-radius: 3px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}

.chips a:hover {
  border-color: var(--seal);
}

.chips span {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--sheet);
}

.chips-after {
  margin-top: 1rem;
}

.sources {
  font-size: var(--step--1);
  color: var(--ink-soft);
  padding-left: 1.1rem;
}

.sources li {
  margin-bottom: 0.35rem;
}

.checked {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: var(--step--1);
  color: var(--ink-soft);
}

.prose {
  max-width: 36rem;
}

.prose ul {
  padding-left: 1.2rem;
}

.prose li {
  margin-bottom: 0.4rem;
}

@media (min-width: 46rem) {
  .form {
    grid-template-columns: repeat(4, 1fr);
  }

  .form__wage {
    grid-column: span 2;
  }

  .form__wide {
    grid-column: span 2;
  }

  .stub {
    padding-inline: 1.5rem;
  }

  .stub::before {
    margin-inline: calc(-1.5rem - 1.5px);
  }

  .stub__head,
  .stub__real {
    margin-inline: -1.5rem;
    padding-inline: 1.5rem;
  }
}

/* Wide screens: the stub stays in the text column and the fields move into the left margin beside it. */
@media (min-width: 76rem) {
  .tool__grid {
    display: grid;
    grid-template-columns: 15rem 40rem;
    gap: 2rem;
    align-items: start;
    width: 57rem;
    margin-left: -17rem;
  }

  .tool__inputs {
    position: sticky;
    top: 1.5rem;
  }

  .tool__toggle {
    display: none;
  }

  .is-collapsed > .form,
  .tool__inputs > .form {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .tool__inputs .form__wage,
  .tool__inputs .form__wide {
    grid-column: 1 / -1;
  }

  .tool__grid .stub {
    margin-top: 0;
  }
}

/*
 * Phones: the page is there to show one line, net pay, so everything above it gives up height.
 * The aim is that the total is on the first screen of a rate page without scrolling.
 */
@media (max-width: 30rem) {
  .masthead .wrap {
    padding-block: 0.55rem;
  }

  /* the site name beside it is the same link */
  .nav a[href='/'] {
    display: none;
  }

  /* at this height the logo is as wide as the name was in text, so the menu still fits beside it at 320 */
  .logo {
    --logo-height: 1.125rem;
  }

  .crumbs {
    margin-top: 0.6rem;
  }

  h1 {
    margin: 0.5rem 0 0.5rem;
  }

  .lead {
    font-size: 1.0625rem;
    margin-bottom: 0.9rem;
  }

  .tool {
    margin-top: 0;
  }

  .tool__inputs.is-collapsed + .tool__result .stub {
    margin-top: 0.75rem;
  }

  .stub__head {
    padding-block: 0.6rem 0.55rem;
  }

  .stub__terms {
    font-size: 0.8rem;
    line-height: 1.35;
    margin-top: 0.15rem;
  }

  .stub table {
    margin-top: 0.15rem;
  }

  /* a narrower margin inside the stub leaves the labels room to stay on one line */
  .stub {
    padding-inline: 0.75rem;
  }

  .stub::before {
    margin-inline: calc(-0.75rem - 1.5px);
  }

  .stub__head,
  .stub__real {
    margin-inline: -0.75rem;
    padding-inline: 0.75rem;
  }

  .stub td + td,
  .stub th + th,
  .stub td + th {
    padding-left: 0.5rem;
  }

  .stub .stub__lines,
  .stub .stub__periods {
    font-size: 0.875rem;
  }

  .stub__lines th,
  .stub__lines td {
    padding-block: 0.4rem;
    line-height: 1.25;
  }

  .stub__lines thead th {
    white-space: nowrap;
  }

  .stub__lines .stub__hint {
    font-size: 0.75rem;
  }

  .stub .stub__total > * {
    font-size: 1rem;
    padding-block: 0.5rem;
  }
}

/* Phones: tables keep their two most useful number columns and give up padding before they give up digits. */
@media (max-width: 26rem) {
  .figures th,
  .figures td {
    padding-inline: 0.55rem;
  }

  .hide-s {
    display: none;
  }
}

@media (max-width: 22rem) {
  .figures th,
  .figures td {
    padding-inline: 0.4rem;
    font-size: 0.925rem;
  }

  .figures thead th {
    font-size: 0.8rem;
  }

  .hide-xs {
    display: none;
  }

  .stub .stub__lines,
  .stub .stub__periods {
    font-size: 0.8125rem;
  }

  /* the narrowest phones: seven-figure pay still has to fit inside the stub */
  .stub__lines thead th {
    white-space: normal;
  }

  .stub .stub__total > * {
    font-size: 0.8125rem;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .stub {
    transition: opacity 0.15s;
  }
}

@media print {
  .masthead,
  .footer,
  .form,
  .share,
  .chips,
  .neighbors {
    display: none;
  }

  body {
    background: #fff;
  }
}
