/* ===========================================================================
   StreamForge — Points economy pane
   Loads after styles.css. Only touches eco-* selectors (+ listed ids).
   Same design language: near-black glass, one pink accent, Geist,
   mono tabular numerals, 18/11/9 radius scale, motion gated by
   prefers-reduced-motion.
   =========================================================================== */

/* ---------- layout: settings rail + main column ---------- */
.eco-grid {
  display: grid;
  grid-template-columns: minmax(340px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin-top: 14px;
}
@media (max-width: 940px) {
  .eco-grid { grid-template-columns: 1fr; }
}

/* ---------- glass cards ---------- */
.eco-card {
  position: relative;
  min-width: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 140px),
    var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px;
  box-shadow: var(--edge-hi), var(--shadow-1);
  animation: sf-eco-card-in 0.55s var(--spring-soft) backwards;
}
.eco-settings { animation-delay: 0.04s; }
.eco-main { animation-delay: 0.1s; }
@keyframes sf-eco-card-in {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

/* faint accent wash in the main card's top-right corner */
.eco-main::before {
  content: ""; position: absolute; top: -60px; right: -60px;
  width: 220px; height: 220px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.07), transparent 70%);
}

/* section headings sit flush at the top of a card; positioning only —
   the .sub-h look itself is untouched */
.eco-card > .sub-h:first-child { margin-top: 0; }

/* ---------- section head rows (title left, action right) ---------- */
.eco-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin: 30px 0 14px;
}
.eco-card-head:first-child { margin-top: 0; }
.eco-card-head .sub-h { margin: 0; }
.eco-card-head > .btn { flex: none; }
#ecoAccounts { font-variant-numeric: tabular-nums; flex: none; }

/* the currency name reads as the accent it is */
#ecoUnitLbl { color: var(--pink-4); font-weight: 600; }

/* ---------- earn rates: a settings matrix, not a stack ---------- */
.eco-earn {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  margin: 2px 0 4px;
}
.eco-earn-f {
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
  font-size: 11.5px; font-weight: 500; color: var(--muted); line-height: 1.35;
}
.eco-earn-f input {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg);
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
@media (max-width: 420px) {
  .eco-earn { grid-template-columns: 1fr; }
}

/* hide number spinners on the compact numeric fields — cleaner matrix */
.eco-earn-f input::-webkit-outer-spin-button,
.eco-earn-f input::-webkit-inner-spin-button,
.eco-rw-cost::-webkit-outer-spin-button,
.eco-rw-cost::-webkit-inner-spin-button,
.eco-rw-cd::-webkit-outer-spin-button,
.eco-rw-cd::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}

/* ---------- chat commands: mono fields in a row ---------- */
.eco-cmds {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 12px;
  margin: 2px 0 4px;
}
.eco-cmds label {
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
  font-size: 11.5px; font-weight: 500; color: var(--muted);
}
.eco-cmds input,
#ecoCmdBalance, #ecoCmdRewards, #ecoCmdRedeem, #ecoCmdLink {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.01em;
  padding: 7px 10px;
  background: var(--bg);
}
.eco-hint {
  margin: 8px 0 2px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
}
.eco-hint em { font-style: normal; font-weight: 600; color: var(--text); }
@media (max-width: 1120px) and (min-width: 941px) {
  .eco-cmds { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .eco-cmds { grid-template-columns: 1fr; }
}

/* ---------- rewards list ---------- */
.eco-reward-list {
  list-style: none; margin: 0 0 6px; padding: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.eco-reward {
  display: grid;
  grid-template-columns: auto minmax(0, 1.1fr) 88px 76px minmax(0, 1.35fr) auto;
  grid-template-areas: "on name cost cd msg del";
  gap: 8px; align-items: center;
  padding: 9px 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--edge-hi);
  transition: border-color var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
  animation: sf-eco-row-in 0.4s var(--spring-soft) backwards;
}
.eco-reward:hover { border-color: var(--border-strong); }
.eco-reward:nth-child(2) { animation-delay: 0.04s; }
.eco-reward:nth-child(3) { animation-delay: 0.08s; }
.eco-reward:nth-child(n + 4) { animation-delay: 0.12s; }
@keyframes sf-eco-row-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

/* toggle placement only — the switch's own look is shared */
.switch.eco-rw-on { grid-area: on; flex: none; margin-right: 2px; }

/* compact, editable-looking inline fields */
.eco-reward input[type="text"],
.eco-reward input[type="number"] {
  padding: 6px 9px;
  font-size: 12.5px;
  background: var(--bg);
  border-radius: var(--r-sm);
}
.eco-rw-name { grid-area: name; font-weight: 600; }
.eco-rw-msg { grid-area: msg; }
.eco-rw-msg { color: var(--muted); }
.eco-rw-msg:focus { color: var(--text); }

/* the price — mono, right-aligned, accent-tinted */
.eco-rw-cost {
  grid-area: cost;
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  text-align: right; font-weight: 600;
  color: var(--pink-4);
  background: rgba(var(--accent-rgb), 0.07);
  border-color: rgba(var(--accent-rgb), 0.24);
}
.eco-rw-cost:hover { border-color: rgba(var(--accent-rgb), 0.4); }

/* cooldown — quiet mono seconds */
.eco-rw-cd {
  grid-area: cd;
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  text-align: right; color: var(--muted);
}
.eco-rw-cd:focus { color: var(--text); }

/* delete — invisible until you mean it, then red */
.eco-rw-del {
  grid-area: del;
  flex: none; padding: 6px 8px;
  color: var(--faint);
  background: transparent; border-color: transparent; box-shadow: none;
}
.eco-rw-del .ph { font-size: 15px; }
.eco-rw-del:hover {
  color: #ff8296;
  background: rgba(255, 84, 112, 0.1);
  border-color: rgba(255, 84, 112, 0.32);
  transform: none;
}
.eco-rw-del:active { transform: scale(0.94); }

/* narrow rows: note drops to its own line */
@media (max-width: 720px) {
  .eco-reward {
    grid-template-columns: auto minmax(0, 1fr) 88px 76px auto;
    grid-template-areas:
      "on name cost cd del"
      ".  msg  msg  msg msg";
  }
}

/* ---------- empty state ---------- */
.eco-empty {
  display: block;
  padding: 24px 18px; text-align: center;
  color: var(--muted); font-size: 12.5px; line-height: 1.55;
  background: rgba(255, 255, 255, 0.015);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  animation: sf-eco-row-in 0.4s var(--ease) backwards;
}

/* ---------- redemption queue ---------- */
.eco-queue {
  list-style: none; margin: 0 0 6px; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.eco-redemption {
  display: grid;
  grid-template-columns: minmax(70px, max-content) minmax(0, 1fr) max-content max-content max-content;
  gap: 12px; align-items: center;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 13px;
  transition: border-color var(--dur-2) var(--ease), background var(--dur-2) var(--ease),
              opacity var(--dur-2) var(--ease);
  animation: sf-eco-row-in 0.4s var(--spring-soft) backwards;
}
.eco-redemption:hover { border-color: var(--border-strong); background: rgba(255, 255, 255, 0.05); }
.eco-redemption:nth-child(2) { animation-delay: 0.04s; }
.eco-redemption:nth-child(3) { animation-delay: 0.08s; }
.eco-redemption:nth-child(n + 4) { animation-delay: 0.12s; }

/* pending rows carry the accent bar — state is never colour-only */
.eco-redemption.st-pending {
  border-color: rgba(var(--accent-rgb), 0.2);
  box-shadow: inset 3px 0 0 rgba(var(--accent-rgb), 0.55);
}
.eco-redemption.st-fulfilled,
.eco-redemption.st-refunded { opacity: 0.55; }
.eco-redemption.st-fulfilled:hover,
.eco-redemption.st-refunded:hover { opacity: 0.85; }

.eco-rd-user {
  font-weight: 700; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.eco-rd-reward {
  min-width: 0; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.eco-rd-cost {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 12.5px; font-weight: 600; color: var(--pink-4);
  white-space: nowrap;
}

/* status pill */
.eco-rd-status {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 999px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  white-space: nowrap;
}
.st-pending .eco-rd-status {
  color: var(--pink-4);
  background: rgba(var(--accent-rgb), 0.12);
  border-color: rgba(var(--accent-rgb), 0.32);
}
.st-fulfilled .eco-rd-status {
  color: #34d399;
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.3);
}
.st-refunded .eco-rd-status {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.09);
  border-color: rgba(251, 191, 36, 0.28);
}

.eco-rd-actions { display: inline-flex; gap: 6px; justify-self: end; }
.st-fulfilled .eco-rd-actions,
.st-refunded .eco-rd-actions { visibility: hidden; }

@media (max-width: 640px) {
  .eco-redemption {
    grid-template-columns: minmax(0, 1fr) max-content max-content;
    grid-auto-flow: row dense;
    gap: 6px 10px;
  }
  .eco-rd-reward { grid-column: 1 / -1; }
  .eco-rd-actions { grid-column: 1 / -1; justify-self: start; }
}

/* ---------- top balances leaderboard ---------- */
.eco-board {
  list-style: none; margin: 0; padding: 0;
  counter-reset: sf-eco-rank;
  display: flex; flex-direction: column; gap: 2px;
}
.eco-board li {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 13px;
  transition: background var(--dur-2) var(--ease);
  animation: sf-eco-row-in 0.35s var(--ease) backwards;
}
.eco-board li:hover { background: rgba(255, 255, 255, 0.035); }
.eco-board li:nth-child(2) { animation-delay: 0.03s; }
.eco-board li:nth-child(3) { animation-delay: 0.06s; }
.eco-board li:nth-child(4) { animation-delay: 0.09s; }
.eco-board li:nth-child(n + 5) { animation-delay: 0.12s; }

.eco-board li::before {
  counter-increment: sf-eco-rank;
  content: counter(sf-eco-rank);
  flex: none; width: 21px; height: 21px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 10.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
}
/* the leader gets the accent */
.eco-board li:first-child { background: rgba(var(--accent-rgb), 0.06); }
.eco-board li:first-child:hover { background: rgba(var(--accent-rgb), 0.09); }
.eco-board li:first-child::before {
  color: #fff; background: var(--pink-grad);
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.4);
}

.eco-bn {
  flex: 1; min-width: 0; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.eco-bp {
  flex: none;
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-weight: 600; font-size: 12.5px;
  color: var(--pink-4);
}

/* ---------- chat games ---------- */
.eco-game {
  padding: 10px 0 2px;
  border-top: 1px solid var(--border);
}
.eco-game:first-child { border-top: none; }
.eco-game-name { margin: 0; font-size: 13px; font-weight: 700; }
.eco-game .eco-cmds { margin-top: 6px; }
.eco-game .eco-hint { margin-top: 4px; }

/* ---------- chat games overlay link ---------- */
/* interactive games tab */
.game-check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 8px 0 4px; }
.wd-live { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.wd-live .muted { flex: 1; min-width: 140px; }

.eco-games-link { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.eco-games-link .btn { flex: none; }
.eco-games-link span { min-width: 0; }

/* ---------- edit points on the balances board ---------- */
.eco-board li { flex-wrap: wrap; }
.eco-bedit { flex: none; margin-left: 6px; opacity: .55; }
.eco-board li:hover .eco-bedit { opacity: 1; }
.eco-bexp {
  flex-basis: 100%; display: flex; align-items: center; gap: 8px;
  padding: 6px 2px 2px;
}
.eco-bexp-amt { flex: 1; min-width: 0; max-width: 130px; }
.eco-edit-add { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.eco-edit-add select { flex: none; }
.eco-edit-add input[type="text"] { flex: 1; min-width: 0; }
.eco-edit-add input[type="number"] { flex: none; width: 90px; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .eco-card,
  .eco-reward,
  .eco-redemption,
  .eco-empty,
  .eco-board li {
    animation: none;
  }
}
