/* ════════════════════════════════════════════════════════════════════════
   GRC Migrate — Base Components
   Reusable pieces built on tokens.css. No component library, no JS deps.
   ════════════════════════════════════════════════════════════════════════ */

/* ── App shell ─────────────────────────────────────────────────────────── */
.gm-shell {
  min-height: 100vh;
  background-color: var(--bg-shell);
  /* subtle grid texture */
  background-image:
    linear-gradient(var(--bg-grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid-line) 1px, transparent 1px);
  background-size: 42px 42px;
  color: var(--text-on-dark);
  font-family: var(--font-ui);
}

/* ── Frosted header ────────────────────────────────────────────────────── */
.gm-header {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-6);
  background: rgba(10, 14, 26, 0.78);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--glass-border);
}
.gm-header-brand { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.gm-header-logo {
  width: 34px; height: 34px; border-radius: var(--r-md);
  background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; color: var(--accent-contrast);
  flex-shrink: 0;
}
.gm-header-logo img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }
.gm-header-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.gm-header-sub { font-size: 11px; color: var(--text-on-dark-dim); }
.gm-header-right { display: flex; align-items: center; gap: var(--sp-3); }

/* Mode indicator chip */
.gm-mode {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
}
.gm-mode--demo   { background: rgba(245, 158, 11, 0.16); color: var(--demo-amber); border-color: rgba(245, 158, 11, 0.4); }
.gm-mode--live   { background: var(--status-pass-soft); color: var(--status-pass); border-color: rgba(52, 211, 153, 0.35); }
.gm-mode--dryrun { background: var(--status-info-soft); color: var(--status-info); border-color: rgba(96, 165, 250, 0.35); }

/* Connection status dots */
.gm-conn { display: flex; align-items: center; gap: var(--sp-2); font-size: 11px; color: var(--text-on-dark-dim); }
.gm-conn-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--status-skip);
  flex-shrink: 0;
}
.gm-conn-dot--ok   { background: var(--status-pass); box-shadow: 0 0 6px rgba(52, 211, 153, 0.6); }
.gm-conn-dot--warn { background: var(--status-warn); }
.gm-conn-dot--fail { background: var(--status-fail); }

/* ── Glass card ────────────────────────────────────────────────────────── */
.gm-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.gm-card-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--glass-border);
}
.gm-card-title {
  font-size: 11px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--text-on-dark-dim);
  font-family: var(--font-mono);
}
.gm-card-body { padding: var(--sp-5); }

/* Light surface card — for dense readable content inside the dark shell */
.gm-card--light { background: var(--surface); border-color: rgba(15, 23, 42, 0.08); color: var(--text-body); backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: var(--shadow-light-card); }
.gm-card--light .gm-card-title { color: var(--text-dim); }
.gm-card--light .gm-card-header { border-bottom-color: rgba(15, 23, 42, 0.07); }

/* ── Stat block (numbers are ALWAYS mono) ──────────────────────────────── */
.gm-stat { text-align: center; padding: var(--sp-4); }
.gm-stat-num {
  font-family: var(--font-mono);
  font-size: 34px; font-weight: 600; line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--text-on-dark);
}
.gm-stat-num--accent { background: var(--accent-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.gm-stat-num--pass { color: var(--status-pass); }
.gm-stat-num--warn { color: var(--status-warn); }
.gm-stat-num--fail { color: var(--status-fail); }
.gm-stat-label {
  margin-top: var(--sp-1);
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-on-dark-faint);
  font-family: var(--font-mono);
}

/* ── Status badge ──────────────────────────────────────────────────────── */
.gm-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 600; letter-spacing: 0.06em;
  padding: 3px 9px; border-radius: var(--r-pill);
  border: 1px solid transparent;
  white-space: nowrap;
}
.gm-badge--pass { background: var(--status-pass-soft); color: var(--status-pass); border-color: rgba(52, 211, 153, 0.3); }
.gm-badge--warn { background: var(--status-warn-soft); color: var(--status-warn); border-color: rgba(251, 191, 36, 0.3); }
.gm-badge--fail { background: var(--status-fail-soft); color: var(--status-fail); border-color: rgba(248, 113, 113, 0.3); }
.gm-badge--skip { background: var(--status-skip-soft); color: var(--status-skip); border-color: rgba(148, 163, 184, 0.3); }
.gm-badge--info { background: var(--status-info-soft); color: var(--status-info); border-color: rgba(96, 165, 250, 0.3); }
.gm-badge--accent { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

/* ── Progress bar ──────────────────────────────────────────────────────── */
.gm-progress { height: 7px; border-radius: var(--r-pill); background: rgba(148, 163, 184, 0.12); overflow: hidden; }
.gm-progress-fill {
  height: 100%; border-radius: inherit;
  background: var(--accent-gradient);
  width: 0%;
  transition: width var(--dur-slow) var(--ease-out);
}
.gm-progress-fill--warn { background: var(--status-warn); }
.gm-progress-fill--fail { background: var(--status-fail); }

/* Packet-flow shimmer on active progress (guarded) */
@media (prefers-reduced-motion: no-preference) {
  .gm-progress-fill--active {
    background-image: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 50%, var(--accent) 100%);
    background-size: 200% 100%;
    animation: gm-packet-flow 1.6s linear infinite;
  }
  @keyframes gm-packet-flow {
    from { background-position: 100% 0; }
    to   { background-position: -100% 0; }
  }
}

/* ── Step rail ─────────────────────────────────────────────────────────── */
.gm-steprail { display: flex; align-items: center; gap: 0; overflow-x: auto; padding: var(--sp-2) 0; }
.gm-step { display: flex; align-items: center; flex-shrink: 0; }
.gm-step-btn {
  display: flex; align-items: center; gap: var(--sp-2);
  background: none; border: none; cursor: pointer; padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  color: var(--text-on-dark-faint);
  font-family: var(--font-ui); font-size: 12.5px; font-weight: 500;
  transition: color var(--dur-fast) ease, background var(--dur-fast) ease;
}
.gm-step-btn:hover:not(:disabled) { background: rgba(148, 163, 184, 0.08); }
.gm-step-btn:disabled { cursor: not-allowed; opacity: 0.55; }
.gm-step-num {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  border: 1px solid var(--glass-border-strong);
  color: var(--text-on-dark-dim);
  flex-shrink: 0;
}
.gm-step--complete .gm-step-num { background: var(--status-pass-soft); border-color: rgba(52, 211, 153, 0.45); color: var(--status-pass); }
.gm-step--complete .gm-step-btn { color: var(--text-on-dark-dim); }
.gm-step--active .gm-step-num {
  background: var(--accent-gradient); border-color: transparent; color: var(--accent-contrast);
  box-shadow: var(--accent-glow);
}
.gm-step--active .gm-step-btn { color: var(--text-on-dark); font-weight: 600; }
.gm-step-connector { width: 26px; height: 1px; background: var(--glass-border-strong); flex-shrink: 0; }
.gm-step--complete + .gm-step .gm-step-connector,
.gm-step--complete .gm-step-connector { background: rgba(52, 211, 153, 0.4); }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.gm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  font-family: var(--font-ui); font-size: 13px; font-weight: 600;
  padding: 10px 20px; border-radius: var(--r-md);
  border: 1px solid transparent; cursor: pointer;
  transition: transform var(--dur-fast) ease, box-shadow var(--dur-fast) ease, opacity var(--dur-fast) ease;
}
.gm-btn:active:not(:disabled) { transform: translateY(1px); }
.gm-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.gm-btn--primary { background: var(--accent-gradient); color: var(--accent-contrast); box-shadow: var(--accent-glow); }
.gm-btn--primary:hover:not(:disabled) { box-shadow: var(--accent-glow-strong); }
.gm-btn--ghost { background: transparent; color: var(--text-on-dark-dim); border-color: var(--glass-border-strong); }
.gm-btn--ghost:hover:not(:disabled) { color: var(--text-on-dark); border-color: rgba(148, 163, 184, 0.5); }
.gm-btn--danger { background: transparent; color: var(--status-fail); border-color: rgba(248, 113, 113, 0.4); }
.gm-btn--danger:hover:not(:disabled) { background: var(--status-fail-soft); }
.gm-btn--sm { font-size: 11.5px; padding: 6px 12px; }
.gm-btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

/* Disabled-with-tooltip wrapper (native title + visual cue) */
.gm-tooltip-wrap { position: relative; display: inline-flex; }
.gm-tooltip-wrap[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--bg-shell-raised); color: var(--text-on-dark);
  border: 1px solid var(--glass-border-strong); border-radius: var(--r-sm);
  padding: 7px 11px; font-size: 11.5px; white-space: nowrap;
  box-shadow: var(--shadow-raised); z-index: 80; pointer-events: none;
}

/* ── Data table ────────────────────────────────────────────────────────── */
.gm-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.gm-table th {
  text-align: left; padding: 9px 12px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-on-dark-faint);
  border-bottom: 1px solid var(--glass-border-strong);
}
.gm-table td { padding: 9px 12px; border-bottom: 1px solid var(--glass-border); color: var(--text-on-dark-dim); vertical-align: top; }
.gm-table tr:last-child td { border-bottom: none; }
.gm-table .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; color: var(--text-on-dark); }
.gm-card--light .gm-table th { color: var(--text-dim); border-bottom-color: rgba(15, 23, 42, 0.12); }
.gm-card--light .gm-table td { color: var(--text-body); border-bottom-color: rgba(15, 23, 42, 0.06); }
.gm-card--light .gm-table .num { color: var(--text-strong); }

/* ── Toast / inline alert ──────────────────────────────────────────────── */
.gm-alert {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  font-size: 12.5px; border: 1px solid;
}
.gm-alert--info { background: var(--status-info-soft); border-color: rgba(96, 165, 250, 0.3); color: #bfdbfe; }
.gm-alert--warn { background: var(--status-warn-soft); border-color: rgba(251, 191, 36, 0.3); color: #fde68a; }
.gm-alert--fail { background: var(--status-fail-soft); border-color: rgba(248, 113, 113, 0.3); color: #fecaca; }
.gm-alert--pass { background: var(--status-pass-soft); border-color: rgba(52, 211, 153, 0.3); color: #a7f3d0; }

.gm-toast-stack { position: fixed; bottom: var(--sp-5); right: var(--sp-5); z-index: 90; display: flex; flex-direction: column; gap: var(--sp-2); max-width: 380px; }
@media (prefers-reduced-motion: no-preference) {
  .gm-toast-enter { animation: gm-toast-in var(--dur-med) var(--ease-out); }
  @keyframes gm-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

/* ── Staggered card reveal (guarded) ───────────────────────────────────── */
@media (prefers-reduced-motion: no-preference) {
  .gm-reveal { animation: gm-reveal-up var(--dur-med) var(--ease-out) both; }
  .gm-reveal:nth-child(2) { animation-delay: 60ms; }
  .gm-reveal:nth-child(3) { animation-delay: 120ms; }
  .gm-reveal:nth-child(4) { animation-delay: 180ms; }
  .gm-reveal:nth-child(5) { animation-delay: 240ms; }
  @keyframes gm-reveal-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
}

/* ── Guided beacon pulse (demo, guarded) ───────────────────────────────── */
@media (prefers-reduced-motion: no-preference) {
  .gm-beacon { position: relative; }
  .gm-beacon::before {
    content: ''; position: absolute; inset: -5px; border-radius: inherit;
    border: 2px solid var(--accent);
    animation: gm-beacon-pulse 1.8s ease-out infinite;
    pointer-events: none;
  }
  @keyframes gm-beacon-pulse {
    0%   { opacity: 0.85; transform: scale(1); }
    70%  { opacity: 0; transform: scale(1.12); }
    100% { opacity: 0; transform: scale(1.12); }
  }
}

/* ── Utility ───────────────────────────────────────────────────────────── */
.gm-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.gm-hidden { display: none !important; }
.gm-eyebrow {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-on-dark-faint);
}

/* ── Footer lockup ─────────────────────────────────────────────────────── */
.gm-footer {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-6);
  border-top: 1px solid var(--glass-border);
  font-size: 11.5px; color: var(--text-on-dark-faint);
  flex-wrap: wrap;
}
.gm-footer a { color: var(--text-on-dark-dim); text-decoration: none; }
.gm-footer a:hover { color: var(--text-on-dark); }
.gm-footer-lockup strong { color: var(--text-on-dark-dim); font-weight: 600; }
.gm-footer-left, .gm-footer-right { display: flex; align-items: center; gap: var(--sp-3); }

/* ── Demo theme preview control ────────────────────────────────────────── */
.gm-theme-preview { display: inline-flex; align-items: center; gap: var(--sp-2); }
.gm-theme-select {
  background: var(--glass-bg-raised);
  color: var(--text-on-dark);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--r-sm);
  font-family: var(--font-ui); font-size: 11.5px;
  padding: 4px 8px;
}
.gm-theme-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ── Demo welcome overlay ──────────────────────────────────────────────── */
.gm-welcome-overlay {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(6, 9, 18, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-5);
}
.gm-welcome-card { max-width: 480px; padding: var(--sp-8); }
.gm-welcome-card h2 { font-size: 20px; font-weight: 700; color: var(--text-on-dark); margin: var(--sp-2) 0 var(--sp-3); letter-spacing: -0.01em; }
.gm-welcome-card p { font-size: 13.5px; color: var(--text-on-dark-dim); line-height: 1.65; }
.gm-welcome-card strong { color: var(--text-on-dark); }
.gm-welcome-actions { display: flex; gap: var(--sp-3); margin-top: var(--sp-6); }
@media (prefers-reduced-motion: no-preference) {
  .gm-welcome-card { animation: gm-reveal-up var(--dur-med) var(--ease-out) both; }
}
