/* ============================================================
   CardXchange — Base: reset + typography + layout primitives
   ============================================================ */

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

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

::selection { background: var(--violet-600); color: #fff; }

/* Quiet, branded scrollbar */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #cfc9e2;
  border-radius: 8px;
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--violet-400); }

h1, h2, h3, h4, .display {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--ink);
  font-feature-settings: "liga", "kern";
}

h1 { font-size: clamp(32px, 4.6vw, 48px); }
h2 { font-size: clamp(23px, 3vw, 30px); }
h3 { font-size: 19.5px; }
h4 { font-size: 16px; }

p { margin: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
}

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

::placeholder { color: var(--ink-3); }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 40%, transparent);
  outline-offset: 2px;
}

/* ---- Layout helpers ---- */
.container {
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.muted   { color: var(--ink-2); }
.faint   { color: var(--ink-3); }
.money   { font-family: var(--font-display); font-weight: 700; font-variant-numeric: lining-nums tabular-nums; }
.green   { color: var(--green-600); }
.red     { color: var(--red-600); }
.amber   { color: var(--amber-700); }
.accent  { color: var(--accent); }

.flex        { display: flex; }
.flex-center { display: flex; align-items: center; }
.between     { display: flex; align-items: center; justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.wrap   { flex-wrap: wrap; }

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

/* Wide tables / rows scroll inside their card, never the page.
   position:relative contains absolutely-positioned descendants
   (e.g. .visually-hidden) so they can't force page-wide overflow. */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; position: relative; }

/* ---- Scroll-reveal (elements start hidden, JS adds .is-in) ---- */
.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
  transition-delay: var(--reveal-delay, 0s);
}
.reveal.is-in { opacity: 1; transform: none; }

/* Value bump when a live number recalculates */
.bump { animation: bump 0.35s var(--ease-spring); }
@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* ---- Motion ---- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}
