/* =============================================================================
   USA Take-Home Pay Calculator
   Visual concept: a payroll register. Ruled lines, right-aligned tabular
   figures, faint alternating bars from continuous-feed payroll paper.
   ========================================================================== */

:root {
  --paper:      #F7F8F5;
  --bar:        #E8EFE8;
  --rule:       #C9D2C9;
  --rule-firm:  #8F9E92;
  --ink:        #1A2420;
  --ink-soft:   #5A6760;
  --minus:      #9E3B2B;
  --net:        #2C6A4F;
  --net-wash:   #EAF2EC;
  --focus:      #1F5C4A;

  --fs-base: 1rem;
  --measure: 64ch;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: var(--fs-base);
  line-height: 1.6;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 1.25rem; }

/* --- Masthead ------------------------------------------------------------ */
.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 0 1rem;
  border-bottom: 1px solid var(--rule);
  flex-wrap: wrap;
}
.wordmark {
  font-weight: 600;
  /* Scales down on narrow screens so the full name and the year badge
     stay on one line instead of wrapping. */
  font-size: clamp(0.875rem, 3.4vw, 1.0625rem);
  letter-spacing: -0.015em;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}
.wordmark span { color: var(--net); }
.year-badge {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.8125rem;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  padding: 0.1rem 0.5rem;
  border-radius: 2px;
}

/* --- Page head ----------------------------------------------------------- */
.page-head { padding: 2.5rem 0 1.75rem; max-width: var(--measure); }
h1 {
  font-size: clamp(1.75rem, 4.2vw, 2.5rem);
  line-height: 1.15;
  letter-spacing: -0.022em;
  font-weight: 600;
  margin: 0 0 0.75rem;
}
.deck { margin: 0; color: var(--ink-soft); font-size: 1.0625rem; }

/* --- Calculator layout --------------------------------------------------- */
.calculator {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 2.5rem;
  align-items: start;
  padding-bottom: 2.5rem;
}
@media (max-width: 820px) {
  .calculator { grid-template-columns: 1fr; gap: 1.75rem; }
}

/* --- Form ---------------------------------------------------------------- */
.field { margin-bottom: 1.125rem; }
.field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.3rem;
}
.hint { display: block; font-weight: 400; color: var(--ink-soft); font-size: 0.8125rem; }

input[type="number"], select {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--rule-firm);
  border-radius: 3px;
  padding: 0.55rem 0.7rem;
}
input[type="number"] { font-family: "IBM Plex Mono", ui-monospace, monospace; }
input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

.money-input { position: relative; }
.money-input input { padding-left: 1.6rem; }
.money-input::before {
  content: "$";
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  color: var(--ink-soft);
  pointer-events: none;
}

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

details.advanced {
  border-top: 1px solid var(--rule);
  margin-top: 1.5rem;
  padding-top: 0.875rem;
}
details.advanced summary {
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--focus);
  list-style: none;
}
details.advanced summary::-webkit-details-marker { display: none; }
details.advanced summary::before { content: "+ "; font-family: "IBM Plex Mono", monospace; }
details.advanced[open] summary::before { content: "– "; }
details.advanced .field:first-of-type { margin-top: 1rem; }

/* --- Pay stub ------------------------------------------------------------ */
.stub {
  background: #fff;
  border: 1px solid var(--rule-firm);
  border-radius: 3px;
  overflow: hidden;
}
.stub-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.85rem 1.1rem;
  border-bottom: 2px solid var(--ink);
  gap: 1rem;
}
.stub-head h2 { font-size: 0.9375rem; font-weight: 600; margin: 0; }
.stub-head .period {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.8125rem;
  color: var(--ink-soft);
}

.ledger { width: 100%; border-collapse: collapse; }
.ledger th, .ledger td {
  padding: 0.5rem 1.1rem;
  font-size: 0.9375rem;
  text-align: left;
}
.ledger td.amt {
  text-align: right;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ledger tbody tr:nth-child(even) { background: var(--bar); }
.ledger tr.gross td { font-weight: 600; border-bottom: 1px solid var(--rule); }
.ledger tr.deduction td.amt { color: var(--minus); }
.ledger td .sub {
  display: block;
  font-size: 0.75rem;
  color: var(--ink-soft);
  line-height: 1.35;
}
.ledger tr.subtotal td {
  border-top: 1px solid var(--rule-firm);
  font-weight: 600;
}

/* The one bold moment: the net pay total, on a double rule. */
.net-line {
  background: var(--net-wash);
  border-top: 3px double var(--ink);
  padding: 1rem 1.1rem 1.15rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
}
.net-line .net-label { font-size: 0.875rem; font-weight: 500; }
.net-line .net-label .sub { display: block; font-size: 0.75rem; color: var(--ink-soft); font-weight: 400; }
.net-line .net-amt {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.6rem, 4.5vw, 2.125rem);
  font-weight: 600;
  color: var(--net);
  line-height: 1;
  letter-spacing: -0.02em;
}

.stub-foot {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  border-top: 1px solid var(--rule);
}
.stub-foot div { padding: 0.7rem 1.1rem; }
.stub-foot div + div { border-left: 1px solid var(--rule); }
.stub-foot dt { font-size: 0.75rem; color: var(--ink-soft); margin: 0; }
.stub-foot dd {
  margin: 0.1rem 0 0;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 0.9375rem;
  font-weight: 500;
}

.notice {
  margin-top: 0.875rem;
  padding: 0.7rem 0.85rem;
  border-left: 3px solid var(--rule-firm);
  background: var(--bar);
  font-size: 0.8125rem;
  color: var(--ink-soft);
  border-radius: 0 3px 3px 0;
}
.notice[hidden] { display: none; }

/* --- Ad slots ------------------------------------------------------------ */
.ad-slot { margin: 2rem 0; min-height: 90px; text-align: center; }
.ad-slot[data-label]::before {
  content: attr(data-label);
  display: block;
  font-size: 0.6875rem;
  color: var(--ink-soft);
  margin-bottom: 0.35rem;
}

/* --- Content sections ---------------------------------------------------- */
section.prose { padding: 2.25rem 0; border-top: 1px solid var(--rule); }
section.prose h2 {
  font-size: 1.375rem;
  letter-spacing: -0.015em;
  margin: 0 0 0.85rem;
  font-weight: 600;
}
section.prose h3 { font-size: 1.0625rem; margin: 1.5rem 0 0.4rem; font-weight: 600; }
section.prose p, section.prose li { max-width: var(--measure); }
section.prose p { margin: 0 0 0.9rem; }
section.prose p a, .deck a { color: var(--focus); text-decoration: underline; text-underline-offset: 2px; }
section.prose p a:hover, .deck a:hover { text-decoration-thickness: 2px; }

.breakdown { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
.breakdown th, .breakdown td { padding: 0.55rem 0.75rem; font-size: 0.9375rem; }
.breakdown th { text-align: left; border-bottom: 2px solid var(--ink); font-weight: 600; }
.breakdown td { border-bottom: 1px solid var(--rule); }
.breakdown td.amt {
  text-align: right;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}
.breakdown tbody tr:nth-child(even) { background: var(--bar); }

.faq details {
  border-bottom: 1px solid var(--rule);
  padding: 0.85rem 0;
}
.faq summary { cursor: pointer; font-weight: 500; }
.faq details p { margin: 0.6rem 0 0; color: var(--ink-soft); }

/* --- Cluster links ------------------------------------------------------- */
.related ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0;
  border-top: 1px solid var(--rule);
}
.related li { border-bottom: 1px solid var(--rule); }
.related a {
  display: block;
  padding: 0.8rem 0.25rem;
  color: var(--ink);
  text-decoration: none;
}
.related a:hover, .related a:focus-visible { color: var(--focus); }
.related a strong { display: block; font-weight: 500; font-size: 0.9375rem; }
.related a span { font-size: 0.8125rem; color: var(--ink-soft); }

footer.site {
  border-top: 1px solid var(--rule);
  padding: 1.5rem 0 2.5rem;
  font-size: 0.8125rem;
  color: var(--ink-soft);
}
footer.site p { max-width: var(--measure); margin: 0 0 0.5rem; }
footer.site .footer-nav {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--rule);
}
footer.site .footer-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  white-space: nowrap;
}
footer.site .footer-nav a:hover,
footer.site .footer-nav a:focus-visible { color: var(--focus); text-decoration: underline; }

@media (max-width: 429px) {
  /* The full wordmark plus the year badge cannot share a line on a phone,
     and a wrapped masthead pushes the calculator below the fold. The tax
     year is already in the title, the meta description and the sources
     block, so the badge is the redundant half. */
  .masthead .year-badge { display: none; }
}

@media (max-width: 420px) {
  .stub-foot div { padding: 0.6rem 0.7rem; }
  .stub-foot dt { font-size: 0.6875rem; line-height: 1.3; }
  .stub-foot dd { font-size: 0.875rem; }
}

.sources {
  margin-top: 1.75rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--rule);
  font-size: 0.8125rem;
  color: var(--ink-soft);
  line-height: 1.55;
}
.sources strong { color: var(--ink); font-weight: 500; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
