/* DeskLark Studio -- Freelancer Set-Aside Calculator
   Brand palette matches the wedding and cash-stuffing calculators and the
   Pinterest pin-card system (build/marketing/pinterest/make_pin_cards.py):
   teal #132F32 / teal-light #2C544E / cream #F8F5EF / gold #C9A24B
   / ink #221F1C / gray #55504A. A dedicated warning red is used for the
   prominent "Not Tax Advice" disclaimer box, mirroring how the same red
   flags the cash-stuffing calculator's over-budget state -- regulatory
   copy gets the same visual urgency as a real error state, not a quiet
   footnote.

   Number-input width note (carried forward from the cash-stuffing
   calculator's reviewer round): native spin buttons clip visible digits,
   so every number/percentage input below disables the native spinner and
   uses a fixed width from the start -- 14ch for base-level fields
   (set-aside percentage), 12ch for fields inside repeated rows (income
   entry amount). */

:root {
  --teal: #132F32;
  --teal-light: #2C544E;
  --cream: #F8F5EF;
  --cream-dim: #EFEAE0;
  --gold: #C9A24B;
  --ink: #221F1C;
  --gray: #55504A;
  --accent: #8C6A1F;
  --warn: #B3261E;
  --warn-bg: #FBEAE8;
  --rule: #DAD3C4;
  --radius: 10px;
  --max-w: 820px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  line-height: 1.55;
}

h1, h2, h3 {
  font-family: Georgia, "Times New Roman", serif;
  color: var(--teal);
  line-height: 1.2;
  margin: 0 0 0.5em;
}

h1 { font-size: clamp(1.6rem, 5vw, 2.3rem); }
h2 { font-size: clamp(1.3rem, 4vw, 1.7rem); margin-top: 0; }
h3 { font-size: clamp(1.05rem, 3vw, 1.2rem); margin-top: 1.4em; }

p { margin: 0 0 1em; }

a { color: var(--teal-light); }
a:hover, a:focus { color: var(--teal); }

.wrap {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 20px;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--teal);
  color: var(--cream);
  padding: 10px 16px;
  z-index: 100;
  border-radius: 0 0 8px 0;
}
.skip-link:focus {
  left: 0;
}

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

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

.site-header {
  background: var(--teal);
  color: var(--cream);
  padding: 22px 0;
}
.site-header .wordmark {
  font-family: Georgia, serif;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0 0 4px;
  color: var(--cream);
}
.site-header .tagline {
  margin: 0;
  font-size: 0.92rem;
  color: #C9C4B8;
}

.site-footer {
  background: var(--teal);
  color: #C9C4B8;
  margin-top: 48px;
  padding: 24px 0 32px;
  font-size: 0.85rem;
}
.site-footer p { margin: 0 0 6px; }
.footer-fine { color: #9c9686; }

.site-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}
.site-links a {
  color: #E4DCC4;
  text-decoration: none;
}
.site-links a:hover, .site-links a:focus {
  color: var(--gold);
  text-decoration: underline;
}

/* ---------- layout sections ---------- */

main.wrap { padding-top: 28px; padding-bottom: 12px; }

section { margin-bottom: 40px; }

.intro .lede {
  color: var(--gray);
  font-size: 1.02rem;
  max-width: 66ch;
}

/* ---------- disclaimer box ---------- */

.disclaimer-box {
  margin-top: 16px;
  border: 1.5px solid var(--warn);
  background: var(--warn-bg);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.disclaimer-box .db-label {
  margin: 0 0 4px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.78rem;
  color: var(--warn);
}
.disclaimer-box .db-text {
  margin: 0;
  color: var(--ink);
  font-size: 0.9rem;
}

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

.calculator {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 22px 20px 8px;
}

.field-group {
  margin-bottom: 26px;
  border: 0;
  padding: 0;
}

.field-group > label,
.field-group legend {
  display: block;
  font-weight: 700;
  color: var(--teal);
  margin-bottom: 8px;
  font-size: 1rem;
}

.hint {
  color: var(--gray);
  font-size: 0.85rem;
  margin: 6px 0 0;
}

.pct-suffix, .number-prefix, .amount-prefix {
  display: flex;
  align-items: center;
  background: var(--cream-dim);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 0 10px;
  flex: 0 0 auto;
  width: fit-content;
}
.pct-suffix span, .number-prefix span, .amount-prefix span {
  color: var(--gray);
  font-weight: 700;
}
.pct-suffix span { margin-left: 4px; }
.number-prefix span, .amount-prefix span { margin-right: 2px; }
.pct-suffix input[type="number"], .number-prefix input[type="number"], .amount-prefix input[type="number"] {
  border: 0;
  background: transparent;
}

input[type="text"],
input[type="number"],
input[type="month"],
input[type="date"] {
  font-size: 1rem;
  padding: 9px 10px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
input[type="number"] {
  /* Native spin buttons eat into visible text width; disabled below and
     replaced with a fixed ch-width so digits never clip (see file header
     note -- this was a real bug caught in the cash-stuffing calculator's
     reviewer round and is fixed from the start here). */
  -moz-appearance: textfield;
  appearance: textfield;
}
#setaside-pct {
  width: 14ch;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input:focus {
  border-color: var(--teal-light);
}

/* ---------- income entry rows ---------- */

.entry-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.entry-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--cream-dim);
}

.entry-row input[type="month"] {
  flex: 0 0 auto;
  /* Native month-picker controls render their own internal shadow-DOM text
     (not plain text this stylesheet can measure via scrollWidth), so a
     fixed ch width here was clipping longer values ("September 2026")
     behind the calendar-icon affordance even though the plain
     clientWidth>=scrollWidth probe used for the number inputs read clean --
     the clipping is inside the control's own rendering, invisible to that
     probe. 20ch is generous enough for the longest "Month YYYY" value
     across every locale-neutral rendering tested; verified visually via a
     cropped screenshot instead. */
  width: 20ch;
}
.entry-row input[type="text"] {
  flex: 1 1 160px;
  min-width: 120px;
}
.entry-row .amount-prefix {
  flex: 0 0 auto;
}
.entry-row .amount-prefix input[type="number"] {
  width: 12ch;
}
.entry-setaside-hint {
  flex: 1 1 100%;
  order: 5;
  font-size: 0.82rem;
  /* Darker than --accent (#8C6A1F) specifically for this small text-on-
     cream-dim usage -- #8C6A1F only cleared 4.17:1 against --cream-dim,
     short of WCAG AA's 4.5:1 for normal-size text (caught by the axe-core
     scan in tests/verify.mjs). #6B4F17 clears 6.36:1 on the same
     background while staying in the same warm gold-brown family. */
  color: #6B4F17;
  font-weight: 600;
}

.btn-remove {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--gray);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-remove:hover:not(:disabled), .btn-remove:focus-visible:not(:disabled) {
  border-color: var(--warn);
  color: var(--warn);
}
.btn-remove:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.list-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.btn-secondary {
  background: #fff;
  border: 1.5px solid var(--teal-light);
  color: var(--teal-light);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-secondary:hover:not(:disabled), .btn-secondary:focus-visible:not(:disabled) {
  background: var(--teal-light);
  color: #fff;
}
.btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#entry-count {
  font-weight: 700;
  color: var(--teal);
  margin: 0;
}

.priority-note {
  color: var(--warn);
}

/* ---------- results ---------- */

.pct-prompt {
  border: 1px dashed var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--cream-dim);
  color: var(--ink);
  font-weight: 600;
}

.table-scroll {
  /* position:relative makes this the containing block for the
     visually-hidden <label class="sr-only"> elements the quarterly table's
     date-picker cells generate (see app.js renderQuarterResults). Without
     it, those position:absolute labels' containing block falls through to
     the viewport/root instead of this scroll container, and their
     un-clipped nowrap text (long strings like "Q1 2026 (Jan-Mar) your due
     date") was inflating document.documentElement.scrollWidth even though
     nothing was visibly rendered outside the box -- caught via a 320px
     Playwright scrollWidth probe. */
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: #fff;
  margin-top: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 460px;
  font-size: 0.92rem;
}

thead th {
  text-align: left;
  background: var(--teal);
  color: var(--cream);
  padding: 10px 12px;
  font-weight: 700;
  position: sticky;
  top: 0;
}

tbody th, tbody td, tfoot th, tfoot td {
  padding: 9px 12px;
  border-top: 1px solid var(--rule);
}

tbody th {
  text-align: left;
  font-weight: 600;
  color: var(--ink);
}

.num { text-align: right; }
.muted { color: var(--gray); }
.amount { font-weight: 700; color: var(--teal); }

#quarter-results-body input[type="date"] {
  width: 12.5ch;
  font-size: 0.85rem;
  padding: 6px 8px;
}

#month-results-empty, #quarter-results-empty, #year-results-empty {
  margin-top: 8px;
}

.how-it-works {
  margin-top: 14px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 10px 14px;
  background: #fff;
}
.how-it-works summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--teal);
}
.how-it-works p {
  margin-top: 10px;
  color: var(--gray);
  font-size: 0.9rem;
}

.share-box {
  margin-top: 22px;
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--cream-dim);
}
.share-box h3 { margin-top: 0; margin-bottom: 10px; }

.summary-text {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow-y: auto;
  margin: 0 0 12px;
}

.btn {
  display: inline-block;
  border: 0;
  border-radius: 999px;
  padding: 11px 20px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--teal);
  color: var(--cream);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--teal-light);
}

.copy-status {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--teal-light);
  min-height: 1.2em;
}

/* ---------- FAQ ---------- */

.faq-item {
  border-bottom: 1px solid var(--rule);
  padding: 16px 0;
}
.faq-item:last-child { border-bottom: 0; }
.faq-item h3 { margin-top: 0; margin-bottom: 6px; }
.faq-item p { color: var(--gray); margin-bottom: 0; }

/* ---------- promo cards ---------- */

.promo-intro { color: var(--gray); }

.promo-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.promo-card {
  display: block;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 18px;
  background: #fff;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.12s ease, transform 0.12s ease;
}
.promo-card:hover, .promo-card:focus-visible {
  border-color: var(--gold);
  transform: translateY(-1px);
}
.promo-card h3 { color: var(--teal); margin-top: 0; }
.promo-card p { color: var(--gray); font-size: 0.92rem; }

.promo-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
}

.promo-cta {
  display: inline-block;
  font-weight: 700;
  color: var(--teal-light);
}

.promo-card--soon {
  background: var(--cream-dim);
  cursor: default;
}
.promo-card--soon:hover, .promo-card--soon:focus-visible {
  transform: none;
  border-color: var(--rule);
}
.promo-cta--disabled {
  color: var(--gray);
}

@media (min-width: 620px) {
  .promo-cards {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 640px) {
  :root { font-size: 17px; }
  .calculator { padding: 28px 28px 10px; }
}
