/* ============================================================
   GPX Wyzwania — Base (reset + root typography + a11y)
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html, body {
  height: 100%;
  scroll-behavior: smooth;
  /* Safety net: nigdy nie pozwalamy na poziomy scroll. Gdyby pojedynczy
     element pomylił się z szerokością (np. tabela leaderboarda na bardzo
     wąskim viewporcie), strona nadal trzyma się w ramie ekranu zamiast
     ujawniać poziomy pasek scroll i degradować UX.

     UWAGA: to maskuje problem, nie rozwiązuje go u źródła. Mobile browser
     wykrywa scrollWidth > clientWidth i auto-skaluje stronę w dół (user widzi
     wszystko za małe i musi pinch-zoom-in). Dlatego niżej `min-width: 0` na
     wszystkich elementach — żeby pierwsze szukać prawdziwego źródła overflow,
     a `overflow-x: hidden` zostawić tylko jako siatkę bezpieczeństwa. */
  overflow-x: hidden;
}

/* Globalne: grid/flex children domyślnie mają `min-width: auto` (= min-content),
   przez co tabular-nums czy długie liczby rozpychają kolumny do treści i
   przebijają viewport. `min-width: 0` pozwala kolumnom skurczyć się do
   wartości z grid-template (np. minmax(0, 1fr)). `:where()` ma specificity 0
   więc explicit `min-width: <wartość>` (np. .btn) nadal wygrywa. */
:where(*) {
  min-width: 0;
}

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

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  color: var(--color-ink);
  background: var(--color-surface);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

@media (prefers-color-scheme: dark) {
  body {
    line-height: calc(var(--lh-body) + 0.05);
  }
}

img, svg, video, canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

svg {
  fill: currentColor;
  stroke: currentColor;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: var(--color-accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--color-accent-strong);
}

p {
  max-width: var(--measure);
}

h1, h2, h3, h4 {
  font-weight: 700;
  line-height: var(--lh-heading);
  letter-spacing: var(--tracking-tight);
  color: var(--color-ink);
  text-wrap: balance;
}

h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }

ul, ol {
  padding: 0;
  list-style: none;
}

/* ------------------------------------------------------------
   Focus
   ------------------------------------------------------------ */
:focus { outline: none; }

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ------------------------------------------------------------
   Selection
   ------------------------------------------------------------ */
::selection {
  background: var(--color-accent);
  color: var(--color-accent-ink);
}

/* ------------------------------------------------------------
   Utility: data numerical
   ------------------------------------------------------------ */
.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  letter-spacing: 0;
}

/* ------------------------------------------------------------
   Utility: visually-hidden (for a11y labels)
   ------------------------------------------------------------ */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------
   Reduced motion
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
