/* ============================================================
   NextGen Ranking — paper-clean, mobile-first
   Single goal: read the ranking. Everything else is muted.
   ============================================================ */

:root {
  --bg:        #faf9f6;   /* warm paper */
  --bg-2:      #f4f2ed;   /* slightly stronger */
  --card:      #ffffff;
  --ink:       #0e1116;
  --ink-2:     #545b66;
  --ink-3:     #8c93a0;
  --line:      rgba(14, 17, 22, 0.08);
  --line-2:    rgba(14, 17, 22, 0.14);
  --accent:    #1f8a5b;   /* padel court green */
  --accent-2:  #ecf6f0;   /* soft accent fill */
  --gold:      #b8860b;
  --silver:    #6c757d;
  --bronze:    #a05a2c;
  --radius:    14px;
  --radius-sm: 10px;

  --font-sans: "Inter", "Helvetica Neue", Helvetica, system-ui, sans-serif;
  --font-disp: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  font-feature-settings: "tnum" 1, "cv11";
}

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

button { font-family: inherit; }

/* ===== Page shell ===== */
.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 16px 64px;
}

/* ===== Header ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 6px 4px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand__mark {
  width: 32px; height: 32px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--accent-2);
  border-radius: 8px;
}
.brand__name {
  font-family: var(--font-disp); font-weight: 600;
  font-size: 17px; letter-spacing: -0.01em;
  line-height: 1;
}
.brand__tag {
  font-size: 11px; color: var(--ink-3); margin-top: 4px;
  letter-spacing: 0.01em;
}
.updated {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 11px;
  color: var(--ink-3); white-space: nowrap;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
}
.updated__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
}

/* ===== Language switcher ===== */
.topbar__right {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; justify-content: flex-end;
}
.lang {
  display: flex; gap: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  padding: 2px;
}
.lang__btn {
  appearance: none;
  border: 0; background: transparent;
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.08em; font-weight: 600;
  color: var(--ink-3);
  padding: 5px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
}
.lang__btn:hover { color: var(--ink); }
.lang__btn--on {
  background: var(--ink);
  color: #fff;
}

/* ===== Selector pills ===== */
.pills {
  display: flex; gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 8px -16px 0;
  padding: 4px 16px 6px;
}
.pills::-webkit-scrollbar { display: none; }
.pill {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink-2);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  min-height: 38px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.15s;
}
.pill:focus { outline: 0; }
.pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pill:hover:not(.pill--disabled) {
  border-color: var(--line-2);
  color: var(--ink);
}
.pill--on,
.pill--on:hover,
.pill--on:focus,
.pill--on:active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.pill--on > span {
  color: #fff;
  -webkit-text-fill-color: #fff;
}
.pill--on .pill__soon { background: rgba(255,255,255,0.16); color: rgba(255,255,255,0.7); }
.pill--disabled { color: var(--ink-3); cursor: not-allowed; }
.pill__soon {
  font-family: var(--font-mono); font-size: 9px;
  letter-spacing: 0.14em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px;
  background: var(--bg-2); color: var(--ink-3);
}

.pills-row {
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-3);
  margin: 14px 4px 6px;
}

/* ===== Section line above table ===== */
.tablehead {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px;
  margin: 22px 4px 10px;
}
.tablehead__title {
  font-family: var(--font-disp); font-weight: 600;
  font-size: 16px; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 8px;
}
.tablehead__count {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--ink-3);
}
/* ===== Search ===== */
.search {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  margin: 0 4px 10px;
}
.search__icon { color: var(--ink-3); font-size: 14px; }
.search__input {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: 0;
  color: var(--ink); font-family: var(--font-sans); font-size: 14px;
}
.search__input::placeholder { color: var(--ink-3); }

/* ===== Classification table ===== */
.ctable {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.ctable__head {
  display: grid;
  grid-template-columns: 40px 1fr 72px 72px;
  gap: 10px;
  padding: 12px 14px;
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.ctable__head .ctable__col--points,
.ctable__head .ctable__col--delta { text-align: right; }

.ctable__row {
  display: grid;
  grid-template-columns: 40px 1fr 72px 72px;
  gap: 10px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}
.ctable__row-wrap:last-child .ctable__row { border-bottom: 0; }

.ctable__col--player { min-width: 0; }
.ctable__col--delta  { text-align: right; }
.ctable__col--points { text-align: right; }

.rank {
  font-family: var(--font-mono); font-weight: 500;
  font-size: 14px; color: var(--ink-2);
  text-align: center;
}
.rank--1, .rank--2, .rank--3 {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%;
  font-weight: 700; color: #fff;
}
.rank--1 { background: var(--gold); }
.rank--2 { background: var(--silver); }
.rank--3 { background: var(--bronze); }

.player {
  font-family: var(--font-disp); font-weight: 500;
  font-size: 15px; color: var(--ink);
  line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}
.player__sub {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--ink-3); margin-top: 2px;
  letter-spacing: 0.04em;
}

.delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-family: var(--font-mono); font-size: 12px; font-weight: 500;
  color: var(--accent);
  padding: 3px 7px; border-radius: 999px;
  background: var(--accent-2);
}
.delta--zero {
  display: inline; color: var(--ink-3);
  background: transparent; padding: 0;
}

.pts {
  font-family: var(--font-disp); font-weight: 600;
  font-size: 17px; color: var(--ink);
  letter-spacing: -0.01em;
}

/* ===== Empty state ===== */
.empty {
  padding: 56px 24px; text-align: center;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty__icon { font-size: 32px; opacity: 0.4; margin-bottom: 10px; }
.empty__title { font-family: var(--font-disp); font-weight: 600; font-size: 16px; margin-bottom: 6px; }
.empty__sub { font-size: 13px; color: var(--ink-3); }

/* ===== Disclosure: how points work ===== */
.disclose {
  margin-top: 28px;
}
.disclose__btn {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-disp); font-weight: 500;
  font-size: 14px; color: var(--ink);
}
.disclose__btn:hover { border-color: var(--line-2); }
.disclose__chev { transition: transform 0.18s; font-size: 12px; color: var(--ink-3); }
.disclose__btn[aria-expanded="true"] .disclose__chev { transform: rotate(180deg); }
.disclose__body {
  margin-top: 8px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.rule-row {
  display: grid; grid-template-columns: 60px 1fr;
  gap: 14px; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.rule-row:last-child { border-bottom: 0; }
.rule-row__pts {
  font-family: var(--font-disp); font-weight: 700;
  font-size: 18px; color: var(--accent);
}
.rule-row__lbl { font-size: 13px; color: var(--ink-2); line-height: 1.4; }

/* ===== Footer ===== */
.footer {
  margin-top: 32px;
  font-size: 11px;
  color: var(--ink-3);
  text-align: center;
  line-height: 1.6;
}
.footer a { color: var(--ink-2); }

/* ===== Stage timeline (under header) ===== */
.timeline {
  display: flex; align-items: center;
  gap: 2px;
  margin: 4px 4px 0;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.tl-stop {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; flex-shrink: 0;
  min-width: 44px;
}
.tl-stop__dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--card);
  border: 1.5px solid var(--line-2);
}
.tl-stop--data .tl-stop__dot { background: var(--accent); border-color: var(--accent); }
.tl-stop--latest .tl-stop__dot {
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--accent) 18%, transparent);
}
.tl-stop__num {
  font-family: var(--font-disp); font-weight: 600;
  font-size: 11px; color: var(--ink-2);
  line-height: 1;
}
.tl-stop--data .tl-stop__num,
.tl-stop--latest .tl-stop__num { color: var(--ink); }
.tl-stop__date {
  font-family: var(--font-mono); font-size: 9px;
  color: var(--ink-3); line-height: 1;
  letter-spacing: 0.04em;
}
.tl-rail {
  flex: 1 1 auto; min-width: 8px;
  height: 1.5px;
  background: var(--line-2);
  border-radius: 999px;
  margin-bottom: 18px; /* aligns with dot center */
}

/* ===== Stage trail (per row) ===== */
.trail {
  display: inline-flex; gap: 3px;
  margin-top: 6px;
}
.trail__dot {
  width: 18px; height: 18px;
  border-radius: 5px;
  display: inline-grid; place-items: center;
  font-family: var(--font-mono); font-size: 9px; font-weight: 600;
  background: var(--bg-2);
  color: var(--ink-3);
  border: 1px solid transparent;
  transition: transform 0.12s;
}
.trail__dot:hover { transform: translateY(-1px); }
.trail__dot--none  { opacity: 0.55; }
.trail__dot--g     { background: color-mix(in oklch, var(--ink) 7%,  white); color: var(--ink-2); }
.trail__dot--qf    { background: color-mix(in oklch, #4a8bc2 22%, white); color: #2c5d87; }
.trail__dot--sf    { background: color-mix(in oklch, var(--accent) 22%, white); color: var(--accent); }
.trail__dot--fin   { background: color-mix(in oklch, var(--silver) 28%, white); color: #3a4047; }
.trail__dot--champ {
  background: color-mix(in oklch, var(--gold) 32%, white);
  color: #7a5a08;
  border-color: color-mix(in oklch, var(--gold) 45%, white);
}
.trail__id { line-height: 1; }

/* ===== Classification row interactive ===== */
.ctable__row {
  width: 100%;
  background: var(--card);
  border: 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.ctable__row:hover { background: color-mix(in oklch, var(--accent) 3%, white); }
.ctable__row--open { background: color-mix(in oklch, var(--accent) 5%, white); }
.ctable__row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ===== Player profile drawer ===== */
.profile {
  position: fixed; inset: 0;
  z-index: 50;
  display: flex; flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
}
.profile__backdrop {
  position: absolute; inset: 0;
  background: rgba(14, 17, 22, 0.32);
  backdrop-filter: blur(2px);
  animation: profile-fade 0.18s ease-out;
  pointer-events: none;
}
.profile__panel {
  pointer-events: auto;
}
.profile__panel {
  position: relative;
  background: var(--bg);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 -8px 32px rgba(14, 17, 22, 0.18);
  animation: profile-slide 0.22s ease-out;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
@keyframes profile-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes profile-slide {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.profile__head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  position: sticky; top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  z-index: 1;
}
.profile__name-wrap { min-width: 0; }
.profile__name {
  font-family: var(--font-disp); font-weight: 600;
  font-size: 20px; letter-spacing: -0.01em;
  color: var(--ink); line-height: 1.15;
  overflow: hidden; text-overflow: ellipsis;
}
.profile__record {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--ink-3); margin-top: 4px;
  letter-spacing: 0.04em;
}
.profile__close {
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-2);
  font-size: 22px; line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.profile__close:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.profile__close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.profile__body {
  padding: 14px 16px 28px;
  display: flex; flex-direction: column; gap: 18px;
}
.profile__empty {
  padding: 36px 24px;
  text-align: center;
  color: var(--ink-3); font-size: 14px;
}

.profile__headline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}
.stat {
  text-align: center;
  padding: 8px 4px;
  border-radius: 8px;
}
.stat__num {
  font-family: var(--font-disp); font-weight: 700;
  font-size: 20px; color: var(--ink);
  line-height: 1;
}
.stat__lbl {
  font-family: var(--font-mono); font-size: 9px;
  color: var(--ink-3); letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 6px;
}
.stat--win .stat__num  { color: var(--accent); }
.stat--loss .stat__num { color: var(--bronze); }

.profile__section { display: flex; flex-direction: column; gap: 8px; }
.profile__h3 {
  margin: 0;
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 600;
}
.profile__hint {
  font-size: 13px; color: var(--ink-3);
  padding: 14px 16px;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}
.profile__list {
  list-style: none; margin: 0; padding: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.profile__list-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.profile__list-row:last-child { border-bottom: 0; }
.profile__list-name {
  font-family: var(--font-disp); font-weight: 500;
  font-size: 14px; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.profile__list-meta {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--ink-3); flex-shrink: 0;
  letter-spacing: 0.02em;
}

.profile__matches {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.match {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.match__tag {
  display: flex; flex-direction: column; gap: 2px;
  align-items: flex-start;
}
.match__stage {
  font-family: var(--font-disp); font-weight: 600;
  font-size: 13px; color: var(--ink);
  line-height: 1;
}
.match__phase {
  font-family: var(--font-mono); font-size: 9px;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-3);
}
.match__teams { min-width: 0; }
.match__partner {
  font-family: var(--font-disp); font-size: 13px;
  color: var(--ink); line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.match__vs {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--ink-2); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.match__result {
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0;
}
.match__result-mark {
  width: 22px; height: 22px;
  display: inline-grid; place-items: center;
  border-radius: 50%;
  font-family: var(--font-disp); font-weight: 700;
  font-size: 12px;
  background: var(--bg-2); color: var(--ink-2);
}
.match__result--win  .match__result-mark { background: var(--accent);                       color: #fff; }
.match__result--loss .match__result-mark { background: color-mix(in oklch, var(--bronze) 80%, white); color: #fff; }
.match__score {
  font-family: var(--font-mono); font-size: 13px; font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.02em;
}

/* Bigger points number on mobile */
.pts { font-size: 18px; }
.stagger-in {
  opacity: 0; transform: translateY(4px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.stagger-in--on { opacity: 1; transform: translateY(0); }

/* ===== Wider screens ===== */
@media (min-width: 720px) {
  .page { padding: 32px 24px 80px; max-width: 820px; }
  .brand__name { font-size: 20px; }
  .brand__tag  { font-size: 12px; }
  .pills { margin: 8px 0 0; padding: 4px 0 6px; }
  .ctable__head, .ctable__row {
    grid-template-columns: 56px 1fr 96px 96px;
    padding: 14px 20px;
    gap: 16px;
  }
  .player { font-size: 16px; }
  .pts { font-size: 21px; }
  .trail__dot { width: 20px; height: 20px; font-size: 10px; }
  .tl-stop { min-width: 56px; }
  .tl-stop__date { font-size: 10px; }

  .profile { justify-content: center; align-items: center; padding: 24px; }
  .profile__panel {
    max-width: 560px; width: 100%;
    max-height: 84vh;
    border-radius: 18px;
    box-shadow: 0 18px 48px rgba(14, 17, 22, 0.22);
  }
  .profile__name { font-size: 22px; }
  .stat__num { font-size: 24px; }
}
