/* =========================
   DESIGN SYSTEM
   =========================
   Single authoritative stylesheet
   All presentation flows through this file
   
   LEGACY STYLES FROZEN IN: styles.legacy.css
   ========================= */

/* =========================
   DESIGN TOKENS
   ========================= */

:root {
  /* Colors */
  --color-bg: #ffffff;
  --color-surface: #f7f7f8;
  --color-text: #0f172a;
  --color-muted: #475569;
  --color-accent: #2563eb;
  
  /* Legacy mappings (maintain compatibility) */
  --bg: var(--color-bg);
  --panel: var(--color-surface);
  --text: var(--color-text);
  --text-muted: var(--color-muted);
  --text-subtle: #94a3b8;
  --primary: var(--color-accent);
  --border: #e2e8f0;
  --link: var(--color-accent);
  --hover: var(--color-surface);
  
  /* Typography */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 2rem;
  --space-xl: 4rem;
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  
  /* Legacy spacing (maintain compatibility) */
  --spacing-xs: var(--space-xs);
  --spacing-sm: var(--space-sm);
  --spacing-md: var(--space-md);
  --spacing-lg: var(--space-lg);
  --spacing-xl: var(--space-xl);
  --spacing-2xl: var(--space-xl);
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

/* =========================
   BASE ELEMENTS
   ========================= */

* { 
  box-sizing: border-box; 
}

html { 
  font-size: 14px; 
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  font-family: var(--font-sans);
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 0.5rem;
  line-height: 1.25;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--color-text);
}

h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

p {
  margin: 0 0 1rem;
  line-height: 1.6;
}

a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

ul, ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* =========================
   LAYOUT PRIMITIVES
   ========================= */

.container {
  max-width: 64rem;
  margin-left: auto;
  margin-right: auto;
  padding-left: 2rem;
  padding-right: 2rem;
}

.section {
  margin-bottom: var(--spacing-xl);
}

/* =========================
   COMPONENTS
   ========================= */

/* Buttons */
.button,
button,
.btn,
[type="submit"] {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.button--primary,
.btn-primary {
  background: var(--color-primary);
  color: white;
  border: 1px solid var(--color-primary);
}

.button--primary:hover,
.btn-primary:hover {
  background: var(--color-text);
  border-color: var(--color-text);
}

/* Cards */
.card {
  background: var(--color-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

/* =========================
   INLINE EXTRACTION UTILITIES
   ========================= */

/* Spacing (token-aligned) */
.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-3xl { margin-top: 3rem; }

.mb-xs { margin-bottom: var(--space-xs); }
.mb-sm { margin-bottom: 0.75rem; } /* Common value */
.mb-md { margin-bottom: var(--space-md); } /* 1rem */
.mb-lg { margin-bottom: 1.5rem; } /* Common intermediate value */
.mb-xl { margin-bottom: var(--space-lg); } /* 2rem */
.mb-2xl { margin-bottom: 2.5rem; } /* Common intermediate value */
.mb-3xl { margin-bottom: 3rem; } /* Common larger spacing */
.mb-4xl { margin-bottom: var(--space-xl); } /* 4rem */
.m-0 { margin: 0; }

.p-xs { padding: var(--space-xs); }
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }

.pt-lg { padding-top: var(--space-lg); }
.pt-xl { padding-top: var(--space-xl); }

.pl-lg { padding-left: 1.5rem; }

/* Typography */
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.75rem; }

.text-muted { 
  color: var(--color-muted);
  line-height: 1.6;
}
.text-strong { font-weight: 600; }
.font-normal { font-weight: 400; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.leading-normal { line-height: 1.4; }
.leading-relaxed { line-height: 1.6; }
.leading-loose { line-height: 1.8; }

/* Color (token only) */
.bg-surface { background-color: var(--color-surface); }
.text-accent { 
  color: var(--color-accent);
  text-decoration: underline;
}

/* Layout */
.max-w-sm { max-width: 32rem; } /* 512px */
.max-w-md { max-width: 43.75rem; } /* 700px - most common */
.max-w-lg { max-width: 50rem; } /* 800px */
.max-w-xl { max-width: 56.25rem; } /* 900px */
.max-w-2xl { max-width: 56.25rem; } /* 900px - alias */

/* Component patterns */
.card-style {
  border: 1px solid var(--border);
  padding: var(--space-lg);
  border-radius: var(--radius-md);
}

.btn-primary-inline {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background: var(--color-accent);
  color: white;
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: 500;
}

.btn-primary-full {
  width: 100%;
  padding: var(--space-md);
  font-size: 1.1rem;
}

.btn-secondary-full {
  width: 100%;
  padding: var(--space-md);
  font-size: 1.1rem;
  border: 1px solid var(--border);
}

/* Section dividers */
.section-divider {
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border);
}

/* =========================
   UTILITIES (LIMITED)
   ========================= */

/* Text */
.text-center { text-align: center; }

/* Display */
.flex { display: flex; }
.grid { display: grid; }
.hidden { display: none !important; }
.contact-modal {
  display: flex;
}
.contact-modal.hidden {
  display: none !important;
}
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.flex-wrap { flex-wrap: wrap; }

/* =========================
   HOMEPAGE HIERARCHY
   ========================= */

.home-hero {
  padding: var(--space-xl) 0;
}

.home-hero h1 {
  font-size: 2.5rem;
  line-height: 1.15;
  max-width: 47.5rem;
}

.home-subtitle {
  margin-top: var(--space-sm);
  font-size: 1.125rem;
  color: var(--color-muted);
  max-width: 45rem;
}

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

.home-section--muted {
  background: var(--color-surface);
}

.home-services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-lg);
}

.home-cta {
  margin-top: var(--space-xl);
  padding: var(--space-lg);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  text-align: center;
}

/* =========================
   SERVICE PAGE HIERARCHY
   ========================= */

.service-hero {
  padding: var(--space-xl) 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  margin-bottom: var(--space-xl);
}

.service-hero h1 {
  font-size: 2.25rem;
  line-height: 1.2;
  max-width: 45rem;
  margin-bottom: var(--space-md);
}

.service-subtitle {
  margin-top: var(--space-sm);
  font-size: 1.125rem;
  color: var(--color-muted);
  max-width: 45rem;
}

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

.service-section--muted {
  background: var(--color-surface);
  padding: var(--space-xl) var(--space-lg);
  margin: var(--space-xl) calc(var(--space-lg) * -1);
  border-radius: var(--radius-md);
}

.service-section-title {
  font-size: 1.5rem;
  margin-bottom: var(--space-md);
}

.service-proof {
  border-left: 4px solid var(--color-accent);
  padding-left: var(--space-md);
  margin: var(--space-md) 0;
}

.service-cta {
  margin-top: var(--space-xl);
  padding: var(--space-lg);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  text-align: center;
}

/* =========================
   OVERRIDES (for legacy compatibility)
   ========================= */

/* Ensure tokens cascade through legacy components */

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
}

.container {
  padding-left: var(--space-lg);
  padding-right: var(--space-lg);
}

/* Cards - ensure token authority */
.card {
  background: var(--color-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

/* Buttons - ensure token authority */
.button,
button:not(.trace-border-btn):not(.mobile-menu-toggle),
.btn,
[type="submit"] {
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
}

.button--primary,
.btn-primary,
button:not(.trace-border-btn):not(.mobile-menu-toggle),
.btn {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: white;
}

.button--primary:hover,
.btn-primary:hover,
button:not(.trace-border-btn):not(.mobile-menu-toggle):hover,
.btn:hover {
  background: var(--color-text);
  border-color: var(--color-text);
}

/* Typography - ensure token authority */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-mono);
  color: var(--color-text);
}

a {
  color: var(--color-accent);
}

/* Forms - ensure token authority */
input[type="text"],
input[type="email"],
input[type="url"],
input[type="search"],
textarea,
select {
  border-radius: var(--radius-md);
  border-color: var(--border);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--color-accent);
}

/* Footer */
footer {
  background: var(--color-surface);
  border-top-color: var(--border);
}

/* Header */
.header {
  border-bottom-color: var(--border);
}

