/* Free calculator. Builds on site.css tokens, so light and dark
   appearance follow the rest of boparo.com. Mobile first. */
:root {
  --good: #1f6b45;
  --warn: #8a5a00;
  --bad: #a3271f;
  --field-bg: #fff;
  --field-border: #b9c4bc;
}
:root[data-theme="dark"] {
  --good: #9fe0b2;
  --warn: #f2c66d;
  --bad: #ff9c94;
  --field-bg: #151719;
  --field-border: #5b6168;
}
.container.narrow {
  width: min(760px, calc(100% - 80px));
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.tool-hero {
  padding: 48px 0 36px;
}
.tool-hero h1 {
  font-size: clamp(38px, 5vw, 64px);
}
.tool-message {
  margin-top: 14px;
  font-size: clamp(19px, 2.2vw, 24px);
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.35;
  color: var(--accent);
}
.breadcrumb {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 20px;
}
.breadcrumb a {
  color: var(--accent);
}
.promise-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
}
.promise-list li:before {
  content: "✓ ";
}
/* In-page links; :root scroll-padding already clears the sticky header. */
.page-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
}
.page-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid var(--rule);
  border-radius: 99px;
  background: var(--bg-surface);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.page-nav a:hover {
  border-color: var(--accent);
}
.tool-page main section {
  scroll-margin-top: 8px;
}
.calculator-section {
  padding: 32px 0 56px;
}
.estimator {
  font-size: 15px;
}
.calc-fallback p {
  margin-bottom: 16px;
}
.worked-table,
.loads {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 15px;
}
.worked-table caption {
  text-align: left;
  font-weight: 600;
  margin-bottom: 8px;
}
.worked-table th,
.worked-table td,
.loads th,
.loads td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  font-weight: 400;
  vertical-align: top;
}
.worked-table td,
.loads td {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.loads thead th {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.worked-table tr.total th,
.worked-table tr.total td {
  font-weight: 600;
  border-bottom-width: 2px;
}
.table-scroll {
  overflow-x: auto;
}

/* ---- Calculator ------------------------------------------------------- */
.calc-layout {
  display: grid;
  gap: 20px;
}
.calc-card {
  background: var(--bg-app);
  border: 1px solid var(--rule);
  border-radius: 18px;
  padding: 20px 16px;
  min-width: 0;
}
.calc-card h2 {
  font-size: 22px;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}
.calc-card h3 {
  font-size: 16px;
  letter-spacing: 0;
  margin: 28px 0 12px;
}
.settings > summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  gap: 4px;
}
.settings > summary::-webkit-details-marker {
  display: none;
}
.settings > summary h2 {
  margin: 0;
}
.settings > summary h2:after {
  content: " ＋";
  color: var(--accent);
}
.settings[open] > summary h2:after {
  content: " －";
}
.settings[open] > summary {
  margin-bottom: 12px;
}
/* Hint text only: the shared header uses .button.small, which must keep
   site.css's button colours exactly as on the homepage. */
.small:not(.button),
.hint {
  font-size: 13px;
  color: var(--muted);
}
.grid {
  display: grid;
  gap: 0 16px;
}
.field {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
  min-width: 0;
}
.field label,
legend {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  background: var(--field-bg);
  color: var(--text-primary);
  font: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
}
.field textarea {
  min-height: 88px;
  resize: vertical;
}
.affix {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  background: var(--field-bg);
  overflow: hidden;
}
.affix:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.affix input {
  border: 0;
  border-radius: 0;
  min-width: 0;
  flex: 1;
}
.affix input:focus-visible {
  outline: none;
}
.affix .prefix,
.affix .suffix {
  display: grid;
  place-items: center;
  padding: 0 10px;
  color: var(--muted);
  background: var(--bg-soft);
  font-size: 15px;
  white-space: nowrap;
}
[aria-invalid="true"],
.affix:has([aria-invalid="true"]) {
  border-color: var(--bad) !important;
}
.field-error {
  font-size: 13px;
  color: var(--bad);
  min-height: 0;
}
.field-error:empty {
  display: none;
}
fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 16px;
  min-width: 0;
}
legend {
  padding: 0;
  margin-bottom: 8px;
}
.choice label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 15px;
}
.choice input,
.check input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chips legend {
  width: 100%;
}
.chips label {
  position: relative;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--field-border);
  border-radius: 99px;
  background: var(--field-bg);
  cursor: pointer;
}
.chips input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.chips label:has(input:checked) {
  background: var(--button-bg);
  border-color: var(--button-bg);
  color: var(--button-text);
  font-weight: 600;
}
.chips label:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 40px;
  padding-top: 8px;
  font-size: 15px;
}
.check input {
  margin: 1px 0 0;
}
.plain legend {
  margin-bottom: 4px;
}
.rows {
  display: grid;
  gap: 4px;
}
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr);
  gap: 0 10px;
  align-items: start;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--rule);
}
.row .remove {
  grid-column: 1 / -1;
  justify-self: start;
}
.text-button,
.remove {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.remove {
  color: var(--muted);
  font-weight: 400;
  font-size: 14px;
  min-height: 36px;
}

/* Results */
.results {
  border-width: 2px;
  border-color: var(--accent);
  background: var(--bg-surface);
}
.results.stale .tiers,
.results.stale .analysis {
  opacity: 0.4;
}
.tiers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.tier {
  display: grid;
  gap: 2px;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-app);
  font-size: 13px;
  color: var(--muted);
  min-width: 0;
}
.tier strong {
  font-size: 24px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.tier.suggested {
  background: var(--button-bg);
  color: var(--button-text);
}
.tier.suggested strong,
.tier.suggested .small {
  color: var(--button-text);
}
.health {
  margin: 4px 0 16px;
  padding: 12px 14px;
  border-radius: 12px;
  border-left: 4px solid currentColor;
  background: var(--bg-app);
  font-weight: 600;
  font-size: 15px;
}
.health.good {
  color: var(--good);
}
.health.warn {
  color: var(--warn);
}
.health.bad {
  color: var(--bad);
}
.analysis,
.breakdown {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  margin: 0;
  font-size: 15px;
}
.analysis dt,
.breakdown dt {
  color: var(--muted);
}
.analysis dd,
.breakdown dd {
  margin: 0;
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.analysis dt.gap,
.analysis dt.gap + dd {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
}
.breakdown dt:last-of-type,
.breakdown dd:last-of-type {
  padding-top: 8px;
  border-top: 1px solid var(--rule);
}
.cost-details {
  margin-top: 16px;
}
.cost-details summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}
.issues {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-app);
  border-left: 4px solid var(--bad);
}
.issues p {
  color: var(--bad);
  font-weight: 600;
}
.example-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 16px;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--bg-soft);
}
.example-banner p {
  color: var(--text-primary);
  font-weight: 600;
}
.save-status {
  font-size: 13px;
  margin-bottom: 8px;
}
.logo-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 8px;
}
.logo-preview {
  width: 120px;
  height: 48px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fff;
}
.forget {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  display: grid;
  gap: 12px;
  justify-items: start;
}
.create {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  margin-top: 8px;
}
.create .button[aria-busy="true"] {
  opacity: 0.6;
}
.pdf-message {
  margin-top: 12px;
  font-size: 14px;
}
.pdf-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.pdf-actions .hint {
  flex-basis: 100%;
}
.pdf-actions[hidden] {
  display: none;
}
.pdf-preview {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}
.pdf-preview:empty {
  display: none;
}
.pdf-preview canvas {
  width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: 0 6px 24px #0e3b2e14;
  background: #fff;
}
.upgrade-note {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-soft);
  font-size: 14px;
  color: var(--text-primary);
}
.upgrade-note a {
  color: var(--accent);
  font-weight: 600;
}

/* ---- Content sections -------------------------------------------------- */
.how-to {
  padding: 8px 0 56px;
}
.how-to h2 {
  font-size: clamp(26px, 3vw, 36px);
  margin-bottom: 16px;
}
.steps {
  display: grid;
  gap: 12px;
  margin: 0;
  padding-left: 22px;
}
.steps li {
  color: var(--muted);
  padding-left: 4px;
}
.steps strong {
  color: var(--text-primary);
}
.estimate-note {
  margin-top: 12px;
}
.explainer,
.scenarios,
.compare,
.faq-section {
  padding: 64px 0;
}
.explainer h2 {
  font-size: clamp(30px, 4vw, 44px);
  margin-bottom: 16px;
}
.explainer h3 {
  margin: 28px 0 10px;
  font-size: 20px;
}
.explainer p {
  margin-bottom: 12px;
}
.scenario-grid {
  display: grid;
  gap: 16px;
  margin-top: 32px;
}
.scenario {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 20px;
  border-radius: 18px;
  background: var(--bg-surface);
}
.scenario h3 {
  font-size: 20px;
}
.scenario dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 0;
}
.scenario dl div {
  display: grid;
}
.scenario dt {
  font-size: 12px;
  color: var(--muted);
}
.scenario dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.scenario dd.loss {
  color: var(--bad);
}
.scenario .lesson {
  color: var(--text-primary);
}
.scenario .button {
  justify-self: start;
}
.compare-grid {
  display: grid;
  gap: 16px;
  margin-top: 32px;
}
.compare-card {
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  border-radius: 18px;
  background: var(--bg-surface);
  border: 1px solid var(--rule);
}
.compare-card .feature-list {
  flex: 1;
  margin: 12px 0 20px;
}
.entry-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}
.card-tagline {
  color: var(--muted);
  font-weight: 600;
  margin-top: 4px;
}
.card-footer {
  display: flex;
  flex-direction: column;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
}
.card-footer .actions {
  margin-top: auto;
  padding-top: 18px;
}
.card-footer .quiet-note {
  margin-top: 10px;
}
.compare-card.core {
  border: 2px solid var(--accent);
}
.compare-card h3 {
  margin-bottom: 8px;
}
.compare-card .price-line {
  color: var(--text-primary);
}
.faq-section .faq {
  padding-top: 0;
}

@media (min-width: 640px) {
  .calc-card {
    padding: 24px;
  }
  .grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .tiers {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.6fr) auto;
    align-items: end;
  }
  .row .remove {
    grid-column: auto;
    margin-bottom: 14px;
  }
  .scenario-grid,
  .compare-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  /* Side by side, both cards share three rows (header, list, footer) so
     dividers and buttons align. Keep the span equal to the card's children. */
  .compare-card {
    display: grid;
    grid-row: span 3;
    grid-template-rows: subgrid;
    row-gap: 0;
  }
}
@media (min-width: 1000px) {
  .calc-layout {
    grid-template-columns: minmax(0, 1fr) minmax(340px, 400px);
    align-items: start;
  }
  .calc-layout > * {
    grid-column: 1;
  }
  .calc-layout > .results {
    grid-column: 2;
    grid-row: 1 / span 3;
    position: sticky;
    top: 88px;
  }
  .results .tiers {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .results .grid.two {
    grid-template-columns: 1fr;
  }
  .scenario-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 800px) {
  .container.narrow {
    width: calc(100% - 32px);
  }
}
@media (max-width: 520px) {
  .calculator-section .container {
    width: calc(100% - 24px);
  }
  .tool-hero {
    padding: 32px 0 24px;
  }
}
