/* =========================================================================
   BASE  (SHELL area) — reset, typography, utilities, grain texture
   ========================================================================= */
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  font-size: var(--fs-md);
  font-weight: 500;
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
  overflow: hidden;            /* views scroll inside their own section */
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
input, textarea, [data-selectable] { user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; margin: 0; }
input { font: inherit; color: inherit; margin: 0; }
img, svg { display: block; }
a { color: var(--violet-300); text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--violet-400); outline-offset: 2px; }
::selection { background: var(--primary-tint); }

/* ---------- grain: very subtle film noise over big surfaces ---------- */
.grain::after,
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.045;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 1.1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 160px 160px;
}
.grain { position: relative; isolation: isolate; }
.grain::after { position: absolute; border-radius: inherit; z-index: 0; opacity: 0.05; }

/* ---------- typography ---------- */
.t-display, .h1, .h2, .h3 {
  font-family: var(--font-display);
  letter-spacing: var(--tracking-display);
  line-height: var(--lh-tight);
}
.h1 { font-size: var(--fs-3xl); font-weight: 700; }
.h2 { font-size: var(--fs-2xl); font-weight: 700; }
.h3 { font-size: var(--fs-xl); font-weight: 600; }
.t-lg { font-size: var(--fs-lg); }
.t-sm { font-size: var(--fs-sm); }
.t-xs { font-size: var(--fs-xs); }
.t-2 { color: var(--text-2); }
.t-3 { color: var(--text-3); }
.t-strong { font-weight: 700; }
.t-caps { text-transform: uppercase; letter-spacing: var(--tracking-caps); font-size: var(--fs-xs); font-weight: 700; }
.t-center { text-align: center; }
.t-pos { color: var(--green-400); }
.t-neg { color: var(--red-400); }
.t-gold { color: var(--gold-400); }
.num, .tnum { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1, 'lnum' 1; }
.t-mono { font-family: var(--font-mono); font-size: 12px; word-break: break-all; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ---------- layout utilities ---------- */
.row { display: flex; align-items: center; gap: var(--s-3); }
.col { display: flex; flex-direction: column; gap: var(--s-3); }
.grow { flex: 1; min-width: 0; }
.stack-2 > * + * { margin-top: var(--s-2); }
.stack-3 > * + * { margin-top: var(--s-3); }
.stack-4 > * + * { margin-top: var(--s-4); }
.stack-6 > * + * { margin-top: var(--s-6); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.no-scrollbar { scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }

/* ---------- motion utilities (see js/core/motion.js) ---------- */
/* Children of .stagger fade/slide in one after another; motion.stagger() sets --i. */
.stagger > * { animation: rise var(--dur-ui) var(--ease-standard) both; animation-delay: calc(var(--i, 0) * var(--stagger-step)); }
.anim-rise { animation: rise var(--dur-ui) var(--ease-standard) both; }
.anim-pop { animation: pop var(--dur-ui) var(--ease-spring) both; }
.anim-fade { animation: fade var(--dur-fast) var(--ease-standard) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes pop { from { opacity: 0; transform: scale(0.92); } }
@keyframes fade { from { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
  }
  .stagger > *, .anim-rise, .anim-pop { animation-name: fade !important; animation-duration: var(--dur-fast) !important; }
}
html.reduced-motion *, html.reduced-motion *::before, html.reduced-motion *::after {
  animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important;
}
