/* ---------- Tokens ---------- */
:root {
  --bg: #F5F4F2;
  --text: #121214;
  --muted: #6f6b64;
  --faint: #ccc8c2;
  --card: #ffffff;
  --dim: rgba(245, 244, 242, 0.82);
  --grain-opacity: 0.06;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 12px 32px -8px rgba(0,0,0,.18);
  --card-shadow: none; /* flat project and teaser cards in light mode */

  /* Link colors come from each company's logo tile, darkened in light mode to reach 4.5:1 */
  --goodmake: #087c4b;
  --subber: #db000c;
  --codecademy: #2e00e9;
  --battuta: #956108;
  --omada: #c7390d;
  --kustomer: #786400;

  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --spring: cubic-bezier(.34, 1.36, .5, 1);
  --col: 560px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --text: #ededee;
    --muted: #9c9ca1;
    --faint: #3a3a3e;
    --card: #121214;
    --dim: rgba(4, 4, 5, 0.86);
    --grain-opacity: 0.07;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 16px 40px -8px rgba(0,0,0,.7);
    --card-shadow: var(--shadow);
    --goodmake: #0ba967;
    --subber: #ff646c;
    --codecademy: #6783fe;
    --battuta: #ea990c;
    --omada: #f3724a;
    --kustomer: #f2d530;
  }
}
:root[data-theme="dark"] {
  --bg: #000000;
  --text: #ededee;
  --muted: #9c9ca1;
  --faint: #3a3a3e;
  --card: #121214;
  --dim: rgba(4, 4, 5, 0.86);
  --grain-opacity: 0.07;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 16px 40px -8px rgba(0,0,0,.7);
  --card-shadow: var(--shadow);
  --goodmake: #0ba967;
  --subber: #ff646c;
  --codecademy: #6783fe;
  --battuta: #ea990c;
  --omada: #f3724a;
  --kustomer: #f2d530;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  transition: background-color .5s var(--ease-out), color .5s var(--ease-out);
  overflow-x: hidden;
}
h1, h2, h3, p { margin: 0; font-weight: inherit; font-size: inherit; }
a { color: inherit; }
img { display: block; max-width: 100%; }

/* Subtle static grain over everything */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: var(--grain-opacity);
  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='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 1.4 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Header ---------- */
.header {
  position: absolute; /* scrolls away with the page */
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px;
  pointer-events: none;
}
.header > * { pointer-events: auto; }
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  font-weight: 500;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 44px; height: 44px;
  margin: -4px -6px -4px -5px; /* the mark has built-in padding; keep it optically aligned */
  color: var(--logo-edge);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.18));
}
.brand-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(0,0,0,.06), 0 2px 6px rgba(0,0,0,.14);
}
/* Mark switch: data-mark="avatar" on <html> shows the photo, otherwise the Y card. */
:root:not([data-mark="avatar"]) .brand-avatar,
:root:not([data-mark="avatar"]) .intro-avatar,
[data-mark="avatar"] .brand-mark,
[data-mark="avatar"] .intro-card .mark,
[data-mark="avatar"] .intro-tile { display: none; }
.theme-toggle {
  width: 36px; height: 36px;
  border: 0; padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: grid; place-items: center;
}
/* Sun/moon: the icon shows the mode you'd switch to, so light mode shows a crescent moon and dark mode a sun. Switching to
   dark, the bite slides off the moon, the disc shrinks and the rays spin in; switching to light, the rays go first, the
   disc grows and the bite slides back. */
.sun-moon { width: 20px; height: 20px; overflow: visible; transition: transform .5s var(--spring); }
.sun-moon .sm-core, .sun-moon .sm-rays { transform-box: fill-box; transform-origin: center; }
.sun-moon .sm-bite { transform: none; transition: transform .4s cubic-bezier(.4, 0, .2, 1) .32s; }
.sun-moon .sm-core { transform: none; transition: transform .45s var(--spring) .12s; }
.sun-moon .sm-rays { opacity: 0; transform: scale(.4) rotate(-60deg); transition: opacity .2s ease, transform .3s cubic-bezier(.4, 0, 1, 1); }
:root[data-theme="dark"] .sun-moon .sm-bite { transform: translate(10px, -10px); transition: transform .35s cubic-bezier(.4, 0, .2, 1); }
:root[data-theme="dark"] .sun-moon .sm-core { transform: scale(.62); transition: transform .45s var(--spring) .22s; }
:root[data-theme="dark"] .sun-moon .sm-rays { opacity: 1; transform: none; transition: opacity .3s ease .38s, transform .55s var(--spring) .38s; }
@media (prefers-reduced-motion: reduce) { .sun-moon, .sun-moon * { transition: none !important; } }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sun-moon .sm-bite { transform: translate(10px, -10px); transition: transform .35s cubic-bezier(.4, 0, .2, 1); }
  :root:not([data-theme="light"]) .sun-moon .sm-core { transform: scale(.62); transition: transform .45s var(--spring) .22s; }
  :root:not([data-theme="light"]) .sun-moon .sm-rays { opacity: 1; transform: none; transition: opacity .3s ease .38s, transform .55s var(--spring) .38s; }
}
.theme-toggle:hover .sun-moon { transform: rotate(-18deg) scale(1.08); }
.theme-toggle:focus-visible, .row:focus-visible, a:focus-visible {
  outline: 2px solid var(--muted);
  outline-offset: 4px;
  border-radius: 8px;
}

/* ---------- Layout ---------- */
.main {
  width: min(100% - 48px, var(--col));
  margin-left: max(24px, calc(50vw - 520px));
  padding: 168px 0 96px;
}

.intro-text { position: relative; }
/* Soft wash of the page color behind the text, so the background feed never competes with it */
.intro-text::before {
  content: "";
  position: absolute;
  inset: -72px -96px;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(closest-side, var(--bg) 55%, transparent);
  opacity: .9;
}
.intro-text h1 { font-size: 21px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.35; margin-bottom: 18px; }
.intro-text p { color: var(--muted); margin-bottom: 14px; }
/* Availability: a quiet status line with a Goodmake-green dot */
.intro-text .avail {
  display: flex; align-items: center; gap: 10px;
  margin-top: 24px; margin-bottom: 0;
  color: var(--text); font-size: 15px; font-weight: 500;
}
.avail::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--goodmake);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--goodmake) 18%, transparent);
}
.co {
  color: var(--c);
  text-decoration: none;
  font-weight: 500;
  transition: opacity .2s;
}
.co:hover { opacity: .7; }

.links { display: flex; gap: 20px; margin-top: 26px; font-size: 15px; }
.avail + .links { margin-top: 12px; }
.links a, .footer a {
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: var(--faint);
  text-underline-offset: 4px;
  transition: color .2s, text-decoration-color .2s;
}
.links a:hover, .footer a:hover { color: var(--text); text-decoration-color: currentColor; }
.mail { display: inline-flex; align-items: center; gap: 6px; }
.copy-mail {
  position: relative; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 6px;
  display: grid; place-items: center; background: transparent; color: var(--muted); cursor: pointer;
  transition: color .2s, background .2s;
}
.copy-mail:hover { color: var(--text); background: color-mix(in srgb, var(--text) 8%, transparent); }
.copy-mail:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.copy-mail svg { grid-area: 1 / 1; width: 14px; height: 14px; transition: opacity .2s, transform .3s var(--spring); }
.copy-mail .i-ok { opacity: 0; transform: scale(.5); color: var(--goodmake); }
.copy-mail.is-copied .i-copy { opacity: 0; transform: scale(.5); }
.copy-mail.is-copied .i-ok { opacity: 1; transform: none; }

/* ---------- Work list ---------- */
.work { margin-top: 104px; }
.label { font-size: 14px; color: var(--muted); margin-bottom: 18px; }
.rows { list-style: none; margin: 0; padding: 0; }

.row {
  position: relative;
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  cursor: default;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.row-logo {
  width: 48px; height: 48px;
  border-radius: 9px;
  object-fit: cover;
  box-shadow: var(--shadow);
  /* Hairline keeps light tiles (Goodmake) from melting into the page */
  outline: 1px solid rgba(0,0,0,.06); outline-offset: -1px;
  transition: transform .5s var(--spring);
}
.row-text h3 { font-weight: 500; font-size: 16px; letter-spacing: -0.01em; line-height: 1.35; }
.row-text p { color: var(--muted); font-size: 15px; line-height: 1.4; }

/* Work grid: two columns of big project cards, wider than the text column */
.work { width: min(1040px, 100vw - 2 * max(24px, 50vw - 520px)); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 44px 20px; }
.card-vis {
  position: relative; display: block;
  aspect-ratio: 3 / 2; border-radius: 8px; overflow: hidden;
  background: var(--vis);
  box-shadow: var(--card-shadow);
  outline: 1px solid rgba(0,0,0,.06); outline-offset: -1px;
  transition: transform .6s var(--ease-out);
}
a.card-vis:hover { transform: translateY(-3px); }
.card-poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card-vis iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; pointer-events: none; opacity: 0; transition: opacity .6s ease; }
.card-vis iframe.is-live { opacity: 1; }
.card-meta { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 14px; padding-top: 14px; }
.card-meta .row-logo { width: 40px; height: 40px; border-radius: 8px; }
.card-meta h3 a { text-decoration: none; }
.card-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 15px; font-weight: 500; color: var(--c); text-decoration: none; white-space: nowrap;
  transition: opacity .2s;
}
.card-link span { display: inline-block; transition: transform .4s var(--spring); }
.card:hover .card-link span { transform: translateX(3px); }
.card-link:hover { opacity: .75; }

/* Dim layer: sits above the page, below the active row */
.dim {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--dim);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .45s var(--ease-out);
}
body.is-focus .dim { opacity: 1; }
.row.is-open { z-index: 30; }
.row.is-open .row-logo { transform: scale(1.06); }

/* Cards: desktop row of three, straight and side by side, to the right of the row */
.cards {
  /* As wide as fits between the row text and the window edge, up to 280px */
  --cw: min(280px, calc((100vw - max(24px, 50vw - 520px) - 402px) / 3));
  --step: calc(var(--cw) + 16px);
  position: absolute;
  left: 330px;
  top: 50%;
  width: 0; height: 0;
  pointer-events: none;
}
.cards img {
  position: absolute;
  left: 0; top: 0;
  width: var(--cw);
  max-width: none;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-48px, -50%) scale(.92);
  transform-origin: 0% 50%;
  transition:
    transform .5s var(--ease-out),
    opacity .25s ease;
}
.row.is-open .cards { pointer-events: auto; }
.row.is-open .cards img { opacity: 1; transition: transform .7s var(--spring), opacity .3s ease; }
.row.is-open .cards img:nth-child(1) { transform: translate(0, -50%); transition-delay: 0ms; }
.row.is-open .cards img:nth-child(2) { transform: translate(var(--step), -50%); transition-delay: 60ms; }
.row.is-open .cards img:nth-child(3) { transform: translate(calc(var(--step) * 2), -50%); transition-delay: 120ms; }
.row.is-open .cards img:hover { transform: translate(var(--x, 0), -50%) scale(1.03); }
.row.is-open .cards img:nth-child(2):hover { --x: var(--step); }
.row.is-open .cards img:nth-child(3):hover { --x: calc(var(--step) * 2); }

@media (max-width: 760px) { .grid { grid-template-columns: 1fr; gap: 36px; } }

/* Touch / narrow screens: tap a row to open a swipe strip under it */
@media (hover: none), (max-width: 1040px) {
  .row { grid-template-columns: 44px 1fr; cursor: pointer; }
  .row-logo { width: 44px; height: 44px; border-radius: 8px; }
  .cards {
    position: static;
    width: auto; height: auto;
    grid-column: 1 / -1;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 80%;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 24px;
    max-height: 0;
    margin: 0 -24px;
    padding: 0 24px;
    transition: max-height .5s var(--ease-out), padding .5s var(--ease-out);
    scrollbar-width: none;
  }
  .cards::-webkit-scrollbar { display: none; }
  .cards img {
    position: static;
    width: 100%;
    scroll-snap-align: start;
    transform: translateY(12px) scale(.96);
  }
  .row.is-open .cards { max-height: 360px; padding-top: 6px; padding-bottom: 14px; }
  .row.is-open .cards img:nth-child(n) { transform: none; }
  .dim { display: none; }
}

/* ---------- Footer ---------- */
/* Same footer as the case studies: say hi on the left, © on the right */
.footer { margin-top: 120px; padding-top: 20px; border-top: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
  color: var(--muted); font-size: 14px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 24px; }
.footer p { margin: 0; }
.footer .muted { color: var(--muted); font-size: 14px; }
.footer .mail { gap: 4px; vertical-align: middle; }

/* ---------- Reveal after the intro ---------- */
.js .reveal { opacity: 0; transform: translateY(14px); filter: blur(4px); }
.js .header { opacity: 0; }
body.is-ready .reveal {
  opacity: 1; transform: none; filter: none;
  transition: opacity .9s var(--ease-out), transform .9s var(--ease-out), filter .9s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 55ms);
}
body.is-ready .header { opacity: 1; transition: opacity .6s var(--ease-out); }

/* ---------- Loading intro ---------- */
.intro {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #050506;
  overflow: hidden;
  display: none;
  cursor: pointer;
}
.js .intro { display: block; }
.intro.is-gone { display: none; }
.intro-stage {
  position: absolute;
  inset: 0;
  perspective: 1100px;
  perspective-origin: 50% 50%;
}
.layer {
  position: absolute;
  left: 50%; top: 50%;
  width: 164px; height: 164px;
  margin: -82px 0 0 -82px;
  border-radius: 34px;
  background-size: cover;
  background-position: center;
  border: 1.5px solid var(--glow);
  box-shadow: 0 0 24px -2px var(--glow), inset 0 0 30px -6px var(--glow);
  opacity: 0;
  will-change: transform, opacity;
}

.intro-lockup {
  position: absolute;
  left: 50%; top: 50%;
  display: flex;
  align-items: center;
  gap: 22px;
  transform: translate(-82px, -50%); /* card centered, name trails to the right */
  transform-origin: 0 0; /* matches the card's, so the lockup flies in on the card's path */
}
.intro-card {
  position: relative;
  width: 164px; height: 164px;
  flex: none;
  opacity: 0;
  transform-origin: 0 0;
}
.intro-card svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.intro-card .mark { color: rgba(255, 255, 255, .9); }
.intro-tile { position: absolute; inset: 0; border-radius: 34px; background: #0C0C0E; }
.intro-avatar {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 34px;
}
.intro-name {
  color: #f4f4f5;
  font-weight: 500;
  font-size: 34px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  opacity: 0;
  transform-origin: 0 0;
}
@keyframes fadeIn { to { opacity: 1; } }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .card-meta { grid-template-columns: 40px 1fr; }
  .card-link { grid-column: 2; margin-top: -8px; font-size: 14px; }
  .header { padding: 18px 20px; }
  .main { padding-top: 128px; }
  .intro-text h1 { font-size: 19px; }
  .intro-text::before { inset: -40px -24px; }
  .intro-lockup { flex-direction: column; gap: 18px; transform: translate(-50%, -50%); }
  .intro-name { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation: none !important; }
  .js .reveal { transform: none; filter: none; }
}

/* Logo hairline: a dark edge on light backgrounds, a bright edge on dark ones */
:root { --logo-edge: rgba(20, 20, 24, .38); }
:root[data-theme="dark"] { --logo-edge: rgba(255, 255, 255, .9); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --logo-edge: rgba(255, 255, 255, .9); }
}
