/* ============================================================
   TCG Value — Design System
   Canonical brand tokens, typography, and component primitives.
   All pages import this first; page-specific sheets extend it.
   ============================================================ */

/* === FONT IMPORT =========================================== */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

/* === COLOR PALETTE ========================================== */
:root {
  /* Backgrounds */
  --bg:         #070b12;  /* page base — deepest dark */
  --bg-2:       #0c1220;  /* section alt bg */
  --bg-3:       #111929;  /* card surface alt */

  /* Surfaces */
  --surface:    #111827;  /* card / panel surface */
  --surface-2:  #1a2436;  /* input bg, nested surface */
  --surface-3:  #1e2d45;  /* hover surface, elevated */

  /* Borders */
  --border:     #1e2d45;  /* default border */
  --border-2:   #253447;  /* hover / focus border */
  --border-3:   #2e3d56;  /* emphasis border */

  /* Text */
  --text:       #f0f4ff;  /* primary text */
  --text-2:     #8ca0c8;  /* secondary / body text */
  --text-3:     #4d6382;  /* muted / placeholder */

  /* Brand — Primary (hot orange) */
  --primary:           #ff6b2c;
  --primary-h:         #e85a1a;  /* hover */
  --primary-d:         #cc4a08;  /* active/pressed */
  --primary-dim:       rgba(255, 107, 44, 0.12);
  --primary-dim2:      rgba(255, 107, 44, 0.06);
  --primary-glow:      rgba(255, 107, 44, 0.25);

  /* Brand — Secondary (indigo) */
  --secondary:         #6366f1;
  --secondary-h:       #4f46e5;
  --secondary-d:       #4338ca;
  --secondary-dim:     rgba(99, 102, 241, 0.15);
  --secondary-dim2:    rgba(99, 102, 241, 0.08);

  /* Semantic */
  --success:     #3dd68c;
  --success-dim: rgba(61, 214, 140, 0.15);
  --danger:      #ef4444;
  --danger-dim:  rgba(239, 68, 68, 0.15);
  --warn:        #eab308;
  --warn-dim:    rgba(234, 179, 8, 0.15);
  --info:        #60a5fa;
  --info-dim:    rgba(96, 165, 250, 0.15);
}

/* === TYPOGRAPHY ============================================ */
:root {
  --font-display: 'Syne', sans-serif;  /* headings — personality, edge */
  --font-body:    'DM Sans', sans-serif; /* body — clean, readable */
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

  /* Font-size scale */
  --text-xs:   0.6875rem;   /* 11px — labels, badges */
  --text-sm:   0.8125rem;   /* 13px — meta, secondary */
  --text-base: 0.9375rem;   /* 15px — body copy */
  --text-md:   1rem;        /* 16px — default */
  --text-lg:   1.125rem;    /* 18px — subheadings */
  --text-xl:   1.25rem;     /* 20px — card titles */
  --text-2xl:  1.5rem;      /* 24px — page headings */
  --text-3xl:  1.875rem;    /* 30px — section titles */
  --text-4xl:  2.25rem;     /* 36px — hero headlines */
  --text-5xl:  3rem;        /* 48px — display */
  --text-6xl:  4.5rem;       /* 72px — hero display */

  /* Line heights */
  --leading-none:   1;
  --leading-tight:  1.1;
  --leading-snug:   1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.7;
  --leading-loose:  1.9;

  /* Letter spacing */
  --tracking-tight:  -0.03em;
  --tracking-snug:   -0.02em;
  --tracking-normal: 0;
  --tracking-wide:   0.04em;
  --tracking-wider:  0.08em;
  --tracking-widest: 0.14em;

  /* Font weights */
  --font-normal:    400;
  --font-medium:    500;
  --font-semibold:  600;
  --font-bold:      700;
  --font-extrabold: 800;
}

/* === SPACING SCALE (4px base) ============================== */
:root {
  --space-1:  0.25rem;   /* 4px  */
  --space-2:  0.5rem;    /* 8px  */
  --space-3:  0.75rem;   /* 12px */
  --space-4:  1rem;       /* 16px */
  --space-5:  1.25rem;   /* 20px */
  --space-6:  1.5rem;     /* 24px */
  --space-8:  2rem;       /* 32px */
  --space-10: 2.5rem;     /* 40px */
  --space-12: 3rem;       /* 48px */
  --space-16: 4rem;       /* 64px */
  --space-20: 5rem;       /* 80px */
  --space-24: 6rem;       /* 96px */
}

/* === BORDER RADIUS ========================================= */
:root {
  --radius-sm:  4px;
  --radius:     6px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;
}

/* === SHADOWS =============================================== */
:root {
  --shadow-xs:  0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm:  0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow:     0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg:  0 16px 48px rgba(0, 0, 0, 0.45);
  --shadow-xl:  0 24px 64px rgba(0, 0, 0, 0.55);
  --shadow-primary: 0 8px 24px rgba(255, 107, 44, 0.3);
  --shadow-secondary: 0 8px 24px rgba(99, 102, 241, 0.3);
}

/* === TRANSITIONS =========================================== */
:root {
  --ease:       0.15s ease;
  --ease-md:    0.2s ease;
  --ease-slow:  0.3s ease;
  --ease-spring: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out:   0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* === BASE RESET ============================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
ul { list-style: none; }
button, input, select, textarea { font-family: inherit; }

/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-3); }

/* Text selection */
::selection { background: var(--primary-dim); color: var(--text); }

/* Focus ring */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* === LAYOUT PRIMITIVES ===================================== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* === BUTTONS =============================================== */

/* .btn — base class, do not use alone */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-weight: var(--font-semibold);
  border: none;
  cursor: pointer;
  transition: background var(--ease), color var(--ease),
              border-color var(--ease), box-shadow var(--ease),
              transform var(--ease);
  white-space: nowrap;
  line-height: 1;
}
.btn:active { transform: scale(0.98); }

/* .btn-primary — orange CTA */
.btn-primary {
  background: var(--primary);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.btn-primary:hover { background: var(--primary-h); box-shadow: var(--shadow-primary); }
.btn-primary:active { background: var(--primary-d); box-shadow: none; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* .btn-secondary — ghost-ish with border */
.btn-secondary {
  background: transparent;
  color: var(--text);
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--border-3); color: var(--text); }
.btn-secondary:active { background: var(--surface-2); }

/* .btn-ghost — no border, subtle bg on hover */
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  border: none;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

/* .btn-indigo — secondary / nav CTAs */
.btn-indigo {
  background: var(--secondary);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.btn-indigo:hover { background: var(--secondary-h); box-shadow: var(--shadow-secondary); }

/* .btn-danger — destructive actions */
.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }

/* Size variants */
.btn-sm  { padding: 7px 14px;  font-size: var(--text-xs); }
.btn-lg  { padding: 13px 28px; font-size: var(--text-base); border-radius: var(--radius-lg); }
.btn-xl  { padding: 15px 36px; font-size: var(--text-lg);   border-radius: var(--radius-lg); }

/* === FORMS ================================================= */

/* Text input */
.input, input[type="text"], input[type="email"], input[type="number"], input[type="search"] {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 11px 14px;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-family: var(--font-body);
  width: 100%;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.input:focus, input[type="text"]:focus, input[type="email"]:focus,
input[type="number"]:focus, input[type="search"]:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px var(--secondary-dim);
}
.input::placeholder, input::placeholder { color: var(--text-3); }
.input:disabled { opacity: 0.5; cursor: not-allowed; }

/* Textarea */
textarea, .textarea {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 11px 14px;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-family: var(--font-body);
  width: 100%;
  resize: vertical;
  min-height: 80px;
  line-height: var(--leading-relaxed);
  transition: border-color var(--ease), box-shadow var(--ease);
}
textarea:focus, .textarea:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px var(--secondary-dim);
}

/* Select */
select, .select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 11px 36px 11px 14px;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-family: var(--font-body);
  width: 100%;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238ca0c8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color var(--ease);
}
select:focus, .select:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px var(--secondary-dim);
}

/* Toggle (checkbox / radio) */
input[type="checkbox"], input[type="radio"] {
  accent-color: var(--secondary);
  cursor: pointer;
  width: 18px; height: 18px; flex-shrink: 0;
}

/* Range */
input[type="range"] {
  accent-color: var(--primary);
  width: 100%;
}

/* Form field */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-2);
}
.field label .req { color: var(--danger); margin-left: 2px; }
.field-hint { font-size: var(--text-xs); color: var(--text-3); }
.field-error { font-size: var(--text-xs); color: var(--danger); }

/* Input with prefix/suffix */
.input-wrap { position: relative; display: flex; }
.input-wrap .input { padding-left: 40px; }
.input-prefix {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-size: var(--text-base);
  pointer-events: none;
}

/* === CARD ================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: border-color var(--ease-md), box-shadow var(--ease-md), transform var(--ease-md);
  position: relative;
  overflow: hidden;
}
/* Colored top stripe — use card--accent, card--indigo, etc. */
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--border);
  transition: background var(--ease-md);
}
.card--accent::before  { background: var(--primary); }
.card--indigo::before  { background: var(--secondary); }
.card--success::before { background: var(--success); }
.card--warn::before    { background: var(--warn); }
.card--danger::before  { background: var(--danger); }

.card:hover {
  border-color: var(--border-2);
  box-shadow: var(--shadow);
}
.card--interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* === BADGE / CHIP ========================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  line-height: 1.4;
}
.badge--primary   { background: var(--primary-dim);   color: var(--primary); border: 1px solid rgba(255,107,44,0.2); }
.badge--secondary { background: var(--secondary-dim); color: #818cf8; border: 1px solid rgba(99,102,241,0.2); }
.badge--success   { background: var(--success-dim);   color: var(--success); }
.badge--danger    { background: var(--danger-dim);    color: var(--danger); }
.badge--warn      { background: var(--warn-dim);      color: var(--warn); }
.badge--neutral   { background: var(--surface-2);     color: var(--text-2); }

/* Status dot */
.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.status-dot--pulse { animation: pulse 2.4s infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* === DIVIDER =============================================== */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-6) 0;
}
.divider--glow {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

/* === SECTION EYEBROW ====================================== */
.eyebrow {
  font-size: 0.6875rem;
  font-weight: var(--font-bold);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--primary);
}

/* === TABLE ================================================= */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--text-3);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.data-table td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
  color: var(--text);
  vertical-align: middle;
}
.data-table tbody tr { transition: background var(--ease); }
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* === TOAST ================================================= */
.toast {
  position: fixed;
  bottom: var(--space-8);
  right: var(--space-8);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  animation: toast-in 0.25s ease-out;
  max-width: 360px;
}
.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast.success { border-color: rgba(61,214,140,0.3); }
.toast.error   { border-color: rgba(239,68,68,0.3); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* === EMPTY STATE =========================================== */
.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-6);
  color: var(--text-3);
}
.empty-state-icon { font-size: 48px; margin-bottom: var(--space-4); opacity: 0.4; }
.empty-state h3 { font-size: var(--text-xl); font-weight: var(--font-bold); color: var(--text); margin-bottom: var(--space-2); }
.empty-state p { font-size: var(--text-base); max-width: 360px; margin: 0 auto; line-height: var(--leading-relaxed); }

/* === SKELETON LOADER ======================================= */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: var(--radius-md);
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* === RESPONSIVE ============================================ */
@media (max-width: 900px) {
  .container { padding: 0 var(--space-4); }
}
@media (max-width: 600px) {
  .container { padding: 0 var(--space-4); }
  .toast { bottom: var(--space-4); right: var(--space-4); left: var(--space-4); max-width: none; }
}