/* =============================================================
   TRYTRACK BASE.CSS  — v2
   Reset · Design tokens · Typography · Utilities · Accessibility
   ============================================================= */

/* ── Reset ─────────────────────────────────────────────────── */

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

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

body {
  min-height: 100vh;
  overflow-x: hidden;
}

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

img { height: auto; }

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

button {
  border: none;
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol { list-style: none; }

/* ── Design Tokens ─────────────────────────────────────────── */

:root {
  /* Backgrounds */
  --bg:         #07111f;
  --bg-deep:    #020617;
  --bg-soft:    #0f172a;

  /* Surfaces */
  --surface:        rgba(15, 23, 42, 0.84);
  --surface-strong: rgba(15, 23, 42, 0.94);
  --surface-soft:   rgba(30, 41, 59, 0.62);
  --surface-glass:  rgba(15, 23, 42, 0.72);

  /* Borders */
  --border:       rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);
  --border-glow:  rgba(56, 189, 248, 0.35);

  /* Text */
  --text:         #f8fafc;
  --text-soft:    #e2e8f0;
  --muted:        #94a3b8;
  --muted-strong: #cbd5e1;

  /* Brand */
  --primary:       #38bdf8;
  --primary-dark:  #2563eb;
  --primary-soft:  rgba(56, 189, 248, 0.16);
  --primary-faint: rgba(56, 189, 248, 0.08);

  /* Semantic */
  --success:       #22c55e;
  --success-soft:  rgba(34, 197, 94, 0.16);
  --warning:       #f59e0b;
  --warning-soft:  rgba(245, 158, 11, 0.16);
  --danger:        #ef4444;
  --danger-soft:   rgba(239, 68, 68, 0.16);

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, var(--primary), var(--primary-dark));
  --gradient-surface: linear-gradient(135deg, rgba(15,23,42,0.88), rgba(2,6,23,0.72));

  /* Radii */
  --r-xs:   10px;
  --r-sm:   14px;
  --r-md:   18px;
  --r-lg:   22px;
  --r-xl:   28px;
  --r-2xl:  34px;
  --r-pill: 999px;

  /* Shadows */
  --shadow-xs: 0 4px 12px rgba(0,0,0,0.18);
  --shadow-sm: 0 8px 24px rgba(0,0,0,0.22);
  --shadow-md: 0 16px 44px rgba(0,0,0,0.28);
  --shadow-lg: 0 24px 70px rgba(0,0,0,0.34);
  --shadow-glow: 0 0 34px rgba(56,189,248,0.14);

  /* Layout */
  --sidebar-w: 280px;
  --page-pad:  32px;

  /* Spacing scale */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 28px; --sp-8: 32px;
  --sp-10: 40px; --sp-12: 48px; --sp-16: 64px;

  /* Type scale */
  --fs-xs:   11px; --fs-sm: 12px; --fs-md: 14px;
  --fs-base: 15px; --fs-lg: 16px; --fs-xl: 20px;
  --fs-2xl:  24px; --fs-3xl: 32px;

  /* Transitions */
  --ease:      0.2s ease;
  --ease-slow: 0.35s cubic-bezier(0.22, 1, 0.36, 1);

  /* Z-index */
  --z-sidebar:  1000;
  --z-overlay:  99998;
  --z-menu:     99999;
  --z-toast:    100000;
  --z-loader:   100001;
}

/* ── Global Body ───────────────────────────────────────────── */

body {
  font-family: Inter, "SF Pro Display", system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left,  rgba(56,189,248,0.20), transparent 28%),
    radial-gradient(circle at bottom right, rgba(34,197,94,0.12), transparent 28%),
    linear-gradient(180deg, #07111f 0%, #020617 100%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.menu-open { overflow: hidden; }

/* ── Typography ────────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
  color: var(--text);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

h1 { font-size: clamp(28px, 4vw, 48px); line-height: 1.02; }
h2 { font-size: clamp(22px, 3vw, 32px); }
h3 { font-size: 20px; }
h4 { font-size: 16px; }

p  { color: inherit; line-height: 1.7; }
small { color: var(--muted); font-size: 13px; }
strong { font-weight: 900; }

::selection {
  background: rgba(56, 189, 248, 0.30);
  color: #fff;
}

/* ── Focus ─────────────────────────────────────────────────── */

:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.55);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}

/* ── Scrollbar ─────────────────────────────────────────────── */

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(56,189,248,0.4) rgba(15,23,42,0.55);
}
*::-webkit-scrollbar            { width: 8px; height: 8px; }
*::-webkit-scrollbar-track      { background: rgba(15,23,42,0.55); }
*::-webkit-scrollbar-thumb      { background: rgba(56,189,248,0.35); border-radius: 99px; border: 2px solid rgba(15,23,42,0.55); }
*::-webkit-scrollbar-thumb:hover { background: rgba(56,189,248,0.55); }

/* ── Eyebrow / Badge ───────────────────────────────────────── */

.eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: var(--fs-xs);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Semantic text colours ─────────────────────────────────── */

.text-muted    { color: var(--muted) !important; }
.text-soft     { color: var(--text-soft) !important; }
.text-success  { color: #86efac !important; }
.text-warning  { color: #fcd34d !important; }
.text-danger   { color: #fca5a5 !important; }
.text-primary  { color: var(--primary) !important; }

.small-text, .section-subtitle, .chart-subtitle {
  color: var(--muted);
  line-height: 1.5;
}
.small-text       { font-size: var(--fs-md); }
.section-subtitle { margin-top: 4px; }
.chart-subtitle   { margin-top: -10px; margin-bottom: 16px; font-size: 13px; }

/* ── Surface helpers ───────────────────────────────────────── */

.glass-surface {
  background: var(--surface-glass);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* ── Utility classes ───────────────────────────────────────── */

.hidden      { display: none !important; }
.invisible   { visibility: hidden !important; }
.full-width  { width: 100% !important; }
.no-wrap     { white-space: nowrap; }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.center-content { display: grid; place-items: center; }
.flex-between   { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4); }
.flex-start     { display: flex; justify-content: flex-start; align-items: center; gap: var(--sp-4); }
.flex-col       { display: flex; flex-direction: column; }

.gap-sm  { gap: var(--sp-3); }
.gap-md  { gap: var(--sp-5); }
.gap-lg  { gap: var(--sp-8); }

.mt-sm { margin-top: var(--sp-3); }
.mt-md { margin-top: var(--sp-5); }
.mt-lg { margin-top: var(--sp-8); }
.mb-sm { margin-bottom: var(--sp-3); }
.mb-md { margin-bottom: var(--sp-5); }
.mb-lg { margin-bottom: var(--sp-8); }

/* ── Empty state ───────────────────────────────────────────── */

.empty-state {
  padding: 32px 24px;
  border-radius: var(--r-lg);
  background: rgba(2,6,23,0.42);
  border: 1px dashed rgba(148,163,184,0.26);
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  color: #fff;
  font-size: 16px;
}

/* ── Canvas / media defaults ───────────────────────────────── */

canvas { display: block; max-width: 100%; }

/* ── Responsive token overrides ────────────────────────────── */

@media (max-width: 1200px) { :root { --page-pad: 24px; } }
@media (max-width: 700px)  { :root { --page-pad: 18px; } h1 { font-size: 28px; } }
@media (max-width: 480px)  { :root { --page-pad: 14px; } }

/* ── Reduced motion ────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
