/* Apex chess — black & gold static site stylesheet.
   Single self-contained file. No external assets. Mobile-first.
   Typography: JetBrains Mono everywhere — terminal aesthetic on screen. */

@font-face {
  font-family: "JetBrains Mono";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("fonts/JetBrainsMono-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: url("fonts/JetBrainsMono-Bold.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-weight: 400;
  font-style: italic;
  font-display: swap;
  src: url("fonts/JetBrainsMono-Italic.woff2") format("woff2");
}

:root {
  --bg:        #0a0a0a;
  --surface:   #141414;
  --surface-2: #1f1f1f;
  --border:    #2a2a2a;
  --gold:      #d4af37;
  --gold-hi:   #ffd700;
  --gold-dim:  rgba(212, 175, 55, 0.18);
  --gold-glow: rgba(212, 175, 55, 0.35);
  --fg:        #f5f5f5;
  --fg-muted:  #9ca3af;
  --green:     #4ade80;
  --red:       #f87171;
  --radius:    10px;
  --radius-sm: 6px;
  --shadow:    0 8px 24px rgba(0, 0, 0, 0.45);
  --t-fast:    120ms ease;
  --t:         180ms ease;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color var(--t-fast), border-color var(--t-fast);
}
a:hover, a:focus {
  color: var(--gold-hi);
  border-bottom-color: var(--gold-hi);
}

/* ===== Top nav ===== */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 28px;
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--gold-dim);
}
.site-nav .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  color: var(--gold);
  border-bottom: none;
  text-transform: uppercase;
}
.site-nav .brand .brand-mark {
  display: inline-block;
  color: var(--gold-hi);
}
.site-nav .brand .brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  object-fit: cover;
}
.site-nav .nav-links {
  display: flex;
  gap: 22px;
  font-size: 0.95rem;
}
.site-nav .nav-links a {
  color: var(--fg-muted);
  border-bottom: none;
  padding: 4px 2px;
}
.site-nav .nav-links a:hover {
  color: var(--gold-hi);
}

/* ===== Layout ===== */

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--fg);
  margin: 0 0 0.6em;
}
h1 { font-size: 2.1rem; line-height: 1.15; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; color: var(--gold); }

.section-heading {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 6px;
  margin: 32px 0 18px;
  border-bottom: 1px solid var(--gold-dim);
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.85rem;
  font-weight: 700;
}
.section-heading .meta {
  color: var(--fg-muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85rem;
  margin-left: auto;
}

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

/* ===== Page header ===== */

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 24px;
  padding-bottom: 18px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.page-header .title-block { flex: 1 1 auto; }
.page-header .meta-block {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-size: 0.92rem;
  color: var(--fg-muted);
}
.page-header .meta-block strong { color: var(--fg); font-weight: 600; }

/* ===== Status pills ===== */

.pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--fg-muted);
  vertical-align: middle;
}
.pill.status-active   { background: var(--gold-dim); color: var(--gold-hi); border-color: var(--gold); }
.pill.status-complete { background: rgba(255,255,255,0.05); color: var(--fg); border-color: var(--border); }
.pill.status-planned  { background: rgba(255,255,255,0.04); color: var(--fg-muted); border-color: var(--border); }

/* ===== Cards / grid ===== */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
}
.card {
  display: block;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
  color: inherit;
  text-decoration: none;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--gold);
  box-shadow: var(--shadow), 0 0 0 1px var(--gold-glow);
  color: inherit;
}
.card .card-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--fg);
}
.card .card-meta {
  font-size: 0.88rem;
  color: var(--fg-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}
.card.featured {
  background: linear-gradient(180deg, rgba(212,175,55,0.10), var(--surface) 60%);
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold-glow);
}

/* ===== Tables ===== */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 18px 0 28px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}
thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--gold);
  font-weight: 700;
  text-align: left;
  text-transform: uppercase;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gold-dim);
  white-space: nowrap;
}
tbody td {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:nth-child(even) td { background: rgba(255, 255, 255, 0.015); }
tbody tr:hover td { background: rgba(212, 175, 55, 0.05); }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
td.center, th.center { text-align: center; }
td.score, th.score { font-family: var(--font-mono); font-weight: 700; color: var(--gold); }

/* Top-3 rank highlight */
tr.rank-1 td.rank, tr.rank-1 td.score { color: var(--gold-hi); }
tr.rank-1 td.rank::before { content: "★ "; color: var(--gold-hi); }
tr.rank-2 td.rank, tr.rank-2 td.score { color: var(--gold); }
tr.rank-3 td.rank, tr.rank-3 td.score { color: var(--gold); opacity: 0.85; }

/* Withdrawn rows */
tr.withdrawn td { opacity: 0.55; font-style: italic; }
tr.withdrawn td.player::after {
  content: " — withdrawn";
  color: var(--fg-muted);
  font-style: italic;
}

/* ===== Result chips ===== */

.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.chip.win-white   { background: rgba(74, 222, 128, 0.10); color: var(--green); border-color: rgba(74, 222, 128, 0.35); }
.chip.win-black   { background: rgba(248, 113, 113, 0.10); color: var(--red);   border-color: rgba(248, 113, 113, 0.35); }
.chip.draw        { background: var(--gold-dim); color: var(--gold-hi); border-color: var(--gold); }
.chip.forfeit     { background: rgba(0,0,0,0); color: var(--gold-hi); border: 1px dashed var(--gold); }
.chip.bye         { background: rgba(0,0,0,0); color: var(--fg-muted); border: 1px dashed var(--border); }
.chip.pending     { background: rgba(0,0,0,0); color: var(--fg-muted); border-color: var(--border); }

/* ===== Pairings grid ===== */

.pairings {
  display: grid;
  grid-template-columns: 60px minmax(180px, 1fr) auto minmax(180px, 1fr);
  gap: 8px 16px;
  align-items: center;
  background: var(--surface);
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.pairings .row { display: contents; }
.pairings .row .board {
  font-family: var(--font-mono);
  color: var(--gold);
  font-weight: 700;
  text-align: right;
}
.pairings .row .white,
.pairings .row .black { padding: 8px 0; }
.pairings .row .white { text-align: right; }
.pairings .row .black { text-align: left; }
.pairings .row .center { text-align: center; }
.pairings .row + .row { border-top: 1px solid var(--border); }
.pairings .header {
  display: contents;
  color: var(--gold);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pairings .header > * {
  padding: 6px 0;
  font-weight: 700;
  border-bottom: 1px solid var(--gold-dim);
}

/* ===== Crosstable ===== */

.crosstable { font-size: 0.88rem; }
.crosstable th, .crosstable td { white-space: nowrap; padding: 6px 8px; text-align: center; }
.crosstable th.player, .crosstable td.player { text-align: left; min-width: 200px; }
.crosstable td.seed { color: var(--fg-muted); font-family: var(--font-mono); width: 36px; }
.crosstable td.cell {
  font-family: var(--font-mono);
  font-weight: 600;
}
.crosstable td.ct-win        { color: var(--green); }
.crosstable td.ct-loss       { color: var(--red); }
.crosstable td.ct-draw       { color: var(--gold-hi); }
.crosstable td.ct-bye        { color: var(--fg-muted); font-style: italic; }
.crosstable td.ct-forfeit-win { color: var(--gold); border-bottom: 1px dashed var(--gold); }
.crosstable td.ct-forfeit-loss { color: var(--red); border-bottom: 1px dashed var(--red); opacity: 0.7; }
.crosstable td.ct-pending    { color: var(--fg-muted); }
.crosstable td.ct-empty      { color: var(--border); }

/* ===== Footer ===== */

footer {
  margin-top: 60px;
  padding: 24px;
  text-align: center;
  color: var(--fg-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}
footer .gold-rule {
  display: block;
  width: 60px;
  height: 2px;
  background: var(--gold);
  margin: 0 auto 16px;
  border-radius: 2px;
}

/* ===== Featured-tournament hero (home page) ===== */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 32px;
  align-items: center;
  margin: 0 0 36px;
  padding: 28px 32px;
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  background:
    radial-gradient(120% 120% at 0% 0%, rgba(212,175,55,0.16), transparent 60%),
    linear-gradient(180deg, var(--surface), var(--surface-2));
  box-shadow: 0 0 0 1px var(--gold-glow), var(--shadow);
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--gold);
  transition: transform var(--t), box-shadow var(--t);
}
.hero:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 0 2px var(--gold-glow), var(--shadow);
  color: inherit;
}
.hero .hero-left { display: flex; align-items: center; gap: 22px; }
.hero .hero-logo {
  width: 168px;
  height: 168px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px var(--gold-dim);
}
.hero .hero-text { display: flex; flex-direction: column; gap: 6px; }
.hero .hero-eyebrow {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--gold);
  font-weight: 700;
}
.hero .hero-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--fg);
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.hero .hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 0.88rem;
  color: var(--fg-muted);
  align-items: center;
}
.hero .hero-leaders {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 18px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius-sm);
}
.hero .hero-leaders .label {
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 4px;
}
.hero .hero-leader {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: baseline;
  padding: 4px 0;
}
.hero .hero-leader .lr {
  font-weight: 800;
  color: var(--gold-hi);
  font-size: 1rem;
}
.hero .hero-leader .ln { color: var(--fg); }
.hero .hero-leader .ls { color: var(--gold); font-weight: 700; }
.hero .hero-cta {
  align-self: end;
  font-size: 0.85rem;
  color: var(--gold);
  font-weight: 700;
}

/* Pulsing dot used inside the live status pill. */
.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold-hi);
  margin-right: 6px;
  vertical-align: middle;
  box-shadow: 0 0 0 0 var(--gold);
  animation: apex-pulse 1.6s ease-out infinite;
}
@keyframes apex-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(212,175,55,0.7); }
  70%  { box-shadow: 0 0 0 10px rgba(212,175,55,0); }
  100% { box-shadow: 0 0 0 0 rgba(212,175,55,0); }
}

/* ===== Big rank + trophy on standings ===== */

.standings tr.rank-1 td.rank,
.standings tr.rank-2 td.rank,
.standings tr.rank-3 td.rank {
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  padding-top: 8px;
  padding-bottom: 8px;
}
.standings tr.rank-1 td.rank { color: var(--gold-hi); }
.standings tr.rank-2 td.rank,
.standings tr.rank-3 td.rank { color: var(--gold); }
.standings tr.rank-1 td.rank::before { content: "🏆 "; font-size: 1.1em; }
.standings tr.rank-2 td.rank::before { content: "🥈 "; font-size: 1.1em; }
.standings tr.rank-3 td.rank::before { content: "🥉 "; font-size: 1.1em; }

/* ===== Sparkline column ===== */

.standings td.spark { padding: 6px 14px; vertical-align: middle; }
.spark svg {
  display: block;
  width: 110px;
  height: 24px;
  overflow: visible;
}
.spark svg polyline {
  stroke: var(--gold);
  stroke-width: 1.6;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.spark svg circle.head {
  fill: var(--gold-hi);
}
.spark .spark-empty {
  display: inline-block;
  width: 110px;
  height: 24px;
  color: var(--fg-muted);
  font-style: italic;
  font-size: 0.78rem;
  line-height: 24px;
}

/* ===== Responsive ===== */

@media (max-width: 700px) {
  main { padding: 18px 14px 60px; }
  .site-nav { padding: 12px 14px; gap: 12px; }
  .site-nav .nav-links { gap: 14px; font-size: 0.88rem; }
  h1 { font-size: 1.6rem; }
  .pairings {
    grid-template-columns: 36px 1fr auto 1fr;
    gap: 6px 8px;
    padding: 10px;
  }
  thead th, tbody td { padding: 8px 10px; }
  .crosstable { font-size: 0.78rem; }

  .hero {
    grid-template-columns: 1fr;
    padding: 20px;
    gap: 18px;
  }
  .hero .hero-logo { width: 128px; height: 128px; }
  .hero .hero-title { font-size: 1.4rem; }

  /* Hide the sparkline column on narrow viewports — table needs the room. */
  .standings th.spark, .standings td.spark { display: none; }

  .standings tr.rank-1 td.rank,
  .standings tr.rank-2 td.rank,
  .standings tr.rank-3 td.rank { font-size: 1.25rem; }
}

/* ===== Misc utility ===== */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 28px;
}
.actions a {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--gold);
  font-weight: 600;
  border-bottom: 1px solid var(--gold-dim);
}
.actions a:hover {
  border-color: var(--gold);
  color: var(--gold-hi);
}

.empty-state {
  padding: 40px 24px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  color: var(--fg-muted);
}
