/* Font faces live in fonts.css so this file carries no asset paths. */

:root {
  --ground: #f7f7f5;
  --surface: #ffffff;
  --mat: #efefeb;
  --ink: #111111;
  --body: #4a4a47;
  --muted: #63635e;
  --line: #dcdcd7;
  --track: #8d8d86;
  --dark: #111111;
  --dark-hover: #333331;
  --dark-line: #2c2c2a;
  --dark-body: #c4c4be;
  --dark-muted: #a3a39d;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --gutter: 32px;
  --col1: 6.5rem;
  --col-gap: 24px;
  --shelf-cols: 1.22fr 1fr 1fr;
  --shelf-gap: 20px;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 4px;
}

[hidden] {
  display: none !important;
}

/* 1120px up to a 1440px viewport, growing to 1240px by 1920px. */

.page {
  max-width: clamp(1120px, calc(760px + 25vw), 1240px);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.inl {
  white-space: nowrap;
  text-decoration: underline;
  text-decoration-color: var(--muted);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.inl:hover {
  text-decoration-color: var(--ink);
}

/* Keeps a short phrase on one line. */

.nb {
  white-space: nowrap;
}

.rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.arrow {
  flex: none;
  margin-right: -4px;
  stroke: var(--muted);
  transition: transform 0.2s ease, stroke 0.2s ease;
}

/* Masthead: shares the shelf's three columns, so the link grid sits over the third card. */

.mast {
  display: grid;
  grid-template-columns: var(--shelf-cols);
  gap: 24px var(--shelf-gap);
  align-items: end;
  padding: 52px 0 32px;
}

.mast__intro {
  grid-column: 1 / 3;
  min-width: 0;
}

.name {
  margin-bottom: 14px;
  font-size: clamp(2.5rem, 1.9rem + 2.6vw, 3.5rem);
  font-weight: 600;
  line-height: 1.06;
  letter-spacing: -0.03em;
}

/* The two paragraphs grow from 18px and 14px on a phone to 20px and 16px at 1120px. */

.lede {
  max-width: 54ch;
  margin-bottom: 8px;
  font-size: clamp(1.125rem, 0.98rem + 0.385vw, 1.25rem);
  line-height: 1.45;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

/* Each sentence of the lede starts on its own line and is balanced on its own. From tablet up
   the first one (role and place) fits on a single line. The link and the comma after it share
   one no-wrap span in the markup: the link is an inline-block (for its touch area, below) and a
   line may break right after one, which would start the next line with the comma. */

.lede__s {
  display: block;
}

.bio {
  max-width: 62ch;
  color: var(--body);
  font-size: clamp(0.875rem, 0.73rem + 0.385vw, 1rem);
  line-height: 1.55;
  text-wrap: pretty;
}

/* Links inside the two intro paragraphs get a 44px touch area on any touch-capable device, centred
   on the text so the line spacing does not change. */

.lede .inl,
.bio .inl {
  position: relative;
  display: inline-block;
}

@media (any-pointer: coarse) {
  .lede .inl::after,
  .bio .inl::after {
    position: absolute;
    top: 50%;
    right: -2px;
    left: -2px;
    min-width: 44px;
    height: max(100%, 44px);
    content: "";
    transform: translateY(-50%);
  }
}

.links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.links__cell {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background-color 0.15s ease;
}

.links__cell svg {
  flex: none;
}

/* The two solid marks are drawn slightly smaller to match the outline icons' weight;
   the margin keeps every icon in a 16px box so the labels share a left edge. */

.links__cell .icon-solid {
  margin: 0 0.75px;
}

.links__cell:nth-child(2n) {
  border-left: 1px solid var(--line);
}

.links__cell:nth-child(n + 3) {
  border-top: 1px solid var(--line);
}

.links__cell:hover {
  background: var(--mat);
}

.links__cell--solid {
  background: var(--dark);
  color: var(--ground);
}

.links__cell--solid:hover {
  background: var(--dark-hover);
}

.links__cell:focus-visible {
  outline-offset: -3px;
  border-radius: 5px;
}

.links__cell--solid:focus-visible {
  outline-color: var(--ground);
}

/* Section headers */

.section-head {
  display: flex;
  gap: 0 16px;
  align-items: baseline;
  justify-content: space-between;
}

/* When the two do not fit on one line the title gives way first, wrapping down to its
   longest word; only then does the link wrap. */

.section-title {
  flex: 0 1000 auto;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25rem;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  text-wrap: balance;
}

.section-link {
  position: relative;
  flex: 0 1 auto;
  min-width: 0;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25rem;
  text-align: right;
}

.section-link:hover {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

/* On touch-capable devices small standalone links get a 44px-tall touch area from a
   pseudo-element, so the focus ring still hugs the text. */

@media (any-pointer: coarse) {
  .section-link::before,
  .plate__link::before,
  .exp__org .inl::before,
  .foot__mail::before {
    position: absolute;
    inset: -12px 0;
    content: "";
  }
}

/* The toggle is hidden in the markup and revealed by the script once it works. The second
   content value keeps the sign out of the accessible name where that syntax is supported. */

.section-link[data-toggle]::after {
  margin-left: 6px;
  content: "+";
  content: "+" / "";
}

.section-link[data-toggle][aria-expanded="true"]::after {
  content: "−";
  content: "−" / "";
}

/* Projects shelf */

.projects {
  padding-bottom: 48px;
}

.projects .section-head {
  padding-bottom: 16px;
}

.shelf {
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: var(--shelf-cols);
  gap: 0 var(--shelf-gap);
}

.card {
  display: grid;
  grid-row: span 2;
  grid-template-rows: subgrid;
  grid-template-columns: minmax(0, 1fr);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color 0.2s ease;
}

/* The title holds the card's link and its ::after stretches over the whole card, so the
   card behaves as one link while leaving room for a second link inside it. The focus
   ring is drawn around the card, not around the title text. */

.card__link::after {
  position: absolute;
  inset: 0;
  content: "";
}

.card__link:focus-visible {
  outline: none;
}

.card:has(.card__link:focus-visible) {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

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

.card:hover .arrow,
.pub:hover .arrow {
  stroke: var(--ink);
  transform: translate(2px, -2px);
}

/* The mat takes its minimum height from a 16:10 box and the screenshot's frame fills
   whatever height the row ends up with, so the mat is even on three sides at every width. */

.card__mat {
  position: relative;
  padding: 12px 12px 0;
  border-bottom: 1px solid var(--line);
  background: var(--mat);
}

.card__mat::before {
  display: block;
  aspect-ratio: 16 / 10;
  content: "";
}

.card__frame {
  position: absolute;
  top: 12px;
  left: 12px;
  width: calc(100% - 24px);
  height: calc(100% - 12px);
  overflow: hidden;
  border: 1px solid rgba(17, 17, 17, 0.08);
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
}

.card__shot {
  width: 100%;
  max-width: none;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

/* A sparse screenshot is shown enlarged from its top-left corner, so what it contains
   stays legible at card size. 135% ends the jpmusicnearme capture in the white band
   below its filter buttons; a different screenshot will want a different value. */

.card__shot--tight {
  width: 135%;
  height: 135%;
  object-position: left top;
}

.card__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
}

.card__head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.card__head .arrow {
  margin-top: 3px;
}

.card__title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.card__meta,
.card__stack {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.5;
}

.card__text {
  color: var(--body);
  font-size: 0.875rem;
  line-height: 1.5;
  text-wrap: pretty;
}

.card__stack {
  margin-top: auto;
  padding-top: 8px;
}

.card--dark {
  border-color: var(--dark);
  background: var(--dark);
  color: var(--ground);
}

/* The divider belongs to the plate, the same shelf row as the white cards' mat border, so
   the three titles share a baseline exactly. */

.card--dark .card__plate {
  border-bottom: 1px solid var(--dark-line);
}

.card--dark .card__meta,
.card--dark .card__stack {
  color: var(--dark-muted);
}

.card--dark .card__text {
  color: var(--dark-body);
}

.card--dark .arrow {
  stroke: var(--dark-muted);
}

.card--dark:hover {
  border-color: var(--dark-muted);
}

.card--dark:hover .arrow {
  stroke: var(--ground);
}

.card:hover .card__title,
.pub:hover .pub__title {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

/* Install line at the top, figure and caption at the bottom. The mascot stands on the
   figure's baseline at the right, so its cropped lower edge has a line to sit on. It
   shares the first three rows instead of adding one, so the panel is never taller than
   the 16:10 screenshot frames next to it. */

.card__plate {
  display: grid;
  grid-template-rows: auto minmax(14px, 1fr) auto auto;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 12px;
  padding: 20px 20px 16px;
}

.plate__install {
  grid-row: 1;
  grid-column: 1;
}

.plate__install,
.plate__caption {
  color: var(--dark-muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.5;
}

.plate__mascot {
  grid-row: 1 / span 3;
  grid-column: 2;
  align-self: end;
  width: 88px;
  height: 62px;
  margin-bottom: 6px;
  object-fit: contain;
}

/* The 14vw ceiling only bites when text is enlarged on a narrow phone, where it keeps the
   figure clear of the mascot beside it. */

.plate__stat {
  grid-row: 3;
  grid-column: 1;
  font-size: min(clamp(2.75rem, 2rem + 2.2vw, 3.25rem), 14vw);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.plate__caption {
  grid-row: 4;
  grid-column: 1 / -1;
  margin-top: 8px;
  text-wrap: balance;
}

/* Each line of the caption is its own block, so when one has to wrap on a narrow phone it is
   balanced over two lines instead of leaving its last word alone. */

.plate__line {
  display: block;
}

/* A link inside the card sits above the stretched card link. While it is hovered the
   card's own hover cues are switched off, so it is clear which link a click follows. */

.plate__link {
  position: relative;
  z-index: 1;
  text-decoration: underline;
  text-decoration-color: var(--dark-muted);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.plate__link:hover {
  color: var(--ground);
  text-decoration-color: var(--ground);
}

.plate__link:focus-visible {
  outline-color: var(--ground);
}

.card:has(.plate__link:hover) .card__title {
  text-decoration: none;
}

.card--dark:has(.plate__link:hover) .arrow {
  stroke: var(--dark-muted);
  transform: none;
}

/* Ledgers */

.ledger {
  padding-bottom: 32px;
  border-top: 2px solid var(--ink);
}

.ledger .section-head {
  padding: 16px 0;
}

.when {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.5rem;
}

.pub {
  display: grid;
  grid-template-columns: var(--col1) minmax(0, 1fr) 20px;
  gap: 4px var(--col-gap);
  align-items: start;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.pub__meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.tag {
  padding: 2px 5px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.pub__main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.pub__title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5rem;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.pub__authors {
  max-width: 76ch;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
  text-wrap: pretty;
}

.pub__authors span,
.pub__authors strong {
  white-space: nowrap;
}

.pub__authors strong {
  color: var(--ink);
  font-weight: 600;
}

.pub .arrow {
  justify-self: end;
  margin-top: 4px;
}

.exp {
  display: grid;
  grid-template-columns: var(--col1) minmax(0, 1fr) minmax(0, 1.45fr);
  gap: 6px var(--col-gap);
  align-items: start;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.exp__when {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.spark-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 5.5rem;
}

.spark {
  position: relative;
  display: block;
  height: 4px;
  background: var(--track);
}

.spark i {
  position: absolute;
  top: 0;
  left: var(--from);
  width: var(--span);
  height: 4px;
  background: var(--ink);
}

.spark-key {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.2;
}

.exp__role {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5rem;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.exp__org {
  color: var(--body);
  font-size: 0.875rem;
  line-height: 1.375rem;
}

.exp__org .inl {
  position: relative;
  display: inline-block;
}

.exp__sum {
  min-width: 0;
  max-width: 62ch;
  color: var(--body);
  font-size: 0.875rem;
  line-height: 1.55;
  text-wrap: pretty;
}

/* Footer */

.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: space-between;
  padding: 20px 0 36px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.25rem;
}

.foot__mail {
  position: relative;
  display: inline-block;
  text-decoration: underline;
  text-decoration-color: var(--muted);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.foot__mail:hover {
  color: var(--ink);
  text-decoration-color: var(--ink);
}

/* In the table layouts the date, the title and the first line of text share a baseline. */

@media (min-width: 601px) {
  .pub,
  .exp {
    align-items: baseline;
  }

  .pub .arrow {
    align-self: start;
  }
}

/* Three-across shelf (961px up): the experience table sits on the shelf's own columns, so
   each summary starts on the second card's left edge. The date keeps its narrow column
   inside the first track and the role is offset past it. */

@media (min-width: 961px) {
  .exp {
    grid-template-columns: var(--shelf-cols);
    column-gap: var(--shelf-gap);
  }

  .exp__when {
    grid-row: 1;
    grid-column: 1;
    justify-self: start;
    width: var(--col1);
  }

  .exp__what {
    grid-row: 1;
    grid-column: 1;
    margin-left: calc(var(--col1) + var(--col-gap));
  }

  .exp__sum {
    grid-row: 1;
    grid-column: 2 / 4;
  }

  /* The two white cards' short paragraphs are balanced so neither ends on a single word.
     Their compounds are kept whole in the markup. */

  .card:not(.card--dark) .card__text {
    text-wrap: balance;
  }
}

/* Desktop: the flagship column gets a little more of the shelf. The masthead uses the
   same variable, so the link grid stays over the third card.

   The publications table joins the same columns here, where its titles have the room:
   each venue starts on the third card's left edge, under the link grid. */

@media (min-width: 1120px) {
  :root {
    --shelf-cols: 1.35fr 1fr 1fr;
  }

  .pub {
    grid-template-columns: var(--shelf-cols);
    column-gap: var(--shelf-gap);
  }

  .pub__meta {
    display: contents;
  }

  .pub .when {
    grid-row: 1;
    grid-column: 1;
    justify-self: start;
  }

  .pub__main {
    grid-row: 1;
    grid-column: 1 / 3;
    margin-left: calc(var(--col1) + var(--col-gap));
  }

  .pub .tag,
  .pub .arrow {
    grid-row: 1;
    grid-column: 3;
  }

  .pub .tag {
    justify-self: start;
  }
}

/* Tablet: link grid becomes a bar of four, flagship spans the shelf as a split card. */

@media (min-width: 721px) and (max-width: 960px) {
  .plate__mascot {
    width: clamp(104px, 15.6vw, 120px);
    height: auto;
    aspect-ratio: 297 / 208;
  }

  /* The gap between the halves already stands in for most of the right padding. */

  .card--dark .card__plate {
    padding-right: calc(20px - var(--shelf-gap));
  }
}

@media (max-width: 960px) {
  :root {
    --gutter: 24px;
    --shelf-gap: 16px;
  }

  .mast {
    grid-template-columns: minmax(0, 1fr);
  }

  .mast__intro {
    grid-column: auto;
  }

  .links {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .links__cell:nth-child(n + 3) {
    border-top: 0;
  }

  .links__cell:nth-child(n + 2) {
    border-left: 1px solid var(--line);
  }

  .shelf {
    grid-template-rows: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--shelf-gap);
  }

  .card {
    grid-row: auto;
    grid-template-rows: auto 1fr;
  }

  /* The flagship's two halves use the shelf's own columns and gap, so its divider sits on
     the left edge of the card below it. */

  .card--dark {
    grid-template-rows: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--shelf-gap);
    grid-column: 1 / -1;
  }

  .card--dark .card__plate {
    padding-bottom: 20px;
    border-bottom: 0;
  }

  .card--dark .card__body {
    border-left: 1px solid var(--dark-line);
  }

  .exp {
    grid-template-columns: var(--col1) minmax(0, 1fr);
  }

  .exp__sum {
    grid-column: 2;
  }
}

/* Tablet tables: a tighter gap gives the titles room to stay on one line, and the date
   cell spans both rows so the key under the first bar does not push its summary down. */

@media (min-width: 601px) and (max-width: 960px) {
  .ledger {
    --col-gap: 16px;
  }

  .pub {
    grid-template-columns: var(--col1) minmax(0, 1fr) 16px;
  }

  .exp__when {
    grid-row: 1 / span 2;
  }

  .exp__what {
    grid-row: 1;
    grid-column: 2;
  }

  .exp__sum {
    grid-row: 2;
  }
}

/* Narrow tablet and large phone: the flagship's plate needs the full width. */

@media (max-width: 720px) {
  .card--dark {
    grid-template-rows: auto auto;
    grid-template-columns: minmax(0, 1fr);
  }

  .card--dark .card__plate {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--dark-line);
  }

  .card--dark .card__body {
    border-left: 0;
  }
}

/* Between phone and tablet the stacked flagship is wide, so the mascot stands next to the
   figure instead of at the far edge. */

@media (min-width: 601px) and (max-width: 720px) {
  .card__plate {
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 24px;
  }

  .plate__mascot {
    justify-self: start;
    width: 104px;
    height: 73px;
  }
}

/* Phone */

@media (max-width: 600px) {
  :root {
    --gutter: 20px;
  }

  .mast {
    padding: 36px 0 28px;
  }

  .links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .links__cell:nth-child(n + 2) {
    border-left: 0;
  }

  .links__cell:nth-child(2n) {
    border-left: 1px solid var(--line);
  }

  .links__cell:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .shelf {
    grid-template-columns: minmax(0, 1fr);
  }

  .pub {
    grid-template-columns: minmax(0, 1fr) 20px;
    gap: 6px 12px;
  }

  .pub__meta {
    flex-direction: row;
    gap: 8px;
    align-items: center;
  }

  .pub__main {
    grid-row: 2;
    grid-column: 1 / -1;
  }

  .exp {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .exp__when {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
  }

  .spark-wrap {
    position: relative;
    margin-top: 10px;
  }

  .spark-key {
    position: absolute;
    top: 8px;
    right: 0;
    left: 0;
  }

  .card__text .nb {
    white-space: normal;
  }

  .exp__sum {
    grid-column: 1;
  }
}

/* On the narrowest phones the lede is a pixel smaller, so its first sentence still fits on two
   lines with the place name whole. */

@media (max-width: 340px) {
  .lede {
    font-size: 1.0625rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .arrow,
  .card,
  .links__cell {
    transition: none;
  }

  .card:hover .arrow,
  .pub:hover .arrow {
    transform: none;
  }
}
