/* =====================================================================
   GeoSprig — Base / global layer (resets, typography, primitives)
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4 { margin: 0 0 var(--sp-3); font-weight: var(--weight-bold); letter-spacing: -0.02em; line-height: 1.2; }
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
p { margin: 0 0 var(--sp-4); }
small { font-size: var(--text-xs); }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
code, kbd, pre {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 0.125rem 0.375rem;
}
abbr[title] { text-decoration: underline dotted; cursor: help; }

/* ---------- Focus (WCAG 2.2: visible focus ring on everything interactive) */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible, .btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary-focus-ring);
  border-radius: var(--radius-sm);
}

/* ---------- Skip-to-content ---------- */
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 9999;
  background: var(--primary); color: #fff; padding: var(--sp-2) var(--sp-4);
  border-radius: 0 0 var(--radius) 0; font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
}
.skip-link:focus { left: 0; }

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

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  font-family: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium);
  line-height: 1.25rem; padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius); border: 1px solid transparent; cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease),
              border-color var(--duration-fast) var(--ease),
              color var(--duration-fast) var(--ease),
              transform var(--duration-micro) var(--ease),
              box-shadow var(--duration-small, 150ms) var(--ease);
  user-select: none; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary {
  background: var(--surface); color: var(--text-secondary);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-alt); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-alt); color: var(--text); }
.btn-sm { padding: var(--sp-1) var(--sp-3); font-size: var(--text-xs); }
.btn-lg { padding: var(--sp-3) var(--sp-6); font-size: var(--text-base); }
.btn-block { width: 100%; }

.btn .spinner { margin-right: var(--sp-1); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  background: var(--surface-alt); color: var(--text);
  border-radius: var(--radius-full); padding: calc(var(--sp-1) / 2) var(--sp-2);
  font-size: var(--text-xs); font-weight: var(--weight-medium); line-height: 1.25rem;
}
.badge-success { background: var(--success-light); color: var(--success-dark); }
.badge-warning { background: var(--warning-light); color: var(--warning-dark); }
.badge-danger { background: var(--danger-light); color: var(--danger-dark); }
.badge-info { background: var(--info-light); color: var(--info-dark); }
.badge-neutral { background: var(--surface-alt); color: var(--text-secondary); }

/* CRM flavours */
.badge-crm-new       { background: var(--crm-new-light); color: var(--primary-hover); }
.badge-crm-contacted { background: var(--crm-contacted-light); color: var(--crm-contacted); }
.badge-crm-interested{ background: var(--crm-interested-light); color: #065F46; }
.badge-crm-closed    { background: var(--crm-closed-light); color: var(--crm-closed); }
.badge-crm-rejected  { background: var(--crm-rejected-light); color: var(--crm-rejected); }
.badge-crm-followup  { background: var(--crm-followup-light); color: var(--crm-followup); }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.field label { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text); }
.field .hint { font-size: var(--text-xs); color: var(--text-muted); }

.input, .select, .textarea {
  width: 100%;
  font-family: inherit; font-size: var(--text-sm); color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: var(--sp-2) var(--sp-3);
  transition: border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary-focus-ring);
}
.input-error { border-color: var(--danger); }
.input-error:focus { border-color: var(--danger); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px rgba(239, 68, 68, 0.25); }
.textarea { min-height: 96px; resize: vertical; }
.input[disabled] { background: var(--surface-alt); color: var(--text-muted); cursor: not-allowed; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table thead th {
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  text-transform: uppercase; letter-spacing: 0.05em;
  text-align: left; padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.table tbody td {
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-sm); color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr { transition: background-color var(--duration-micro) var(--ease); }
.table tbody tr:hover { background: var(--surface-alt); }
.table tbody tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

/* ---------- Alerts / flash ---------- */
.alert {
  border-radius: var(--radius); padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-sm); margin-bottom: var(--sp-4);
  display: flex; align-items: flex-start; gap: var(--sp-2);
}
.alert-success { background: var(--success-light); color: var(--success-dark); border: 1px solid var(--success); }
.alert-error { background: var(--danger-light); color: var(--danger-dark); border: 1px solid var(--danger); }
.alert-info { background: var(--info-light); color: var(--info-dark); border: 1px solid var(--info); }
.alert-warning { background: var(--warning-light); color: var(--warning-dark); border: 1px solid var(--warning); }

/* ---------- KPI cards ---------- */
.kpi { display: flex; flex-direction: column; gap: var(--sp-1); }
.kpi .kpi-value { font-size: var(--text-2xl); font-weight: var(--weight-bold); letter-spacing: -0.02em; }
.kpi .kpi-label { font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }

/* ---------- Skeleton loading ---------- */
@keyframes skeleton-shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: var(--surface-alt) linear-gradient(90deg, var(--surface-alt) 25%, rgba(156,163,175,0.25) 37%, var(--surface-alt) 63%);
  background-size: 400px 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

/* ---------- Motion helpers ---------- */
/* Default state: visible. GSAP will animate in if available. */
[data-reveal] { opacity: 1; transform: none; }
[data-reveal].is-revealed { opacity: 1; transform: translateY(0); transition: opacity var(--duration-reveal) var(--ease), transform var(--duration-reveal) var(--ease); }

/* Ensure reduced motion also keeps content visible */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  [data-reveal] { opacity: 1 !important; transform: none !important; }
}

/* Utility gap classes */
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }

/* Material symbol sizes are set inline via font-variation-settings). */
.icon { width: 1.25rem; height: 1.25rem; display: inline-block; flex: none; }