:root {
  /* Stitch Brand & Surface Tokens (DESIGN.md) */
  --surface: #faf8ff;
  --surface-dim: #d2d9f4;
  --surface-bright: #faf8ff;
  --surface-lowest: #ffffff;
  --surface-low: #f2f3ff;
  --surface-container: #eaedff;
  --surface-high: #e2e7ff;
  --surface-highest: #dae2fd;
  --on-surface: #131b2e;
  --on-surface-variant: #404944;
  --inverse-surface: #283044;
  --inverse-on-surface: #eef0ff;
  --outline: #707974;
  --outline-variant: #bfc9c3;

  /* Forest Emerald Primary & Growth Tertiary */
  --primary: #003527;
  --on-primary: #ffffff;
  --primary-container: #064e3b;
  --on-primary-container: #80bea6;
  --inverse-primary: #95d3ba;
  --primary-fixed: #b0f0d6;
  --on-primary-fixed: #002117;
  --tertiary: #003623;
  --on-tertiary: #ffffff;
  --tertiary-container: #004f35;
  --on-tertiary-container: #51c695;
  --tertiary-fixed: #85f8c4;

  /* Energetic Ember Orange Secondary */
  --secondary: #a73a00;
  --on-secondary: #ffffff;
  --secondary-hover: #7f2b00;
  --secondary-container: #fd651e;
  --secondary-fixed: #ffdbce;
  --secondary-fixed-dim: #ffb599;
  --on-secondary-fixed: #370e00;
  --on-secondary-fixed-variant: #7f2b00;

  /* Semantic Status */
  --error: #ba1a1a;
  --error-container: #ffdad6;
  --on-error-container: #93000a;
  --success: #064e3b;
  --success-bg: #b0f0d6;
  --success-text: #002117;

  /* Typography */
  --font-display: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-body: 'Manrope', 'Segoe UI', system-ui, -apple-system, sans-serif;

  /* Radii & Depth */
  --radius-xs: 0.25rem;
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-full: 9999px;

  --shadow-subtle: 0 1px 3px rgba(6, 78, 59, 0.04), 0 6px 16px -4px rgba(15, 23, 42, 0.04);
  --shadow-card: 0 8px 24px -4px rgba(6, 78, 59, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-elevated: 0 18px 42px -6px rgba(6, 78, 59, 0.12), 0 4px 12px -2px rgba(15, 23, 42, 0.06);
  --shadow-ember: 0 10px 24px -6px rgba(167, 58, 0, 0.28);

  --container-max: 1280px;
  --header-height: 80px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--on-surface);
  background-color: var(--surface);
  overscroll-behavior: none;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  color: var(--on-surface);
  text-wrap: balance;
}

p {
  margin: 0;
  text-wrap: pretty;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

:focus-visible {
  outline: 2px solid var(--secondary-container);
  outline-offset: 2px;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  padding: 12px 18px;
  background: var(--primary);
  color: var(--on-primary);
  font-family: var(--font-display);
  font-weight: 700;
  border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
  left: 12px;
  top: 12px;
}

.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 24px;
}

@media (min-width: 1024px) {
  .container {
    padding: 0 48px;
  }
}

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  line-height: 1;
  user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

.icon-filled {
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

/* Shared Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.25;
  cursor: pointer;
  transition-property: background-color, border-color, color, box-shadow, transform;
  transition-duration: 160ms;
  transition-timing-function: ease-out;
}

.btn:active {
  transform: scale(0.98);
}

.btn[disabled] {
  opacity: 0.72;
  cursor: not-allowed;
  transform: none;
}

.btn-lg {
  min-height: 54px;
  padding: 14px 24px;
  border-radius: var(--radius-md);
  font-weight: 700;
}

.btn-full {
  width: 100%;
}

.btn-ember {
  background-color: var(--secondary);
  color: var(--on-secondary);
  box-shadow: var(--shadow-ember);
}

.btn-ember:hover {
  background-color: var(--secondary-hover);
}

.btn-primary {
  background-color: var(--primary);
  color: var(--on-primary);
  box-shadow: var(--shadow-subtle);
}

.btn-primary:hover {
  background-color: var(--primary-container);
}

.btn-soft {
  background-color: var(--surface-low);
  color: var(--on-surface);
}

.btn-soft:hover {
  background-color: var(--surface-high);
}

.btn-card {
  background-color: var(--surface-lowest);
  color: var(--primary);
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: var(--shadow-subtle);
}

.btn-card:hover {
  background-color: var(--surface-container);
}

.btn-muted {
  background-color: var(--surface-container);
  color: var(--on-surface);
}

.btn-muted:hover {
  background-color: var(--surface-high);
}

/* Badges & Chips */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  max-width: 100%;
}

.pill-emerald {
  background-color: var(--primary-fixed);
  color: var(--on-primary-fixed);
}

.pill-ember {
  background-color: var(--secondary-fixed);
  color: var(--on-secondary-fixed);
}

.pill-surface-high {
  background-color: var(--surface-high);
  color: var(--primary);
  box-shadow: var(--shadow-subtle);
}

.pill-surface {
  background-color: var(--surface-container);
  color: var(--on-surface);
}

.pill-dark-glass {
  background-color: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

/* Swatches (for brand-logos.php — zero inline styles for CSP) */
.swatch-primary { background-color: var(--primary); }
.swatch-primary-container { background-color: var(--primary-container); }
.swatch-emerald { background-color: #10B981; }
.swatch-secondary { background-color: var(--secondary); }
.swatch-ember { background-color: var(--secondary-container); }
.swatch-fixed { background-color: var(--secondary-fixed-dim); }

/* Spinner */
.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: tfr-spin 0.7s linear infinite;
}

@keyframes tfr-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes tfr-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
