/* base.css: reset, typography and layout primitives. Theme values come from tokens.css. */

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

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-ui);
  font-size: var(--text-md);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-tint), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  transition: background-color var(--dur-slow) var(--ease-out), color var(--dur-slow) var(--ease-out);
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.2;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }
p { margin: 0; }
a { color: var(--accent-ink); text-underline-offset: 2px; }
a:hover { color: var(--text); }
code, kbd, .mono { font-family: var(--font-mono); font-size: 0.92em; }
kbd {
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  box-shadow: 0 1px 0 var(--border);
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

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

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

/* Scrollbars that respect the theme */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }

.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;
}

/* ---- Layout primitives ---------------------------------------------------------------- */
.stack { display: flex; flex-direction: column; gap: var(--gap, var(--space-4)); }
.row { display: flex; align-items: center; gap: var(--gap, var(--space-3)); flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.spacer { flex: 1; }
.grid-2 { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.grid-3 { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: var(--text-sm); }
.xs { font-size: var(--text-xs); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Gentle entrance used for page and card reveals (opacity + 6px rise; disabled for reduced motion). */
@keyframes rise-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.rise-in { animation: rise-in var(--dur-slow) var(--ease-out) both; }
@media (prefers-reduced-motion: reduce) {
  /* Loading indicators (.motion-ok) keep animating, since they communicate state, not decoration. */
  *:not(.motion-ok), *:not(.motion-ok)::before, *:not(.motion-ok)::after {
    animation-duration: 0ms !important; animation-iteration-count: 1 !important; transition-duration: 0ms !important;
  }
}

/* In-app "Reduce motion" switch (App settings) mirrors the OS preference. */
:root.reduce-motion *:not(.motion-ok),
:root.reduce-motion *:not(.motion-ok)::before,
:root.reduce-motion *:not(.motion-ok)::after {
  animation-duration: 0ms !important; animation-iteration-count: 1 !important; transition-duration: 0ms !important;
}
