/* =====================================================================
   AutoInvest Calculator — Figma "D - Calculator Template" 8639:28723.
   White band, 1240 container. Two columns (inputs | results), then a growth
   chart card, then a CTA. Sliders use native range inputs styled to the
   soft-blue track + knob; the chart is drawn live by assets/js/autoinvest.js.
   Tokens + component-local --ai-* props.
   ===================================================================== */

.autoinvest {
  --ai-gap: 40px;
  --ai-panel-pad: 40px;
  --ai-plot-h: 180px;
  --ai-yaxis-w: 68px;

  background: var(--gray-0);
  padding-block: 40px 80px; /* 40px gap from the feature row above, 80px to footer */
}

/* ---- Feature row (two image cards above the calculator) ---- */
.autoinvest-features { padding-block: 48px 0; }
.autoinvest-features__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.autoinvest-features__card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 265px;
  padding: 40px;
  border: 1px solid var(--soft-blue);
  border-radius: var(--radius-8);
  box-shadow: 0 0 8px rgba(153, 204, 250, 0.4);
  overflow: hidden;
}
.autoinvest-features__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-8);
  pointer-events: none;
}
.autoinvest-features__text {
  position: relative;
  z-index: 1;
  margin: 0;
  max-width: 260px;
  font-weight: var(--fw-regular);
  font-size: var(--fs-16);
  line-height: 1.4;
  color: var(--gray-8);
  word-break: break-word;
}
@media (max-width: 767.98px) {
  .autoinvest-features { padding-inline: var(--pad-mobile); }
  .autoinvest-features__row { grid-template-columns: 1fr; }
  /* Stack the caption ABOVE a contained image — the desktop overlay (text on
     the photo's light area) has no room on a narrow card, so the product
     imagery printed over the text. */
  .autoinvest-features__card {
    min-height: 0;
    padding: 0;
    background: var(--pale-blue);
  }
  .autoinvest-features__text {
    order: -1;            /* caption first (card is a flex column) */
    max-width: none;
    padding: 24px 20px 16px;
  }
  .autoinvest-features__img {
    position: static;     /* flow below the caption instead of covering it */
    width: 100%;
    height: auto;
    aspect-ratio: 1220 / 530;   /* matches the source; reserves space (no CLS) */
  }
}

.autoinvest__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--ai-gap);
}

/* ---- Two columns: inputs (wider) | results ---- */
.autoinvest__cols {
  display: grid;
  grid-template-columns: 11fr 9fr;   /* Figma 660 : 540 */
  gap: var(--ai-gap);
  width: 100%;
}
.autoinvest__col {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

/* Section sub-heading (Axiforma Medium 32/45). */
.autoinvest__heading {
  margin: 0;
  font-weight: var(--fw-medium);
  font-size: var(--fs-32);
  line-height: var(--lh-45);
  color: #1a1a1a;
  word-break: break-word;
}

/* ---- Panels ---- */
.autoinvest__panel {
  border-radius: var(--radius-8);
  padding: var(--ai-panel-pad);
  flex: 1 1 auto;
}
.autoinvest__panel--inputs {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--ai-gap);
  border: 1px solid var(--gray-3);
}
.autoinvest__panel--results {
  display: flex;
  flex-direction: column;
  gap: 30px;
  background: var(--pale-blue);
  border: 1px solid var(--soft-blue);
}

/* ---- Slider field ---- */
.autoinvest__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.autoinvest__field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: var(--fs-18);
  color: var(--gray-8);
}
.autoinvest__field-label { font-weight: var(--fw-regular); }
.autoinvest__field-value { font-weight: var(--fw-semibold); white-space: nowrap; }

/* Native range, styled: soft-blue filled track + white/blue knob. */
.autoinvest__range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.autoinvest__range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--soft-blue) 0 var(--fill, 50%), var(--gray-3) var(--fill, 50%) 100%);
}
.autoinvest__range::-moz-range-track { height: 4px; border-radius: 2px; background: var(--gray-3); }
.autoinvest__range::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--soft-blue); }
.autoinvest__range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--gray-0);
  border: 2px solid var(--og-blue);
  box-shadow: 0 1px 3px rgba(31, 57, 84, 0.3);
}
.autoinvest__range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gray-0);
  border: 2px solid var(--og-blue);
  box-shadow: 0 1px 3px rgba(31, 57, 84, 0.3);
}
.autoinvest__range:focus-visible { outline: 2px solid var(--og-blue); outline-offset: 4px; border-radius: 4px; }

/* ---- Result figure ---- */
.autoinvest__result { display: flex; flex-direction: column; }
.autoinvest__result-label {
  font-weight: var(--fw-regular);
  font-size: var(--fs-18);
  line-height: var(--lh-25);
  color: var(--gray-8);
}
.autoinvest__result-value {
  font-weight: var(--fw-medium);
  font-size: var(--fs-44);
  line-height: var(--lh-55);
  color: var(--gray-8);
  word-break: break-word;
}
.autoinvest__result--hero .autoinvest__result-value { color: var(--og-blue); }

/* ---- Chart card ---- */
.autoinvest__chart-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  padding: 20px;
  background: var(--gray-0);
  border: 1px solid var(--gray-4);
  border-radius: var(--radius-8);
}
.autoinvest__legend {
  display: flex;
  gap: 30px;
  justify-content: center;
}
.autoinvest__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-12);
  color: var(--gray-8);
}
.autoinvest__dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.autoinvest__dot--invest { background: var(--soft-blue); }
.autoinvest__dot--appr { background: var(--og-blue); }

/* Chart grid: [y labels | plot column], with the "Years" title centred below. */
.autoinvest__chart {
  display: grid;
  grid-template-columns: var(--ai-yaxis-w) 1fr;
  column-gap: 12px;
  align-items: start;
  width: 100%;
}
.autoinvest__yaxis {
  grid-column: 1;
  height: var(--ai-plot-h);   /* matches the SVG height so labels line up with gridlines */
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  text-align: right;
  font-size: 10px;
  color: var(--gray-8);
  white-space: nowrap;
}
.autoinvest__plotwrap {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.autoinvest__svg {
  width: 100%;
  height: var(--ai-plot-h);
  overflow: visible;
}
.autoinvest__grid { stroke: var(--gray-3); stroke-width: 1; vector-effect: non-scaling-stroke; }
.autoinvest__area { fill: rgba(0, 128, 243, 0.08); stroke: none; }
.autoinvest__line { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; }
.autoinvest__line--invest { stroke: var(--soft-blue); }
.autoinvest__line--appr { stroke: var(--og-blue); }

.autoinvest__xaxis {
  position: relative;
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  height: 16px;
}
.autoinvest__xaxis li {
  position: absolute;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--gray-8);
  white-space: nowrap;
}
.autoinvest__xtitle {
  grid-column: 1 / -1;       /* full-width row below the chart */
  justify-self: center;
  margin-top: 6px;
  font-size: 10px;
  font-weight: var(--fw-semibold);
  color: var(--gray-8);
}

/* ---- CTA ---- */
.autoinvest__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 160px;
  padding: 14px 24px;
  border-radius: var(--radius-8);
  background: var(--og-blue);
  color: var(--gray-0);
  font-family: var(--font-sans);
  font-weight: var(--fw-medium);
  font-size: var(--fs-16);
  line-height: 1;
  letter-spacing: 0.16px;
  text-decoration: none;
  white-space: nowrap;
}
.autoinvest__cta:hover { background: #006fd6; }

/* ---- Tablet (≤1023.98): stack inputs above results — the 11fr/9fr split is
   too tight at mid widths; the chart stays fluid (width:100% SVG). ---- */
@media (max-width: 1023.98px) {
  .autoinvest__cols { grid-template-columns: 1fr; }
}

/* ---- Large-mobile / mobile (≤767.98) ---- */
@media (max-width: 767.98px) {
  .autoinvest { padding-inline: var(--pad-mobile); }
  /* grid-template-columns:1fr already set by the 1023.98 block above */
  .autoinvest__cols { gap: 24px; }
  .autoinvest__heading { font-size: clamp(24px, 6.4vw, var(--fs-32)); line-height: 1.3; }
  .autoinvest__panel { padding: 20px; }
  .autoinvest__result-value { font-size: var(--fs-32); line-height: var(--lh-45); }
  .autoinvest { --ai-yaxis-w: 44px; }
  .autoinvest__chart-card { padding: 16px; }
}
