/* Credit wallet: balances card, notes, history and the Wallet page entry.
   Brand colours come from --accent / --on-accent and the player theme tokens,
   so light and dark both follow the tenant. */

.credits-page {
  --cw-gold: var(--sc-gold, color-mix(in srgb, var(--accent) 72%, var(--ink)));
  --cw-sub: color-mix(in srgb, var(--ink) 68%, var(--card));
  --cw-line2: color-mix(in srgb, var(--line) 78%, var(--ink));
}

.credits-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-start;
}

.credits-main {
  flex: 1 1 600px;
}

.credits-aside {
  flex: 1 1 300px;
  min-width: 0;
  max-width: 100%;
}

.cw-card,
.ch-card {
  box-sizing: border-box;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  color: var(--ink);
}

.cw-card *,
.ch-card * {
  box-sizing: border-box;
}

.cw-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.cw-amount {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin: 8px 0 0;
}

.cw-amount-value {
  font-size: 48px;
  line-height: 56px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.cw-code {
  color: var(--cw-gold);
  font-size: 20px;
  font-weight: 700;
}

.cw-sub {
  margin: 4px 0 0;
  color: var(--cw-sub);
  font-size: 13px;
  line-height: 20px;
}

.cw-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.cw-convert,
.cw-ghost {
  height: 48px;
  border-radius: 12px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.cw-convert {
  padding: 0 24px;
  border: 0;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}

.cw-convert:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.cw-ghost {
  padding: 0 20px;
  border: 1px solid var(--cw-line2);
  background: transparent;
  color: var(--ink);
  font-weight: 600;
}

.cw-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px;
  margin: 24px 0 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--line);
}

.cw-tile {
  min-width: 0;
  padding: 14px 16px;
  background: var(--card);
}

.cw-tile dt {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.cw-lock {
  color: var(--cw-gold);
}

.cw-tile dd {
  margin: 0;
}

.cw-tile-value {
  margin-top: 4px;
  font-size: 18px;
  line-height: 24px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.cw-tile-note {
  color: var(--muted);
  font-size: 12px;
}

.cw-notes {
  padding: 20px;
}

.cw-notes h2 {
  margin: 0;
  font-size: 16px;
  line-height: 24px;
  font-weight: 700;
}

.cw-notes ul {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  color: var(--cw-sub);
  font-size: 13px;
  line-height: 20px;
}

.cw-notes li {
  display: flex;
  gap: 10px;
}

.cw-notes b {
  color: var(--ink);
}

.cw-dot {
  flex: 0 0 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 4px;
  background: var(--cw-line2);
}

.cw-dot[data-tone="accent"] {
  background: var(--cw-gold);
}

.cw-dot[data-tone="yes"] {
  background: var(--yes);
}

/* History */
.ch-title-main {
  margin: 0;
  font-size: 18px;
  line-height: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.ch-list {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.ch-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.ch-icon {
  display: flex;
  flex: 0 0 40px;
  align-items: center;
  justify-content: center;
  height: 40px;
  border-radius: 12px;
  background: var(--soft);
  color: var(--cw-sub);
}

.ch-text {
  flex: 1 1 180px;
  min-width: 0;
}

.ch-title {
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
}

.ch-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.ch-side {
  flex: 0 0 auto;
  text-align: right;
}

.ch-amount {
  font-size: 14px;
  line-height: 20px;
  font-weight: 700;
}

.ch-amount[data-tone="credited"] {
  color: var(--yes);
}

.ch-amount.ch-struck {
  color: var(--muted);
  text-decoration: line-through;
}

.ch-status {
  display: inline-block;
  height: 20px;
  margin-top: 4px;
  padding: 0 8px;
  border-radius: 10px;
  background: var(--soft);
  color: var(--cw-sub);
  font-size: 12px;
  line-height: 20px;
  font-weight: 600;
}

.ch-status[data-tone="credited"] {
  background: var(--yes-soft);
  color: var(--yes);
}

.ch-status[data-tone="locked"] {
  color: var(--cw-gold);
}

.ch-status[data-tone="forfeited"] {
  background: var(--no-soft);
  color: var(--no);
}

.ch-state {
  color: var(--muted);
  font-size: 13px;
}

.ch-state:not(:empty) {
  padding: 24px 0 0;
  border-top: 1px solid var(--line);
}

.ch-state[data-state="loading"] {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 12px;
  border-top: 0;
}

.ch-state[data-state="error"],
.ch-state[data-state="moreError"] {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
}

.ch-state p {
  margin: 0;
}

.ch-state button,
.ch-more button {
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--cw-line2);
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.ch-more {
  margin-top: 12px;
  text-align: center;
}

.ch-more button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.ch-skeleton {
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--soft), var(--line), var(--soft));
  background-size: 200% 100%;
  animation: sc-shimmer 1.3s ease-in-out infinite;
}

.cw-convert:focus-visible,
.cw-ghost:focus-visible,
.ch-state button:focus-visible,
.ch-more button:focus-visible {
  outline: 2px solid var(--focus-ring, var(--accent));
  outline-offset: 2px;
}

@media (hover: hover) {
  .cw-convert:not(:disabled):hover {
    filter: brightness(1.08);
  }

  .cw-ghost:hover,
  .ch-more button:not(:disabled):hover {
    border-color: var(--cw-gold);
  }
}

@media (max-width: 560px) {
  .cw-card,
  .ch-card {
    padding: 20px 16px;
  }

  .cw-amount-value {
    font-size: 40px;
    line-height: 48px;
  }

  .cw-actions > * {
    flex: 1 1 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ch-skeleton {
    animation: none;
  }
}

/* Wallet page entry card */
.credits-entry {
  --ce-gold: color-mix(in srgb, var(--accent) 72%, var(--ink));
  display: block;
  box-sizing: border-box;
  margin: 0 0 12px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  color: var(--ink);
  font-family: "Inter", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}

.credits-entry[hidden] {
  display: none;
}

.ce-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ce-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ce-open {
  color: var(--ce-gold);
  font-size: 12px;
  font-weight: 700;
}

.ce-amount {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 8px;
}

.ce-value {
  font-size: 24px;
  line-height: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.ce-code {
  color: var(--ce-gold);
  font-size: 14px;
  font-weight: 700;
}

.ce-line {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.credits-entry:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}

.credits-entry:focus-visible {
  outline: 2px solid var(--focus-ring, var(--accent));
  outline-offset: 2px;
}

@media (min-width: 900px) {
  .credits-entry {
    margin-bottom: 16px;
  }
}
