/* =========================================================================
   MantaSys home page (index.html); about.html builds on it
   Loaded after brand.css, which supplies the IBM Plex @font-face rules and the
   font tokens. site.css is not loaded: this page has its own dark layout.

   How the motion works: story.js writes --p (0 → 1) on each .scene as you
   scroll through it. Elements turn that into a local --t with
       --t: clamp(0, (var(--p) - var(--a)) / var(--w), 1)
   i.e. "start at --a, take --w of the scene to finish". Every animated rule is
   scoped to html.js, so without the script, or with reduced motion, the page
   shows every scene in its finished state.
   ========================================================================= */

:root {
  --bg:   #0F1623;   /* Deep Navy */
  --bg-2: #141D2D;
  --bg-3: #1C2638;
  --fg:   #E8EBF0;
  --fg-2: #B4BBC7;
  --fg-3: #8A93A2;   /* lowest grey used for text: 5.6:1 on --bg */
  --fg-4: #4A5465;   /* strokes and decoration only */
  --line:   rgba(232, 235, 240, 0.14);
  --line-2: rgba(232, 235, 240, 0.07);
  --teal:      #0D9488;   /* Ocean Teal, fills */
  --teal-hi:   #2DD4BF;   /* teal for text and strokes on navy */
  --teal-tint: rgba(45, 212, 191, 0.10);
  --bar-bg:    rgba(15, 22, 35, .72);
  --soft:      rgba(232, 235, 240, .06);   /* faint fills: sketch blocks */
  --row:       rgba(232, 235, 240, .12);   /* UI rows in the software window */
  --warn:      #F2C98B;                     /* ?/! marks and placeholders */
  --warn-tint: rgba(242, 201, 139, .16);
  --warn-line: rgba(242, 201, 139, .5);
  --alarm:     #E28A7A;                     /* waste and email tangles */
  --cube-gap:  #070B12;                     /* shows between the cube tiles */
  --shadow:    0 30px 60px -30px rgba(0, 0, 0, .6);
  --scheme:    dark;
  --fog:       #080C14;   /* the fog over the floor plan (02) */
  --fog-2:     #121A27;

  --gx: clamp(20px, 6vw, 96px);      /* side gutter */
  --rail-w: 0px;                     /* space kept for the progress rail */
  --ease: cubic-bezier(.2, .7, .1, 1);
}
@media (min-width: 1000px) { :root { --rail-w: 96px; } }

/* Light theme, picked with the switcher in the bar (story.js) and remembered
   per browser. Same brand: paper, ink and the darker accent teal for text. */
:root[data-theme="light"] {
  --bg:   #F7F8FA;
  --bg-2: #FFFFFF;
  --bg-3: #ECEFF3;
  --fg:   #0F1623;
  --fg-2: #3A4454;
  --fg-3: #5B6474;   /* 5.7:1 on --bg */
  --fg-4: #B7BDC8;
  --line:   rgba(15, 22, 35, 0.14);
  --line-2: rgba(15, 22, 35, 0.07);
  --teal-hi:   #0F766E;
  --teal-tint: rgba(13, 148, 136, 0.08);
  --bar-bg:    rgba(247, 248, 250, .78);
  --soft:      rgba(15, 22, 35, .05);
  --row:       rgba(15, 22, 35, .10);
  --warn:      #9A5B00;
  --warn-tint: rgba(217, 140, 30, .14);
  --warn-line: rgba(154, 91, 0, .45);
  --alarm:     #C2410C;
  --cube-gap:  #0F1623;
  --shadow:    0 30px 60px -30px rgba(15, 22, 35, .28);
  --scheme:    light;
  --fog:       #D3D8E0;
  --fog-2:     #E3E6EB;
}

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

html {
  background: var(--bg);
  color-scheme: var(--scheme);
  scroll-behavior: smooth;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  transition: background-color .3s, color .3s;
  font-family: var(--display);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
h1, h2, h3, p, dl, dd, figure, ol, ul { margin: 0; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--teal-hi); outline-offset: 3px; }
::selection { background: var(--teal); color: #fff; }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 50;
  background: var(--teal-hi); color: var(--bg); padding: 8px 14px; font-weight: 600;
}
.skip:focus { top: 12px; }

.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--teal-hi);
}

h2 {
  font-size: clamp(1.9rem, 3.6vw, 3.3rem);
  line-height: 1.08;
  letter-spacing: -.03em;
  font-weight: 600;
  margin-top: .35em;
  max-width: 22ch;
  text-wrap: balance;
}

.lede {
  font-size: clamp(1rem, 1.2vw, 1.15rem);
  color: var(--fg-2);
  max-width: 46ch;
}
.lede.dim { color: var(--fg-3); }

/* ---------- Background grid -------------------------------------------- */

/* body is its own stacking context so the fixed z-index:-1 background layers
   (.grid-bg, the sound-wave.js canvas) paint above body's background rather
   than behind it. */
body { isolation: isolate; }

/* The grid was never actually visible (body's background covered it until the
   rule above); the dotted wave from sound-wave.js replaces it. Remove the
   display:none to bring it back, or delete the grid with its <div>. */
.grid-bg { display: none; }

.grid-bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(var(--line-2) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-2) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 45%, #000 30%, transparent 100%);
          mask-image: radial-gradient(ellipse 80% 70% at 50% 45%, #000 30%, transparent 100%);
  animation: drift 40s linear infinite;
  opacity: .7;
}
@keyframes drift { to { background-position: 56px 56px; } }

/* ---------- Top bar ----------------------------------------------------- */

.bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px var(--gx);
  background: var(--bar-bg);
  -webkit-backdrop-filter: blur(12px);
          backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-2);
}
.bar-name {
  display: flex; align-items: center; gap: 10px;
  color: var(--fg); text-decoration: none;
  font-weight: 600; font-size: 1.15rem; letter-spacing: -.025em; line-height: 1;
}
.bar-name svg { width: 28px; height: 28px; flex: none; }
.bar-name .sys { color: var(--teal-hi); }
.bar-links {
  display: flex; align-items: center; gap: clamp(14px, 2.4vw, 30px);
  list-style: none; padding: 0; font-size: .9rem;
}
.bar-links a { color: var(--fg-2); text-decoration: none; }
.bar-links a:hover { color: var(--fg); }
.bar-links .bar-cta {
  color: var(--teal-hi); border: 1px solid var(--teal-hi); padding: 6px 14px;
  transition: background-color .2s, color .2s;
}
.bar-links .bar-cta:hover { background: var(--teal-hi); color: var(--bg); }

/* Theme switcher: the icon shows the theme a click switches to.
   The sound button (scene-sound.js) shares the look; its icon shows the current state. */
.theme-btn, .sound-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px; padding: 0;
  background: none; color: var(--fg-2); cursor: pointer;
  border: 1px solid var(--line);
  transition: color .2s, border-color .2s;
}
.theme-btn[hidden], .sound-btn[hidden] { display: none; }
.theme-btn:hover, .sound-btn:hover { color: var(--fg); border-color: var(--fg-3); }
.theme-btn svg, .sound-btn svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round;
}
.theme-btn .i-moon { display: none; }
[data-theme="light"] .theme-btn .i-moon { display: block; }
[data-theme="light"] .theme-btn .i-sun { display: none; }
.sound-btn .spk { stroke-linejoin: round; }
.sound-btn .i-on { display: none; }
.sound-btn[aria-pressed="true"] { color: var(--teal-hi); border-color: var(--teal-hi); }
.sound-btn[aria-pressed="true"] .i-on { display: block; }
.sound-btn[aria-pressed="true"] .i-off { display: none; }
@media (max-width: 560px) {
  .bar-links li:nth-child(1), .bar-links li:nth-child(3) { display: none; }
}

/* ---------- Progress rail ---------------------------------------------- */

.rail {
  position: fixed; right: 28px; top: 50%; z-index: 15;
  transform: translateY(-50%);
  display: none;
}
@media (min-width: 1000px) { .rail { display: block; } }
.rail ol { list-style: none; padding: 0; display: grid; gap: 4px; }
.rail a {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 6px 0; text-decoration: none;
  font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
}
.rail-n { color: var(--fg-3); }
.rail-l {
  /* one fixed width, so the numbers line up whatever the label's length */
  width: 6em; text-align: left;
  color: var(--fg-2);
  opacity: 0; transform: translateX(6px);
  transition: opacity .25s, transform .25s;
}
.rail a::after {
  content: ""; width: 8px; height: 8px; flex: none;
  border: 1px solid var(--fg-3);
  transition: background-color .25s, border-color .25s, transform .25s;
}
.rail a:hover .rail-l,
.rail a:focus-visible .rail-l,
.rail a[aria-current] .rail-l { opacity: 1; transform: none; }
.rail a[aria-current] .rail-n,
.rail a[aria-current] .rail-l { color: var(--teal-hi); }
.rail a[aria-current]::after {
  background: var(--teal-hi); border-color: var(--teal-hi); transform: rotate(45deg);
}

/* ---------- Scenes ------------------------------------------------------ */

.scene { position: relative; --p: 1; }
.stage {
  position: relative;
  min-height: 100vh; min-height: 100svh;
  padding: 96px calc(var(--gx) + var(--rail-w)) 56px var(--gx);
  display: grid;
  align-content: center;
}
html.js .scene { height: var(--len, 100vh); --p: 0; }
html.js .stage {
  position: sticky; top: 0;
  height: 100vh; height: 100svh;
  overflow: hidden;
}
@media (max-width: 720px) {
  html.js .scene { height: calc(var(--len, 100vh) * .8); }
  html.js .s-contact { height: auto; }
}

/* The local timeline */
html.js .rv,
html.js .fn,
html.js .demo,
html.js .rv-draw,
html.js .sprout { --t: clamp(0, (var(--p) - var(--a, 0)) / var(--w, .2), 1); }

html.js .rv {
  opacity: var(--t);
  transform: translateY(calc((1 - var(--t)) * 28px));
}
html.js .draw {
  stroke-dasharray: 1 1;
  stroke-dashoffset: calc(1 - var(--t, 1));
}

/* =======================================================================
   01 · Premise
   ======================================================================= */

.s-premise .stage {
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(24px, 4vw, 72px);
}
.headline {
  font-size: clamp(2rem, 3.9vw, 4rem);
  line-height: 1.04;
  letter-spacing: -.038em;
  font-weight: 600;
  margin: .45em 0 .55em;
}
.headline .ln { display: block; overflow: hidden; padding-bottom: .08em; }
.headline .ln > span { display: inline-block; text-wrap: balance; }
.headline em { font-style: normal; color: var(--teal-hi); position: relative; white-space: nowrap; }
.headline em::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -.04em; height: 3px;
  background: var(--teal-hi); transform-origin: left;
}
.premise-lede { display: grid; gap: 14px; }

html.js .headline .ln > span { animation: rise 1s var(--ease) both; }
html.js .headline .ln:nth-child(2) > span { animation-delay: .12s; }
html.js .headline .ln:nth-child(3) > span { animation-delay: .24s; }
html.js .headline em::after { animation: underline .9s var(--ease) .9s both; }
html.js .premise-copy .eyebrow,
html.js .premise-lede { animation: fade-up .9s var(--ease) .55s both; }
html.js .premise-copy .eyebrow { animation-delay: .05s; }
html.js .premise-vis { animation: fade .9s ease .35s both; }
@keyframes rise { from { transform: translateY(105%); } }
@keyframes underline { from { transform: scaleX(0); } }
@keyframes fade-up { from { opacity: 0; transform: translateY(16px); } }
@keyframes fade { from { opacity: 0; } }

.merge { width: 100%; height: auto; max-height: 72vh; overflow: visible; display: block; }
.merge text { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; fill: var(--fg-3); }
.merge .vlabel.one { fill: var(--teal-hi); }

.pm rect { fill: var(--bg-2); stroke: var(--fg-4); }
.pm text {
  font-family: var(--display); font-size: 13px; letter-spacing: 0;
  fill: var(--fg-2); text-anchor: middle;
}
.pm-link { fill: none; stroke: var(--fg-4); stroke-width: 1.2; }
.pm-flow {
  fill: none; stroke: var(--teal-hi); stroke-width: 2;
  stroke-dasharray: 10 360;
  animation: travel 4s linear infinite;
}
@keyframes travel { from { stroke-dashoffset: 370; } to { stroke-dashoffset: 0; } }
.pm-person { fill: none; stroke: var(--fg-3); stroke-width: 1.4; }

.win { fill: var(--bg-2); stroke: var(--fg-4); }
.win-bar { stroke: var(--fg-4); }
.win-dot { fill: var(--fg-4); }
.win-side { fill: var(--bg-3); }
.win-row { stroke: var(--row); stroke-width: 6; }
.win-card { fill: var(--bg-3); }
.win-card.hot { fill: var(--teal-tint); stroke: var(--teal-hi); }
.merge .code { fill: var(--teal-hi); font-size: 11px; letter-spacing: .02em; }
.caret { fill: var(--teal-hi); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.pc path { fill: var(--fg); }
.mark-dot { fill: var(--teal-hi); }
.half, .pc, .mark-dot, .mark { transform-box: fill-box; transform-origin: center; }

/* Without the script there is no merge to watch: show the finished mark. */
html:not(.js) .half,
html:not(.js) .waste,
html:not(.js) .redundant { display: none; }

html.js .s-premise .stage {
  --m: clamp(0, (var(--p) - .04) / .5, 1);    /* the halves come together */
  --d: clamp(0, (var(--p) - .55) / .15, 1);   /* the dot lands */
}
html.js .half-work {
  transform: translateX(calc(var(--m) * 170px)) scale(calc(1 - var(--m) * .55));
  opacity: calc(1 - var(--m) * 1.3);
}
html.js .half-soft {
  transform: translateX(calc(var(--m) * -170px)) scale(calc(1 - var(--m) * .55));
  opacity: calc(1 - var(--m) * 1.3);
}
html.js .pc {
  opacity: clamp(0, var(--m) * 1.6 - .5, 1);
  transform: translate(calc(var(--dx) * (1 - var(--m)) * 1px), calc(var(--dy) * (1 - var(--m)) * 1px));
}
html.js .mark-dot { transform: scale(var(--d)); }
html.js .mark { filter: drop-shadow(0 0 calc(var(--d) * 18px) rgba(45, 212, 191, .35)); }
html.js .merge .vlabel.one { opacity: var(--d); }

.scroll-hint {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%);
  display: grid; justify-items: center; gap: 8px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--fg-3);
}
.scroll-hint::after {
  content: ""; width: 1px; height: 36px;
  background: linear-gradient(var(--teal-hi), transparent);
  animation: hint 1.8s var(--ease) infinite;
  transform-origin: top;
}
@keyframes hint { 0% { transform: scaleY(0); } 60% { transform: scaleY(1); opacity: 1; } 100% { opacity: 0; } }
html:not(.js) .scroll-hint { display: none; }
html.js .scroll-hint { opacity: calc(1 - var(--p) * 8); }

/* =======================================================================
   02 · People (may later replace 03 and 04)
   A floor plan of cubicles. Markup from tools/gen-people-scene.mjs.
     step 1  fog: each person sees only their own corner; steps scattered
     step 2  walls fade, people walk to their doors and talk, the fog lifts,
             duplicates go and the steps line up in the corridor
     step 3  people back at their desks, each wired to their own step
   Phase variables default to 1: without the script it is the finished state.
   ======================================================================= */

.s-people .stage {
  grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
  align-items: center;
  gap: clamp(24px, 4vw, 64px);
  --t1: 1; --t2: 1; --t3: 1;
}
html.js .s-people .stage {
  --t1: clamp(0, (var(--p) - .02) / .31, 1);   /* the lights come up */
  --t2: clamp(0, (var(--p) - .36) / .26, 1);   /* people talk, the process forms */
  --t3: clamp(0, (var(--p) - .69) / .24, 1);   /* back to work, connected */
}
.people-vis svg { width: 100%; height: auto; max-height: 76vh; display: block; overflow: visible; }
.people-vis text {
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  fill: var(--fg-2); stroke: none; text-anchor: middle;
}

.floor { fill: none; stroke: var(--line); }
.walls path {
  fill: none; stroke: var(--fg-3); stroke-width: 3; stroke-linecap: square;
  opacity: calc(1 - var(--t2) * .8);
}
.desks rect { fill: var(--bg-3); stroke: var(--fg-4); }
.desks .screen {
  stroke: none;
  fill: color-mix(in srgb, var(--teal-hi) calc(var(--t3) * 100%), var(--fg-4));
}

/* ---- process steps ---- */
.pt {
  --u: clamp(0, (var(--t2) - .3 - var(--k, 0) * .25) / .45, 1);
  transform-box: view-box; transform-origin: 0 0;
  transform:
    translate(calc((var(--sx) + (var(--ox, var(--sx)) - var(--sx)) * var(--u)) * 1px),
              calc((var(--sy) + (var(--oy, var(--sy)) - var(--sy)) * var(--u)) * 1px))
    translate(39px, 17px) rotate(calc(var(--sr) * (1 - var(--u)) * 1deg)) translate(-39px, -17px);
}
.pt rect {
  stroke-width: 1.2;
  fill: color-mix(in srgb, var(--bg-2) calc(var(--u) * 100%), var(--bg-3));
  stroke: color-mix(in srgb, var(--teal-hi) calc(var(--u) * 100%), var(--fg-3));
}
.people-vis .pt text { font-size: 9.5px; letter-spacing: .06em; fill: var(--fg); }
.pt.dup { opacity: clamp(0, 1 - var(--t2) * 3, 1); }
.pt.dup rect { stroke: var(--fg-4); stroke-dasharray: 3 3; }
.people-vis .pt.dup text { fill: var(--fg-3); }
.pt .strike { stroke: var(--alarm); stroke-width: 1.5; opacity: clamp(0, var(--t2) * 10, 1); }
.pt-in { transform-box: fill-box; transform-origin: center; }
html.js .s-people[data-step="0"] .pt-in { animation: wobble 2.6s ease-in-out infinite alternate; }
html.js .s-people[data-step="0"] .pt:nth-child(3n) .pt-in { animation-delay: -.9s; }
html.js .s-people[data-step="0"] .pt:nth-child(3n+1) .pt-in { animation-delay: -1.7s; }
@keyframes wobble { to { transform: rotate(5deg) translateY(-2px); } }
html.js .s-people[data-step="2"] .pt:not(.dup) rect {
  animation: shimmer 2.8s ease-in-out infinite;
  animation-delay: calc(var(--k) * -2.8s);
}

/* ---- people ---- */
.who {
  --mv: calc(clamp(0, var(--t2) * 2.5, 1) - clamp(0, var(--t3) * 2, 1));
  transform: translateY(calc(var(--dy) * var(--mv) * 1px));
  fill: none; stroke-width: 1.5;
  stroke: color-mix(in srgb, var(--teal-hi) calc(var(--t2) * 100%), var(--fg-2));
}
.who-ring { fill: var(--bg); }
.bub { opacity: clamp(0, min(var(--t2) * 4 - 1, 1 - var(--t3) * 4), 1); }
.bub rect { fill: var(--bg-2); stroke: var(--teal-hi); stroke-width: 1.2; }
.bub circle { fill: var(--teal-hi); stroke: none; animation: talk 1.2s ease-in-out infinite; }
.bub circle:nth-of-type(2) { animation-delay: .2s; }
.bub circle:nth-of-type(3) { animation-delay: .4s; }
.who:nth-child(even) .bub circle { animation-duration: 1.5s; }
@keyframes talk { 50% { opacity: .2; } }
html.js .s-people[data-step="2"] .who-ring { animation: ring 2.4s ease-in-out infinite; }

/* ---- the fog ---- */
.fog { opacity: clamp(0, 1 - var(--t2) * 1.6, 1); }
.fog rect { fill: var(--fog); fill-opacity: .9; }
.mist { fill-opacity: .8; }
.mist { fill: var(--fog-2); animation: mist 14s ease-in-out infinite alternate; }
.mist.m2 { animation-duration: 18s; animation-direction: alternate-reverse; }
.mist.m3 { animation-duration: 22s; }
@keyframes mist { to { transform: translateX(70px); } }
.hole {
  transform-box: fill-box; transform-origin: center;
  transform: scale(calc(.8 + var(--t1) * .2 + var(--t2) * 3));
}

/* ---- work thrown over the walls ---- */
.tosses { opacity: clamp(0, 1 - var(--t2) * 4, 1); }
.toss { fill: none; stroke: var(--fg-4); stroke-dasharray: 3 5; }
.toss-env {
  offset-rotate: 0deg;
  animation: toss 3.4s ease-in-out infinite;
  animation-delay: calc(var(--i) * -1.15s);
}
.toss-env rect { fill: var(--bg-2); }
.toss-env rect, .toss-env path { stroke: var(--warn); stroke-width: 1.2; }
.toss-env path { fill: none; }
@keyframes toss {
  0% { offset-distance: 0%; opacity: 0; }
  15%, 85% { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}
html:not(.js) .tosses { display: none; }

/* ---- the running process ---- */
.pipe { fill: none; stroke: var(--line); stroke-width: 2; opacity: var(--t2); }
.pipe-flow {
  fill: none; stroke: var(--teal-hi); stroke-width: 3; stroke-dasharray: 6 22;
  opacity: clamp(0, var(--t3) * 3 - 1, 1);
  animation: flow 1.4s linear infinite;
}
.pipe-arrow { fill: none; stroke: var(--teal-hi); stroke-width: 2; opacity: var(--t3); }
.lk { --t: var(--t3); fill: none; stroke: var(--teal-hi); stroke-width: 1.5; opacity: .55; }
.lk-pk {
  fill: none; stroke: var(--teal-hi); stroke-width: 3; stroke-dasharray: 4 26;
  opacity: clamp(0, var(--t3) * 4 - 3, 1);
  animation: flow 1.6s linear infinite;
}
.lk-pk.up { animation-direction: reverse; }

/* =======================================================================
   03 · Process
   One process → a pile → a solved cube → a running system with people.
   Each .tile carries three states as variables (see index.html):
     start --sx --sy --w0 (width factor) --o0 (1 = visible at the start)
     pile  --px --py --pr
     cube  --cx --cy --cr (rotate) --cs (skewX); the faces share scale(1, .866)
   --k / --k2 stagger each tile within the pile and the cube phases.
   The phase variables default to 1, so without the script the visual is
   simply the finished future state.
   ======================================================================= */

.s-process .stage {
  grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
  align-items: center;
  gap: clamp(24px, 4vw, 64px);
  --t1: 1; --t2: 1; --t3: 1;
  --top: var(--teal); --left: #DDE2EA; --right: #34445E;
}
html.js .s-process .stage {
  --t1: clamp(0, (var(--p) - .04) / .26, 1);   /* one process → a pile */
  --t2: clamp(0, (var(--p) - .36) / .26, 1);   /* the pile → the cube */
  --t3: clamp(0, (var(--p) - .69) / .24, 1);   /* the cube → the system */
}
.process-copy { order: 2; }
.process-vis { order: 1; }
.process-vis svg { width: 100%; height: auto; max-height: 76vh; display: block; overflow: visible; }

/* ---- tiles ---- */
.tile {
  --u1: clamp(0, (var(--t1) - var(--k) * .5) * 2, 1);
  --u2: clamp(0, (var(--t2) - var(--k2) * .45) / .55, 1);
  --g: calc(var(--o0) + (1 - var(--o0)) * var(--u1));
  transform-box: view-box;
  transform-origin: 0 0;
  transform:
    translate(
      calc((var(--sx) + (var(--px) - var(--sx)) * var(--u1) + (var(--cx) - var(--px)) * var(--u2)) * 1px),
      calc((var(--sy) + (var(--py) - var(--sy)) * var(--u1) + (var(--cy) - var(--py)) * var(--u2)) * 1px))
    rotate(calc((var(--pr) * var(--u1) + (var(--cr) - var(--pr)) * var(--u2)) * 1deg))
    skewX(calc(var(--cs) * var(--u2) * 1deg))
    scale(calc(var(--g) * (var(--w0) + (1 - var(--w0)) * var(--u1))),
          calc(var(--g) * (1 - .134 * var(--u2))));
  opacity: clamp(0, var(--g) * 3, 1);
}
.tile rect {
  vector-effect: non-scaling-stroke;
  stroke-width: 1;
  /* grey and outlined while it is a mess; its face colour once it is sorted */
  fill: color-mix(in srgb, var(--face) calc(var(--u2) * 100%), var(--bg-3));
  stroke: color-mix(in srgb, var(--face) calc(var(--u2) * 100%), var(--fg-3));
}
.f-top   { --face: var(--top); }
.f-left  { --face: var(--left); }
.f-right { --face: var(--right); }

.cube-body { fill: var(--cube-gap); opacity: clamp(0, var(--t2) * 2 - 1, 1); }
.cube-g {
  transform-box: view-box; transform-origin: 320px 230px;
  transform: scale(calc(1 - var(--t3) * .28));
}
/* once it runs, a slow wave passes over the cube */
html.js .s-process[data-step="2"] .tile rect {
  animation: shimmer 2.8s ease-in-out infinite;
  animation-delay: calc(var(--k2) * -2.8s);
}
@keyframes shimmer { 50% { filter: brightness(1.35); } }

/* ---- the opening process ---- */
.start {
  opacity: clamp(0, 1 - var(--t1) * 5, 1);
  fill: none; stroke: var(--teal-hi); stroke-width: 1.5;
}
.process-vis .start text {
  fill: var(--fg); stroke: none; text-anchor: middle;
  font-family: var(--display); font-size: 13px; letter-spacing: 0;
}

/* ---- the mess ---- */
.mess {
  opacity: clamp(0, min(var(--t1) * 1.6 - .3, 1) - var(--t2) * 2.5, 1);
  fill: none; stroke: var(--fg-3); stroke-width: 1.2;
}
.tangle-a { stroke-dasharray: 4 5; animation: jitter 1.2s linear infinite; }
.tangle-b { stroke: var(--alarm); stroke-dasharray: 2 6; animation: jitter 1.6s linear infinite reverse; }
@keyframes jitter { to { stroke-dashoffset: -18; } }
.env rect { fill: var(--bg-2); }
.env { animation: bob 2.2s ease-in-out infinite; }
.env:nth-of-type(2) { animation-delay: -.7s; }
.env:nth-of-type(3) { animation-delay: -1.4s; }
@keyframes bob { 50% { transform: translateY(-5px); } }
.process-vis .mess text {
  fill: var(--warn); stroke: none; font-family: var(--display); font-weight: 600; font-size: 22px;
}

/* ---- the future state ---- */
.fs { opacity: clamp(0, var(--t3) * 3, 1); }
.fs-line { --t: var(--t3); fill: none; stroke: var(--line); stroke-width: 2; }
.fs-in, .fs-out, .fs-up, .fs-down {
  fill: none; stroke-width: 6; stroke-linecap: butt;
  stroke-dasharray: 6 22;
  opacity: clamp(0, var(--t3) * 4 - 3, 1);
  animation: flow 1.4s linear infinite;
}
.fs-in { stroke: var(--fg-3); }
.fs-out { stroke: var(--teal-hi); }
.fs-up, .fs-down { stroke: var(--teal); stroke-width: 4; animation-duration: 1.8s; }
.fs-down { animation-direction: reverse; }
@keyframes flow { to { stroke-dashoffset: -28; } }
.fs-arrow { fill: none; stroke: var(--teal-hi); stroke-width: 2; opacity: var(--t3); }
.station {
  fill: none; stroke: var(--teal-hi); stroke-width: 1.5;
  transform-box: fill-box; transform-origin: center;
  transform: scale(calc(.6 + var(--t3) * .4));
}
.station .st-ring { fill: var(--bg); }
.process-vis .station text {
  fill: var(--fg-2); stroke: none; text-anchor: middle;
  font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
}
.station .st-ring { animation: ring 2.4s ease-in-out infinite; }
/* department icons (tools/icons.mjs) in place of the words */
.ic { fill: none; stroke-linecap: round; stroke-linejoin: round; }@keyframes ring { 50% { stroke-width: 3; } }

/* =======================================================================
   04 · Method
   ======================================================================= */

.s-method .stage {
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  align-items: center;
  gap: clamp(24px, 4vw, 64px);
}
.method-h { max-width: 16ch; }
.mh { display: block; transition: color .5s; }
html.js .mh { color: var(--fg-4); }
html.js .s-method[data-step="0"] .mh[data-i="0"],
html.js .s-method[data-step="1"] .mh[data-i="1"],
html.js .s-method[data-step="2"] .mh[data-i="2"] { color: var(--fg); }
html.js .s-method[data-step="1"] .mh[data-i="0"],
html.js .s-method[data-step="2"] .mh[data-i="0"],
html.js .s-method[data-step="2"] .mh[data-i="1"] { color: var(--fg-3); }

.cards { display: grid; gap: 14px; margin-top: clamp(20px, 4vh, 40px); max-width: 460px; }
.card {
  background: var(--bg-2); border: 1px solid var(--line); border-left: 2px solid var(--teal-hi);
  padding: 18px 22px;
}
.card-k {
  font-family: var(--mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--teal-hi);
}
.card-k span { color: var(--fg-3); margin-right: 6px; }
.card-t { margin-top: 8px; font-size: 1.15rem; font-weight: 600; letter-spacing: -.015em; line-height: 1.3; }
.card-d { margin-top: 6px; color: var(--fg-3); font-size: .95rem; line-height: 1.5; }
html.js .card {
  grid-area: 1 / 1;
  opacity: 0; transform: translateY(18px);
  transition: opacity .5s var(--ease), transform .5s var(--ease);
  pointer-events: none;
}
html.js .scene[data-step="0"] .card[data-i="0"],
html.js .scene[data-step="1"] .card[data-i="1"],
html.js .scene[data-step="2"] .card[data-i="2"] { opacity: 1; transform: none; pointer-events: auto; }

.steps-bar { display: none; }
html.js .steps-bar {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  margin-top: 18px; max-width: 460px;
}
.steps-bar span { position: relative; height: 2px; background: var(--line); }
.steps-bar span::after {
  content: ""; position: absolute; inset: 0; background: var(--teal-hi);
  transform-origin: left;
  transform: scaleX(clamp(0, (var(--p) - var(--a)) / var(--w), 1));
}

.method-vis svg { width: 100%; height: auto; max-height: 74vh; display: block; overflow: visible; }
.method-vis text { font-family: var(--mono); font-size: 12px; letter-spacing: .06em; fill: var(--fg-2); }

.waste { fill: none; stroke: var(--fg-3); stroke-width: 1.5; stroke-dasharray: 5 5; }
.redundant rect { fill: var(--bg); stroke: var(--fg-3); }
.redundant path { stroke: var(--alarm); stroke-width: 1.5; }
.straight { fill: none; stroke: var(--teal-hi); stroke-width: 2.5; }
.steps rect { fill: var(--bg); stroke: var(--teal-hi); stroke-width: 1.5; }
.steps .end { fill: var(--teal); }

.blk rect { fill: var(--bg-2); stroke: var(--fg-4); }
.blk circle, .blk ellipse, .blk path:not(.link):not(.link-flow), .blk rect + rect {
  fill: none; stroke: var(--fg-2); stroke-width: 1.3;
}
.blk > rect:first-of-type { fill: var(--bg-2); stroke: var(--fg-4); stroke-width: 1; }
.link { fill: none; stroke: var(--fg-4); stroke-width: 1.5; }
.link-flow {
  fill: none; stroke: var(--teal-hi); stroke-width: 2;
  stroke-dasharray: 4 10; animation: pulse-down 1s linear infinite;
}
@keyframes pulse-down { to { stroke-dashoffset: -14; } }

.grow { fill: none; stroke: var(--teal-hi); stroke-width: 2; }
.sprout rect { fill: var(--teal-tint); stroke: var(--teal-hi); }
.method-vis .sprout text { fill: var(--teal-hi); font-size: 10px; text-anchor: middle; }
.sprout, .bar { transform-box: fill-box; }
.sprout { transform-origin: center; }
.chart-base { stroke: var(--fg-4); }
.bar {
  fill: var(--teal); transform-origin: 50% 100%;
  transform: scaleY(calc(var(--h) / 44));
}
.ground { stroke: var(--line); }
.robot { color: var(--teal-hi); }
.robot-run { transform: translateX(500px); }
.eye { animation: blink-eye 4s infinite; transform-box: fill-box; transform-origin: center; }
@keyframes blink-eye { 0%, 92%, 100% { transform: none; } 95% { transform: scaleY(.1); } }

html.js .s-method .stage {
  --t1: clamp(0, (var(--p) - .03) / .27, 1);
  --t2: clamp(0, (var(--p) - .36) / .26, 1);
  --t3: clamp(0, (var(--p) - .69) / .26, 1);
}
/* Transform: the wasteful route flattens onto the line, then the line draws */
html.js .waste,
html.js .redundant {
  transform-box: view-box; transform-origin: 0 220px;
  transform: scaleY(calc(1 - var(--t1)));
  opacity: calc(1 - var(--t1) * .9);
}
html.js .straight { --t: var(--t1); }
/* Integrate: blocks drop in, links draw, then flow */
html.js .blk {
  opacity: var(--t2);
  transform: translateY(calc(var(--oy) * (1 - var(--t2)) * 1px));
}
html.js .link { --t: var(--t2); }
html.js .link-flow { opacity: clamp(0, (var(--t2) - .8) * 5, 1); }
/* Evolve: a branch grows, sprouts appear, the chart rises, the robot rolls */
html.js .grow { --t: var(--t3); }
html.js .sprout {
  --w: .06;
  transform: scale(var(--t)); opacity: var(--t);
}
html.js .bar { transform: scaleY(calc(var(--h) / 44 * var(--t3))); }
html.js .robot-run { transform: translateX(calc(-80px + var(--t3) * 580px)); opacity: clamp(0, var(--t3) * 8, 1); }
html.js .chart-base { opacity: var(--t3); }
html.js .wheel { transform: rotate(calc(var(--t3) * 1440deg)); }

/* =======================================================================
   05 · Sandbox
   ======================================================================= */

.s-sandbox .stage { gap: clamp(20px, 4vh, 40px); }
.sandbox-head .lede { margin-top: 14px; }
.demos {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(20px, 3vw, 44px);
  max-width: 1120px;
  perspective: 1400px;
}
.demo {
  display: flex; flex-direction: column;
  background: var(--bg-2); border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
html.js .demo {
  opacity: var(--t);
  transform-origin: 50% 100%;
  transform:
    translateY(calc((1 - var(--t)) * 160px))
    rotateX(calc((1 - var(--t)) * 30deg))
    rotateZ(calc((1 - var(--t)) * var(--tilt)));
}
.demo-frame { display: block; text-decoration: none; border-bottom: 1px solid var(--line); }
.chrome {
  display: flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px; background: var(--bg-3);
}
.chrome i { width: 8px; height: 8px; background: var(--fg-4); }
.chrome .url {
  flex: 1; margin-left: 10px; padding: 2px 10px;
  background: var(--bg); color: var(--fg-3);
  font-family: var(--mono); font-size: 11px; letter-spacing: .04em;
}
.view {
  position: relative; display: block; overflow: hidden;
  aspect-ratio: 16 / 9;
  background: var(--bg-3);
}
.view iframe {
  position: absolute; top: 0; left: 0;
  width: 1280px; height: 720px; border: 0;
  transform: scale(var(--s, .4)); transform-origin: 0 0;
  pointer-events: none;
  opacity: 0; transition: opacity .8s ease;
  background: #E8E0DB;
}
.view iframe.is-loaded { opacity: 1; }
/* Shown until (or instead of) the live preview */
.sketch {
  position: absolute; inset: 0; padding: 6%;
  display: grid; grid-template-columns: 1fr 3fr 3fr; grid-template-rows: 1fr 2fr 2fr; gap: 6px;
}
.sketch b { background: var(--soft); }
.sketch b:nth-child(1) { grid-row: 1 / 4; }
.sketch b:nth-child(2) { grid-column: 2 / 4; background: var(--teal-tint); }
.demo-frame:hover .view::after {
  content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 2px var(--teal-hi);
}

.demo-body { padding: 18px 22px 22px; display: grid; gap: 8px; }
.tags { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; color: var(--fg-3); }
.demo h3 { font-size: 1.2rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.25; }
.demo-body > p:not(.tags) { color: var(--fg-3); font-size: .95rem; line-height: 1.5; }
.go, .all-demos a, .more a {
  justify-self: start;
  color: var(--teal-hi); text-decoration: none;
  border-bottom: 1px solid currentColor; padding-bottom: 2px;
  font-weight: 500;
}
.go:hover, .all-demos a:hover, .more a:hover { color: var(--fg); }

/* =======================================================================
   Feature scenes (sandbox/index.html, work.html)
   A framed preview (.demo, as in 05 · Sandbox) beside its copy and a
   numbered list (.try) whose items light up in turn. Add .flip to put the
   preview on the right. Pair with data-cues="stop:.try li" for the sound.
   ======================================================================= */

.s-demo .stage {
  grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr);
  align-items: center;
  gap: clamp(24px, 4vw, 64px);
  perspective: 1400px;   /* for the preview’s tilt-in, as .demos has */
}
.s-demo.flip .stage { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); }
.s-demo.flip .demo { order: 2; }

.demo-copy { display: grid; gap: 12px; justify-items: start; }
.demo-copy h2 { margin-top: 0; font-size: clamp(1.7rem, 2.8vw, 2.7rem); max-width: 18ch; }
.demo-copy .lede { max-width: 50ch; }

/* a pulsing dot before an eyebrow: "Live demo", "Live site" */
.live { display: inline-flex; align-items: center; gap: 8px; }
.live::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--teal-hi);
  animation: live 2.2s ease-out infinite;
}
.live.is-soon::before { background: var(--warn); animation: none; }
@keyframes live {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--teal-hi) 60%, transparent); }
  100% { box-shadow: 0 0 0 9px transparent; }
}

.try-k {
  margin-top: 6px;
  font-family: var(--mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--fg-2);
}
.try {
  list-style: none; padding: 0; counter-reset: try;
  display: grid; gap: 8px; width: 100%;
}
.try li {
  counter-increment: try;
  position: relative;
  padding: 10px 14px 10px 46px;
  background: var(--bg-2); border: 1px solid var(--line);
  color: var(--fg-2); font-size: .95rem; line-height: 1.45;
  --t: 1;
}
.try li::before {
  content: counter(try, decimal-leading-zero);
  position: absolute; left: 14px; top: 11px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .1em;
  color: var(--teal-hi);
}
.try li::after {
  content: ""; position: absolute; left: -1px; top: -1px; bottom: -1px; width: 2px;
  background: var(--teal-hi);
  transform: scaleY(var(--t)); transform-origin: top;
}
.try strong { color: var(--fg); font-weight: 600; }
html.js .try li {
  --t: clamp(0, (var(--p) - var(--a)) / .1, 1);
  opacity: calc(.15 + var(--t) * .85);
  transform: translateX(calc((1 - var(--t)) * 24px));
}
html.js .s-demo.flip .try li { transform: translateX(calc((1 - var(--t)) * -24px)); }

@media (max-height: 900px) and (min-width: 721px) {
  .demo-copy .lede { font-size: .95rem; }
  .try li { padding-top: 8px; padding-bottom: 8px; font-size: .9rem; }
  .try li::before { top: 9px; }
}
@media (max-height: 760px) and (min-width: 721px) {
  .demo-copy .lede { display: none; }
}
@media (max-width: 1100px) {
  .s-demo .stage,
  .s-demo.flip .stage { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 720px) {
  /* Feature scenes scroll normally on phones. */
  html.js .s-demo { height: auto; }
  html.js .s-demo .stage { position: relative; height: auto; overflow: visible; }
  .s-demo .stage,
  .s-demo.flip .stage { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .s-demo.flip .demo { order: 0; }
  html.js .s-demo .demo,
  html.js .s-demo .rv,
  html.js .try li { opacity: 1; transform: none; }
  html.js .try li { --t: 1; }
  .s-demo .demo-copy .lede { display: block; }
}

/* =======================================================================
   06 · Contact
   ======================================================================= */

.s-contact .stage { overflow: hidden; }
.big-mark {
  position: absolute; right: calc(-6vw + var(--rail-w)); top: 50%;
  width: min(62vw, 720px); height: auto;
  transform: translateY(-50%);
  fill: var(--fg); opacity: .05;
  pointer-events: none;
}
.big-mark circle { fill: var(--teal-hi); opacity: 1; }
html.js .big-mark { animation: breathe 9s ease-in-out infinite; }
@keyframes breathe {
  50% { transform: translateY(-50%) scale(1.04) rotate(-1.5deg); opacity: .08; }
}

.contact-copy { position: relative; display: grid; gap: 18px; justify-items: start; }
.s-contact h2 { font-size: clamp(2.2rem, 5.2vw, 4.6rem); max-width: 14ch; }

.contacts {
  display: grid; grid-template-columns: repeat(2, minmax(0, auto)); gap: 22px 56px;
  margin-top: 14px;
}
.contacts dt {
  font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--fg-3);
}
.contacts dd { margin-top: 6px; font-size: 1.1rem; }

/* Placeholders are hatched so they can't ship unnoticed. */
.ph {
  display: inline-block; padding: 1px 6px;
  color: var(--warn); font-size: .9em;
  background: repeating-linear-gradient(45deg, var(--warn-tint) 0 6px, transparent 6px 12px);
  outline: 1px dashed var(--warn-line);
}

.more { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 14px 32px; margin-top: 10px; }

.end-foot {
  position: absolute; left: var(--gx); right: calc(var(--gx) + var(--rail-w)); bottom: 22px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding-top: 14px; border-top: 1px solid var(--line-2);
  font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--fg-3);
}
.s-contact .stage { padding-bottom: 110px; }

/* =======================================================================
   Smaller and shorter screens
   ======================================================================= */

@media (max-height: 960px) and (min-width: 721px) {
  .stage { padding-top: 80px; padding-bottom: 28px; }
  .sandbox-head .lede { display: none; }
  .demo-body { padding: 14px 18px 18px; }
  .demos { max-width: min(1120px, calc((100vh - 400px) * 2.1)); }
}
@media (max-height: 820px) and (min-width: 721px) {
  .stage { padding-top: 80px; padding-bottom: 32px; }
  .demo-body > p:not(.tags) { display: none; }
  .demos { max-width: min(1120px, calc((100vh - 300px) * 2.1)); }
}

@media (max-width: 900px) {
  .s-premise .stage,
  .s-process .stage,
  .s-method .stage,
  .s-people .stage { grid-template-columns: minmax(0, 1fr); align-content: center; gap: 18px; }
  .merge { max-height: 32vh; max-height: 32svh; }
  .method-vis svg,
  .process-vis svg,
  .people-vis svg { max-height: 36vh; max-height: 36svh; }
  .process-copy { order: 0; }
  .method-h { max-width: none; }
  .cards { margin-top: 14px; }
}

@media (max-width: 720px) {
  .stage { padding-top: 76px; padding-bottom: 28px; }
  .headline { font-size: clamp(1.75rem, 8.4vw, 2.4rem); margin: .35em 0 .45em; }
  .headline em { white-space: normal; }
  .premise-lede .dim { display: none; }


  .card { padding: 14px 16px; }
  .card-d { font-size: .88rem; }

  /* The sandbox and the contact scene scroll normally on phones. */
  html.js .s-sandbox { height: auto; }
  html.js .s-sandbox .stage,
  html.js .s-contact .stage { position: relative; height: auto; }
  html.js .s-sandbox .stage { overflow: visible; }
  .scroll-hint { display: none; }
  .demos { grid-template-columns: minmax(0, 1fr); }
  .contacts { grid-template-columns: minmax(0, 1fr); }
  .big-mark { width: 120vw; right: -40vw; }
  .end-foot { position: static; margin-top: 40px; }
  .s-contact .stage { padding-bottom: 28px; }
}

/* ---------- Fast scrolling ---------------------------------------------- */
/* story.js sets .fast-scroll while the page is flung or the scrollbar dragged:
   step transitions would only flicker half-way, so everything snaps to the
   state the scroll position gives it, and the step-triggered loops hold still. */
html.fast-scroll *, html.fast-scroll *::before, html.fast-scroll *::after {
  transition: none !important;
  animation-play-state: paused !important;
}

/* ---------- Reduced motion ---------------------------------------------- */
/* html never gets .js, so nothing is pinned or scroll-driven; this stops the
   ambient loops too. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
