/*
 * Sagix — site styles.
 * Assets are cached by browsers for 24h: bump ?v= on the <link> in every page after editing this file.
 */

/* Fonts (self-hosted, SIL OFL — see assets/fonts/OFL-*.txt) */
@font-face {
  font-family: "Instrument Sans";
  src: url("/assets/fonts/instrument-sans-latin-wght.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("/assets/fonts/instrument-sans-latin-ext-wght.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/assets/fonts/ibm-plex-mono-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Tokens */
:root {
  color-scheme: dark;

  --ink: #0a0c0b;
  --ink-2: #0f1210;
  --ink-3: #151916;
  --line: rgba(233, 236, 231, 0.09);
  --line-2: rgba(233, 236, 231, 0.18);
  --text: #e9ece7;
  --text-2: #a2a9a1;
  --text-3: #7c837b;
  --sage: #a7bfa3;
  --sage-soft: rgba(167, 191, 163, 0.14);

  --font-sans: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --gutter: clamp(20px, 4vw, 48px);
  --col-gap: clamp(16px, 2vw, 32px);
  --maxw: 1280px;
  --header-h: 64px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Base */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
p { text-wrap: pretty; }

::selection { background: var(--sage); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--sage);
  outline-offset: 4px;
}

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

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: 12px;
  z-index: 100;
  padding: 8px 14px;
  background: var(--sage);
  color: var(--ink);
  font-weight: 600;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

.container {
  width: 100%;
  max-width: calc(var(--maxw) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Mono labels */
.eyebrow,
.index {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.eyebrow b,
.index b { font-weight: 400; color: var(--sage); }

/* Brand: symbol + wordmark */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}
.mark { width: 26px; height: 26px; flex: none; }
.mark path { fill: none; stroke: currentColor; stroke-width: 3.5; }
.mark rect { fill: var(--sage); }

.wordmark {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1;
}
/* The dot of the i is the Sagix node. */
.wordmark__i { position: relative; }
.wordmark__i::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0.085em;
  width: 0.15em;
  height: 0.15em;
  background: var(--sage);
  transform: translateX(-50%);
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(10, 12, 11, 0.82);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(var(--header-h) - 1px); /* + 1px border */
}
.nav ul { display: flex; gap: clamp(20px, 3vw, 40px); }
.nav a {
  font-size: 0.875rem;
  color: var(--text-2);
  transition: color 0.2s ease;
}
.nav a:hover { color: var(--text); }
.nav .nav__contact {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
.nav .nav__contact::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--sage);
}

@media (max-width: 760px) {
  .nav li:not(:last-child) { display: none; }
}

/* Hero */
.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: calc(100svh - var(--header-h));
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(233, 236, 231, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(233, 236, 231, 0.035) 1px, transparent 1px);
  background-size: 80px 80px;
  background-position: -1px -1px;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 65% 35%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse 70% 60% at 65% 35%, #000 20%, transparent 75%);
  pointer-events: none;
}
.hero__inner {
  position: relative;
  padding-top: clamp(48px, 10vh, 128px);
  padding-bottom: clamp(24px, 5vh, 64px);
}
.hero__title {
  margin-top: 28px;
  font-size: clamp(2.6rem, 1.2rem + 6.2vw, 7.5rem);
  font-weight: 500;
  line-height: 0.96;
  letter-spacing: -0.045em;
  text-wrap: balance;
}
.hero__lead {
  max-width: 34rem;
  margin-top: clamp(28px, 4vw, 48px);
  margin-left: auto;
  margin-right: clamp(0px, 6vw, 96px);
  font-size: clamp(1.125rem, 1rem + 0.45vw, 1.375rem);
  line-height: 1.5;
  color: var(--text-2);
}
.hero__lead strong { display: block; margin-bottom: 0.5em; font-weight: 500; color: var(--text); }

@media (min-width: 720px) {
  .hero__title span { display: block; }
}
@media (max-width: 900px) {
  .hero__lead { margin-left: 0; margin-right: 0; }
}

/* Hero graphic: tangled inputs -> one node -> ordered lanes */
.system {
  position: relative;
  flex: none;
  height: clamp(230px, 22vw, 320px);
  margin-top: auto;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}
.system svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.system path { fill: none; }
.sys-in path { stroke: rgba(233, 236, 231, 0.17); stroke-width: 1; }
.sys-out path { stroke: rgba(233, 236, 231, 0.32); stroke-width: 1; }
.sys-bus { stroke: rgba(233, 236, 231, 0.14); stroke-width: 1; stroke-dasharray: 2 5; }
.sys-dots rect { fill: rgba(233, 236, 231, 0.55); }
.sys-route { stroke: var(--sage); stroke-opacity: 0.75; stroke-width: 1.25; }
.sys-pulse {
  stroke: var(--sage);
  stroke-width: 2;
  stroke-dasharray: 34 1100;
  stroke-dashoffset: 34;
  opacity: 0;
}
.sys-frame { fill: none; stroke: var(--sage); stroke-opacity: 0.35; stroke-width: 1; }
.sys-node { fill: var(--sage); }

@media (prefers-reduced-motion: no-preference) {
  .sys-in path,
  .sys-out path,
  .sys-route {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: draw 1.8s var(--ease) forwards;
    animation-delay: calc(0.25s + var(--i, 0) * 55ms);
  }
  .sys-out path { animation-delay: calc(1.1s + var(--i, 0) * 45ms); }
  .sys-route { animation-delay: 1s; animation-duration: 2.2s; }
  .sys-bus,
  .sys-dots { opacity: 0; animation: fade 1.2s ease forwards 1.9s; }
  .sys-node,
  .sys-frame {
    transform-box: fill-box;
    transform-origin: center;
    opacity: 0;
    animation: pop 0.9s var(--ease) forwards 0.9s;
  }
  .sys-frame { animation: pop 0.9s var(--ease) forwards 1s, breathe 6s ease-in-out infinite 2s; }
  .sys-pulse { animation: pulse 7s cubic-bezier(0.45, 0, 0.25, 1) infinite 2.8s; }

  .hero .rise {
    opacity: 0;
    animation: rise 1s var(--ease) forwards;
    animation-delay: calc(var(--d, 0) * 120ms + 0.1s);
  }
}

@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade { to { opacity: 1; } }
@keyframes pop {
  from { opacity: 0; transform: scale(0.4); }
  to { opacity: 1; transform: none; }
}
@keyframes breathe {
  0%, 100% { stroke-opacity: 0.35; }
  50% { stroke-opacity: 0.12; }
}
@keyframes pulse {
  0% { stroke-dashoffset: 34; opacity: 1; }
  70% { stroke-dashoffset: -1000; opacity: 1; }
  100% { stroke-dashoffset: -1000; opacity: 0; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

/* Sections */
.section { padding-block: clamp(80px, 9vw, 136px); }

.section__head {
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  row-gap: 24px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}
.section__head::before {
  content: "";
  position: absolute;
  top: -4px;
  left: 0;
  width: 7px;
  height: 7px;
  background: var(--sage);
}
.section__head .eyebrow { grid-column: 1 / span 3; padding-top: 0.6em; }
.section__title {
  grid-column: 4 / span 9;
  font-size: clamp(2rem, 1.2rem + 3vw, 3.75rem);
  font-weight: 500;
  line-height: 1.04;
  letter-spacing: -0.035em;
  text-wrap: balance;
}
.section__intro {
  grid-column: 4 / span 6;
  font-size: 1.125rem;
  color: var(--text-2);
}

/* Content column that lines up with section titles */
.section__body {
  margin-top: clamp(48px, 6vw, 88px);
  margin-left: calc((100% + var(--col-gap)) * 3 / 12);
}

@media (max-width: 900px) {
  .section__head .eyebrow,
  .section__title,
  .section__intro { grid-column: 1 / -1; }
  .section__head .eyebrow { padding-top: 0; }
  .section__body { margin-left: 0; }
}

/* 01 — What we do */
.area {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 5fr);
  gap: 16px var(--col-gap);
  padding-block: clamp(28px, 3.5vw, 44px);
  border-top: 1px solid var(--line);
}
.area:last-child { border-bottom: 1px solid var(--line); }
.area::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--sage);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.8s var(--ease);
}
.area:hover::before { transform: scaleX(1); }
.area__title {
  margin-top: 10px;
  font-size: clamp(1.375rem, 1.1rem + 0.8vw, 1.75rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.area__lead {
  font-size: 1.1875rem;
  line-height: 1.45;
  color: var(--text);
}
.area__text { margin-top: 12px; color: var(--text-2); }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}
.tags li {
  padding: 6px 10px;
  border: 1px solid var(--line-2);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.3;
  color: var(--text-2);
}

@media (max-width: 700px) {
  .area { grid-template-columns: 1fr; }
}

/* Panel with a node on its corner */
.panel {
  position: relative;
  background: var(--ink-2);
  border: 1px solid var(--line);
  padding: clamp(28px, 4vw, 56px);
}
.panel::before {
  content: "";
  position: absolute;
  top: -4px;
  left: -4px;
  width: 7px;
  height: 7px;
  background: var(--sage);
}

.brief { margin-top: clamp(48px, 6vw, 80px); }
.brief__title {
  max-width: 18ch;
  font-size: clamp(1.75rem, 1.2rem + 2vw, 2.75rem);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.03em;
  text-wrap: balance;
}
.brief__text {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px var(--col-gap);
  margin-top: clamp(24px, 3vw, 40px);
  color: var(--text-2);
}
@media (max-width: 700px) {
  .brief__text { grid-template-columns: 1fr; }
}

/* 02 — Approach */
.principles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}
.principle {
  background: var(--ink);
  padding: clamp(28px, 3.5vw, 48px);
  transition: background-color 0.4s ease;
}
.principle:hover { background: var(--ink-2); }
.principle .index { display: flex; align-items: center; gap: 10px; }
.principle .index::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--line-2);
  transition: background-color 0.4s ease;
}
.principle:hover .index::before { background: var(--sage); }
.principle__title {
  margin-top: clamp(28px, 4vw, 56px);
  font-size: clamp(1.75rem, 1.3rem + 1.4vw, 2.5rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.principle__text { margin-top: 14px; max-width: 38ch; color: var(--text-2); }

@media (max-width: 700px) {
  .principles { grid-template-columns: 1fr; }
}

/* 03 — Working together */
.steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 32px var(--col-gap);
  counter-reset: step;
}
.step {
  position: relative;
  padding-top: 24px;
  border-top: 1px solid var(--line-2);
}
.step::before {
  content: "";
  position: absolute;
  top: -4px;
  left: 0;
  width: 7px;
  height: 7px;
  background: var(--text-3);
  transition: background-color 0.5s ease;
  transition-delay: calc(var(--d, 0) * 220ms + 0.3s);
}
.steps.is-in .step::before,
html:not(.js) .step::before { background: var(--sage); }
.step__title {
  margin-top: 12px;
  font-size: 1.375rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.step__text { margin-top: 8px; font-size: 0.9375rem; color: var(--text-2); }

@media (max-width: 900px) {
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .steps { grid-template-columns: 1fr; }
}

.modes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--col-gap);
  margin-top: clamp(56px, 7vw, 96px);
}
.mode { display: flex; flex-direction: column; }
.mode__title {
  margin-top: 14px;
  font-size: clamp(1.625rem, 1.3rem + 1vw, 2.125rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.mode__text { margin: 14px 0 28px; color: var(--text-2); }
.mode__list {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.mode__list li {
  position: relative;
  padding-left: 20px;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text);
}
.mode__list li + li { margin-top: 10px; }
.mode__list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 5px;
  height: 5px;
  background: var(--sage);
}
.modes__note {
  margin-top: 28px;
  font-size: 0.9375rem;
  color: var(--text-3);
}

@media (max-width: 760px) {
  .modes { grid-template-columns: 1fr; }
}

/* 04 — Contact */
.contact__card {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px 40px;
  max-width: 46rem;
}
.contact__email {
  display: inline-block;
  margin-top: 12px;
  font-size: clamp(1.375rem, 1.1rem + 1vw, 2rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
  border-bottom: 1px solid var(--line-2);
  transition: border-color 0.3s ease;
}
.contact__email:hover { border-color: var(--sage); }
.contact__copy {
  display: none;
  padding: 10px 16px;
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.3s ease, color 0.3s ease;
}
.js .contact__copy { display: inline-block; }
.contact__copy:hover { border-color: var(--sage); color: var(--text); }

/* "Copied" notice for email links (site.js) */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 2 * var(--gutter));
  padding: 12px 18px;
  background: var(--ink-3);
  border: 1px solid var(--line-2);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text);
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s var(--ease);
}
.toast::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  background: var(--sage);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 40px 48px;
  font-size: 0.875rem;
  color: var(--text-2);
}
.site-footer__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px 40px;
}
.site-footer__row + .site-footer__row {
  align-items: flex-end;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.site-footer .brand .mark { width: 22px; height: 22px; }
.site-footer .wordmark { font-size: 1.125rem; }
.site-footer a:hover { color: var(--text); }
.site-footer__tagline { color: var(--text-3); }
.site-footer__legal {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.7;
  color: var(--text-3);
}

/* 404 */
.notfound {
  position: relative;
  min-height: calc(100svh - var(--header-h));
  display: flex;
  align-items: center;
  overflow: hidden;
}
.notfound::before { /* same grid as the hero */
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(233, 236, 231, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(233, 236, 231, 0.035) 1px, transparent 1px);
  background-size: 80px 80px;
  -webkit-mask-image: radial-gradient(ellipse 60% 60% at 50% 50%, #000 10%, transparent 75%);
  mask-image: radial-gradient(ellipse 60% 60% at 50% 50%, #000 10%, transparent 75%);
  pointer-events: none;
}
.notfound .container { position: relative; padding-block: 96px; }
.notfound__title {
  margin-top: 24px;
  font-size: clamp(2.5rem, 1.4rem + 4.5vw, 5.5rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.045em;
}
.notfound__link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 40px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line-2);
  transition: border-color 0.3s ease;
}
.notfound__link:hover { border-color: var(--sage); }

/* Legal pages */
.legal__updated { grid-column: 4 / span 9; }
@media (max-width: 900px) {
  .legal__updated { grid-column: 1 / -1; }
}

.prose { max-width: 46rem; color: var(--text-2); }
.prose h2 {
  margin-top: 56px;
  font-size: clamp(1.375rem, 1.1rem + 0.8vw, 1.75rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text);
}
.prose h2:first-child { margin-top: 0; }
.prose p,
.prose ul,
.prose address { margin-top: 16px; }
.prose address { font-style: normal; }
.prose .nowrap { white-space: nowrap; }
.prose strong { font-weight: 500; color: var(--text); }
.prose ul li { position: relative; padding-left: 20px; }
.prose ul li + li { margin-top: 10px; }
.prose ul li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.68em;
  width: 5px;
  height: 5px;
  background: var(--sage);
}
.prose a,
.site-footer__legal a {
  color: var(--text);
  border-bottom: 1px solid var(--line-2);
  transition: border-color 0.3s ease;
}
.prose a:hover,
.site-footer__legal a:hover { border-color: var(--sage); }

/* Scroll reveals (enabled by site.js) */
@media (prefers-reduced-motion: no-preference) {
  .js [data-reveal] {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
    transition-delay: calc(var(--d, 0) * 90ms);
  }
  .js [data-reveal].is-in { opacity: 1; transform: none; }
}
