/* ===========================================================
   saife — design tokens
   Palette derived from the validated dataviz reference palette.
   =========================================================== */
:root {
  color-scheme: light;

  --page:        #f9f9f7;
  --surface:     #fcfcfb;
  --surface-alt: #ffffff;
  --ink:         #0b0b0b;
  --ink-2:       #52514e;
  --ink-muted:   #898781;
  --line:        #e1e0d9;
  --line-strong: #c3c2b7;

  --blue:        #2a78d6;
  --blue-dark:   #184f95;
  --blue-tint:   #eef5fd;
  --orange:      #eb6834;
  --orange-tint: #fdf0e9;
  --aqua:        #1baf7a;
  --aqua-tint:   #eafaf4;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;

  --shadow-1: 0 1px 2px rgba(11,11,11,0.06), 0 1px 1px rgba(11,11,11,0.04);
  --shadow-2: 0 12px 32px rgba(11,11,11,0.08), 0 2px 8px rgba(11,11,11,0.05);

  --max: 1120px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page:        #0d0d0d;
    --surface:     #17171a;
    --surface-alt: #1c1c1f;
    --ink:         #ffffff;
    --ink-2:       #c3c2b7;
    --ink-muted:   #918f88;
    --line:        #2c2c2a;
    --line-strong: #3a3a37;

    --blue:        #4b93e8;
    --blue-dark:   #86b6ef;
    --blue-tint:   #16253a;
    --orange:      #e98456;
    --orange-tint: #3a2418;
    --aqua:        #2fc78e;
    --aqua-tint:   #113228;

    --shadow-1: 0 1px 2px rgba(0,0,0,0.4);
    --shadow-2: 0 12px 32px rgba(0,0,0,0.45);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--page);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding-inline: clamp(20px, 5vw, 32px);
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--blue);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  z-index: 1000;
}
.skip-link:focus { left: 0; }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
}
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; display: block; }
.brand .tag {
  font-weight: 500;
  font-size: 0.7rem;
  color: var(--ink-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-left: 1px solid var(--line);
  padding-left: 10px;
  margin-left: 2px;
}

nav.primary-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
nav.primary-nav a {
  color: var(--ink-2);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}
nav.primary-nav a:hover { color: var(--ink); background: var(--surface-alt); text-decoration: none; }

.nav-cta {
  background: var(--blue) !important;
  color: #fff !important;
}
.nav-cta:hover { background: var(--blue-dark) !important; }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.nav-toggle svg { width: 20px; height: 20px; stroke: var(--ink); }

/* ---------- Hero ---------- */
.hero {
  padding: clamp(48px, 9vw, 96px) 0 clamp(32px, 6vw, 64px);
}
.hero .wrap { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 20px; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--blue-tint);
  color: var(--blue-dark);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 7px 14px;
  border-radius: 999px;
}
.hero h1 {
  font-size: clamp(2.1rem, 5.2vw, 3.6rem);
  line-height: 1.08;
  margin: 4px 0 0;
  max-width: 18ch;
  letter-spacing: -0.02em;
}
.hero .lede {
  max-width: 62ch;
  font-size: clamp(1.05rem, 2.1vw, 1.3rem);
  color: var(--ink-2);
  margin: 0;
}
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 22px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.98rem;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-alt); text-decoration: none; }

.hero-line {
  margin-top: 28px;
  font-weight: 700;
  font-size: clamp(1.2rem, 2.6vw, 1.6rem);
  color: var(--ink);
}
.hero-line .accent { color: var(--blue); }

/* ---------- Sections ---------- */
section.block {
  padding: clamp(40px, 7vw, 76px) 0;
  border-top: 1px solid var(--line);
}
section.block.tight { padding-top: clamp(24px, 4vw, 40px); }
.block-head {
  max-width: 74ch;
  margin: 0 0 28px;
}
.kicker {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 8px;
}
h2 {
  font-size: clamp(1.5rem, 3.2vw, 2.1rem);
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}
h2 .sub {
  display: block;
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink-2);
  margin-top: 8px;
}
h3 {
  font-size: 1.15rem;
  margin: 0 0 8px;
}
p { margin: 0 0 14px; color: var(--ink-2); }
.prose p:last-child { margin-bottom: 0; }
.prose strong { color: var(--ink); }
.lead-line {
  font-size: 1.15rem;
  color: var(--ink);
  font-weight: 600;
}
.pull {
  font-size: clamp(1.15rem, 2.4vw, 1.45rem);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
  margin: 18px 0;
  padding-left: 18px;
  border-left: 3px solid var(--blue);
}
.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 32px;
}
.prose ul { margin: 0 0 14px; padding-left: 1.2em; color: var(--ink-2); }
.prose li { margin-bottom: 6px; }

/* ---------- Cards / grids ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 16px;
}
.card-grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  box-shadow: var(--shadow-1);
}
.card .icon-dot {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--blue-tint);
  color: var(--blue-dark);
  margin-bottom: 12px;
  font-size: 1.1rem;
}
.card h3 { margin-bottom: 6px; }
.card p { margin-bottom: 0; font-size: 0.95rem; }

/* ---------- Diagrams ---------- */
.diagram-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(18px, 3vw, 32px);
  box-shadow: var(--shadow-1);
  margin: 28px 0 8px;
}
.diagram-caption {
  font-size: 0.85rem;
  color: var(--ink-muted);
  margin-top: 12px;
  text-align: center;
}
.diagram-legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--ink-2);
}
.diagram-legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend-swatch { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* ---------- Timeline ---------- */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item {
  display: grid;
  grid-template-columns: 120px 24px 1fr;
  gap: 0 18px;
}
.tl-phase { font-weight: 700; color: var(--blue-dark); padding: 14px 0; }
.tl-rail { display: flex; flex-direction: column; align-items: center; }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--blue); margin-top: 18px; flex-shrink: 0; }
.tl-line { flex: 1; width: 2px; background: var(--line); }
.tl-item:last-child .tl-line { display: none; }
.tl-body { padding: 14px 0 26px; }
.tl-body h3 { margin-bottom: 4px; font-size: 1.05rem; }
.tl-body p { margin-bottom: 0; font-size: 0.95rem; }

/* ---------- Quote / mission ---------- */
.mission-block {
  background: linear-gradient(180deg, var(--blue-tint), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(28px, 5vw, 48px);
  text-align: center;
}
.mission-block p { color: var(--ink-2); max-width: 60ch; margin: 0 auto 12px; }
.mission-block .pull { border: none; padding: 0; margin: 10px auto; max-width: 44ch; }

/* ---------- Join / form ---------- */
.join-panel {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 40px;
  align-items: start;
}
.join-copy .pull { margin-top: 0; }
.join-copy ul { padding-left: 1.1em; color: var(--ink-2); }

.form-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(22px, 3vw, 30px);
  box-shadow: var(--shadow-2);
}
.form-card h3 { margin-bottom: 4px; }
.form-card .form-sub { color: var(--ink-2); font-size: 0.92rem; margin-bottom: 20px; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}
.field input, .field textarea {
  width: 100%;
  font: inherit;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--ink);
}
.field input:focus, .field textarea:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
  border-color: var(--blue);
}
.field .hint { font-size: 0.78rem; color: var(--ink-muted); margin-top: 4px; }
.field-optional label::after {
  content: " (optional)";
  font-weight: 400;
  color: var(--ink-muted);
}

.form-actions { display: flex; align-items: center; gap: 14px; margin-top: 6px; }
.form-note { font-size: 0.78rem; color: var(--ink-muted); }

.form-status {
  margin-top: 14px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  display: none;
}
.form-status.ok { display: block; background: var(--aqua-tint); color: #0b3d2b; border: 1px solid var(--aqua); }
.form-status.err { display: block; background: var(--orange-tint); color: #5a2a10; border: 1px solid var(--orange); }
@media (prefers-color-scheme: dark) {
  .form-status.ok { color: #bdf2dd; }
  .form-status.err { color: #ffd9c2; }
}

/* honeypot */
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Flow / pipeline diagrams ---------- */
.flow {
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.flow-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0;
}
.flow-row-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  text-align: center;
  margin-bottom: 10px;
}
.flow-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 4px;
  min-width: 118px;
  padding: 14px 12px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--line-strong);
  background: var(--surface-alt);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}
.flow-node .fn-icon { font-size: 1.3rem; line-height: 1; }
.flow-node .fn-note { font-size: 0.72rem; font-weight: 500; color: var(--ink-muted); }
.flow-node.local { border-color: var(--blue); background: var(--blue-tint); color: var(--blue-dark); }
.flow-node.cloud { border-color: var(--line-strong); background: var(--surface); color: var(--ink-2); }
.flow-node.action { border-color: var(--aqua); background: var(--aqua-tint); color: #0b3d2b; }
.flow-node.condition { border-style: dashed; border-color: var(--orange); background: var(--orange-tint); color: #7a3413; }
@media (prefers-color-scheme: dark) {
  .flow-node.action { color: #bdf2dd; }
  .flow-node.condition { color: #ffd9c2; }
}

.flow-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
  padding: 0 6px;
  flex-shrink: 0;
}
.flow-arrow svg { width: 26px; height: 16px; }
.flow-arrow.down { display: none; }
.flow-arrow.maybe { color: var(--orange); }

.flow-divider {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-muted);
  position: relative;
  margin: 2px 0;
}
.flow-divider span {
  background: var(--surface);
  padding: 0 12px;
  position: relative;
  z-index: 1;
}
.flow-divider::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  border-top: 1px dashed var(--line);
}

@media (max-width: 640px) {
  .flow-row { flex-direction: column; }
  .flow-arrow.across { display: none; }
  .flow-arrow.down { display: flex; }
  .flow-arrow.down svg { transform: rotate(90deg); }
  .flow-node { width: 100%; max-width: 260px; }
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 32px 0 40px;
  color: var(--ink-muted);
  font-size: 0.85rem;
}
.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.footer-brand { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-weight: 600; }
.footer-brand img { width: 22px; height: 22px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .join-panel { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  nav.primary-nav { display: none; }
  .nav-toggle { display: flex; }
  .card-grid { grid-template-columns: 1fr; }
  .tl-item { grid-template-columns: 88px 20px 1fr; }
  body.nav-open nav.primary-nav {
    display: flex;
    position: fixed;
    inset: 68px 0 auto 0;
    background: var(--page);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    align-items: stretch;
    padding: 10px 16px 16px;
    gap: 2px;
    box-shadow: var(--shadow-2);
  }
  body.nav-open nav.primary-nav a { padding: 12px 10px; }
}
