/* ═══════════════════════════════════════════════════════════════
   Blaigent — Shared site chrome (nav + footer + base styles)
   Include on every public-facing page for design consistency.
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
  --bg: #ffffff;
  --bg-elevated: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #475569;
  --text-subtle: #64748b;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: rgba(79, 70, 229, 0.12);
  --accent-dark: #3730a3;
  --accent-warm: #f6ad55;
  --accent-dim: rgba(79, 70, 229, 0.06);
  --growth: #7c3aed;
  --growth-light: rgba(124, 58, 237, 0.12);
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --radius: 16px;
  --radius-sm: 12px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.1);
  --font-display: 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono-label: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --bg-code: #0f172a;
  /* Minimum tap target per Apple HIG / WCAG 2.5.5 */
  --tap-target-min: 44px;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  position: relative;
  min-height: 100vh;
}
@supports (-webkit-overflow-scrolling: touch) {
  * { -webkit-overflow-scrolling: touch; }
}

/* ── Common Layout ── */
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 24px); }
.page-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: max(96px, calc(76px + env(safe-area-inset-top))) clamp(16px, 4vw, 24px) 64px;
}

/* ── Common Typography ── */
.sec-label {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 0.75rem;
}
.sec-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.1rem, 4vw, 3.1rem);
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
  color: var(--text);
}
.sec-desc {
  color: var(--text-muted);
  max-width: 56ch;
  margin: 0 0 2.75rem;
  font-size: 1.0625rem;
  line-height: 1.75;
}

/* ── Common Components ── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.btn-primary {
  padding: 10px 20px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.28);
}
.btn-ghost {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.2s, color 0.2s;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.cta-row { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 1.25rem; }

/* Cards */
.sc-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(24px, 4vw, 32px);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.25s;
}
.sc-card:hover {
  border-color: rgba(99, 102, 241, 0.2);
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}
.sc-card h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  margin: 0 0 0.75rem;
  color: var(--text);
}
.sc-card p {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.7;
}
.sc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: clamp(16px, 3vw, 24px);
  margin-top: 2rem;
}

/* Sections */
.sc-section {
  padding: clamp(80px, 12vw, 140px) 0;
  border-bottom: 1px solid var(--border);
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
.sc-section.visible { opacity: 1; transform: translateY(0); }
.sc-section:last-of-type { border-bottom: none; }

/* Hero (subpage) */
.sc-hero {
  margin-bottom: clamp(48px, 8vw, 72px);
  position: relative;
}
.sc-hero h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.2rem, 4.5vw, 3.4rem);
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
  color: var(--text);
  line-height: 1.1;
}
.sc-hero .lead {
  color: var(--text-muted);
  font-size: clamp(1.05rem, 2vw, 1.2rem);
  max-width: 50ch;
  margin: 0 0 1.5rem;
  line-height: 1.7;
}

/* ═══════════════════════════════════════════════════════════════
   NAV
   ═══════════════════════════════════════════════════════════════ */
.sc-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9999;
  padding: 14px 24px;
  padding-top: max(14px, env(safe-area-inset-top));
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
  transition: background 0.3s, box-shadow 0.3s;
  min-height: 56px;
}
.sc-nav.scrolled {
  background: rgba(255,255,255,0.96);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.sc-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}
.sc-nav-logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: #0f172a;
  text-decoration: none;
}
.sc-nav-links {
  display: flex;
  gap: 8px;
  align-items: center;
}
.sc-nav-links > a,
.sc-nav-dd > .sc-nav-dd-trigger {
  color: #4a5568;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 6px 12px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: none;
  font-family: inherit;
}
.sc-nav-links > a:hover,
.sc-nav-dd > .sc-nav-dd-trigger:hover {
  color: #0f172a;
  background: rgba(0,0,0,0.04);
}
.sc-nav-cta {
  margin-left: 8px;
  padding: 8px 18px !important;
  border-radius: 999px !important;
  background: var(--accent) !important;
  color: #fff !important;
  font-weight: 600 !important;
  border: none;
  transition: box-shadow 0.2s, transform 0.2s !important;
}
.sc-nav-cta:hover {
  background: rgba(99, 102, 241, 0.92) !important;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.25) !important;
  transform: translateY(-1px);
}

/* Dropdown */
.sc-nav-dd {
  position: relative;
}
.sc-nav-dd-trigger svg {
  width: 12px; height: 12px;
  transition: transform 0.2s;
}
.sc-nav-dd:hover .sc-nav-dd-trigger svg,
.sc-nav-dd.open .sc-nav-dd-trigger svg {
  transform: rotate(180deg);
}
.sc-nav-dd-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 280px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.04);
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s, transform 0.15s;
  transform: translateX(-50%) translateY(4px);
  z-index: 100;
}
.sc-nav-dd:hover .sc-nav-dd-menu,
.sc-nav-dd.open .sc-nav-dd-menu {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
.sc-nav-dd-menu a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  color: #4a5568;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
.sc-nav-dd-menu a:hover {
  background: rgba(99, 102, 241, 0.06);
  color: #0f172a;
}
/* Icon-based dropdown items (matches Header.tsx DropdownPanel) */
.sc-dd-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: background 0.12s;
}
.sc-dd-item:hover { background: rgba(79, 70, 229, 0.05); color: inherit; }
.sc-dd-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.sc-dd-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: #0f172a;
  line-height: 1.3;
}
.sc-dd-desc {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 2px;
  line-height: 1.4;
}
.sc-nav-dd-cta-row {
  border-top: 1px solid #f1f5f9;
  padding: 8px 12px 4px;
  margin-top: 4px;
}
.sc-nav-dd-cta-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #4f46e5;
  text-decoration: none;
  transition: gap 0.15s;
}
.sc-nav-dd-cta-link:hover { gap: 8px; }

.sc-nav-dd-menu .dd-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  color: #94a3b8;
  margin-left: auto;
}

/* Mobile menu toggle */
.sc-nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  color: #0f172a;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  transition: all 0.2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.sc-nav-toggle:hover {
  background: rgba(0,0,0,0.04);
  border-color: var(--accent);
}
.sc-nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: #0f172a;
  border-radius: 2px;
  transition: all 0.3s;
}
.sc-nav-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.sc-nav-toggle.active span:nth-child(2) { opacity: 0; }
.sc-nav-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(7px, -6px); }

/* Mobile nav */
/* Switch to burger menu at 1024px instead of 768px. The full nav (logo,
   4 dropdowns, Pricing, Sign in, Start free CTA) needs ~900px to lay out
   horizontally. Between ~769–1023px the flex row wraps to 2 lines and the
   hover-opened dropdown panels (absolute-positioned, z-index 100) end up
   geometrically covering the wrapped "Sign in" / "Start free" links,
   making them unclickable. Raising the breakpoint avoids the wrap
   entirely. Only the nav media query is bumped — footer stays at 768px
   since it doesn't have the same overlap problem. */
@media (max-width: 1024px) {
  .sc-nav-toggle { display: flex; }
  /* Drawer: !important to defeat any landing-app / Tailwind / legacy .nav-links rules.
     Fills the entire viewport below the nav with an opaque white surface so page
     content behind it (hero, etc.) cannot bleed through. */
  nav.sc-nav .sc-nav-links,
  .sc-nav-links {
    position: fixed !important;
    top: var(--sc-nav-h, max(72px, calc(56px + env(safe-area-inset-top)))) !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    /* Explicit height (NOT auto). iOS Safari with position:fixed + top + bottom +
       height:auto collapses to content height, leaving the drawer only as tall
       as the user block and letting the hero bleed through below. Forcing
       calc(100dvh - top) makes the drawer reliably fill the viewport. */
    height: calc(100dvh - var(--sc-nav-h, 72px)) !important;
    min-height: calc(100dvh - var(--sc-nav-h, 72px)) !important;
    max-height: none !important;
    width: 100vw !important;
    z-index: 10000 !important;
    background: #ffffff !important;
    flex-direction: column;
    align-items: stretch;
    padding: 20px 24px max(24px, env(safe-area-inset-bottom));
    gap: 2px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    transform: none !important;
    opacity: 1;
    visibility: visible;
    display: none;
  }
  .sc-nav-links.active { display: flex !important; }
  /* Prevent background scroll while mobile menu is open. On iOS, overflow:hidden
     alone is not enough — the page still rubber-band scrolls. Pinning body as
     fixed locks it reliably. site-chrome.js must save/restore scrollY when
     opening/closing the drawer for this to feel seamless. */
  body.sc-nav-open { overflow: hidden; }
  .sc-nav-links > a,
  .sc-nav-dd > .sc-nav-dd-trigger {
    font-size: 1rem;
    padding: 12px 16px;
    border-radius: 10px;
    width: 100%;
  }
  .sc-nav-cta {
    margin-left: 0 !important;
    margin-top: 8px;
    justify-content: center;
    width: 100%;
  }
  /* Mobile dropdowns expand inline */
  .sc-nav-dd-menu {
    position: static !important;
    left: auto !important;
    right: auto !important;
    transform: none !important;
    opacity: 1;
    visibility: visible;
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 0 0 0 16px;
    display: none;
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
    background: transparent;
  }
  .sc-nav-dd.open .sc-nav-dd-menu { display: block !important; }
  .sc-nav-dd-menu a { padding: 14px 16px; min-height: 44px; display: flex; align-items: center; }
  .sc-dd-title, .sc-dd-desc { white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
}

/* ═══════════════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════════════ */
.sc-footer {
  border-top: 1px solid rgba(255,255,255,0.06);
  background: #0f172a;
  padding: clamp(48px, 8vw, 64px) 0 28px;
  margin-top: clamp(48px, 10vw, 80px);
  box-shadow: none;
}
.sc-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 24px);
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 5fr);
  gap: clamp(32px, 6vw, 64px);
  align-items: flex-start;
}
.sc-footer-brand h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: #f8fafc;
  margin: 0 0 0.5rem;
}
.sc-footer-brand p {
  color: #64748b;
  font-size: 0.9375rem;
  margin: 0 0 1rem;
  max-width: 32ch;
  line-height: 1.6;
}
.sc-footer-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: clamp(16px, 3vw, 32px);
}
.sc-footer-col-title {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #475569;
  margin-bottom: 0.75rem;
}
.sc-footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sc-footer-links li { margin-bottom: 0.35rem; }
.sc-footer-links a {
  font-size: 0.9375rem;
  color: #64748b;
  text-decoration: none;
  transition: color 0.2s, transform 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sc-footer-links a { transition: color 0.15s ease; }
.sc-footer-links a:hover { color: var(--accent); }
.sc-footer-links .badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.1);
  color: #64748b;
}
.sc-footer-bottom {
  max-width: 1200px;
  margin: 28px auto 0;
  padding: 20px clamp(16px, 4vw, 24px) 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 0.8125rem;
  color: #475569;
}
.sc-footer-bottom-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
}
.sc-footer-bottom-links a {
  color: #475569;
  text-decoration: none;
}
.sc-footer-bottom-links a:hover { color: var(--accent); }

/* ── Footer column accordion: behave as plain div on desktop ── */
.sc-footer-col-details {
  margin: 0;
  padding: 0;
}
@media (min-width: 769px) {
  .sc-footer-col-details > summary {
    list-style: none;
    pointer-events: none;
    cursor: default;
  }
  .sc-footer-col-details > summary::-webkit-details-marker { display: none; }
  .sc-footer-col-details[open] .sc-footer-links { display: block; }
  .sc-footer-col-details .sc-footer-links { display: block; }
}

@media (max-width: 768px) {
  .sc-footer-inner { grid-template-columns: 1fr; }
  .sc-footer-col-details > summary {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    list-style: none;
  }
  .sc-footer-col-details > summary::-webkit-details-marker { display: none; }
  .sc-footer-col-details > summary::after {
    content: '';
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.2s;
    margin-right: 4px;
  }
  .sc-footer-col-details[open] > summary::after {
    transform: rotate(-135deg);
  }
  .sc-footer-col-details:not([open]) .sc-footer-links { display: none; }
  .sc-footer-col-details[open] .sc-footer-links { display: block; }
}

/* ── Mobile auth block in burger menu ───────────────────────── */
/* Breakpoint matches the nav burger switch above (1024px). Earlier this
   was gated at 768px, which left a broken intermediate state between
   769-1024px where the burger drawer was open but the user block (with
   email + Dashboard + Sign out) stayed hidden — the leaked desktop
   avatar was the only auth UI visible, and clicking it sent users to
   "#" (the avatar's href) instead of opening the menu. */
.sc-nav-user-mobile { display: none; }
@media (max-width: 1024px) {
  .sc-nav-user-mobile {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 12px 12px;
    margin: -8px 0 8px;
    border-bottom: 1px solid var(--border);
  }
  .sc-nav-user-mobile .sc-nav-user-row {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
  }
  .sc-nav-user-mobile .sc-nav-user-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; flex-shrink: 0;
    font-family: var(--font-display);
  }
  .sc-nav-user-mobile .sc-nav-user-name {
    font-weight: 600; font-size: 0.95rem; color: var(--text); line-height: 1.2;
  }
  .sc-nav-user-mobile .sc-nav-user-email {
    font-size: 0.8rem; color: var(--text-muted); line-height: 1.3; margin-top: 2px;
    word-break: break-all;
  }
  .sc-nav-user-mobile .sc-nav-user-signout {
    background: none; border: none; padding: 6px 0;
    font-family: inherit; font-size: 0.9rem; color: var(--text-muted);
    text-align: left; cursor: pointer; align-self: flex-start;
  }
  .sc-nav-user-mobile .sc-nav-user-signout:hover { color: var(--accent); }
  .sc-nav-auth-hidden-mobile { display: none !important; }
}

/* ── Accessibility: visible keyboard focus on interactive elements ── */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Auth-aware CTAs ──
   site-chrome.js toggles `.blaigent-authed` / `.blaigent-anon` on <html>.
   Page authors tag CTAs with:
     .cta-signup / .cta-signin  → only show when logged OUT
     .cta-dashboard             → only show when logged IN
   Keeps hero / section CTAs in sync with the navbar's auth state. */
html.blaigent-authed .cta-signup,
html.blaigent-authed .cta-signin {
  display: none !important;
}
html.blaigent-anon .cta-dashboard {
  display: none !important;
}

/* ── Hide chat widget while the mobile burger drawer is open ──
   The widget launcher uses z-index 2147483645 so it sits on top of every
   other UI layer. On mobile that means it covers items in the bottom-right
   of the burger drawer. Hide both the launcher and the open panel while
   the drawer is open so the menu is fully usable. */
body.sc-nav-open #bw-launcher,
body.sc-nav-open #bw-panel,
body.sc-nav-open #bw-minipill {
  display: none !important;
}
