/* ============================================================
   Referral program — only referral.html uses this file (ZEN-306).
   The path a referral travels (the Home delivery spine's rail), the two payout calculators and the referral form.
   Every colour is a token, so the page switches A/B/C like the others. Blocks keep their size whatever the
   controls pick: only values move.
   ============================================================ */

/* ---------- hero ---------- */
.rf-hero { position: relative; padding: 176px 0 40px; overflow-x: clip; }
.rf-hero .hero-glow { z-index: 0; }
.rf-hero .wrap { position: relative; z-index: 1; }
.rf-hero h1 { max-width: 15ch; margin: 22px 0 0; text-wrap: balance; }
.rf-hero-in { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); gap: 56px; align-items: end; }
.rf-hero .hero-ctas { margin-top: 28px; }
/* the deck: a quiet two-line link beside the CTA, no box; hover moves only the colour and the arrow */
.rf-dl { display: inline-flex; flex-direction: column; justify-content: center; gap: 3px; min-height: 58px; margin-left: 10px; border-radius: 10px; color: var(--text); }
.rf-dl-k { font-size: 13px; color: var(--text-muted); }   /* faint on the page bg is 4.3:1 in concept B */
.rf-dl-t { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 500; font-size: 16px; letter-spacing: -0.01em; transition: color .25s var(--ease); }
.rf-dl svg { flex: none; width: 20px; height: 20px; color: var(--accent-text); }
.rf-dl .ar { transition: transform .35s var(--ease); }
.rf-dl:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 6px; }
@media (hover: hover) and (pointer: fine) {
  .rf-dl:hover .rf-dl-t { color: var(--accent-text); }
  .rf-dl:hover .ar { transform: translateY(2px); }
}

/* figures: tabular everywhere a number can change */
.rf-num { font-variant-numeric: tabular-nums; }

/* ---------- the path: who does what, in order; the actor names each step, so no numbers ---------- */
.rf-path { padding-top: 56px; }
.rf-rail { position: relative; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-rows: auto 44px auto; column-gap: 20px; }
/* one shared row height: the tallest card sets it, so every node sits on the same line */
.rf-stage { display: grid; grid-row: span 3; grid-template-rows: subgrid; }
.rf-card {
  position: relative; isolation: isolate; overflow: hidden; padding: 12px 14px 13px; align-self: end;
  border: 1px solid var(--border); border-radius: 12px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 6%, transparent), transparent 45%), var(--surface-solid);
  transition: opacity .5s var(--ease), transform .5s var(--ease), border-color .6s var(--ease), box-shadow .6s var(--ease);
}
.rf-card::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; background-image: var(--grain); background-size: 140px 140px; opacity: .05; mix-blend-mode: overlay; }
.rf-card .h { display: flex; justify-content: space-between; gap: 8px; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--border); font-size: 12.5px; color: var(--text-muted); }
.rf-card .h em { font-style: normal; color: var(--text-faint); }
.rf-card .row { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; line-height: 1.95; color: var(--text-faint); }
.rf-card .row b { font-weight: 400; color: var(--text); text-align: right; white-space: nowrap; }
.rf-card .opt { display: flex; align-items: center; gap: 8px; font-size: 12px; line-height: 2; color: var(--text-muted); }
.rf-card .opt i { position: relative; flex: none; width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--text-faint); transition: border-color .3s var(--ease) var(--k, 0s); }
.rf-card .opt i::after { content: ""; position: absolute; inset: 2px; border-radius: 50%; background: var(--accent-text); transform: scale(.4); opacity: 0; transition: transform .45s var(--ease-spring) var(--k, 0s), opacity .2s var(--ease) var(--k, 0s); }
.rf-card .opt.sel i { border-color: var(--accent-text); }
.rf-card .opt.sel i::after { transform: none; opacity: 1; }
.rf-card .sig { display: block; width: 100%; height: 26px; margin-top: 2px; }
.rf-card .sig path { fill: none; stroke: var(--text-muted); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 0; transition: stroke-dashoffset .9s var(--ease) var(--k, 0s); }
.rf-card .sig-l { border-top: 1px dashed var(--border-strong); padding-top: 3px; font-size: 11px; color: var(--text-faint); }
.rf-card .bars { display: flex; align-items: flex-end; gap: 6px; height: 62px; }
.rf-card .bars i { flex: 1; border-radius: 3px 3px 0 0; background: color-mix(in srgb, var(--accent-soft) 42%, transparent); transform-origin: bottom; transition: transform .5s var(--ease) var(--k, 0s); }
.rf-card .bars-x { display: flex; justify-content: space-between; margin-top: 6px; font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }
.rf-card .split { position: relative; height: 10px; margin: 6px 0 4px; border-radius: 3px; background: color-mix(in srgb, var(--text) 7%, transparent); }
.rf-card .split i { position: absolute; inset: 0; border-radius: 3px; background: linear-gradient(90deg, var(--accent) 0 40%, color-mix(in srgb, var(--accent-soft) 45%, transparent) 40%); clip-path: inset(0 0 0 0 round 3px); transition: clip-path .8s var(--ease) var(--k, 0s); }
.rf-card.last.on { border-color: color-mix(in srgb, var(--accent-soft) 50%, var(--border)); box-shadow: var(--shadow-hover); }   /* lifted, not glowing: it is not a link */

/* each card plays once its node is reached: values type in, the signature draws, revenue grows */
.rf-rail.armed .rf-card:not(.on) { opacity: 0; transform: translateY(8px); }
.rf-rail.armed .rf-card .row b { clip-path: inset(0 0 0 100%); transition: clip-path .5s var(--ease) var(--k, 0s); }
.rf-rail.armed .rf-card.on .row b { clip-path: inset(0 0 0 0); }
.rf-rail.armed .rf-card:not(.on) .opt.sel i { border-color: var(--text-faint); }
.rf-rail.armed .rf-card:not(.on) .opt.sel i::after { transform: scale(.4); opacity: 0; }
.rf-rail.armed .rf-card:not(.on) .sig path { stroke-dashoffset: 1; }
.rf-rail.armed .rf-card:not(.on) .bars i { transform: scaleY(0); }
.rf-rail.armed .rf-card:not(.on) .split i { clip-path: inset(0 100% 0 0 round 3px); }

.rf-node { position: relative; z-index: 1; justify-self: center; align-self: center; width: 10px; height: 10px; background: var(--bg); border: 1px solid color-mix(in srgb, var(--text) 40%, transparent); transition: background-color .25s var(--ease), border-color .25s var(--ease); }
.rf-node::before { content: ""; position: absolute; left: 4px; bottom: 100%; width: 1px; height: 12px; background: color-mix(in srgb, var(--text) 14%, transparent); transition: background-color .3s var(--ease); }
.rf-node.on { background: var(--accent-text); border-color: var(--accent-text); }
.rf-node.on::before { background: color-mix(in srgb, var(--accent-text) 55%, transparent); }
/* placed by js/referral.js from the first node's centre to the last's */
.rf-line { position: absolute; top: var(--ly, 172px); left: var(--lx, 10%); width: var(--lw, 80%); height: 1px; background: color-mix(in srgb, var(--text) 14%, transparent); pointer-events: none; }
.rf-line i { position: absolute; inset: 0; background: var(--accent-text); transform-origin: left; }
/* the dot that travels the path: the wordmark's dot, carried from the introduction to the payout */
.rf-head { position: absolute; z-index: 2; top: -4px; left: -4px; width: 9px; height: 9px; border-radius: 50%; background: var(--logo-mark); opacity: 0; transition: opacity .3s var(--ease); }
.rf-rail.armed .rf-head { opacity: 1; }
.rf-stage .who { font-size: 13.5px; font-weight: 500; color: var(--accent-text); padding-top: 6px; }
.rf-stage h3 { margin-top: 8px; font-size: 18px; letter-spacing: -0.015em; }
.rf-stage p { margin-top: 6px; font-size: 14px; line-height: 1.55; color: var(--text-muted); text-wrap: pretty; }
.rf-stage p a { color: var(--accent-text); text-underline-offset: 3px; }   /* in-text links as on contact.html */
@media (hover: hover) and (pointer: fine) { .rf-stage p a:hover { text-decoration: underline; } }

/* ---------- rough panel (EMPHASIS-PATTERNS §7): opaque, soft top light, grain ---------- */
.rf-panel {
  position: relative; overflow: hidden; isolation: isolate;
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 9%, transparent), transparent 42%), var(--surface-solid);
}
.rf-panel::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none; background-image: var(--grain); background-size: 140px 140px; opacity: .05; mix-blend-mode: overlay; }

/* ---------- segmented switch with a sliding pill: the Home engagement tabs' motion (.eng-tab-ind) ----------
   js/referral.js sizes the pill once and slides it as a transform on --ease-spring, so it overshoots its target */
.rf-seg { position: relative; display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 999px; background: var(--chip-bg); }
.rf-seg button {
  position: relative; z-index: 1; min-width: 52px; height: 36px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent;
  font: 500 14px/1 var(--font-display); letter-spacing: -0.01em; color: var(--text-muted); cursor: pointer; transition: color .3s var(--ease);
}
.rf-seg button::after { content: ""; position: absolute; inset: -4px 0; }   /* 44px to tap */
.rf-seg button:hover { color: var(--text); }
.rf-seg button[aria-pressed="true"] { color: #fff; }
.rf-seg button:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.rf-seg-ind { position: absolute; z-index: 0; top: 4px; left: 0; height: calc(100% - 8px); width: 0; transform-origin: 0 50%; pointer-events: none; transition: transform .5s var(--ease-spring); }
.rf-seg-ind i { display: block; width: 100%; height: 100%; border-radius: 999px; background: var(--accent-fill); box-shadow: 0 6px 20px -10px color-mix(in srgb, var(--accent) 75%, transparent); }

/* ---------- range input in the site's colours ---------- */
.rf-range { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 44px; margin: -8px 0; background: transparent; cursor: pointer; }   /* 44px to tap, 28px in the layout */
.rf-range::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--accent) var(--p, 30%), var(--border-strong) var(--p, 30%)); }
.rf-range::-moz-range-track { height: 4px; border-radius: 4px; background: var(--border-strong); }
.rf-range::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
.rf-range::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.45); transition: box-shadow .25s var(--ease); }
.rf-range::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.45); }
.rf-range:focus-visible { outline: none; }
.rf-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-text), 0 4px 10px rgba(0,0,0,.4); }
.rf-range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px var(--accent-text); }

/* rolling digits: each digit is a 0–9 strip moved by a transform; the screen reader gets the plain value */
.odo { display: inline-flex; align-items: baseline; font-variant-numeric: tabular-nums; white-space: nowrap; }
.odo-d { display: inline-block; height: 1em; line-height: 1; overflow: hidden; }
.odo-s { display: block; transition: transform .7s var(--ease); }
.odo-s span { display: block; height: 1em; }

/* ---------- the payout, worked out: fixed geometry, only values move ---------- */
.rf-calc { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 20px; }
.rf-box { display: flex; flex-direction: column; padding: 30px 32px 32px; }
.rf-box h3 { font-size: 22px; letter-spacing: -0.02em; }
.rf-box .ds { margin-top: 8px; font-size: 15px; color: var(--text-muted); }
.rf-k { font-size: 13px; color: var(--text-faint); }

.rf-sl { position: relative; margin-top: 30px; padding-top: 42px; }
.rf-bub { position: absolute; top: 0; left: 0; padding: 6px 11px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface-solid); font-family: var(--font-display); font-weight: 500; font-size: 15px; line-height: 1.2; color: var(--text); white-space: nowrap; transform: translateX(-50%); will-change: transform; pointer-events: none; }
.rf-bub::after { content: ""; position: absolute; left: calc(50% + var(--ax, 0px)); bottom: -5px; width: 8px; height: 8px; margin-left: -4px; background: inherit; border-right: 1px solid var(--border-strong); border-bottom: 1px solid var(--border-strong); transform: rotate(45deg); }
.rf-mark { position: absolute; top: 74px; transform: translateX(-50%); font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); white-space: nowrap; pointer-events: none; }
.rf-mark::before { content: ""; position: absolute; left: 50%; bottom: 100%; width: 1px; height: 8px; margin-bottom: 2px; background: var(--text-faint); }
.rf-ends { display: flex; justify-content: space-between; margin-top: 24px; font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }

.rf-wf { margin-top: 26px; display: grid; gap: 12px; }
.rf-wf > div { display: grid; grid-template-columns: 178px minmax(0, 1fr) 92px; gap: 14px; align-items: center; font-size: 14px; color: var(--text-muted); }
.rf-wf > div > span { white-space: nowrap; font-variant-numeric: tabular-nums; }
.rf-wf .tr { position: relative; height: 22px; border-radius: 4px; background: color-mix(in srgb, var(--text) 4%, transparent); }
.rf-wf .tr i { position: absolute; inset: 0; transition: clip-path .3s var(--ease); }   /* keeps up with a dragged thumb */
.rf-wf .tr i.a { background: var(--accent); }
.rf-wf .tr i.b { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.rf-wf .tr i.t { background: linear-gradient(90deg, var(--accent) 0 var(--sa, 30%), color-mix(in srgb, var(--accent-soft) 45%, transparent) var(--sa, 30%)); }
.rf-wf b { font-family: var(--font-mono); font-weight: 400; font-size: 14px; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.rf-wf .tot { margin-top: 2px; padding-top: 14px; border-top: 1px solid var(--border); color: var(--text); }
.rf-total { display: grid; gap: 8px; justify-items: start; margin-top: auto; padding-top: 26px; }
.rf-total .n { font-family: var(--font-display); font-weight: 500; font-size: clamp(44px, 4.6vw, 64px); letter-spacing: -0.035em; line-height: 1; color: var(--text); }
.rf-f { font-size: 13.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.rf-ctrl { display: grid; gap: 18px; margin-top: 24px; }
.rf-n { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.rf-rate-h { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.rf-rate-h output { font-family: var(--font-display); font-weight: 500; font-size: 18px; color: var(--text); }   /* Subtitle */

/* the chart: one row per engineer, one segment per monthly payment; not clickable, hover reads a month */
.rf-chart { margin-top: 26px; }
.rf-read { font-size: 14px; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.rf-read b { font-weight: 500; color: var(--text); }
.rf-ax { position: relative; height: 16px; margin: 12px 76px 6px 0; font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }
.rf-ax span { position: absolute; top: 0; white-space: nowrap; }
.rf-grid { display: grid; gap: 6px; cursor: default; }
.rf-grid > div { display: grid; grid-template-columns: minmax(0, 1fr) 64px; gap: 12px; align-items: center; }
.rf-bar { display: grid; grid-template-columns: repeat(24, 1fr); gap: 1px; }
.rf-bar i { position: relative; height: 12px; overflow: hidden; background: color-mix(in srgb, var(--text) 6%, transparent); transition: background-color .15s var(--ease); }
.rf-bar i:first-child { border-radius: 3px 0 0 3px; }
.rf-bar i:last-child { border-radius: 0 3px 3px 0; }
.rf-bar i:nth-child(13) { margin-left: 3px; }   /* year two starts here */
.rf-bar i::after { content: ""; position: absolute; inset: 0; background: var(--accent); opacity: .78; transform: scaleY(0); transform-origin: bottom; transition: transform .35s var(--ease) var(--k, 0s), opacity .15s var(--ease); }
.rf-bar i.on::after { transform: none; }
.rf-bar i.hot { background: color-mix(in srgb, var(--text) 14%, transparent); }
.rf-bar i.hot::after { opacity: 1; }
.rf-sum { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; transition: opacity .3s var(--ease); }
.rf-sum.off { opacity: 0; }

/* ---------- the referral form ---------- */
.rf-form-sec .final-inner { align-items: start; }
.rf-form { padding: 32px; overflow: visible; }   /* the country list of the phone field may hang past the panel */
.rf-form .form-grid { margin-top: 0; }
.rf-form fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.rf-form .rf-seg { align-self: flex-start; }   /* .field is a flex column: hug the buttons, don't stretch the track */
.rf-form legend { margin-bottom: 8px; padding: 0; font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .02em; color: var(--text-faint); }   /* as .field label */
.rf-form .consent { margin-top: 20px; }
.rf-form .btn { margin-top: 22px; }

/* narrower desktops: give the text column room for both hero links on one line */
@media (max-width: 1180px) { .rf-hero-in { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 44px; } }
@media (max-width: 1024px) {
  .rf-hero-in, .rf-calc { grid-template-columns: 1fr; gap: 24px; }
  .rf-rail { grid-template-columns: 1fr; grid-template-rows: none; row-gap: 0; }
  .rf-stage { position: relative; grid-row: auto; grid-template-rows: auto; grid-template-columns: 28px minmax(0, 1fr); column-gap: 18px; padding-bottom: 28px; }
  .rf-stage::before { content: ""; position: absolute; left: 13px; top: 18px; bottom: -6px; width: 1px; background: color-mix(in srgb, var(--accent-text) 50%, transparent); }
  .rf-stage:last-child::before { display: none; }
  .rf-node { grid-column: 1; grid-row: 1; align-self: start; margin-top: 8px; }
  .rf-node::before { display: none; }
  .rf-stage > div:last-child { grid-column: 2; grid-row: 1; }
  .rf-card { grid-column: 2; grid-row: 2; align-self: start; max-width: 360px; margin-top: 14px; }
  .rf-line { display: none; }
}
@media (max-width: 640px) {
  .rf-hero { padding-top: 132px; }
  .rf-dl { margin-left: 0; }
  .rf-box { padding: 22px 18px 24px; }
  .rf-wf > div { grid-template-columns: 1fr 84px; row-gap: 6px; }
  .rf-wf .tr { grid-column: 1 / -1; grid-row: 2; }
  .rf-ax { margin-right: 60px; }
  .rf-grid > div { grid-template-columns: minmax(0, 1fr) 52px; gap: 8px; }
  /* phones: two lines reserved for the texts that change, so the panel keeps its height */
  .rf-read { white-space: normal; min-height: calc(2 * 1.5em); line-height: 1.5; }
  .rf-f { min-height: calc(2 * 1.45em); line-height: 1.45; }
  .rf-form { padding: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .rf-card, .rf-node, .rf-wf .tr i, .rf-bar i::after, .rf-card .sig path, .rf-card .bars i, .rf-card .split i, .rf-card .opt i::after,
  .rf-seg button, .rf-seg-ind, .odo-s, .rf-range::-webkit-slider-thumb { transition: none; }
}
