/* Residence-permit calculator (rentsale.me only; loaded from residence_permit.hbs).
 *
 * Adapted from specs/spec-1-residence-permit-calc/vnj-calculator.html. Two deliberate
 * departures from that source, both required to live inside this site:
 *
 * 1. SCOPING. Every rule is prefixed with `.RpCalc`. The source is a standalone document and
 *    uses generic class names (.base, .tag, .pill, .seg, .plan, .summary, .config, .ln) that
 *    would otherwise collide with Bootstrap and style.css. The inner names are kept as-is so
 *    this file stays diffable against a future drop from the designer; `.RpCalc` is the BEM
 *    block, the names inside it are the source's.
 *    The source's `body { ... }` rule lives on `.RpCalc` instead -- style.css makes `body` a
 *    3-row grid, and repainting it here would break the page frame.
 *
 * 2. PALETTE. The source is a blue design system; this uses the site's own theme variables so
 *    the page does not read as a pasted-in widget. Fonts likewise: the Google Fonts link is
 *    dropped (this repo vendors everything, no CDN references anywhere) in favour of ThemeFont.
 */

.RpCalc {
  /* Mapped onto static/rentsale/theme.css. Only these two blocks change to re-skin. */
  --ink: var(--fg-strong-color);
  --ink-2: var(--fg-color);
  --muted: var(--fg-muted-color);
  --paper: var(--bg-color);
  --bg: var(--bg-muted-color);
  --line: var(--border-color);
  --brand: var(--primary-color);
  --brand-2: var(--attention-color);
  --brand-ink: var(--fg-strong-color);

  /* The source's blue tints have no theme equivalent, so they are derived from --brand:
   * ~8% and ~20% over white. Kept as literals rather than color-mix() to avoid depending on
   * that function's browser support. */
  --brand-tint: #f4f5f0;
  --brand-tint-2: #e7e9de;
  /* --primary-color darkened ~11%: the point at which white text reaches 4.5:1, which the
   * 11px uppercase labels on the summary card need. Used ONLY as the card gradient's start. */
  --brand-deep: #787950;

  --mint: #10b981;
  --radius: 12px;
  --r-sm: 8px;
  --shadow: 0 24px 60px -30px var(--shadow-color);
  --font: "ThemeFont", sans-serif;
  --display: "ThemeFont", sans-serif;

  color: var(--ink);
  line-height: 1.5;
  border-radius: var(--border-radius);
  /* Sits inside .container, which already contributes 12px a side -- so the horizontal
   * padding stays small on narrow screens rather than stacking to ~28px. */
  margin: 24px 0 30px;
  padding: clamp(18px, 3.5vw, 44px) clamp(8px, 2vw, 24px) 60px;
  background:
    radial-gradient(90% 60% at 85% -5%, var(--brand-tint) 0%, transparent 55%),
    radial-gradient(70% 50% at 0% 0%, #e4fbf4 0%, transparent 45%),
    var(--bg);
}

/* box-sizing is already set globally by Bootstrap's reboot, so the source's `*` rule is gone. */

.RpCalc .shell {
  max-width: 1000px;
  margin: 0 auto;
  position: relative;
  font-family: var(--font);
}

.RpCalc .masthead {
  margin: 0 auto 26px;
  max-width: 640px;
  text-align: center;
  padding-top: 8px;
}

/* Was a <span>; it is the page's <h1> now, hence the margin reset. */
.RpCalc .tagline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand-ink);
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 7px 14px;
  border-radius: 99px;
  box-shadow: 0 6px 18px -12px var(--shadow-color);
}

.RpCalc .tagline .d {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mint);
}

.RpCalc .masthead p {
  color: var(--muted);
  font-size: 15.5px;
  margin: 14px 0 0;
}

.RpCalc .layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 22px;
  align-items: start;
}

@media (max-width: 880px) {
  .RpCalc .layout {
    grid-template-columns: 1fr;
  }
}

.RpCalc .config {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(20px, 3vw, 28px);
  box-shadow: var(--shadow);
}

.RpCalc .sec {
  margin-bottom: 26px;
}

.RpCalc .sec:last-child {
  margin-bottom: 0;
}

.RpCalc .sec-h {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 13px;
}

.RpCalc .sec-n {
  font-family: var(--display);
  font-size: 13px;
  font-weight: 800;
  color: var(--primary-fg-color);
  background: var(--brand);
  width: 24px;
  height: 24px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.RpCalc .sec-t {
  font-size: 15px;
  font-weight: 800;
}

.RpCalc .bases {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.RpCalc .base {
  border: 1.6px solid var(--line);
  border-radius: var(--r-sm);
  padding: 14px;
  cursor: pointer;
  transition: 0.16s;
  background: var(--paper);
  position: relative;
  overflow: hidden;
}

.RpCalc .base:hover {
  border-color: var(--brand-2);
  transform: translateY(-2px);
}

.RpCalc .base:focus-visible,
.RpCalc .pill:focus-visible {
  outline: 2px solid var(--brand-ink);
  outline-offset: 2px;
}

.RpCalc .base.on {
  border-color: var(--brand);
  background: linear-gradient(180deg, var(--brand-tint), var(--paper));
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.RpCalc .base .ic {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--brand-tint);
  color: var(--brand-ink);
  display: grid;
  place-items: center;
  margin-bottom: 10px;
}

.RpCalc .base.on .ic {
  background: var(--brand);
  color: var(--primary-fg-color);
}

.RpCalc .base .ic svg {
  width: 20px;
  height: 20px;
}

.RpCalc .base .t {
  font-weight: 800;
  font-size: 14.5px;
}

.RpCalc .base .p {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

/* 11px, so --fg-strong-color rather than --brand: the olive does not reach 4.5:1 on white. */
.RpCalc .base .tag {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 11px;
  font-weight: 800;
  color: var(--fg-strong-color);
  opacity: 0;
  transition: 0.16s;
}

.RpCalc .base.on .tag {
  opacity: 1;
}

.RpCalc .unsure {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 2px;
  text-align: left;
}

.RpCalc .unsure:hover {
  color: var(--ink);
}

.RpCalc .unsure.on {
  color: var(--brand-ink);
  font-weight: 700;
}

.RpCalc .steprow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1.6px solid var(--line);
  border-radius: var(--r-sm);
  padding: 12px 14px;
}

.RpCalc .steprow .lbl b {
  display: block;
  font-weight: 700;
  font-size: 14.5px;
}

.RpCalc .steprow .lbl span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.RpCalc .stepper {
  display: flex;
  align-items: center;
  border: 1.6px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
}

/* 22px bold counts as large text, so --brand clears the 3:1 bar here. */
.RpCalc .stepper button {
  width: 40px;
  height: 40px;
  border: 0;
  background: var(--brand-tint);
  color: var(--brand-ink);
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}

.RpCalc .stepper button:hover {
  background: var(--brand-tint-2);
}

.RpCalc .stepper button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.RpCalc .stepper .val {
  min-width: 44px;
  text-align: center;
  font-weight: 800;
  font-size: 17px;
  font-family: var(--display);
}

.RpCalc .pill {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1.6px solid var(--line);
  border-radius: var(--r-sm);
  padding: 13px 15px;
  cursor: pointer;
  transition: 0.15s;
  margin-bottom: 10px;
}

.RpCalc .pill:last-child {
  margin-bottom: 0;
}

.RpCalc .pill:hover {
  border-color: var(--brand-2);
}

.RpCalc .pill.on {
  border-color: var(--brand);
  background: var(--brand-tint);
}

.RpCalc .pill .chk {
  width: 24px;
  height: 24px;
  border-radius: var(--r-sm);
  border: 2px solid var(--line);
  flex: 0 0 auto;
  position: relative;
  transition: 0.15s;
}

.RpCalc .pill.on .chk {
  background: var(--brand);
  border-color: var(--brand);
}

.RpCalc .pill.on .chk::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 3px;
  width: 6px;
  height: 12px;
  border: solid var(--primary-fg-color);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.RpCalc .pill .nm b {
  display: block;
  font-weight: 700;
  font-size: 14.5px;
}

.RpCalc .pill .nm span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

/* 13.5px on a pale tint -- see the .tag note above. */
.RpCalc .pill .pr {
  margin-left: auto;
  font-weight: 800;
  font-size: 13.5px;
  color: var(--fg-strong-color);
  background: var(--brand-tint);
  padding: 5px 11px;
  border-radius: 99px;
  white-space: nowrap;
}

.RpCalc .seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--brand-tint);
  padding: 6px;
  border-radius: 14px;
}

.RpCalc .seg button {
  border: 0;
  background: transparent;
  padding: 13px 10px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-2);
  transition: 0.15s;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  text-align: center;
}

.RpCalc .seg button .s {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

.RpCalc .seg button.on {
  background: var(--paper);
  color: var(--brand-ink);
  box-shadow: 0 6px 16px -8px var(--shadow-color);
}

.RpCalc .seg button.on .s {
  color: var(--fg-strong-color);
}

/* The site header is sticky at 72px, so 20px (the source's value) would slide underneath it. */
.RpCalc .summary {
  position: sticky;
  top: 88px;
}

@media (max-width: 880px) {
  .RpCalc .summary {
    position: static;
  }
}

.RpCalc .smartcard {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  background: var(--paper);
}

/* Gradient runs --brand-deep -> --brand-ink. Mapping both ends onto the theme's two olives
 * would have produced a near-flat block, and starting at --brand fails contrast for the 11px
 * labels below. */
.RpCalc .sc-top {
  position: relative;
  padding: 22px 24px 20px;
  color: #fff;
  overflow: hidden;
  background: linear-gradient(135deg, var(--brand-deep) 0%, var(--brand-ink) 100%);
}

.RpCalc .sc-top::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -40px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.16), transparent 65%);
}

/* Full white, not a tint: 11px on the gradient's light end needs the whole 4.5:1. */
.RpCalc .sc-top .k {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #fff;
  font-weight: 700;
}

.RpCalc .sc-basis {
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  line-height: 1.25;
  margin: 6px 0 16px;
  min-height: 44px;
}

.RpCalc .sc-lab {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff;
  font-weight: 600;
}

.RpCalc .sc-price {
  font-family: var(--display);
  font-weight: 800;
  font-size: 46px;
  line-height: 1;
  letter-spacing: -0.02em;
  margin-top: 4px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

/* 22px next to a 46px figure: large text, so a softened white is fine. */
.RpCalc .sc-price small {
  font-size: 22px;
  color: rgba(255, 255, 255, 0.78);
}

.RpCalc .sc-old {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: line-through;
  margin-top: 8px;
  height: 18px;
}

.RpCalc .sc-save {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #b9f5dc;
  padding: 5px 12px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 700;
}

.RpCalc .sc-save.hide {
  display: none;
}

.RpCalc .sc-body {
  padding: 18px 24px 22px;
}

.RpCalc .ln {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
}

.RpCalc .ln span {
  color: var(--muted);
}

.RpCalc .ln b {
  font-weight: 700;
  white-space: nowrap;
}

.RpCalc .ln.disc span,
.RpCalc .ln.disc b {
  color: var(--mint);
}

.RpCalc .ln.tot {
  border-bottom: 0;
  padding-top: 13px;
  font-size: 15px;
}

.RpCalc .ln.tot b {
  font-family: var(--display);
  font-size: 20px;
}

.RpCalc .plan {
  margin-top: 14px;
  background: var(--brand-tint);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 15px 16px;
  display: none;
}

.RpCalc .plan.show {
  display: block;
}

.RpCalc .plan .ph {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-ink);
  margin-bottom: 12px;
}

.RpCalc .timeline {
  display: flex;
  gap: 10px;
}

.RpCalc .tstep {
  flex: 1;
  text-align: center;
  position: relative;
}

.RpCalc .tstep .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--brand);
  margin: 0 auto 8px;
  box-shadow: 0 0 0 4px var(--brand-tint-2);
}

.RpCalc .tstep .amt {
  font-family: var(--display);
  font-weight: 800;
  font-size: 18px;
}

.RpCalc .tstep .cap {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.3;
}

.RpCalc .tbar {
  height: 3px;
  background: var(--brand-tint-2);
  border-radius: 2px;
  margin: 6px 0 12px;
  position: relative;
}

.RpCalc .tbar::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 50%;
  background: var(--brand);
  border-radius: 2px;
}

.RpCalc .savemeter {
  display: flex;
  align-items: center;
  gap: 12px;
}

.RpCalc .savemeter .big {
  font-family: var(--display);
  font-weight: 800;
  font-size: 24px;
  color: var(--mint);
  white-space: nowrap;
}

.RpCalc .savemeter .tx {
  font-size: 12.5px;
  color: var(--ink-2);
}

.RpCalc .incl {
  margin-top: 16px;
}

.RpCalc .incl-h {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 9px;
}

.RpCalc .incl li {
  list-style: none;
  font-size: 13px;
  color: var(--ink-2);
  padding: 4px 0 4px 23px;
  position: relative;
}

.RpCalc .incl li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 8px;
  width: 6px;
  height: 11px;
  border: solid var(--mint);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* The source's .cta rules are gone with the "Go to rentsale.me" button. */

.RpCalc .fineprint {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 13px;
  line-height: 1.5;
  text-align: center;
}
