/* ============================================================
   [bonus_calculator] widget (.bc- block + .bcw breakout wrapper).
   Rendered by inc/bonus-calculator.php; live math in
   js/bonus-calculator-v2.js. Consumes tokens.css only, so the
   widget is stack-agnostic (v2 pages and, until the port, any
   legacy page that ever carries the shortcode).
   Design reference: mockups/bonus-calculator-v2/index.html.
   ============================================================ */

/* breakout wrapper: on the article shell the widget spreads wider than
   the reading column. On narrow viewports it goes static (a transformed
   ancestor would become the containing block for any fixed descendant;
   none exist here, but the family convention stands). */
.bcw {
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  width: min(66rem, calc(100vw - 2 * var(--bji-gutter)));
  margin-bottom: var(--bji-space-6);
}
@media (max-width: 880px) {
  .bcw { position: static; left: auto; transform: none; width: auto; }
}

.bc-calc {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 4fr);
  background: var(--bji-surface);
  border: 1px solid var(--bji-border);
  border-radius: var(--bji-radius-xl);
  box-shadow: var(--bji-shadow-lg);
  overflow: hidden;
}
@media (max-width: 880px) { .bc-calc { grid-template-columns: 1fr; } }

/* --- left panel: the offer, as the T&Cs state it --- */
.bc-in { padding: var(--bji-space-6); }
.bc-in > h2 { margin: 0 0 var(--bji-space-1); font-size: var(--bji-text-xl); font-weight: var(--bji-weight-bold); }
.bc-in > .hint { margin: 0 0 var(--bji-space-5); font-size: var(--bji-text-sm); color: var(--bji-text-muted); }

.bc-seg { display: inline-flex; background: var(--bji-gray-050); border: 1px solid var(--bji-border-strong); border-radius: var(--bji-radius-pill); padding: 3px; }
/* labels/spans are block flex items: inline-block here would add baseline
   descender space under the pills (uneven top/bottom gap) */
.bc-seg label { position: relative; display: block; }
.bc-seg input { position: absolute; opacity: 0; pointer-events: none; }
.bc-seg span {
  display: block;
  white-space: nowrap;
  padding: 6px 16px;
  border-radius: var(--bji-radius-pill);
  font-size: var(--bji-text-sm);
  font-weight: var(--bji-weight-semibold);
  color: var(--bji-text-muted);
  cursor: pointer;
  transition: background var(--bji-duration-fast) var(--bji-ease), color var(--bji-duration-fast) var(--bji-ease);
}
.bc-seg input:checked + span { background: var(--bji-navy-900); color: #fff; }
.bc-seg input:focus-visible + span { outline: 2px solid var(--bji-blue-500); outline-offset: 2px; }

.bc-fields { display: grid; grid-template-columns: 1fr 1fr; gap: var(--bji-space-4); margin-top: var(--bji-space-5); }
@media (max-width: 560px) { .bc-fields { grid-template-columns: 1fr; } }
.bc-field label { display: block; font-size: var(--bji-text-sm); font-weight: var(--bji-weight-semibold); margin-bottom: 6px; }
.bc-field label .tc { font-weight: var(--bji-weight-regular); color: var(--bji-text-faint); }
.bc-field input[type="number"], .bc-field select {
  width: 100%;
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--bji-border-strong);
  border-radius: var(--bji-radius-sm);
  background: var(--bji-surface);
  color: var(--bji-text);
}
.bc-field input:focus, .bc-field select:focus { outline: 2px solid var(--bji-blue-500); outline-offset: 0; border-color: var(--bji-blue-500); }
.bc-field[hidden] { display: none; }
.bc-field .sub-seg { margin-top: 8px; }
/* the generic field-label margin must not pad the pills inside a seg */
.bc-field .bc-seg label { margin-bottom: 0; }

/* unit affixes: $ leads money, % trails rates */
.bc-unit { position: relative; }
.bc-unit > span {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--bji-text-sm);
  font-weight: var(--bji-weight-semibold);
  color: var(--bji-text-faint);
  pointer-events: none;
}
.bc-unit.money > span { left: 12px; }
.bc-unit.money > input { padding-left: 26px; }
.bc-unit.rate > span { right: 12px; }
.bc-unit.rate > input { padding-right: 30px; }

.bc-quick { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.bc-quick button {
  font: inherit;
  font-size: var(--bji-text-xs);
  font-weight: var(--bji-weight-semibold);
  padding: 4px 12px;
  border-radius: var(--bji-radius-pill);
  border: 1px solid var(--bji-border-strong);
  background: var(--bji-surface);
  color: var(--bji-text-muted);
  cursor: pointer;
}
.bc-quick button:hover { border-color: var(--bji-blue-500); color: var(--bji-blue-600); }

/* click-to-reveal field explainers (hover titles die on touch) */
.bc-info {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin-left: 4px;
  padding: 0;
  border: 1px solid var(--bji-border-strong);
  border-radius: 50%;
  background: var(--bji-surface);
  color: var(--bji-text-faint);
  font-size: 10px;
  font-weight: var(--bji-weight-bold);
  line-height: 1;
  vertical-align: 1px;
  cursor: pointer;
}
.bc-info:hover, .bc-info[aria-expanded="true"] { border-color: var(--bji-blue-500); color: var(--bji-blue-600); }
.bc-field .bc-tip {
  margin: 6px 0 0;
  padding: var(--bji-space-2) var(--bji-space-3);
  background: var(--bji-gray-050);
  border-left: 3px solid var(--bji-blue-500);
  border-radius: var(--bji-radius-sm);
  font-size: var(--bji-text-xs);
  font-weight: var(--bji-weight-regular);
  color: var(--bji-text-muted);
}
.bc-field .bc-tip[hidden] { display: none; }

/* --- right panel: the receipt --- */
.bc-out {
  background: var(--bji-navy-900);
  color: var(--bji-text-inverse);
  padding: var(--bji-space-6);
  display: flex;
  flex-direction: column;
}
.bc-out h2 { margin: 0 0 var(--bji-space-4); font-size: var(--bji-text-xl); font-weight: var(--bji-weight-bold); }
.bc-out .rows { display: grid; gap: 0; }
.bc-out .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--bji-space-3);
  padding: 10px 0;
  border-bottom: 1px dashed rgb(255 255 255 / 0.18);
  font-size: var(--bji-text-sm);
}
.bc-out .row .k { color: var(--bji-text-inverse-muted); }
.bc-out .row .k small { display: block; font-size: var(--bji-text-xs); color: rgb(255 255 255 / 0.45); }
.bc-out .row .v { font-weight: var(--bji-weight-bold); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* the label wraps to two lines beside the oversized value, so center
   the pair instead of baseline-aligning against the first line only */
.bc-out .row.total { border-bottom: 0; padding-top: var(--bji-space-4); align-items: center; }
.bc-out .row.total .k { font-size: var(--bji-text-base); color: #fff; }
.bc-out .row.total .v { font-size: var(--bji-text-3xl); line-height: 1; }
.bc-out .v.good { color: #3ddc84; }
.bc-out .v.bad { color: #ff7676; }
.bc-out .v.meh { color: var(--bji-amber-500); }

.bc-out .bc-verdict {
  margin: var(--bji-space-4) 0 0;
  padding: var(--bji-space-3) var(--bji-space-4);
  border-radius: var(--bji-radius-md);
  font-size: var(--bji-text-sm);
  background: rgb(255 255 255 / 0.08);
  border: 1px solid rgb(255 255 255 / 0.14);
}
.bc-verdict b { color: #fff; }
.bc-out .bc-cap-warn {
  margin: var(--bji-space-3) 0 0;
  font-size: var(--bji-text-xs);
  color: var(--bji-amber-500);
}
.bc-out .bc-cap-warn[hidden] { display: none; }
.bc-out .bc-be { margin: var(--bji-space-3) 0 0; font-size: var(--bji-text-xs); color: rgb(255 255 255 / 0.6); }
.bc-be b { color: #fff; }
.bc-out .bc-be[hidden] { display: none; }
/* no margin-top:auto here: pinning this note to the panel bottom opened
   a void above it whenever the inputs panel grew taller (open tips);
   spare panel height now falls quietly below the note instead */
.bc-out .bc-assume { margin: 0; padding-top: var(--bji-space-4); font-size: var(--bji-text-xs); color: rgb(255 255 255 / 0.45); }
