/* TradeSafe design tokens, reset and layout primitives.
 *
 * The palette is deliberately calm: deep navy grounds, slate surfaces, one
 * blue for action and one green for "settled safely". Saturated colour is
 * rationed — it is how the interface says something matters, so spending it on
 * decoration would leave nothing to say it with when a payment is held or a
 * dispute opens.
 *
 * No webfont is loaded anywhere in this app, on purpose. Mongolian needs both
 * the cyrillic AND cyrillic-ext ranges (Ө Ү ө ү live in the latter) and most
 * display webfonts ship only the former, which silently substitutes those four
 * letters from a fallback face and looks broken — on a trust product, text
 * that renders wrong reads as a text that is fake. The system stack below has
 * full Cyrillic coverage on every platform we care about.
 */

:root {
  --font: "Segoe UI", Roboto, "Helvetica Neue", system-ui, -apple-system, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  /* ---- dark, the default ---- */
  --bg: #070a0f;
  --bg-2: #0b1017;
  --surface: #111821;
  --surface-2: #151d27;
  --surface-3: #1b2531;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .14);
  --line-soft: rgba(255, 255, 255, .05);

  --ink: #f5f7fa;
  --ink-dim: #b3bdcc;
  --ink-faint: #8b96a7;

  --primary: #4f8cff;
  --primary-hi: #6ba0ff;
  --primary-ink: #04122e;
  --primary-soft: rgba(79, 140, 255, .14);
  --primary-line: rgba(79, 140, 255, .34);

  --success: #35c98a;
  --success-soft: rgba(53, 201, 138, .13);
  --success-line: rgba(53, 201, 138, .32);
  --warn: #e0a34a;
  --warn-soft: rgba(224, 163, 74, .13);
  --warn-line: rgba(224, 163, 74, .32);
  --danger: #f26d78;
  --danger-soft: rgba(242, 109, 120, .13);
  --danger-line: rgba(242, 109, 120, .34);
  --info: #7aa2d8;

  /* Liquid glass. One recipe, used only on things that float above content:
   * the top bar, the tab bar, modals, dropdowns, status cards. Everything
   * else is opaque — glass over glass is just fog. */
  --glass-bg: rgba(17, 24, 33, .72);
  --glass-blur: 18px;
  --glass-line: rgba(255, 255, 255, .1);
  --glass-hi: rgba(255, 255, 255, .07);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .34);
  --shadow: 0 8px 24px -6px rgba(0, 0, 0, .5);
  --shadow-lg: 0 24px 60px -14px rgba(0, 0, 0, .62);

  /* ---- shape ---- */
  --r-xs: 6px;
  --r-sm: 9px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-full: 999px;

  /* Control heights. Every button, input and select picks one of these three,
   * which is what stops a row of mixed controls looking assembled by accident. */
  --h-sm: 32px;
  --h: 40px;
  --h-lg: 48px;

  /* ---- motion ---- */
  --dur-1: 120ms;   /* press, colour */
  --dur-2: 200ms;   /* hover, toggles */
  --dur-3: 300ms;   /* page and panel entrances */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-out: cubic-bezier(0, 0, .2, 1);

  --maxw: 1180px;
}

:root[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-2: #eef1f7;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f8;
  --line: rgba(14, 25, 45, .11);
  --line-strong: rgba(14, 25, 45, .2);
  --line-soft: rgba(14, 25, 45, .07);

  --ink: #0f1723;
  --ink-dim: #46536a;
  --ink-faint: #64718a;

  --primary: #245fd6;
  --primary-hi: #1a51c2;
  --primary-ink: #ffffff;
  --primary-soft: rgba(36, 95, 214, .09);
  --primary-line: rgba(36, 95, 214, .28);

  /* Darker than it looks like it needs to be: this green is most often set on
   * its own 10% tint (a "settled safely" badge), and at #12855a that pairing
   * measures 4.08:1 — under AA. On the tint this clears 4.67:1. */
  --success: #0f7a52;
  --success-soft: rgba(15, 122, 82, .1);
  --success-line: rgba(15, 122, 82, .26);
  --warn: #91600f;
  --warn-soft: rgba(145, 96, 15, .1);
  --warn-line: rgba(145, 96, 15, .26);
  --danger: #c32f3d;
  --danger-soft: rgba(195, 47, 61, .09);
  --danger-line: rgba(195, 47, 61, .26);
  --info: #35618f;

  --glass-bg: rgba(255, 255, 255, .74);
  --glass-line: rgba(14, 25, 45, .1);
  --glass-hi: rgba(255, 255, 255, .75);

  --shadow-sm: 0 1px 2px rgba(16, 27, 48, .07);
  --shadow: 0 8px 24px -8px rgba(16, 27, 48, .16);
  --shadow-lg: 0 24px 56px -16px rgba(16, 27, 48, .22);
}

/* ------------------------------------------------------------------ reset */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  /* The page scrolls vertically only; wide things scroll inside their own box. */
  overflow-x: hidden;
}

/* A single, very quiet ambient wash. It exists to stop a full-viewport flat
 * navy reading as an unfinished page, and it is fixed so it never parallaxes. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(70% 50% at 50% -10%, color-mix(in srgb, var(--primary) 9%, transparent), transparent 70%);
}

h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.22; font-weight: 680; letter-spacing: -.016em; }
h1 { font-size: clamp(1.55rem, 1.15rem + 1.7vw, 2.15rem); letter-spacing: -.024em; }
h2 { font-size: clamp(1.15rem, 1rem + .7vw, 1.4rem); }
h3 { font-size: 1.02rem; font-weight: 650; }
p { margin: 0 0 .8em; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
hr { border: 0; border-top: 1px solid var(--line); margin: .2rem 0; }

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

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--primary); color: var(--primary-ink);
  padding: .7rem 1.1rem; border-radius: 0 0 var(--r) 0; font-weight: 600;
}
.skip:focus { left: 0; }

/* One focus ring for the whole product. Two tones so it stays visible on both
 * a dark surface and a light one without needing per-component overrides. */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* The router moves focus to <main> on every navigation so a screen reader
 * announces the new view. That is programmatic focus, not keyboard focus — but
 * Chromium still matches :focus-visible for it, which drew a 2px ring around
 * the entire page on every route change. Suppressed here and nowhere else: the
 * skip link still lands focus on <main>, and every real control keeps its ring. */
#main:focus, #main:focus-visible { outline: none; }

::selection { background: color-mix(in srgb, var(--primary) 35%, transparent); }

/* ---------------------------------------------------------------- layout */

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(1rem, 3vw, 1.6rem); }
.wrap-narrow { max-width: 760px; }

.main { min-height: 60dvh; padding: 1.5rem 0 6rem; }

.row { display: flex; gap: .55rem; align-items: center; }
.row-wrap { flex-wrap: wrap; }
.between { display: flex; gap: .8rem; align-items: center; justify-content: space-between; }
.spacer { flex: 1 1 auto; }
.stack { display: grid; gap: .8rem; }
.stack-sm { display: grid; gap: .45rem; }
.stack-lg { display: grid; gap: 1.6rem; }
.stack-xl { display: grid; gap: 2.4rem; }

/* Flex and grid children both default to min-width:auto, so one long unbroken
 * title inside a row refuses to shrink and drags the page wider than the
 * phone. Every layout primitive that can hold user text opts out of that. */
.stack > *, .stack-sm > *, .stack-lg > *, .stack-xl > *,
.cols > *, .between > *, .panel > *, .scroll-x > *, .row > * { min-width: 0; }

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.grid > * { min-width: 0; }

.cols { display: grid; gap: 1.4rem; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 900px) { .cols { grid-template-columns: minmax(0, 1fr); } }

.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* --------------------------------------------------------------- utility */

.muted { color: var(--ink-dim); }
.faint { color: var(--ink-faint); }
.small { font-size: .85rem; }
.tiny { font-size: .765rem; }
.mono { font-family: var(--mono); font-size: .92em; }
.strike { text-decoration: line-through; opacity: .55; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hidden { display: none !important; }
.measure { max-width: 62ch; }

/* Screen-reader-only, still focusable. Used for labels that would be visual
 * noise but that a screen reader needs to make a control make sense. */
.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- motion */

/* Every view fades up on entry. 300ms and 6px — enough to register as "the
 * page responded", short enough that nobody waits for it. */
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position-x: -200%; } }

.view-in { animation: view-in var(--dur-3) var(--ease-out) both; }

/* Reduced motion: keep state changes instant but do not remove them, so a
 * toggle still visibly toggles and a status still visibly changes. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
