/**
 * affordability.css
 *
 * Styling for views/home-affordability-calculator.php, loaded only on that page (layouts/head.php). Mobile first: inputs, then the result
 * card, then the financing card, with a slim bottom bar ("Up to $X") on phones; from 900px up the inputs are a narrow left column and the
 * result is a sticky card on the right. Same palette as lead-form.css / feedback.css (#12233D text, #DCE1E8 borders, #4B5A70 labels,
 * #1E40AF accent). Inputs are 16px so iOS does not zoom into them.
 */

.aff-wrap {
  max-width: var(--wrap-container, 1100px);
  margin: 0 auto;
  padding: 24px var(--wrap-gutter, 16px) 48px;
  color: #12233D;
}

.aff-heading {
  font-size: 30px;
  font-weight: 600;
  margin: 0 0 8px;
}

.aff-intro {
  max-width: none;
  margin: 0 0 20px;
  font-size: 16px;
  line-height: 1.5;
  color: #4B5A70;
}

/* visually hidden, still read by screen readers */
.aff-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.aff-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.aff-card {
  border: 1px solid #DCE1E8;
  border-radius: 8px;
  background: #FFFFFF;
  padding: 16px;
}

.aff-inputs {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #F7F8FA;
}

.aff-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* ---- Fields ---- */
.aff-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  margin: 0;
}

.aff-field > label {
  font-size: 13px;
  font-weight: 600;
  color: #4B5A70;
}

.aff-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.aff-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.aff-row > .aff-input {
  flex: 1 1 auto;
  min-width: 0;
}

.aff-input {
  position: relative;
  display: block;
}

.aff-input[hidden] {
  display: none;
}

.aff-input input,
.aff-field select {
  width: 100%;
  box-sizing: border-box;
  min-height: 44px;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid #DCE1E8;
  border-radius: 8px;
  background: #FFFFFF;
  color: #12233D;
  font-size: 16px;
  line-height: 1.2;
}

.aff-input input:disabled {
  background: #EEF0F4;
  color: #7A8699;
}

.aff-input--pre input { padding-left: 26px; }
.aff-input--suf input { padding-right: 30px; }
.aff-input--unit input { padding-right: 38px; }
.aff-input--short { flex: 0 0 84px; }

.aff-adorn {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  font-size: 15px;
  color: #4B5A70;
  pointer-events: none;
}

.aff-input--suf .aff-adorn,
.aff-adorn--end {
  left: auto;
  right: 12px;
}

.aff-input--wide input { padding-right: 58px; }

.aff-input input:focus-visible,
.aff-field select:focus-visible {
  outline: 2px solid #1E40AF;
  outline-offset: 1px;
}

/* $ / % switch and the DTI presets: small pill buttons */
.aff-seg,
.aff-chips {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 0;
  border: 1px solid #DCE1E8;
  border-radius: 8px;
  overflow: hidden;
  background: #FFFFFF;
}

.aff-seg button,
.aff-chips button {
  min-width: 44px;
  min-height: 42px;
  margin: 0;
  padding: 0 10px;
  border: 0;
  border-left: 1px solid #DCE1E8;
  background: #FFFFFF;
  color: #1E40AF;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.aff-seg button:first-child,
.aff-chips button:first-child {
  border-left: 0;
}

.aff-seg button[aria-pressed="true"],
.aff-chips button[aria-pressed="true"] {
  background: #1E40AF;
  color: #FFFFFF;
}

.aff-seg button:focus-visible,
.aff-chips button:focus-visible {
  outline: 2px solid #1E40AF;
  outline-offset: -2px;
}

/* ---- Advanced ---- */
.aff-adv {
  border-top: 1px solid #DCE1E8;
  padding-top: 8px;
}

.aff-adv summary {
  display: flex;
  align-items: center;
  min-height: 40px;
  font-size: 15px;
  font-weight: 600;
  color: #1E40AF;
  cursor: pointer;
}

.aff-adv-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0 4px;
}

.aff-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  font-size: 15px;
  color: #12233D;
  cursor: pointer;
}

.aff-check input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: #1E40AF;
}

/* ---- Result card ---- */
.aff-result-card {
  scroll-margin-top: 12px;
  outline: none;
}

.aff-empty {
  margin: 0 0 12px;
  padding: 24px 8px;
  text-align: center;
  font-size: 16px;
  line-height: 1.5;
  color: #4B5A70;
}

.aff-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  border-radius: 8px;
  background: #EEF0F4;
}

.aff-tabs button {
  flex: 1 1 0;
  min-height: 40px;
  margin: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #4B5A70;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.aff-tabs button[aria-selected="true"] {
  background: #FFFFFF;
  color: #12233D;
  box-shadow: 0 1px 3px rgba(18, 35, 61, 0.15);
}

.aff-tabs button:focus-visible {
  outline: 2px solid #1E40AF;
  outline-offset: 1px;
}

.aff-headline {
  margin: 0 0 6px;
  font-size: 17px;
  line-height: 1.3;
  color: #4B5A70;
}

.aff-headline strong {
  display: block;
  margin-top: 2px;
  font-size: 40px;
  line-height: 1.1;
  font-weight: 700;
  color: #1E40AF;
}

.aff-sub {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.5;
  color: #4B5A70;
}

/* ---- Affordability meter: coloured zones under a native range input, so the marker drags and works from the keyboard ---- */
.aff-meter {
  --aff-pad: 20px;   /* room above the bar for the tick labels; js/affordability.js raises it when labels stack in two rows */
  position: relative;
  padding-top: var(--aff-pad);
}

/* Tick marks (40% / 45% / 50% DTI): positioned in px by js/affordability.js over the same 13px-inset track as the bar and the slider thumb. */
.aff-ticks {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 13px;
  right: 13px;
  pointer-events: none;
}

.aff-tick-line {
  position: absolute;
  width: 2px;
  margin-left: -1px;
  background: #12233D;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.75);
  border-radius: 1px;
}

.aff-tick-label {
  position: absolute;
  height: 14px;
  font-size: 11px;
  font-weight: 700;
  line-height: 14px;
  white-space: nowrap;
  color: #12233D;
}

.aff-ticks-note {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: #4B5A70;
}

.aff-meter-bar {
  display: flex;
  height: 14px;
  margin: 12px 13px;
  border-radius: 7px;
  overflow: hidden;
}

.aff-zone { display: block; height: 100%; }
.aff-zone--ok { background: #2F855A; }
.aff-zone--mid { background: #D69E2E; }
.aff-zone--high { background: #C53030; }

.aff-range {
  position: absolute;
  top: var(--aff-pad);
  left: 0;
  width: 100%;
  height: 38px;
  margin: 0;
  background: transparent;
  cursor: grab;
  -webkit-appearance: none;
  appearance: none;
}

.aff-range:active { cursor: grabbing; }

.aff-range::-webkit-slider-runnable-track {
  height: 38px;
  background: transparent;
}

.aff-range::-moz-range-track {
  height: 38px;
  background: transparent;
}

.aff-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  margin-top: 6px;
  border: 4px solid #12233D;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 4px rgba(18, 35, 61, 0.4);
}

.aff-range::-moz-range-thumb {
  box-sizing: border-box;
  width: 26px;
  height: 26px;
  border: 4px solid #12233D;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 4px rgba(18, 35, 61, 0.4);
}

.aff-range:focus-visible {
  outline: 2px solid #1E40AF;
  outline-offset: 2px;
  border-radius: 8px;
}

.aff-scale {
  display: flex;
  justify-content: space-between;
  padding: 0 4px;
  font-size: 12px;
  color: #4B5A70;
}

.aff-key {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: #4B5A70;
}

.aff-key li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.aff-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.aff-dot--ok { background: #2F855A; }
.aff-dot--mid { background: #D69E2E; }
.aff-dot--high { background: #C53030; }

.aff-verdict {
  min-height: 63px;
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #F7F8FA;
  font-size: 14px;
  line-height: 1.5;
  color: #12233D;
}

.aff-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  color: #FFFFFF;
}

.aff-tag--ok { background: #2F855A; }
.aff-tag--mid { background: #8A5A00; }
.aff-tag--high { background: #C53030; }

/* ---- Payment tab ---- */
.aff-chart {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.aff-chart svg {
  display: block;
  width: 180px;
  height: 180px;
}

.aff-donut-total { font-size: 5px; font-weight: 700; fill: #12233D; }
.aff-donut-sub { font-size: 2.6px; fill: #4B5A70; }

.aff-legend {
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.aff-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 7px 0;
  border-bottom: 1px solid #E5E9F0;
  font-size: 14px;
}

.aff-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: 0 0 auto;
}

.aff-legend-name { flex: 1 1 auto; }
.aff-legend-val { font-weight: 600; font-variant-numeric: tabular-nums; }

.aff-cta {
  display: block;
  margin-top: 16px;
  padding: 13px 16px;
  border-radius: 8px;
  background: #1E40AF;
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.aff-cta:hover,
.aff-cta:focus-visible {
  background: #16327F;
}

.aff-disclaimer {
  margin: 14px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: #4B5A70;
}

/* ---- Financing card ---- */
.aff-talk {
  background: #F7F8FA;
}

.aff-talk-title {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 600;
}

.aff-talk p {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.5;
  color: #4B5A70;
}

.aff-talk-link {
  font-size: 15px;
  font-weight: 600;
  color: #1E40AF;
}

/* ---- Content below ---- */
.aff-copy {
  margin: 48px 0 0;
}

.aff-copy h2 {
  margin: 0 0 12px;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
  color: #12233D;
}

.aff-note {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: #4B5A70;
}

.aff-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.aff-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.aff-table th,
.aff-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #E5E9F0;
  text-align: right;
  white-space: nowrap;
  color: #12233D;
}

.aff-table thead th {
  font-size: 13px;
  font-weight: 600;
  color: #4B5A70;
  border-bottom-color: #DCE1E8;
}

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

.aff-table tbody th {
  font-weight: 600;
}

.aff-table td[data-col="price"] {
  font-weight: 700;
  color: #1E40AF;
}

.aff-notes {
  margin: 0;
}

.aff-notes dt {
  margin: 14px 0 0;
  font-size: 16px;
  font-weight: 700;
  color: #12233D;
}

.aff-notes dd {
  margin: 2px 0 0;
  max-width: 760px;
  font-size: 15px;
  line-height: 1.6;
  color: #3B4A60;
}

.aff-faq-item {
  max-width: 760px;
  border-bottom: 1px solid #E5E9F0;
}

.aff-faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  cursor: pointer;
  list-style: none;
}

.aff-faq-item summary::-webkit-details-marker { display: none; }

.aff-faq-item summary::after {
  content: "+";
  flex: 0 0 auto;
  font-size: 22px;
  line-height: 1;
  color: #1E40AF;
}

.aff-faq-item[open] summary::after { content: "\2212"; }

.aff-faq-item h3 {
  margin: 0;
  padding: 10px 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  color: #12233D;
}

.aff-faq-item p {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 1.6;
  color: #3B4A60;
}

.aff-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin: 40px 0 0;
  font-size: 16px;
  font-weight: 600;
}

.aff-links a { color: #1E40AF; }

/* ---- Phone bottom bar ---- */
.aff-bar {
  display: none;
}

@media (max-width: 899px) {
  .aff-bar:not([hidden]) {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900;
    display: block;
    padding: 8px var(--wrap-gutter, 16px) calc(8px + env(safe-area-inset-bottom, 0px));
    background: #FFFFFF;
    border-top: 1px solid #E2E7EE;
    box-shadow: 0 -2px 10px rgba(18, 35, 61, 0.08);
  }

  .aff-bar button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 48px;
    margin: 0;
    padding: 0 16px;
    border: 0;
    border-radius: 10px;
    background: #1E40AF;
    color: #FFFFFF;
    font-size: 16px;
    cursor: pointer;
  }

  .aff-bar strong { font-size: 18px; }
  .aff-bar-go { font-size: 14px; font-weight: 600; }
}

@media (min-width: 900px) {
  .aff-heading { font-size: 34px; }

  .aff-grid {
    grid-template-columns: 360px minmax(0, 1fr);
    align-items: start;
    gap: 24px;
  }

  .aff-side {
    position: sticky;
    top: 16px;
  }

  .aff-result-card { padding: 20px; }

  .aff-chart {
    flex-direction: row;
    align-items: center;
  }

  .aff-chart svg {
    width: 170px;
    height: 170px;
  }

  .aff-chart > div { flex: 0 0 auto; }
  .aff-legend { flex: 1 1 auto; width: auto; }
}
