/* ==========================================================================
   base.css — reset, typography, focus, utilities, reduced motion (Core)
   Tokens only (see tokens.css). No hex colors here.
   ========================================================================== */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
  scrollbar-color: var(--surface-3) transparent;
  scrollbar-gutter: stable;
}

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-size: var(--fs-14);
  line-height: var(--lh-14);
  font-weight: var(--fw-regular);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'kern' 1;
}

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

img {
  height: auto;
}

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

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:disabled,
[aria-disabled='true'] {
  cursor: default;
}

a {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3,
h4 {
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
  overflow-wrap: anywhere;
}

p {
  text-wrap: pretty;
}

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

[hidden] {
  display: none !important;
}

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

/* ---- Focus: one visible ring everywhere, keyboard only ---- */
:focus {
  outline: none;
}

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

/* ---- Icons ---- */
.icon {
  flex: none;
  pointer-events: none;
}

/* ---- Numbers ---- */
.tabular,
.num,
.tnum {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

/* ---- Utilities ---- */
.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;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.clamp-2,
.clamp-3 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.clamp-2 {
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.clamp-3 {
  -webkit-line-clamp: 3;
  line-clamp: 3;
}

.muted {
  color: var(--text-3);
}

.skip-link {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-tooltip);
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-1);
  font-weight: var(--fw-medium);
  transform: translateY(-200%);
  transition: transform var(--dur-base) var(--ease);
}

.skip-link:focus-visible {
  transform: none;
}

@media (max-width: 899px), (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
  a,
  button,
  input,
  select,
  textarea,
  [role='button'],
  [role='tab'],
  [role='radio'],
  [role='switch'],
  [role='menuitem'] {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
}

/* ---- Scrollbars (WebKit) ---- */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg);
}

@media (hover: hover) {
  ::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
  }
}

/* ---- Reduced motion: kill transitions and animations globally ---- */
@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;
  }
}
