/**
 * PlacedAI Design System Foundation
 * CSS custom properties, typography, spacing, and utility classes.
 * Imported before all other stylesheets.
 *
 * What this file owns: design tokens, global typography, base utilities.
 * What it does NOT own: component-specific styles, page layouts, animations.
 */

/* ── Self-hosted fonts (from @fontsource packages, copied via build-fonts.js) ── */
@import url('../fonts/inter/index.css');
@import url('../fonts/inter-tight/index.css');

/* ── Design tokens ──────────────────────────────────────────────────────────── */
:root {
  /* Colors */
  --color-canvas: #F7F8FA;
  --color-surface: #FFFFFF;
  --color-surface-alt: #F1F4F8;
  --color-text-primary: #0B1020;
  --color-text-secondary: #5B6472;
  --color-border: #E3E8EF;
  --color-accent: #4F6BFF;
  --color-accent-hover: #3E57E8;
  --color-success: #17B26A;
  --color-warning: #F59E0B;
  --color-critical: #E5484D;

  /* Border radii */
  --radius-card: 20px;
  --radius-btn: 14px;
  --radius-input: 16px;

  /* Shadows */
  --shadow-card: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-card-hover: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 220ms ease;

  /* Typography */
  --font-heading: 'Inter Tight', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-label: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Spacing base (8px grid) */
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;
  --space-7: 56px;
  --space-8: 64px;
  --space-9: 72px;
  --space-10: 80px;
  --space-11: 88px;
  --space-14: 112px;
}

/* ── Section rhythm ─────────────────────────────────────────────────────────── */
.section-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
}

@media (max-width: 768px) {
  .section-container {
    padding: 0 16px;
  }
}

.section {
  padding: var(--space-14) 0;
}

@media (max-width: 1024px) {
  .section {
    padding: 72px 0;
  }
}

@media (max-width: 768px) {
  .section {
    padding: 48px 0;
  }
}

/* ── Typography ─────────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--color-text-primary);
}

h1 { font-size: clamp(2.8rem, 5.5vw, 4.8rem); }
h2 { font-size: clamp(2rem, 3.8vw, 3rem); }
h3 { font-size: clamp(1.6rem, 2.8vw, 2.2rem); }
h4 { font-size: clamp(1.2rem, 2vw, 1.5rem); }

body, p, li {
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.7;
  color: var(--color-text-primary);
}

.label {
  font-family: var(--font-label);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
}

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  min-height: 44px;
  background-color: var(--color-accent);
  color: #FFFFFF;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

.btn-primary:hover {
  background-color: var(--color-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 107, 255, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  min-height: 44px;
  background-color: transparent;
  color: var(--color-accent);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 500;
  border: 1.5px solid var(--color-accent);
  border-radius: var(--radius-btn);
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.btn-secondary:hover {
  background-color: rgba(79, 107, 255, 0.08);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  min-height: 44px;
  background-color: transparent;
  color: var(--color-text-secondary);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

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

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-card-hover);
}

/* ── Inputs ──────────────────────────────────────────────────────────────────── */
.input {
  width: 100%;
  padding: 12px 16px;
  min-height: 44px;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--color-text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  box-sizing: border-box;
}

.input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(79, 107, 255, 0.15);
}

.input::placeholder {
  color: var(--color-text-secondary);
  opacity: 0.7;
}

/* ── Skip to content (WCAG 2.1 SC 2.4.1) ──────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 10000;
  padding: 12px 20px;
  background: var(--color-accent);
  color: #fff;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  border-radius: 0 0 var(--radius-btn) var(--radius-btn);
  text-decoration: none;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* ── Focus-visible styles (WCAG 2.1 SC 2.4.7) ────────────────────────────── */
/* Only show focus ring for keyboard navigation, not mouse clicks */
:focus-visible {
  outline: 2.5px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Remove default focus for mouse users (browsers already do this) */
:focus:not(:focus-visible) {
  outline: none;
}

/* Global interactive element minimum touch target (44×44px WCAG SC 2.5.5) */
a, button, input, select, textarea, [tabindex], [role="button"] {
  min-height: 44px;
  min-width: 44px;
}

/* Links inside text (small) — reset min-width so text links don't stretch */
p a, li a, span a, .label a {
  min-height: unset;
  min-width: unset;
}

/* ── Main content landmark (WCAG SC 1.3.1) ────────────────────────────────── */
main {
  display: block;
}

/* ══ GLOBAL RESPONSIVE RULES ══════════════════════════════════════════════ */
/* Prevent horizontal overflow site-wide */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

* {
  box-sizing: border-box;
}

main,
section,
header,
footer,
div {
  width: 100%;
  max-width: 100%;
}

/* Container system */
.container {
  width: min(100% - 32px, 1240px);
  margin-inline: auto;
}

@media (max-width: 768px) {
  .container {
    width: min(100% - 32px, 100%);
  }
}

/* Images and visual elements */
img,
video,
canvas,
svg,
iframe {
  max-width: 100%;
  height: auto;
}

/* Overflow wrap for all text */
h1, h2, h3, h4, h5, h6, p, a, li, span {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* ── Mobile Typography ─────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  h1 {
    font-size: 40px !important;
    line-height: 1.02 !important;
    letter-spacing: -0.03em !important;
  }

  h2 {
    font-size: 30px !important;
    line-height: 1.08 !important;
  }

  h3 {
    font-size: 21px !important;
    line-height: 1.2 !important;
  }

  body, p, li {
    font-size: 16px !important;
    line-height: 1.55 !important;
  }

  .label, .eyebrow {
    font-size: 13px !important;
  }
}

/* ── Mobile Header ──────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .wordmark-sub { display: none; }
  .header-cta { display: none; }
}

/* ── Sticky Mobile CTA ────────────────────────────────────────────────────── */
.sticky-cta {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  padding: 12px 16px;
  background: #fff;
  box-shadow: 0 -4px 24px rgba(11, 16, 32, 0.08);
  display: none;
}

@media (max-width: 767px) {
  .sticky-cta { display: block; }
}

.sticky-cta a,
.sticky-cta button {
  display: block;
  width: 100%;
  height: 52px;
  border-radius: 16px;
  background: #4F6BFF;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  line-height: 52px;
  text-decoration: none;
  border: none;
  cursor: pointer;
}

.sticky-cta a:hover,
.sticky-cta button:hover {
  background: #3E57E8;
}

.sticky-cta a:active,
.sticky-cta button:active {
  background: #2E44D0;
}

/* Prevent sticky CTA from covering page content */
@media (max-width: 767px) {
  main,
  .page-content,
  .main-content {
    padding-bottom: 80px !important;
  }
}

/* ── Blog Grid ──────────────────────────────────────────────────────────────── */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

@media (max-width: 1024px) {
  .blog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  .blog-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

/* ── Legal Container ────────────────────────────────────────────────────────── */
.legal-container {
  width: min(100% - 32px, 820px);
  margin-inline: auto;
  padding-block: 72px;
}

@media (max-width: 767px) {
  .legal-container {
    padding-block: 48px;
  }
}

.legal-container h1 {
  font-size: clamp(36px, 10vw, 56px);
  color: #0B1020;
}

.legal-container h2 {
  font-size: 26px;
  color: #0B1020;
}

.legal-container p {
  font-size: 16px;
  line-height: 1.7;
  color: #5B6472;
}

.legal-container ul {
  padding-left: 20px;
}

.legal-container li {
  font-size: 16px;
  line-height: 1.7;
  color: #5B6472;
}

/* ── Email Capture Modal ────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 16, 32, 0.48);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 100;
}

.modal-panel {
  width: min(100%, 480px);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  border-radius: 24px;
  background: #FFFFFF;
  padding: 28px;
}

.modal-panel h2 {
  font-size: 22px;
  color: #0B1020;
  margin-bottom: 8px;
}

.modal-panel p {
  font-size: 15px;
  color: #5B6472;
  margin-bottom: 20px;
}

.modal-input {
  width: 100%;
  height: 48px;
  border: 1.5px solid #E3E8EF;
  border-radius: 16px;
  padding: 0 16px;
  font-size: 15px;
  margin-bottom: 12px;
  box-sizing: border-box;
}

.modal-btn-primary {
  width: 100%;
  height: 48px;
  border-radius: 16px;
  background: #4F6BFF;
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  border: none;
  cursor: pointer;
  margin-bottom: 8px;
}

.modal-btn-secondary {
  background: none;
  border: none;
  color: #5B6472;
  font-size: 14px;
  cursor: pointer;
  display: block;
  margin-inline: auto;
}

/* ── Hide floating chat on mobile form pages ────────────────────────────────── */
@media (max-width: 767px) {
  .floating-chat,
  .chat-bubble {
    display: none !important;
  }
}