/*
 * Finance page — the parts that belong to this page only.
 *
 * Hero shell, section rhythm, the segmented control, panels, sliders, media slots
 * and the mid CTA band live in service_pages.css; the hero keyframes live in
 * ink_graphics.css. All three load together from finance/index.
 *
 * Spec: docs/Redesign/design_handoff_service_pages/README.md
 */

/* navbar_home is fixed and roughly 80px tall once the md:h-12 logo is in it.
   .svc-hero-inner's own 76px top padding therefore only just clears it and the
   headline read as though it were tucked under the nav. Same treatment as
   .find-hero, .escrow-hero and .insure-hero. */
.finance-hero .svc-hero-inner {
  padding-top: 156px;
}

/* ============================ hero artwork ============================
   Finance's art layer starts at 54% and its scrim carries a heavier mid-stop
   than the others, because the pig sits further left than the other subjects. */

.finance-hero .svc-hero-art {
  left: 54%;
}

/* Finance's pig sits further left than the other subjects, so its wash reaches
   a little further across. Same weight as the shared one otherwise. */
.finance-hero .svc-hero-scrim {
  background: linear-gradient(
    100deg,
    rgba(20, 48, 110, 0.5) 0%,
    rgba(20, 48, 110, 0.36) 26%,
    rgba(30, 64, 175, 0.2) 42%,
    rgba(37, 99, 235, 0.07) 56%,
    rgba(37, 99, 235, 0) 66%
  );
}

.finance-hero-piggy {
  position: absolute;
  right: 20px;
  bottom: 46px;
  width: min(94%, 520px);
  max-height: 80%;
}

/* =========================== loan categories =========================== */

.finance-cats-head {
  max-width: 660px;
  margin-bottom: 22px;
}

.finance-cat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

/* Photo-backed category tiles — the Firefly loan cards. The navy scrim
   carries brand tone and text contrast (same recipe as the find path tiles);
   the photos are graded neutral-documentary on purpose. */
.finance-cat-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 140px;
  padding: 16px 18px 15px;
  overflow: hidden;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  color: #ffffff;
  background: var(--svc-ink);
  border: 1px solid var(--svc-border);
  border-radius: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.finance-cat-photo {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s var(--svc-ease);
}

.finance-cat-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    to top,
    rgba(10, 24, 61, 0.88) 0%,
    rgba(10, 24, 61, 0.44) 55%,
    rgba(10, 24, 61, 0.14) 100%
  );
}

.finance-cat-tile:hover .finance-cat-photo {
  transform: scale(1.04);
}

.finance-cat-tile:hover {
  border-color: var(--svc-orange);
}

/* The pale orange fill of the old flat tiles is invisible on a photo, so the
   active state is a thick orange ring plus a real shadow — it has to read as
   "selected and clickable" over imagery. The ring is an ::after overlay:
   an inset box-shadow paints beneath the absolutely-positioned photo. */
.finance-cat-tile.is-active {
  border-color: var(--svc-orange);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.18);
}

.finance-cat-tile.is-active::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  border: 3px solid var(--svc-orange);
  border-radius: inherit;
}

.finance-cat-title {
  position: relative;
  z-index: 2;
  display: block;
  margin-bottom: 4px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: #ffffff;
}

.finance-cat-sub {
  position: relative;
  z-index: 2;
  display: block;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
}

/* Panel height changes between categories. That is fine — do not lock it. */
.finance-cat-panels {
  overflow: hidden;
  background: #ffffff;
  border: 1px solid var(--svc-border);
  border-radius: 16px;
}

.finance-cat-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.finance-cat-covers {
  padding: 20px clamp(22px, 3vw, 34px) 22px;
}

.finance-cat-options {
  padding: 20px clamp(22px, 3vw, 34px) 22px;
  background: var(--svc-tint);
  border-left: 1px solid var(--svc-border);
}

.finance-cat-panel-label {
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--svc-faint);
}

.finance-cat-cover {
  display: flex;
  gap: 11px;
  padding: 8px 0;
  font-size: 15px;
  line-height: 1.5;
  color: #334155;
  border-bottom: 1px solid var(--svc-tint-deep);
}

.finance-cat-cover i,
.finance-cat-cover .svg-inline--fa {
  flex: 0 0 13px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--svc-orange);
}

.finance-cat-bestfor {
  margin-top: 14px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--svc-muted);
}

.finance-cat-bestfor span {
  font-weight: 600;
  color: #334155;
}

.finance-cat-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--svc-border);
}

.finance-cat-option i,
.finance-cat-option .svg-inline--fa {
  flex: 0 0 17px;
  font-size: 14px;
  color: var(--svc-orange);
}

.finance-cat-option span {
  font-size: 15px;
  color: #334155;
}

/* =========================== payment estimator =========================== */

/* The estimator is a thing you use, not read, so the whole section is budgeted
   to sit inside a laptop screen without scrolling. Every number here and in the
   panel rules below is part of that; grow one and something else has to give. */
.finance-estimator {
  padding-top: 30px;
  padding-bottom: 34px;
  border-bottom: 1px solid var(--svc-border-soft);
}

.finance-estimator-head {
  max-width: 660px;
  margin-bottom: 10px;
}

.finance-estimator-title {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.03em;
  color: var(--svc-ink);
}

/* Says out loud that the pricing is seed data until /api/rates exists. A plain
   line rather than a pill — as a badge it read like a status people were meant
   to act on, when it is a footnote about where the numbers come from. */
.finance-rate-status {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #a16207;
}

.finance-rate-status.is-live {
  color: #15803d;
}

.finance-estimator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 10px;
}

/* ---- inputs ---- */

.finance-program {
  padding: 8px 16px 8px;
  border-bottom: 1px solid var(--svc-tint-deep);
}

/* Label on the left, Reset on the right — the panel-head strip is gone. */
.finance-program-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.finance-program-row .finance-field-label {
  margin-bottom: 0;
}

.finance-field-label {
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.finance-program-note {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--svc-faint);
}

/* Sliders span the row; the five minor fields sit three across in two rows,
   each label stacked over its input in the slider-head caps style. */
.finance-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  column-gap: 16px;
  padding: 2px 16px 8px;
}

.finance-fields .finance-field:not(.finance-field--slider) {
  padding: 7px 0 2px;
  border-bottom: 0;
}

.finance-fields .finance-field:not(.finance-field--slider) .finance-field-row {
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
}

.finance-fields .finance-field:not(.finance-field--slider) .finance-field-row label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--svc-body);
}

/* The term-clamp echo lives inside the caps label; it speaks, not shouts. */
.finance-fields .finance-field:not(.finance-field--slider) .finance-field-hint {
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
}

.finance-fields .finance-field--slider {
  grid-column: 1 / -1;
}

.finance-field {
  padding: 5px 0;
  border-bottom: 1px solid var(--svc-tint-deep);
}

/* Slider groups read like the home savings calculator: caps label left, the
   value as a big editable figure right (borderless at rest, ring on focus),
   track tight underneath. Same markup and targets — presentation only. */
.finance-field--slider {
  padding: 5px 0 2px;
}

.finance-field--slider .finance-field-row {
  grid-template-columns: minmax(0, 1fr) 168px;
  align-items: baseline;
}

.finance-field--slider .finance-field-row > label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--svc-body);
}

.finance-field--slider .finance-field-hint {
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
}

.finance-field--slider .finance-input {
  background: transparent;
  border-color: transparent;
}

.finance-field--slider .finance-input input {
  padding: 2px 6px;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.finance-field--slider .finance-input-affix {
  font-size: 14px;
  font-weight: 600;
}

.finance-field:last-child {
  border-bottom: 0;
}

.finance-field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 148px;
  gap: 14px;
  align-items: center;
}

.finance-field-row label {
  font-size: 14px;
  color: #334155;
}

.finance-field-hint {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--svc-faint);
}

.finance-input {
  display: flex;
  align-items: center;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.finance-input:focus-within {
  border-color: var(--svc-orange);
  box-shadow: 0 0 0 3px rgba(255, 79, 0, 0.18);
}

/* A field whose text does not parse to a number. The controller pairs this
   with the neutral output state, so the wrong number is never on screen. */
.finance-input.is-invalid {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.finance-input-affix {
  padding: 0 8px;
  font-size: 13px;
  color: var(--svc-faint);
}

.finance-input-affix:first-child {
  padding-left: 11px;
}

.finance-input-affix:last-child {
  padding-right: 11px;
}

.finance-input input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 7px 10px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--svc-ink);
  background: none;
  border: none;
}

.finance-input input:focus {
  outline: none;
}

.finance-field--slider .svc-range {
  margin-top: 0;
}

/* ---- output ---- */

.finance-total {
  padding: 12px 20px 10px;
  border-bottom: 1px solid var(--svc-border-soft);
}

.finance-total-label {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--svc-faint);
}

.finance-total-figure {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.finance-total-amount {
  font-size: 38px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.035em;
  color: var(--svc-ink);
}

.finance-total-per {
  font-size: 16px;
  font-weight: 500;
  color: var(--svc-muted);
}

/* Composition bar. Segments are pre-rendered and hidden when their component is
   zero, so an unused row never shows up as a 0% sliver. */
.finance-bar {
  display: flex;
  height: 10px;
  margin-top: 10px;
  overflow: hidden;
  background: var(--svc-tint-deep);
  border-radius: 999px;
}

.finance-bar-seg {
  flex: 0 0 calc(var(--share, 0) * 1%);
}

.finance-bar-seg[hidden],
.finance-legend-item[hidden] {
  display: none;
}

.finance-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 18px;
  margin-top: 8px;
}

.finance-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--svc-muted);
}

.finance-legend-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.finance-legend-pct {
  font-weight: 600;
  color: #334155;
}

.finance-bar-seg.is-pi,
.finance-legend-dot.is-pi {
  background: var(--svc-orange);
}

.finance-bar-seg.is-tax,
.finance-legend-dot.is-tax {
  background: #1e40af;
}

.finance-bar-seg.is-ins,
.finance-legend-dot.is-ins {
  background: #60a5fa;
}

.finance-bar-seg.is-mi,
.finance-legend-dot.is-mi {
  background: #a16207;
}

.finance-bar-seg.is-hoa,
.finance-legend-dot.is-hoa {
  background: var(--svc-faint);
}

.finance-ledger {
  padding: 4px 20px 0;
}

.finance-ledger-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 0;
  font-size: 15px;
  border-bottom: 1px solid var(--svc-tint-deep);
}

.finance-ledger-row > span:first-child {
  color: var(--svc-muted);
}

.finance-ledger-row > span:last-child {
  font-weight: 600;
  color: var(--svc-ink-soft);
}

.finance-summary {
  padding: 4px 20px 2px;
}

.finance-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 5px 0;
  font-size: 14px;
}

.finance-summary-row > span:first-child {
  color: var(--svc-faint);
}

.finance-summary-row > span:last-child {
  font-weight: 600;
  color: var(--svc-body);
}

/* The program-row Reset. Plain padding only — the old panel-head version used
   negative margins, and in this flex row they let the z-indexed seg buttons
   below swallow the click. */
.finance-reset {
  padding: 6px 0 6px 12px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #2563eb;
  background: none;
  border: 0;
  cursor: pointer;
}

.finance-reset:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

.finance-reset:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.finance-estimator-cta {
  margin: 0 20px 14px;
}

.finance-estimator-cta-note {
  margin-top: 8px;
  text-align: center;
  font-size: 13px;
  color: var(--svc-faint);
}

.finance-estimator-note {
  margin: 14px 0 0;
  max-width: 70ch; /* unbounded it ran ~177ch across the section */
  font-size: 13px;
  line-height: 1.65;
  color: var(--svc-faint);
  text-wrap: pretty;
}

/* Mobile sticky total. Desktop never shows it — the output panel is beside
   the inputs there. The controller toggles .is-on while the estimator section
   is in the viewport. */
.finance-total-sticky {
  display: none;
}

@media (max-width: 767px) {
  .finance-total-sticky {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
    background: #ffffff;
    border-top: 1px solid var(--svc-border);
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
    transform: translateY(110%);
    transition: transform 0.25s ease;
  }

  .finance-total-sticky.is-on {
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .finance-total-sticky {
    transition: none;
  }
}

.finance-total-sticky-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--svc-muted);
}

.finance-total-sticky-amount {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--svc-ink);
}

/* ============================ how it works ============================ */

.finance-hiw-media {
  margin-top: 34px;
}

/* ======================= loan guidelines & resources =======================
   A reference band, not a headline section — 52/56px tall rather than the
   section scale, on its own pale blue. */

.finance-resources {
  padding: 40px clamp(24px, 5vw, 64px) 44px;
  background: #f5faff;
  border-top: 1px solid #e6eef7;
}

.finance-resources-grid {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: clamp(30px, 5vw, 72px);
  align-items: start;
}

.finance-resources-title {
  margin: 0 0 10px;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--svc-ink);
}

.finance-resources-blurb {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--svc-muted);
  text-wrap: pretty;
}

.finance-resources-rows {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0 clamp(28px, 4vw, 56px);
}

.finance-resource-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 0;
  color: var(--svc-ink);
  text-decoration: none;
  border-bottom: 1px solid #e6eef7;
  /* Background only — an animated padding-left re-lays the row out every
     frame; the hover indent applies in one step and the fade masks it. */
  transition: background 0.2s ease;
}

.finance-resource-row:hover {
  color: var(--svc-ink);
  background: #ffffff;
  padding-left: 8px;
}

.finance-resource-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.finance-resource-desc {
  font-size: 14px;
  color: var(--svc-muted);
}

.finance-resource-row i,
.finance-resource-row .svg-inline--fa {
  margin-left: auto;
  font-size: 10px;
  color: var(--svc-hairline);
}


/* ====================== laptop-viewport budget ======================
   Owner 2026-08-09: the page read as endless scrolling. Section paddings and
   the how-it-works rhythm are tightened finance-wide; the estimator internals
   are tightened at their own rules above. */

.finance-page-wrapper .svc-section {
  padding-top: 48px;
  padding-bottom: 52px;
}

.finance-page-wrapper .svc-midcta {
  padding-bottom: 52px;
}

.finance-page-wrapper .svc-hiw {
  gap: clamp(28px, 4vw, 52px);
}

/* No headline to clear since the h2 came out of this section. */
.finance-page-wrapper .svc-hiw-steps {
  padding-top: 0;
}

.finance-page-wrapper .svc-hiw-step {
  padding-top: 13px;
  padding-bottom: 13px;
}

/* ====================== home-calculator sliders ======================
   Same language as the home savings calculator: 4px track, orange fill,
   orange thumb in a white ring. payment_estimator_controller keeps --fill in
   step with the value; Firefox fills natively via ::-moz-range-progress. */

.finance-page-wrapper .svc-range {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

.finance-page-wrapper .svc-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg,
    #ff4f00 0 var(--fill, 50%), #e2e8f0 var(--fill, 50%) 100%);
}

.finance-page-wrapper .svc-range::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: #e2e8f0;
}

.finance-page-wrapper .svc-range::-moz-range-progress {
  height: 4px;
  border-radius: 999px;
  background: #ff4f00;
}

.finance-page-wrapper .svc-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -8px;
  border-radius: 50%;
  background: #ff4f00;
  border: 3px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  cursor: grab;
}

.finance-page-wrapper .svc-range::-moz-range-thumb {
  box-sizing: border-box;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ff4f00;
  border: 3px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  cursor: grab;
}

/* ============================= responsive ============================= */

@media (max-width: 1023px) {
  .finance-resources-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 767px) {
  /* Same clearance, against the shorter mobile navbar (h-8 logo). */
  .finance-hero .svc-hero-inner {
    padding-top: 108px;
  }

  .finance-cat-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .finance-cat-options {
    border-left: 0;
    border-top: 1px solid var(--svc-border);
  }

  .finance-estimator-title {
    font-size: 27px;
  }

  .finance-fields {
    grid-template-columns: 1fr;
  }

  .finance-field-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .finance-total-amount {
    font-size: 34px;
  }
}
