/* ─── functionSPACE canonical site styles ─────────────────────────────────
   Design tokens, base layout, nav, footer. Owned by the home page's look.
   Loaded on every page; pair with /site-chrome.js which injects the nav and
   footer. Page-specific styling stays in each page's <style> block.
   ─────────────────────────────────────────────────────────────────────── */

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

:root {
  --color-bg: #0d0e12;
  --color-text: #F0F1F3;
  --color-text-secondary: #c0c5ce;
  --color-text-tertiary: #8B919A;
  --color-text-muted: #5a6170;
  --color-border: #1e2128;
  --color-surface: #131519;
  --color-surface-alt: #181b20;
  --color-wireframe: #454c5a;
  --color-accent: #3B82F6;
  --color-accent-hover: #60A5FA;
  --color-accent-subtle: rgba(59,130,246,0.08);
  --color-accent-bdr: rgba(59,130,246,0.3);
  --color-strong: #F0F1F3;
  --font-heading: 'Hedvig Letters Serif', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --gutter: clamp(20px, 4vw, 40px);
  --nav-height: 60px;
}
[data-theme="light"] {
  --color-bg: #F9F9F9;
  --color-text: #202124;
  --color-text-secondary: #434954;
  --color-text-tertiary: #525966;
  --color-text-muted: #676F7F;
  --color-border: #D8DCE2;
  --color-surface: #FFFFFF;
  --color-surface-alt: #F0F0F2;
  --color-wireframe: #B5BCC9;
  --color-accent-hover: #2673E2;
  --color-accent-subtle: #EAEEFF;
  --color-strong: #202124;
}

html {
  overflow-x: clip;
  /* Offset in-page anchor jumps (TOC links, #hash, scrollIntoView) so the
     target heading clears the fixed nav instead of hiding behind it. */
  scroll-padding-top: calc(var(--nav-height) + 24px);
}
html, body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}
body { width: 100%; overflow-x: hidden; }

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

/* Pages other than home get auto top-padding so content clears the fixed nav. */
body:not([data-page="home"]) main { padding-top: var(--nav-height); }

/* ── NAV ──────────────────────────────────────────────── */
.nav {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 14px var(--gutter);
  background: rgba(13, 14, 18, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
}
[data-theme="light"] .nav {
  background: rgba(240, 238, 232, 0.72);
  border-bottom-color: rgba(0,0,0,0.06);
}
.nav-left { display: flex; align-items: center; gap: 20px; }
.nav-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--color-text); }
.nav-logo svg { height: 25px; width: auto; color: var(--color-text); }
.nav-wordmark { height: 22px; width: auto; }
.nav-wordmark-dark { display: block; }
.nav-wordmark-light { display: none; }
[data-theme="light"] .nav-wordmark-dark { display: none; }
[data-theme="light"] .nav-wordmark-light { display: block; }

.nav-links { display: flex; gap: 4px; align-items: center; }
.nav-link {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-sans);
  font-size: 13px; color: var(--color-text-tertiary);
  text-decoration: none; padding: 6px 10px; border-radius: var(--radius-sm);
  transition: color 0.2s;
  cursor: pointer; background: none; border: 0;
}
.nav-link:hover, .nav-link.active { color: var(--color-text); }
/* dropdown parents (Research, Developers) get .active via data-page on the wrapper */
.nav-dropdown.active > .nav-link { color: var(--color-text); }

/* Developers dropdown */
.nav-dropdown { position: relative; }
.nav-dropdown > .nav-link svg { transition: transform 0.2s; }
.nav-dropdown:hover > .nav-link svg,
.nav-dropdown.open > .nav-link svg { transform: rotate(180deg); }
.nav-dropdown-menu {
  position: absolute; top: 100%; left: 0;
  margin-top: 8px;
  min-width: 160px;
  background: rgba(13,14,18,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 6px;
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity .15s, transform .15s, visibility .15s;
}
[data-theme="light"] .nav-dropdown-menu { background: rgba(255,255,255,0.97); }
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu {
  opacity: 1; visibility: visible; transform: translateY(0);
}
.nav-dropdown-menu a {
  display: block;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--color-text-tertiary);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.nav-dropdown-menu a:hover { color: var(--color-text); background: var(--color-surface-alt); }

.nav-right { display: flex; align-items: center; gap: 10px; }
.nav-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  color: var(--color-text-tertiary);
  transition: color 0.2s;
}
.nav-icon:hover { color: var(--color-text); }
.nav-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-sans); font-size: 12px; font-weight: 500;
  color: var(--color-text-secondary);
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s;
}
.nav-pill:hover { color: var(--color-text); border-color: var(--color-wireframe); }
.nav-cta {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-sans); font-size: 12px; font-weight: 500;
  color: var(--color-bg);
  background: var(--color-strong);
  padding: 7px 14px;
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: opacity 0.2s;
}
.nav-cta:hover { opacity: 0.85; }

/* Mobile drawer */
.nav-mobile-toggle {
  display: none;
  width: 44px; height: 44px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  cursor: pointer;
  align-items: center; justify-content: center;
  padding: 0;
  transition: border-color .15s;
}
.nav-mobile-toggle:hover { border-color: var(--color-wireframe); }
.nav-drawer {
  position: fixed; top: var(--nav-height); left: 0; right: 0;
  max-height: calc(100dvh - var(--nav-height));
  overflow-y: auto;
  background: rgba(13,14,18,0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  z-index: 99;
  transform: translateY(-8px);
  opacity: 0; visibility: hidden;
  transition: transform .2s cubic-bezier(.4,0,.2,1), opacity .2s, visibility .2s;
  padding: 12px 24px 24px;
  display: flex; flex-direction: column;
}
[data-theme="light"] .nav-drawer { background: rgba(249,249,249,0.98); }
.nav-drawer.open { transform: translateY(0); opacity: 1; visibility: visible; }
.nav-drawer a {
  display: flex; align-items: center; gap: 8px;
  padding: 13px 8px; font-size: 15px; font-weight: 500;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}
.nav-drawer a.nav-drawer-sub {
  padding-left: 20px; font-size: 14px; color: var(--color-text-secondary); font-weight: 400;
}
.nav-drawer-label {
  padding: 14px 8px 6px; font-family: var(--font-mono);
  font-size: 10px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--color-text-muted);
}
.nav-drawer .nav-cta {
  margin-top: 14px; justify-content: center;
  font-size: 14px; padding: 12px 18px;
  border-bottom: none;
}

@media (max-width: 860px) {
  .nav-mobile-toggle { display: inline-flex; }
  .nav-links { display: none; }
  .nav-pill { display: none; }
}
@media (max-width: 540px) {
  .nav { padding: 12px 16px; }
  .nav-icon { display: none; }
  /* CTA also hidden in top bar — surfaced in the drawer instead, where it has a proper 44px+ tap area */
  .nav .nav-right > .nav-cta { display: none; }
}

/* ── FOOTER ───────────────────────────────────────────── */
footer.site-footer {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px 24px;
  padding: 28px var(--gutter);
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 13px;
}
.footer-brand { display: inline-flex; align-items: center; gap: 12px; color: var(--color-text-tertiary); }

/* Compact single-row link cluster, sits between brand and theme toggle */
.footer-links {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 14px 32px;
}
.footer-links > a {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}
.footer-links > a:hover { color: var(--color-text); }
.footer-social {
  display: inline-flex; align-items: center; gap: 8px;
  padding-left: 18px; margin-left: 6px;
  border-left: 1px solid var(--color-border);
}

/* Mobile: stack brand / links / toggle, links left-aligned and wrapping */
@media (max-width: 640px) {
  footer.site-footer { justify-content: flex-start; }
  .footer-links { order: 3; width: 100%; }
  .footer-social { border-left: none; padding-left: 0; margin-left: auto; }
}
.footer-wordmark { height: 16px; width: auto; }
.footer-wordmark-dark { display: inline-block; }
.footer-wordmark-light { display: none; }
[data-theme="light"] .footer-wordmark-dark { display: none; }
[data-theme="light"] .footer-wordmark-light { display: inline-block; }

.theme-toggle {
  display: flex; gap: 2px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: 3px;
}
.theme-btn {
  background: none; border: none; cursor: pointer;
  color: var(--color-text-muted); padding: 4px 8px;
  border-radius: 5px; font-size: 13px; transition: all 0.2s;
}
.theme-btn.active { background: var(--color-surface-alt); color: var(--color-strong); }

/* ── EARLY ACCESS POPUP (iframe modal) ─────────────────── */
/* Iframe is lazily injected by site-chrome.js; src points at the VPS-hosted
   form (growth.functionspace.dev/earlyaccess), theme-synced via postMessage. */
.fs-ea-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: clamp(12px, 4vw, 32px);
  background: rgba(6,7,9,0.66);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; visibility: hidden;
  transition: opacity .22s ease, visibility .22s ease;
}
[data-theme="light"] .fs-ea-overlay { background: rgba(20,20,22,0.42); }
.fs-ea-overlay.open { opacity: 1; visibility: visible; }
.fs-ea-panel {
  position: relative; width: 100%; max-width: 600px;
  height: min(88dvh, 780px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: 0 24px 70px rgba(0,0,0,0.5);
  transform: translateY(12px) scale(.99);
  transition: transform .22s ease;
}
.fs-ea-overlay.open .fs-ea-panel { transform: none; }
.fs-ea-frame { width: 100%; height: 100%; border: 0; display: block; background: var(--color-surface); }
.fs-ea-close {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 40px; height: 40px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: 50%; color: var(--color-text-tertiary); cursor: pointer;
  transition: color .15s, border-color .15s;
}
.fs-ea-close:hover { color: var(--color-text); border-color: var(--color-wireframe); }
body.fs-ea-open { overflow: hidden; }
@media (max-width: 520px) {
  .fs-ea-overlay { padding: 0; }
  .fs-ea-panel { max-width: none; height: 100dvh; border-radius: 0; border: 0; }
  .fs-ea-close { width: 44px; height: 44px; top: 8px; right: 8px; }
}
