/*
 * RV Loan Master
 * One loud element: the result panel, drawn as a US interstate guide sign.
 * Everything else is quiet: white page, spruce ink, thin rules.
 */
:root {
  --sign: #006b54;
  --sign-deep: #00563f;
  --ink: #16302a;
  --muted: #4c625c;
  --rule: #d3dfdb;
  --field: #f3f7f6;
  --paper: #ffffff;
  --focus: #f2b632;
  --link: #00604b;
  --font: 'Overpass', 'Helvetica Neue', Arial, sans-serif;
  --measure: 68ch;
  --radius: 6px;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: 16px;
  top: 12px;
  background: var(--paper);
  padding: 8px 12px;
  z-index: 10;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--rule);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 14px;
  padding-bottom: 14px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.wordmark-shield {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 30px;
  border-radius: 6px;
  background: var(--sign);
  color: #fff;
  font-size: 0.95rem;
  box-shadow: inset 0 0 0 2px var(--sign), inset 0 0 0 4px #fff;
}

.header-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  list-style: none;
  margin: 0;
  padding: 0;
  font-weight: 600;
}

.header-nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}

.header-nav a:hover,
.header-nav a[aria-current='page'] {
  border-bottom-color: var(--sign);
}

/* Page head */
main {
  padding-bottom: 64px;
}

.page-head {
  max-width: 1120px;
  margin: 0 auto;
  padding: 36px 20px 8px;
}

.crumbs {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 10px;
}

h1,
h2,
h3 {
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4.5vw, 3rem);
  font-weight: 800;
  max-width: 22ch;
}

h2 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 14px;
}

h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.lead {
  font-size: 1.2rem;
  color: var(--muted);
  max-width: 60ch;
  margin: 12px 0 0;
}

.byline {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 14px 0 0;
}

/* Calculator */
.calc-block {
  max-width: 1120px;
  margin: 28px auto 0;
  padding: 0 20px;
}

.calc-heading {
  margin: 48px 0 18px;
}

.calc {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.calc-inputs {
  display: grid;
  gap: 18px;
}

fieldset {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
  margin: 0;
  display: grid;
  gap: 14px;
}

legend {
  font-weight: 700;
  padding: 0 6px;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

.field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

input[type='number'],
input[type='month'],
select {
  width: 100%;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--field);
  border: 1px solid #b9cbc5;
  border-radius: var(--radius);
  padding: 11px 12px;
  min-height: 48px;
}

input[type='number']:hover,
select:hover {
  border-color: var(--muted);
}

input[type='number'] {
  -moz-appearance: textfield;
}

input[type='number']::-webkit-outer-spin-button,
input[type='number']::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.has-prefix input {
  padding-left: 28px;
}

.affix {
  position: absolute;
  color: var(--muted);
  font-weight: 600;
  pointer-events: none;
}

.prefix {
  left: 12px;
}

.suffix {
  right: 12px;
  font-size: 0.9rem;
}

.hint {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 6px 0 0;
  line-height: 1.45;
}

.check {
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 600;
}

.check input {
  width: 20px;
  height: 20px;
  accent-color: var(--sign);
}

/* The sign */
.sign {
  background: var(--sign);
  border-radius: 16px;
  padding: 8px;
  color: #fff;
}

.sign-inner {
  border: 3px solid #fff;
  border-radius: 10px;
  padding: 22px 24px 24px;
}

.sign-label {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
}

.sign-amount {
  margin: 2px 0 0;
  font-size: clamp(3rem, 7vw, 4.5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
}

.sign-sub {
  margin: 8px 0 18px;
  font-size: 0.98rem;
  min-height: 1.5em;
}

.results {
  margin: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.45);
}

.result-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.22);
}

.result-row dt {
  font-weight: 400;
}

.result-row dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
}

.result-row.strong {
  border-bottom: 0;
  font-size: 1.1rem;
}

.result-row.strong dt {
  font-weight: 700;
}

.sign-extra {
  margin: 14px 0 0;
  padding: 12px 14px;
  background: var(--sign-deep);
  border-radius: 8px;
  line-height: 1.45;
}

.sign-note {
  margin: 10px 0 0;
  font-size: 0.9rem;
}

.sign a {
  color: #fff;
}

/* Schedule, ownership and comparison tables span the full calculator width */
.schedule,
.ownership,
.calc-wide {
  grid-column: 1 / -1;
}

.schedule summary {
  cursor: pointer;
  font-weight: 700;
  padding: 12px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.schedule[open] summary {
  margin-bottom: 12px;
}

.ownership {
  border-top: 1px solid var(--rule);
  padding-top: 26px;
}

.ownership .results {
  border-top-color: var(--rule);
  max-width: 520px;
  margin-top: 18px;
}

.ownership .result-row {
  border-bottom-color: var(--rule);
}

.own-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.ownership .hint {
  max-width: var(--measure);
}

.schedule-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.segmented {
  display: inline-flex;
  border: 1px solid #b9cbc5;
  border-radius: var(--radius);
  overflow: hidden;
}

.segmented button,
.button-secondary {
  font: inherit;
  font-weight: 700;
  min-height: 44px;
  padding: 8px 16px;
  cursor: pointer;
  border: 0;
  background: var(--paper);
  color: var(--ink);
}

.segmented button[aria-pressed='true'] {
  background: var(--sign);
  color: #fff;
}

.button-secondary {
  border: 1px solid var(--sign);
  border-radius: var(--radius);
  color: var(--sign);
}

.button-secondary:hover {
  background: var(--field);
}

/* Long-form content */
.prose {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

.prose-section {
  max-width: var(--measure);
  margin-top: 48px;
}

.prose-section.wide {
  max-width: none;
}

.prose-section p,
.prose-section li {
  margin: 0 0 14px;
}

.prose-section ul,
.prose-section ol {
  padding-left: 22px;
  margin: 0 0 14px;
}

.prose-section h3 {
  margin: 26px 0 8px;
}

.formula {
  font-size: 1.15rem;
  font-weight: 700;
  padding: 14px 16px;
  border-left: 4px solid var(--sign);
  background: var(--field);
  overflow-x: auto;
  white-space: nowrap;
}

.callout {
  border: 1px solid var(--rule);
  border-left: 4px solid var(--focus);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 18px 0;
}

.callout p:last-child {
  margin-bottom: 0;
}

/* Tables */
.table-scroll {
  overflow-x: auto;
  margin: 8px 0 6px;
}

table.data {
  border-collapse: collapse;
  width: 100%;
  min-width: 520px;
  font-size: 0.98rem;
}

table.data caption {
  text-align: left;
  font-weight: 700;
  padding-bottom: 8px;
}

table.data th,
table.data td {
  text-align: right;
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

table.data th:first-child,
table.data td:first-child {
  text-align: left;
}

table.data thead th {
  border-bottom: 2px solid var(--ink);
  font-weight: 700;
}

table.data tbody th {
  font-weight: 700;
}

table.data .left {
  text-align: left;
}

table.data tr[aria-current='true'] th,
table.data tr[aria-current='true'] td {
  background: var(--field);
  font-weight: 700;
}

table.data td.neg {
  color: #a23b1e;
}

table.data .sub {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
}

.table-note {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 6px 0 0;
}

/* FAQ */
.faq details {
  border-bottom: 1px solid var(--rule);
}

.faq details:first-of-type {
  border-top: 1px solid var(--rule);
}

.faq summary {
  cursor: pointer;
  padding: 14px 0;
  list-style-position: outside;
}

.faq summary h3 {
  display: inline;
  margin: 0;
  font-size: 1.08rem;
}

.faq-answer {
  padding: 0 0 8px;
}

/* Related links */
.related-list {
  list-style: none;
  padding: 0 !important;
  display: grid;
  gap: 2px;
}

.related-list li {
  display: grid;
  gap: 2px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  margin: 0 !important;
}

.related-list a {
  font-weight: 700;
}

.related-list span {
  color: var(--muted);
  font-size: 0.95rem;
}

.sources li {
  font-size: 0.95rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--rule);
  padding: 40px 0 48px;
  font-size: 0.95rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 28px;
}

.site-footer h2 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.site-footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-footer li {
  margin: 5px 0;
}

.footer-note {
  margin: 28px 0 0;
  color: var(--muted);
  max-width: var(--measure);
}

@media (max-width: 860px) {
  .calc {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .field-pair {
    grid-template-columns: 1fr;
  }

  .sign-inner {
    padding: 18px 16px 20px;
  }

  .header-nav {
    gap: 4px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}

/* Small-screen payment bar: appears only while the results panel is off screen */
.payment-bar {
  display: none;
}

@media (max-width: 860px) {
  html {
    /* Keeps a focused input from being scrolled behind the bar */
    scroll-padding-bottom: 88px;
  }

  .payment-bar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 20;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      'label button'
      'value button';
    align-items: center;
    column-gap: 12px;
    padding: 8px 8px 8px 16px;
    background: var(--sign);
    color: #fff;
    border-radius: 12px;
    box-shadow: inset 0 0 0 2px var(--sign), inset 0 0 0 4px #fff, 0 6px 18px rgba(22, 48, 42, 0.25);
    transform: translateY(calc(100% + 24px));
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
  }

  .payment-bar.is-visible {
    transform: none;
    visibility: visible;
    transition: transform 0.2s ease;
  }

  .payment-bar-label {
    grid-area: label;
    font-size: 0.85rem;
    font-weight: 600;
    padding-top: 4px;
  }

  .payment-bar-value {
    grid-area: value;
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.1;
    padding-bottom: 4px;
  }

  .payment-bar button {
    grid-area: button;
    font: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--sign);
    background: #fff;
    border: 0;
    border-radius: 8px;
    padding: 12px 14px;
    min-height: 44px;
    cursor: pointer;
  }
}

@media (max-width: 860px) and (prefers-reduced-motion: reduce) {
  .payment-bar,
  .payment-bar.is-visible {
    transition: none;
  }
}

/* Text-heavy tables become stacked cards on phones instead of scrolling sideways */
@media (max-width: 640px) {
  table.data.stack {
    min-width: 0;
  }

  table.data.stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  table.data.stack tr {
    display: block;
    padding: 12px 0;
    border-bottom: 1px solid var(--rule);
  }

  table.data.stack th,
  table.data.stack td {
    display: block;
    text-align: left;
    border: 0;
    padding: 2px 0;
  }

  table.data.stack tbody th {
    font-size: 1.05rem;
    padding-bottom: 6px;
  }

  table.data.stack td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--muted);
  }

  table.data.stack td + td {
    margin-top: 6px;
  }
}

/* Embedded calculator (inside other sites' iframes) */
body.embed {
  padding: 16px 16px 8px;
}

body.embed main {
  padding-bottom: 0;
}

.embed-credit {
  margin: 14px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Embed promo page */
.copy-code label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}

.copy-code textarea {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  padding: 12px;
  color: var(--ink);
  background: var(--field);
  border: 1px solid #b9cbc5;
  border-radius: var(--radius);
  resize: vertical;
}

.copy-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
}

.button-primary {
  font: inherit;
  font-weight: 700;
  min-height: 44px;
  padding: 8px 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--sign);
  color: #fff;
  cursor: pointer;
}

.button-primary:hover {
  background: var(--sign-deep);
}

.embed-preview {
  border: 1px dashed #b9cbc5;
  border-radius: 12px;
  padding: 12px;
  margin-top: 12px;
}
