/*
 * CertaRounds — base: reset, typography, focus, selection, scrollbars.
 * Depends on tokens.css.
 */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-padding-top: calc(var(--topbar-h) + var(--safe-top) + 8px);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: var(--fw-regular);
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd, ul, ol { margin: 0; }
ul[role="list"], ol[role="list"], .list-reset { list-style: none; padding: 0; }

h1, h2, h3, h4 {
  color: var(--text-strong);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--lh-tight);
  text-wrap: balance;
}
h1 { font-size: var(--fs-30); }
h2 { font-size: var(--fs-20); line-height: var(--lh-snug); }
h3 { font-size: var(--fs-17); line-height: var(--lh-snug); letter-spacing: var(--tracking-snug); }
h4 { font-size: var(--fs-15); line-height: var(--lh-snug); letter-spacing: 0; }
p { text-wrap: pretty; }

a { color: var(--link); text-decoration: none; text-underline-offset: 3px; }
a:hover { color: var(--link-hover); text-decoration: underline; }

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

button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
button:disabled, [aria-disabled="true"] { cursor: not-allowed; }
input, textarea, select { background: none; border: 0; }
textarea { resize: vertical; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
table { border-collapse: collapse; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-4) 0; }
[hidden] { display: none !important; }

kbd {
  font-family: var(--font-sans);
  font-size: var(--fs-12);
  font-weight: var(--fw-semibold);
}

/* Numbers that change (timers, counters) never jitter */
.tnum, time, .num { font-variant-numeric: tabular-nums; }

/* ---------- Focus ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}
/* Components with their own radius keep it: they use box-shadow rings instead. */

/* ---------- Selection ---------- */
::selection { background: var(--violet-200); color: var(--navy-900); }
:root[data-theme="dark"] ::selection { background: #4A3FB0; color: #FFFFFF; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) ::selection { background: #4A3FB0; color: #FFFFFF; }
}

/* ---------- Scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--border-control); }

/* ---------- Typography helpers ---------- */
.t-display { font-size: var(--fs-36); font-weight: var(--fw-bold); letter-spacing: var(--tracking-tight); line-height: 1.08; color: var(--text-strong); }
.t-h1 { font-size: var(--fs-30); font-weight: var(--fw-bold); letter-spacing: var(--tracking-tight); line-height: var(--lh-tight); color: var(--text-strong); }
.t-h2 { font-size: var(--fs-20); font-weight: var(--fw-bold); letter-spacing: var(--tracking-tight); line-height: var(--lh-snug); color: var(--text-strong); }
.t-h3 { font-size: var(--fs-17); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-snug); line-height: var(--lh-snug); color: var(--text-strong); }
.t-body { font-size: var(--fs-body); line-height: var(--lh-body); }
.t-lead { font-size: var(--fs-17); line-height: var(--lh-body); color: var(--text-2); }
.t-small { font-size: var(--fs-13); line-height: 1.45; }
.t-caption { font-size: var(--fs-13); line-height: 1.4; color: var(--text-3); }
.t-overline { font-size: var(--fs-12); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--text-3); }
.t-value { font-size: var(--fs-24); font-weight: var(--fw-bold); letter-spacing: var(--tracking-tight); line-height: 1.1; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.t-accent { color: var(--text-accent); }
.t-muted { color: var(--text-2); }
.t-subtle { color: var(--text-3); }
.t-strong { color: var(--text-strong); font-weight: var(--fw-semibold); }
.t-success { color: var(--success); }
.t-danger { color: var(--danger); }
.t-warning { color: var(--warning); }
.t-center { text-align: center; }
.t-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.t-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.t-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Accessible hiding */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--sp-3); top: -200px;
  z-index: var(--z-tooltip);
  padding: var(--sp-2) var(--sp-4);
  background: var(--surface); color: var(--link);
  border-radius: var(--r-sm); box-shadow: none;
  font-weight: var(--fw-semibold);
}
.skip-link:focus { top: calc(var(--safe-top) + var(--sp-3)); box-shadow: var(--shadow-raised); }

/* Reduced motion: stop every transition and animation, not just ours */
@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;
  }
}
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}
