/* Layout and components. Colours, fonts and images live in theme.css. */

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: var(--bg) var(--page-texture);
  color: var(--text);
  font: 15px/1.55 var(--font-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; text-wrap: balance; letter-spacing: .01em; }
h1 { font-size: clamp(2rem, 5vw, 3.4rem); }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.1rem; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
main.wrap { flex: 1; padding-block: 28px 56px; display: flex; flex-direction: column; gap: 32px; }

/* ---- Header ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-block: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-logo { height: 34px; width: auto; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; text-transform: uppercase; letter-spacing: .06em; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { text-decoration: none; padding: 7px 12px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 500; }
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a.active { color: var(--text); background: var(--surface-2); }
.nav a.nav-cta { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.nav-auth { display: flex; gap: 4px; align-items: center; }
.nav-auth a { text-decoration: none; padding: 7px 12px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 500; }
.nav-auth a:hover, .nav-auth a.active { color: var(--text); background: var(--surface-2); }
.nav-login, .nav-logout { font: inherit; font-weight: 600; cursor: pointer; border-radius: var(--radius-sm); padding: 7px 12px; }
.nav-login { background: var(--discord); color: #fff; border: 1px solid var(--discord); }
.nav-logout { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.nav-logout:hover { color: var(--text); }
button.btn { font: inherit; font-weight: 600; cursor: pointer; color: var(--text); }
.btn-discord, button.btn-discord { background: var(--discord); border-color: var(--discord); color: #fff; }

/* ---- Sign-ups ---- */
.signup { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.signup-alt { color: var(--muted); font-size: .9rem; }
.signup-alt:hover { color: var(--text); }
.signup-count { color: var(--muted); font-size: .9rem; }
.signup-count:empty { display: none; }
.card-signup { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---- Footer ---- */
.footer { border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.footer-inner { display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; padding-block: 20px; font-size: .9rem; }

/* ---- Common pieces ---- */
.section { display: flex; flex-direction: column; gap: 14px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-head a { color: var(--accent); text-decoration: none; font-weight: 600; font-size: .9rem; }
.eyebrow { font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.loading, .error { padding: 60px 0; text-align: center; color: var(--muted); }
.error { color: var(--bad); }
.error p { color: var(--muted); max-width: 60ch; margin: 8px auto 0; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .75rem; font-weight: 600; letter-spacing: .03em;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--chip, var(--muted)) 55%, transparent);
  color: var(--chip, var(--muted));
  background: color-mix(in srgb, var(--chip, var(--muted)) 12%, transparent);
  white-space: nowrap;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.status-finished { --chip: var(--good); }
.status-upcoming { --chip: var(--warn); }
.status-canceled { --chip: var(--bad); }
.team-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--team, var(--muted)); flex: none; display: inline-block; }
.sub-tag { font-size: .7rem; color: var(--warn); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--tab, var(--accent)); border-color: var(--tab, var(--accent)); color: var(--accent-ink); }

select, input[type="search"] {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 12px; max-width: 100%;
}
.controls { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.controls label { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: .9rem; }

/* ---- Hero ---- */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius); border: 1px solid var(--line);
  padding: clamp(28px, 6vw, 64px) clamp(20px, 5vw, 48px);
  background:
    linear-gradient(100deg, var(--bg) 20%, color-mix(in srgb, var(--bg) 40%, transparent) 100%),
    var(--hero-image) center / cover no-repeat,
    radial-gradient(circle at 85% 20%, color-mix(in srgb, var(--accent) 35%, transparent), transparent 55%),
    var(--surface);
  display: flex; flex-direction: column; gap: 14px;
}
.hero p { margin: 0; font-size: 1.1rem; color: var(--muted); max-width: 52ch; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.btn { display: inline-block; text-decoration: none; font-weight: 600; padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.stat-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat .value { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; line-height: 1.2; }
.stat .value.small { font-size: 1.15rem; }
.stat .label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

/* ---- Leaderboard ---- */
.lb-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); align-items: start; }
.lb h3 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 10px; }
.lb h3 small { font-family: var(--font-body); font-size: .75rem; color: var(--muted); font-weight: 500; }
.lb ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.lb li { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 6px 8px; border-radius: var(--radius-sm); }
.lb li:nth-child(odd) { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.lb .rank { font-family: var(--font-display); font-weight: 700; color: var(--muted); text-align: center; }
.lb li:nth-child(1) .rank { color: var(--gold); }
.lb li:nth-child(2) .rank { color: var(--silver); }
.lb li:nth-child(3) .rank { color: var(--bronze); }
.lb .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .who a { text-decoration: none; font-weight: 500; }
.lb .who a:hover { color: var(--accent); }
.lb .val { font-weight: 600; font-variant-numeric: tabular-nums; }
.lb .meta { font-size: .75rem; color: var(--muted); margin-left: 6px; }
.empty { color: var(--muted); font-size: .9rem; padding: 6px 8px; }

/* ---- Tables ---- */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: .9rem; }
th, td { padding: 9px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
thead th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
tbody tr:last-child td { border-bottom: 0; }
.career-summary { display: flex; flex-wrap: wrap; gap: 8px; }
.sum-item { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; min-width: 84px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.sum-label { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.sum-value { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; }
tr.career td { font-weight: 700; background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* ---- Players ---- */
.player-card { display: flex; flex-direction: column; gap: 8px; text-decoration: none; transition: border-color .15s; }
.player-card:hover { border-color: var(--accent); }
.player-card .name { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; overflow-wrap: anywhere; }
.player-card .line { display: flex; gap: 14px; font-size: .85rem; color: var(--muted); }
.player-card .line b { color: var(--text); font-weight: 600; }
.trophy { color: var(--gold); }

.profile-head { display: flex; flex-direction: column; gap: 10px; }
.aka { color: var(--muted); }
.history { display: flex; flex-direction: column; gap: 8px; }
.history-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) 150px 96px; gap: 12px; align-items: center; padding: 10px 14px; }
.history-row .game-slot, .history-row .champ-slot { display: flex; flex-wrap: wrap; gap: 4px; }
.history-row .team { display: flex; gap: 8px; align-items: center; min-width: 0; }
.history-row .team span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-row a { text-decoration: none; font-weight: 600; }

/* ---- Events ---- */
.event-card { display: flex; flex-direction: column; gap: 10px; text-decoration: none; transition: border-color .15s; }
.event-card:hover { border-color: var(--accent); }
.event-card .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.event-card .code { font-size: .75rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.event-card .winner { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.team-card { border-top: 4px solid var(--team, var(--line)); }
.team-card h3 { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.team-card ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.team-card li { display: flex; justify-content: space-between; gap: 8px; }
.team-card li a { text-decoration: none; }
.team-card li a:hover { color: var(--accent); }
.winner-badge, .place-1 { --chip: var(--gold); }
.place-2 { --chip: var(--silver); }
.place-3 { --chip: var(--bronze); }
.podium { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.podium li { display: flex; gap: 8px; align-items: center; min-width: 0; }
.podium li span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-rank { font-family: var(--font-display); font-weight: 700; font-size: .8rem; width: 2.2em; flex: none; }
.podium-1 { font-weight: 600; }
.podium-1 .podium-rank { color: var(--gold); }
.podium-2 .podium-rank { color: var(--silver); }
.podium-3 .podium-rank { color: var(--bronze); }
.podium-2, .podium-3 { color: var(--muted); font-size: .9rem; }

@media (max-width: 560px) {
  .history-row { grid-template-columns: auto auto 1fr; gap: 6px 8px; }
  .history-row > a, .history-row .team { grid-column: 1 / -1; }
  .history-row .champ-slot:empty { display: none; }
  .nav a { padding: 6px 9px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
