/* ==========================================================
   INSPI DESIGN SYSTEM v2
   Quiet surfaces, single accent, crisp typography,
   short interruptible motion, monospace numerics.
   Emil Kowalski design engineering principles applied.
   ========================================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  /* --- Neutrals (zinc, never pure black) --- */
  --bg:            #FAFAF9;
  --surface:       #FFFFFF;
  --surface-alt:   #F4F4F5;
  --surface-raised:#FFFFFF;
  --line:          rgba(24, 24, 27, 0.08);
  --line-strong:   rgba(24, 24, 27, 0.14);
  --ink:           #18181B;
  --ink-muted:     #52525B;
  --ink-soft:      #71717A;

  /* --- Single accent (desaturated indigo) --- */
  --accent:        #4F46E5;
  --accent-hover:  #4338CA;
  --accent-wash:   rgba(79, 70, 229, 0.08);
  --accent-line:   rgba(79, 70, 229, 0.18);

  /* --- Semantic (muted, never neon) --- */
  --ok:            #16A34A;
  --warn:          #CA8A04;
  --err:           #DC2626;

  /* --- Motion tokens (Emil: strong ease-out, never ease-in for UI) --- */
  --ease-out:      cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out:   cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer:   cubic-bezier(0.32, 0.72, 0, 1);
  --dur-fast:      120ms;
  --dur-base:      180ms;
  --dur-slow:      260ms;
  --dur-enter:     350ms;

  /* --- Shape --- */
  --r-xs:  6px;
  --r-sm:  10px;
  --r-md:  14px;
  --r-lg:  20px;
  --r-xl:  24px;
  --r-full:999px;

  /* --- Type scale --- */
  --t-xs:   12px;
  --t-sm:   14px;
  --t-base: 15px;
  --t-lg:   18px;
  --t-xl:   24px;
  --t-2xl:  32px;
  --t-3xl:  44px;

  /* --- Depth --- */
  --shadow-sm:   0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg:   0 12px 32px -8px rgba(0,0,0,0.08);
  --shadow-glow: 0 0 0 1px var(--accent-line), 0 4px 16px rgba(79, 70, 229, 0.1);
}

/* Dark mode disabled — all apps use white/light theme */

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Manrope', ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: var(--t-base);
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
}

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: 'Manrope', sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}
h1 { font-size: var(--t-3xl); line-height: 1.05; font-weight: 700; letter-spacing: -0.03em; }
h2 { font-size: var(--t-2xl); line-height: 1.15; }
h3 { font-size: var(--t-xl); line-height: 1.25; }
p  { color: var(--ink-muted); max-width: 65ch; }
small, .t-small { font-size: var(--t-sm); color: var(--ink-muted); }

/* Monospace numerics for dashboards */
.num, .metric, tbody td.n, [data-numeric] {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, monospace;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* --- Layout primitives --- */
.page    { max-width: 1200px; margin: 0 auto; padding: 48px 24px 64px; }
.page-sm { max-width: 760px;  margin: 0 auto; padding: 48px 24px 64px; }
.page-lg { max-width: 1400px; margin: 0 auto; padding: 48px 24px 64px; }
.stack   { display: flex; flex-direction: column; }
.stack > * + * { margin-top: var(--gap, 16px); }
.row     { display: flex; align-items: center; gap: var(--gap, 12px); }
.grid    { display: grid; gap: 16px; }
@media (min-width: 768px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}
/* Asymmetric grid for DESIGN_VARIANCE:8 */
@media (min-width: 768px) {
  .grid-asym { grid-template-columns: 2fr 1fr; }
  .grid-asym-r { grid-template-columns: 1fr 2fr; }
  .grid-70-30 { grid-template-columns: 7fr 3fr; }
  .grid-30-70 { grid-template-columns: 3fr 7fr; }
}

/* --- Divider-based grouping (cards used sparingly) --- */
.section { padding: 24px 0; border-top: 1px solid var(--line); }
.section:first-child { border-top: 0; padding-top: 0; }

/* --- Card (use only where elevation is meaningful) --- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 20px;
  transition: border-color var(--dur-base) var(--ease-out),
              transform  var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out);
}
.card--hover:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}
.card--pick {
  cursor: pointer;
}
.card--pick:active {
  transform: scale(0.98);
}
.card__label { font-size: var(--t-xs); color: var(--ink-soft); letter-spacing: 0.04em; text-transform: uppercase; }
.card__title { font-size: var(--t-lg); font-weight: 600; margin-top: 4px; }
.card__desc  { font-size: var(--t-sm); color: var(--ink-muted); margin-top: 8px; line-height: 1.5; }

/* --- Glass card (frosted surface with edge refraction) --- */
.glass {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
@media (prefers-color-scheme: dark) {
  .glass {
    background: rgba(17, 17, 19, 0.7);
    border-color: rgba(255, 255, 255, 0.06);
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  }
}

/* --- Button --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  font: inherit; font-weight: 500; font-size: var(--t-sm);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out),
              background var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out);
  user-select: none;
}
.btn:hover { background: var(--surface-alt); box-shadow: var(--shadow-sm); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn--primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.btn--primary:hover { background: var(--ink-muted); }

.btn--accent {
  background: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent);
}
.btn--accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-muted); }
.btn--ghost:hover { color: var(--ink); background: var(--surface-alt); }

.btn--lg { height: 48px; padding: 0 22px; font-size: var(--t-base); border-radius: var(--r-md); }
.btn--sm { height: 32px; padding: 0 12px; font-size: var(--t-xs); }
.btn--block { width: 100%; }

/* --- Input --- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: var(--t-sm); font-weight: 500; color: var(--ink); }
.field__hint  { font-size: var(--t-xs); color: var(--ink-soft); }
.field__error { font-size: var(--t-xs); color: var(--err); }
.input, .textarea, .select {
  width: 100%;
  padding: 10px 12px;
  font: inherit; font-size: var(--t-sm);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  transition: border-color var(--dur-base) var(--ease-out),
              box-shadow   var(--dur-base) var(--ease-out);
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
.textarea { min-height: 96px; resize: vertical; }

/* --- Badge / Tag --- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px;
  font-size: var(--t-xs); font-weight: 500;
  color: var(--ink-muted);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
}
.badge--accent { color: var(--accent); background: var(--accent-wash); border-color: var(--accent-line); }
.badge--ok     { color: var(--ok);     background: rgba(22, 163, 74, 0.08);  border-color: rgba(22, 163, 74, 0.18); }
.badge--warn   { color: var(--warn);   background: rgba(202, 138, 4, 0.08);  border-color: rgba(202, 138, 4, 0.18); }
.badge--err    { color: var(--err);    background: rgba(220, 38, 38, 0.08);  border-color: rgba(220, 38, 38, 0.18); }

/* --- Stat --- */
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat__label { font-size: var(--t-xs); color: var(--ink-soft); letter-spacing: 0.04em; text-transform: uppercase; }
.stat__value {
  font-family: 'IBM Plex Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-size: var(--t-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.stat__delta { font-size: var(--t-xs); color: var(--ink-muted); font-family: 'IBM Plex Mono', monospace; }
.stat__delta--up   { color: var(--ok); }
.stat__delta--down { color: var(--err); }

/* --- Status dot (breathing) --- */
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; position: relative; }
.dot::after {
  content: ''; position: absolute; inset: -3px; border-radius: 50%;
  border: 2px solid currentColor; opacity: 0.4;
  animation: pulse 2s var(--ease-out) infinite;
}
@keyframes pulse {
  0%   { transform: scale(0.9); opacity: 0.4; }
  70%  { transform: scale(1.4); opacity: 0;   }
  100% { transform: scale(1.4); opacity: 0;   }
}

/* --- Skeleton (shimmer with realistic sizing) --- */
.sk {
  background: linear-gradient(90deg, var(--surface-alt) 0%, var(--line) 50%, var(--surface-alt) 100%);
  background-size: 200% 100%;
  border-radius: var(--r-xs);
  animation: shimmer 1.4s linear infinite;
}
.sk--text { height: 14px; width: 60%; border-radius: 4px; }
.sk--title { height: 20px; width: 40%; border-radius: 4px; }
.sk--stat { height: 32px; width: 80px; border-radius: 6px; }
.sk--card { height: 120px; border-radius: var(--r-md); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* --- Entry stagger (add .enter to a parent; children cascade in) --- */
.enter > * {
  opacity: 0;
  transform: translateY(8px);
  animation: enterIn var(--dur-slow) var(--ease-out) forwards;
  animation-delay: calc(var(--i, 0) * 50ms);
}
@keyframes enterIn {
  to { opacity: 1; transform: translateY(0); }
}

/* --- Fade-up entry for individual elements --- */
.fade-up {
  opacity: 0;
  transform: translateY(12px);
  animation: fadeUp var(--dur-enter) var(--ease-out) forwards;
  animation-delay: var(--delay, 0ms);
}
@keyframes fadeUp {
  to { opacity: 1; transform: none; }
}

/* --- Scale-in entry (never from scale(0), always 0.95+) --- */
.scale-in {
  opacity: 0;
  transform: scale(0.96);
  animation: scaleIn var(--dur-slow) var(--ease-out) forwards;
  animation-delay: var(--delay, 0ms);
}
@keyframes scaleIn {
  to { opacity: 1; transform: scale(1); }
}

/* --- Slide-in from bottom (for toasts, drawers) --- */
.slide-up {
  transform: translateY(100%);
  animation: slideUp var(--dur-enter) var(--ease-drawer) forwards;
}
@keyframes slideUp {
  to { transform: translateY(0); }
}

/* --- Progress bar --- */
.progress {
  height: 4px;
  background: var(--surface-alt);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-full);
  transition: width var(--dur-enter) var(--ease-in-out);
}

/* --- Link --- */
a { color: var(--accent); text-decoration: none; transition: color var(--dur-base) var(--ease-out); }
a:hover { color: var(--accent-hover); }

/* --- Table (for dashboards) --- */
table.data {
  width: 100%; border-collapse: collapse; font-size: var(--t-sm);
}
table.data th, table.data td {
  padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line);
}
table.data th {
  font-weight: 500; color: var(--ink-soft); font-size: var(--t-xs);
  text-transform: uppercase; letter-spacing: 0.04em;
}
table.data tbody tr {
  transition: background var(--dur-fast) var(--ease-out);
}
table.data tbody tr:hover { background: var(--surface-alt); }
table.data td.n { text-align: right; }

/* --- Section header --- */
.eyebrow {
  font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-soft); font-weight: 500;
}

/* --- Divider --- */
.divider {
  height: 1px;
  background: var(--line);
  border: none;
  margin: 24px 0;
}

/* --- Avatar --- */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent-wash);
  color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: var(--t-xs);
  flex-shrink: 0;
}
.avatar--sm { width: 28px; height: 28px; font-size: 10px; }
.avatar--lg { width: 44px; height: 44px; font-size: var(--t-sm); }

/* --- Empty state --- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 24px; text-align: center; gap: 12px;
  color: var(--ink-soft);
}
.empty__icon { opacity: 0.3; }
.empty__title { font-weight: 600; color: var(--ink-muted); }
.empty__desc { font-size: var(--t-sm); max-width: 36ch; }

/* --- Utility --- */
.muted    { color: var(--ink-muted); }
.soft     { color: var(--ink-soft); }
.hidden   { display: none; }
.right    { text-align: right; }
.center   { text-align: center; }
.nowrap   { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only  { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

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

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  .enter > * { opacity: 1; transform: none; animation: none; }
  .fade-up, .scale-in { opacity: 1; transform: none; animation: none; }
  .slide-up { transform: none; animation: none; }
}

/* --- Touch devices: no hover states --- */
@media (hover: none) {
  .btn:hover, .card--hover:hover, a:hover { background: initial; }
}

/* ==========================================================
   v2.1 — Modern AI-agent polish (2026-05-08)
   Border beam, breathing dot, streaming dots, button glow,
   count-up safety, soft page background.
   Drops in non-invasively: any page using inspi.css gets these
   without changes to its markup unless it opts in by class.
   ========================================================== */

/* Soft violet glow at the top of the page (very subtle ambient) */
body.has-ambient {
  background:
    radial-gradient(1200px 600px at 50% -200px, rgba(99, 102, 241, 0.06), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

/* Tabular numerics for any element with .num — KPI safe by default */
.num, .kpi-value, .stat-value, [data-num] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* Primary button glow on hover — adds the "AI product" feel */
.btn-primary:hover, .btn--primary:hover, .btn.is-primary:hover, button[type=submit]:not(.subtle):hover {
  box-shadow: 0 0 0 4px var(--accent-line), 0 8px 24px rgba(79, 70, 229, 0.15);
  transition: box-shadow var(--dur-base) var(--ease-out);
}

/* Breathing live status dot — opt-in via .pulse-dot */
.pulse-dot {
  position: relative;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); display: inline-block;
}
.pulse-dot.amber { background: var(--warn); }
.pulse-dot.red   { background: var(--err); }
.pulse-dot::before, .pulse-dot::after {
  content: ''; position: absolute; inset: -3px;
  border-radius: 50%; border: 1px solid currentColor; color: inherit;
  opacity: 0; animation: pulseDotInspi 2.4s var(--ease-out) infinite;
  pointer-events: none;
}
.pulse-dot::before { animation-delay: 1.2s; }
.pulse-dot:not(.amber):not(.red) { color: var(--ok); }
.pulse-dot.amber { color: var(--warn); }
.pulse-dot.red   { color: var(--err); }
@keyframes pulseDotInspi {
  0%   { opacity: 0.6; transform: scale(0.8); }
  100% { opacity: 0;   transform: scale(2.6); }
}

/* Streaming-dots loader — drop-in replacement for "Loading…" text */
.stream-dots {
  display: inline-flex; gap: 4px; align-items: center;
  padding: 24px; justify-content: center; color: var(--ink-soft);
}
.stream-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-soft);
  animation: streamPulseInspi 1.2s ease-in-out infinite;
}
.stream-dots span:nth-child(2) { animation-delay: 0.15s; }
.stream-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes streamPulseInspi {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); background: var(--accent); }
}

/* Hero card with subtle border beam + dot-pattern texture (opt-in via .hero-beam) */
.hero-beam {
  position: relative;
  background:
    radial-gradient(600px 200px at 100% 0%, rgba(124, 58, 237, 0.05), transparent 60%),
    radial-gradient(400px 200px at 0% 100%, rgba(99, 102, 241, 0.04), transparent 60%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  isolation: isolate;
}
.hero-beam::before {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(24, 24, 27, 0.04) 1px, transparent 0);
  background-size: 16px 16px;
  pointer-events: none;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 50%, black 30%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 50%, black 30%, transparent 70%);
  z-index: 0;
}
.hero-beam::after {
  content: ''; position: absolute; inset: 0;
  border-radius: inherit; pointer-events: none;
  padding: 1px;
  background: conic-gradient(from var(--beam-angle, 0deg), transparent 0% 70%, #6366f1 80%, #a855f7 90%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: beamRotateInspi 8s linear infinite;
  opacity: 0.6;
}
.hero-beam > * { position: relative; z-index: 1; }
@property --beam-angle { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
@keyframes beamRotateInspi { to { --beam-angle: 360deg; } }

/* Status pill for onboarding health — green/yellow/red/idle */
.health-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--r-full);
  font-size: var(--t-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.health-pill::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.health-pill.green { background: rgba(22, 163, 74, 0.10); color: var(--ok); }
.health-pill.yellow { background: rgba(202, 138, 4, 0.10); color: var(--warn); }
.health-pill.red { background: rgba(220, 38, 38, 0.10); color: var(--err); }
.health-pill.idle { background: var(--surface-alt); color: var(--ink-soft); }

/* Reduced motion respects the new animations too */
@media (prefers-reduced-motion: reduce) {
  .pulse-dot::before, .pulse-dot::after { animation: none; }
  .stream-dots span { animation: none; }
  .hero-beam::after { animation: none; }
}
