/* ==========================================================
   Payout calculator (all classes prefixed "calc-")
   Colours come only from the tokens in styles.css.
   ========================================================== */

.calc-sub { margin-bottom: var(--sp-5); }

/* Two columns on desktop, stacked (controls first) on mobile */
.calc-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: var(--sp-5);
  align-items: start;
}
@media (max-width: 860px) { .calc-layout { grid-template-columns: 1fr; } }

/* ---------- Controls ---------- */
.calc-controls { display: flex; flex-direction: column; gap: var(--sp-5); }
.calc-field { border: 0; margin: 0; padding: 0; min-width: 0; }
.calc-field-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.calc-field label, .calc-field legend { font-weight: 600; font-size: var(--fs-sm); }
.calc-field legend { padding: 0; margin-bottom: var(--sp-2); }
.calc-value { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.calc-value-prize { color: var(--gold); }
.calc-value-pay { color: var(--money); }

/* Range sliders: full width, accent colour follows the money meaning */
.calc-field input[type="range"] {
  width: 100%; padding: 0; border: 0; background: transparent;
  accent-color: var(--brand); cursor: pointer; height: 28px;
}
#calc-prize { accent-color: var(--gold); }
#calc-pay { accent-color: var(--money); }
.calc-field input[type="range"]:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Segmented toggle built from radio inputs (keyboard + screen-reader friendly) */
.calc-seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: var(--radius-sm); padding: var(--sp-1); gap: var(--sp-1); }
.calc-seg input { position: absolute; opacity: 0; pointer-events: none; }
.calc-seg label {
  text-align: center; padding: var(--sp-2) var(--sp-3); border-radius: 6px;
  font-weight: 600; font-size: var(--fs-sm); color: var(--muted); cursor: pointer;
  transition: background .15s, color .15s;
}
.calc-seg input:checked + label { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }
.calc-seg input:focus-visible + label { outline: 2px solid var(--brand); outline-offset: 1px; }

.calc-hint {
  margin: 0; padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm);
  background: var(--brand-soft); color: var(--brand); font-size: var(--fs-xs); font-weight: 600;
}
.calc-hint[hidden] { display: none; }

/* ---------- Token grid ---------- */
.calc-people {
  list-style: none; margin: 0 0 var(--sp-3); padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: var(--sp-3);
}
.calc-token {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--sp-1);
  text-align: center; outline: none;
  transition: opacity .3s ease, transform .3s ease;
}
/* Enter / leave states (added by JS, then removed / element deleted) */
.calc-token.calc-enter, .calc-token.calc-leave { opacity: 0; transform: scale(.5); }

/* The "avatar" is a CSS circle with a tiny head + shoulders drawn using pseudo-elements */
.calc-avatar {
  position: relative; width: 44px; height: 44px; border-radius: 50%;
  background: var(--money-soft); border: 2px solid var(--money);
  overflow: hidden; transition: background .3s, border-color .3s;
}
.calc-avatar::before { /* head */
  content: ""; position: absolute; left: 50%; top: 7px; width: 14px; height: 14px;
  margin-left: -7px; border-radius: 50%; background: var(--money); transition: background .3s;
}
.calc-avatar::after { /* shoulders */
  content: ""; position: absolute; left: 50%; top: 24px; width: 28px; height: 28px;
  margin-left: -14px; border-radius: 50%; background: var(--money); transition: background .3s;
}
.calc-token.is-winner .calc-avatar { background: var(--gold-soft); border-color: var(--gold); }
.calc-token.is-winner .calc-avatar::before,
.calc-token.is-winner .calc-avatar::after { background: var(--gold); }

.calc-star {
  position: absolute; top: -6px; right: calc(50% - 30px); font-size: var(--fs-md); line-height: 1;
  color: var(--gold); background: var(--surface); border-radius: 50%; width: 20px; height: 20px;
  display: none; place-items: center; box-shadow: var(--shadow);
}
.calc-token.is-winner .calc-star { display: grid; }

.calc-amount {
  font-size: var(--fs-xs); font-weight: 700; color: var(--money);
  padding: 1px 8px; border-radius: 999px; background: var(--money-soft); white-space: nowrap;
}
.calc-token.is-winner .calc-amount { color: var(--gold); background: var(--gold-soft); }
.calc-token:focus-visible .calc-avatar, .calc-token:hover .calc-avatar { box-shadow: 0 0 0 3px var(--brand-soft), 0 0 0 5px var(--brand); }

.calc-legend { list-style: none; margin: 0 0 var(--sp-5); padding: 0; display: flex; gap: var(--sp-4); font-size: var(--fs-xs); color: var(--muted); }
.calc-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: var(--sp-1); }
.calc-dot-gold { background: var(--gold); }
.calc-dot-green { background: var(--money); }

/* ---------- Stacked bar ---------- */
.calc-bar { display: flex; height: 22px; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.calc-bar-gold { background: var(--gold); transition: width .4s ease; }
.calc-bar-green { background: var(--money); transition: width .4s ease; }
.calc-bar-labels { display: flex; justify-content: space-between; gap: var(--sp-3); margin-top: var(--sp-2); font-size: var(--fs-xs); font-weight: 700; }
.calc-bar-label-gold { color: var(--gold); }
.calc-bar-label-green { color: var(--money); text-align: right; }

/* ---------- Stats ---------- */
.calc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); margin: var(--sp-5) 0 var(--sp-4); }
@media (max-width: 560px) { .calc-stats { grid-template-columns: 1fr; } }
.calc-stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: var(--sp-3) var(--sp-4); }
.calc-stat-gold { background: var(--gold-soft); }
.calc-stat-green { background: var(--money-soft); }
.calc-stat-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: var(--muted); }
.calc-stat-num { font-size: var(--fs-lg); font-weight: 800; font-variant-numeric: tabular-nums; }
.calc-stat-gold .calc-stat-label, .calc-stat-gold .calc-stat-num { color: var(--gold); }
.calc-stat-green .calc-stat-label, .calc-stat-green .calc-stat-num { color: var(--money); }
.calc-compare { margin: 0; font-weight: 600; }

/* Respect users who prefer less motion: no animations at all */
@media (prefers-reduced-motion: reduce) {
  .calc-token, .calc-avatar, .calc-bar-gold, .calc-bar-green, .calc-seg label { transition: none; }
}
