/* ==========================================================================
   TRAYVOX LABS : base.css
   Design foundation: tokens, reset, type, layout, buttons, nav, footer,
   reveal utilities, reduced motion. Page-specific styling lives elsewhere.

   Contents
     1. Fonts
     2. Tokens
     3. Reset
     4. Base elements and accessibility
     5. Type: display scale, label, amp, prose
     6. Layout: container, section, grid helpers, utilities
     7. Buttons
     8. Nav (topbar, mobile menu)
     9. Footer
    10. Reveal / motion utilities
    11. Reduced motion
    12. Shared pieces (section head, links, next-link, image fallback)
    13. Work with us (shared CTA)
   ========================================================================== */

/* ---------- 1. Fonts ----------
   Nexa Bold is self-hosted and used for the wordmark only.
   Space Grotesk (500), Instrument Sans and IBM Plex Mono are loaded by each
   page from Google Fonts (see the <link> in every page head). */
@font-face {
  font-family: 'Nexa Bold';
  src: url('/fonts/NexaBold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---------- 2. Tokens ---------- */
:root {
  /* colour */
  --base: #141416;                /* Deep Gunmetal: main backgrounds */
  --base-deep: #0A0A0A;           /* vignettes, deep sections */
  --surface: #1B1C1F;             /* slightly lifted gunmetal */
  --surface-2: #232428;           /* raised panels, cards */
  --text: #E5E7EB;                /* Cool Platinum */
  --muted: #A1A7B3;               /* slate, 7.3:1 on --base */
  --dim: #5F6572;                 /* decorative only (3:1): never for readable text */
  --accent-fill: #0E6B64;         /* buttons, badges (deep teal, 5.8:1 with --on-accent) */
  --accent-hover: #115E59;        /* hover, active outlines, tints */
  --signal: #14B8A6;              /* small links, focus rings, status dots, labels */
  --on-accent: #F3F4F6;           /* text on teal fills */
  --line: rgba(229, 231, 235, .09);
  --line-strong: rgba(229, 231, 235, .18);
  --scrim: rgba(20, 20, 22, .94);

  /* type families */
  --font-display: 'Space Grotesk', 'Instrument Sans', system-ui, sans-serif;
  --font-body: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --font-brand: 'Nexa Bold', 'Space Grotesk', sans-serif;

  /* fluid type scale (viewport 360px to 1600px) */
  --fs-xs: clamp(0.75rem, 0.73rem + 0.08vw, 0.8125rem);    /* labels, 12 to 13 */
  --fs-sm: clamp(0.875rem, 0.85rem + 0.1vw, 0.9375rem);    /* 14 to 15 */
  --fs-body: clamp(1rem, 0.96rem + 0.18vw, 1.125rem);      /* 16 to 18 */
  --fs-lead: clamp(1.125rem, 1rem + 0.55vw, 1.5rem);       /* 18 to 24 */
  --fs-h3: clamp(1.25rem, 1.1rem + 0.7vw, 1.75rem);
  --fs-display-md: clamp(1.875rem, 1.2rem + 2.9vw, 3.75rem);
  --fs-display-lg: clamp(2.375rem, 1.3rem + 5.2vw, 6.75rem);
  --fs-display-xl: clamp(2.875rem, 1.4rem + 8.4vw, 11.5rem);

  /* spacing scale (4px base, fluid at the large end) */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: clamp(3.5rem, 2.5rem + 4vw, 6rem);
  --s-9: clamp(5rem, 3rem + 8vw, 10rem);
  --s-10: clamp(7rem, 4rem + 12vw, 15rem);

  /* layout */
  --pad-x: clamp(1.25rem, 0.5rem + 3.6vw, 4.5rem);
  --maxw: 88rem;                   /* 1408px */
  --measure: 38rem;                /* comfortable reading width */
  --nav-h: 4.5rem;

  /* shape */
  --r-sm: 6px;
  --r-md: 14px;
  --r-lg: 28px;
  --r-pill: 999px;

  /* motion: animate only transform and opacity */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 180ms;
  --t-med: 300ms;
  --t-slow: 900ms;

  /* stacking */
  --z-content: 1;
  --z-nav: 50;
  --z-menu: 49;
  --z-curtain: 100;

  color-scheme: dark;
}

/* ---------- 3. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: auto;          /* Lenis owns smooth scrolling */
  scroll-padding-top: calc(var(--nav-h) + var(--s-4));
}
body { min-height: 100vh; min-height: 100dvh; }
img, picture, video, canvas, svg { display: block; max-width: 100%; }
img { height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul[role='list'], ol[role='list'] { list-style: none; padding: 0; }
h1, h2, h3, h4, p { overflow-wrap: break-word; }

/* ---------- 4. Base elements and accessibility ---------- */
body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.6;
  font-weight: 400;
  color: var(--text);
  background: var(--base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;               /* clip, not hidden: keeps position: sticky working */
}
body.menu-open { overflow: hidden; }

::selection { background: var(--accent-fill); color: var(--on-accent); }

/* visible focus everywhere, mouse clicks stay clean */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

.skip-link {
  position: fixed;
  top: var(--s-3);
  left: var(--s-3);
  z-index: calc(var(--z-curtain) + 1);
  padding: var(--s-3) var(--s-5);
  min-height: 44px;
  background: var(--accent-fill);
  color: var(--on-accent);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: .12em;
  text-transform: uppercase;
  border-radius: var(--r-pill);
  transform: translateY(-200%);
}
.skip-link:focus-visible { transform: none; outline-offset: 2px; }

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

/* ---------- 5. Type ---------- */
.display-xl, .display-lg, .display-md {
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--text);
  text-wrap: balance;
}
.display-xl { font-size: var(--fs-display-xl); line-height: .92; letter-spacing: -0.045em; }
.display-lg { font-size: var(--fs-display-lg); line-height: .98; letter-spacing: -0.04em; }
.display-md { font-size: var(--fs-display-md); line-height: 1.06; letter-spacing: -0.03em; }

/* Space Grotesk's ampersand is awkward: always set it in the body face */
.amp {
  font-family: var(--font-body);
  font-weight: 500;
  font-style: normal;
  letter-spacing: 0;
}

/* mono eyebrow */
.label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.label--signal { color: var(--signal); }
.label--dot::before {
  content: '';
  display: inline-block;
  width: .5em; height: .5em;
  margin-right: .75em;
  border-radius: 50%;
  background: var(--signal);
  vertical-align: .05em;
}

.h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--fs-h3);
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.lead {
  font-size: var(--fs-lead);
  line-height: 1.45;
  color: var(--muted);
  max-width: var(--measure);
}
.prose { max-width: var(--measure); }
.prose > * + * { margin-top: var(--s-5); }
.prose a, .link {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 0.25em;
  transition: text-decoration-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.prose a:hover, .link:hover { text-decoration-color: var(--signal); color: var(--signal); }
.text-muted { color: var(--muted); }

/* ---------- 6. Layout ---------- */
.container {
  width: 100%;
  max-width: calc(var(--maxw) + var(--pad-x) * 2);
  margin-inline: auto;
  padding-inline: var(--pad-x);
}
.section { padding-block: var(--s-9); position: relative; }
.section--tight { padding-block: var(--s-8); }
.section--surface { background: var(--surface); }
.rule { height: 1px; border: 0; background: var(--line); }

.stack > * + * { margin-top: var(--stack, var(--s-5)); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap, var(--s-4)); }
.grid-12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap, var(--s-5)); }

/* main starts below the fixed topbar on pages that do not have a full-bleed hero */
.page-top { padding-top: calc(var(--nav-h) + var(--s-8)); }

/* ---------- 7. Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  min-height: 44px;
  padding: 0.85rem 1.6rem;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  line-height: 1.2;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--t-med) var(--ease), color var(--t-med) var(--ease),
              border-color var(--t-med) var(--ease), transform var(--t-med) var(--ease);
}
.btn .arrow { display: inline-block; transition: transform var(--t-med) var(--ease); }
.btn:active { transform: scale(.97); }

.btn-solid { background: var(--accent-fill); color: var(--on-accent); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }

@media (hover: hover) {
  .btn-solid:hover { background: var(--accent-hover); }
  .btn-ghost:hover { border-color: var(--signal); color: var(--signal); }
  .btn:hover .arrow { transform: translateX(4px); }
}
.btn-solid:focus-visible { outline-color: var(--text); }
.btn[aria-disabled='true'], .btn:disabled { opacity: .45; pointer-events: none; }

/* ---------- 8. Nav ---------- */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: var(--z-nav);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-5);
  height: var(--nav-h);
  padding-inline: var(--pad-x);
  border-bottom: 1px solid transparent;
  transition: background var(--t-med) var(--ease), border-color var(--t-med) var(--ease),
              transform .5s var(--ease);
}
/* hides on scroll down, returns on scroll up; never while focus is inside it */
html.js:not(.reduced) .topbar.is-hidden:not(:focus-within) { transform: translate3d(0, -101%, 0); }
.topbar.scrolled {
  background: rgba(20, 20, 22, .78);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom-color: var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  color: var(--text);
}
.brand-name {
  font-family: var(--font-brand);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .3em;
  white-space: nowrap;
}
.logo-mark { display: block; height: 30px; width: auto; flex: none; }
.brand .logo-mark { transform: translate(5px, -3px); }   /* optical centre with the wordmark */

.nav { display: flex; align-items: center; gap: var(--s-1); }
.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.9rem;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color var(--t-med) var(--ease);
}
@media (hover: hover) { .nav-link:hover { color: var(--text); } }
.nav-link[aria-current='page'] { color: var(--signal); }
.btn-nav { margin-left: var(--s-3); padding: 0.7rem 1.3rem; }

.nav-toggle { display: none; }

@media (min-width: 761px) and (max-width: 1000px) {
  .brand-name { letter-spacing: .2em; }
  .nav-link { padding: 0 0.65rem; letter-spacing: .1em; }
}

/* hamburger and full-screen menu when the nav no longer fits beside the brand */
@media (max-width: 760px) {
  :root { --nav-h: 4rem; }
  .brand { gap: 9px; position: relative; z-index: 2; }
  .brand-name { font-size: 13px; letter-spacing: .2em; }
  .logo-mark { height: 24px; }

  /* no backdrop-filter here: it would trap the fixed full-screen menu inside the bar */
  .topbar.scrolled {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: var(--scrim);
  }

  .nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    width: 44px;
    height: 44px;
    margin-right: -10px;
    position: relative;
    z-index: 2;
    -webkit-tap-highlight-color: transparent;
  }
  .nav-toggle span {
    display: block;
    width: 22px;
    height: 1.5px;
    background: var(--text);
    transition: transform .5s var(--ease);
  }
  .menu-open .nav-toggle span:nth-child(1) { transform: translateY(3.75px) rotate(45deg); }
  .menu-open .nav-toggle span:nth-child(2) { transform: translateY(-3.75px) rotate(-45deg); }

  .nav {
    position: fixed;
    inset: 0;
    z-index: 1;
    margin: 0;
    padding: calc(var(--nav-h) + var(--s-4)) var(--pad-x) var(--s-7);
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    background: var(--base);
    opacity: 0;
    visibility: hidden;
    transition: opacity .4s var(--ease), visibility 0s linear .4s;
  }
  .menu-open .nav {
    opacity: 1;
    visibility: visible;
    transition: opacity .4s var(--ease), visibility 0s;
  }

  .nav-link {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(2.125rem, 10.5vw, 3rem);
    letter-spacing: -0.03em;
    text-transform: none;
    line-height: 1.1;
    color: var(--text);
    padding: var(--s-2) 0;
    min-height: 56px;
    opacity: 0;
    transform: translateY(18px);
    transition: opacity .6s var(--ease), transform .6s var(--ease), color var(--t-med) var(--ease);
  }
  .nav-link[aria-current='page'] { color: var(--signal); }
  .btn-nav {
    margin: var(--s-6) 0 0;
    padding: 1rem 1.7rem;
    opacity: 0;
    transform: translateY(18px);
    transition: opacity .6s var(--ease), transform .6s var(--ease), background var(--t-med) var(--ease);
  }
  .menu-open .nav-link, .menu-open .btn-nav { opacity: 1; transform: none; }
  .menu-open .nav > *:nth-child(1) { transition-delay: .08s; }
  .menu-open .nav > *:nth-child(2) { transition-delay: .14s; }
  .menu-open .nav > *:nth-child(3) { transition-delay: .20s; }
  .menu-open .nav > *:nth-child(4) { transition-delay: .26s; }
}
@media (max-width: 360px) {
  .brand-name { letter-spacing: .14em; }
}

/* ---------- 9. Footer ---------- */
.footer {
  position: relative;
  padding-block: var(--s-8) var(--s-6);
  background: var(--base);
  border-top: 1px solid var(--line);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-6);
}
.footer-brand { display: grid; gap: var(--s-4); }
.footer .logo-mark { height: 24px; }
.footer-line { max-width: 28rem; }
.footer-mail {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--fs-lead);
  letter-spacing: -0.02em;
  color: var(--text);
  transition: color var(--t-med) var(--ease);
}
@media (hover: hover) { .footer-mail:hover { color: var(--signal); } }
.footer-legal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3) var(--s-6);
  margin-top: var(--s-7);
  padding-top: var(--s-5);
  border-top: 1px solid var(--line);
}
.footer-legal .label { font-size: 0.6875rem; letter-spacing: .1em; }
.footer-links { display: flex; gap: var(--s-2); }
.footer-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: var(--s-3);
  margin-inline: calc(var(--s-3) * -1) 0;
  transition: color var(--t-med) var(--ease);
}
@media (hover: hover) { .footer-links a:hover { color: var(--signal); } }

/* ---------- 10. Reveal / motion utilities ----------
   Hidden-until-animated states exist only when JS has run (html.js) and the
   visitor has not asked for reduced motion (html.reduced). Without JS, or with
   reduced motion, everything is simply visible. */
html.js:not(.reduced) .reveal {
  opacity: 0;
  transform: translate3d(0, 28px, 0);
  transition: opacity var(--t-slow) var(--ease), transform var(--t-slow) var(--ease);
  transition-delay: calc(var(--i, 0) * 70ms);
  will-change: opacity, transform;
}
html.js:not(.reduced) .reveal.is-in {
  opacity: 1;
  transform: none;
  will-change: auto;
}

/* load curtain and custom cursor are created by core.js (never present without JS) */
.curtain {
  position: fixed;
  inset: 0;
  z-index: var(--z-curtain);
  display: grid;
  place-items: center;
  background: var(--base);
  pointer-events: none;
}
.curtain-line {
  display: block;
  width: min(14rem, 40vw);
  height: 1px;
  background: var(--signal);
}
.cursor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: calc(var(--z-curtain) + 2);
  width: 28px;
  height: 28px;
  border: 1px solid var(--signal);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: background var(--t-med) var(--ease);
}
.cursor.is-grown { background: rgba(20, 184, 166, .14); }
@media (hover: none), (pointer: coarse), (prefers-reduced-motion: reduce) { .cursor, .curtain { display: none; } }

/* ---------- 12. Shared pieces (every page) ---------- */
.section-head { display: grid; gap: var(--s-4); margin-bottom: var(--s-8); max-width: 62rem; }
.section-head .lead { margin-top: var(--s-2); }

.nowrap { white-space: nowrap; }

/* text link with arrow, 44px tall target */
.tlink {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text);
  border-bottom: 1px solid transparent;
  transition: color var(--t-med) var(--ease);
}
.tlink .arrow { display: inline-block; transition: transform var(--t-med) var(--ease); }
@media (hover: hover) {
  .tlink:hover { color: var(--signal); }
  .tlink:hover .arrow { transform: translateX(4px); }
}
.reel-links { display: flex; flex-wrap: wrap; gap: 0 var(--s-6); margin-top: var(--s-3); }

/* quiet closing link at the end of a section */
.next { display: flex; justify-content: flex-end; margin-top: var(--s-8); }
.next-link {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 44px;
  padding-inline: var(--s-2);
  color: var(--muted);
  border-bottom: 1px solid var(--line-strong);
  transition: color var(--t-med) var(--ease), border-color var(--t-med) var(--ease);
}
.next-link .arrow { display: inline-block; transition: transform var(--t-med) var(--ease); }
@media (hover: hover) {
  .next-link:hover { color: var(--signal); border-color: var(--signal); }
  .next-link:hover .arrow { transform: translateX(4px); }
}

/* image fallback: a failed image is hidden and its box keeps size and accent colour.
   :is() lifts specificity so it wins over each page's own media-box background. */
.img-failed > img { visibility: hidden; }
.img-failed:is(div, figure, span, li) { background: color-mix(in srgb, var(--accent, var(--signal)) 48%, var(--base)); }

/* ---------- 13. Work with us (shared partial: partials/cta.html) ---------- */
.wwu {
  background:
    radial-gradient(60rem 28rem at 85% 0%, rgba(20, 184, 166, .07), transparent 70%),
    var(--surface);
}
.wwu-title { margin-top: var(--s-4); max-width: 13ch; }
.wwu-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--s-5);
  row-gap: var(--s-8);
  margin-top: var(--s-8);
}
.wwu-who { grid-column: 1 / span 6; display: grid; gap: var(--s-5); align-content: start; }
.wwu-audit { color: var(--muted); max-width: var(--measure); }
.wwu-actions { margin-top: var(--s-3); }
.steps { grid-column: 8 / span 5; list-style: none; padding: 0; }
.step {
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: var(--s-4);
  padding-block: var(--s-5);
  border-top: 1px solid var(--line-strong);
}
.step:last-child { border-bottom: 1px solid var(--line-strong); }
.step-text {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--fs-h3);
  line-height: 1.2;
  letter-spacing: -0.02em;
}
@media (max-width: 760px) {
  .wwu-grid { display: block; }
  .steps { margin-top: var(--s-8); }
  .wwu-actions .btn { flex: 1 1 auto; }
  .next { margin-top: var(--s-7); }
}

/* ---------- 11. Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1 !important; transform: none !important; }
}
