/* ==========================================================================
   NISYS — styles
   Dark theme by default, light theme via [data-theme="light"] (see theme.js):
   warm black or pale sand ground, orange accent, warm neutrals.
   ========================================================================== */

:root {
  color-scheme: dark;

  --bg:      #0B0806;
  --bg-2:    #120D09;
  --bg-3:    #1D1610;
  --bg-rgb:  11,8,6;
  --line:    rgba(248,238,228, 0.10);
  --line-2:  rgba(248,238,228, 0.18);

  --ink:     #F8EEE4;
  --ink-2:   #C9B8A8;
  --ink-3:   #9A8877;
  --ink-rgb: 248,238,228;

  --ember:   #FF8A3D;
  --ember-2: #FFB37D;
  --ember-rgb:   255,138,61;
  --ember-2-rgb: 255,179,125;
  --ember-dim: rgba(255,138,61, 0.16);
  --on-ember: #1F0D02;
  --moss:    #FCD34D;

  --font-display: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --wrap: 1200px;
  --gutter: clamp(16px, 4vw, 48px);
  --radius: 6px;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.5rem;
  --step-3: clamp(1.75rem, 1.2rem + 2vw, 2.75rem);
  --step-4: clamp(2.25rem, 1.4rem + 3.4vw, 4.25rem);
  --step-5: clamp(2.75rem, 1.6rem + 5vw, 6rem);
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg:      #FBF7F2;
  --bg-2:    #F5EEE6;
  --bg-3:    #EBDFD2;
  --bg-rgb:  251,247,242;
  --line:    rgba(31,20,11, 0.10);
  --line-2:  rgba(31,20,11, 0.18);

  --ink:     #1F140B;
  --ink-2:   #4A3C30;
  --ink-3:   #6B5A4B;
  --ink-rgb: 31,20,11;

  --ember:   #A34200;
  --ember-2: #7F3300;
  --ember-rgb:   163,66,0;
  --ember-2-rgb: 127,51,0;
  --ember-dim: rgba(163,66,0, 0.10);
  --on-ember: #FFFFFF;
  --moss:    #8A5000;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; overflow-x: clip; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, canvas, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
p { margin: 0; }
h1, h2, h3 { margin: 0; font-family: var(--font-display); text-wrap: balance; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
em { font-style: italic; }

:focus-visible { outline: 2px solid var(--ember); outline-offset: 3px; border-radius: 2px; }

.skip {
  position: absolute; left: 16px; top: -100px;
  padding: 10px 14px; background: var(--ember); color: var(--on-ember); z-index: 100;
  font-weight: 600;
}
.skip:focus { top: 16px; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* --- type roles ---------------------------------------------------------- */

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex; align-items: center; gap: 12px;
}
.eyebrow .num {
  color: var(--ember);
  font-weight: 500;
}
.eyebrow .num::after {
  content: "";
  display: inline-block;
  width: 24px; height: 1px;
  background: var(--ember);
  margin-left: 12px;
  vertical-align: middle;
}

.display {
  font-size: var(--step-4);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 96;
  max-width: 20ch;
}

.lede {
  font-size: var(--step-1);
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 62ch;
}

.grid__body > p:not(.lede) {
  color: var(--ink-2);
  max-width: 62ch;
}

/* --- buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 10px;
  padding: 14px 22px;
  border-radius: 999px;
  background: var(--ember);
  color: var(--on-ember);
  font-weight: 600;
  font-size: var(--step--1);
  letter-spacing: 0.01em;
  border: 1px solid var(--ember);
  transition: background .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--ember-2); border-color: var(--ember-2); }
.btn:active { transform: translateY(1px); }
.btn--ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-2);
}
.btn--ghost:hover { background: rgba(var(--ink-rgb),0.06); border-color: var(--ink-2); color: var(--ink); }
.btn--small { padding: 9px 16px; font-size: 0.8125rem; }

/* --- nav ----------------------------------------------------------------- */

.nav {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 50;
  background: rgba(var(--bg-rgb), 0.72);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  border-bottom: 1px solid var(--line);
}
.nav__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px;
  min-height: 68px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); }
.nav__inner > .brand { margin-right: auto; }
.brand__mark { width: 34px; height: 20px; color: var(--ember); }
.brand__name {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.18em;
  font-size: 1rem;
}
.nav__links {
  display: flex; align-items: center; gap: 28px;
  font-size: var(--step--1);
  color: var(--ink-2);
}
.nav__links a:not(.btn):hover { color: var(--ink); }
.theme-toggle {
  flex: none;
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  color: var(--ink-2);
  transition: color .2s ease, border-color .2s ease;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-2); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle__moon,
:root[data-theme="light"] .theme-toggle__sun { display: none; }
:root[data-theme="light"] .theme-toggle__moon { display: block; }
html:not([data-theme]) .theme-toggle { display: none; }
@media (min-width: 761px) { .theme-toggle { order: 1; } }
.nav__toggle {
  display: none;
  width: 44px; height: 44px;
  flex-direction: column; justify-content: center; align-items: center; gap: 6px;
}
.nav__toggle span { display: block; width: 22px; height: 2px; background: var(--ink); transition: transform .25s ease, opacity .25s ease; }
.nav__toggle[aria-expanded="true"] span:first-child { transform: translateY(4px) rotate(45deg); }
.nav__toggle[aria-expanded="true"] span:last-child { transform: translateY(-4px) rotate(-45deg); }

@media (max-width: 760px) {
  .nav__toggle { display: flex; }
  .nav__links {
    position: absolute; left: 0; right: 0; top: 100%;
    flex-direction: column; align-items: flex-start;
    gap: 4px;
    padding: 12px var(--gutter) 20px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    display: none;
  }
  .nav__links.is-open { display: flex; }
  .nav__links a:not(.btn) { padding: 10px 0; font-size: var(--step-1); }
  .nav__links .btn { margin-top: 8px; }
}

/* --- hero ---------------------------------------------------------------- */

.hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border-bottom: 1px solid var(--line);
}
.hero__canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: -2;
}
.hero__scrim {
  position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(90deg, rgba(var(--bg-rgb),0.92) 0%, rgba(var(--bg-rgb),0.72) 45%, rgba(var(--bg-rgb),0.25) 100%),
    linear-gradient(180deg, rgba(var(--bg-rgb),0.4) 0%, rgba(var(--bg-rgb),0) 30%, rgba(var(--bg-rgb),0.6) 100%);
}
.hero__inner {
  padding-block: clamp(72px, 12vw, 160px) clamp(64px, 10vw, 140px);
  display: grid;
  gap: 28px;
  max-width: calc(var(--wrap));
}
.hero__title {
  font-size: var(--step-5);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.025em;
  font-variation-settings: "opsz" 96;
  max-width: 16ch;
}
.hero__lede {
  font-size: var(--step-1);
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 58ch;
}
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hero__note {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: var(--step-1);
  color: var(--ember-2);
  margin-top: 8px;
}
.hero__readout {
  position: absolute; right: var(--gutter); bottom: 20px;
  display: flex; gap: 12px; align-items: baseline;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  text-transform: uppercase;
}
.hero__readout-value { color: var(--ember); font-variant-numeric: tabular-nums; font-size: 0.875rem; }
@media (max-width: 560px) { .hero__readout { display: none; } }

/* --- sections ------------------------------------------------------------ */

.section {
  padding-block: clamp(72px, 10vw, 140px);
  border-bottom: 1px solid var(--line);
}
.grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 8fr);
  column-gap: clamp(24px, 5vw, 80px);
  row-gap: 24px;
  align-items: start;
}
.grid__label { position: sticky; top: calc(68px + 32px + env(safe-area-inset-top, 0px)); }
.grid__body { display: grid; gap: 28px; }
@media (max-width: 760px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .grid__label { position: static; }
}

/* mission */
.section--mission { background: var(--bg-2); }
.pillars {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid var(--line-2);
  margin-top: 12px;
}
.pillars li {
  padding: 24px 24px 28px 0;
  display: grid; gap: 10px;
  border-right: 1px solid var(--line);
}
.pillars li:not(:first-child) { padding-left: 24px; }
.pillars li:last-child { border-right: 0; }
.pillars__k { font-family: var(--font-display); font-weight: 600; font-size: var(--step-1); color: var(--moss); }
.pillars__v { color: var(--ink-2); font-size: var(--step--1); line-height: 1.55; }
@media (max-width: 760px) {
  .pillars { grid-template-columns: minmax(0, 1fr); }
  .pillars li { border-right: 0; border-bottom: 1px solid var(--line); padding-left: 0 !important; }
  .pillars li:last-child { border-bottom: 0; }
}

/* problem */
.flow {
  margin: 12px 0 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: stretch;
  gap: 0;
}
.flow__step {
  padding: 20px 18px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  display: grid; gap: 6px; align-content: start;
  background: var(--bg-2);
}
.flow__step--waste {
  border-color: var(--ember);
  background: var(--ember-dim);
}
.flow__k { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink); }
.flow__step--waste .flow__k { color: var(--ember); }
.flow__v { font-size: var(--step--1); color: var(--ink-2); line-height: 1.5; }
.flow__arrow {
  width: 36px; align-self: center; height: 1px; background: var(--line-2); position: relative;
}
.flow__arrow::after {
  content: ""; position: absolute; right: -1px; top: -4px;
  border: 4.5px solid transparent; border-left-color: var(--line-2); border-right: 0;
}
.flow figcaption {
  grid-column: 1 / -1;
  margin-top: 16px;
  color: var(--ink-3);
  font-size: var(--step--1);
  line-height: 1.55;
  max-width: 62ch;
}
@media (max-width: 760px) {
  .flow { grid-template-columns: minmax(0, 1fr); row-gap: 0; }
  .flow__arrow { width: 1px; height: 28px; justify-self: center; }
  .flow__arrow::after {
    right: -4px; top: auto; bottom: -1px;
    border: 4.5px solid transparent; border-top-color: var(--line-2); border-bottom: 0;
  }
}

.costs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(20px, 3vw, 40px);
  border-top: 1px solid var(--line-2);
  padding-top: 28px;
}
.costs__item { display: grid; gap: 8px; align-content: start; }
.costs__k { font-family: var(--font-display); font-weight: 600; font-size: var(--step-1); }
.costs__item p { font-size: var(--step--1); color: var(--ink-2); line-height: 1.55; }
@media (max-width: 760px) { .costs { grid-template-columns: minmax(0, 1fr); } }

/* approach + demo */
.section--approach { background: var(--bg-2); }
.demo {
  margin-top: clamp(48px, 6vw, 80px);
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}
.demo__viz {
  position: relative;
  aspect-ratio: 1 / 1;
  max-width: 100%;
  background:
    radial-gradient(ellipse at center, rgba(var(--ember-rgb),0.08), transparent 60%),
    var(--bg);
  border-right: 1px solid var(--line);
}
.demo__viz canvas { width: 100%; height: 100%; }
.demo__panel {
  min-width: 0;
  padding: clamp(24px, 3vw, 40px);
  display: grid; gap: 18px; align-content: start;
}
.demo__title { font-size: var(--step-2); font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; }
.demo__text { color: var(--ink-2); font-size: var(--step--1); line-height: 1.55; }
.demo__control { display: grid; gap: 10px; font-size: var(--step--1); color: var(--ink-2); }
.demo__control-row { display: flex; justify-content: space-between; align-items: baseline; }
.demo__control output { font-family: var(--font-mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.demo__control em, .demo__stat em { font-family: var(--font-mono); font-style: italic; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 28px; background: transparent; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: var(--line-2); border-radius: 1px; }
input[type="range"]::-moz-range-track { height: 2px; background: var(--line-2); border-radius: 1px; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--ember); border: 2px solid var(--bg);
  margin-top: -8px; box-shadow: 0 0 0 1px var(--ember);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--ember); border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--ember);
}

.demo__stat {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center; gap: 14px;
  font-size: var(--step--1); color: var(--ink-2);
}
.meter { height: 6px; background: var(--bg-3); border-radius: 3px; overflow: hidden; }
.meter__fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--ember), var(--ember-2)); transition: width .12s linear; }
.demo__stat-v { font-family: var(--font-mono); color: var(--ink); font-variant-numeric: tabular-nums; min-width: 4ch; text-align: right; }
.demo__actions { display: flex; flex-wrap: wrap; gap: 10px; }
.demo__formula {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--ink-3);
  padding-top: 14px;
  border-top: 1px solid var(--line);
  overflow-x: auto;
  white-space: nowrap;
}
@media (max-width: 860px) {
  .demo { grid-template-columns: minmax(0, 1fr); }
  .demo__viz { border-right: 0; border-bottom: 1px solid var(--line); }
}

/* build */
.stack { counter-reset: stack; display: grid; border-top: 1px solid var(--line-2); margin-top: 12px; }
.stack__item {
  counter-increment: stack;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 8px 16px;
  padding: 26px 0;
  border-bottom: 1px solid var(--line);
}
.stack__item::before {
  content: counter(stack, decimal-leading-zero);
  font-family: var(--font-mono);
  color: var(--ember);
  font-size: 0.8125rem;
  padding-top: 5px;
  grid-row: 1 / span 2;
}
.stack__k { font-family: var(--font-display); font-weight: 600; font-size: var(--step-1); }
.stack__item p { grid-column: 2; color: var(--ink-2); font-size: var(--step--1); line-height: 1.55; max-width: 60ch; }

/* join */
.section--join { background: var(--bg-2); }
.roles {
  margin-top: clamp(40px, 5vw, 64px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.role {
  padding: clamp(22px, 2.6vw, 32px);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--bg);
  display: grid; gap: 14px; align-content: start;
  transition: border-color .2s ease;
}
.role:hover { border-color: var(--ember); }
.role__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.role__title { font-size: var(--step-2); font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; }
.role__apply {
  flex: none;
  font-family: var(--font-mono);
  font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ember);
  padding: 6px 0;
  border-bottom: 1px solid currentColor;
}
.role__apply:hover { color: var(--ember-2); }
.role__tags {
  font-family: var(--font-mono);
  font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3); line-height: 1.7;
}
.role__text { color: var(--ink-2); font-size: var(--step--1); line-height: 1.55; }
@media (max-width: 760px) { .roles { grid-template-columns: minmax(0, 1fr); } }

.speculative {
  margin-top: 20px;
  padding: clamp(22px, 2.6vw, 32px);
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px; align-items: center;
}
.speculative > div { display: grid; gap: 10px; }
.speculative__text { color: var(--ink-2); font-size: var(--step--1); line-height: 1.55; max-width: 64ch; }
@media (max-width: 760px) { .speculative { grid-template-columns: minmax(0, 1fr); } }

/* contact */
.contact { display: flex; flex-wrap: wrap; align-items: center; gap: 18px 24px; }
.contact__mail {
  font-family: var(--font-display);
  font-size: var(--step-3);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ember);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease;
  word-break: break-all;
}
.contact__mail:hover { border-color: var(--ember); }

/* footer */
.footer { padding-block: clamp(48px, 6vw, 80px) 0; }
.footer__inner {
  display: grid;
  grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr));
  gap: 32px;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--line);
}
.footer__brand { display: grid; gap: 16px; align-content: start; }
.footer__tag { color: var(--ink-3); font-size: var(--step--1); max-width: 34ch; }
.footer__col { display: grid; gap: 10px; align-content: start; font-size: var(--step--1); color: var(--ink-2); }
.footer__col a:hover { color: var(--ink); }
.footer__h { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px; }
.footer__bottom { padding-block: 22px 28px; color: var(--ink-3); font-size: 0.8125rem; }
@media (max-width: 760px) {
  .footer__inner { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer__brand { grid-column: 1 / -1; }
}

/* legal pages */
.legal { padding-block: clamp(56px, 8vw, 120px); }
.legal .wrap { display: grid; gap: 28px; max-width: 760px; }
.legal h1 { font-size: var(--step-4); font-weight: 500; letter-spacing: -0.02em; line-height: 1.05; }
.legal h2 { font-size: var(--step-2); font-weight: 600; margin-top: 12px; }
.legal p, .legal li { color: var(--ink-2); max-width: 65ch; }
.legal ul { list-style: disc; padding-left: 1.2em; display: grid; gap: 6px; }
.legal .placeholder { color: var(--ember-2); font-family: var(--font-mono); font-size: 0.9em; }
.legal a { color: var(--ember); border-bottom: 1px solid transparent; }
.legal a:hover { border-color: currentColor; }

/* motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
