/*
 * Base layer: reset, typography styles and global motion behaviour.
 * Type styles mirror the Figma text styles 1:1 (plus four Delta extensions
 * marked ✚ for general-purpose apps: auth, errors, page titles, hero stats).
 */

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

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 20px;
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  background: var(--surface-bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'tnum' 0;
  /* Theme swaps are transitions too. */
  transition:
    background-color var(--dur-color) var(--ease-color),
    color var(--dur-color) var(--ease-color);
}

h1,
h2,
h3,
h4,
h5,
h6,
p,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

ul[role='list'],
ol[role='list'] {
  list-style: none;
  margin: 0;
  padding: 0;
}

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

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

button {
  cursor: pointer;
}

a {
  color: var(--text-brand);
  text-decoration: none;
}

::selection {
  background: var(--brand);
  color: var(--text-on-brand);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ── Type styles ────────────────────────────────────────────────────── */
.type-display-lg { /* ✚ auth, 404, hero */
  font-size: 40px;
  line-height: 48px;
  font-weight: var(--weight-extrabold);
  letter-spacing: -0.8px;
}
.type-display-md { /* ✚ */
  font-size: 28px;
  line-height: 36px;
  font-weight: var(--weight-bold);
  letter-spacing: -0.4px;
}
.type-heading-xl { /* ✚ page titles */
  font-size: 20px;
  line-height: 28px;
  font-weight: var(--weight-bold);
  letter-spacing: -0.2px;
}
.type-heading-lg {
  font-size: 18px;
  line-height: 24px;
  font-weight: var(--weight-bold);
  letter-spacing: -0.2px;
}
.type-heading-md {
  font-size: 16px;
  line-height: 22px;
  font-weight: var(--weight-bold);
  letter-spacing: -0.2px;
}
.type-heading-sm {
  font-size: 14px;
  line-height: 20px;
  font-weight: var(--weight-semibold);
}
.type-body-md {
  font-size: 14px;
  line-height: 20px;
  font-weight: var(--weight-medium);
}
.type-body-sm {
  font-size: 12px;
  line-height: 16px;
  font-weight: var(--weight-medium);
}
.type-label-md {
  font-size: 12px;
  line-height: 16px;
  font-weight: var(--weight-semibold);
  letter-spacing: 0.2px;
}
.type-label-sm {
  font-size: 11px;
  line-height: 14px;
  font-weight: var(--weight-medium);
  letter-spacing: 0.2px;
}
.type-caption {
  font-size: 11px;
  line-height: 14px;
  font-weight: var(--weight-regular);
}
.type-mono-sm {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 16px;
  font-weight: var(--weight-regular);
}
.type-stat-xl { /* ✚ hero metrics */
  font-size: 36px;
  line-height: 1;
  font-weight: var(--weight-bold);
  letter-spacing: -0.6px;
  font-variant-numeric: tabular-nums;
}
.type-stat-lg {
  font-size: 28px;
  line-height: 1;
  font-weight: var(--weight-bold);
  letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums;
}
.type-stat-md {
  font-size: 18px;
  line-height: 1;
  font-weight: var(--weight-bold);
  letter-spacing: -0.2px;
  font-variant-numeric: tabular-nums;
}
.type-eyebrow {
  font-size: 11px;
  line-height: 14px;
  font-weight: var(--weight-medium);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-brand { color: var(--text-brand); }
.tabular { font-variant-numeric: tabular-nums; }

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

/* ── Global motion helpers ──────────────────────────────────────────── */

/* v-flash: a value just changed — brand-tinted wash that settles away. */
.d-flash {
  animation: d-flash calc(var(--dur-smooth) * 2) var(--ease-smooth);
}
@keyframes d-flash {
  from {
    background-color: var(--brand-bg);
    box-shadow: 0 0 0 1px var(--brand-edge);
  }
}

/* Skeleton shimmer — the only looping animation allowed: it says "loading". */
@keyframes d-shimmer {
  from {
    background-position: 150% 0;
  }
  to {
    background-position: -50% 0;
  }
}

/* Indeterminate activity — running states. */
@keyframes d-spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes d-pulse-dot {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.6);
    opacity: 0.5;
  }
}

/* Theme switch uses the View Transitions API when available (see useTheme). */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

/* Scrollbars that match the surfaces. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
