/* ==========================================================================
   UpSynQ — site foundation
   Tokens, base type, layout primitives and shared components (header,
   footer, buttons, labels, forms). Page-specific styles live in their own
   file (e.g. home.css). See docs/website/DESIGN_SYSTEM.md.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* --------------------------------------------------------------------------
   Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Brand core — upsynq-logo-final/README.md */
  --cream:            #F9F5EC;
  --ink:              #1A1612;
  --terracotta:       #A8412A;   /* on cream/white only */
  --terracotta-light: #E0795C;   /* terracotta on ink — #A8412A fails contrast there */

  /* Supporting neutrals (derived from ink/cream) */
  --cream-warm:  #F2ECDC;
  --cream-deep:  #E8E0CA;
  --ink-mid:     #3D342A;
  --ink-soft:    #6A5D4D;
  --ink-faint:   #9A8B75;
  --ink-raised:  #241F1A;        /* panels on ink */
  --ink-line:    #3A322A;        /* rules on ink */
  --rule:        #D4C8AA;
  --rule-soft:   #E6DCC2;
  --on-ink-soft: #C9BFA6;        /* secondary text on ink */
  --positive:    #4E6B3A;        /* "feasible" — used sparingly */

  /* Type */
  --font-display: 'Sora', system-ui, sans-serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;

  --fs-display: clamp(2.6rem, 1.4rem + 4.6vw, 5.1rem);
  --fs-h2:      clamp(1.9rem, 1.2rem + 2.4vw, 3.1rem);
  --fs-h3:      clamp(1.2rem, 1.05rem + .5vw, 1.45rem);
  --fs-lede:    clamp(1.08rem, 1rem + .35vw, 1.3rem);
  --fs-body:    1.0625rem;
  --fs-small:   .9rem;
  --fs-label:   .72rem;

  /* Layout */
  --page-max: 1240px;
  --gutter:   clamp(20px, 5vw, 64px);
  --section-y: clamp(72px, 9vw, 128px);
  --header-h: 72px;

  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.08; letter-spacing: -0.025em; margin: 0; }
p { margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--terracotta); outline-offset: 3px; border-radius: 2px; }
.on-ink :focus-visible, .site-footer :focus-visible { outline-color: var(--terracotta-light); }

.visually-hidden {
  position: absolute !important; 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: 12px; top: -48px; z-index: 100;
  background: var(--ink); color: var(--cream); padding: 10px 16px; text-decoration: none;
  font-weight: 600; transition: top .2s;
}
.skip-link:focus { top: 12px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* --------------------------------------------------------------------------
   Layout primitives
   -------------------------------------------------------------------------- */
.wrap { max-width: var(--page-max); margin: 0 auto; padding: 0 var(--gutter); }
.section { padding: var(--section-y) 0; position: relative; }
.section + .section { border-top: 1px solid var(--rule); }
.section--warm { background: var(--cream-warm); }
.section--ink { background: var(--ink); color: var(--cream); border-top-color: var(--ink) !important; }
.section--ink + .section { border-top-color: transparent; }

.section-head { max-width: 900px; margin-bottom: clamp(36px, 5vw, 64px); }
.section-head h2 { font-size: var(--fs-h2); }
.section-head .lede { margin-top: 20px; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: var(--terracotta);
  margin-bottom: 18px;
}
.eyebrow::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.on-ink .eyebrow, .section--ink .eyebrow { color: var(--terracotta-light); }

.lede { font-size: var(--fs-lede); line-height: 1.55; color: var(--ink-mid); max-width: 680px; }
.section--ink .lede { color: var(--on-ink-soft); }

/* Small mono label used for status / measurement category */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: .68rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-soft);
  border: 1px solid var(--rule); padding: 4px 8px; line-height: 1.2; white-space: nowrap;
}
.tag--live    { color: var(--positive); border-color: color-mix(in srgb, var(--positive) 45%, transparent); }
.tag--accent  { color: var(--terracotta); border-color: color-mix(in srgb, var(--terracotta) 45%, transparent); }
.section--ink .tag, .on-ink .tag { color: var(--on-ink-soft); border-color: var(--ink-line); }
.on-ink .tag--live { color: #9DBF7E; border-color: color-mix(in srgb, #9DBF7E 45%, transparent); }
.section--ink .tag--accent, .on-ink .tag--accent { color: var(--terracotta-light); border-color: color-mix(in srgb, var(--terracotta-light) 45%, transparent); }

.illustrative {
  font-family: var(--font-mono); font-size: .66rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-soft);
}

/* --------------------------------------------------------------------------
   Buttons & links
   -------------------------------------------------------------------------- */
.btn {
  --btn-bg: var(--ink); --btn-fg: var(--cream); --btn-bd: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 12px 22px;
  background: var(--btn-bg); color: var(--btn-fg); border: 1px solid var(--btn-bd);
  font-family: var(--font-body); font-size: 1rem; font-weight: 600; line-height: 1.2;
  text-decoration: none; cursor: pointer; border-radius: 0;
  transition: background .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease);
}
.btn:hover { --btn-bg: var(--terracotta); --btn-bd: var(--terracotta); }
.btn .arrow { transition: transform .2s var(--ease); }
.btn:hover .arrow { transform: translateX(3px); }
.btn--ghost { --btn-bg: transparent; --btn-fg: var(--ink); --btn-bd: var(--ink); }
.btn--ghost:hover { --btn-bg: var(--ink); --btn-fg: var(--cream); --btn-bd: var(--ink); }
.btn--small { min-height: 40px; padding: 8px 16px; font-size: .92rem; }
.section--ink .btn { --btn-bg: var(--cream); --btn-fg: var(--ink); --btn-bd: var(--cream); }
.section--ink .btn:hover { --btn-bg: var(--terracotta-light); --btn-bd: var(--terracotta-light); --btn-fg: var(--ink); }
.section--ink .btn--ghost { --btn-bg: transparent; --btn-fg: var(--cream); --btn-bd: var(--on-ink-soft); }

.text-link {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; text-decoration: none; color: var(--ink);
  border-bottom: 1px solid currentColor; padding-bottom: 2px;
}
.text-link:hover { color: var(--terracotta); }
.section--ink .text-link { color: var(--cream); }
.section--ink .text-link:hover { color: var(--terracotta-light); }

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--cream) 94%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  -webkit-backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.site-header.is-scrolled { border-bottom-color: var(--rule); }
.site-header__inner {
  max-width: var(--page-max); margin: 0 auto; padding: 0 var(--gutter);
  height: var(--header-h); display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.brand { display: flex; align-items: center; flex-shrink: 0; }
.brand picture { display: block; }
/* Horizontal lockup; below 480px <picture> swaps to the wordmark only (never the mark alone) */
.brand__logo { height: 30px; width: auto; }

.site-nav { display: flex; align-items: center; gap: 30px; }
.site-nav__list { display: flex; align-items: center; gap: 28px; list-style: none; margin: 0; padding: 0; }
.site-nav__list a {
  font-size: .95rem; font-weight: 500; color: var(--ink-mid); text-decoration: none;
  padding: 6px 0; border-bottom: 1px solid transparent; transition: color .15s, border-color .15s;
}
.site-nav__list a:hover, .site-nav__list a[aria-current="true"], .site-nav__list > li > a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--terracotta); }

/* Solutions disclosure menu (click / keyboard; not hover-only) */
.site-nav__group { position: relative; }
.site-nav__trigger {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 0; background: none; border: 0; cursor: pointer;
  font-size: .95rem; font-weight: 500; line-height: 1.6; color: var(--ink-mid); border-bottom: 1px solid transparent;
}
.site-nav__trigger::after { content: ''; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-2px) rotate(45deg); transition: transform .2s; }
.site-nav__trigger[aria-expanded="true"]::after { transform: translateY(1px) rotate(-135deg); }
.site-nav__trigger:hover, .site-nav__group:has([aria-current="page"]) .site-nav__trigger { color: var(--ink); border-bottom-color: var(--terracotta); }
.site-nav__menu {
  list-style: none; margin: 0; padding: 8px 0; position: absolute; top: calc(100% + 10px); left: -16px; min-width: 260px;
  background: var(--cream); border: 1px solid var(--ink); display: none; z-index: 60;
}
.site-nav__trigger[aria-expanded="true"] + .site-nav__menu { display: block; }
.site-nav__menu a { display: block; padding: 10px 16px; border: 0; font-size: .95rem; }
.site-nav__menu a:hover, .site-nav__menu a[aria-current="page"] { background: var(--cream-warm); color: var(--ink); }
.site-nav__menu a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--terracotta); }

.nav-toggle {
  display: none; width: 44px; height: 44px; margin-right: -10px;
  background: none; border: 0; cursor: pointer; position: relative;
}
.nav-toggle span, .nav-toggle span::before, .nav-toggle span::after {
  position: absolute; left: 11px; width: 22px; height: 2px; background: var(--ink); content: '';
  transition: transform .25s var(--ease), opacity .2s;
}
.nav-toggle span { top: 21px; }
.nav-toggle span::before { left: 0; top: -7px; }
.nav-toggle span::after { left: 0; top: 7px; }
.nav-toggle[aria-expanded="true"] span { background: transparent; }
.nav-toggle[aria-expanded="true"] span::before { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span::after { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 960px) {
  .nav-toggle { display: block; }
  .site-nav {
    position: fixed; inset: var(--header-h) 0 auto 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--cream); border-bottom: 1px solid var(--rule);
    padding: 8px var(--gutter) 24px;
    visibility: hidden; opacity: 0; transform: translateY(-8px);
    transition: opacity .2s, transform .2s var(--ease), visibility 0s .2s;
    max-height: calc(100dvh - var(--header-h)); overflow-y: auto;
  }
  .site-nav.is-open { visibility: visible; opacity: 1; transform: none; transition: opacity .2s, transform .2s var(--ease); }
  .site-nav__list { flex-direction: column; gap: 0; }
  .site-nav__list a { display: block; padding: 16px 0; font-size: 1.15rem; border-bottom: 1px solid var(--rule-soft); }
  .site-nav__trigger { display: flex; width: 100%; justify-content: space-between; padding: 16px 0; font-size: 1.15rem; border-bottom: 1px solid var(--rule-soft); }
  .site-nav__menu { position: static; min-width: 0; border: 0; padding: 0 0 0 16px; background: none; }
  .site-nav__menu a { padding: 14px 0; font-size: 1.05rem; border-bottom: 1px solid var(--rule-soft); }
  .site-nav .btn { margin-top: 20px; }
}
@media (max-width: 480px) { .brand__logo { height: 24px; } }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.site-footer { background: var(--ink); color: var(--cream); padding: 72px 0 32px; }
.site-footer__grid { display: grid; grid-template-columns: 1.5fr repeat(5, 1fr); gap: 32px; }
.site-footer__logo { height: 34px; width: auto; }
.site-footer__tag { margin-top: 18px; max-width: 320px; color: var(--on-ink-soft); font-size: .95rem; line-height: 1.55; }
.site-footer__heading {
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--terracotta-light); margin: 6px 0 16px;
}
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.site-footer a { color: var(--cream); text-decoration: none; font-size: .95rem; }
.site-footer a:hover { color: var(--terracotta-light); }
.site-footer__base {
  margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--ink-line);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: .72rem; letter-spacing: .08em; color: var(--ink-faint); text-transform: uppercase;
}
@media (max-width: 960px) {
  .site-footer__grid { grid-template-columns: repeat(3, 1fr); }
  .site-footer__brand { grid-column: 1 / -1; }
}
@media (max-width: 560px) { .site-footer__grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .site-footer__logo { height: 26px; } }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.form { display: grid; gap: 18px; }
.form__row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 640px) { .form__row { grid-template-columns: 1fr; } }
.field { display: grid; gap: 6px; }
.field label { font-family: var(--font-mono); font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  width: 100%; font: inherit; font-size: 1rem; color: var(--ink);
  background: #fff; border: 1px solid var(--rule); border-radius: 0; padding: 12px 14px; min-height: 48px;
  transition: border-color .15s;
}
.field textarea { min-height: 110px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.form__submit { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.form__meta { font-size: .88rem; color: var(--ink-soft); }
.form__error { color: var(--terracotta); font-size: .95rem; margin-top: 4px; width: 100%; }
.form__honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.form-success { padding: 28px; border: 1px solid var(--ink); background: #fff; }
.form-success h3 { font-size: 1.35rem; margin: 8px 0 10px; }
.form-success p { color: var(--ink-mid); }

/* --------------------------------------------------------------------------
   Reveal-on-scroll (progressive: content is visible without JS)
   -------------------------------------------------------------------------- */
.js [data-reveal] { opacity: 0; transform: translateY(14px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.js [data-reveal].is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .js [data-reveal] { opacity: 1; transform: none; } }

/* --------------------------------------------------------------------------
   Footer legal links, analytics consent, form privacy line, legal pages
   -------------------------------------------------------------------------- */
.site-footer__base a { color: var(--on-ink-soft); font-size: inherit; text-decoration: underline; text-underline-offset: 3px; }
.site-footer__base a:hover { color: var(--terracotta-light); }
.site-footer__link { background: none; border: 0; padding: 0; font: inherit; letter-spacing: inherit; text-transform: inherit; color: var(--on-ink-soft); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; min-height: 24px; }
.site-footer__link:hover { color: var(--terracotta-light); }

.consent {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 80;
  max-width: 760px; margin: 0 auto; padding: 16px 18px; background: var(--ink); color: var(--cream);
  border-top: 3px solid var(--terracotta-light); display: flex; gap: 14px 20px; align-items: center; flex-wrap: wrap;
}
.consent[hidden] { display: none; }
.consent__text { flex: 1 1 320px; font-size: .9rem; line-height: 1.5; color: var(--on-ink-soft); }
.consent__text a { color: var(--cream); }
.consent__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.consent .btn { --btn-bg: var(--cream); --btn-fg: var(--ink); --btn-bd: var(--cream); min-height: 44px; }
.consent .btn:hover { --btn-bg: var(--terracotta-light); --btn-bd: var(--terracotta-light); }
.consent .btn--ghost { --btn-bg: transparent; --btn-fg: var(--cream); --btn-bd: var(--on-ink-soft); }
.consent :focus-visible { outline-color: var(--terracotta-light); }

.form__privacy { font-size: .86rem; line-height: 1.5; color: var(--ink-soft); }
.form__privacy a { color: var(--ink); }
.field input[aria-invalid="true"], .field select[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: var(--terracotta); box-shadow: 0 0 0 1px var(--terracotta); }

.legal { padding: clamp(36px, 6vw, 80px) 0 clamp(64px, 8vw, 112px); }
.legal__wrap { max-width: 820px; }
.legal__title { font-size: clamp(2.2rem, 1.4rem + 2.6vw, 3.4rem); font-weight: 800; letter-spacing: -0.03em; }
.legal__date { margin-top: 10px; font-family: var(--font-mono); font-size: .76rem; color: var(--ink-soft); }
.legal h2 { margin-top: 36px; font-size: 1.3rem; letter-spacing: -0.015em; }
.legal p { margin-top: 12px; line-height: 1.7; color: var(--ink-mid); }
.legal p a { color: var(--ink); }
.legal__inline { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.legal__links { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 24px; margin-top: 28px !important; }
