/* Reset, fonts, atmosphere (sun glow + grain), typography helpers, focus, motion preferences */

@font-face {
  font-family: 'Urbanist';
  src: url('../assets/fonts/urbanist-variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Urbanist';
  src: url('../assets/fonts/urbanist-italic-variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('../assets/fonts/jetbrains-mono-variable.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

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

html, body, div, span, h1, h2, h3, h4, p, ul, ol, li, form, fieldset, legend, button, input {
  margin: 0;
  padding: 0;
}
ul, ol { list-style: none; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  font-family: var(--font-family-sans);
  font-size: var(--t-body);
  font-weight: 500;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
  font-feature-settings: 'kern', 'liga';
}

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; -webkit-appearance: none; appearance: none; touch-action: manipulation; }
button:disabled { cursor: not-allowed; }
input { -webkit-appearance: none; appearance: none; }
h1, h2, h3 { font-weight: 800; letter-spacing: -0.03em; }

/* ---------- Atmosphere: sun glow + film grain, behind everything ---------- */
#app { position: relative; isolation: isolate; }
#app::before, #app::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
#app::before { background: var(--sky-1), var(--sky-2), var(--sky-3), var(--bg); }
#app::after {
  background-image: var(--grain);
  background-size: 160px 160px;
  mix-blend-mode: var(--grain-blend);
  opacity: var(--grain-opacity);
}
#app > * { position: relative; z-index: 1; }
@media (prefers-reduced-motion: no-preference) {
  #app::before { animation: sun-drift 60s ease-in-out infinite alternate; }
}
@keyframes sun-drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(-1.5%, 1%, 0) scale(1.04); }
}

/* ---------- Typography helpers ---------- */
/* R4-06: mono is data (sentence case, no tracking); .kicker is the one mono caps label. */
.mono {
  font-family: var(--font-family-mono);
  font-size: var(--t-label);
  font-weight: 500;
  letter-spacing: 0;
}
.kicker {
  font-family: var(--font-family-mono);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
  color: var(--text3);
}
/* Numerals: display face (Urbanist has no tnum, so the live clock uses fixed-width .dg/.dc cells). */
.num, .court-card__score-value, .stepper-value, .standings-row__points, .podium__points,
.timer-dock__digits, .timer-overlay__digits, .timer-pill__digits, .stat-num {
  font-family: var(--font-family-sans);
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: 'tnum', 'lnum', 'kern';
}

/* ---------- Icons (R4-01 / R4-05) ---------- */
/* An inline SVG sat on its wrapper's text baseline and drew ~3px high in every icon button.
   Icons are blocks, and a span that only wraps an icon is an inline-flex box (zero
   specificity, so any component display rule still wins). */
svg.i, button svg { display: block; flex: none; }
:where(span:has(> svg:only-child)) { display: inline-flex; }
/* Beside a label, an icon centres on the label's cap height, not its line box (the box centre
   sits ~0.06em below Urbanist's and JetBrains Mono's cap centre). */
:where(:is(.btn, .cmd-btn, .court-card__done, .link-btn, .panel-leader__link, .round-scrubber, .roster-card--new, .timer-pill,
  .top-bar__players, .time-up-banner__btn--icon) > span:has(> svg.i:only-child):not(:only-child)) { translate: 0 -0.06em; }
.timer-dock__btn--play.is-primary:has(.timer-dock__play-label) .timer-dock__play-icon { translate: 0 -0.06em; }
@media (max-width: 759px) { .cmd-btn--back:not(:has(.cmd-btn__label)) > span { translate: none; } } /* icon-only on Compact */
/* One optical stroke: stroke-width is in rendered px at any drawn size (1.75 / 2.25). */
svg.i :is(path, circle, rect, line, polyline, polygon, ellipse) { vector-effect: non-scaling-stroke; }

/* ---------- Focus ---------- */
/* R4-18: the ring is the outline alone; it follows each control's own radius and never
   replaces the control's own shadow. */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--accent-fill);
  outline-offset: 3px;
}
:root:not([data-theme="dark"]) :focus-visible { outline-color: var(--accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) :focus-visible { outline-color: var(--accent-fill); } }
[data-theme="dark"] :focus-visible { outline-color: var(--accent-fill); }

::selection { background: var(--accent-fill); color: var(--on-accent); }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }

/* ---------- Scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

/* ---------- Motion / transparency / contrast preferences ---------- */
@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;
  }
  #app::before { animation: none; }
}
@media (prefers-contrast: more) {
  #app::after { display: none; }
}
@media (forced-colors: active) {
  :focus-visible { outline-color: Highlight; }
}

/* Fixed-width timer cells (see js/timerClock.js paintDigits). */
/* --clock-em is the painted string's width in em ("12:00" = 4 x 0.6 + 0.3); paintDigits updates it. */
[data-timer-digits] { --clock-em: 2.7; display: inline-flex; justify-content: center; align-items: baseline; }
.dg { display: inline-block; width: 0.6em; text-align: center; }
.dc { display: inline-block; width: 0.3em; text-align: center; transform: translateY(-0.04em); }
.dg, .dc { letter-spacing: 0; }
