/* KCL Stats — additive component styles for the stats pages (dashboard,
   player, match, leaderboards, matches). Loaded after /styles.css, which
   supplies the shared reset, color tokens, fonts, topnav, and footer used
   across the whole kcl.ktiers.com site (see about/index.html). Only
   stats-specific components live here; team colors (blue = team1,
   red = team2) are the one deliberate departure from the shared --accent. */

:root {
  --radius: 16px;
  --radius-sm: 8px;
  --mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;

  --blue: #3b82f6;
  --blue-glow: rgba(59, 130, 246, .16);
  --blue-border: rgba(59, 130, 246, .35);

  --red: #ef4444;
  --red-glow: rgba(239, 68, 68, .16);
  --red-border: rgba(239, 68, 68, .35);

  --green: #22c55e;
  --yellow: #eab308;
}

.mono { font-family: var(--mono); }

/* ── Page shell ─────────────────────────────────────── */
.page { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; width: 100%; flex: 1; }
.page-title { font-size: 22px; font-weight: 800; letter-spacing: -.4px; margin-bottom: 4px; }
.page-subtitle { font-size: 13.5px; color: var(--mutedtext); margin-bottom: 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section { margin-bottom: 36px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 14px; gap: 12px; flex-wrap: wrap;
}
.section-title { font-size: 15px; font-weight: 700; letter-spacing: .2px; }
.section-link { font-size: 12.5px; color: var(--accent); text-decoration: none; font-weight: 600; }
.section-link:hover { text-decoration: underline; }
.section-head-title-group { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* ── Cards ──────────────────────────────────────────── */
.card {
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 18px 20px;
}

/* ── Quick stats bar ────────────────────────────────── */
.stat-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-tile {
  background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-tile-label {
  font-size: 11px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--muted); margin-bottom: 8px;
}
.stat-tile-value { font-size: 22px; font-weight: 800; font-family: var(--mono); letter-spacing: -.5px; }
.stat-tile-sub { font-size: 12px; color: var(--mutedtext); margin-top: 3px; }

/* ── Badges / chips ─────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  padding: 3px 9px; border-radius: 99px;
}
.badge-live { background: rgba(239, 68, 68, .15); color: #ff6b6b; border: 1px solid var(--red-border); }
.badge-win { background: rgba(34, 197, 94, .15); color: var(--green); border: 1px solid rgba(34, 197, 94, .3); }
.badge-live .pulse-dot {
  width: 6px; height: 6px; border-radius: 50%; background: #ff4d4d;
  box-shadow: 0 0 0 0 rgba(255, 77, 77, .6);
  animation: pulse 1.4s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 77, 77, .55); }
  70% { box-shadow: 0 0 0 7px rgba(255, 77, 77, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0); }
}
.gamemode-chip {
  font-size: 11px; font-weight: 700; letter-spacing: .3px; color: var(--muted);
  background: #ffffff08; border: 1px solid var(--border2);
  padding: 6px 12px; border-radius: 6px;
}
.team-badge { font-weight: 800; font-size: 12.5px; letter-spacing: .3px; }
.team-badge.blue { color: var(--blue); }
.team-badge.red { color: var(--red); }
.unlinked { color: var(--muted); font-style: italic; }
.player-link { text-decoration: none; color: var(--text); }
.player-link:hover { color: var(--accent); text-decoration: underline; }
.map-link { text-decoration: none; color: inherit; }
.map-link:hover { color: var(--accent); text-decoration: underline; }

.back-btn {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px;
  background: var(--surface2); border: 1px solid var(--border2); color: var(--text);
  font-family: var(--mono); font-size: 12.5px; padding: 6px 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: border-color .15s;
}
.back-btn:hover { border-color: var(--accent); }

/* ── Live match cards ───────────────────────────────── */
.live-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.live-card {
  background: var(--surface2); border: 1px solid var(--red-border); border-radius: var(--radius);
  padding: 16px 18px; position: relative; overflow: hidden;
}
.live-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, var(--blue), var(--red));
}
.live-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.live-card-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.live-card-map { color: var(--text); font-weight: 700; }
.live-card-score { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 20px; font-weight: 700; margin: 4px 0 12px; }
.live-card-score .side.blue { color: var(--blue); }
.live-card-score .side.red { color: var(--red); }
.live-rosters { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.live-roster-side.blue { border-left: 2px solid var(--blue); padding-left: 10px; }
.live-roster-side.red { border-left: 2px solid var(--red); padding-left: 10px; }
.live-roster-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  margin-bottom: 6px;
}
.live-roster-side.blue .live-roster-label { color: var(--blue); }
.live-roster-side.red .live-roster-label { color: var(--red); }
.roster-player-row { font-size: 13px; padding: 2px 0; display: flex; align-items: center; gap: 5px; }
.captain-star { color: var(--yellow); font-size: 11px; }
.mvp-star { color: #ffd700; font-size: 16px; }
.svp-star { color: #c0c0c0; font-size: 16px; }

/* ── Player lookup (dashboard recent matches) ───────── */
.player-lookup { position: relative; }
.player-lookup-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.player-lookup-input {
  background: var(--surface2); border: 1px solid var(--border2); color: var(--text);
  font-family: 'Outfit', sans-serif; font-size: 12.5px; padding: 6px 10px; border-radius: var(--radius-sm);
  outline: none; width: 200px;
}
.player-lookup-input:focus { border-color: var(--accent); }
.player-lookup-clear {
  background: none; border: none; color: var(--muted); font-size: 12px; font-weight: 600;
  cursor: pointer; padding: 6px 4px; font-family: 'Outfit', sans-serif; white-space: nowrap;
}
.player-lookup-clear:hover { color: var(--text); }
.player-lookup-profile-link {
  font-size: 12px; font-weight: 600; color: var(--accent); text-decoration: none; white-space: nowrap;
}
.player-lookup-profile-link:hover { text-decoration: underline; }
.player-lookup-suggestions {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 20; width: 240px;
  background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius-sm);
  padding: 5px; box-shadow: 0 12px 32px rgba(0, 0, 0, .5); max-height: 260px; overflow-y: auto;
}
.player-lookup-item {
  display: block; width: 100%; text-align: left; background: none; border: none; color: var(--muted);
  font-family: 'Outfit', sans-serif; font-size: 13px; padding: 8px 10px; border-radius: 7px; cursor: pointer;
}
.player-lookup-item:hover { color: var(--text); background: #ffffff08; }

/* ── Match cards (recent / dashboard) ───────────────── */
.match-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.match-card {
  display: block; background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--text);
  transition: border-color .15s, transform .15s;
}
.match-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.match-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 6px; }
.match-card-score { display: flex; align-items: center; justify-content: center; gap: 10px; font-family: var(--mono); font-size: 20px; font-weight: 700; margin: 6px 0; }
.match-card-score .side { color: var(--muted); }
.match-card-score .side.winner.blue { color: var(--blue); }
.match-card-score .side.winner.red { color: var(--red); }
.match-card-foot { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 8px; }

/* ── Leaderboard teasers ────────────────────────────── */
.teaser-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.teaser-card { background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--radius); padding: 16px 18px; }
.teaser-label { font-size: 11px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.teaser-player { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.teaser-name { font-weight: 700; font-size: 15px; }
.teaser-value { font-family: var(--mono); font-weight: 700; color: var(--accent); font-size: 15px; }

/* ── Leaderboard grid ───────────────────────────────── */
.lb-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
@media (max-width: 860px) { .lb-grid { grid-template-columns: 1fr; } }

/* ── Tables ─────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border2); border-radius: var(--radius); }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; background: var(--surface2); }
table.data-table th {
  text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
  background: #ffffff05;
}
table.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: #ffffff05; }
table.data-table td.num, table.data-table th.num { text-align: right; font-family: var(--mono); }
tr.row-captain { background: rgba(234, 179, 8, .06); }
tr.row-clickable { cursor: pointer; }
tr.row-clickable:hover { background: #ffffff08; }
.rank-cell { font-family: var(--mono); font-weight: 700; color: var(--muted); width: 36px; }
.rank-cell.top1 { color: #ffd700; }
.rank-cell.top2 { color: #c0c0c0; }
.rank-cell.top3 { color: #cd7f32; }
.see-everyone-btn {
  display: block; width: 100%; padding: 10px 14px; border: none; border-top: 1px solid var(--border);
  background: transparent; color: var(--accent); font-size: 12.5px; font-weight: 700;
  cursor: pointer; text-align: center; text-decoration: none; box-sizing: border-box;
}
.see-everyone-btn:hover { background: #ffffff05; }

table.data-table th.metric-col { color: var(--accent); }
table.data-table td.metric-col { color: var(--text); font-weight: 700; background: rgba(255, 119, 0, .06); }

/* ── Filter bar ─────────────────────────────────────── */
.filter-bar { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; align-items: flex-end; }
.filter-bar select {
  background: var(--surface2); border: 1px solid var(--border2); color: var(--text);
  font-family: 'Outfit', sans-serif; font-size: 13px; padding: 7px 10px; border-radius: var(--radius-sm);
  outline: none; cursor: pointer;
}
.filter-bar select:focus { border-color: var(--accent); }
.filter-group { display: flex; flex-direction: column; gap: 8px; }
.filter-label {
  font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted);
}
.date-input {
  background: var(--surface2); border: 1px solid var(--border2); color: var(--text);
  font-family: 'Outfit', sans-serif; font-size: 13px; padding: 6px 9px; border-radius: var(--radius-sm);
  outline: none; color-scheme: dark;
}
.date-input:focus { border-color: var(--accent); }
.segment-group { display: inline-flex; border: 1px solid var(--border2); border-radius: var(--radius-sm); overflow: hidden; }
.segment-btn {
  font-family: 'Outfit', sans-serif; font-size: 12.5px; font-weight: 600; padding: 7px 14px;
  background: var(--surface2); color: var(--muted); border: none; cursor: pointer; transition: all .15s;
}
.segment-btn + .segment-btn { border-left: 1px solid var(--border2); }
.segment-btn:hover { color: var(--text); }
.segment-btn.active { background: var(--accent); color: #fff; }

/* ── Charts grid (dashboard analytics) ──────────────── */
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }

/* ── Pagination ─────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 18px; }
.pagination button {
  background: var(--surface2); border: 1px solid var(--border2); color: var(--text);
  font-family: var(--mono); font-size: 12.5px; padding: 6px 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: border-color .15s;
}
.pagination button:hover:not(:disabled) { border-color: var(--accent); }
.pagination button:disabled { opacity: .35; cursor: not-allowed; }
.pagination .page-info { font-size: 12.5px; color: var(--muted); font-family: var(--mono); padding: 0 6px; }

/* ── Score header (match detail) ────────────────────── */
.score-header {
  display: flex; align-items: center; justify-content: center; gap: 28px;
  padding: 28px 20px; background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--radius); margin-bottom: 24px;
}
.score-side { text-align: center; flex: 1; max-width: 200px; }
.score-side-label { font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 6px; }
.score-side.blue .score-side-label { color: var(--blue); }
.score-side.red .score-side-label { color: var(--red); }
.score-side-value { font-family: var(--mono); font-size: 44px; font-weight: 800; line-height: 1; }
.score-side.winner .score-side-value { text-shadow: 0 0 24px currentColor; }
.score-side.blue.winner .score-side-value { color: var(--blue); }
.score-side.red.winner .score-side-value { color: var(--red); }
.score-side:not(.winner) .score-side-value { color: var(--muted); }
.score-divider { font-size: 22px; color: var(--muted); font-weight: 700; }
.winner-tag { display: block; font-size: 10.5px; color: var(--muted); margin-top: 6px; letter-spacing: .4px; text-transform: uppercase; }

.teams-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }

/* ── Matches list (history cards) ───────────────────── */
.matches-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.match-card-teams { display: grid; grid-template-columns: 1fr; gap: 12px; }
[data-map-bg] { background-size: cover; background-position: center; }
.team-panel { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border2); }
.team-panel-head { padding: 10px 16px; font-weight: 800; font-size: 13.5px; letter-spacing: .4px; }
.team-panel.blue .team-panel-head { background: var(--blue-glow); color: var(--blue); border-bottom: 1px solid var(--blue-border); }
.team-panel.red .team-panel-head { background: var(--red-glow); color: var(--red); border-bottom: 1px solid var(--red-border); }

.draft-order { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.draft-pick {
  display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border2);
  border-radius: 99px; padding: 5px 12px; font-size: 12.5px;
}
.draft-pick-num { font-family: var(--mono); color: var(--muted); font-weight: 700; }
.draft-arrow { color: var(--muted); font-size: 12px; }

/* ── Player profile ─────────────────────────────────── */
.profile-header { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.profile-avatar {
  width: 56px; height: 56px; border-radius: 50%; object-fit: cover;
  border: 1px solid var(--border2); background: var(--surface2); flex-shrink: 0;
}
.profile-avatar-fallback {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface2); border: 1px solid var(--border2);
  color: var(--muted); font-weight: 800; font-size: 20px;
}
.profile-id { font-family: var(--mono); font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.profile-sub { font-size: 13px; color: var(--mutedtext); margin-bottom: 24px; }

.breakdown-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.breakdown-card-title {
  font-size: 11px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--muted); margin-bottom: 16px;
}
.breakdown-row { display: flex; align-items: center; gap: 10px; font-size: 13px; padding: 5px 0; }
.breakdown-row .name { flex: 0 0 130px; color: var(--mutedtext); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breakdown-row .name.map-link:hover { color: var(--accent); text-decoration: underline; }
.breakdown-bar-track { flex: 1; height: 6px; background: var(--surface); border-radius: 99px; overflow: hidden; }
.breakdown-bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.breakdown-row .val { font-family: var(--mono); width: 70px; text-align: right; color: var(--text); flex-shrink: 0; }

.social-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.social-card { display: flex; align-items: center; justify-content: space-between; }
.social-card .label { font-size: 12px; color: var(--muted); }

.kv-row { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.kv-row:last-child { border-bottom: none; }
.kv-row .k { color: var(--mutedtext); }
.kv-row .v { font-family: var(--mono); font-weight: 700; }
.streak-win { color: var(--green); }
.streak-loss { color: var(--red); }

/* ── Gamemode tabs (player profile) ─────────────────── */
.tab-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.tab-btn {
  font-family: 'Outfit', sans-serif; font-size: 12.5px; font-weight: 700; letter-spacing: .3px;
  padding: 7px 14px; border-radius: 99px; border: 1px solid var(--border2); background: var(--surface2);
  color: var(--muted); cursor: pointer; transition: all .15s;
}
.tab-btn:hover { color: var(--text); border-color: var(--muted); }
.tab-btn.active { color: var(--accent); border-color: var(--accent); background: rgba(255, 119, 0, .1); }

/* ── Wide analytics stat grid ───────────────────────── */
.stat-bar-flex { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

/* ── Matchup highlight cards ────────────────────────── */
.matchup-highlight { border-radius: var(--radius); padding: 14px 16px; border: 1px solid; }
.matchup-highlight.good { border-color: rgba(34, 197, 94, .3); background: rgba(34, 197, 94, .05); }
.matchup-highlight.bad { border-color: rgba(239, 68, 68, .3); background: rgba(239, 68, 68, .05); }

/* ── Performance chart ──────────────────────────────── */
.chart-wrap { position: relative; }
.score-chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis-label { font-family: var(--mono); font-size: 10px; fill: var(--muted); }
.chart-area { fill: var(--accent); opacity: .12; transition: d .5s cubic-bezier(.22, .61, .36, 1); }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; transition: d .5s cubic-bezier(.22, .61, .36, 1); }
.chart-draw { animation: chart-grow-in .9s cubic-bezier(.22, .61, .36, 1) both; }
.chart-draw.no-grow { animation: none; clip-path: none; }
@keyframes chart-grow-in {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0% 0 0); }
}
.chart-point { cursor: pointer; transition: transform .45s cubic-bezier(.22, .61, .36, 1); }
.chart-point circle:last-child { transition: r .1s; }
.chart-point:hover circle:last-child, .chart-point:focus circle:last-child { r: 7; }
.chart-point:focus { outline: none; }
.chart-tooltip {
  position: absolute; transform: translate(-50%, -130%); background: #0d0e14ee; border: 1px solid var(--border2);
  border-radius: 6px; padding: 6px 10px; font-size: 12px; color: var(--text); white-space: nowrap; pointer-events: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .4); z-index: 2;
}
.chart-legend { display: flex; gap: 16px; margin-top: 8px; padding-left: 50px; }
.chart-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.chart-dot-swatch { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.chart-dot-swatch.win { background: var(--green); }
.chart-dot-swatch.loss { background: var(--red); }

@media (prefers-reduced-motion: reduce) {
  .chart-draw { animation: none; clip-path: none; }
  .chart-point, .chart-area, .chart-line { transition: none; }
}

/* ── Empty / error states ───────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 40px 20px; color: var(--muted); text-align: center; font-size: 13.5px;
}
.empty-state.error { color: #ff8080; }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 860px) {
  .stat-bar { grid-template-columns: repeat(2, 1fr); }
  .teams-grid { grid-template-columns: 1fr; }
  .breakdown-grid { grid-template-columns: 1fr; }
  .live-rosters { grid-template-columns: 1fr; }
  .matches-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .stat-bar { grid-template-columns: 1fr 1fr; }
  .score-header { gap: 14px; padding: 20px 12px; }
  .score-side-value { font-size: 32px; }
}
