/* Top bar over the hero: resume link, name, contact link */
.site-bar {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: 10px var(--page-pad);
  color: #fff;
  /* Lets the mouse reach the hero underneath; the links switch it back on */
  pointer-events: none;
}

.site-name,
.site-bar__link {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: var(--tracking-mono);
  text-transform: uppercase;
  white-space: nowrap;
  color: inherit;
}

.site-name {
  text-align: center;
}

.site-bar__link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  /* Solid backing so the hero's guide lines pass behind the label, not through it */
  margin: 0 -6px;
  padding: 0 6px;
  background: var(--blue);
  text-decoration: none;
  pointer-events: auto;
}

.site-bar__link--left {
  justify-self: start;
}

.site-bar__link--right {
  justify-self: end;
}

.site-bar__link:hover {
  text-decoration: underline;
  text-underline-offset: 0.3em;
}

.site-bar__link:focus-visible {
  outline: 1px solid #fff;
  outline-offset: 4px;
}


/* ---------- Menu (phones and small tablets) ---------- */

/* Menu button: just the pixel icon, no box. It belongs to the hero: menu.js pixelates
   it away once the hero has been scrolled past, and back in on return.
   The tap area stays 44px even though only the 18px icon shows. */
.menu-btn {
  position: fixed;
  top: 10px;
  right: calc(var(--page-pad) - 13px);
  z-index: 80;
  display: none;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  color: #fff;
  cursor: pointer;
}

.menu-btn.is-away {
  visibility: hidden;
  pointer-events: none;
}

.menu-btn:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: -4px;
}

.menu-btn__close,
.menu-btn[aria-expanded="true"] .menu-btn__open {
  display: none;
}

.menu-btn[aria-expanded="true"] .menu-btn__close {
  display: block;
}

/* The icon redrawn as tiles while it pixelates away */
.menu-btn-tiles {
  position: fixed;
  z-index: 81;
  pointer-events: none;
}

/* The pause screen */
.menu {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-3);
  padding: 88px var(--page-pad) var(--space-5);
  overflow-y: auto;
  background: var(--ink);
  color: #fff;
}

.menu[hidden] {
  display: none;
}

/* The tile wipe drawn by motion.js sits between the menu and its button */
.pixel-wipe {
  position: fixed;
  inset: 0;
  z-index: 75;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.menu__kicker,
.menu__hint,
.menu__num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.4;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.menu__kicker {
  margin: 0;
  color: var(--yellow);
}

.menu__hint {
  margin: var(--space-2) 0 0;
  color: rgba(255, 255, 255, 0.6);
  animation: roles-blink 1.2s steps(1, end) infinite;
}

.menu__list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.menu__item {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 8px 0 8px 26px;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 10vw, 3.25rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: #fff;
}

.menu__num {
  flex: 0 0 auto;
  letter-spacing: 0.12em;
  color: var(--sky);
}

/* Selection arrow, like a game menu: shows on the item being pressed, hovered or focused */
.menu__item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  background: var(--yellow);
  clip-path: polygon(0 0, 28% 0, 28% 14%, 57% 14%, 57% 28%, 86% 28%, 86% 43%, 100% 43%, 100% 57%, 86% 57%, 86% 72%, 57% 72%, 57% 86%, 28% 86%, 28% 100%, 0 100%);
  opacity: 0;
}

.menu__item:hover,
.menu__item:active,
.menu__item:focus-visible {
  outline: none;
  color: var(--yellow);
}

.menu__item:hover::before,
.menu__item:active::before,
.menu__item:focus-visible::before {
  opacity: 1;
}

/* Items step in one after another when the menu opens */
.menu.is-open .menu__kicker,
.menu.is-open .menu__item,
.menu.is-open .menu__hint {
  animation: menu-item-in 240ms steps(3, end) both;
}

.menu.is-open li:nth-child(1) .menu__item { animation-delay: 60ms; }
.menu.is-open li:nth-child(2) .menu__item { animation-delay: 120ms; }
.menu.is-open li:nth-child(3) .menu__item { animation-delay: 180ms; }
.menu.is-open li:nth-child(4) .menu__item { animation-delay: 240ms; }
.menu.is-open li:nth-child(5) .menu__item { animation-delay: 300ms; }

.menu.is-open .menu__hint {
  animation: menu-item-in 240ms steps(3, end) 420ms both, roles-blink 1.2s steps(1, end) 700ms infinite;
}

@keyframes menu-item-in {
  from { opacity: 0; transform: translateX(-16px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .menu.is-open .menu__kicker,
  .menu.is-open .menu__item,
  .menu.is-open .menu__hint,
  .menu__hint {
    animation: none;
  }
}

/* While the menu is open the page behind it does not scroll */
.menu-open {
  overflow: hidden;
}

/* ---------- Hero: a blue canvas with the headline being "designed" ---------- */

.hero {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: var(--space-12) var(--page-pad);
  overflow: hidden;
  background: var(--blue);
  color: #fff;
}

.hero a:focus-visible {
  outline-color: #fff;
}

/* The frame shrinks to the headline, so the block sits in the centre of the page
   while the text inside stays left aligned. Its font size drives everything in it. */
.hero__frame {
  position: relative;
  width: fit-content;
  max-width: 100%;
  font-size: clamp(2.25rem, min(8vw, 17vh), 9.5rem);
}

.hero__line {
  position: relative;
  margin: 0;
  font-family: var(--font-display);
  font-size: 1em;
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.01em;
  text-align: left;
  color: #fff;
}

.hero__row {
  display: block;
  white-space: nowrap;
}

.hero__row--alt {
  color: var(--sky);
}

/* The second line is a button: pressing it retypes the line as the next phrase */
.hero__text[role="button"] {
  outline: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.hero__text[role="button"]:focus-visible {
  outline: 1px dashed rgba(255, 255, 255, 0.8);
  outline-offset: 0.04em;
}

@media (hover: hover) {
  .hero:not(.is-typing) .hero__text[role="button"]:hover {
    outline: 1px dashed rgba(255, 255, 255, 0.7);
    outline-offset: 0.04em;
  }
}

/* Appears above the box, on the right, once the headline has been changed */
.hero__reset {
  position: absolute;
  z-index: 4;
  right: -0.2em;
  bottom: calc(100% + 0.12em + 10px);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 5px 8px;
  border: 0;
  background: var(--yellow);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1;
  letter-spacing: var(--tracking-mono);
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
}

.hero__reset[hidden] {
  display: none;
}

/* Invisible padding so the small label is still an easy target for a thumb */
.hero__reset::after {
  content: "";
  position: absolute;
  inset: -12px -10px;
}

.hero__reset:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* While the line is being retyped the caret stays solid, like a real one mid-keystroke */
.hero.is-live.is-typing .hero__caret,
.hero.is-typing .hero__caret {
  animation: none;
  opacity: 1;
}

/* Text cursor after the last word, as if the line is still being typed */
.hero__caret {
  display: inline-block;
  width: 0.05em;
  height: 0.8em;
  margin-left: 0.07em;
  vertical-align: -0.05em;
  background: #fff;
  animation: hero-caret 1.1s steps(1, end) infinite;
}

@keyframes hero-caret {
  0%, 55% { opacity: 1; }
  56%, 100% { opacity: 0; }
}

/* ----- Design-tool furniture around the headline ----- */

.hero__tools {
  position: absolute;
  inset: -0.12em -0.2em -0.1em;
  pointer-events: none;
}

.hero__guide {
  position: absolute;
  background: rgba(255, 255, 255, 0.42);
}

.hero__guide--h {
  left: -100vw;
  right: -100vw;
  height: 1px;
}

.hero__guide--v {
  top: -100vh;
  bottom: -100vh;
  width: 1px;
}

.hero__guide--top { top: 0; }
.hero__guide--mid { top: 50%; background: rgba(255, 255, 255, 0.22); }
.hero__guide--bottom { bottom: 0; }
.hero__guide--left { left: 0; }
.hero__guide--right { right: 0; }

.hero__box {
  position: absolute;
  inset: 0;
  border: 1px solid #fff;
}

.hero__handle {
  position: absolute;
  width: 9px;
  height: 9px;
  margin: -5px 0 0 -5px;
  background: #fff;
  border: 1px solid var(--blue);
}

/* With a mouse the handles can be dragged to scale the headline */
.hero.can-drag .hero__handle {
  pointer-events: auto;
  transition: transform 120ms ease-out, background-color 120ms ease-out;
}

.hero.can-drag .hero__handle:hover,
.hero.can-drag .hero__handle.is-dragging {
  background: var(--yellow);
  transform: scale(1.5);
}

.hero__handle--tl { left: 0; top: 0; }
.hero__handle--tm { left: 50%; top: 0; }
.hero__handle--tr { left: 100%; top: 0; }
.hero__handle--ml { left: 0; top: 50%; }
.hero__handle--mr { left: 100%; top: 50%; }
.hero__handle--bl { left: 0; top: 100%; }
.hero__handle--bm { left: 50%; top: 100%; }
.hero__handle--br { left: 100%; top: 100%; }

.hero__tag,
.hero__size,
.hero__cursor-name {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1;
  letter-spacing: var(--tracking-mono);
  text-transform: uppercase;
  white-space: nowrap;
}

.hero__tag {
  position: absolute;
  left: 0;
  bottom: 100%;
  margin-bottom: 10px;
  padding: 5px 8px;
  background: #fff;
  color: var(--blue);
}

.hero__size {
  position: absolute;
  left: 50%;
  top: 100%;
  margin-top: 12px;
  padding: 5px 8px;
  background: var(--orange);
  color: var(--ink);
  transform: translateX(-50%);
}

.hero__size:empty {
  display: none;
}

.hero__cursor {
  position: absolute;
  left: 100%;
  top: 100%;
  display: flex;
  align-items: flex-start;
  margin: 8px 0 0 8px;
  color: var(--yellow);
}

/* When a visitor's mouse is over the hero, this cursor becomes theirs */
.hero.has-pointer,
.hero.has-pointer * {
  cursor: none;
}

.hero__cursor:not(.is-following) {
  transition: transform 500ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.hero.is-live .hero__cursor.is-following {
  animation: none;
}

.hero__cursor.is-following {
  z-index: 5;
}

.hero__cursor svg {
  flex: 0 0 auto;
  display: block;
}

.hero__cursor-name {
  margin: 16px 0 0 2px;
  padding: 5px 8px;
  background: var(--yellow);
  color: var(--ink);
}

.hero__scroll {
  position: absolute;
  left: 50%;
  bottom: var(--space-3);
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.4;
  letter-spacing: var(--tracking-mono);
  text-transform: uppercase;
  text-decoration: none;
  color: #fff;
  transform: translateX(-50%);
}

.hero__scroll svg {
  animation: hero-nudge 1.6s steps(2, jump-none) infinite;
}

@keyframes hero-nudge {
  from { transform: translateY(0); }
  to { transform: translateY(4px); }
}

/* ----- Intro sequence -----
   hero.js adds .is-live once the headline starts to pixelate in. Without it
   (no script, or reduced motion) everything above simply shows in place. */

.hero.is-live .hero__guide {
  animation: hero-draw 800ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.hero.is-live .hero__guide--h { --from: scaleX(0); }
.hero.is-live .hero__guide--v { --from: scaleY(0); }

/* Each guide comes in from a different side */
.hero.is-live .hero__guide--top { transform-origin: left center; animation-delay: 650ms; }
.hero.is-live .hero__guide--right { transform-origin: center top; animation-delay: 760ms; }
.hero.is-live .hero__guide--bottom { transform-origin: right center; animation-delay: 870ms; }
.hero.is-live .hero__guide--left { transform-origin: center bottom; animation-delay: 980ms; }
.hero.is-live .hero__guide--mid { transform-origin: right center; animation-delay: 1090ms; }

@keyframes hero-draw {
  from { transform: var(--from); }
  to { transform: none; }
}

.hero.is-live .hero__box {
  animation: hero-fade 300ms ease 1350ms both;
}

.hero.is-live .hero__handle {
  animation: hero-pop 220ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.hero.is-live .hero__handle--tl { animation-delay: 1500ms; }
.hero.is-live .hero__handle--tm { animation-delay: 1530ms; }
.hero.is-live .hero__handle--tr { animation-delay: 1560ms; }
.hero.is-live .hero__handle--mr { animation-delay: 1590ms; }
.hero.is-live .hero__handle--br { animation-delay: 1620ms; }
.hero.is-live .hero__handle--bm { animation-delay: 1650ms; }
.hero.is-live .hero__handle--bl { animation-delay: 1680ms; }
.hero.is-live .hero__handle--ml { animation-delay: 1710ms; }

.hero.is-live .hero__tag {
  animation: hero-fade 260ms ease 1750ms both;
}

.hero.is-live .hero__size {
  animation: hero-fade 260ms ease 1850ms both;
}

.hero.is-live .hero__cursor {
  animation: hero-cursor 700ms cubic-bezier(0.2, 0.7, 0.2, 1) 1900ms both;
}

.hero.is-live .hero__caret {
  animation: hero-fade 1ms linear 1000ms both, hero-caret 1.1s steps(1, end) 1000ms infinite;
}

.hero.is-live .hero__scroll {
  animation: hero-fade 400ms ease 2100ms both;
}

@keyframes hero-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes hero-pop {
  from { opacity: 0; transform: scale(0); }
  to { opacity: 1; transform: none; }
}

@keyframes hero-cursor {
  from { opacity: 0; transform: translate(90px, 70px); }
  to { opacity: 1; transform: none; }
}

/* Until the pixel reveal is ready the headline and tools stay hidden so they
   cannot flash. If the script never runs, they show after 1.5s. */
.js-reveal .hero__line,
.js-reveal .hero__tools {
  visibility: hidden;
  animation: hero-failsafe 0s 1.5s forwards;
}

@keyframes hero-failsafe {
  to { visibility: visible; }
}

.pixel-reveal {
  position: absolute;
  z-index: 2;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .hero__caret,
  .hero__scroll svg {
    animation: none;
  }
}

/* ---------- Scroll transitions ----------
   motion.js adds .reveal-on to <html>, then .is-in to each element as it scrolls
   into view. Without the script nothing is hidden. */

.reveal-on [data-reveal] {
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity 600ms ease var(--reveal-delay, 0ms),
    transform 700ms cubic-bezier(0.2, 0.7, 0.2, 1) var(--reveal-delay, 0ms);
}

.reveal-on [data-reveal].is-in {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .reveal-on [data-reveal] {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ---------- About ---------- */

.about {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
  column-gap: var(--space-6);
  padding: var(--space-12) var(--page-pad) var(--space-12);
}

.about__label {
  margin: 0.9em 0 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.about__lead {
  margin: 0;
  font-family: var(--font-sans);
  font-size: clamp(1.75rem, 3.4vw, 3.5rem);
  font-weight: var(--weight-body, 400);
  line-height: 1.05;
  letter-spacing: var(--tracking-headline);
  color: var(--ink);
}

/* "but why?" pixelates in when the line scrolls into view, and again on hover */
.about__why {
  position: relative;
  display: inline-block;
  white-space: nowrap;
  letter-spacing: -0.01em;
  cursor: default;
}

.about__text {
  max-width: 46rem;
  margin: var(--space-5) 0 0;
}

.about__text p {
  margin: 0 0 0.85em;
  font-family: var(--font-sans);
  font-size: clamp(1.125rem, 1.55vw, 1.5rem);
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--ink-2);
}

.about__text p:last-child {
  margin-bottom: 0;
}

.about__text strong {
  font-weight: 400;
  color: var(--ink);
}

.work {
  padding: var(--space-12) var(--page-pad) var(--space-16);
  border-top: var(--hairline) solid var(--line);
}

.work__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 7vw, 7rem);
  font-weight: 400;
  line-height: var(--leading-headline);
  letter-spacing: -0.01em;
}

.work__sub {
  margin: var(--space-2) 0 var(--space-8);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  letter-spacing: -0.02em;
  color: var(--ink-2);
}

.work__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
}

.work-card {
  display: block;
  text-decoration: none;
}

.work-card picture {
  display: block;
}

/* 12:7 is the shape of the project images, so they show whole */
.work-card__thumb {
  width: 100%;
  height: auto;
  aspect-ratio: 12 / 7;
  object-fit: cover;
  border: var(--hairline) solid var(--line);
  display: block;
}

/* Where the card is narrow it shows a closer, taller crop (see the <picture> in the page) */
@media (max-width: 600px), (min-width: 769px) and (max-width: 900px) {
  .work-card__thumb {
    aspect-ratio: 127 / 140;
  }
}

.work-card__meta {
  margin: var(--space-2) 0 var(--space-1);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: var(--tracking-mono);
  text-transform: uppercase;
  color: var(--ink-2);
}

.work-card__title {
  margin: 0 0 var(--space-1);
  font-family: var(--font-sans);
  font-size: 2rem;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: var(--tracking-title);
}

.work-card__arrow {
  display: inline-block;
  margin-left: 0.15em;
  transition: transform 0.2s ease;
}

.work-card:hover .work-card__title,
.work-card:focus-visible .work-card__title {
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

.work-card:hover .work-card__arrow,
.work-card:focus-visible .work-card__arrow {
  transform: translateX(4px);
}

.work-card__desc {
  margin: 0;
  color: var(--ink-2);
}

/* ---------- Role selector ---------- */

/* Each role has four colours:
   --role       bright fill (pips, glow)
   --role-ink   dark version for text and borders, 4.5:1 or better on white and on the tint
   --role-tint  pale background for the ability card
   --role-line  mid tone for decorative lines */
.roles {
  --role: #faed01;
  --role-ink: #6f6900;
  --role-tint: #fefcdb;
  --role-line: #d3c801;

  overflow-x: clip;
}

.roles[data-role="researcher"] {
  --role: #6fc3ff;
  --role-ink: #006ab6;
  --role-tint: #ebf7ff;
  --role-line: #50aaeb;
}

.roles[data-role="ui"] {
  --role: #214afe;
  --role-ink: #2049ff;
  --role-tint: #e0e6ff;
  --role-line: #214afe;
}

.roles[data-role="otis"] {
  --role: #fe4727;
  --role-ink: #c91e00;
  --role-tint: #ffe5e1;
  --role-line: #ef3c1c;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ----- Title screen -----
   A dark, full-height "character select" card. When it scrolls into view the title
   pixelates in, the subtitle types itself, and the four silhouettes pop in one by one.
   Each silhouette is a button that jumps to that role in the selector below. */

.roles__intro {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  min-height: 100vh;
  min-height: 100svh;
  padding: clamp(40px, 8vh, 96px) var(--page-pad);
  background: var(--ink);
  color: #fff;
  text-align: center;
}

.roles__intro a:focus-visible,
.roles__intro button:focus-visible {
  outline-color: var(--yellow);
}

.roles__kicker,
.roles__sub,
.roles__prompt,
.roles__ghost-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.roles__kicker {
  margin: 0;
  color: var(--yellow);
}

.roles__title {
  position: relative;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, min(9vw, 20vh), 10.5rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.01em;
  color: #fff;
}

.roles__sub {
  min-height: 1.4em;
  margin: 0;
  font-size: clamp(0.8rem, 1.2vw, 1.05rem);
  color: var(--sky);
}

/* Blinking block after the typed subtitle */
.roles__sub::after {
  content: "";
  display: inline-block;
  width: 0.6em;
  height: 1em;
  margin-left: 0.3em;
  vertical-align: -0.15em;
  background: currentColor;
  animation: roles-blink 1s steps(1, end) infinite;
}

.roles__lineup {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(12px, 3vw, 44px);
  margin: var(--space-5) 0 0;
  padding: 0;
  list-style: none;
}

.roles__ghost {
  --ghost: var(--yellow);
  --ghost-size: clamp(52px, min(15vh, 17vw), 150px);
  min-width: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
}

/* The sprite is used as a stencil, so only its outline shape shows, filled with one colour */
.roles__ghost-shape {
  display: block;
  width: var(--ghost-size);
  height: var(--ghost-size);
  background: var(--ghost);
  -webkit-mask: var(--sprite-url) center bottom / contain no-repeat;
  mask: var(--sprite-url) center bottom / contain no-repeat;
  transition: transform 160ms cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: 50% 100%;
}

.roles__ghost--ux { --ghost: var(--yellow); --sprite-url: url("../assets/sprites/sprite-ux-designer.gif"); }
.roles__ghost--researcher { --ghost: #6fc3ff; --sprite-url: url("../assets/sprites/sprite-user-researcher.gif"); }
.roles__ghost--ui { --ghost: var(--blue); --sprite-url: url("../assets/sprites/sprite-ui-designer-clean.gif"); }
.roles__ghost--otis { --ghost: var(--orange); --sprite-url: url("../assets/sprites/sprite-otis.gif"); }

.roles__ghost--otis .roles__ghost-shape {
  width: calc(var(--ghost-size) * 0.7);
  height: calc(var(--ghost-size) * 0.7);
}

@media (hover: hover) {
  .roles__ghost:hover {
    color: #fff;
  }

  .roles__ghost:hover .roles__ghost-shape {
    transform: scale(1.1);
  }
}

/* Sits straight under the silhouettes */
.roles__prompt {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-top: var(--space-2);
  padding: 6px 14px;
  text-decoration: none;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.75);
}

@keyframes roles-blink {
  0%, 60% { opacity: 1; }
  61%, 100% { opacity: 0; }
}

/* Waiting state, only when motion.js is running the entrance (.reveal-on).
   .is-live is added when the card is on screen. */
.reveal-on .roles__intro:not(.is-live) .roles__title,
.reveal-on .roles__intro:not(.is-live) .roles__kicker,
.reveal-on .roles__intro:not(.is-live) .roles__sub,
.reveal-on .roles__intro:not(.is-live) .roles__prompt {
  visibility: hidden;
}

.reveal-on .roles__intro:not(.is-live) .roles__ghost {
  opacity: 0;
}

.reveal-on .roles__intro.is-live .roles__ghost {
  animation: roles-ghost-in 260ms steps(3, end) both;
}

.reveal-on .roles__intro.is-live li:nth-child(1) .roles__ghost { animation-delay: 1500ms; }
.reveal-on .roles__intro.is-live li:nth-child(2) .roles__ghost { animation-delay: 1680ms; }
.reveal-on .roles__intro.is-live li:nth-child(3) .roles__ghost { animation-delay: 1860ms; }
.reveal-on .roles__intro.is-live li:nth-child(4) .roles__ghost { animation-delay: 2040ms; }

.reveal-on .roles__intro.is-live .roles__prompt {
  animation: hero-fade 300ms ease 2400ms both;
}

@keyframes roles-ghost-in {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .roles__sub::after {
    animation: none;
  }
}

.roles__stage {
  /* Fills the screen on laptops, but stops growing on very tall screens so the
     content is not left floating in empty space */
  min-height: min(100vh, 920px);
  min-height: min(100svh, 920px);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  grid-template-areas: "info viewer";
  align-items: center;
  column-gap: clamp(32px, 6vw, 112px);
  padding: var(--space-6) var(--page-pad);
}

/* ----- Character and controls ----- */

.roles__viewer {
  grid-area: viewer;
  justify-self: center;
  width: 100%;
  max-width: 540px;
  /* Size of the selected character. The side characters are placed relative to it. */
  --sprite: clamp(220px, min(46vh, 30vw), 400px);
}

/* All four characters live in the same spot. Classes set by roles.js decide the pose:
   is-active  centre, full size, coloured outline and glow
   is-prev    left, smaller, dimmed
   is-next    right, smaller, dimmed
   (none)     hidden behind the active one */

.roles__card {
  position: relative;
  height: var(--sprite);
}

.roles__layer {
  position: absolute;
  left: 50%;
  bottom: 0;
  z-index: 0;
  width: var(--sprite);
  height: var(--sprite);
  margin-left: calc(var(--sprite) / -2);
  opacity: 0;
  pointer-events: none;
  transform: translateX(0) scale(0.4);
  transform-origin: 50% 100%;
  transition:
    transform 420ms cubic-bezier(0.34, 1.4, 0.64, 1),
    opacity 300ms ease;
}

.roles__layer.is-prev,
.roles__layer.is-next {
  z-index: 1;
  opacity: 0.32;
  pointer-events: auto;
  cursor: pointer;
}

.roles__layer.is-prev {
  transform: translateX(-52%) scale(0.58);
}

.roles__layer.is-next {
  transform: translateX(52%) scale(0.58);
}

.roles__layer.is-active {
  z-index: 2;
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0) scale(1);
}

@media (hover: hover) {
  .roles__layer.is-prev:hover,
  .roles__layer.is-next:hover {
    opacity: 0.65;
  }
}

/* Both filter lists have the same functions in the same order so the browser
   can animate smoothly between dimmed and selected. */
.roles__sprite {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  filter:
    brightness(1)
    saturate(0.6)
    drop-shadow(2px 0 0 transparent)
    drop-shadow(-2px 0 0 transparent)
    drop-shadow(0 2px 0 transparent)
    drop-shadow(0 -2px 0 transparent)
    drop-shadow(0 0 12px transparent);
  transition: filter 300ms ease;
}

/* Otis is a dog, so he stands smaller than the human roles.
   Sized (not transformed) so his outline stays the same thickness. */
.roles__layer--small .roles__sprite {
  position: absolute;
  left: 15%;
  bottom: 0;
  width: 70%;
  height: 70%;
}

.roles__layer.is-active .roles__sprite {
  filter:
    brightness(1)
    saturate(1)
    drop-shadow(2px 0 0 var(--role-line))
    drop-shadow(-2px 0 0 var(--role-line))
    drop-shadow(0 2px 0 var(--role-line))
    drop-shadow(0 -2px 0 var(--role-line))
    drop-shadow(0 0 12px color-mix(in srgb, var(--role) 55%, transparent));
}

/* Arrows sit under the side characters */
.roles__controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: calc(var(--sprite) * 1.04 + 52px);
  max-width: 100%;
  margin: var(--space-4) auto 0;
}

.roles__arrow {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 0;
  padding: 0;
  background: var(--bg);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  color: var(--ink);
  cursor: pointer;
  transition: transform 80ms ease-out, box-shadow 80ms ease-out, background-color 250ms ease;
}

@media (hover: hover) {
  .roles__arrow:hover {
    background: var(--role-tint);
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--ink);
  }
}

.roles__arrow:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 var(--ink);
}

.roles__arrow:focus-visible,
.roles__pip:focus-visible {
  outline: 2px solid var(--role-ink);
  outline-offset: 3px;
}

.roles__pips {
  display: flex;
  align-items: center;
  gap: 2px;
}

.roles__pip {
  display: grid;
  place-items: center;
  width: 24px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.roles__pip::before {
  content: "";
  width: 10px;
  height: 10px;
  background: var(--bg);
  border: 1px solid var(--ink-3);
  transition: background-color 250ms ease, border-color 250ms ease, width 120ms ease-out;
}

.roles__pip:hover::before {
  border-color: var(--ink);
}

.roles__pip.is-active::before {
  width: 22px;
  background: var(--role);
  border-color: var(--role-ink);
}

/* ----- Role copy ----- */

.roles__info {
  grid-area: info;
  justify-self: start;
  width: 100%;
  max-width: 42rem;
  text-align: left;
  transition: opacity 150ms ease, transform 150ms ease;
}

.roles__info.is-swapping {
  opacity: 0;
  transform: translateY(6px);
}

.roles__num {
  margin: 0 0 var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.2;
  letter-spacing: 0.2em;
  color: var(--role-ink);
  transition: color 250ms ease;
}

.roles__name {
  margin: 0 0 var(--space-3);
  font-family: var(--font-display);
  font-size: clamp(2rem, 3.7vw, 3.75rem);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.role__body {
  max-width: 36rem;
  margin: 0 0 var(--space-4);
  font-family: var(--font-sans);
  font-size: 1.125rem;
  line-height: 1.5;
  color: var(--ink-2);
}

.role__group {
  margin: 0 0 var(--space-3);
}

.role__label {
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.2;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.role__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.role__chips li {
  padding: 5px 10px;
  border: 1px solid var(--ink);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--ink);
  white-space: nowrap;
}

/* ----- Ability card ----- */

.roles__ability {
  position: relative;
  max-width: 33rem;
  margin-top: var(--space-4);
  padding: 20px 24px 22px;
  background: var(--role-tint);
  border: 1px solid var(--role-ink);
  transition: background-color 250ms ease, border-color 250ms ease;
}

/* Inner keyline, 3px inside the border */
.roles__ability::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid var(--role-line);
  pointer-events: none;
  transition: border-color 250ms ease;
}

.roles__ability-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.2;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--role-ink);
  transition: color 250ms ease;
}

.roles__ability-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}

.roles__ability-iconbox {
  flex: 0 0 56px;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 6px;
  background: var(--bg);
  border: 1px solid var(--role-line);
  transition: border-color 250ms ease;
}

.roles__ability-icon {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.roles__ability-name {
  margin: 2px 0 6px;
  font-family: var(--font-pixel-geist);
  font-size: 1.2rem;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink);
}

.roles__ability-tagline {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--ink-2);
  text-wrap: pretty;
}

@media (prefers-reduced-motion: reduce) {
  .roles__info,
  .roles__arrow,
  .roles__layer,
  .roles__sprite,
  .roles__pip::before {
    transition: none;
  }
}

.site-footer {
  border-top: var(--hairline) solid var(--line);
  padding: var(--space-4) var(--page-pad);
  text-align: center;
}

.site-footer p {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: var(--tracking-mono);
  text-transform: uppercase;
  color: var(--ink-2);
}


/* Tablets in portrait and anything narrower: the selector stacks, character on top */
@media (max-width: 900px) {
  .roles__stage {
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "viewer"
      "info";
    row-gap: var(--space-5);
    padding-top: var(--space-5);
    padding-bottom: var(--space-8);
  }

  .roles__viewer {
    max-width: 420px;
    --sprite: clamp(200px, min(42vh, 62vw), 340px);
  }

  .roles__arrow {
    width: 48px;
    height: 48px;
  }

  .roles__name {
    font-size: clamp(2rem, 9vw, 2.75rem);
  }

  .role__body {
    font-size: 1.0625rem;
  }

  .role__chips li {
    white-space: normal;
  }

  .roles__ability {
    padding: 18px 18px 20px;
  }

  .roles__pip {
    width: 32px;
  }
}

@media (max-width: 768px) {
  /* The two top links move into the menu; the name stays centred */
  .site-bar {
    grid-template-columns: 1fr;
    min-height: 64px;
  }

  .site-bar__link {
    display: none;
  }

  .menu-btn {
    display: grid;
  }

  .hero__frame {
    font-size: clamp(2rem, min(11vw, 17vh), 4.5rem);
  }

  .roles__title {
    font-size: clamp(2rem, min(11.5vw, 20vh), 5.5rem);
  }

  .hero__handle--tm,
  .hero__handle--bm,
  .hero__handle--ml,
  .hero__handle--mr {
    display: none;
  }

  /* No room beside the box on a phone, so the cursor tucks under its right edge */
  .hero__cursor {
    left: auto;
    right: 0;
    margin: 10px 0 0;
  }

  .hero__size {
    left: 0;
    transform: none;
  }

  .about {
    grid-template-columns: minmax(0, 1fr);
    row-gap: var(--space-3);
    padding-top: var(--space-8);
    padding-bottom: var(--space-10);
  }

  .about__label {
    margin-top: 0;
  }

  .work {
    padding-top: var(--space-8);
  }

  .work__grid {
    grid-template-columns: 1fr;
  }

  .work-card__title {
    font-size: 1.5rem;
  }
}

@media (max-width: 390px) {
  .site-bar {
    gap: var(--space-1);
    padding-left: var(--space-2);
    padding-right: var(--space-2);
  }

  .hero,
  .about,
  .work,
  .roles__intro,
  .roles__stage {
    padding-left: var(--space-2);
    padding-right: var(--space-2);
  }
}

/* Short screens, such as a phone on its side: tighten the full-height sections */
@media (max-height: 480px) {
  .hero {
    padding-top: var(--space-8);
    padding-bottom: var(--space-8);
  }

  .roles__intro {
    gap: var(--space-2);
    padding-top: var(--space-6);
    padding-bottom: var(--space-2);
  }

  .roles__title {
    font-size: clamp(2rem, min(9vw, 16vh), 5rem);
  }

  .roles__prompt {
    margin-top: 0;
  }

  .roles__lineup {
    margin-top: var(--space-2);
  }

  .roles__ghost {
    --ghost-size: clamp(44px, 16vh, 80px);
  }
}
