/*
  BASE: reset, document typography, links, focus and selection, and the layout and utility
  primitives every page uses. Component families live in components.css as `.c-*`; the app shell
  lives in shell.css as `.s-*`. Everything here reads semantic tokens from tokens.css.
*/

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar-height) + var(--space-4));
}

body {
  min-height: 100vh;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

svg {
  flex-shrink: 0;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

table {
  border-collapse: collapse;
}

[hidden] {
  display: none !important;
}

/* ---------- Type ---------- */

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--color-text-strong);
  font-family: var(--font-sans);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}

h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-base); }
h4,
h5,
h6 { font-size: var(--text-md); letter-spacing: normal; }

p {
  text-wrap: pretty;
}

small {
  font-size: var(--text-sm);
}

strong,
b {
  font-weight: var(--weight-semibold);
}

code,
samp,
pre {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

td,
th,
time,
data {
  font-variant-numeric: tabular-nums;
}

ul,
ol {
  padding-left: var(--space-5);
}

hr {
  border: 0;
  border-top: 1px solid var(--color-border);
}

/* ---------- Links ---------- */

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

a:hover {
  color: var(--color-link-hover);
}

/* ---------- Focus and selection ----------
   Focus and selection are independent, so a row can be selected, focused, or both, and each reads
   in both themes. Selection is a left bar (no layout shift). */

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

[aria-selected="true"],
.is-selected {
  background: var(--color-surface-selected);
  box-shadow: inset 3px 0 0 var(--color-action);
}

::selection {
  background: color-mix(in srgb, var(--color-action) 22%, transparent);
}

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

/* ---------- Layout primitives ---------- */

.l-container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.l-page {
  padding-block: var(--space-6) var(--space-12);
}

.l-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.l-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.l-split {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

/* ---------- Utilities ---------- */

.u-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.u-muted { color: var(--color-text-muted); }
.u-subtle { color: var(--color-text-subtle); }
.u-num { font-variant-numeric: tabular-nums; }
.u-mono { font-family: var(--font-mono); font-size: 0.92em; }

.u-overline {
  color: var(--color-text-muted);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-overline);
  text-transform: uppercase;
}

.u-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
