/**
 * THREE CHANCES — component set.
 *
 * Depends on design/tokens.css. Card lives separately in design/card.css.
 * One accent only: gold. Win green and loss red are semantic state colours and
 * are never used decoratively — and never as the sole carrier of meaning, so
 * every win/loss state also ships a glyph or a shape difference.
 *
 * Variants are modifier classes, mapping 1:1 to Figma variants.
 */

/* ================================================================
 * BUTTONS
 * ================================================================ */

.tc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--tc-space-2);
  min-height: var(--tc-touch-min);
  padding: 0 var(--tc-space-6);
  border: 1px solid transparent;
  border-radius: var(--tc-radius-button);
  font-family: var(--tc-font-ui);
  font-size: var(--tc-size-body);
  font-weight: var(--tc-weight-semibold);
  letter-spacing: 0.01em;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background-color var(--tc-duration-fast) var(--tc-ease-standard),
    border-color var(--tc-duration-fast) var(--tc-ease-standard),
    transform var(--tc-duration-fast) var(--tc-ease-standard),
    box-shadow var(--tc-duration-fast) var(--tc-ease-standard);
}

.tc-btn--block { width: 100%; }
.tc-btn--sm { min-height: 36px; padding: 0 var(--tc-space-4); font-size: var(--tc-size-label); border-radius: var(--tc-radius-button-sm); }

/* Primary — the single gold call to action. One per screen. */
.tc-btn--primary {
  background: var(--tc-gold);
  color: var(--tc-surface-table);
  box-shadow: 0 2px 12px var(--tc-gold-glow);
}

.tc-btn--primary:hover,
.tc-btn--primary.is-hover {
  background: var(--tc-gold-light);
  box-shadow: 0 4px 20px var(--tc-gold-glow-strong);
}

.tc-btn--primary:active,
.tc-btn--primary.is-pressed {
  transform: translateY(1px);
  box-shadow: 0 1px 6px var(--tc-gold-glow);
}

/* Ghost — secondary actions. Gold hairline, no fill. */
.tc-btn--ghost {
  background: transparent;
  color: var(--tc-gold);
  border-color: rgba(212, 165, 116, 0.45);
}

.tc-btn--ghost:hover,
.tc-btn--ghost.is-hover {
  background: var(--tc-gold-glow);
  border-color: var(--tc-gold);
}

.tc-btn--ghost:active,
.tc-btn--ghost.is-pressed { transform: translateY(1px); }

.tc-btn:disabled,
.tc-btn.is-disabled {
  background: var(--tc-surface-2);
  color: var(--tc-text-disabled);
  border-color: transparent;
  box-shadow: none;
  transform: none;
  cursor: not-allowed;
  pointer-events: none;
}

.tc-btn:focus-visible {
  outline: none;
  box-shadow: var(--tc-focus-ring);
}

/* ================================================================
 * PLAYER CHIP
 * ================================================================ */

.tc-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--tc-space-3);
  padding: var(--tc-space-2) var(--tc-space-4) var(--tc-space-2) var(--tc-space-2);
  background: var(--tc-surface-2);
  border: 1px solid var(--tc-card-edge);
  border-radius: var(--tc-radius-pill);
}

.tc-chip__avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: var(--tc-radius-pill);
  background: linear-gradient(160deg, var(--tc-surface) 0%, var(--tc-surface-table) 100%);
  border: 1px solid rgba(212, 165, 116, 0.4);
  font-family: var(--tc-font-ui);
  font-size: var(--tc-size-micro);
  font-weight: var(--tc-weight-semibold);
  color: var(--tc-gold);
}

.tc-chip__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.tc-chip__name {
  font-family: var(--tc-font-ui);
  font-size: var(--tc-size-label);
  font-weight: var(--tc-weight-medium);
  color: var(--tc-text-primary);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tc-chip__meta {
  font-family: var(--tc-font-mono);
  font-size: 11px;
  color: var(--tc-text-muted);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

/* The player whose turn it is. */
.tc-chip--active {
  border-color: rgba(212, 165, 116, 0.55);
  box-shadow: 0 0 16px var(--tc-gold-glow);
}

/* ================================================================
 * STREAK BADGE
 * Three pips = the three rounds; the count is the streak.
 * ================================================================ */

.tc-streak {
  display: inline-flex;
  align-items: center;
  gap: var(--tc-space-2);
  padding: var(--tc-space-1) var(--tc-space-3);
  border-radius: var(--tc-radius-pill);
  background: rgba(212, 165, 116, 0.12);
  border: 1px solid rgba(212, 165, 116, 0.3);
  font-family: var(--tc-font-mono);
  font-size: var(--tc-size-micro);
  font-weight: var(--tc-weight-medium);
  color: var(--tc-gold);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.tc-streak__label { text-transform: uppercase; letter-spacing: var(--tc-tracking-wide); }

/* Bonus armed — the next win pays the streak bonus. */
.tc-streak--armed {
  background: rgba(212, 165, 116, 0.2);
  border-color: var(--tc-gold);
  color: var(--tc-gold-light);
  box-shadow: 0 0 18px var(--tc-gold-glow-strong);
}

.tc-streak--cold {
  background: transparent;
  border-color: var(--tc-card-edge);
  color: var(--tc-text-muted);
}

/* ================================================================
 * SCORE PILL
 * ================================================================ */

.tc-score {
  display: inline-flex;
  align-items: stretch;
  border-radius: var(--tc-radius-pill);
  overflow: hidden;
  border: 1px solid var(--tc-card-edge);
  background: var(--tc-surface-2);
  font-family: var(--tc-font-mono);
  font-size: var(--tc-size-label);
  font-variant-numeric: tabular-nums;
}

.tc-score__side {
  display: flex;
  align-items: center;
  gap: var(--tc-space-2);
  padding: var(--tc-space-2) var(--tc-space-4);
  color: var(--tc-text-muted);
}

.tc-score__num { color: var(--tc-text-primary); font-size: var(--tc-size-body); }

.tc-score__divider {
  width: 1px;
  background: var(--tc-card-edge);
  flex: 0 0 auto;
}

/* Leading / trailing carry a glyph as well as a colour. */
.tc-score__side--leading { color: var(--tc-win); }
.tc-score__side--leading .tc-score__num { color: var(--tc-win); }
.tc-score__side--trailing { color: var(--tc-loss); }
.tc-score__side--trailing .tc-score__num { color: var(--tc-loss); }

.tc-score__cue { font-size: 11px; line-height: 1; }

/* ================================================================
 * ROUND INDICATOR
 * Three segments. Result rounds carry ✓ / ✗, not colour alone.
 * ================================================================ */

.tc-rounds { display: inline-flex; align-items: center; gap: var(--tc-space-2); }

.tc-rounds__seg {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--tc-radius-pill);
  border: 1px solid var(--tc-card-edge);
  background: var(--tc-surface-2);
  font-family: var(--tc-font-mono);
  font-size: 11px;
  line-height: 1;
  color: var(--tc-text-muted);
}

.tc-rounds__seg--current {
  border-color: var(--tc-gold);
  color: var(--tc-gold);
  box-shadow: 0 0 14px var(--tc-gold-glow);
}

.tc-rounds__seg--won {
  border-color: var(--tc-win);
  background: rgba(95, 194, 139, 0.16);
  color: var(--tc-win);
}

.tc-rounds__seg--lost {
  border-color: var(--tc-loss);
  background: rgba(224, 113, 120, 0.16);
  color: var(--tc-loss);
  /* Shape differs from won: squared, not round. */
  border-radius: var(--tc-radius-button-sm);
}

/* ================================================================
 * OPPONENT THINKING DOTS
 * ================================================================ */

.tc-thinking {
  display: inline-flex;
  align-items: center;
  gap: var(--tc-space-2);
  padding: var(--tc-space-2) var(--tc-space-4);
  border-radius: var(--tc-radius-pill);
  background: var(--tc-surface-2);
  border: 1px solid var(--tc-card-edge);
  font-family: var(--tc-font-ui);
  font-size: var(--tc-size-micro);
  color: var(--tc-text-muted);
}

.tc-thinking__dots { display: inline-flex; gap: 4px; }

.tc-thinking__dot {
  width: 5px;
  height: 5px;
  border-radius: var(--tc-radius-pill);
  background: var(--tc-gold);
  animation: tc-think 1200ms var(--tc-ease-standard) infinite;
}

.tc-thinking__dot:nth-child(2) { animation-delay: 160ms; }
.tc-thinking__dot:nth-child(3) { animation-delay: 320ms; }

@keyframes tc-think {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ================================================================
 * TIMER PILL
 * ================================================================ */

.tc-timer {
  display: inline-flex;
  align-items: center;
  gap: var(--tc-space-2);
  padding: var(--tc-space-2) var(--tc-space-4);
  border-radius: var(--tc-radius-pill);
  background: var(--tc-surface-2);
  border: 1px solid var(--tc-card-edge);
  font-family: var(--tc-font-mono);
  font-size: var(--tc-size-timer);
  font-variant-numeric: tabular-nums;
  color: var(--tc-text-primary);
  line-height: 1;
}

.tc-timer__unit { font-size: var(--tc-size-micro); color: var(--tc-text-muted); }

.tc-timer__track {
  width: 40px;
  height: 3px;
  border-radius: var(--tc-radius-pill);
  background: var(--tc-card-edge);
  overflow: hidden;
}

.tc-timer__fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--tc-gold);
}

/* Warning — running out. Colour shifts AND a ! marker appears AND it pulses,
   so the urgency survives both colour blindness and a muted screen. */
.tc-timer--warning {
  border-color: var(--tc-loss);
  color: var(--tc-loss);
  animation: tc-pulse 900ms var(--tc-ease-standard) infinite;
}

.tc-timer--warning .tc-timer__fill { background: var(--tc-loss); }
.tc-timer--warning .tc-timer__unit { color: var(--tc-loss); }

.tc-timer__alert {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: var(--tc-radius-pill);
  background: var(--tc-loss);
  color: var(--tc-surface-table);
  font-size: 11px;
  font-weight: var(--tc-weight-semibold);
  font-family: var(--tc-font-ui);
}

@keyframes tc-pulse {
  0%, 100% { box-shadow: 0 0 0 var(--tc-loss-glow); }
  50% { box-shadow: 0 0 18px var(--tc-loss-glow-strong); }
}

/* ================================================================
 * STAKES DISPLAY
 * ================================================================ */

.tc-stakes {
  display: inline-flex;
  align-items: center;
  gap: var(--tc-space-5);
  padding: var(--tc-space-3) var(--tc-space-5);
  border-radius: var(--tc-radius-panel);
  background: var(--tc-surface);
  border: 1px solid var(--tc-card-edge);
}

.tc-stakes__item { display: flex; flex-direction: column; gap: 2px; }

.tc-stakes__label {
  font-family: var(--tc-font-ui);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: var(--tc-tracking-wide);
  color: var(--tc-text-muted);
}

.tc-stakes__value {
  font-family: var(--tc-font-mono);
  font-size: var(--tc-size-heading);
  font-variant-numeric: tabular-nums;
  color: var(--tc-text-primary);
  line-height: 1.1;
}

.tc-stakes__value--accent { color: var(--tc-gold); }

/* ================================================================
 * VS DIVIDER
 * ================================================================ */

.tc-vs {
  display: flex;
  align-items: center;
  gap: var(--tc-space-4);
  width: 100%;
}

.tc-vs__line {
  flex: 1 1 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--tc-card-edge) 40%, var(--tc-card-edge) 60%, transparent 100%);
}

.tc-vs__mark {
  font-family: var(--tc-font-display);
  font-size: var(--tc-size-heading);
  color: var(--tc-gold);
  letter-spacing: 0.06em;
  flex: 0 0 auto;
}

/* ================================================================
 * MODE TILE
 * ================================================================ */

.tc-mode {
  display: flex;
  flex-direction: column;
  gap: var(--tc-space-2);
  width: 100%;
  padding: var(--tc-space-5);
  text-align: left;
  background: var(--tc-surface);
  border: 1px solid var(--tc-card-edge);
  border-radius: var(--tc-radius-panel);
  cursor: pointer;
  font-family: var(--tc-font-ui);
  transition:
    border-color var(--tc-duration-fast) var(--tc-ease-standard),
    background-color var(--tc-duration-fast) var(--tc-ease-standard),
    box-shadow var(--tc-duration-fast) var(--tc-ease-standard);
}

.tc-mode__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--tc-space-3); }

.tc-mode__name {
  font-size: var(--tc-size-body);
  font-weight: var(--tc-weight-semibold);
  color: var(--tc-text-primary);
}

.tc-mode__stake {
  font-family: var(--tc-font-mono);
  font-size: var(--tc-size-label);
  color: var(--tc-gold);
  font-variant-numeric: tabular-nums;
}

.tc-mode__desc { font-size: var(--tc-size-label); color: var(--tc-text-muted); margin: 0; }

.tc-mode:hover,
.tc-mode.is-hover { border-color: rgba(212, 165, 116, 0.5); background: var(--tc-surface-2); }

.tc-mode.is-selected {
  border-color: var(--tc-gold);
  background: var(--tc-surface-2);
  box-shadow: 0 0 0 1px var(--tc-gold), 0 0 24px var(--tc-gold-glow);
}

.tc-mode.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.tc-mode:focus-visible { outline: none; box-shadow: var(--tc-focus-ring); }

/* ================================================================
 * RESULT BADGE
 * ================================================================ */

.tc-result {
  display: inline-flex;
  align-items: center;
  gap: var(--tc-space-3);
  padding: var(--tc-space-3) var(--tc-space-6);
  border-radius: var(--tc-radius-pill);
  font-family: var(--tc-font-ui);
  font-size: var(--tc-size-heading);
  font-weight: var(--tc-weight-semibold);
  letter-spacing: var(--tc-tracking-wide);
  text-transform: uppercase;
}

.tc-result__glyph {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  font-size: 15px;
  color: var(--tc-surface-table);
}

.tc-result--win {
  background: rgba(95, 194, 139, 0.16);
  border: 1px solid var(--tc-win);
  color: var(--tc-win);
  box-shadow: 0 0 28px var(--tc-win-glow);
}

.tc-result--win .tc-result__glyph { background: var(--tc-win); border-radius: var(--tc-radius-pill); }

.tc-result--loss {
  background: rgba(224, 113, 120, 0.16);
  border: 1px solid var(--tc-loss);
  color: var(--tc-loss);
  box-shadow: 0 0 28px var(--tc-loss-glow);
}

/* Squared badge, not round — shape carries the outcome too. */
.tc-result--loss .tc-result__glyph {
  background: var(--tc-loss);
  border-radius: var(--tc-radius-button-sm) 0 var(--tc-radius-button-sm) 0;
}

/* ================================================================
 * ELO DELTA CARD
 * ================================================================ */

.tc-elo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--tc-space-5);
  padding: var(--tc-space-4) var(--tc-space-5);
  border-radius: var(--tc-radius-panel);
  background: var(--tc-surface);
  border: 1px solid var(--tc-card-edge);
  min-width: 220px;
}

.tc-elo__label {
  font-family: var(--tc-font-ui);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: var(--tc-tracking-wide);
  color: var(--tc-text-muted);
}

.tc-elo__value {
  font-family: var(--tc-font-mono);
  font-size: var(--tc-size-title);
  font-variant-numeric: tabular-nums;
  color: var(--tc-text-primary);
  line-height: 1.1;
}

.tc-elo__delta {
  display: inline-flex;
  align-items: center;
  gap: var(--tc-space-1);
  padding: var(--tc-space-1) var(--tc-space-3);
  border-radius: var(--tc-radius-pill);
  font-family: var(--tc-font-mono);
  font-size: var(--tc-size-label);
  font-variant-numeric: tabular-nums;
}

/* Sign and arrow both carry direction; colour is the third signal. */
.tc-elo__delta--up { background: rgba(95, 194, 139, 0.16); color: var(--tc-win); }
.tc-elo__delta--down { background: rgba(224, 113, 120, 0.16); color: var(--tc-loss); }

/* ================================================================
 * LOGO WORDMARK
 * Three pips for three chances.
 * ================================================================ */

.tc-logo {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: var(--tc-space-2);
}

.tc-logo__pips { display: inline-flex; gap: 5px; }

.tc-logo__pip {
  width: 5px;
  height: 5px;
  border-radius: var(--tc-radius-pill);
  background: var(--tc-gold);
}

.tc-logo__pip--spent { background: rgba(212, 165, 116, 0.3); }

.tc-logo__text {
  font-family: var(--tc-font-display);
  font-size: var(--tc-size-title);
  line-height: 1;
  color: var(--tc-text-primary);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.tc-logo--sm .tc-logo__text { font-size: var(--tc-size-label); letter-spacing: 0.18em; }
.tc-logo--sm .tc-logo__pip { width: 3px; height: 3px; }

.tc-logo--horizontal { flex-direction: row; align-items: center; gap: var(--tc-space-3); }

.tc-logo--gold .tc-logo__text { color: var(--tc-gold); }

@media (prefers-reduced-motion: reduce) {
  .tc-thinking__dot,
  .tc-timer--warning { animation: none; }
  .tc-btn,
  .tc-mode { transition: none; }
}
