/* =========================================================
   nutriAI Design System — Foundations
   Fonts: Inter (local) + Instrument Serif + JetBrains Mono (Google)
   Brand colors pulled directly from the nutriAI logomark.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Instrument+Serif:ital@0;1&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* ---------- Brand colors — from logomark ---------- */
  /* AdOpsify primary: cobalt blue + electric violet, lifted from the mark. */
  --brand-cobalt:  #2E5BFF;
  --brand-violet:  #6E2BD9;
  --brand-cyan:    #45B6FF;
  --brand-crimson: #C43E5A;
  --brand-orange:  #E87B35;
  --brand-blue:    #4A6CF7;
  --brand-teal:    #38B894;

  /* Cobalt scale — primary */
  --cobalt-50:  #EEF3FF;
  --cobalt-100: #D6E1FF;
  --cobalt-300: #8FA8FF;
  --cobalt-500: #2E5BFF;
  --cobalt-600: #2347D9;
  --cobalt-700: #1A33A8;
  --cobalt-900: #0E1C66;

  /* Violet scale — secondary */
  --violet-50:  #F1EAFE;
  --violet-100: #DCC9FB;
  --violet-300: #A77AEC;
  --violet-500: #6E2BD9;
  --violet-700: #4F1CA0;
  --violet-900: #2A0F58;

  /* Crimson scale */
  --crimson-50:  #FBEDF0;
  --crimson-100: #F5D0D8;
  --crimson-500: #C43E5A;
  --crimson-700: #8E2840;

  /* Orange scale */
  --orange-50:  #FDF1E6;
  --orange-100: #FAD9B8;
  --orange-500: #E87B35;
  --orange-700: #B85C1F;

  /* Blue scale */
  --blue-50:   #EEF1FE;
  --blue-100:  #D1DAFC;
  --blue-500:  #4A6CF7;
  --blue-700:  #2F4AC2;

  /* Teal scale — primary accent (food/health cue) */
  --teal-50:   #E6F6F0;
  --teal-100:  #C3E9D8;
  --teal-300:  #7AD2B1;
  --teal-500:  #38B894;
  --teal-600:  #2A9F7C;
  --teal-700:  #1F7A5D;
  --teal-900:  #103D2F;

  /* Neutrals (warm) */
  --ink-950: #0E120E;
  --ink-900: #121410;
  --ink-700: #2A2E28;
  --ink-500: #5B6158;
  --ink-400: #7B8279;
  --ink-300: #9AA196;
  --ink-200: #C4C9BF;
  --ink-100: #E8E4DB;
  --ink-50:  #F2EFE8;
  --paper:   #FAF8F4;
  --paper-raised: #FFFFFF;

  /* Semantic accents (mapped to brand hues) */
  --warn-500:    var(--orange-500);
  --error-500:   var(--crimson-500);
  --success-500: var(--teal-600);
  --info-500:    var(--blue-500);

  /* ---------- Semantic color tokens ---------- */
  --bg:           var(--paper);
  --bg-raised:    var(--paper-raised);
  --bg-sunken:    var(--ink-50);
  --bg-inverse:   var(--ink-900);

  --fg:           var(--ink-900);
  --fg-muted:     var(--ink-500);
  --fg-subtle:    var(--ink-300);
  --fg-inverse:   var(--paper);
  --fg-on-accent: var(--paper);    /* teal is mid-tone — use paper */

  --border:       var(--ink-100);
  --border-strong:var(--ink-200);

  --accent:       var(--cobalt-500);
  --accent-hover: var(--cobalt-600);
  --accent-press: var(--cobalt-700);
  --accent-soft:  var(--cobalt-50);

  /* Legacy aliases — old code says lime/teal, we route everything to cobalt now. */
  --lime-50:  var(--cobalt-50);
  --lime-100: var(--cobalt-100);
  --lime-200: var(--cobalt-100);
  --lime-300: var(--cobalt-300);
  --lime-500: var(--cobalt-500);
  --lime-600: var(--cobalt-600);
  --lime-700: var(--cobalt-700);
  --lime-900: var(--cobalt-900);

  /* Brand gradient — used in CTAs, hero accents, mark glow */
  --brand-gradient: linear-gradient(135deg, var(--brand-cyan) 0%, var(--brand-cobalt) 45%, var(--brand-violet) 100%);
  --brand-gradient-soft: linear-gradient(135deg, color-mix(in oklab, var(--brand-cyan) 20%, transparent) 0%, color-mix(in oklab, var(--brand-violet) 20%, transparent) 100%);

  /* ---------- Typography — families ---------- */
  --font-display: 'Instrument Serif', 'Times New Roman', serif;
  --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

  /* ---------- Type scale ---------- */
  --fs-12: 12px; --fs-14: 14px; --fs-16: 16px; --fs-18: 18px;
  --fs-22: 22px; --fs-28: 28px; --fs-36: 36px; --fs-48: 48px;
  --fs-64: 64px; --fs-96: 96px; --fs-128: 128px;

  --lh-tight:   1.08;
  --lh-display: 1.12;
  --lh-snug:    1.3;
  --lh-body:    1.5;
  --lh-loose:   1.7;

  --tr-tight:  -0.02em;
  --tr-snug:   -0.01em;
  --tr-normal: 0;
  --tr-wide:   0.08em;

  /* ---------- Spacing ---------- */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px;
  --s-6: 24px; --s-8: 32px; --s-12: 48px; --s-16: 64px;
  --s-24: 96px; --s-32: 128px;

  /* ---------- Radii ---------- */
  --r-sm: 8px; --r-md: 14px; --r-lg: 22px; --r-xl: 32px; --r-full: 9999px;

  /* ---------- Shadows ---------- */
  --sh-sm: 0 1px 2px rgba(18,20,16,0.04);
  --sh-md: 0 4px 12px rgba(18,20,16,0.06);
  --sh-lg: 0 12px 32px rgba(18,20,16,0.08);
  --sh-xl: 0 24px 64px rgba(18,20,16,0.12);

  /* ---------- Motion ---------- */
  --ease-out-quart: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out-expo:  cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out:    cubic-bezier(0.65, 0, 0.35, 1);
  --dur-micro: 180ms; --dur-std: 450ms; --dur-slow: 900ms;

  /* ---------- Layout ---------- */
  --nav-h: 72px; --tabbar-h: 84px; --maxw: 1280px; --gutter: 96px;
}

/* ===================== BASE ===================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-16);
  line-height: var(--lh-body);
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ===================== TYPE ===================== */
.eyebrow, .ds-eyebrow {
  font-family: var(--font-sans);
  font-size: var(--fs-12); font-weight: 500;
  letter-spacing: var(--tr-wide); text-transform: uppercase;
  color: var(--fg-muted);
}

.display-xl {
  font-family: var(--font-display);
  font-size: clamp(64px, 10vw, 128px);
  line-height: var(--lh-tight); letter-spacing: var(--tr-tight);
  font-weight: 400; color: var(--fg);
}
.display-lg {
  font-family: var(--font-display);
  font-size: clamp(48px, 7vw, 96px);
  line-height: var(--lh-display); letter-spacing: var(--tr-tight);
  font-weight: 400;
}

h1, .h1 { font-family: var(--font-sans); font-size: var(--fs-48); line-height: var(--lh-tight); letter-spacing: var(--tr-tight); font-weight: 700; margin: 0; }
h2, .h2 { font-family: var(--font-sans); font-size: var(--fs-36); line-height: var(--lh-display); letter-spacing: var(--tr-snug); font-weight: 700; margin: 0; }
h3, .h3 { font-family: var(--font-sans); font-size: var(--fs-28); line-height: var(--lh-snug); letter-spacing: var(--tr-snug); font-weight: 600; margin: 0; }
h4, .h4 { font-family: var(--font-sans); font-size: var(--fs-22); line-height: var(--lh-snug); font-weight: 600; margin: 0; }

/* Non-hero section headings use simple sans-serif */
section h1, section h2, section h3, section h4, section .h1, section .h2, section .h3, section .h4 { font-family: var(--font-sans) !important; }

p, .body { font-size: var(--fs-16); line-height: var(--lh-body); color: var(--fg); margin: 0; }
.body-lg { font-size: var(--fs-18); line-height: var(--lh-body); }
.body-sm { font-size: var(--fs-14); line-height: var(--lh-body); color: var(--fg-muted); }
.caption { font-size: var(--fs-12); line-height: var(--lh-body); color: var(--fg-muted); }

.num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.num-xl { font-family: var(--font-mono); font-size: var(--fs-96); font-weight: 500; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }

.serif-italic { font-family: var(--font-display); font-style: italic; font-weight: 400; }

a { color: inherit; text-decoration: none; }
a.link {
  color: var(--fg);
  background-image: linear-gradient(var(--fg), var(--fg));
  background-size: 0% 1px; background-repeat: no-repeat; background-position: 0 100%;
  transition: background-size var(--dur-std) var(--ease-out-quart);
}
a.link:hover { background-size: 100% 1px; }

code { font-family: var(--font-mono); font-size: 0.92em; background: var(--bg-sunken); padding: 2px 6px; border-radius: var(--r-sm); border: 1px solid var(--border); }
::selection { background: var(--cobalt-100); color: var(--ink-900); }

/* ===================== UTILITY ===================== */
.brand-grad-text {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.eyebrow-mono {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cobalt-700);
  font-weight: 600;
}

/* -----------------------------
   Responsive typography & measure
   - Prevent overly long/stretched lines (max-width by measure)
   - Provide tuned type scale for mobile / tablet / desktop
   - Keep headings beautiful and readable across devices
   ----------------------------- */

/* Prevent stretched text and enable hyphenation */
p, h1, h2, h3, h4, .body, .body-lg, .body-sm, .display-xl, .display-lg {
  hyphens: auto;
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 70ch;
}

/* Global overflow guard and responsive media handling */
html, body { overscroll-behavior-x: contain; }
body { overflow-x: hidden; }

/* Make media responsive */
img, picture, video, iframe {
  max-width: 100% !important;
  height: auto !important;
  display: block !important;
}

/* Tighten container gutters on small viewports to avoid computed over-widths */
@media (max-width: 599px) {
  .container, main, article, .content { padding-left: 16px !important; padding-right: 16px !important; }
}

/* Ensure service cards and FAQ items never force horizontal layout */
.scard { display: block !important; width: 100% !important; max-width: 100% !important; box-sizing: border-box !important; }
.scard * { min-width: 0 !important; }
.faq-row { width: 100% !important; box-sizing: border-box !important; }
.faq-row button { white-space: normal !important; text-align: left !important; }


/* Layout container helper — limits measure on wide screens */
.container, main, article, .content {
  max-width: var(--maxw);
  margin-left: auto;
  margin-right: auto;
  padding-left: clamp(16px, 4vw, var(--gutter));
  padding-right: clamp(16px, 4vw, var(--gutter));
}

/* Mobile first: compact, slightly smaller type */
@media (max-width: 599px) {
  :root {
    --fs-16: 15px;
    --fs-18: 16px;
    --fs-22: 18px;
    --fs-28: 20px;
    --fs-36: 24px;
    --fs-48: 32px;
    --nav-h: 64px;
    --gutter: 24px;
  }
  .display-xl { font-size: clamp(40px, 10vw, 64px); }
  .display-lg { font-size: clamp(28px, 7vw, 48px); }
}

/* Tablet: use hamburger nav (see Nav.jsx breakpoint), slightly larger type */
@media (min-width: 600px) and (max-width: 1023px) {
  :root {
    --fs-16: 16px;
    --fs-18: 17px;
    --fs-22: 20px;
    --fs-28: 24px;
    --fs-36: 30px;
    --fs-48: 40px;
    --nav-h: 72px;
    --gutter: 48px;
  }
  .display-xl { font-size: clamp(48px, 9vw, 96px); }
  .display-lg { font-size: clamp(36px, 6.5vw, 72px); }
}

/* Desktop: full nav and larger, comfortable type scale */
@media (min-width: 1024px) {
  :root {
    --fs-16: 16px;
    --fs-18: 18px;
    --fs-22: 22px;
    --fs-28: 28px;
    --fs-36: 36px;
    --fs-48: 48px;
    --nav-h: 84px;
    --gutter: 96px;
  }
  .display-xl { font-size: clamp(64px, 6.5vw, 128px); }
  .display-lg { font-size: clamp(48px, 5.5vw, 96px); }
}

@media (min-width: 1200px) {
  h1, h2, h3, p, .body { max-width: 72ch; }
}

/* Nav visibility controlled by CSS to ensure desktop shows full nav */
.nav-links { display: none; }
.nav-toggle { display: inline-grid; }

@media (min-width: 1024px) {
  .nav-links { display: flex !important; align-items: center; gap: 32px; }
  .nav-toggle { display: none !important; }
}

/* Stronger measure protection to override inline max-widths */
p, h1, h2, h3, h4, .body, .body-lg, .body-sm, .display-xl, .display-lg {
  max-width: 70ch !important;
}

/* Footer responsive grid */
@media (max-width: 599px) {
  .footer-grid {
    grid-template-columns: 1fr !important;
  }
}

/* -----------------------------
   Pixel-consistency overrides
   - Ensure hero text respects container width
   - Standardize header height/padding across breakpoints
   - Normalize footer horizontal padding for symmetry
   ----------------------------- */
.page-hero, .hero {
  width: 100%;
  box-sizing: border-box;
}
.page-hero h1, .hero h1 {
  display: block;
  max-width: min(70ch, 100%);
  width: 100%;
  margin-left: 0;
  margin-right: 0;
  overflow-wrap: break-word;
  hyphens: auto;
}
/* Stronger overrides to ensure consistent rendering even when other rules exist */
main h1, .page-hero h1, .hero h1, h1 {
  max-width: min(70ch, 100%) !important;
  width: 100% !important;
  box-sizing: border-box !important;
  overflow-wrap: break-word !important;
  hyphens: auto !important;
}

header, nav[role="navigation"] {
  height: var(--nav-h);
  min-height: var(--nav-h);
  align-items: center;
}

/* Restore and pin logo to expected header location */
header, nav[role="navigation"] {
  position: relative;
  z-index: 50;
  display: flex;
  align-items: center;
}

header img, nav img, .brand img, .logo img, .site-mark img {
  position: relative !important;
  top: 0 !important;
  transform: none !important;
  margin: 0 !important;
  display: inline-block !important;
}

/* Constrain logo size to header to prevent overlap */
header img, nav img, .brand img, .logo img, .site-mark img {
  max-height: calc(var(--nav-h) - 16px) !important;
  height: auto !important;
  width: auto !important;
}

/* Footer logo: keep smaller than header logo for visual hierarchy */
footer img, .footer img, .footer-grid img {
  max-height: 40px !important;
  height: auto !important;
  width: auto !important;
  display: inline-block !important;
}

/* If footer-brand container exists, ensure it doesn't scale logo up */
.footer .brand img, .footer-grid .brand img {
  max-height: 40px !important;
  margin: 0 !important;
}

/* Make header logo match footer size for consistent visual weight */
header img, nav img, .brand img, .logo img, .site-mark img {
  max-height: 40px !important;
  height: auto !important;
  width: auto !important;
}

/* Use site sans font for text adjacent to the logo */
header .brand, header .site-mark, header .brand a, header .brand span, .logo-text, .site-title, nav .brand {
  font-family: var(--font-sans) !important;
  font-weight: 600 !important;
}

/* Ensure brand container sits flush to left edge of header */
.brand, .site-mark, .logo { margin-left: 0 !important; padding-left: 0 !important; }

footer, .footer {
  padding: clamp(24px, 6vw, 80px) clamp(16px, 4vw, var(--gutter)) 40px !important;
}



@media (min-width: 600px) and (max-width: 1023px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* =====================
   Global pixel-perfect overrides
   - Harmonize heading scales with clamp() for consistent rendering
   - Tame hero spacing and ensure measure doesn't exceed container
   - Ensure footer grid on desktop is the expected 2fr/1fr/1fr/1fr layout
   ===================== */

/* Heading scale (safe, overrides to align display across pages) */
h1 {
  font-size: clamp(32px, 5.2vw, 72px) !important;
  line-height: 1.08 !important;
  letter-spacing: var(--tr-tight) !important;
  margin: 0 0 12px 0 !important;
}

h2 {
  font-size: clamp(22px, 3.6vw, 44px) !important;
  line-height: var(--lh-display) !important;
  margin: 0 0 10px 0 !important;
}

h3 { font-size: clamp(18px, 3vw, 28px) !important; line-height: var(--lh-snug) !important; margin: 0 0 8px 0 !important; }
h4 { font-size: clamp(16px, 2.4vw, 22px) !important; line-height: var(--lh-snug) !important; margin: 0 0 6px 0 !important; }

/* Hero measure + padding */
.page-hero, .hero {
  padding-top: clamp(32px, 8vw, 120px) !important;
  padding-bottom: clamp(20px, 5vw, 80px) !important;
}
.page-hero h1, .hero h1, main h1 {
  max-width: min(70ch, var(--maxw)) !important;
  margin-left: auto !important;
  margin-right: auto !important;
  text-wrap: balance;
}

/* Footer desktop grid */
@media (min-width: 1024px) {
  .footer-grid { grid-template-columns: 2fr 1fr 1fr 1fr !important; gap: clamp(24px, 3vw, 48px) !important; }
}

/* Form controls and CTAs: consistent sizing */
input, textarea, select, button {
  font-family: var(--font-sans) !important;
  font-size: var(--fs-16) !important;
  line-height: var(--lh-body) !important;
}

/* Targeted overflow fixes for cards and FAQ rows */
a.scard, .scard, .scard * {
  white-space: normal !important;
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
}

.faq-row, .faq-row * {
  white-space: normal !important;
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
}

.services, .services .scard {
  box-sizing: border-box !important;
}

/* Allow flex/grid children to shrink to prevent horizontal overflow */
.scard { min-width: 0 !important; }
.scard > * { min-width: 0 !important; }
.faq-row { min-width: 0 !important; }
.faq-row * { min-width: 0 !important; }

/* Force cards to respect container width and avoid internal horizontal scroll */
.scard {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow: visible !important;
}

/* Ensure FAQ container respects its container width */
.service-faq, .service-faq > div, .service-faq * {
  box-sizing: border-box !important;
  max-width: 100% !important;
}

