/*
 * /fee-savings-calculator/ (Bold Stack): the form, the result, the chart and the stack comparison.
 * Loaded after css/bold-stack.css, css/guide-page.css, css/plain-page.css and css/product-page.css.
 * js/calculator.js writes the chart, the dots and the table rows with these classes. Class prefix fc-;
 * the names the script animates stay as they were (chart-col, bar-stack, bar-kept, stack-dot,
 * stack-square, stack-anim, stack-grid, rise, play, pill-pulse).
 *
 * Inputs are 48px tall with a 16px font, so iOS doesn't zoom on focus. Teal is what you keep and white
 * is what the fees take: amber stays for warnings and errors, and nothing here is red.
 */

/* The form beside the result, so the figures change next to the inputs. Stacked on phones. */
.fc-tool { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); align-items: start; gap: 20px; margin-top: 36px; }
.fc-card { min-width: 0; padding: clamp(20px, 2.4vw, 28px); background: var(--bs-surface); border: 1px solid var(--bs-hairline); border-radius: var(--bs-radius-feature); }

/* -------------------------------------------------------------------- form */
.fc-form { position: sticky; top: 100px; display: flex; flex-direction: column; gap: 24px; }
.fc-field { min-width: 0; margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 8px; }
.fc-field > legend { margin-bottom: 8px; padding: 0; }
.fc-label { font-size: 13px; font-weight: 700; }
.fc-input-wrap { position: relative; }
.fc-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  background: var(--bs-slate);
  border: 1px solid var(--bs-outline);
  border-radius: var(--bs-radius-input);
  color: var(--bs-white);
  color-scheme: dark;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}
.fc-input::-webkit-outer-spin-button, .fc-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.fc-input:focus-visible { outline: 2px solid var(--bs-teal); outline-offset: 1px; }
.fc-input--money { padding-left: 32px; }
.fc-input--rate { padding-right: 68px; }
.fc-affix { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 16px; font-weight: 500; pointer-events: none; }
.fc-affix--end { left: auto; right: 14px; font-size: 13px; }

.fc-form .bs-preset { background: var(--bs-slate); }
.fc-form .bs-preset[aria-pressed="true"] { background: rgba(20, 175, 172, 0.16); border: 1.5px solid var(--bs-teal); font-weight: 700; }
.fc-form .bs-preset:focus-visible { outline: 2px solid var(--bs-teal); outline-offset: 2px; }

/* The kit's tabs, as radio buttons. */
.fc-seg { background: var(--bs-slate); }
.fc-seg > label { position: relative; flex: 1 1 0; min-width: 0; display: flex; cursor: pointer; }
.fc-seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.fc-seg .bs-tabs__tab { width: 100%; padding: 0 4px; }
.fc-seg input:checked + .bs-tabs__tab { background: var(--bs-teal); color: var(--bs-slate); font-weight: 700; }
.fc-seg input:focus-visible + .bs-tabs__tab { outline: 2px solid var(--bs-teal); outline-offset: 2px; }
.fc-seg--four .bs-tabs__tab { font-size: 13px; }

/* ------------------------------------------------------------------ result */
.fc-result { display: flex; flex-direction: column; gap: 22px; }
.fc-keep { display: flex; flex-direction: column; gap: 10px; }
.fc-keep-line { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.fc-figure { display: inline-block; transform-origin: left center; color: var(--bs-teal); font-size: clamp(56px, 7vw, 80px); font-weight: 800; letter-spacing: -0.035em; line-height: 1; font-variant-numeric: tabular-nums; }
.fc-keep-with { font-size: clamp(19px, 1.7vw, 22px); font-weight: 700; line-height: 1.2; }
.fc-sats { max-width: 40em; font-size: 15px; font-weight: 500; line-height: 1.5; }

.fc-chart-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 24px; }
.fc-legend { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; font-weight: 500; line-height: 1.4; }
.fc-legend li { display: flex; align-items: center; gap: 8px; }
.fc-swatch { flex: 0 0 auto; width: 12px; height: 12px; border-radius: 3px; }
.fc-swatch--kept { background: var(--bs-teal); }
.fc-swatch--fees { background: var(--bs-white); }
.fc-view { flex: 0 0 220px; }

/* The chart. */
.fc-plot { display: flex; flex-direction: column; gap: 8px; }
.fc-chart { position: relative; height: 320px; margin-top: 16px; }
.fc-chart-layer { position: absolute; inset: 0; }
.fc-chart-bars { display: flex; align-items: flex-end; gap: 6px; }
.fc-grid-line { position: absolute; left: 0; right: 0; border-top: 1px solid var(--bs-hairline); }
.fc-grid-tick { position: absolute; left: 0; top: -16px; font-size: 10.5px; font-weight: 500; }
.chart-col { flex: 1 1 0; min-width: 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.bar-stack { width: 100%; max-width: 28px; display: flex; flex-direction: column; gap: 2px; }
.bar-kept { flex: 1 1 auto; }
.fc-chart-x { display: flex; gap: 6px; font-size: 12px; font-weight: 500; }
.fc-x-label { flex: 1 1 0; min-width: 0; text-align: center; }
.fc-tip { position: absolute; z-index: 2; pointer-events: none; padding: 8px 12px; background: var(--bs-slate); border: 1px solid var(--bs-outline); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); font-size: 12.5px; font-weight: 500; line-height: 1.5; white-space: nowrap; }
.fc-tip strong { font-weight: 700; }

.fc-summary { font-size: 15px; font-weight: 500; line-height: 1.5; }
.fc-summary strong { font-weight: 800; }
.fc-explain { font-size: 15px; font-weight: 400; line-height: 1.55; }

/* The figures as a table. */
.fc-details { border-top: 1px solid var(--bs-hairline); border-bottom: 1px solid var(--bs-hairline); }
.fc-details > summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px; font-size: 15px; font-weight: 700; cursor: pointer; list-style: none; }
.fc-details > summary::-webkit-details-marker { display: none; }
.fc-details[open] { padding-bottom: 18px; }
.fc-swipe { display: none; margin-bottom: 10px; font-size: 13px; font-weight: 500; }
.fc-table .fc-num { text-align: right; font-variant-numeric: tabular-nums; }
.fc-table th { white-space: normal; }
.fc-table thead th:first-child { width: 8%; }
.fc-assume { display: flex; flex-direction: column; gap: 8px; }

/* ------------------------------------------------------------- the two ways on */
.fc-fork { align-items: stretch; margin-top: 20px; }
.fc-fork .pl-card > h2 { font-size: clamp(20px, 1.8vw, 24px); font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.fc-fork .pl-card > p { flex: 1 1 auto; font-size: 15px; font-weight: 500; line-height: 1.5; }
.fc-more { margin-top: 18px; }

/* ---------------------------------------------------- the shape of your stack */
.fc-stack { align-items: stretch; margin-top: 8px; }
.fc-stack .pl-card { gap: 8px; }
.fc-count { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 15px; font-weight: 700; line-height: 1.3; }
.fc-count-n { font-size: clamp(32px, 3.2vw, 44px); font-weight: 800; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.fc-count-n--teal { color: var(--bs-teal); }
.stack-grid { display: flex; flex-wrap: wrap; align-content: flex-start; }
.fc-dots { gap: 2px; margin-top: 12px; }
.fc-dots--squares { gap: 4px; }
.fc-scale:empty { display: none; }
.stack-dot { width: 6px; height: 6px; border-radius: 2px; }
.stack-square { width: 14px; height: 14px; border-radius: 3px; }

/* The cost of moving it. */
.fc-move-name { font-weight: 700; }
.fc-move-pct { font-weight: 700; }
.fc-move-bar { height: 4px; margin: 8px 0 6px; }
.fc-move-bar > div { height: 100%; border-radius: 2px; }
.fc-move-nzd { font-size: 12.5px; font-weight: 500; line-height: 1.5; }
.pl-sec > p.fc-takeaway { font-weight: 700; }

/* ---------------------------------------------------------------- the close */
.fc-final { margin-top: 56px; }
.fc-final .hm-arrow-link { align-self: flex-start; }

/* ---------------------------------------------------------------- movement */
.stack-grid.play .stack-anim { animation: fcMarkIn 0.25s both; animation-delay: calc(var(--i) * 2.5ms); }
@keyframes fcMarkIn { from { opacity: 0; transform: scale(0.2); } to { opacity: 1; transform: scale(1); } }
.chart-col .bar-stack { transition: filter 0.15s; }
.chart-col:hover .bar-stack { filter: brightness(1.15); }
#chart-bars.rise .bar-stack { transform-origin: bottom; animation: fcBarRise 0.45s cubic-bezier(0.22, 1, 0.36, 1) both; animation-delay: calc(var(--col) * 35ms); }
@keyframes fcBarRise { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.pill-pulse { animation: fcPulse 0.3s ease-out; }
@keyframes fcPulse { 0% { transform: scale(1); } 50% { transform: scale(1.04); } 100% { transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  .stack-grid.play .stack-anim, #chart-bars.rise .bar-stack, .pill-pulse { animation: none; }
  .chart-col .bar-stack { transition: none; }
}

/* ------------------------------------------------------------------ phones */
@media (max-width: 860px) {
  .fc-tool { grid-template-columns: minmax(0, 1fr); margin-top: 28px; }
  .fc-form { position: static; }
  .fc-chart { height: 256px; }
  .fc-chart-bars, .fc-chart-x { gap: 3px; }
  .fc-view { flex: 1 1 100%; }
  .fc-swipe { display: block; }
  .fc-final .hp-final-copy .bs-pill { align-self: stretch; }
}
