:root {
  color-scheme: light;
  --cream: #f4efe6;
  --ink: #141414;
  --muted: #6a645c;
  --emerald: #0f6b4c;
  --emerald-ink: #f4efe6;
  --card: #fffdf8;

  /* one gutter token drives .page, .wrap and .lede so nothing drifts */
  --pad-x: 20px;
  --gutter-l: max(var(--pad-x), env(safe-area-inset-left));
  --gutter-r: max(var(--pad-x), env(safe-area-inset-right));
  --wrap: 1120px;

  --stagger-dur: 500ms;
  --stagger-distance: 12px;
  --stagger-stagger: 40ms;
  --stagger-blur: 3px;
  --stagger-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --learn-shift: 2px;
  --learn-spread: 8deg;
  --learn-in: 350ms;
  --learn-out: 350ms;
  --learn-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --tap: 240ms cubic-bezier(0.22, 1, 0.36, 1);

  --card-gap: 36px;
  --fade: 34px;
}
* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
}
html, body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(20px, env(safe-area-inset-top)) 0 max(28px, env(safe-area-inset-bottom));
}
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* shared shell: header/page content + the stage block both use this box */
.page, .wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 20px;
}
.page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  container-type: inline-size;
  padding: 0;
}
.wrap { display: block; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 20px 0;
  width: 100%;
}
.mark {
  width: 96px;
  height: 96px;
  color: var(--ink);
  flex: 0 0 96px;
  display: block;
}
@media (min-width: 720px) {
  .mark { width: 120px; height: 120px; flex-basis: 120px; }
}

/* ---------- pill CTA / shared link chrome ---------- */
.t-learn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--emerald);
  color: var(--emerald-ink);
  font: 500 15px/1 "IBM Plex Sans", sans-serif;
  white-space: nowrap;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background-color var(--tap), transform var(--tap);
}
.t-learn:active { transform: scale(.97); }
.t-learn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(20,20,20,.22);
}
@media (hover: hover) {
  .t-learn:not(.t-learn-ghost):hover { background: #0c5a40; }
  .t-learn-ghost:hover { border-color: rgba(20,20,20,.4); background: rgba(20,20,20,.03); }
}
.t-learn-chevron {
  display: inline-flex;
  transform: translateX(0);
  transition: transform var(--learn-out) var(--learn-ease);
}
.t-learn-arm {
  transform-box: view-box;
  transform-origin: 10px 8px;
  vector-effect: non-scaling-stroke;
  transition: transform var(--learn-out) var(--learn-ease);
}
.t-learn:hover .t-learn-chevron { transform: translateX(var(--learn-shift)); transition-duration: var(--learn-in); }
.t-learn:hover .t-learn-arm { transition-duration: var(--learn-in); }
.t-learn:hover .t-learn-arm-top { transform: rotate(var(--learn-spread)); }
.t-learn:hover .t-learn-arm-bot { transform: rotate(calc(var(--learn-spread) * -1)); }
/* 390px guard: the header pill must never clip — the "15 min" suffix retracts
   before the pill can ever hit the viewport edge */
.cta-rest { display: none; }
@media (min-width: 400px) { .cta-rest { display: inline; } }

/* ---------- wordmark: ONE line, even tracking ---------- */
.mid {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 0;
  padding: 12px 20px 10px;
}
.lockup {
  width: 100%;
  text-align: left;
}
.word {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  font-weight: 700;
  font-size: clamp(28px, 7.2vw, 64px);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0;
  line-height: 1;
  color: var(--ink);
  white-space: nowrap;
  font-kerning: none;
  font-variant-ligatures: none;
  font-feature-settings: "kern" 0, "liga" 0;
  display: block;
  width: max-content;
  max-width: 100%;
}
.mission {
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(15px, 2.1vw, 18px);
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0.01em;
  color: var(--muted);
  margin: 14px 0 0;
  max-width: 22em;
  text-wrap: pretty;
  text-align: left;
}

/* ---------- stage: headline + rail + learn more ---------- */
.stage { flex: 0 0 auto; }
.lede {
  font-family: "DM Serif Display", Georgia, serif;
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.005em;
  margin: 0 0 16px;
  max-width: 30ch;
  text-wrap: pretty;
}
.t-stagger-line {
  display: block;
  opacity: 0;
  transform: translateY(var(--stagger-distance));
  filter: blur(var(--stagger-blur));
  transition:
    opacity var(--stagger-dur) var(--stagger-ease),
    transform var(--stagger-dur) var(--stagger-ease),
    filter var(--stagger-dur) var(--stagger-ease);
}
.t-stagger-line--2 { transition-delay: var(--stagger-stagger); }
.t-stagger.is-shown .t-stagger-line {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}

/* ---------- rail ---------- */
.rails { margin: 0; }
.rail {
  overflow: hidden;
  /* vertical padding so the tile shadow is not clipped by overflow:hidden */
  padding: 10px 0 8px;
  /* px-based fade = consistent peek at every width (5% was ~20px on a phone) */
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--fade), #000 calc(100% - var(--fade)), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 var(--fade), #000 calc(100% - var(--fade)), transparent 100%);
}
.track {
  display: flex;
  width: max-content;
  align-items: flex-start;
  will-change: transform;
  animation: carousel-ltr 48s linear infinite;
}
/* 3 identical groups, each card carrying its own trailing margin (no flex gap)
   => track width = exactly 3 groups, so -100%/3 is a mathematically seamless loop */
.logo-card {
  flex: 0 0 auto;
  width: 128px;
  margin-right: var(--card-gap);
  text-align: center;
  color: inherit;
  transition: transform var(--tap);
}
.logo-card:active { transform: scale(.97); }
.logo-card .icon {
  display: block;
  width: 112px;
  height: 112px;
  margin: 0 auto;
  border-radius: 26px;
  overflow: hidden;
  background: var(--cream);
  box-shadow: 0 10px 18px rgba(20, 20, 20, 0.22);
}
.logo-card .icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 0;
  background: none;
  filter: none;
}
.logo-card > span:last-child {
  display: block;
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.25;
  min-height: 2.5em;              /* two label lines reserved => labels align across cards */
  letter-spacing: 0.02em;
  color: var(--muted);
  transition: color var(--tap);
}
@media (hover: hover) {
  .logo-card:hover .icon { transform: translateY(-3px); box-shadow: 0 16px 26px rgba(20, 20, 20, 0.32); }
  .logo-card:hover > span:last-child { color: var(--ink); }
  .rail:hover .track { animation-play-state: paused; }   /* desktop-only pause */
}
@keyframes carousel-ltr {
  from { transform: translateX(calc(-100% / 3)); }
  to   { transform: translateX(0); }
}
@media (min-width: 720px) {
  :root { --card-gap: 48px; --fade: 60px; }
  .logo-card { width: 168px; }
  .logo-card .icon { width: 148px; height: 148px; border-radius: 33px; }
  .rail { padding: 14px 0 10px; }
}

/* ---------- learn more ---------- */
.more-row {
  display: flex;
  justify-content: center;
  padding: 14px 0 2px;
}

/* ---------- work list ---------- */
.intro { padding: 10px 0 22px; }
.intro .word {
  font-family: ui-monospace, Menlo, "Courier New", monospace;
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  margin: 0 0 10px;
}
.intro .lede { margin: 0; }

.list { display: flex; flex-direction: column; margin: 0 -10px; }
.work-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 20px;
  padding: 22px 10px;
  border-bottom: 1px solid rgba(20,20,20,.14);
  align-items: start;
  color: inherit;
  transition: background-color var(--tap);
}
.work-item:first-child { border-top: 1px solid rgba(20,20,20,.14); }
.work-item:active { background: rgba(20,20,20,.07); }
@media (hover: hover) { .work-item:hover { background: rgba(20,20,20,.04); } }

.work-item .icon {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 16px;
  overflow: hidden;
  background: #141414;
  box-shadow: 0 8px 16px rgba(20,20,20,.22);
}
.work-item .icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.work-title {
  font-family: "DM Serif Display", Georgia, serif;
  font-size: 23px;
  font-weight: 400;
  line-height: 1.15;
  margin: 0 0 6px;
}
.work-tech {
  font-family: ui-monospace, Menlo, "Courier New", monospace;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin-bottom: 10px;
}
.work-desc { font-size: 15px; color: var(--muted); line-height: 1.55; margin: 0; max-width: 34em; }

/* neutral key/value tag — NOT a stat block */
.metric-tag {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 6px 11px;
  border: 1px solid rgba(20,20,20,.16);
  border-radius: 999px;
  font-family: ui-monospace, Menlo, "Courier New", monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  justify-self: end;
  align-self: start;
}
.metric-tag strong { color: var(--ink); font-weight: 600; }

@media (max-width: 640px) {
  :root { --pad-x: 18px; }
  .work-item { grid-template-columns: 56px minmax(0, 1fr); gap: 16px; padding: 20px 10px; }
  .work-item .icon { width: 56px; height: 56px; border-radius: 12px; }
  .metric-tag { grid-column: 2; justify-self: start; margin-top: 2px; }
  .work-title { font-size: 21px; }
  .list { margin: 0 -10px; }
}

/* ---------- work detail ---------- */
.detail { padding-bottom: 40px; }
.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;                /* real hit target, was ~18px tall */
  margin: 6px 0 10px;
  font-family: ui-monospace, Menlo, "Courier New", monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color var(--tap), transform var(--tap);
}
.back:active { transform: translateX(-2px); }
@media (hover: hover) { .back:hover { color: var(--ink); } }

.detail-hero { display: grid; gap: 26px; }
@media (min-width: 800px) {
  .detail-hero {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.72fr);
    gap: 48px;
    align-items: start;
  }
  .detail-media { margin-top: 6px; }
}
/* copy first in DOM (mobile reads title → detail → shot); media moves right on desktop */
.detail-media { display: flex; justify-content: center; }
.detail-shot {
  display: block;
  width: auto;
  height: auto;
  max-width: min(100%, 340px);     /* phone shots stay phone-sized; 256px icons stay 256px */
  border-radius: 26px;
  box-shadow: 0 20px 40px rgba(20,20,20,.20);
}
.detail h1 {
  font-family: "DM Serif Display", Georgia, serif;
  font-size: clamp(30px, 5vw, 46px);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
  text-wrap: balance;
}
.detail .tech {
  font-family: ui-monospace, Menlo, "Courier New", monospace;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin-bottom: 18px;
}
.detail p.body {
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  margin: 0 0 4px;
  max-width: 36em;
  text-wrap: pretty;
}
.detail-cta { margin: 22px 0 0; }
.detail .metric-tag { margin-top: 20px; }

/* ---------- reduced motion: no marquee, but the rail stays fully reachable ---------- */
@media (prefers-reduced-motion: reduce) {
  .t-stagger-line { transition: none !important; opacity: 1; transform: none; filter: none; }
  .t-learn, .t-learn-chevron, .t-learn-arm { transition: none !important; }
  .logo-card, .logo-card .icon, .work-item, .back { transition: none !important; }
  .logo-card:active, .t-learn:active, .work-item:active { transform: none; }
  .detail-shot { box-shadow: 0 12px 24px rgba(20,20,20,.16); }
  .track { animation: none; transform: none; }
  .rail {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-mask-image: none;
    mask-image: none;
  }
  .rail::-webkit-scrollbar { display: none; }
  .logo-card { scroll-snap-align: start; }
}
