/* Quickli borrowing calculator (template-parts/quickli-calculator.php). Loaded by header.php for the
   Calculators page and by header-home-redesign.php for loan pages.
   The widget's own background (#EFE7DB) is set in Quickli; containers around it use the same colour.
   The widget is a cross-origin iframe: avoid clip-path / container queries on its ancestors, which can stop
   Chrome from routing pointer events into it. Crops use plain overflow clipping instead; "clip" (not "hidden") so
   scrollIntoView calls (e.g. Quickli's own scroll-into-view message) can't scroll the cropped part back into view.
   "clip" doesn't contain the iframe wrapper's negative crop margin by itself, so flow-root does. */

.quickli-embed {
  display: flow-root;
  position: relative;
  overflow: hidden;
  overflow: clip;
}

.quickli-embed .quickli-placeholder {
  display: none !important;
}

/* Hides the widget's "Assumptions & Disclaimer" link by cropping the iframe bottom.
   Crop sizes follow the widget's own 617px layout breakpoint; quickli-embed--wide is toggled by the partial's
   script from the iframe (= container) width.
   Below 617px the widget leaves almost no space under its last card, so 40px of spacing is added back. */
.quickli-embed .quickli-form {
  margin-bottom: -100px;
}

.quickli-embed:not(.quickli-embed--wide) {
  margin-bottom: 40px;
}

.quickli-embed.quickli-embed--wide .quickli-form {
  margin-bottom: -120px;
}

/* Borrowing-capacity widget (not the Calculators page picker) and purchasing-power widget. Below 617px they are a
   step-by-step layout whose step button is pinned to the iframe bottom with the disclaimer link just above it, so a
   beige strip covers the disclaimer instead. */
.quickli-embed--borrowing-capacity:not(.quickli-embed--picker):not(.quickli-embed--wide),
.quickli-embed--purchasing-power:not(.quickli-embed--wide) {
  margin-bottom: 0;
}

.quickli-embed--borrowing-capacity:not(.quickli-embed--picker):not(.quickli-embed--wide) .quickli-form,
.quickli-embed--purchasing-power:not(.quickli-embed--wide) .quickli-form {
  margin-bottom: 0;
}

.quickli-embed--borrowing-capacity:not(.quickli-embed--picker):not(.quickli-embed--wide)::after,
.quickli-embed--purchasing-power:not(.quickli-embed--wide)::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 125px;
  height: 80px;
  background: #efe7db;
}

/* Loan pages' loan-repayment widget. Its full-width "Book an Appointment" button sits directly above the
   disclaimer link, so a smaller crop keeps the button whole. */
.quickli-embed--loan-repayment .quickli-form {
  margin-bottom: -92px;
}

.quickli-embed--loan-repayment.quickli-embed--wide .quickli-form {
  margin-bottom: -96px;
}

/* Quickli's "Book an Appointment" button can only open a new tab, so a transparent link sits over it to jump to
   the on-page booking section (or open the Contact side popup on the finance calculator pages). At 617px+ it covers the right-hand button only ("Suggested Lenders" sits on the
   left); position is measured from the container bottom (after the crop above).
   Below 617px the borrowing-capacity and purchasing-power buttons aren't at a fixed position, so Quickli's own button
   action is used there. */
.quickli-embed__book {
  position: absolute;
  left: calc(50% + 8px);
  right: 37px;
  height: 46px;
  z-index: 1;
  border-radius: 999px;
}

.quickli-embed--borrowing-capacity .quickli-embed__book {
  bottom: 73px;
  height: 47px;
}

/* The purchasing-power button is 50px tall at 768px+ and 46px below; the overlay uses the taller size. */
.quickli-embed--purchasing-power .quickli-embed__book {
  bottom: 44px;
  height: 50px;
}

.quickli-embed--borrowing-capacity:not(.quickli-embed--wide) .quickli-embed__book,
.quickli-embed--purchasing-power:not(.quickli-embed--wide) .quickli-embed__book {
  display: none;
}

/* The refinance button can sit up to ~10px higher while the results below it update, so the overlay extends
   8px above the button. */
.quickli-embed--refinance-feasibility .quickli-embed__book {
  bottom: 196px;
  height: 54px;
}

.quickli-embed--refinance-feasibility:not(.quickli-embed--wide) .quickli-embed__book {
  left: 27px;
  right: 27px;
  bottom: 202px;
}

/* The loan-repayment button is full width and the last item in the widget, so its position doesn't move. */
.quickli-embed--loan-repayment .quickli-embed__book {
  left: 10px;
  right: 10px;
  bottom: 14px;
}

.quickli-embed--loan-repayment.quickli-embed--wide .quickli-embed__book {
  left: 20px;
  right: 20px;
  bottom: 20px;
}

/* The stamp-duty button is full width; the results below it keep the same height, so its position doesn't move. */
.quickli-embed--stamp-duty .quickli-embed__book {
  left: 26px;
  right: 26px;
  bottom: 940px;
}

.quickli-embed--stamp-duty.quickli-embed--wide .quickli-embed__book {
  left: 36px;
  right: 36px;
  bottom: 800px;
  height: 50px;
}

/* Calculators page picker: transparent links over its cards ("Borrowing Capacity", "Refinance Feasibility",
   "Loan Repayment", "Stamp Duty", "Purchasing Power") open the matching calculator pages instead of the widget's
   in-frame calculators.
   Below 600px the cards are one column, 200px tall (219px when the text wraps) with 32px gaps. From 600px
   (quickli-embed--grid) they are two columns of up to 368px, centred with at least 52px each side; cards are 219px
   tall below ~840px and 201px above. Links below the first row span both possible positions of their card. */
.quickli-embed__card {
  position: absolute;
  top: 34px;
  left: 34px;
  right: 34px;
  height: 200px;
  z-index: 1;
  border-radius: 16px;
}

.quickli-embed__card--2 {
  top: 266px;
  height: 219px;
}

.quickli-embed__card--3 {
  top: 505px;
  height: 225px;
}

.quickli-embed__card--4 {
  top: 755px;
  height: 207px;
}

.quickli-embed__card--5 {
  top: 962px;
  height: 257px;
}

.quickli-embed--grid .quickli-embed__card {
  top: 44px;
  width: min(368px, (100% - 136px) / 2);
  height: 219px;
}

.quickli-embed--grid .quickli-embed__card--1,
.quickli-embed--grid .quickli-embed__card--3 {
  left: max(52px, 50% - 384px);
  right: auto;
}

.quickli-embed--grid .quickli-embed__card--3,
.quickli-embed--grid .quickli-embed__card--4 {
  top: 283px;
  height: 225px;
}

.quickli-embed--grid .quickli-embed__card--2,
.quickli-embed--grid .quickli-embed__card--4 {
  left: auto;
  right: max(52px, 50% - 384px);
}

/* The fifth card is alone on the third row, centred. */
.quickli-embed--grid .quickli-embed__card--5 {
  top: 508px;
  left: 0;
  right: 0;
  margin: 0 auto;
  height: 262px;
}
