/* Tellyport design system — shared tokens and components for the console, website, docs, and demo.
   Light is the default; [data-theme="dark"] on <html> switches every surface. */

:root {
  color-scheme: light;
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --bg: #f7f8fa;
  --bg-subtle: #f2f4f7;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-sunken: #f9fafb;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #0f172a;
  --text-secondary: #475467;
  --text-tertiary: #667085;
  --text-inverse: #ffffff;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-border: #c7d2fe;
  --accent-text: #3730a3;
  --focus-ring: 0 0 0 3px rgba(79, 70, 229, 0.22);

  --success: #067647;
  --success-soft: #ecfdf3;
  --success-border: #abefc6;
  --warning: #b54708;
  --warning-soft: #fffaeb;
  --warning-border: #fedf89;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --danger-border: #fecdca;
  --info: #175cd3;
  --info-soft: #eff8ff;
  --info-border: #b2ddff;

  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 16px -4px rgba(16, 24, 40, 0.08), 0 4px 6px -2px rgba(16, 24, 40, 0.03);
  --shadow-xl: 0 24px 48px -12px rgba(16, 24, 40, 0.18);

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 15px;
  --text-lg: 18px;
  --text-xl: 22px;
  --text-2xl: 28px;
  --text-3xl: 36px;
  --text-4xl: 48px;

  --duration: 150ms;
  --duration-slow: 280ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* Data visualization (validated categorical order; status colors stay reserved) */
  --chart-1: #4f46e5;
  --chart-2: #eb6834;
  --chart-3: #1baf7a;
  --chart-4: #eda100;
  --chart-5: #e87ba4;
  --chart-other: #98a2b3;
  --chart-error: #d03b3b;
  --chart-grid: #eef0f3;
  --chart-axis: #98a2b3;
  --chart-crosshair: #c4c9d4;
  --map-land: #e3e6ec;
  --map-land-strong: #cfd4dd;
  --map-dot: #4f46e5;
  --map-ring: rgba(79, 70, 229, 0.18);
  --skeleton: #eef0f4;
  --skeleton-shine: #f7f8fa;
  --overlay: rgba(15, 23, 42, 0.45);
  --hover: rgba(15, 23, 42, 0.04);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0b0f;
  --bg-subtle: #15171e;
  --surface: #101218;
  --surface-raised: #161922;
  --surface-sunken: #0c0e13;
  --border: #22252f;
  --border-strong: #2e3240;
  --text: #ecedf2;
  --text-secondary: #a9aebd;
  --text-tertiary: #8a90a2;
  --text-inverse: #ffffff;

  --accent: #6366f1;
  --accent-hover: #7c83f2;
  --accent-soft: rgba(99, 102, 241, 0.15);
  --accent-border: rgba(129, 140, 248, 0.38);
  --accent-text: #b4bcff;
  --focus-ring: 0 0 0 3px rgba(129, 140, 248, 0.38);

  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.1);
  --success-border: rgba(74, 222, 128, 0.28);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.1);
  --warning-border: rgba(251, 191, 36, 0.28);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.1);
  --danger-border: rgba(248, 113, 113, 0.3);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, 0.1);
  --info-border: rgba(96, 165, 250, 0.28);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 32px rgba(0, 0, 0, 0.55);
  --shadow-xl: 0 24px 64px rgba(0, 0, 0, 0.65);

  --chart-1: #7c83f2;
  --chart-2: #d95926;
  --chart-3: #199e70;
  --chart-4: #c98500;
  --chart-5: #d55181;
  --chart-other: #5d6475;
  --chart-error: #e66767;
  --chart-grid: #1c1f28;
  --chart-axis: #6b7184;
  --chart-crosshair: #3a3f4f;
  --map-land: #1f232d;
  --map-land-strong: #2a2f3c;
  --map-dot: #818cf8;
  --map-ring: rgba(129, 140, 248, 0.22);
  --skeleton: #181b23;
  --skeleton-shine: #20242e;
  --overlay: rgba(0, 0, 0, 0.6);
  --hover: rgba(255, 255, 255, 0.04);
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
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;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { color: var(--text); font-weight: 600; letter-spacing: -0.01em; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
code, pre, kbd { font-family: var(--font-mono); font-size: 0.92em; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid transparent; outline-offset: 2px; box-shadow: var(--focus-ring); }
::selection { background: var(--accent-soft); color: var(--accent-text); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Typography helpers */
.eyebrow { font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.mono { font-family: var(--font-mono); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: 36px; padding: 0 var(--space-4);
  border: 1px solid transparent; border-radius: var(--radius);
  font-size: var(--text-base); font-weight: 500; line-height: 1; white-space: nowrap;
  cursor: pointer; text-decoration: none;
  transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease), color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { color: var(--text-inverse); background: var(--accent); box-shadow: var(--shadow-xs); }
.btn-primary:hover:not(:disabled) { color: var(--text-inverse); background: var(--accent-hover); }
.btn-secondary { color: var(--text); background: var(--surface); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover:not(:disabled) { color: var(--text); background: var(--bg-subtle); }
.btn-ghost { color: var(--text-secondary); background: transparent; }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--bg-subtle); }
.btn-danger { color: var(--danger); background: var(--surface); border-color: var(--danger-border); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-sm { height: 30px; padding: 0 var(--space-3); font-size: var(--text-sm); border-radius: var(--radius-sm); }
.btn-lg { height: 44px; padding: 0 var(--space-5); font-size: var(--text-md); }
.btn-block { width: 100%; }

/* Form controls */
.field { display: grid; gap: 6px; font-size: var(--text-sm); font-weight: 500; color: var(--text); }
.field small, .field .hint { font-weight: 400; color: var(--text-tertiary); }
.input, .select, .textarea {
  width: 100%; min-height: 38px; padding: 8px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  font-size: var(--text-base); color: var(--text); background: var(--surface); box-shadow: var(--shadow-xs);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-tertiary); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: var(--focus-ring); outline: none; }
.textarea { min-height: 96px; resize: vertical; }

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.card-body { padding: var(--space-6); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-5) var(--space-6); border-bottom: 1px solid var(--border); }
.divider { height: 1px; background: var(--border); border: 0; margin: var(--space-6) 0; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: 500; color: var(--text-secondary); background: var(--bg-subtle); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge-plain::before { display: none; }
.badge-success { color: var(--success); background: var(--success-soft); border-color: var(--success-border); }
.badge-warning { color: var(--warning); background: var(--warning-soft); border-color: var(--warning-border); }
.badge-danger { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); }
.badge-info { color: var(--info); background: var(--info-soft); border-color: var(--info-border); }
.badge-accent { color: var(--accent-text); background: var(--accent-soft); border-color: var(--accent-border); }

/* Callouts */
.callout { display: flex; gap: var(--space-3); padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-sunken); font-size: var(--text-sm); color: var(--text-secondary); }
.callout b, .callout strong { color: var(--text); font-weight: 600; }
.callout-info { background: var(--info-soft); border-color: var(--info-border); }
.callout-warning { background: var(--warning-soft); border-color: var(--warning-border); }
.callout-danger { background: var(--danger-soft); border-color: var(--danger-border); }
.callout-success { background: var(--success-soft); border-color: var(--success-border); }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th { padding: 10px var(--space-4); text-align: left; font-size: var(--text-xs); font-weight: 500; color: var(--text-tertiary); background: var(--surface-sunken); border-bottom: 1px solid var(--border); }
.table td { padding: 12px var(--space-4); border-bottom: 1px solid var(--border); color: var(--text-secondary); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }

/* Tabs */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab { position: relative; padding: 10px var(--space-3); border: 0; background: none; font-size: var(--text-sm); font-weight: 500; color: var(--text-tertiary); cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"], .tab.active { color: var(--accent); }
.tab[aria-selected="true"]::after, .tab.active::after { content: ""; position: absolute; left: var(--space-2); right: var(--space-2); bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }

/* Code */
.code-block { margin: 0; padding: var(--space-4); overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-sunken); font: 12.5px/1.65 var(--font-mono); color: var(--text); }
:root[data-theme="dark"] .code-block { background: #0a0c10; }
.kbd { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: var(--radius-xs); font-size: 11px; color: var(--text-secondary); background: var(--surface); }

/* Brand mark */
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: var(--text-md); color: var(--text); letter-spacing: -0.01em; }
.logo-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #6366f1, #4338ca); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), var(--shadow-xs); }
.logo-mark svg { width: 16px; height: 16px; }
.logo-mark img { width: 18px; height: 18px; }
/* Full wordmark: swap the light/dark artwork with the theme. */
.brand-wordmark { display: inline-flex; align-items: center; }
.brand-wordmark img { height: 26px; width: auto; }
.brand-wordmark .on-dark { display: none; }
:root[data-theme="dark"] .brand-wordmark .on-light { display: none; }
:root[data-theme="dark"] .brand-wordmark .on-dark { display: block; }

/* Skeleton loader */
.skeleton { position: relative; overflow: hidden; border-radius: var(--radius-sm); background: var(--skeleton); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, var(--skeleton-shine), transparent); animation: skeleton-shine 1.4s ease-in-out infinite; }
@keyframes skeleton-shine { to { transform: translateX(100%); } }

@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; }
}
