/* ============================================================================
   SOLID SPACE — site v2
   Dark cinematic shell. Palette/scale mirror the reference exactly:
   pure black, white, 50% white; edge gutter clamp(2rem, 3.5vw, 3rem).
   ========================================================================== */

:root {
  --base-100: #fff;
  --base-200: rgb(255 255 255 / 0.5);
  --base-300: #000;
  --edge: clamp(2rem, 3.5vw, 3rem);
  --text-small: 0.7rem;
  --text-large: clamp(16px, 3.5vw, 24px);
  --ui: 'Figtree', 'Google Sans', system-ui, sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; }
body {
  height: 100%;
  background: var(--base-300);
  color: var(--base-100);
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;              /* single-viewport pages; case studies override */
}
body.scrollable { overflow: hidden auto; }

::selection { background: var(--base-100); color: var(--base-300); }

/* solid circle cursor (fallback for no-JS / coarse pointers) */
body {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20'%3E%3Ccircle cx='10' cy='10' r='9' fill='%23fff'/%3E%3C/svg%3E") 10 10, auto;
}

/* self-inverting cursor dot: a white disc through a difference blend reads
   black on light surfaces and white on dark ones — including the menu
   panels and wet ink — with no per-surface rules */
body.has-cursor-dot, body.has-cursor-dot * { cursor: none !important; }
.cursor-dot {
  position: fixed;
  top: 0; left: 0;
  width: 18px; height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  background: #fff;
  mix-blend-mode: difference;
  pointer-events: none;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.2s ease;   /* opacity only — position must be instant */
}
body.cursor-dot-on .cursor-dot { opacity: 1; }

/* ---------------------------------------------------------------- canvases */
#bg {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  z-index: 0;
}
#stage3d {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  z-index: 5;                /* above the silk, below content and veil */
  pointer-events: none;
}

/* carousel info-bar text swaps */
.swap { display: inline-block; transition: opacity 0.18s ease, transform 0.22s var(--ease-out); }
.swap-out { opacity: 0; transform: translateY(9px); }

/* ------------------------------------------------------------------- type */
.label {
  font-size: var(--text-small);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
}
.muted { color: var(--base-200); }

a { color: inherit; text-decoration: none; }

/* roll hover: two stacked copies slide up on hover */
.roll {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  height: 1.35em;
}
.roll-inner {
  display: block;
  transition: transform 0.55s var(--ease-out);
}
.roll-inner > span { display: block; height: 1.35em; line-height: 1.35em; }
a:hover .roll-inner, button:hover .roll-inner { transform: translateY(-50%); }

/* -------------------------------------------------------------------- nav */
.nav {
  position: fixed; inset: 0 0 auto 0;
  z-index: 40;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  padding: calc(var(--edge) * 0.66) var(--edge);
  pointer-events: none;
}
.nav > * { pointer-events: auto; }
.nav .brand { justify-self: center; display: inline-flex; align-items: center; }
.nav .brand svg { height: 11px; width: auto; display: block; transition: opacity 0.35s ease; }
.nav .brand:hover svg { opacity: 0.6; }
.nav button {
  background: none; border: 0; color: inherit;
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  cursor: inherit; padding: 0;
}
/* MENU hugs the gutter; a stretched button would center its label */
.nav .menu-toggle { justify-self: start; text-align: left; }

/* menu panel — white rounded card dropping from top-left */
.menu-panel {
  position: fixed;
  top: calc(var(--edge) * 0.45);
  left: calc(var(--edge) * 0.55);
  z-index: 39;
  width: min(370px, 76vw);
  height: min(480px, 64vh);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: var(--base-100);
  color: var(--base-300);
  border-radius: 14px;
  padding: 30px 32px;
  text-align: right;
  transform-origin: top left;
  transform: scale(0.6);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.5s var(--ease-out), opacity 0.35s ease, visibility 0s 0.5s;
}
body.menu-open .menu-panel,
.menu-panel.is-open {
  transform: scale(1);
  opacity: 1;
  visibility: visible;
  transition: transform 0.5s var(--ease-out), opacity 0.25s ease;
}
.menu-panel ul { list-style: none; }
.menu-panel li { overflow: hidden; }
.menu-panel a {
  display: inline-block;
  font-size: 32px;
  line-height: 1.28;
  font-weight: 500;
  opacity: 0;
  transform: translateY(110%);
  transition:
    opacity 0.45s ease,
    transform 0.7s var(--ease-out),
    letter-spacing 0.6s var(--ease-out);
}
body.menu-open .menu-panel a { opacity: 1; transform: none; }
body.menu-open .menu-panel li:nth-child(1) a { transition-delay: 0.10s; }
body.menu-open .menu-panel li:nth-child(2) a { transition-delay: 0.16s; }
body.menu-open .menu-panel li:nth-child(3) a { transition-delay: 0.22s; }
body.menu-open .menu-panel li:nth-child(4) a { transition-delay: 0.28s; }
/* hovering one link quiets the others and lets it breathe — no delay on hover */
body.menu-open .menu-panel ul:hover a { transition-delay: 0s; }
body.menu-open .menu-panel ul:hover a:not(:hover) { opacity: 0.3; }
body.menu-open .menu-panel a:hover {
  transform: translateX(-7px);
  letter-spacing: 0.015em;
}
.menu-panel a[aria-current="page"] { color: rgb(0 0 0 / 0.35); pointer-events: none; }

.menu-toggle .toggle-close { display: none; }
body.menu-open .menu-toggle .toggle-open { display: none; }
body.menu-open .menu-toggle .toggle-close { display: inline-block; position: relative; z-index: 41; }
/* CLOSE sits over the white panel on dark pages — it must go dark there;
   the paper theme keeps its white source (the difference blend flips it) */
body.menu-open .menu-toggle { color: #101011; }
body.theme-paper.menu-open .menu-toggle { color: #fff; }

/* ------------------------------------------------------------------ footer */
.foot {
  position: fixed; inset: auto 0 0 0;
  z-index: 40;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  padding: calc(var(--edge) * 0.66) var(--edge);
  pointer-events: none;
}
.foot > * { pointer-events: auto; }
/* explicit placement: hiding the middle item must not shift the others */
.foot > :nth-child(1) { grid-column: 1; grid-row: 1; }
.foot > :nth-child(2) { grid-column: 2; grid-row: 1; justify-self: center; }
.foot > :nth-child(3) { grid-column: 3; grid-row: 1; justify-self: end; text-align: right; }

.foot .tagline { letter-spacing: 0.18em; }

/* ------------------------------------------------------------ center stage */
.stage {
  position: fixed; inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 0 var(--edge);
  pointer-events: none;
}
.stage > * { pointer-events: auto; }
.stage .lede {
  font-size: var(--text-large);
  line-height: 1.5;
  max-width: 34em;
  font-weight: 400;
}

.links-row {
  display: flex;
  gap: clamp(18px, 3vw, 38px);
  justify-content: center;
  margin-top: 2.2rem;
}

/* --------------------------------------------------------------- preloader */
.preloader {
  position: fixed; inset: 0;
  z-index: 100;
  background: var(--base-300);
  display: grid;
  place-items: center;
}
.preloader canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.preloader-counter {
  position: relative;
  z-index: 2;
  display: flex;
  font-size: var(--text-small);
  letter-spacing: 0.18em;
  font-weight: 500;
  height: 1.3em;
  overflow: hidden;
}
.digit-col { display: block; }
.digit-col span { display: block; height: 1.3em; line-height: 1.3em; }
.preloader.done { transition: opacity 0.6s ease; opacity: 0; pointer-events: none; }

/* page content fades up after load / route change */
.reveal { opacity: 0; transform: translateY(30px); }
body.ready .reveal {
  opacity: 1; transform: none;
  transition: opacity 1.05s ease, transform 1.25s var(--ease-out);
}
body.ready .reveal[data-delay="1"] { transition-delay: 0.15s; }
body.ready .reveal[data-delay="2"] { transition-delay: 0.30s; }
body.ready .reveal[data-delay="3"] { transition-delay: 0.45s; }

/* --------------------------------------------------- paper theme (index) */
body.theme-paper {
  --base-100: #0d0d0e;
  --base-200: rgb(13 13 14 / 0.52);
  --base-300: #fbfbfb;
  background: var(--base-300);
  color: var(--base-100);
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20'%3E%3Ccircle cx='10' cy='10' r='9' fill='%23000'/%3E%3C/svg%3E") 10 10, auto;
}
body.theme-paper ::selection { background: var(--base-100); color: var(--base-300); }

/* chrome text inverts over the ink exactly like the dots do: white source
   through a difference blend reads near-black on paper, white inside ink,
   and splits per-pixel when an ink edge crosses a word */
body.theme-paper .nav,
body.theme-paper .foot {
  color: #fff;
  mix-blend-mode: difference;
}
body.theme-paper .menu-panel {
  background: #101011;
  color: #ebeae7;
}
body.theme-paper .menu-panel a[aria-current="page"] { color: rgb(255 255 255 / 0.35); }

/* static fallback wordmark (no WebGL2): plain image centered on paper */
.fallback-mark {
  position: fixed; inset: 0;
  display: none;
  place-items: center;
  padding: 0 var(--edge);
  z-index: 5;
}
.fallback-mark img { width: 86%; max-width: 1400px; height: auto; }
body.no-gl .fallback-mark { display: grid; }

/* --------------------------------------------- page transitions (router) */
/* exit: the stage and footer sink and fade while a theme-colored veil
   rises over the canvas; the nav never moves. Enter is the .reveal
   stagger plus the veil breathing back off the fresh canvas. */
.page-veil {
  position: fixed; inset: 0;
  z-index: 30;                 /* above canvas + stage, below nav/footer */
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.1s var(--ease-out);
}
.page-veil--on {
  opacity: 1;
  transition: opacity 0.85s cubic-bezier(0.4, 0, 0.2, 1);
}
.stage, .foot {
  transition: opacity 0.6s ease, transform 0.75s cubic-bezier(0.4, 0, 0.2, 1);
}
body.page-exit .stage,
body.page-exit .foot,
body.page-exit .fallback-mark {
  opacity: 0;
  transform: translateY(-34px);   /* content lifts away, reference-style */
}

/* ------------------------------------------- fallback (no-JS) crossfade */
/* Cross-document view transitions: the leaving page settles back and dims,
   the arriving one breathes in. Browsers without support navigate normally. */
@view-transition { navigation: auto; }
::view-transition-old(root) {
  animation: vt-out 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}
::view-transition-new(root) {
  animation: vt-in 0.75s 0.08s var(--ease-out) both;
}
@keyframes vt-out {
  to { opacity: 0; transform: scale(0.988); filter: brightness(0.6); }
}
@keyframes vt-in {
  from { opacity: 0; transform: scale(1.012); }
}

@media (prefers-reduced-motion: reduce) {
  .roll-inner, .menu-panel, .menu-panel a, .reveal { transition: none !important; }
  .reveal { opacity: 1; transform: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}

@media (max-width: 640px) {
  .foot > :nth-child(2) { display: none; }
  .foot--tagline .tagline { display: block; }
}
