/* ==========================================================================
   LeakGrader Unified Design System
   File: web/assets/site.css
   Specification: Mobile-first, Dark Theme, WCAG AA Contrast, 8px Spacing
   ========================================================================== */

/* 1. Design Tokens */
:root {
  /* Colors */
  --bg: #07090e;
  --surface: #0f172a;
  --surface-elevated: #1e293b;
  --surface-hover: #26334d;
  --text: #f8fafc;
  --muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.12);
  --border-subtle: rgba(255, 255, 255, 0.07);
  
  /* Primary Accent (Sky Cyan) */
  --primary: #38bdf8;
  --primary-hover: #0284c7;
  --primary-contrast: #041019;
  --accent: #38bdf8;
  
  /* Semantic Status Colors */
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);

  /* 8px Spacing Scale */
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;
  --space-8: 64px;
  --space-12: 96px;

  /* Radius Scale */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Elevation Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);

  /* Typography Stacks */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Layout Constants */
  --container-max: 1200px;
  --header-height: 64px;
}

/* 2. Global Resets & Accessibility Defaults */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  max-width: 100%;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
  max-width: 100%;
  width: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 3. Typography Scale */
h1, h2, h3, h4, h5, h6 {
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1.15;
  font-weight: 800;
}

h2 {
  font-size: clamp(1.5rem, 3.5vw, 2.25rem);
  line-height: 1.25;
}

h3 {
  font-size: clamp(1.2rem, 2.5vw, 1.5rem);
  line-height: 1.35;
}

p {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
  max-width: 65ch;
}

p.lead {
  font-size: 1.125rem;
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--primary-hover);
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

/* 4. Layout Containers & Section Spacing */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: 20px;
  padding-right: 20px;
}

.section {
  padding-top: 56px;
  padding-bottom: 56px;
}

@media (min-width: 768px) {
  .section {
    padding-top: var(--space-12);
    padding-bottom: var(--space-12);
  }
}

.section-header {
  text-align: center;
  margin-bottom: var(--space-6);
}

.section-header p {
  margin-left: auto;
  margin-right: auto;
  margin-top: var(--space-1);
}

/* 5. Buttons (Min 44px touch targets) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: 44px;
  min-width: 44px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background-color: var(--primary);
  color: var(--primary-contrast);
  border-color: var(--primary);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #ffffff;
}

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

.btn-secondary:hover {
  background-color: var(--surface-hover);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

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

.btn-ghost:hover {
  color: var(--text);
  background-color: rgba(255, 255, 255, 0.05);
}

.btn-block {
  width: 100%;
}

/* 6. Cards & Surfaces */
.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  max-width: 100%;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

/* 7. Forms */
.form-group {
  margin-bottom: var(--space-3);
  text-align: left;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-1);
}

.form-input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  background-color: #05070d;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
  outline: none;
}

.form-input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.form-error {
  color: var(--danger);
  font-size: 0.825rem;
  margin-top: 4px;
}

/* 8. Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 600;
  background-color: rgba(56, 189, 248, 0.12);
  color: var(--primary);
  border: 1px solid rgba(56, 189, 248, 0.28);
}

.badge-success {
  background-color: var(--success-bg);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.3);
}

.badge-warning {
  background-color: var(--warning-bg);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.3);
}

/* 9. Tables with Dedicated Scroll Wrapper (Zero Overflow) */
.table-scroll-wrapper {
  width: 100%;
  max-width: 100%;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: var(--space-3);
  margin-bottom: var(--space-3);
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9375rem;
  white-space: nowrap;
}

.table th, .table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.table th {
  background-color: var(--surface-elevated);
  color: var(--text);
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

/* 10. FAQ Accordion */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 800px;
  margin: 0 auto;
}

.faq-item {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.faq-item[open] {
  border-color: rgba(56, 189, 248, 0.3);
}

.faq-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  min-height: 44px;
}

.faq-summary::-webkit-details-marker {
  display: none;
}

.faq-summary svg {
  transition: transform 0.2s ease;
  flex-shrink: 0;
  margin-left: 12px;
}

.faq-item[open] .faq-summary svg {
  transform: rotate(180deg);
}

.faq-content {
  padding: 0 20px 20px 20px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* 11. Pricing Cards */
.pricing-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin-top: var(--space-5);
}

@media (min-width: 768px) {
  .pricing-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.pricing-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.pricing-card.featured {
  border-color: var(--primary);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.06) 0%, var(--surface) 100%);
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.15);
}

.pricing-card-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
}

.pricing-price {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--text);
  margin: var(--space-2) 0;
}

.pricing-price span {
  font-size: 1rem;
  font-weight: 500;
  color: var(--muted);
}

.pricing-features {
  list-style: none;
  margin: var(--space-3) 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pricing-features li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.9375rem;
  color: var(--text);
}

.pricing-features li svg {
  color: var(--primary);
  flex-shrink: 0;
  margin-top: 2px;
}

/* 12. Site Header & Shared Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: rgba(7, 9, 14, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding-top: env(safe-area-inset-top);
  height: var(--header-height);
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
}

.site-logo-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--primary) 0%, #2563eb 100%);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
}

.desktop-nav {
  display: none;
  align-items: center;
  gap: var(--space-3);
}

@media (min-width: 900px) {
  .desktop-nav {
    display: flex;
  }
}

.nav-link {
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease;
}

.nav-link:hover {
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.mobile-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  cursor: pointer;
}

@media (min-width: 900px) {
  .mobile-menu-btn {
    display: none;
  }
}

/* 13. Mobile Drawer */
.mobile-drawer-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 1050;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.mobile-drawer-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.mobile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 85vw);
  background-color: #07090e;
  border-left: 1px solid var(--border);
  z-index: 1100;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  padding-top: calc(24px + env(safe-area-inset-top));
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

.mobile-drawer.active {
  transform: translateX(0);
}

.mobile-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.mobile-drawer-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
}

.mobile-nav-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  list-style: none;
}

.mobile-nav-link {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 10px 14px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  border-radius: var(--radius-md);
  text-decoration: none;
}

.mobile-nav-link:hover, .mobile-nav-link:active {
  background-color: var(--surface);
  color: var(--primary);
}

/* 14. Shared Footer */
.site-footer {
  background-color: #040508;
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-8);
  padding-bottom: var(--space-6);
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
  margin-bottom: var(--space-8);
}

@media (min-width: 640px) {
  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 900px) {
  .footer-grid {
    grid-template-columns: 1.5fr repeat(4, 1fr);
  }
}

.footer-col h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-2);
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-links a {
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer-links a:hover {
  color: var(--text);
}

.footer-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  font-size: 0.8125rem;
}

@media (min-width: 768px) {
  .footer-bottom {
    flex-direction: row;
    text-align: left;
  }
}

/* 15. NextStep Growth Funnel Component */
.next-step-section {
  padding: var(--space-8) 0;
  background: linear-gradient(180deg, transparent 0%, rgba(15, 23, 42, 0.6) 100%);
  border-top: 1px solid var(--border-subtle);
}

.next-step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-4);
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  max-width: 860px;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .next-step-card {
    padding: var(--space-6) var(--space-6);
  }
}

.next-step-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(56, 189, 248, 0.12);
  color: var(--primary);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.next-step-card h3 {
  font-size: clamp(1.35rem, 3.5vw, 2rem);
  margin-bottom: var(--space-2);
  line-height: 1.25;
}

.next-step-card p {
  color: var(--muted);
  font-size: 1rem;
  max-width: 60ch;
  margin: 0 auto var(--space-4);
  line-height: 1.6;
}

.next-step-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.next-step-crosslinks {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: var(--space-2);
}

.next-step-crosslinks a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}

.next-step-crosslinks a:hover {
  color: #ffffff;
}

/* 16. CRO Elements: Sticky CTA & Polite Exit-Intent */
.sticky-mobile-cta {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 998;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transform: translateY(110%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

.sticky-mobile-cta.visible {
  transform: translateY(0);
}

@media (min-width: 769px) {
  .sticky-mobile-cta {
    display: none !important;
  }
}

.sticky-cta-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sticky-cta-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sticky-cta-price {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

/* Exit Intent Drawer / Bar */
.exit-offer-bar {
  position: fixed;
  bottom: 20px;
  right: 20px;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  box-shadow: var(--shadow-lg);
  z-index: 1001;
  display: none;
  animation: slideInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.exit-offer-bar.active {
  display: block;
}

@keyframes slideInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
  .exit-offer-bar {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
  }
}

.exit-offer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.exit-offer-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.exit-offer-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.exit-offer-close:hover {
  color: var(--text);
}

/* 17. Accessibility & Motion Preferences */
@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;
  }
}
