/* ------------------------------------------------------------------
   Primate Ventures
   Paper, ink, one vermilion. Serif for voice, mono for facts.
------------------------------------------------------------------ */

:root {
  --paper: #efebe3;
  --paper-2: #e6e1d7;
  --ink: #141312;
  --ink-2: #6f6a62;
  --line: rgba(20, 19, 18, 0.16);
  --line-strong: rgba(20, 19, 18, 0.5);
  --accent: #e84b1c;

  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --gutter: clamp(20px, 4vw, 64px);
  --max: 1440px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.83, 0, 0.17, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121110;
    --paper-2: #1a1917;
    --ink: #ece7dd;
    --ink-2: #8f8a80;
    --line: rgba(236, 231, 221, 0.16);
    --line-strong: rgba(236, 231, 221, 0.5);
  }
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: var(--accent); color: var(--paper); }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
h1, h2, h3, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }

.mono {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* paper grain */
.grain {
  position: fixed; inset: 0; z-index: 50; pointer-events: none;
  opacity: 0.55; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.10 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) { .grain { mix-blend-mode: screen; opacity: 0.35; } }

/* ------------------------------------------------------------------
   The mark — a P that assembles from ten parts
------------------------------------------------------------------ */
.mark { display: block; color: var(--ink); overflow: visible; }
.mark .cell rect { fill: currentColor; }
.mark .cell--accent rect { fill: var(--accent); }
.mark--sm { width: 24px; height: 24px; }
.mark--lg { width: 100%; height: 100%; }

/* the pieces fly in and land; only the large mark performs it */
.mark--lg .cell {
  opacity: 0;
  transform: translate(var(--dx), var(--dy)) rotate(var(--r)) scale(0.4);
  animation: snap 0.8s var(--ease-out) var(--d) forwards;
}
@keyframes snap { to { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); } }
/* one frame with the animation off restarts it (see replay() in main.js) */
.mark--lg.no-anim .cell { animation: none; }

/* after landing, the pieces lean toward the cursor */
.mark--lg .cell rect {
  transform: translate(var(--px, 0px), var(--py, 0px));
  transition: transform 0.55s var(--ease-out);
}

#heroMark { cursor: pointer; }

/* ------------------------------------------------------------------
   Nav
------------------------------------------------------------------ */
.nav {
  position: sticky; top: 0; z-index: 40;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 18px var(--gutter);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav__brand { display: inline-flex; align-items: center; gap: 12px; }
.nav__word { font-family: var(--serif); font-size: 22px; letter-spacing: -0.005em; }
.nav__links { display: flex; gap: 28px; justify-self: center; }
.nav__links a {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase;
  position: relative; padding: 4px 0;
}
.nav__links a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: var(--ink); transform: scaleX(0); transform-origin: right;
  transition: transform 0.4s var(--ease-out);
}
.nav__links a:hover::after { transform: scaleX(1); transform-origin: left; }
.nav__meta { justify-self: end; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------
   Layout helpers
------------------------------------------------------------------ */
main { max-width: var(--max); margin: 0 auto; }
section { padding: 0 var(--gutter); }

.section__head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 22px 0 18px; border-bottom: 1px solid var(--ink);
}
.section__title { font-family: var(--serif); font-weight: 400; font-size: clamp(28px, 3vw, 40px); letter-spacing: -0.01em; }
.section__note { color: var(--ink-2); }

/* ------------------------------------------------------------------
   Hero
------------------------------------------------------------------ */
.hero {
  position: relative;
  min-height: calc(100svh - 66px);
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: auto 1fr auto auto;
  column-gap: 20px;
  padding-top: clamp(40px, 8vh, 96px);
  padding-bottom: 28px;
  isolation: isolate;
}
.hero__swarm { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; opacity: 0.85; }

.hero__eyebrow {
  grid-column: 1 / -1;
  display: flex; gap: 14px; color: var(--ink-2);
}
.hero__eyebrow .sep { color: var(--accent); }

.hero__title {
  grid-column: 1 / 10;
  align-self: end;
  margin-top: clamp(40px, 10vh, 120px);
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(52px, 8.6vw, 148px);
  line-height: 0.96;
  letter-spacing: -0.025em;
  text-wrap: balance;
}
.hero__title em { font-style: italic; color: var(--accent); }
.line { display: block; overflow: hidden; padding-bottom: 0.06em; margin-bottom: -0.06em; }
.line__in {
  display: block;
  transform: translateY(110%);
  animation: rise 1.1s var(--ease-out) forwards;
}
.line:nth-child(1) .line__in { animation-delay: 0.15s; }
.line:nth-child(2) .line__in { animation-delay: 0.27s; }
.line:nth-child(3) .line__in { animation-delay: 0.39s; }
@keyframes rise { to { transform: translateY(0); } }

.hero__mark {
  grid-column: 10 / -1;
  grid-row: 2 / 4;
  align-self: end; justify-self: end;
  width: clamp(120px, 18vw, 260px);
  aspect-ratio: 1;
  margin-bottom: 8px;
}

.hero__lede {
  grid-column: 1 / 7;
  margin-top: clamp(28px, 5vh, 56px);
  font-size: clamp(16px, 1.25vw, 19px);
  color: var(--ink-2);
  max-width: 58ch;
}

.hero__foot {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 16px;
  margin-top: clamp(32px, 6vh, 72px);
  color: var(--ink-2);
}
.hero__rule { flex: 1; height: 1px; background: var(--line); }
#heroCount { font-variant-numeric: tabular-nums; color: var(--ink); }

/* ------------------------------------------------------------------
   Index
------------------------------------------------------------------ */
.index { padding-top: 24px; }

.venture { border-bottom: 1px solid var(--line); }

.venture__row {
  width: 100%;
  display: grid;
  grid-template-columns: 64px 1fr auto auto 40px;
  align-items: baseline;
  gap: 24px;
  padding: 30px 0;
  text-align: left;
  position: relative;
}
.venture__row::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: var(--ink); transform: scaleX(0); transform-origin: left;
  transition: transform 0.6s var(--ease-out);
}
.venture__row:hover::before, .venture__row[aria-expanded="true"]::before { transform: scaleX(1); }

.venture__num { color: var(--ink-2); transition: transform 0.4s var(--ease-out); }
.venture__row:hover .venture__num { transform: translateX(6px); color: var(--accent); }

.venture__name {
  font-family: var(--serif);
  font-size: clamp(36px, 5vw, 76px);
  line-height: 1;
  letter-spacing: -0.02em;
  transition: transform 0.5s var(--ease-out);
}
.venture__row:hover .venture__name { transform: translateX(8px); }

.venture__cat, .venture__status { color: var(--ink-2); white-space: nowrap; }
.venture__status { display: inline-flex; align-items: center; gap: 8px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: var(--ink-2); }
.dot--live { background: var(--accent); box-shadow: 0 0 0 0 var(--accent); animation: ping 2.4s ease-out infinite; }
.dot--build { background: var(--ink); }
.dot--lab { background: transparent; border: 1px solid var(--ink); }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); } 100% { box-shadow: 0 0 0 9px transparent; } }

.venture__plus { position: relative; width: 14px; height: 14px; justify-self: end; align-self: center; }
.venture__plus::before, .venture__plus::after {
  content: ""; position: absolute; background: var(--ink); inset: 50% auto auto 0;
  width: 14px; height: 1px; transform: translateY(-50%);
  transition: transform 0.5s var(--ease-out);
}
.venture__plus::after { transform: translateY(-50%) rotate(90deg); }
.venture__row[aria-expanded="true"] .venture__plus::after { transform: translateY(-50%) rotate(0deg); }

/* expand via grid rows */
.venture__panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.7s var(--ease-in-out);
}
.venture.is-open .venture__panel { grid-template-rows: 1fr; }
.venture__panel-in {
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 48px;
}
.venture.is-open .venture__panel-in { padding-bottom: 48px; }

.venture__copy { padding-top: 6px; display: flex; flex-direction: column; gap: 18px; color: var(--ink-2); }
.venture__copy .venture__tag {
  font-family: var(--serif); font-size: clamp(22px, 2.2vw, 30px); line-height: 1.15; color: var(--ink);
  letter-spacing: -0.01em;
}
.venture__facts { margin-top: 6px; border-top: 1px solid var(--line); }
.venture__facts li {
  display: grid; grid-template-columns: 90px 1fr; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.venture__facts li span:first-child { color: var(--ink-2); }
.venture__facts li span:last-child { color: var(--ink); text-transform: none; letter-spacing: 0.02em; }

.btn {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 10px;
  margin-top: 8px;
  padding: 12px 18px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase;
  transition: background 0.3s, color 0.3s, transform 0.4s var(--ease-out);
}
.btn:hover { background: var(--ink); color: var(--paper); transform: translateX(3px); }

/* ---------- demos ---------- */
.demo { min-width: 0; }
.device {
  border: 1px solid var(--ink);
  border-radius: 14px;
  background: var(--paper-2);
  overflow: hidden;
  aspect-ratio: 16 / 10;
  display: grid;
  grid-template-rows: auto 1fr auto;
  transform: translateY(14px);
  opacity: 0;
  transition: transform 0.9s var(--ease-out) 0.15s, opacity 0.9s var(--ease-out) 0.15s;
}
.venture.is-open .device { transform: none; opacity: 1; }
.device__bar {
  display: flex; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--ink-2);
}

/* kontoro: a shelf of books that fill with what you've retained */
.shelf {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 24px 18px 0;
  border-bottom: 2px solid var(--ink);
  margin: 0 18px;
}
.book {
  flex: 1; height: var(--h); border: 1px solid var(--ink); border-bottom: 0;
  border-radius: 3px 3px 0 0; position: relative; overflow: hidden;
  background: var(--paper);
}
.book i {
  position: absolute; left: 0; right: 0; bottom: 0; height: 0;
  background: var(--ink);
  transition: height 1.4s var(--ease-out);
}
.venture.is-open .book i { height: calc(var(--p) * 100%); }
.book:nth-child(4) i { background: var(--accent); }
.book:nth-child(1) i { transition-delay: 0.30s; }
.book:nth-child(2) i { transition-delay: 0.38s; }
.book:nth-child(3) i { transition-delay: 0.46s; }
.book:nth-child(4) i { transition-delay: 0.54s; }
.book:nth-child(5) i { transition-delay: 0.62s; }
.book:nth-child(6) i { transition-delay: 0.70s; }
.book:nth-child(7) i { transition-delay: 0.78s; }
.book:nth-child(8) i { transition-delay: 0.86s; }
.xp { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 14px 18px; color: var(--ink-2); }
.xp__bar { height: 3px; background: var(--line); position: relative; overflow: hidden; }
.xp__bar i { position: absolute; inset: 0; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform 1.6s var(--ease-out) 0.7s; }
.venture.is-open .xp__bar i { transform: scaleX(0.74); }

/* kor: leaderboard */
.board { padding: 8px 18px; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.board li {
  display: grid; grid-template-columns: 22px 1fr 16px auto; gap: 12px; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--line);
  transform: translateX(-10px); opacity: 0;
  transition: transform 0.7s var(--ease-out), opacity 0.7s var(--ease-out);
}
.venture.is-open .board li { transform: none; opacity: 1; }
.board li:nth-child(1) { transition-delay: 0.25s; }
.board li:nth-child(2) { transition-delay: 0.33s; }
.board li:nth-child(3) { transition-delay: 0.41s; }
.board li:nth-child(4) { transition-delay: 0.49s; }
.board li:nth-child(5) { transition-delay: 0.57s; }
.board__rank { color: var(--ink-2); }
.board__who { font-family: var(--serif); font-size: 20px; }
.board__badge { width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--ink); }
.board__badge--new { background: var(--accent); border-color: var(--accent); }
.board__pts { font-variant-numeric: tabular-nums; }
.pulse { display: flex; align-items: center; gap: 8px; padding: 12px 18px; color: var(--ink-2); border-top: 1px solid var(--line); }
.pulse i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: ping 2s ease-out infinite; }

/* swarm demo */
.swarm-demo { width: 100%; height: 100%; display: block; grid-row: 2 / 4; }

/* ------------------------------------------------------------------
   Studio
------------------------------------------------------------------ */
.studio { padding-top: clamp(64px, 10vh, 140px); }
.modes {
  display: grid; grid-template-columns: 1fr 1fr; gap: 48px;
  padding: 40px 0 0;
}
.mode { display: grid; grid-template-columns: 48px 1fr; gap: 0 16px; color: var(--ink-2); }
.mode__num { color: var(--accent); grid-row: 1 / 3; padding-top: 10px; }
.mode__title { font-family: var(--serif); font-weight: 400; font-size: clamp(36px, 4vw, 60px); line-height: 1; letter-spacing: -0.02em; color: var(--ink); margin-bottom: 14px; }
.mode p { max-width: 46ch; }

.caps {
  display: flex; flex-wrap: wrap; gap: 0;
  margin-top: 56px; border-top: 1px solid var(--ink);
}
.caps li {
  padding: 16px 22px 16px 0; margin-right: 22px;
  color: var(--ink-2); position: relative;
}
.caps li::after { content: "·"; position: absolute; right: -4px; color: var(--accent); }
.caps li:last-child::after { content: none; }

/* ------------------------------------------------------------------
   Contact
------------------------------------------------------------------ */
.contact {
  padding-top: clamp(96px, 16vh, 200px);
  padding-bottom: clamp(64px, 10vh, 140px);
  display: flex; flex-direction: column; gap: 18px;
}
.contact__lead { font-family: var(--serif); font-size: clamp(28px, 3.4vw, 52px); line-height: 1.1; letter-spacing: -0.015em; max-width: 22ch; }
.contact__mail {
  font-family: var(--serif);
  font-size: clamp(28px, 6vw, 96px);
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--accent);
  align-self: flex-start;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 2px; background-repeat: no-repeat; background-position: left 96%;
  transition: background-size 0.6s var(--ease-out);
  word-break: break-all;
}
.contact__mail:hover { background-size: 100% 2px; }

/* ------------------------------------------------------------------
   Footer
------------------------------------------------------------------ */
.foot {
  max-width: var(--max); margin: 0 auto;
  display: flex; justify-content: space-between; gap: 20px;
  padding: 22px var(--gutter) 28px;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
}
.foot a:hover { color: var(--ink); }

/* ------------------------------------------------------------------
   Reveal on scroll
------------------------------------------------------------------ */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out); }
.reveal.is-in { opacity: 1; transform: none; }

/* ------------------------------------------------------------------
   Responsive
------------------------------------------------------------------ */
@media (max-width: 900px) {
  .nav { grid-template-columns: 1fr auto; }
  .nav__links { display: none; }
  .hero { grid-template-rows: auto auto auto auto auto; }
  .hero__title { grid-column: 1 / -1; grid-row: 2; }
  .hero__mark { grid-column: 1 / -1; grid-row: 3; justify-self: start; width: 96px; margin-top: 28px; }
  .hero__lede { grid-column: 1 / -1; grid-row: 4; }
  .hero__foot { grid-row: 5; }
  .venture__row { grid-template-columns: 44px 1fr 24px; grid-template-areas: "num name plus" "num meta plus"; row-gap: 8px; }
  .venture__num { grid-area: num; }
  .venture__name { grid-area: name; }
  .venture__cat { grid-area: meta; }
  .venture__status { display: none; }
  .venture__plus { grid-area: plus; }
  .venture__panel-in { grid-template-columns: 1fr; gap: 28px; }
  .modes { grid-template-columns: 1fr; }
  .foot { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .line__in { animation: none; transform: none; }
  .mark--lg .cell { animation: none; opacity: 1; transform: none; }
  .mark--lg .cell rect { transform: none; transition: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .hero__swarm { display: none; }
  .dot--live, .pulse i { animation: none; }
}
