/* Cynergy Automation — site styles */
@import url('./tokens.css');

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  overflow-x: hidden;
  max-width: 100vw;
  background: var(--color-white);
  color: var(--fg-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; height: auto; display: block; }

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 64px);
}

/* ---- Headings (marketing site: not uppercase, sharper weights) ---- */
h1, h2, h3, .h1, .h2, .h3 { text-transform: none !important; margin-block: 0; }
.display-xl { font-family: var(--font-display); font-weight: 800; font-size: clamp(40px, 5.4vw, 76px); line-height: 1.02; letter-spacing: -0.02em; margin: 0; }
.display-lg { font-family: var(--font-display); font-weight: 800; font-size: clamp(34px, 4.2vw, 56px); line-height: 1.05; letter-spacing: -0.018em; margin: 0; }
.h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(32px, 3.4vw, 48px); line-height: 1.1; letter-spacing: -0.015em; margin: 0; }
.h2 { font-family: var(--font-heading); font-weight: 700; font-size: clamp(24px, 2.2vw, 32px); line-height: 1.2; letter-spacing: -0.01em; margin: 0; }
.h3 { font-family: var(--font-heading); font-weight: 700; font-size: 19px; line-height: 1.3; margin: 0; letter-spacing: -0.005em; }
.lead { font-family: var(--font-body); font-size: clamp(16px, 1.25vw, 19px); line-height: 1.55; color: var(--fg-secondary); }
.body { font-family: var(--font-body); font-size: 15px; line-height: 1.6; color: var(--fg-secondary); }
.mono { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }

.section.dark .lead, .section.dark .body { color: var(--color-gray); }

/* ---- Eyebrow ---- */
.eyebrow {
  font-family: var(--font-heading);
  font-weight: 700; font-size: 12px;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--color-blue);
  display: inline-flex; align-items: center; gap: 12px;
}
.eyebrow::before {
  content: ""; display: inline-block; width: 28px; height: 1px; background: currentColor;
}
.eyebrow.on-dark { color: var(--color-blue); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-heading); font-weight: 700;
  font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 13px 22px; border-radius: 2px;
  border: 1px solid transparent;
  transition: all 180ms var(--ease-standard);
  cursor: pointer; white-space: nowrap;
}
.btn-lg { padding: 16px 26px; font-size: 13px; }
.btn-primary { background: var(--color-blue); color: #fff; border-color: var(--color-blue); }
.btn-primary:hover { background: var(--color-blue-deep); border-color: var(--color-blue-deep); }
.btn-ghost-light { background: transparent; color: var(--color-navy); border-color: var(--color-navy); }
.btn-ghost-light:hover { background: var(--color-navy); color: #fff; }
.btn-ghost-dark { background: transparent; color: #fff; border-color: rgba(255,255,255,0.5); }
.btn-ghost-dark:hover { background: #fff; color: var(--color-navy); border-color: #fff; }

/* ---- Sections ---- */
.section { padding: clamp(72px, 9vw, 128px) 0; position: relative; }
.section.dark { background: var(--color-navy); color: #fff; }
.section.fog { background: var(--color-fog); }

/* ---- Dark-surface contrast fix ----
   Inside any element with a navy background, swap --color-blue to a lighter blue
   so small mono eyebrows, case labels, and link accents stay readable (WCAG AA). */
.section.dark,
footer,
.dark-surface {
  --color-blue: var(--color-blue-on-dark);
}

/* ---- Dimension callouts (engineering drawings) ---- */
.dim-line {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-blue);
}

/* ---- Corner ticks on image blocks ---- */
.ticks { position: relative; }
.ticks::before, .ticks::after,
.ticks > .tick-tr, .ticks > .tick-bl {
  content: ""; position: absolute; width: 12px; height: 12px; pointer-events: none;
  border-color: var(--color-blue);
}
.ticks::before { top: 10px; left: 10px; border-left: 1px solid; border-top: 1px solid; border-color: inherit; }
.ticks::after { bottom: 10px; right: 10px; border-right: 1px solid; border-bottom: 1px solid; border-color: inherit; }
.ticks.on-dark::before, .ticks.on-dark::after { border-color: rgba(43,127,255,0.6); }

/* ---- Placeholder image blocks ---- */
.placeholder {
  position: relative; overflow: hidden;
  background: var(--color-navy);
  display: grid; place-items: center;
  color: var(--color-gray);
}
.placeholder::before {
  content: "";
  position: absolute; inset: 0;
  background:
    linear-gradient(135deg, transparent 48%, rgba(43,127,255,0.08) 49%, rgba(43,127,255,0.08) 51%, transparent 52%) 0 0 / 18px 18px,
    radial-gradient(circle at 30% 40%, rgba(43,127,255,0.18), transparent 60%),
    radial-gradient(circle at 75% 75%, rgba(43,127,255,0.08), transparent 55%);
}
.placeholder > * { position: relative; }

/* ---- Technical grid overlay ---- */
.grid-overlay::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 64px 64px;
}

/* ---- Link on light (underline animation) ---- */
.inline-link {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-heading); font-weight: 700;
  font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--color-blue);
  padding-bottom: 4px;
  border-bottom: 2px solid var(--color-blue);
  transition: gap 180ms var(--ease-standard);
}
.inline-link:hover { gap: 14px; }

/* ---- Tweaks panel ---- */
.tweaks-panel {
  position: fixed; bottom: 20px; right: 20px;
  background: #fff;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  width: 280px;
  padding: 16px 18px;
  font-family: var(--font-body);
}
.tweaks-panel h4 {
  font-family: var(--font-heading); font-weight: 700;
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--color-navy); margin: 0 0 12px;
}
.tweaks-panel .row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-top: 1px solid var(--border-subtle);
  font-size: 13px; color: var(--color-slate);
}
.tweaks-panel .row:first-of-type { border-top: none; }
.tweaks-panel .chip {
  font-family: var(--font-mono); font-size: 10px;
  padding: 4px 8px; background: var(--color-fog);
  color: var(--color-navy); border-radius: 2px;
  cursor: pointer; border: 1px solid var(--border-subtle);
  letter-spacing: 0.08em;
}
.tweaks-panel .chip.active { background: var(--color-navy); color: #fff; border-color: var(--color-navy); }
.tweaks-panel .toggle {
  width: 34px; height: 20px; border-radius: 12px;
  background: var(--color-fog); border: 1px solid var(--border-default);
  position: relative; cursor: pointer;
}
.tweaks-panel .toggle::after {
  content: ""; position: absolute; top: 1px; left: 1px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  transition: transform 180ms var(--ease-standard);
}
.tweaks-panel .toggle.on { background: var(--color-blue); border-color: var(--color-blue); }
.tweaks-panel .toggle.on::after { transform: translateX(14px); }

/* ---- Reveal on scroll (body text fades in) ---- */
.reveal { opacity: 1; transform: none; transition: opacity 600ms var(--ease-standard), transform 600ms var(--ease-standard); }
.reveal.pending { opacity: 0; transform: translateY(8px); }
.reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ================================================================
   MOBILE RESPONSIVE (<= 860px)
   Inline styles win over classes — we use attribute selectors + !important
   to stack grids, shrink padding, and make the site phone-legible.
   ================================================================ */
@media (max-width: 860px) {
  /* Stack every multi-column grid on mobile (except header — handled below) */
  :not(header) > [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    justify-items: center !important;
  }

  /* Stacked grid children: fill width up to a readable cap, centered in the row.
     !important on max-width overrides any inline maxWidth: px value.
     Left/right padding normalized to 20px so cards don't sit flush against the
     container edge (and so desktop patterns like `paddingLeft: 48` on every
     other cell don't survive the stack). Side borders removed — they draw
     vertical column dividers that make no sense stacked.
     Header is excluded so the logo/CTA/hamburger layout stays intact. */
  :not(header) > [style*="grid-template-columns"] > * {
    width: 100% !important;
    max-width: 560px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    justify-self: center !important;
    padding-left: 20px !important;
    padding-right: 20px !important;
    border-left: none !important;
    border-right: none !important;
  }

  /* Non-header grid-children that contain huge inline display text shouldn't
     overflow — cap inline headlines that set a fixed px value. */
  :not(header) > [style*="grid-template-columns"] > * [style*="font-size: 64"],
  :not(header) > [style*="grid-template-columns"] > * [style*="fontSize: 64"] {
    font-size: 44px !important;
  }

  /* Header keeps its 3-col layout (logo / nav / cta) and does NOT center children */
  header [style*="grid-template-columns"] {
    grid-template-columns: auto 1fr auto !important;
    justify-items: stretch !important;
    gap: 12px !important;
  }
  header [style*="grid-template-columns"] > * {
    max-width: none;
  }

  /* Shrink header logo so hamburger fits */
  header a[aria-label="Cynergy Automation"] { height: 32px !important; }
  header a[aria-label="Cynergy Automation"] img { height: 28px !important; }

  /* Mobile top bar: logo left, Request-a-quote centered, hamburger fixed right.
     The right-side cell is flex-positioned: CTA centers, hamburger absolute-right. */
  header nav.hide-mobile + div {
    position: relative !important;
    justify-content: center !important;
    width: 100% !important;
    min-width: 0 !important;
    padding-right: 76px !important;
    justify-content: flex-start !important;
  }
  /* Pull the logo closer to the left wall and the CTA closer to the logo:
     collapse the header grid gap on mobile. */
  header > .container {
    gap: 10px !important;
  }
  /* Belt-and-braces: guarantee a real gap between the button and the
     absolutely-positioned hamburger, even if container padding is overridden. */
  header nav.hide-mobile + div > a.btn {
    margin-right: 18px !important;
  }
  header nav.hide-mobile + div > a.btn {
    font-size: 10px !important;
    padding: 8px 12px !important;
    letter-spacing: 0.1em !important;
  }
  header .show-mobile {
    position: absolute !important;
    right: 0 !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    display: inline-flex !important;
  }

  /* Tighter section padding */
  .section { padding: 56px 0 !important; }

  /* Page-hero dark sections (About/Solutions/Contact) use inline paddingTop/Bottom: 120.
     Compound selector beats inline style. */
  section.dark-surface[style*="padding"] {
    padding-top: 56px !important;
    padding-bottom: 56px !important;
  }

  /* Utility top bar — hide the "Maryland Heights, Missouri" tagline
     so phone/email stay on one row */
  .utility-bar .util-location { display: none !important; }
  .utility-bar { font-size: 11px !important; }

  /* Hero: let content height follow content, not 100vh.
     Compound selector beats .container's mobile padding override. */
  .video-hero-content.container {
    width: 100% !important;
    min-height: auto !important;
    padding-top: 80px !important;
    padding-bottom: 60px !important;
  }

  /* Shrink display text a touch more on very small screens */
  .display-xl { font-size: clamp(34px, 8vw, 48px) !important; }
  .display-lg { font-size: clamp(28px, 7vw, 38px) !important; }
  .h1 { font-size: clamp(24px, 6vw, 32px) !important; }

  /* Form: fields stack */
  form[style*="grid-template-columns"] { gap: 16px !important; }

  /* Industries sidebar list should stack too */
  /* (handled by top-level rule) */

  /* Footer: 1.6fr 1fr 1fr 1fr → single column with tighter gap */
  footer [style*="grid-template-columns"] { gap: 32px !important; }

  /* Remove sticky positioning on mobile (about page story eyebrow) */
  [style*="position: sticky"] {
    position: static !important;
  }

  /* All multi-column grids stack fully to single column on mobile — do NOT
     keep 2-col for 3/4 col layouts; the cards are too cramped. */

  /* Hero button row: give a little breathing room */
  .hero-cta-row { flex-direction: column !important; align-items: stretch !important; }
  .hero-cta-row .btn { justify-content: center; width: 100%; }

  /* Reduce case study overlay text size */
  .container { padding: 0 20px !important; }
}

@media (max-width: 520px) {
  /* Very small phones: shrink buttons slightly */
  .btn-lg { padding: 14px 20px !important; font-size: 12px !important; }
  .section { padding: 44px 0 !important; }
  footer .container { padding-top: 48px !important; padding-bottom: 24px !important; }
}
