/* Programs page.
   Backgrounds deliberately reuse the shared palette (--soft / --soft-2 / white
   cards) rather than the flat greys in the mockup, so the page sits on the same
   cream gradient as the rest of the site. */

.programs-page main {
  padding-bottom: clamp(30px, 4vw, 56px);
}

/* --- Hero ---------------------------------------------------------------- */

.programs-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(34px, 4.4vw, 62px) 0 clamp(74px, 8vw, 132px);
}

.programs-hero-media {
  position: absolute;
  top: 0;
  right: 0;
  width: min(58vw, 940px);
  height: 100%;
}

.programs-hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center right;
}

/* Fades the photo into the page background instead of ending on a hard edge. */
.programs-hero-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, #fbf9f5 0%, rgba(251, 249, 245, 0.92) 26%, rgba(251, 249, 245, 0.24) 62%, rgba(251, 249, 245, 0.08) 100%),
    linear-gradient(180deg, rgba(251, 249, 245, 0.35), rgba(251, 249, 245, 0.75));
}

.programs-hero-shell {
  position: relative;
  z-index: 2;
  width: min(1508px, calc(100% - 64px));
  margin: 0 auto;
}

.programs-hero-copy {
  width: min(780px, 58%);
}

.programs-hero h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(36px, 3.3vw, 53px);
  font-weight: 760;
  line-height: 1.04;
}

.programs-hero-lede {
  max-width: 520px;
  margin: 18px 0 0;
  color: #303642;
  font-size: 17px;
  line-height: 1.55;
}

/* --- Loan comparison card ------------------------------------------------ */

.loan-section {
  position: relative;
  z-index: 3;
  width: min(1508px, calc(100% - 64px));
  margin: clamp(-110px, -7vw, -62px) auto 0;
}

.loan-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.loan-tabs {
  display: none;
  gap: clamp(10px, 2.6vw, 42px);
  padding: 0 clamp(18px, 2.4vw, 34px);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: thin;
}

/* Tabs only do something once the script is running. */
.js-tabs .loan-tabs {
  display: flex;
}

.loan-tab {
  position: relative;
  flex: 0 0 auto;
  padding: 18px 6px 16px;
  color: #4a5058;
  background: none;
  border: 0;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.16s ease;
}

.loan-tab::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 3px;
  background: var(--red);
  border-radius: 3px 3px 0 0;
  transform: scaleX(0);
  transition: transform 0.18s ease;
}

.loan-tab:hover {
  color: var(--ink);
}

.loan-tab.is-active {
  color: var(--red);
}

.loan-tab.is-active::after {
  transform: scaleX(1);
}

.loan-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.55fr) minmax(0, 0.95fr);
  gap: clamp(20px, 2.6vw, 40px);
  align-items: start;
  padding: clamp(22px, 2.6vw, 36px) clamp(18px, 2.4vw, 34px);
}

/* Without JS every panel stays on the page, separated for readability. */
.loan-panel + .loan-panel {
  border-top: 1px solid var(--line);
}

.js-tabs .loan-panel {
  display: none;
}

.js-tabs .loan-panel.is-active {
  display: grid;
}

.js-tabs .loan-panel + .loan-panel {
  border-top: 0;
}

/* Icon sits beside the title, with the pills dropping back to the left edge. */
.loan-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 16px;
  align-content: start;
  padding-right: clamp(0px, 1.6vw, 24px);
  border-right: 1px solid var(--line);
}

.loan-summary-icon {
  grid-column: 1;
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  color: var(--ink);
  background: var(--soft-2);
  border-radius: 50%;
}

.loan-summary-icon svg {
  width: 25px;
  height: 25px;
}

.loan-summary h3 {
  grid-column: 2;
  grid-row: 1;
  margin: 6px 0 8px;
  font-size: 23px;
  font-weight: 780;
  line-height: 1.15;
}

.loan-summary > p {
  grid-column: 2;
  grid-row: 2;
  margin: 0 0 18px;
  color: #3d4450;
  font-size: 15px;
  line-height: 1.5;
}

.loan-summary .loan-pill {
  grid-column: 1 / -1;
  justify-self: start;
}

.loan-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 8px 8px 0;
  padding: 9px 15px;
  color: #353b45;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
}

.loan-pill.is-accent {
  color: var(--red);
  border-color: rgba(215, 25, 32, 0.4);
  background: rgba(215, 25, 32, 0.05);
}

.loan-pill svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.loan-specs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px clamp(18px, 2vw, 34px);
  margin: 0;
}

.loan-spec {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 13px 0;
  border-bottom: 1px solid rgba(20, 25, 35, 0.08);
}

/* Last item in each column has nothing after it to separate from. */
.loan-spec:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.loan-spec-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  margin-top: 1px;
  color: var(--ink);
}

.loan-spec-icon svg {
  width: 21px;
  height: 21px;
}

.loan-specs dt {
  margin: 0 0 3px;
  font-size: 14px;
  font-weight: 760;
  line-height: 1.25;
}

.loan-specs dd {
  margin: 0;
  color: #4a515c;
  font-size: 13.5px;
  line-height: 1.45;
}

.loan-about {
  padding: clamp(18px, 1.8vw, 26px);
  background: var(--soft-2);
  border-radius: 10px;
}

.loan-about h4 {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 780;
}

.loan-about p {
  margin: 0 0 16px;
  color: #3d4450;
  font-size: 14px;
  line-height: 1.55;
}

.loan-footnote {
  margin: 14px 0 0;
  padding: 0 clamp(4px, 0.6vw, 10px);
  color: #5b616b;
  font-size: 12.5px;
}

/* --- Assistance + help row ----------------------------------------------- */

.programs-bottom {
  width: min(1508px, calc(100% - 64px));
  margin: clamp(22px, 2.6vw, 38px) auto 0;
  display: grid;
  grid-template-columns: minmax(0, 1.62fr) minmax(0, 1fr);
  gap: clamp(18px, 2vw, 28px);
  align-items: start;
}

.assistance-card {
  padding: clamp(22px, 2.4vw, 34px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
}

.assistance-card h2 {
  margin: 0 0 8px;
  font-size: clamp(22px, 1.9vw, 27px);
  font-weight: 790;
  line-height: 1.15;
}

.assistance-lede {
  margin: 0 0 clamp(18px, 2vw, 26px);
  color: #3d4450;
  font-size: 15.5px;
  line-height: 1.5;
}

.assistance-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(14px, 1.6vw, 24px);
}

.assistance-grid > article {
  padding-right: clamp(10px, 1.2vw, 18px);
  border-right: 1px solid rgba(20, 25, 35, 0.09);
}

.assistance-grid > article:last-child {
  border-right: 0;
  padding-right: 0;
}

.assistance-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 13px;
  color: var(--ink);
  background: var(--soft-2);
  border-radius: 50%;
}

.assistance-icon svg {
  width: 22px;
  height: 22px;
}

.assistance-grid h3 {
  margin: 0 0 6px;
  font-size: 14.5px;
  font-weight: 770;
  line-height: 1.25;
}

.assistance-grid p {
  margin: 0;
  color: #4a515c;
  font-size: 13px;
  line-height: 1.45;
}

.assistance-link {
  display: inline-block;
  margin-top: clamp(18px, 2vw, 26px);
}

.help-card {
  padding: clamp(24px, 2.4vw, 34px);
  background: var(--soft-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  text-align: center;
}

.help-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto 16px;
  color: var(--ink);
  background: #fff;
  border-radius: 50%;
}

.help-icon svg {
  width: 27px;
  height: 27px;
}

.help-card h2 {
  margin: 0 0 10px;
  font-size: clamp(21px, 1.8vw, 26px);
  font-weight: 790;
}

.help-card > p {
  max-width: 340px;
  margin: 0 auto clamp(18px, 2vw, 26px);
  color: #3d4450;
  font-size: 15px;
  line-height: 1.5;
}

.help-cta {
  width: 100%;
}

.help-phone {
  justify-content: center;
  margin-top: 16px;
  font-size: 16px;
}

.help-phone,
.help-cta {
  display: inline-flex;
}

.help-phone {
  display: flex;
}

/* --- Disclaimer ---------------------------------------------------------- */

.programs-disclaimer {
  width: min(1508px, calc(100% - 64px));
  margin: clamp(20px, 2.4vw, 32px) auto 0;
  padding-top: clamp(14px, 1.6vw, 20px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid var(--line);
}

.programs-disclaimer p {
  margin: 0;
  max-width: 760px;
  color: #5b616b;
  font-size: 12.5px;
  line-height: 1.5;
}

.programs-disclaimer .text-link {
  flex: 0 0 auto;
  font-size: 12.5px;
}

/* --- Icon defaults ------------------------------------------------------- */

.loan-summary-icon svg,
.loan-spec-icon svg,
.loan-pill svg,
.assistance-icon svg,
.help-icon svg,
.help-cta svg,
.help-phone svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.help-cta svg {
  width: 21px;
  height: 21px;
  margin-right: 10px;
  stroke-width: 2;
}

/* --- Responsive ---------------------------------------------------------- */

@media (max-width: 1180px) {
  .loan-panel {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  }

  .loan-about {
    grid-column: 1 / -1;
  }

  .assistance-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .assistance-grid > article:nth-child(2n) {
    border-right: 0;
    padding-right: 0;
  }
}

@media (max-width: 900px) {
  .programs-hero-shell,
  .loan-section,
  .programs-bottom,
  .programs-disclaimer {
    width: calc(100% - 40px);
  }

  .programs-hero {
    padding-bottom: clamp(56px, 12vw, 96px);
  }

  .programs-hero-media {
    width: 100%;
  }

  /* Photo sits behind the copy at this size, so it needs a heavier veil. */
  .programs-hero-media::after {
    background:
      linear-gradient(180deg, rgba(251, 249, 245, 0.9) 0%, rgba(251, 249, 245, 0.82) 55%, rgba(251, 249, 245, 0.95) 100%);
  }

  .programs-hero-copy {
    width: 100%;
  }

  .programs-bottom {
    grid-template-columns: 1fr;
  }

  .loan-summary {
    padding-right: 0;
    border-right: 0;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 680px) {
  /* Tighten so all five tabs fit rather than clipping the last one. */
  .loan-tabs {
    gap: 8px;
    padding: 0 14px;
  }

  .loan-tab {
    padding: 16px 5px 14px;
    font-size: 14px;
  }

  .loan-panel {
    grid-template-columns: 1fr;
  }

  .loan-specs {
    grid-template-columns: 1fr;
  }

  /* Single column: only the true last row should lose its rule. */
  .loan-spec:nth-last-child(-n + 2) {
    border-bottom: 1px solid rgba(20, 25, 35, 0.08);
  }

  .loan-spec:last-child {
    border-bottom: 0;
  }

  /* .text-link is nowrap by default; this label is too long to hold one line on
     a narrow phone and was forcing the whole card wider than the viewport. */
  .assistance-link {
    white-space: normal;
  }

  .assistance-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .assistance-grid > article {
    padding-right: 0;
    border-right: 0;
  }

  .programs-disclaimer {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* --- Per-loan detail ------------------------------------------------------ */
/* "Learn more about FHA" used to leave the site for a page about down payment
   assistance; the detail it promised now lives inside the panel. */
.loan-deep {
  grid-column: 1 / -1;
  margin-top: clamp(4px, 0.6vw, 10px);
  border: 1px solid var(--line, #e4e6ea);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.loan-deep > summary {
  cursor: pointer;
  padding: 15px clamp(16px, 1.6vw, 22px);
  font-weight: 780;
  font-size: 15px;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.loan-deep > summary::-webkit-details-marker { display: none; }

.loan-deep > summary::after {
  content: "";
  flex: 0 0 9px;
  width: 9px;
  height: 9px;
  border-right: 2.5px solid var(--brand-red, #d7192b);
  border-bottom: 2.5px solid var(--brand-red, #d7192b);
  transform: rotate(45deg);
  transition: transform .18s ease;
}

.loan-deep[open] > summary::after { transform: rotate(-135deg); }
.loan-deep > summary:hover { background: var(--soft-2, #f6f7f9); }
.loan-deep > summary:focus-visible { outline: 3px solid var(--brand-red, #d7192b); outline-offset: -3px; }

.loan-deep-body {
  padding: 4px clamp(16px, 1.6vw, 22px) clamp(18px, 1.8vw, 24px);
  border-top: 1px solid var(--line, #e4e6ea);
}

.loan-deep-body h4 {
  margin: 16px 0 12px;
  font-size: 17px;
  font-weight: 780;
}

.loan-deep-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 14px clamp(20px, 2.4vw, 40px);
}

.loan-deep-list li {
  padding-left: 20px;
  position: relative;
  font-size: 14px;
  line-height: 1.55;
  color: #3d4450;
}

.loan-deep-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand-red, #d7192b);
}

.loan-deep-list strong {
  display: block;
  color: var(--ink, #12151a);
  font-weight: 780;
  margin-bottom: 3px;
}

@media print {
  .loan-deep-body { display: block !important; }
}
