/* ==========================================================================
   PicklePulse Design System — base.css
   Tokens, typography, and shared components used by landing + app.
   Principles: one accent colour, 4px spacing grid, modular type scale,
   neutral surfaces, colour only for meaning (status), consistent radii.
   ========================================================================== */

:root {
  /* Typography */
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --text-xs: 0.75rem;    /* 12 */
  --text-sm: 0.875rem;   /* 14 */
  --text-base: 1rem;     /* 16 */
  --text-lg: 1.125rem;   /* 18 */
  --text-xl: 1.25rem;    /* 20 */
  --text-2xl: 1.5rem;    /* 24 */
  --text-3xl: 2rem;      /* 32 */
  --text-4xl: 2.5rem;    /* 40 */
  --text-5xl: 3.5rem;    /* 56 */

  /* Neutrals */
  --ink-900: #0b1220;
  --ink-800: #1e293b;
  --ink-700: #334155;
  --ink-600: #475569;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;

  /* Brand (single accent) */
  --brand-50: #f0fdf4;
  --brand-100: #dcfce7;
  --brand-200: #bbf7d0;
  --brand-500: #22c55e;
  --brand-600: #16a34a;
  --brand-700: #15803d;
  --brand-800: #166534;
  --brand-900: #14532d;
  --highlight: #d9f99d; /* pickleball-ball lime, used sparingly */

  /* Semantic status colours */
  --info-50: #eff6ff;   --info-600: #2563eb;  --info-700: #1d4ed8;
  --warn-50: #fffbeb;   --warn-600: #d97706;  --warn-700: #b45309;
  --danger-50: #fff1f2; --danger-600: #e11d48; --danger-700: #be123c;
  --violet-50: #f5f3ff; --violet-600: #7c3aed; --violet-700: #6d28d9;

  /* Spacing (4px grid) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px;
  --s-20: 80px; --s-24: 96px;

  /* Radii & elevation */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 999px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 20px 40px -12px rgba(15, 23, 42, 0.18);
  --ring: 0 0 0 3px rgba(22, 163, 74, 0.25);

  --container: 1200px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--ink-700);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

/* Typography */
h1, h2, h3, h4 { color: var(--ink-900); line-height: 1.2; letter-spacing: -0.02em; font-weight: 700; }
h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-lg); letter-spacing: -0.01em; font-weight: 600; }
h4 { font-size: var(--text-base); letter-spacing: -0.01em; font-weight: 600; }
p { max-width: 68ch; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-muted { color: var(--ink-500); }
.text-strong { color: var(--ink-900); font-weight: 600; }
.tabular { font-variant-numeric: tabular-nums; }
.eyebrow {
  display: inline-block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--brand-700);
  margin-bottom: var(--s-3);
}

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--s-6); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Icons (Lucide) */
.icon { width: 18px; height: 18px; stroke-width: 2; flex-shrink: 0; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 22px; height: 22px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: 40px;
  padding: 0 var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand-600); color: #fff; box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: var(--brand-700); }
.btn-dark { background: var(--ink-900); color: #fff; }
.btn-dark:hover { background: var(--ink-800); }
.btn-secondary { background: var(--surface); color: var(--ink-800); border-color: var(--line-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--ink-400); }
.btn-ghost { background: transparent; color: var(--ink-700); }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink-900); }
.btn-danger-ghost { background: transparent; color: var(--danger-700); }
.btn-danger-ghost:hover { background: var(--danger-50); }
.btn-sm { height: 32px; padding: 0 var(--s-3); font-size: var(--text-xs); border-radius: var(--r-sm); }
.btn-lg { height: 48px; padding: 0 var(--s-6); font-size: var(--text-base); }
.btn-block { width: 100%; }
.btn-icon { width: 36px; height: 36px; padding: 0; }

/* Badges — muted, used only for status */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  height: 22px;
  padding: 0 var(--s-2);
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--ink-600);
}
.badge-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--brand-50); color: var(--brand-800); }
.badge-info { background: var(--info-50); color: var(--info-700); }
.badge-warn { background: var(--warn-50); color: var(--warn-700); }
.badge-danger { background: var(--danger-50); color: var(--danger-700); }
.badge-violet { background: var(--violet-50); color: var(--violet-700); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.card-pad { padding: var(--s-6); }

/* Forms */
.field { display: flex; flex-direction: column; gap: var(--s-2); }
.field + .field { margin-top: var(--s-4); }
.label { font-size: var(--text-sm); font-weight: 500; color: var(--ink-800); }
.hint { font-size: var(--text-xs); color: var(--ink-500); }
.input, .select {
  height: 40px;
  width: 100%;
  padding: 0 var(--s-3);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  color: var(--ink-900);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.input::placeholder { color: var(--ink-400); }
.input:focus, .select:focus { outline: none; border-color: var(--brand-600); box-shadow: var(--ring); }
.select {
  appearance: none;
  padding-right: var(--s-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2364748b' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--s-4); }
.field-row + .field, .field + .field-row, .field-row + .field-row { margin-top: var(--s-4); }

/* Radio choice cards */
.choice-group { display: flex; flex-direction: column; gap: var(--s-2); }
.choice {
  display: flex;
  gap: var(--s-3);
  align-items: flex-start;
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.choice:hover { border-color: var(--ink-400); }
.choice input { margin-top: 3px; accent-color: var(--brand-600); }
.choice:has(input:checked) { border-color: var(--brand-600); background: var(--brand-50); }
.choice-title { font-size: var(--text-sm); font-weight: 600; color: var(--ink-900); }
.choice-desc { font-size: var(--text-xs); color: var(--ink-500); }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--ink-500);
  padding: var(--s-3) var(--s-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}
.modal.open { display: flex; animation: fade 0.15s var(--ease); }
.modal-panel {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  animation: rise 0.2s var(--ease);
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-4); padding: var(--s-6) var(--s-6) 0; }
.modal-body { padding: var(--s-5) var(--s-6); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--s-3); padding: var(--s-4) var(--s-6); border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl); }

/* Summary list (key/value) */
.kv { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-4); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); font-size: var(--text-sm); }
.kv-row { display: flex; justify-content: space-between; gap: var(--s-4); }
.kv-row dt { color: var(--ink-500); }
.kv-row dd { color: var(--ink-900); font-weight: 500; text-align: right; }
.kv-row.total { padding-top: var(--s-2); border-top: 1px dashed var(--line-strong); }
.kv-row.total dd { font-weight: 700; }

/* Toast */
.toast-region { position: fixed; bottom: var(--s-6); right: var(--s-6); z-index: 300; display: flex; flex-direction: column; gap: var(--s-2); }
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  max-width: 380px;
  padding: var(--s-3) var(--s-4);
  background: var(--ink-900);
  color: #fff;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  animation: rise 0.2s var(--ease);
}
.toast .icon { color: var(--brand-500); margin-top: 2px; }

/* Progress */
.progress { height: 6px; background: var(--surface-3); border-radius: var(--r-full); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand-600); border-radius: inherit; }
.progress.is-near > span { background: var(--warn-600); }

/* Brand Logo & Shared Nav Primitives */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--ink-900);
  font-size: 1.0625rem;
  letter-spacing: -0.025em;
}
.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--ink-900) 0%, #1e293b 100%);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  position: relative;
}
.logo-mark::before {
  content: '';
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ecfccb 0%, #bef264 55%, #84cc16 100%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.logo-mark::after {
  content: '';
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ink-900);
  top: 12px;
  left: 13px;
  box-shadow: 5px 1px 0 var(--ink-900), 2px 5px 0 var(--ink-900);
  opacity: 0.7;
}

/* Compact Currency Pill Selector */
.currency-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--ink-700);
  transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.currency-pill:hover {
  border-color: var(--line-strong);
  background: var(--surface-3);
}
.currency-pill select {
  border: none;
  background: transparent;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--ink-900);
  cursor: pointer;
  padding-right: 2px;
  outline: none;
}

/* Nav Divider */
.nav-divider {
  width: 1px;
  height: 20px;
  background: var(--line);
  flex-shrink: 0;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
