:root {
  color-scheme: light dark;
  interpolate-size: allow-keywords;
  --bg: light-dark(#fff, #000);
  --fg: light-dark(#000, #fff);
  --muted: light-dark(#666, #999);
  --line: light-dark(#e4e4e4, #262626);
  --panel: light-dark(#f4f4f4, #141414);
  --glass: light-dark(rgb(255 255 255 / .6), rgb(255 255 255 / .05));
  --glass-edge: light-dark(rgb(255 255 255 / .95), rgb(255 255 255 / .12));
  --glass-shine: light-dark(#fff, rgb(255 255 255 / .16));
  --glass-shadow: light-dark(rgb(0 0 0 / .14), rgb(0 0 0 / .6));
  --blob: light-dark(rgb(0 0 0 / .13), rgb(255 255 255 / .13));
  --display: "Gloock", Georgia, serif;
  --text: "IBM Plex Sans", system-ui, sans-serif;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
}

* { box-sizing: border-box; margin: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 1.5rem; }
html:has(.hero) { scroll-padding-top: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 400 1.0625rem/1.6 var(--text);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .home { font-family: var(--display); font-weight: 400; }
img, video { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }
ul { padding-left: 1.1rem; }
li + li { margin-top: .4rem; }
li::marker { color: var(--muted); }

.wrap { position: relative; max-width: 62rem; margin-inline: auto; padding-inline: clamp(1rem, 4vw, 2rem); }

.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 1rem; padding-block: 1.5rem; }
.top a { text-decoration: none; }
.top nav a:hover { color: var(--fg); }
.home { flex: none; font-size: 1.25rem; }
.top nav { display: flex; flex-wrap: wrap; gap: clamp(.65rem, 3vw, 1.75rem); color: var(--muted); font-size: clamp(.84rem, 2.4vw, .95rem); }

/* Soft grey shapes behind everything, so the glass has something to blur. */
body:has(.hero)::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(38rem 38rem at 12% 22%, var(--blob), transparent 70%),
    radial-gradient(34rem 34rem at 88% 62%, var(--blob), transparent 70%),
    radial-gradient(28rem 28rem at 40% 105%, var(--blob), transparent 70%);
}

.card {
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 1.25rem;
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  box-shadow: inset 0 1px 0 var(--glass-shine), 0 1px 2px var(--glass-shadow), 0 18px 40px -22px var(--glass-shadow);
}

/* Every homepage section fills the screen. Taller ones (open rows) just grow. */
.hero, .section { display: flex; flex-direction: column; justify-content: center; min-height: 100svh; }
.hero { padding-block: 7rem; }

/* The opening letter, on a sheet of lined paper. Every line height and gap is a multiple
   of --row, so the writing sits on the rules all the way down. */
.letter { width: 100%; max-width: 34rem; margin-inline: auto; }
.paper {
  --row: 1.75rem;
  padding: calc(var(--row) * 2) clamp(1.25rem, 6vw, 3rem) calc(var(--row) * 2);
  background: repeating-linear-gradient(transparent 0 calc(var(--row) - 1px), var(--line) calc(var(--row) - 1px) var(--row)), var(--panel);
  border-radius: .25rem;
  rotate: -.6deg;
  box-shadow: 0 1px 2px var(--glass-shadow), 0 24px 50px -28px var(--glass-shadow);
}
.letter h1 { display: flex; align-items: center; gap: .2em; font-size: clamp(2rem, 8vw, 2.6rem); line-height: calc(var(--row) * 2); letter-spacing: -.02em; }
.letter p { font-size: 1rem; line-height: var(--row); }
.letter p + p { margin-top: var(--row); }
/* The real signature, black ink on transparent. Flipped to white ink on the dark paper. */
.sign img { display: block; width: 7rem; height: calc(var(--row) * 3); object-fit: contain; object-position: left center; }
@media (prefers-color-scheme: dark) { .sign img { filter: invert(1); } }

/* Portrait sitting in the headline, slightly tilted like a photo stuck on the page. */
.me { display: inline-block; width: .95em; height: .95em; margin-left: .1em; vertical-align: -.14em; object-fit: cover; border: .05em solid #fff; border-radius: .16em; rotate: 5deg; box-shadow: 0 .03em .06em rgb(0 0 0 / .18), 0 .2em .4em -.12em rgb(0 0 0 / .35); }

.section { padding-block: clamp(4.5rem, 10vh, 7rem); }
.section > h2 { margin-bottom: clamp(2rem, 6vh, 3.5rem); text-align: center; font-size: clamp(2.5rem, 7vw, 4.5rem); line-height: 1; letter-spacing: -.02em; }

/* Things appear one after another as they arrive: blur to sharp, a small rise,
   and text wipes in from the top. The script at the end of index.html adds .in. */
@media (prefers-reduced-motion: no-preference) {
  .js .r { opacity: 0; filter: blur(12px); translate: 0 1.5rem; transition: opacity .9s var(--ease), filter .9s var(--ease), translate .9s var(--ease), scale .9s var(--ease), clip-path 1.1s var(--ease); }
  .js .pop { scale: .2; }
  .js .wipe { clip-path: inset(0 0 100% 0); }
  .js .r.in { opacity: 1; filter: none; translate: 0; scale: 1; }
  .js .wipe.in { clip-path: inset(-1em); }

  details::details-content { block-size: 0; opacity: 0; overflow: clip; transition: block-size .6s var(--ease), opacity .6s var(--ease), content-visibility .6s allow-discrete; }
  details[open]::details-content { block-size: auto; opacity: 1; }
  /* A card closed by opening another one shuts at once, so the page does not slide (see the script). */
  details.shut::details-content { transition: none; }
}

/* Work and project rows: click to open. */
summary { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .1rem 1.5rem; align-items: baseline; padding: clamp(.8rem, 1.9vh, 1.2rem) 3rem clamp(.8rem, 1.9vh, 1.2rem) 1.35rem; cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; position: absolute; top: clamp(.6rem, 1.7vh, 1rem); right: 1.25rem; color: var(--muted); font-size: 1.5rem; }
details[open] > summary::after { content: "–"; }
summary h3 { font-size: clamp(1.35rem, 2.6vw, 1.6rem); letter-spacing: -.01em; line-height: 1.3; }
summary:hover .lede, summary:hover::after { color: var(--fg); }
.lede { grid-column: 1 / -1; color: var(--muted); }
.more { padding: 0 1.35rem 1.5rem; }
.more p + p { margin-top: .75rem; }
time, .meta { color: var(--muted); font-size: .95rem; font-variant-numeric: tabular-nums; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; margin-block: 1.75rem; padding-block: 1.25rem; border-block: 1px solid var(--line); }
@media (min-width: 36rem) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stats dd { margin: 0; font-family: var(--display); font-size: 2rem; line-height: 1.1; letter-spacing: -.01em; }
.stats dt { order: 1; margin-top: .2rem; color: var(--muted); font-size: .875rem; line-height: 1.3; }
.stats div { display: flex; flex-direction: column; }
.more figure { margin-top: 1.75rem; }
.more figure video { width: 100%; border-radius: .75rem; }
.more figure img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: 50% 45%; border-radius: .75rem; }
/* A row of smaller photos: one wide, one tall, the same height. */
.more figure.row { display: grid; grid-template-columns: 2fr 1fr; gap: .5rem; max-width: 32rem; }
.more figure.row img { aspect-ratio: 2 / 3; border-radius: .5rem; }
.more figure.row img:first-child { aspect-ratio: 4 / 3; object-position: 50% 50%; }
.more figure.row figcaption { grid-column: 1 / -1; }
/* In the narrow cards the two photos split the width evenly. */
.project .more figure.row { grid-template-columns: 1fr 1fr; }
.project .more figure.row img { aspect-ratio: 3 / 4; }
/* One tall screenshot, kept narrow so it does not fill the card. */
.more figure.small { max-width: 15rem; }
.more figure.small img { aspect-ratio: auto; border-radius: .5rem; }
figcaption { margin-top: .5rem; color: var(--muted); font-size: .875rem; }

/* A single photo in place of the placeholder. */
.tile { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; object-position: 50% 40%; border-radius: .75rem; }

/* Project screenshots: phones (pictures or looping recordings) rising out of a tile. They fan out when the card is hovered or pressed. */
.shots { position: relative; aspect-ratio: 4 / 3; overflow: hidden; border-radius: .75rem; background: var(--line); container-type: inline-size; }
.shots > * { position: absolute; top: 13%; left: 50%; width: 38%; transform: translateX(-50%); }
.shots > :first-child { transform: translateX(-104%) rotate(-7deg); }
.shots > :nth-child(2) { top: 8%; z-index: 1; }
.shots > :last-child { transform: translateX(4%) rotate(7deg); }
.shots > :only-child { top: 8%; transform: translateX(-50%) rotate(-4deg); }
.shots :is(img, video) { display: block; border-radius: 3.5cqw; box-shadow: 0 1cqw 5cqw rgb(0 0 0 / .28); }
.shots picture img { width: 100%; }
/* One laptop-width screenshot instead of three phones: it tilts, then straightens and rises on hover. */
.shots.wide > img { top: 30%; width: 94%; border-radius: 1.5cqw; transform: translateX(-50%) rotate(-3deg); }
/* Two post screenshots overlapping like cards on a desk. */
.shots.pair > * { top: 10%; width: 64%; border-radius: 1.5cqw; }
.shots.pair > :first-child { transform: translateX(-78%) rotate(-5deg); }
.shots.pair > :last-child { top: 32%; transform: translateX(-22%) rotate(4deg); }
@media (prefers-reduced-motion: no-preference) {
  .shots > * { transition: transform .5s var(--spring); }
  :is(.project, .big):not([open]):is(:hover, .pressed, .lit) .shots > :first-child { transform: translateX(-122%) rotate(-12deg); }
  :is(.project, .big):not([open]):is(:hover, .pressed, .lit) .shots > :nth-child(2) { transform: translate(-50%, -4%); }
  :is(.project, .big):not([open]):is(:hover, .pressed, .lit) .shots > :last-child { transform: translateX(22%) rotate(12deg); }
  :is(.project, .big):not([open]):is(:hover, .pressed, .lit) .shots > :only-child { transform: translate(-50%, -4%); }
  .project:not([open]):is(:hover, .pressed) .shots.pair > :first-child { transform: translateX(-86%) translateY(-3%) rotate(-8deg); }
  .project:not([open]):is(:hover, .pressed) .shots.pair > :last-child { transform: translateX(-14%) translateY(3%) rotate(7deg); }
  .project:not([open]):is(:hover, .pressed) .shots.wide > img { transform: translate(-50%, -8%); }
}

.cards { display: grid; gap: 2.5rem 1.5rem; }
@media (min-width: 52rem) { .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; } }
.project summary, .big summary { display: block; padding: .6rem .6rem 1rem; }
.project summary h3, .big summary h3 { margin: .9rem .5rem 0; }
.project summary::after, .big summary::after { top: auto; bottom: .8rem; right: 1.1rem; }
.project .lede, .big .lede { display: block; padding-inline: .5rem 2rem; }
.project .more, .big .more { padding: 0 1.1rem 1.25rem; }
/* The two big cards run the full width, picture left and name right. */
.big { grid-column: 1 / -1; }
.big .more { max-width: 46rem; margin-inline: auto; }
@media (min-width: 52rem) {
  .big summary { display: grid; grid-template-columns: 3fr 2fr; gap: 0 1rem; align-items: end; padding: .75rem .75rem 1.25rem; }
  .big .shots { aspect-ratio: 16 / 9; }
  .big .shots > * { width: 24%; }
  .big summary h3 { font-size: 2.25rem; }
}

.posts { padding: .4rem 1.35rem; list-style: none; }
.posts li { margin: 0; }
.posts li + li { border-top: 1px solid var(--line); }
.posts a { display: flex; justify-content: space-between; gap: .1rem 1.5rem; padding-block: clamp(.75rem, 1.6vh, 1rem); text-decoration: none; }
.posts a:hover time { color: var(--fg); }
.posts time { flex: none; }
@media (max-width: 34rem) { .posts a { flex-direction: column; } }

.section > div:not(.cards), .posts { width: 100%; max-width: 46rem; margin-inline: auto; }
/* Polaroids clipped to the edge of the letter. They hang off the paper and the writing wraps round them. */
.snap { display: block; width: clamp(7rem, 26vw, 9.5rem); aspect-ratio: 1; padding: .4rem .4rem 1.75rem; object-fit: cover; background: #fff; border-radius: .2rem; box-shadow: 0 1px 2px rgb(0 0 0 / .15), 0 14px 30px -14px rgb(0 0 0 / .5); }
.snap.right { float: right; margin: .25rem clamp(-5rem, 1rem - 10vw, -1.25rem) .75rem 1rem; rotate: 4deg; }
.snap.left { float: left; margin: .25rem 1rem .75rem clamp(-5rem, 1rem - 10vw, -1.25rem); rotate: -3deg; object-position: 40% 50%; }

/* Footer: just icons. Each one opens up to show the handle, on hover, keyboard focus or first tap. */
.contact { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; padding-block: 2rem 5rem; }
.contact a { display: inline-flex; align-items: center; padding: .75rem; line-height: 1.25rem; border: 1px solid var(--glass-edge); border-radius: 99px; background: var(--glass); box-shadow: inset 0 1px 0 var(--glass-shine), 0 2px 4px var(--glass-shadow); text-decoration: none; }
.contact svg { flex: none; width: 1.25rem; height: 1.25rem; fill: currentColor; }
.handle { display: grid; grid-template-columns: 0fr; }
.handle span { min-width: 0; overflow: hidden; white-space: nowrap; }
.contact a:is(:focus-visible, .open) { background: var(--fg); color: var(--bg); }
.contact a:is(:focus-visible, .open) .handle { grid-template-columns: 1fr; margin-left: .5rem; }
@media (hover: hover) {
  .contact a:hover { background: var(--fg); color: var(--bg); }
  .contact a:hover .handle { grid-template-columns: 1fr; margin-left: .5rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .handle { transition: grid-template-columns .45s var(--spring), margin-left .45s var(--spring); }
}

/* Every kind of thing reacts differently. Only on devices with a real cursor. */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  /* A shape that drifts after the cursor, behind the glass. */
  body:has(.hero)::after { content: ""; position: fixed; top: -16rem; left: -16rem; z-index: -1; width: 32rem; height: 32rem; border-radius: 50%; background: radial-gradient(closest-side, var(--blob), transparent); translate: var(--cursor-x, -50rem) var(--cursor-y, -50rem); transition: translate .9s var(--ease); pointer-events: none; }

  /* Menu: a line draws in under the word. */
  .top nav a { background: linear-gradient(currentColor, currentColor) left bottom / 0 1px no-repeat; transition: background-size .35s var(--ease), color .2s; }
  .top nav a:hover { background-size: 100% 1px; }

  /* Portrait: springs up and flips its tilt. */
  .me { transition: rotate .5s var(--spring), scale .5s var(--spring); cursor: grab; }
  .me:hover { rotate: -7deg; scale: 1.3; }

  /* Work: black floods in from the left and the text flips to white. */
  .big { background-image: linear-gradient(var(--fg), var(--fg)); background-repeat: no-repeat; background-size: 0 100%; transition: background-size .55s var(--ease), scale .2s var(--ease); }
  .big summary, .big summary * { transition: color .25s; }
  .big summary::after { transition: color .25s, rotate .45s var(--spring); }
  .big:not([open]):hover { background-size: 100% 100%; }
  .big:not([open]):hover summary, .big:not([open]):hover .lede, .big:not([open]):hover time, .big:not([open]):hover summary::after { color: var(--bg); }
  .big:hover summary::after { rotate: 90deg; }
  .big:active { scale: .99; }

  /* Projects: the card tilts towards the cursor and a glare follows it. */
  .project { position: relative; transform: perspective(50rem) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)); transition: transform .3s var(--ease), box-shadow .3s; }
  .project:not([open]):hover { z-index: 1; box-shadow: inset 0 1px 0 var(--glass-shine), 0 2px 4px var(--glass-shadow), 0 32px 48px -20px var(--glass-shadow); }
  .project::before { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit; background: radial-gradient(14rem circle at var(--glare-x, 50%) var(--glare-y, 50%), light-dark(rgb(255 255 255 / .5), rgb(255 255 255 / .16)), transparent); opacity: 0; transition: opacity .3s; pointer-events: none; }
  .project:not([open]):hover::before { opacity: 1; }
  .tile { transition: scale .5s var(--spring); }
  .project:not([open]):hover .tile { scale: .97; }

  /* Musings: the row you're on stays lit, the rest fade, and an arrow slides in. */
  .posts a { position: relative; transition: padding-left .35s var(--ease), opacity .25s; }
  .posts a::before { content: "→"; position: absolute; left: 0; opacity: 0; translate: -.75rem 0; transition: opacity .25s, translate .35s var(--ease); }
  .posts a:hover { padding-left: 1.6rem; }
  .posts a:hover::before { opacity: 1; translate: 0; }
  .posts:hover li:not(:hover) a { opacity: .35; }

  /* Speaking photo: black and white until you hover, then colour comes in. */
  .snap { filter: grayscale(1); transition: filter .6s var(--ease), scale .6s var(--ease), rotate .6s var(--spring); }
  .snap:hover { filter: none; scale: 1.08; rotate: 0deg; }

  /* Footer icons: lift up, press down when clicked. */
  .contact a { transition: translate .3s var(--spring), background .2s, color .2s; }
  .contact a:hover { translate: 0 -3px; }
  .contact a:active { translate: 0 1px; }
}

/* Phones have no cursor, so scrolling and tapping do the same jobs. */
@media (hover: none) and (prefers-reduced-motion: no-preference) {
  /* A soft shape drifts across the screen as you scroll, behind the glass. */
  body:has(.hero)::after { content: ""; position: fixed; top: -12rem; left: -12rem; z-index: -1; width: 24rem; height: 24rem; border-radius: 50%; background: radial-gradient(closest-side, var(--blob), transparent); animation: drift linear both; animation-timeline: scroll(root); pointer-events: none; }

  /* Work: black floods in as a card reaches the middle of the screen. */
  .big { background-image: linear-gradient(var(--fg), var(--fg)); background-repeat: no-repeat; background-size: 0 100%; transition: background-size .55s var(--ease), scale .2s var(--ease); }
  .big summary, .big summary * { transition: color .25s; }
  .big summary::after { transition: color .25s, rotate .45s var(--spring); }
  .big.lit:not([open]) { background-size: 100% 100%; }
  .big.lit:not([open]) summary, .big.lit:not([open]) .lede, .big.lit:not([open]) time, .big.lit:not([open]) summary::after { color: var(--bg); }
  .big.lit summary::after { rotate: 90deg; }
  .big:active { scale: .98; }

  /* Projects: cards sway as they pass through the screen, and tilt towards your finger. */
  .cards { perspective: 50rem; }
  .project { position: relative; transform: rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)); transition: transform .3s var(--ease); }
  @supports (animation-timeline: view()) {
    .project { animation: sway linear both; animation-timeline: view(); }
  }
  .project::before { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit; background: radial-gradient(12rem circle at var(--glare-x, 50%) var(--glare-y, 50%), light-dark(rgb(255 255 255 / .5), rgb(255 255 255 / .16)), transparent); opacity: 0; transition: opacity .3s; pointer-events: none; }
  .project.pressed::before { opacity: 1; }

  /* Musings: the row in the middle of the screen stays sharp, with an arrow. */
  .posts a { position: relative; transition: padding-left .35s var(--ease), opacity .25s; }
  .posts a::before { content: "→"; position: absolute; left: 0; opacity: 0; translate: -.75rem 0; transition: opacity .25s, translate .35s var(--ease); }
  .posts li.lit a { padding-left: 1.6rem; }
  .posts li.lit a::before { opacity: 1; translate: 0; }
  .posts:has(.lit) li:not(.lit) a { opacity: .35; }

  /* Polaroids: colour comes in as they reach the middle of the screen. */
  .snap { filter: grayscale(1); transition: filter .6s var(--ease); }
  .snap.lit { filter: none; }

  /* Portrait: tap it and it bounces. */
  .me.boing { animation: boing .7s var(--ease); }

  /* Footer icons: press down under your finger. */
  .contact a { transition: translate .3s var(--spring), background .15s, color .15s; }
  .contact a:active { translate: 0 2px; }
}
@keyframes drift { from { translate: 0 10vh; } to { translate: 100vw 90vh; } }
@keyframes sway { from { rotate: x 16deg; } 50% { rotate: x 0deg; } to { rotate: x -16deg; } }
@keyframes boing { 30% { scale: 1.45; rotate: -14deg; } 55% { scale: .9; rotate: 12deg; } 78% { scale: 1.1; rotate: 2deg; } }

/* Musings pages */
.post { max-width: 39rem; margin-inline: auto; padding-block: clamp(2.5rem, 8vw, 5rem); }
.post h1 { font-size: clamp(2.3rem, 6vw, 3.5rem); line-height: 1.08; letter-spacing: -.02em; }
.post > time { display: block; margin-top: .75rem; }
.body { margin-top: 2.25rem; font-size: 1.125rem; line-height: 1.7; }
.body > * + * { margin-top: 1.15em; }
.body h2 { margin-top: 2em; font-size: 1.6rem; line-height: 1.25; letter-spacing: -.01em; }
.body ul, .body ol { padding-left: 1.3em; }
.body hr { border: 0; border-top: 1px solid var(--line); margin-block: 2em; }
sup { line-height: 0; font-family: var(--text); font-size: .7em; }
.notes { margin-top: 3rem; padding: 1.5rem 0 0 1.2rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 1rem; line-height: 1.5; }
.back { margin-top: 3rem; }
