@font-face {
  font-family: "Archivo";
  src: url("../assets/fonts/archivo-var.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("../assets/fonts/sourceserif4-var.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("../assets/fonts/sourceserif4-italic-var.woff2") format("woff2");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}

:root {
  --paper: #e9ecf1;
  --ink: #1b2040;
  --ink-soft: #4a5070;
  --staff: #b9c0ce;
  --low: #2440b8;
  --mid: #2e8b57;
  --high: #f2b705;
  --cell: #dfe3ea;

  --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --serif: "Source Serif 4", Georgia, serif;

  /* perfect fourth, base 18px */
  --s-1: 0.844rem;
  --s0: 1.125rem;
  --s1: 1.5rem;
  --s2: 2rem;
  --s3: 2.666rem;
  --s4: 3.553rem;

  --gutter: clamp(1.25rem, 4vw, 3rem);
  --measure: 36em;
}

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

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--s0);
  line-height: 1.6;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; height: auto; }

a { color: var(--low); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--low);
  outline-offset: 3px;
}

h1, h2, h3, h4 {
  font-family: var(--sans);
  font-weight: 700;
  line-height: 1.1;
  margin: 0;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 0.5rem 1rem;
  z-index: 10;
}
.skip:focus { left: var(--gutter); }

/* Top bar */
.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 1.25rem var(--gutter);
  font-family: var(--sans);
  font-size: var(--s-1);
}
.top a { color: var(--ink); text-decoration: none; }
.top a:hover { text-decoration: underline; }
.top-name { font-weight: 700; }
.top nav { display: flex; gap: 1.25rem; flex-wrap: wrap; }

main, .contact {
  padding-inline: var(--gutter);
  max-width: 80rem;
  margin-inline: auto;
}

/* Hero */
.hero {
  padding-top: clamp(1.5rem, 5vw, 4rem);
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  column-gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
}
.hero-intro { padding-top: 0.5rem; }

.hero h1 {
  font-size: clamp(3.2rem, 8.4vw, 8.5rem);
  font-weight: 800;
  font-stretch: 125%;
  letter-spacing: -0.02em;
  line-height: 0.92;
}

.hero-lede {
  font-size: var(--s1);
  line-height: 1.45;
  max-width: 30em;
  margin: 1.5rem 0 0;
}

/* Instrument */
.instrument { margin: 0; }

.seq {
  --steps: 16;
  display: grid;
  grid-template-columns: 2.4rem repeat(var(--steps), minmax(0, 1fr));
  gap: 3px;
  touch-action: manipulation;
}

.seq-note {
  font-family: var(--sans);
  font-size: var(--s-1);
  font-stretch: 75%;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  align-self: center;
}

.seq-cell {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  aspect-ratio: 1;
  min-height: 0;
  background: var(--cell);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}
.seq-cell.reg-low { --c: var(--low); }
.seq-cell.reg-mid { --c: var(--mid); }
.seq-cell.reg-high { --c: var(--high); }

/* beat lines: a heavier gap before every fourth step */
.seq-cell.beat-start { box-shadow: -3px 0 0 var(--staff); }

.seq-cell:hover { background: var(--staff); }
.seq-cell[aria-pressed="true"] { background: var(--c); }

/* playhead: the column being heard */
.seq-cell.now:not([aria-pressed="true"]) { background: #d3d8e2; }

/* a note sounding: the cell pops and throws a glow in its own colour */
.seq-cell.hit { animation: seq-pop 0.28s ease-out; z-index: 1; }
.seq-cell.hit::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 5px;
  pointer-events: none;
  box-shadow: 0 0 0 2px var(--c), 0 0 26px 8px var(--c);
  animation: seq-glow 0.6s ease-out forwards;
}
@keyframes seq-pop {
  from { transform: scale(1.22); }
  to { transform: scale(1); }
}
@keyframes seq-glow {
  from { opacity: 0.85; transform: scale(1); }
  to { opacity: 0; transform: scale(1.6); }
}
@media (prefers-reduced-motion: reduce) {
  .seq-cell.hit { animation: none; }
  .seq-cell.hit::after { animation: seq-glow-still 0.5s ease-out forwards; }
  @keyframes seq-glow-still {
    from { opacity: 0.7; }
    to { opacity: 0; }
  }
}

.instrument figcaption {
  font-size: var(--s-1);
  line-height: 1.55;
  color: var(--ink-soft);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 1.5rem;
  margin-top: 1.25rem;
  padding-left: 2.4rem; /* line up with the first column of cells */
}
.instrument figcaption p { margin: 0 0 0.6rem; max-width: 34em; grid-column: 2; }
.instrument figcaption .play { grid-row: 1 / span 2; align-self: start; }

.play {
  font-family: var(--sans);
  font-size: var(--s0);
  font-weight: 700;
  color: var(--paper);
  background: var(--ink);
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.4rem;
  cursor: pointer;
  white-space: nowrap;
}
.play[aria-pressed="true"] { background: var(--low); }

/* Section headings */
.work > h2,
.more > h2,
.contact > h2 {
  font-size: var(--s3);
  font-stretch: 112%;
  margin: 0 0 2rem;
}

.work { padding-top: clamp(5rem, 12vw, 9rem); }

/* Projects
   split: title, then media | text side by side (media and text of similar height)
   wide:  title, then media across the page, then intro | notes                     */
.project {
  display: grid;
  column-gap: clamp(1.5rem, 4vw, 3.5rem);
  row-gap: 1.75rem;
  padding: clamp(2.5rem, 6vw, 4.5rem) 0;
  border-top: 1px solid var(--staff);
}
.project > h3 { grid-area: title; }
.project-media { grid-area: media; display: grid; gap: 1rem; align-content: start; }
.project-text { grid-area: text; }
.project-media img { border-radius: 4px; }

.project--split {
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  grid-template-areas: "title title" "media text";
}
.project--split .project-lede { margin-top: 0; }

.project--wide {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "title" "media" "text";
}
.project--wide .project-text {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  column-gap: clamp(1.5rem, 4vw, 3.5rem);
}
.project--wide .project-lede { margin-top: 0; }

.project h3 {
  font-size: var(--s4);
  font-stretch: 115%;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.project-lede {
  font-size: var(--s1);
  line-height: 1.4;
  margin: 1rem 0 1.5rem;
  max-width: var(--measure);
}

.facts {
  margin: 0 0 1.75rem;
  display: grid;
  gap: 0.35rem;
  font-family: var(--sans);
  font-size: var(--s-1);
}
.facts div { display: grid; grid-template-columns: 6.5rem 1fr; gap: 1rem; }
.facts dt { font-stretch: 75%; color: var(--ink-soft); }
.facts dd { margin: 0; }

.project h4 {
  font-size: var(--s0);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.decisions {
  margin: 0 0 1.75rem;
  padding-left: 1.1rem;
  max-width: var(--measure);
}
.decisions li { margin-bottom: 0.7rem; }
.decisions li::marker { color: var(--staff); }

.links {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1.25rem;
  margin: 0;
}
.link-strong {
  font-family: var(--sans);
  font-weight: 700;
  font-size: var(--s0);
}
.link-hint { font-size: var(--s-1); color: var(--ink-soft); }

.media-pair {
  display: grid;
  grid-template-columns: 1.17fr 2.09fr;
  gap: 1rem;
  align-items: start;
}
.media-pair figure { margin: 0; }
.media-pair figcaption {
  font-family: var(--sans);
  font-size: var(--s-1);
  color: var(--ink-soft);
  margin-top: 0.4rem;
}

.phones {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  max-width: 40rem;
}
.phones img { border-radius: 14px; }
.phones img:nth-child(2) { margin-top: 3rem; }

/* Click-to-load video */
.video {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--ink);
  border-radius: 4px;
  overflow: hidden;
}
.video img { width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-play {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  font-family: var(--sans);
  font-size: var(--s-1);
  font-weight: 700;
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-radius: 999px;
  padding: 0.6rem 1.1rem 0.6rem 2.2rem;
  cursor: pointer;
}
.video-play::before {
  content: "";
  position: absolute;
  left: 1rem;
  top: 50%;
  translate: 0 -50%;
  border-left: 0.6rem solid currentColor;
  border-block: 0.38rem solid transparent;
}
.video-play:hover { background: var(--high); }

/* Research */
.research {
  margin-top: clamp(4rem, 10vw, 8rem);
  padding: clamp(2.5rem, 6vw, 4.5rem) var(--gutter);
  margin-inline: calc(var(--gutter) * -1);
  background: var(--ink);
  color: var(--paper);
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}
.research a { color: var(--high); }
.research h2 {
  font-size: var(--s4);
  font-stretch: 115%;
  font-weight: 800;
}
.research-sub {
  font-size: var(--s1);
  line-height: 1.4;
  margin: 1rem 0 2rem;
  max-width: 30em;
}
.research-text > p:not(.research-sub) { max-width: var(--measure); }
.concepts { padding-left: 1.1rem; max-width: var(--measure); }
.concepts li { margin-bottom: 0.7rem; }
.concepts strong { font-family: var(--sans); font-weight: 700; }

.cube { margin: 0; position: sticky; top: 2rem; }
.cube svg { width: 100%; height: auto; overflow: visible; }
.cube-edges path { fill: none; stroke: #5a6290; stroke-width: 1; }
.cube-axes path { fill: none; stroke: var(--paper); stroke-width: 2; }
.cube-diagonal { stroke: var(--high); stroke-width: 3; stroke-dasharray: 2 7; stroke-linecap: round; }
.cube-origin { fill: var(--paper); }
.cube-peak { fill: var(--high); }
.cube-label { fill: var(--paper); font-family: var(--sans); font-size: 13px; }
.cube figcaption {
  font-family: var(--sans);
  font-size: var(--s-1);
  color: #b9c0e0;
  margin-top: 0.75rem;
}

/* Also */
.more { padding-top: clamp(4rem, 10vw, 8rem); }
.more-grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
}
.small-project h3 { font-size: var(--s2); font-stretch: 112%; margin: 1.25rem 0 0.5rem; }
.small-project:not(:has(.video)) h3 { margin-top: 0; }
.small-project p { max-width: var(--measure); margin: 0 0 1rem; }

/* Contact */
.contact {
  padding-top: clamp(4rem, 10vw, 8rem);
  padding-bottom: 4rem;
}
.contact > p { font-size: var(--s1); line-height: 1.4; max-width: 28em; margin: 0 0 1.5rem; }
.contact-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  font-family: var(--sans);
  font-size: var(--s1);
  font-weight: 700;
}

.tools {
  margin: 3rem 0 0;
  display: grid;
  gap: 0.5rem;
  font-family: var(--sans);
  font-size: var(--s-1);
  max-width: 44rem;
}
.tools div { display: grid; grid-template-columns: 9rem 1fr; gap: 1rem; }
.tools dt { font-stretch: 75%; color: var(--ink-soft); }
.tools dd { margin: 0; }

/* Narrow screens */
@media (max-width: 860px) {
  .hero,
  .research,
  .more-grid { grid-template-columns: minmax(0, 1fr); }
  .project--split,
  .project--wide { grid-template-columns: minmax(0, 1fr); grid-template-areas: "title" "media" "text"; }
  .project--wide .project-text { grid-template-columns: minmax(0, 1fr); }
  .cube { position: static; }
  .cube { max-width: 26rem; }
  .instrument { margin-top: 2.5rem; }
  .top nav { gap: 0.9rem; }
}

@media (max-width: 600px) {
  .seq { --steps: 8; grid-template-columns: 2rem repeat(var(--steps), minmax(0, 1fr)); }
  .instrument figcaption { padding-left: 0; grid-template-columns: minmax(0, 1fr); }
  .instrument figcaption p { grid-column: 1; }
  .instrument figcaption .play { grid-row: auto; justify-self: start; margin-bottom: 1rem; }
  .facts div { grid-template-columns: 5.5rem 1fr; }
  .tools div { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .contact-links { font-size: var(--s0); }
  .top { flex-direction: column; gap: 0.4rem; }
}

/* Looping gameplay clip */
.clip { margin: 0; }
.clip-frame { position: relative; border-radius: 4px; overflow: hidden; background: #07080f; }
.clip video { display: block; width: 100%; height: auto; }
.clip-controls {
  position: absolute;
  right: 0.75rem;
  bottom: 0.75rem;
  display: flex;
  gap: 0.5rem;
}
.clip-toggle,
.clip-sound {
  font-family: var(--sans);
  font-size: var(--s-1);
  font-weight: 700;
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  opacity: 0.85;
}
.clip-toggle:hover,
.clip-toggle:focus-visible,
.clip-sound:hover,
.clip-sound:focus-visible { opacity: 1; }
.clip-sound[aria-pressed="true"] { background: var(--high); opacity: 1; }
.clip figcaption {
  font-family: var(--sans);
  font-size: var(--s-1);
  color: var(--ink-soft);
  margin-top: 0.5rem;
  max-width: 40em;
}
