/* Interactive components: widget cards, equation chips, sliders, buttons,
   shape picker, popups, boss-level stars and win banner. */

/* ---- Widget card ---- */
.widget {
  position: relative;
  background: rgba(18, 22, 36, 0.72);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  max-width: 760px;
  margin: 30px auto 0;
}

.graph-wrap {
  position: relative;
  display: flex;
  justify-content: center;
}

.graph-wrap canvas {
  display: block;
  background: rgba(9, 11, 19, 0.55);
  border: 1px solid var(--rule);
  border-radius: 10px;
}

.drag-hint {
  position: absolute;
  top: 10px;
  right: 14px;
  font: 700 12px var(--body);
  color: var(--ink-faint);
  background: rgba(11, 13, 21, 0.8);
  border: 1px solid var(--rule);
  padding: 3px 10px;
  border-radius: 999px;
  pointer-events: none;
}

/* ---- Equation display ---- */
.eq-display {
  font: 500 23px var(--display);
  font-variant-numeric: tabular-nums;
  text-align: center;
  margin-bottom: 14px;
  min-height: 38px;
}

.eq-display var, .machine-eq var {
  font-style: italic;
  font-family: inherit;
}

.eq-display sup {
  font-size: 0.62em;
  vertical-align: 0.55em;
}

.echip {
  display: inline-block;
  padding: 0 9px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--c) 14%, transparent);
  border: 1.5px solid color-mix(in srgb, var(--c) 50%, transparent);
  color: var(--c);
}

/* ---- Sliders ---- */
.ctrl-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
}

.ctrl-label {
  font: 700 15px var(--body);
  color: var(--c);
  min-width: 148px;
  text-align: right;
}

.ctrl-value {
  font: 600 16px var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--c);
  min-width: 64px;
}

.ctrl-row input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 6px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--c, var(--ink)) 22%, rgba(132, 160, 220, 0.1));
  cursor: pointer;
}

.ctrl-row input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--c, var(--ink));
  border: 2.5px solid var(--paper);
  box-shadow: 0 0 12px color-mix(in srgb, var(--c, var(--ink)) 65%, transparent);
  cursor: grab;
}

.ctrl-row input[type='range']::-moz-range-thumb {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--c, var(--ink));
  border: 2.5px solid var(--paper);
  box-shadow: 0 0 12px color-mix(in srgb, var(--c, var(--ink)) 65%, transparent);
  cursor: grab;
}

.wiggle-btn {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--c, var(--ink));
  color: var(--c, var(--ink));
  background: transparent;
  font-size: 11px;
  cursor: pointer;
}
.wiggle-btn:hover { background: color-mix(in srgb, var(--c) 18%, transparent); }

.ctrl-actions { justify-content: center; gap: 12px; }

/* ---- Buttons ---- */
.btn {
  font: 700 15px var(--body);
  letter-spacing: 0.01em;
  color: var(--ink);
  background: color-mix(in srgb, var(--blue) 16%, transparent);
  border: 1.5px solid var(--blue);
  border-radius: 999px;
  padding: 9px 22px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.12s;
}
.btn:hover {
  background: color-mix(in srgb, var(--blue) 30%, transparent);
  box-shadow: 0 0 18px rgba(88, 196, 221, 0.3);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(1px); box-shadow: none; }

.btn.ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--rule);
}
.btn.ghost:hover { box-shadow: none; background: rgba(132, 160, 220, 0.1); }

/* ---- Function library cards ---- */
.shape-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.shape-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 6px 7px;
  background: rgba(9, 11, 19, 0.6);
  border: 1px solid var(--rule);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.shape-card canvas { width: 76px; height: 46px; }

.shape-card .sc-label {
  font: 700 12.5px var(--body);
  color: var(--ink-soft);
}

.shape-card .sc-sub {
  font: 500 11px var(--mono);
  color: var(--ink-faint);
}

.shape-card:hover { border-color: rgba(88, 196, 221, 0.5); }

.shape-card.active {
  border-color: var(--blue);
  background: rgba(88, 196, 221, 0.08);
  box-shadow: 0 0 16px rgba(88, 196, 221, 0.22);
}
.shape-card.active .sc-label { color: var(--ink); }

.shape-note {
  margin: 14px auto 0;
  max-width: 620px;
  text-align: center;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-soft);
  min-height: 48px;
}

/* ---- Captions under widgets ---- */
.machine-caption, .race-caption {
  text-align: center;
  color: var(--ink-soft);
  font-size: 15.5px;
  margin: 14px auto 0;
  max-width: 580px;
}

/* ---- Boss level ---- */
.challenge { max-width: 760px; margin: 0 auto; }

.challenge-top { text-align: center; }

.stars { font-size: 30px; letter-spacing: 8px; }
.star { color: rgba(233, 237, 247, 0.14); }
.star.earned { color: var(--gold); text-shadow: 0 0 14px rgba(245, 200, 87, 0.55); }
.star.current { color: rgba(233, 237, 247, 0.35); }

.challenge-hint {
  font-size: 16.5px;
  color: var(--ink-soft);
  margin-top: 6px;
}

.win-banner {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 24px;
  background: rgba(11, 13, 21, 0.88);
  border-radius: 14px;
}

.win-text {
  font: 600 25px var(--display);
  max-width: 480px;
}

.win-eq-label {
  font: 700 11px var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: -8px;
}

.win-eq {
  font: 500 28px var(--display);
  text-shadow: 0 0 30px rgba(88, 196, 221, 0.25);
}

.confetti-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

/* ---- Popups ---- */
.popup {
  position: absolute;
  z-index: 50;
  background: #151a2b;
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 14px 50px rgba(0, 0, 0, 0.6);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-soft);
}

.popup strong { color: var(--ink); }

.popup p { margin-bottom: 8px; }

.popup a { font-weight: 700; }

.popup-close {
  position: absolute;
  top: 4px;
  right: 10px;
  border: none;
  background: none;
  font-size: 22px;
  color: var(--ink-faint);
  cursor: pointer;
}
