/* ============================================================
   EMM SaaS Design System — components.css
   Buttons, badges, cards, nav, toast, modal, pricing, StreamPay
   badges, FAQ. Depends on tokens.css + base.css.
   ============================================================ */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 12px var(--space-lg);
  min-height: 44px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-busy="true"] { opacity: 0.6; cursor: not-allowed; }

.btn-primary { background: var(--cta-bg); color: var(--cta-fg); }
.btn-primary:hover { background: var(--cta-bg-hover); box-shadow: var(--shadow-md); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent-ink); }

.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }

.btn-danger { background: var(--danger); color: var(--white); }

.btn-navy { background: var(--navy); color: var(--on-navy); }
.btn-navy:hover { background: var(--navy-2); }

.btn-sm { padding: 8px var(--space-md); min-height: 36px; font-size: var(--text-sm); }
.btn-lg { padding: 14px var(--space-xl); min-height: 52px; font-size: var(--text-lg); }
.btn-block { width: 100%; }

.btn svg { width: 20px; height: 20px; flex-shrink: 0; }

/* Loading spinner state (pair with aria-busy="true") */
.btn[aria-busy="true"] .spinner,
.spinner {
  width: 18px; height: 18px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  white-space: nowrap;
}
/* qa:badge-accent — accent pink was 3.8:1 with white; cta-bg is 5.3:1 */
.badge-accent  { background: var(--cta-bg); color: var(--cta-fg); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); }
.badge-info    { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--surface-2); color: var(--text-muted); }
.badge-dot::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur-base) var(--ease-out),
              transform var(--dur-base) var(--ease-out);
}
.card-hover:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.card-title { font-size: var(--text-xl); margin-block-end: var(--space-sm); }
.card-icon {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--cta-fg);
  border-radius: var(--radius-md);
  margin-block-end: var(--space-md);
}
.card-icon svg { width: 24px; height: 24px; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
}
@media (max-width: 900px) { .feature-grid { grid-template-columns: 1fr; } }

/* ---------- Navbar ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  height: var(--nav-height);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-block-end: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--container);
  margin-inline: auto;
  height: 100%;
  padding-inline: var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: var(--weight-black);
  font-size: var(--text-lg);
  color: var(--text);
}
.nav-brand:hover { text-decoration: none; }
.nav-brand .logo-mark {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  background: var(--cta-bg); /* qa:logo-contrast — white on pink-500 was 3.83:1 */
  color: var(--cta-fg);
  display: grid; place-items: center;
}
.nav-links { display: flex; align-items: center; gap: var(--space-md); list-style: none; padding: 0; }
.nav-links a { color: var(--text-muted); font-weight: var(--weight-medium); }
/* qa:nav-btn-color — .nav-links a used to override the button text color (1.26:1) */
.nav-links a.btn-primary { color: var(--cta-fg); }
.nav-links a.btn-secondary, .nav-links a.btn-ghost { color: var(--text); }
.nav-links a.btn-navy { color: var(--on-navy); }
.nav-links a.btn-primary:hover { color: var(--cta-fg); }
.nav-links a:hover { color: var(--text); text-decoration: none; }
@media (max-width: 760px) { .nav-links { display: none; } }

.theme-toggle {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .icon-moon { display: none; }
  :root:not([data-theme]) .theme-toggle .icon-sun { display: block; }
}

/* ---------- Hero ---------- */
.hero {
  padding-block: var(--space-4xl);
  background:
    radial-gradient(ellipse 60% 50% at 80% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent),
    var(--bg);
}
.hero-inner {
  max-width: var(--container-narrow);
  margin-inline: auto;
  padding-inline: var(--space-md);
  text-align: center;
}
.hero h1 { margin-block-end: var(--space-md); }
.hero .lead {
  font-size: var(--text-lg);
  color: var(--text-muted);
  max-width: 62ch;
  margin-inline: auto;
  margin-block-end: var(--space-xl);
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  justify-content: center;
  margin-block-end: var(--space-lg);
}

/* ---------- StreamPay trust badges ---------- */
.pay-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}
.pay-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* ---------- Pricing ---------- */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
  align-items: stretch;
}
@media (max-width: 900px) { .pricing-grid { grid-template-columns: 1fr; } }

.price-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl) var(--space-lg);
}
.price-card.featured {
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
}
.price-card .popular-flag {
  position: absolute;
  top: -14px;
  inset-inline-start: 50%;
  transform: translateX(50%); /* RTL: 50% of own width toward start */
}
.price-name { font-size: var(--text-lg); font-weight: var(--weight-bold); }
.price-amount {
  font-size: var(--text-4xl);
  font-weight: var(--weight-black);
  color: var(--text);
  margin-block: var(--space-sm);
}
.price-amount .currency { font-size: var(--text-lg); font-weight: var(--weight-bold); }
.price-period { color: var(--text-muted); font-size: var(--text-sm); }

.price-features {
  list-style: none;
  padding: 0;
  margin-block: var(--space-lg);
  display: grid;
  gap: var(--space-sm);
  font-size: var(--text-sm);
  flex-grow: 1;
}
.price-features li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
}
.price-features li svg {
  width: 18px; height: 18px;
  color: var(--success);
  flex-shrink: 0;
  margin-block-start: 3px;
}
.price-features li.off { color: var(--text-muted); }
.price-features li.off svg { color: var(--border); }

/* Comparison table variant */
.pricing-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.pricing-table th, .pricing-table td {
  padding: 12px var(--space-md);
  border-block-end: 1px solid var(--border);
  text-align: start;
}
.pricing-table thead th { background: var(--surface-2); }
.pricing-table td .yes { color: var(--success); font-weight: var(--weight-bold); }
.pricing-table td .no  { color: var(--text-muted); }
.pricing-table .col-featured { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed;
  bottom: var(--space-lg);
  inset-inline-start: 50%;
  transform: translateX(50%);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  z-index: var(--z-toast);
  width: min(420px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--navy);
  color: var(--on-navy);
  padding: 12px var(--space-md);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  font-size: var(--text-sm);
  animation: toast-in var(--dur-base) var(--ease-out);
}
.toast-success { border-inline-start: 4px solid var(--success); }
.toast-error   { border-inline-start: 4px solid var(--danger); }
.toast svg { width: 20px; height: 20px; flex-shrink: 0; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
}

/* ---------- Modal (<dialog>) ---------- */
dialog.modal {
  width: min(520px, calc(100vw - 32px));
  border: none;
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xl);
}
dialog.modal::backdrop {
  background: rgba(15, 15, 26, 0.55);
  backdrop-filter: blur(3px);
}
.modal-title { font-size: var(--text-xl); margin-block-end: var(--space-md); }
.modal-close {
  position: absolute;
  top: var(--space-md);
  inset-inline-end: var(--space-md);
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: none;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* ---------- FAQ (details/summary) ---------- */
.faq { display: grid; gap: var(--space-sm); }
.faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
}
.faq summary {
  font-weight: var(--weight-bold);
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  min-height: 44px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  font-size: var(--text-2xl);
  font-weight: var(--weight-regular);
  color: var(--accent-ink);
  transition: transform var(--dur-fast) var(--ease-out);
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { margin-block-start: var(--space-sm); color: var(--text-muted); }

/* ---------- Footer ---------- */
.footer {
  background: var(--navy);
  color: var(--on-navy-muted);
  padding-block: var(--space-2xl) var(--space-lg);
  font-size: var(--text-sm);
}
.footer a { color: var(--on-navy-muted); }
.footer a:hover { color: var(--on-navy); }
.footer-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr 1fr; /* qa:footer-5col — API/MCP column was orphaned */
  gap: var(--space-xl);
}
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
.footer-bottom {
  margin-block-start: var(--space-xl);
  padding-block-start: var(--space-md);
  border-block-start: 1px solid var(--navy-500);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

/* ---------- Misc ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-lg); }
.grid-2 > *, .grid-3 > * { min-width: 0; } /* qa:grid-min — lets cards with <pre>/<table> shrink on mobile */
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }

.stats-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2xl);
  text-align: center;
}
.stat-value { font-size: var(--text-3xl); font-weight: var(--weight-black); color: var(--accent-ink); }

.steps { counter-reset: step; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-lg); } /* qa:steps-track — implicit auto track grew to the max-content of long inline <code> and overflowed mobile */
/* qa:step-block — .step was display:flex, which blockifies every direct inline <code> child into a separate flex item; the text runs between them became anonymous flex items too, all laid out as ONE non-wrapping row with 16px gaps (418px on a 318px track; min-width:0 cannot fix items that cannot shrink). Block flow + an absolutely-positioned counter lets inline <code> wrap with the text. */
.step { position: relative; display: block; padding-inline-start: calc(36px + var(--space-md)); min-width: 0; overflow-wrap: anywhere; }
.step::before {
  counter-increment: step;
  content: counter(step);
  position: absolute; inset-inline-start: 0; top: 0;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--cta-fg);
  border-radius: 50%;
  font-weight: var(--weight-bold);
}
