/* ==========================================================================
   Base: reset, typography, focus ring, utilities.
   Origin: stembot-runeworks:web/src/styles/base.css (adapted)
   Uses semantic tokens only.
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Anchored scroll targets must not hide under the sticky topbar. */
  scroll-padding-top: calc(var(--topbar-h) + var(--space-3));
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-family: var(--font-display);
  line-height: 1.2;
  letter-spacing: -0.01em;
  font-weight: 650;
  text-wrap: balance;
}
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4, h5, h6 { font-size: var(--fs-md); }

p { margin: 0; text-wrap: pretty; }
p + p { margin-top: var(--space-3); }
ul, ol { margin: 0; padding-left: 1.25em; }
img, svg, video, canvas { display: block; max-width: 100%; }
svg { flex-shrink: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-4) 0; }
small { font-size: var(--fs-sm); }
code, kbd, pre, samp { font-family: var(--font-mono); font-size: 0.92em; }
kbd {
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
pre {
  margin: 0;
  padding: var(--space-3);
  overflow: auto;
  background: var(--bg-sunken);
  border-radius: var(--radius);
}

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

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
[hidden] { display: none !important; }

::selection { background: var(--accent-soft); color: var(--text); }

/* One focus ring for everything. `:focus-visible` keeps it off mouse clicks
   while guaranteeing keyboard users always see where they are. */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Headings/regions focused by script (router, skip link) announce themselves
   to screen readers; they are not controls, so no ring. */
[tabindex="-1"]:focus-visible { outline: none; }

/* Skip link: first tab stop on every page. */
.ui-skip-link {
  position: absolute;
  left: var(--space-3);
  top: -100px;
  z-index: calc(var(--z-toast) + 1);
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: var(--radius);
  text-decoration: none;
}
.ui-skip-link:focus { top: var(--space-3); }

/* --- Utilities --------------------------------------------------------- */
.ui-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.ui-muted { color: var(--text-muted); }
.ui-faint { color: var(--text-faint); }
.ui-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ui-mono { font-family: var(--font-mono); }
.ui-num { font-variant-numeric: tabular-nums; }
.ui-small { font-size: var(--fs-sm); }
.ui-nowrap { white-space: nowrap; }
.ui-text-right { text-align: right; }
.ui-text-center { text-align: center; }

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