/* app.css — data-driven tournament app.
   Brand language copied from the live public brochure (brief §8): cream ground,
   indigo ink, warm-accent gold, green for "qualified". Playfair Display for
   display, DM Sans for body, DM Mono for every number (PR, scores, dates). */

:root {
  --indigo: #2d3a6b;
  --indigo-deep: #1a2347;
  --indigo-light: #4a5a9a;
  --indigo-muted: #8891b8;
  --cream: #f5f0e8;
  --cream-dark: #ede7d9;
  --warm-accent: #c4a96d;
  --ink: #1c1c1c;
  --ink-soft: #3d3d3d;
  --rule: rgba(45, 58, 107, 0.15);
  --green: #4a7c59;

  --shadow-card: 0 1px 2px rgba(26, 35, 71, 0.06), 0 8px 24px rgba(26, 35, 71, 0.08);
  --shadow-card-hover: 0 2px 4px rgba(26, 35, 71, 0.1), 0 16px 40px rgba(26, 35, 71, 0.14);
  --radius: 12px;
  --maxw: 1080px;
}

/* qualifier / badge idiom from the live site */
.rank-gm { background: rgba(196, 169, 109, 0.15); color: #8a6d2a; }   /* by_points */
.rank-m  { background: rgba(45, 58, 107, 0.10); color: var(--indigo); }
.rank-wc { background: rgba(74, 124, 89, 0.15); color: #3a6347; }     /* by_pr wildcard */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'DM Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background: var(--cream);
  line-height: 1.55;
  font-size: 16px;
}

h1, h2, h3, h4 {
  font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
  color: var(--indigo-deep);
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
}

a { color: var(--indigo); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: 'DM Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace; }

/* player identity: flag/country-code + name, with breathing room. On platforms
   without flag-emoji glyphs the alpha-2 code shows as text — the gap keeps it
   from gluing to the name. */
.who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.who .flag { font-size: 16px; line-height: 1; flex: none; }

/* ── layout shell ───────────────────────────────────────────────── */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

.site-header {
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(180deg, var(--cream) 0%, var(--cream) 60%, rgba(237, 231, 217, 0.5) 100%);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 18px;
  padding-bottom: 18px;
}
.brand {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 20px;
  color: var(--indigo-deep);
  letter-spacing: 0.2px;
}
.brand .dot { color: var(--warm-accent); }
.site-header nav a {
  font-size: 14px;
  color: var(--ink-soft);
  margin-left: 22px;
  font-weight: 500;
}

.site-footer {
  margin-top: 64px;
  border-top: 1px solid var(--rule);
  color: var(--indigo-muted);
  font-size: 13px;
}
.site-footer .wrap { padding-top: 24px; padding-bottom: 40px; }

/* ── page intro ─────────────────────────────────────────────────── */
.page-intro { padding: 48px 0 8px; }
.page-intro .eyebrow {
  font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--warm-accent); margin-bottom: 10px;
}
.page-intro h1 { font-size: clamp(30px, 5vw, 44px); }
.page-intro p.lede { color: var(--ink-soft); max-width: 60ch; margin: 12px 0 0; }

/* ── status badges (six-state lifecycle) ────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
  border: 1px solid transparent;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.9; }
.badge.upcoming    { background: rgba(136, 145, 184, 0.16); color: var(--indigo-light); }
.badge.registering { background: rgba(196, 169, 109, 0.18); color: #8a6d2a; }
.badge.drawn       { background: rgba(45, 58, 107, 0.10); color: var(--indigo); }
.badge.group_live  { background: rgba(74, 124, 89, 0.16); color: var(--green); }
.badge.knockout    { background: rgba(74, 124, 89, 0.22); color: #2f5c3d; }
.badge.archived    { background: rgba(28, 28, 28, 0.06); color: var(--ink-soft); }
.badge.group_live::before, .badge.knockout::before { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

/* ── hub groups + cards ─────────────────────────────────────────── */
.group { margin-top: 40px; }
.group-head {
  display: flex; align-items: baseline; gap: 12px;
  border-bottom: 1px solid var(--rule); padding-bottom: 10px; margin-bottom: 22px;
}
.group-head h2 { font-size: 22px; }
.group-head .count { color: var(--indigo-muted); font-size: 14px; font-weight: 500; }

.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;
}

.card {
  display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 22px 22px 20px; box-shadow: var(--shadow-card);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
  position: relative; overflow: hidden;
}
a.card { color: inherit; text-decoration: none; }
a.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-card-hover); border-color: rgba(45, 58, 107, 0.28); text-decoration: none; }
.card::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: var(--warm-accent); opacity: 0; transition: opacity 0.16s ease;
}
a.card:hover::before { opacity: 1; }
.card.is-archived::before { background: var(--indigo-muted); }

.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.card h3 { font-size: 20px; line-height: 1.2; }
.card .meta-line { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 14px; margin-top: 4px; }
.card .meta-line .ico { color: var(--indigo-muted); }
.card .dates { font-family: 'DM Mono', monospace; font-size: 13px; color: var(--ink-soft); }
.card-foot { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--rule); display: flex; align-items: center; justify-content: space-between; }
.card-foot .champion { display: flex; align-items: center; gap: 7px; font-size: 14px; }
.card-foot .champion .trophy { color: var(--warm-accent); }
.card-foot .champion .name { font-weight: 600; color: var(--indigo-deep); }
.card-foot .go { font-size: 13px; color: var(--indigo); font-weight: 600; }
.card .players { font-family: 'DM Mono', monospace; font-size: 13px; color: var(--indigo-muted); }

/* ── empty / error states ───────────────────────────────────────── */
.notice {
  background: #fff; border: 1px dashed var(--rule); border-radius: var(--radius);
  padding: 28px; color: var(--ink-soft); text-align: center;
}
.notice.error { border-color: rgba(150, 60, 60, 0.3); color: #8a3b3b; background: rgba(150, 60, 60, 0.03); }
.skeleton { color: var(--indigo-muted); padding: 40px 0; text-align: center; }

/* ── tournament page header ─────────────────────────────────────── */
.event-head { padding: 40px 0 8px; }
.event-head .crumbs { font-size: 13px; color: var(--indigo-muted); margin-bottom: 16px; }
.event-head .crumbs a { color: var(--indigo-light); }
.event-head .title-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.event-head h1 { font-size: clamp(28px, 4.5vw, 40px); }
.event-head .sub { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; margin-top: 12px; color: var(--ink-soft); font-size: 15px; }
.event-head .sub .item { display: inline-flex; align-items: center; gap: 7px; }
.event-head .sub .ico { color: var(--indigo-muted); }
.event-head .format { margin-top: 14px; font-size: 14px; color: var(--ink-soft); background: rgba(45,58,107,0.05); border: 1px solid var(--rule); border-radius: 8px; padding: 8px 14px; display: inline-block; }

/* ── section scaffolding ────────────────────────────────────────── */
.section { margin-top: 46px; }
.section > .section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; border-bottom: 1px solid var(--rule); padding-bottom: 10px; }
.section-head h2 { font-size: 24px; }
.section-head .hint { font-size: 13px; color: var(--indigo-muted); }

/* ── standings table ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--radius); background: #fff; }
table.standings { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.standings th, table.standings td { padding: 11px 14px; text-align: left; white-space: nowrap; }
table.standings thead th {
  font-family: 'DM Sans', sans-serif; font-size: 11.5px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--indigo-muted); border-bottom: 1px solid var(--rule); background: var(--cream);
}
table.standings tbody tr { border-bottom: 1px solid rgba(45, 58, 107, 0.07); }
table.standings tbody tr:last-child { border-bottom: 0; }
table.standings tbody tr:hover { background: rgba(45, 58, 107, 0.025); }
table.standings td.num, table.standings th.num { text-align: right; font-family: 'DM Mono', monospace; }
table.standings td.rank { font-family: 'DM Mono', monospace; color: var(--indigo-muted); width: 38px; }
table.standings .player-cell { display: flex; align-items: center; gap: 9px; }
table.standings .flag { font-size: 17px; line-height: 1; }
table.standings .pname { font-weight: 600; color: var(--indigo-deep); }
table.standings tr.q-points { background: rgba(196, 169, 109, 0.07); }
table.standings tr.q-pr { background: rgba(74, 124, 89, 0.07); }
table.standings tr.q-points:hover { background: rgba(196, 169, 109, 0.12); }
table.standings tr.q-pr:hover { background: rgba(74, 124, 89, 0.12); }
.qual-tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; letter-spacing: 0.02em; }
.pr-cell { cursor: help; border-bottom: 1px dotted var(--indigo-muted); }
.legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; font-size: 12.5px; color: var(--ink-soft); }
.legend .swatch { display: inline-flex; align-items: center; gap: 7px; }
.legend .chip { width: 12px; height: 12px; border-radius: 3px; }

/* ── bracket ────────────────────────────────────────────────────── */
.bracket { display: flex; gap: 28px; overflow-x: auto; padding: 6px 2px 14px; }
.bracket .round-col { display: flex; flex-direction: column; justify-content: space-around; gap: 18px; min-width: 230px; }
.bracket .round-col > .col-label { font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--indigo-muted); margin-bottom: 2px; }
.slot {
  background: #fff; border: 1px solid var(--rule); border-radius: 10px; padding: 10px 12px;
  box-shadow: var(--shadow-card); position: relative;
}
.slot .slot-date { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--indigo-muted); margin-bottom: 7px; display: flex; justify-content: space-between; align-items: center; }
.slot .slot-state { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 7px; border-radius: 999px; }
.slot .slot-state.clinched { background: rgba(74,124,89,0.16); color: var(--green); }
.slot .slot-state.in_progress { background: rgba(196,169,109,0.2); color: #8a6d2a; }
.slot .slot-state.not_started { background: rgba(136,145,184,0.16); color: var(--indigo-light); }
.slot .slot-state.tbd { background: rgba(28,28,28,0.05); color: var(--indigo-muted); }
.slot .seat { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 0; }
.slot .seat + .seat { border-top: 1px solid rgba(45,58,107,0.08); }
.slot .seat .who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.slot .seat .seed { font-family: 'DM Mono', monospace; font-size: 11px; color: #fff; background: var(--indigo-light); border-radius: 5px; padding: 1px 6px; flex: none; }
.slot .seat .who .nm { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .seat.win .nm { font-weight: 700; color: var(--indigo-deep); }
.slot .seat.win .seed { background: var(--green); }
.slot .seat.tbd .nm { color: var(--indigo-muted); font-style: italic; }
.slot .seat .pts { font-family: 'DM Mono', monospace; font-size: 14px; font-weight: 600; color: var(--ink-soft); flex: none; }
.slot .seat.win .pts { color: var(--green); }
.slot.is-clinched { border-color: rgba(74,124,89,0.4); }

/* ── match feed ─────────────────────────────────────────────────── */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.chip-btn {
  font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 500;
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--rule);
  background: #fff; color: var(--ink-soft); cursor: pointer; transition: all 0.14s ease;
}
.chip-btn:hover { border-color: var(--indigo-light); color: var(--indigo); }
.chip-btn.active { background: var(--indigo); border-color: var(--indigo); color: #fff; }

.round-block { margin-bottom: 26px; }
.round-block > h3 { font-size: 15px; font-family: 'DM Sans', sans-serif; font-weight: 600; color: var(--indigo); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.round-block > h3::after { content: ''; flex: 1; height: 1px; background: var(--rule); }

.match-row {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px;
  background: #fff; border: 1px solid var(--rule); border-radius: 10px; padding: 12px 16px; margin-bottom: 8px;
}
.match-row .side { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.match-row .side.p2 { align-items: flex-end; text-align: right; }
.match-row .side .nm { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.match-row .side.p2 .nm { flex-direction: row-reverse; }
.match-row .side .nm.winner { font-weight: 700; color: var(--indigo-deep); }
.match-row .side .pr { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--indigo-muted); }
.match-row .side .pr.pending { color: var(--warm-accent); font-style: italic; }
.match-row .center { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: none; }
.match-row .score { font-family: 'DM Mono', monospace; font-size: 19px; font-weight: 600; color: var(--indigo-deep); letter-spacing: 1px; }
.match-row .score .w { color: var(--indigo-deep); }
.match-row .score .l { color: var(--indigo-muted); }
.match-row .state-tag { font-size: 9.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; padding: 1px 7px; border-radius: 999px; }
.match-row .state-tag.analyzed { background: rgba(74,124,89,0.14); color: var(--green); }
.match-row .state-tag.pr_pending { background: rgba(196,169,109,0.2); color: #8a6d2a; }
.match-row .state-tag.upcoming { background: rgba(136,145,184,0.16); color: var(--indigo-light); }
.match-row.is-upcoming { opacity: 0.78; }

/* ── player cards stub ──────────────────────────────────────────── */
.players-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.pcard { background: #fff; border: 1px solid var(--rule); border-radius: 10px; padding: 16px; box-shadow: var(--shadow-card); }
.pcard .ptop { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.pcard .pname { font-weight: 700; color: var(--indigo-deep); display: flex; align-items: center; gap: 8px; }
.pcard .ptitle { font-size: 11px; font-weight: 600; color: var(--warm-accent); text-transform: uppercase; letter-spacing: 0.04em; }
.pcard .pstats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; font-size: 13px; }
.pcard .pstats .k { color: var(--indigo-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
.pcard .pstats .v { font-family: 'DM Mono', monospace; font-weight: 600; color: var(--ink); }

/* ── responsive ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .match-row { grid-template-columns: 1fr auto 1fr; gap: 8px; padding: 10px 12px; }
  .site-header nav a { margin-left: 14px; }
  .event-head .sub { gap: 12px; }
}
