/* Quiet, Apple-like system: hairline rules, near-black ink, one grey for
   secondary text, generous space. Every corner is square on purpose;
   the play icon is the only round shape. */
:root {
  --cube: clamp(84px, 7vw, 104px);
  --gutter: clamp(16px, 4vw, 56px);
  --ink: #1d1d1f;
  --quiet: #6e6e73;        /* 5.1:1 on white */
  --line: 1.5px solid var(--ink); /* the hard outline used on bars, video and cube faces */
  --fill: #f5f5f7;         /* the one surface grey */
  --link: #0066cc;         /* 5.6:1 on white */
  --selected: #4a4a4a;     /* soft dark grey, white text 8.9:1 */
  --ease: cubic-bezier(.25, .1, .25, 1);
  --row-x: 20px;           /* inner side padding of a row */
  --row-y: 24px;
  /* A normal bar: padding top and bottom, a name line, a note line, two 1.5px borders. */
  --bar-h: calc(var(--row-y) * 2 + 1.1875rem * 1.3 + .9375rem * 1.45 + 3px);
}
* { box-sizing: border-box; margin: 0; padding: 0; border-radius: 0; }
html { background: #fff; -webkit-text-size-adjust: 100%; }
body {
  background: #fff;
  color: var(--ink);
  font: 400 1.0625rem/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Helvetica Neue", Arial, sans-serif;
  letter-spacing: -.011em;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

/* One column; the cube sits right beside the name. */
.page {
  max-width: calc(1200px + var(--gutter) * 2);
  margin-inline: auto;
  padding: clamp(28px, 4vw, 56px) var(--gutter) clamp(72px, 9vw, 136px);
}
main { min-width: 0; }

/* The portrait face: a photo filling the face, or a note saying which file to add. */
.face.portrait { padding: 0; overflow: hidden; color: var(--quiet); font-weight: 500; font-size: max(10px, calc(var(--cube) * .1)); }
.face.portrait img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }

/* Name, bio and links on the left; the cube sits to their right, centred on the block. */
.bio { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.intro { min-width: 0; }
/* The scene is a little larger than the cube so the area around it is draggable too. */
.side { flex: none; display: flex; flex-direction: column; align-items: center; }
/* The dock holds the cube's place in the layout while it's flying around the screen. */
.dock { width: calc(var(--cube) * 1.5); height: calc(var(--cube) * 1.3); }
#scene.flying { position: fixed; left: 0; top: 0; z-index: 40; will-change: transform; }
.spin-me {
  margin-top: 2px; padding: 2px 4px; background: none; border: 0; cursor: pointer;
  font: inherit; font-size: .8125rem; color: var(--quiet);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em;
}
.spin-me:hover { color: var(--ink); }
/* "Spin me" breathes gently until the cube is sent flying. */
.spin-me:not(.flying) { animation: spin-me-pulse 2.6s var(--ease) infinite; }
.spin-me:hover { animation-play-state: paused; }
@keyframes spin-me-pulse {
  0%, 100% { color: var(--quiet); transform: scale(1); }
  50% { color: var(--ink); transform: scale(1.08); }
}
@media (prefers-reduced-motion: reduce) { .spin-me:not(.flying) { animation: none; } }
.spin-me:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
#scene {
  width: calc(var(--cube) * 1.5); height: calc(var(--cube) * 1.3);
  display: grid; place-items: center; perspective: 1400px;
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
}
#scene.dragging { cursor: grabbing; }
#scene:focus-visible { outline: 2px solid var(--link); outline-offset: -2px; }
#cube { position: relative; width: var(--cube); height: var(--cube); transform-style: preserve-3d; }
.face {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 10%;
  text-align: center; background: var(--fill); color: var(--ink);
  border: var(--line);
  font-size: max(10px, calc(var(--cube) * .12)); font-weight: 600; line-height: 1.12; letter-spacing: -.01em;
  text-wrap: balance;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}

/* Bio */
.bio { margin-bottom: clamp(32px, 4vw, 52px); }
h1 { font-size: clamp(2.25rem, 1.6rem + 2vw, 3.25rem); font-weight: 600; line-height: 1.07; letter-spacing: -.03em; }
.bio p { font-size: clamp(1.1875rem, 1.05rem + .5vw, 1.4375rem); line-height: 1.38; letter-spacing: -.017em; color: var(--quiet); margin-top: 12px; max-width: 40ch; text-wrap: balance; }
.bio .links { list-style: disc; padding-left: 1.25em; margin-top: 16px; font-size: 1.0625rem; line-height: 1.7; }
.links li::marker { color: var(--ink); }
.links a { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; }
.links a:hover { text-decoration-thickness: 2px; }
.links a:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* Projects: separate bars, each with a hard outline. */
.section { font-size: .8125rem; font-weight: 600; line-height: 1; letter-spacing: .02em; color: var(--quiet); text-transform: uppercase; margin-bottom: 14px; }
#projects { list-style: none; counter-reset: project; display: grid; gap: 10px; }
/* On wide screens the projects sit in two columns; Mises spans both. */
@media (min-width: 900px) {
  #projects { grid-template-columns: 1fr 1fr; }
  #projects > .featured { grid-column: 1 / -1; }
}
#projects > li { counter-increment: project; position: relative; }
#projects { align-items: start; }
.bar {
  display: grid; grid-template-columns: 2.75rem minmax(0, 1fr) auto auto; column-gap: 0; align-content: center;
  width: 100%; padding: var(--row-y) var(--row-x);
  background: #fff; color: var(--ink);
  border: var(--line); font: inherit; text-align: left; cursor: pointer; text-decoration: none;
  transition: background-color .3s var(--ease), color .3s var(--ease);
}
.bar::before {
  content: counter(project, decimal-leading-zero);
  grid-column: 1; grid-row: 1; align-self: baseline;
  color: var(--quiet); font-size: .875rem; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: .01em;
  transition: color .3s var(--ease);
}
.name { grid-column: 2; grid-row: 1; align-self: baseline; display: block; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.1875rem; font-weight: 600; line-height: 1.3; letter-spacing: -.018em; }
.note { grid-column: 2; display: block; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--quiet); font-style: normal; font-size: .9375rem; line-height: 1.45; letter-spacing: -.008em; transition: color .3s var(--ease); }
/* The project facing you on the cube: a quiet marker only. */
.bar.current::before { color: var(--ink); }
/* Hovered or focused: soft dark grey. */
.bar.active, .bar:hover { background: var(--selected); color: #fff; }
.bar.active .note, .bar:hover .note,
.bar.active::before, .bar:hover::before { color: rgba(255, 255, 255, .8); }
/* Hardware / Software / Research tag: a small outlined label on the right of a bar. */
.tag {
  grid-column: 4; grid-row: 1 / span 2; align-self: center; margin-left: 16px;
  padding: 3px 8px; border: 1px solid var(--ink);
  font-size: .75rem; font-weight: 500; line-height: 1.3; letter-spacing: .01em; white-space: nowrap;
  transition: color .3s var(--ease), border-color .3s var(--ease);
}
.bar.active .tag, .bar:hover .tag, .featured:hover .tag { color: #fff; border-color: #fff; }
/* Hardware is the inverse of Software: a solid dark tag with light text. */
.tag.hardware { background: var(--ink); color: #fff; }
.bar.active .tag.hardware, .bar:hover .tag.hardware { background: #fff; color: var(--ink); border-color: #fff; }
.bar:focus-visible { outline: 2px solid var(--link); outline-offset: -2px; }

/* Mises is 1.5 times the height of a normal row, with a 16:9 video tile on the right. */
.featured-row { display: flex; height: calc(var(--bar-h) * 1.5); background: #fff; border: var(--line); transition: background-color .3s var(--ease); }
.featured-row:has(.bar.active), .featured:hover .featured-row { background: var(--selected); }
.featured .bar { flex: 1; min-width: 0; height: 100%; background: transparent; border: 0; }
.featured .bar.active, .featured:hover .bar { background: var(--selected); color: #fff; }
.featured:hover .bar .note, .featured:hover .bar::before { color: rgba(255, 255, 255, .8); }
.featured .name { font-size: 1.75rem; line-height: 1.18; letter-spacing: -.026em; }
.featured .note { margin-top: 4px; }
.video {
  flex: none; align-self: center; margin-right: var(--row-x);
  height: calc(100% - 28px); aspect-ratio: 16 / 9; max-width: 46%;
  background: var(--fill);
  box-shadow: inset 0 0 0 1.5px var(--ink);
  transition: background-color .3s var(--ease), color .3s var(--ease), box-shadow .3s var(--ease);
}
video.video { object-fit: cover; background: #000; }
.video.placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--quiet); font-size: .75rem; font-weight: 500; line-height: 1.2; letter-spacing: .02em; text-align: center; padding: 8px; }
/* On the dark row the tile steps down to a slightly lighter grey with a hairline, so it reads as part of the row. */
.featured:hover .video.placeholder, .featured:has(.bar.active) .video.placeholder {
  background: #5a5a5a; color: rgba(255, 255, 255, .85); box-shadow: inset 0 0 0 1.5px #fff;
}
.play { flex: none; width: 48px; height: 48px; background: #fff; border: var(--line); border-radius: 50%; position: relative; }
.play::after { content: ""; position: absolute; left: 17.5px; top: 13.5px; border-left: 14px solid var(--ink); border-top: 9px solid transparent; border-bottom: 9px solid transparent; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* Phone */
@media (max-width: 720px) {
  :root { --cube: 72px; --gutter: 16px; --row-x: 14px; --row-y: 18px; }
  .page { padding: 32px 16px 56px; }
  .face { font-size: 9px; padding: 8%; }
  h1 { font-size: 1.875rem; }
  .bio p { font-size: 1.0625rem; margin-top: 8px; }
  .bar { grid-template-columns: 2.25rem minmax(0, 1fr); }
  .featured .name { font-size: 1.375rem; }
  .video { height: calc(100% - 24px); max-width: 44%; }
  .play { width: 40px; height: 40px; }
  .play::after { left: 14.5px; top: 10.5px; border-left-width: 12px; border-top-width: 8px; border-bottom-width: 8px; }
}

/* Hover thumbnails: a few small photos appear inside the project's own bar.
   They're part of the bar's link, so clicking them opens the project page. */
.thumbs {
  grid-column: 3; grid-row: 1 / span 2; align-self: center;
  display: flex; gap: 6px; max-width: 0; margin-left: 0; overflow: hidden; opacity: 0;
  /* Width changes in one step (so the name re-wraps once, not every frame); only the fade animates. */
  transition: opacity .25s var(--ease);
}
li.expanded .thumbs, .bar:focus-visible .thumbs { max-width: 200px; margin-left: 16px; opacity: 1; transition-delay: .08s; }

/* At rest each bar shows one line of name and note, cut off with an ellipsis.
   Hovered (gallery.js adds .expanded after a short pause) the bar grows to 1.5 times
   its height and shows the full text. */
#projects .bar { min-height: var(--bar-h); transition: min-height .3s var(--ease), background-color .3s var(--ease), color .3s var(--ease); }
#projects > li.expanded .bar { min-height: calc(var(--bar-h) * 1.5); }
#projects > li.full .name, #projects > li.full .note { white-space: normal; overflow: visible; }
#projects > .featured .featured-row { transition: height .3s var(--ease), background-color .3s var(--ease); }
#projects > .featured.expanded .featured-row { height: calc(var(--bar-h) * 1.85); } /* Mises is already 1.5x, so it grows only about a quarter */
#projects > .featured .bar { min-height: 0; }
html { overflow-anchor: none; } /* stop the browser re-scrolling while bars grow and shrink */
.thumbs .tile { flex: none; width: 56px; height: 42px; aspect-ratio: auto; }
.thumbs .tile.empty { font-size: .5625rem; padding: 2px; }
.bar:hover .thumbs .tile, .bar.active .thumbs .tile { border-color: #fff; }
.bar:hover .thumbs .tile.empty, .bar.active .thumbs .tile.empty { background: #5a5a5a; color: rgba(255, 255, 255, .85); }
.tile { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--fill); border: 1px solid var(--ink); }
.tile.empty { display: grid; place-items: center; color: var(--quiet); font-size: .75rem; font-weight: 500; text-align: center; padding: 6px; }

/* Project pages */
.project-page { max-width: calc(1000px + var(--gutter) * 2); }
.back { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; font-size: .9375rem; }
.back::before { content: "\2190\00a0"; }
.back:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.project-head { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; margin-top: 40px; }
.project-head .tag { margin-left: 0; font-size: .875rem; }
.lede { margin-top: 16px; max-width: 46ch; color: var(--quiet); font-size: clamp(1.1875rem, 1.05rem + .5vw, 1.4375rem); line-height: 1.38; }
.hero-video { width: 100%; height: auto; max-width: none; margin: 40px 0 0; aspect-ratio: 16 / 9; font-size: .9375rem; }
.project-page .section { margin-top: 56px; }
.gallery.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
@media (max-width: 720px) {
  .thumbs { display: none; }
  /* No hover on phones, so show full text instead of cutting it off. */
  .name, .note { white-space: normal; overflow: visible; }
  .gallery.grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .project-head { margin-top: 28px; }
}
