/* ---------- Fonts ---------- */
@font-face { font-family: "Heading"; src: url("fonts/heading.woff") format("woff"); font-display: swap; }
@font-face { font-family: "Body"; src: url("fonts/body-regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Body"; src: url("fonts/body-bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

/* ---------- Tokens ---------- */
:root {
  --bg: #1b1a1c;
  --fg: #f2efec;
  --muted: rgba(242, 239, 236, 0.62); /* the one secondary text colour */
  --faint: rgba(242, 239, 236, 0.24);
  --line: var(--edge); /* every line on the page: dividers, card borders, menu */
  --edge: rgba(242, 239, 236, 0.28); /* the one 1px line used everywhere: dividers, card borders, menu */
  --glass: rgba(30, 28, 31, 0.55);
  --rose: #c9828f;
  --steel: #8ea6b8;

  --display: "Heading", Georgia, serif;
  --body: "Body", "Helvetica Neue", Arial, sans-serif;

  --col: 520px;
  /* Content sits in a centred ~920px frame, like joshglucas.com, with a minimum side margin on small screens */
  --frame: 920px;
  --gutter: max(clamp(20px, 6vw, 64px), calc((100vw - var(--frame)) / 2));
  --peek-gap: 56px;
  --ease: cubic-bezier(0.2, 0.7, 0.1, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  /* Bold, tightly set body type, as in the reference */
  font: 700 16px/1.4 var(--body);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip; /* (not "hidden", which would stop the sticky nav from sticking) */
}
p { margin: 0; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
.muted { color: var(--muted); }

/* Small spaced caps (dates, labels) — regular weight, as in the reference */
.date, .row__date, .label, .topbar__meta {
  font-weight: 400;
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Background: one grainy diagonal band ---------- */
.bg { position: fixed; inset: 0; z-index: -2; overflow: hidden; pointer-events: none; }
.band {
  position: absolute;
  left: 50%; top: 55%;
  width: 180vmax; height: 30vmax;
  margin: -15vmax 0 0 -90vmax;
  background: linear-gradient(90deg,
    transparent 8%,
    rgba(166, 95, 110, 0.55) 30%,
    rgba(109, 133, 151, 0.45) 50%,
    rgba(166, 95, 110, 0.5) 66%,
    rgba(109, 133, 151, 0.35) 82%,
    transparent 94%);
  filter: blur(70px);
  transform: rotate(-32deg);
  opacity: 0;
  animation: band-in 2.6s var(--ease) 0.2s forwards, band-drift 30s ease-in-out 2.8s infinite alternate;
}
.band--soft {
  top: 20%;
  height: 18vmax;
  background: linear-gradient(90deg, transparent 20%, rgba(109, 133, 151, 0.28) 50%, rgba(166, 95, 110, 0.22) 70%, transparent 90%);
  animation: band-in-soft 3s var(--ease) 0.6s forwards;
}
@keyframes band-in { from { opacity: 0; transform: rotate(-32deg) translateY(6vmax); } to { opacity: 1; transform: rotate(-32deg); } }
@keyframes band-in-soft { to { opacity: 1; } }
@keyframes band-drift { to { transform: rotate(-29deg) translate(4vmax, -3vmax); } }

/* WebGL light (bg.js) replaces the CSS band when available */
.bg-canvas {
  position: fixed;
  will-change: transform; /* its own layer, so scrolling never repaints it */
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  animation: band-in-soft 2.4s var(--ease) 0.1s forwards;
}
.has-bg-gl .bg { display: none; }

.grain {
  position: fixed; inset: 0;
  will-change: transform;
  z-index: -1; pointer-events: none;
  opacity: 0.2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.95' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.5 -0.25'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  /* static: only the light moves */
}
@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-2%, 1%); }
  40% { transform: translate(1%, -2%); }
  60% { transform: translate(-1%, -1%); }
  80% { transform: translate(2%, 2%); }
}

/* ---------- Load-in ---------- */
/* A soft, continuous fade with a whisper of blur — no jumps, no hard stagger */
.reveal {
  opacity: 0;
  filter: blur(3px);
  transition: opacity 1.5s cubic-bezier(0.25, 0.1, 0.25, 1), filter 1.5s cubic-bezier(0.25, 0.1, 0.25, 1);
  transition-delay: var(--d, 0s);
}
.reveal.is-in { opacity: 1; filter: none; }
.reveal.is-settled { transition-duration: 0.4s; transition-delay: 0s; transition-timing-function: var(--ease); }

/* ---------- Shared 1px white-border surface (from the reference) ---------- */
/* Border only, no fill, for the time tooltip */
.tip { border: 1px solid var(--edge); background: none; }

.surface, .xp__card {
  border: 1px solid var(--edge);
  background: rgba(30, 28, 31, 0.35);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
}

/* ---------- Header ---------- */
.topbar {
  --top-pad: clamp(28px, 5vw, 64px);
  /* Sticky: once scrolled, the bar settles 16px from the top of the screen */
  position: sticky;
  top: calc(16px - var(--top-pad));
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  padding: var(--top-pad) var(--gutter) 0;
  pointer-events: none; /* only the time and nav themselves are clickable */
}
.topbar > * { pointer-events: auto; }
/* When stuck, the time steps away so only the nav floats over the page */
.topbar__meta { transition: opacity 0.4s var(--ease), filter 0.4s var(--ease); }
.topbar.is-stuck .topbar__meta { opacity: 0; filter: blur(3px); pointer-events: none; }
.topbar__meta { display: flex; align-items: center; gap: 12px; color: var(--fg); } /* the time is solid white */

/* Time, with a tooltip saying where Mel is and how far ahead/behind the visitor */
.clock {
  all: unset;
  white-space: nowrap;
  position: relative;
  cursor: default;
  /* a text underline (not a border), so the time centres exactly with the nav text */
  text-decoration: underline dotted var(--faint);
  text-underline-offset: 4px;
}
.clock:focus-visible { outline: 1px solid var(--fg); outline-offset: 4px; }
.tip {
  position: absolute;
  top: calc(100% + 12px);
  left: 0; /* time sits top-left now, so the tooltip lines up with its left edge */
  translate: 0 -4px;
  display: grid;
  gap: 8px;
  padding: 14px 18px 15px;
  border-radius: 14px;
  white-space: nowrap;
  text-align: left;
  opacity: 0;
  filter: blur(6px);
  pointer-events: none;
  transition: opacity 0.25s var(--ease), filter 0.3s var(--ease), translate 0.3s var(--ease);
}
.tip__place { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.tip__place svg { flex: none; margin-top: -1px; }
.tip__diff {
  font: 700 14px/1.2 var(--body);
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--fg);
}
.clock:hover .tip, .clock:focus-visible .tip, .clock.is-open .tip { opacity: 1; filter: none; translate: none; }

/* ---------- Layout ---------- */
.page { padding: 0 var(--gutter); }
.col { width: 100%; max-width: var(--col); }

.hero { padding: clamp(96px, 20vh, 200px) 0 clamp(16px, 3vh, 32px); }
/* While a preview is showing, everything except the hovered list (and the preview) steps back */
.hero, .block, .footer { transition: opacity 0.4s var(--ease), filter 0.4s var(--ease); }
.is-peeking .topbar,
.is-peeking .hero,
.is-peeking .footer,
.is-peeking .block:not(.is-focus) { opacity: 0.1; filter: blur(2px); }

.hero__sub {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 28px;
  font-weight: 400;
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg);
}

/* A small white beacon with the background's rose-to-blue light breathing around it */
.beacon {
  position: relative;
  flex: none;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #fff;
}
.beacon::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  z-index: -1;
}
.beacon::before {
  background: conic-gradient(from 0deg, var(--rose), var(--steel), var(--rose));
  filter: blur(3px);
  opacity: 0.5;
  animation: beacon-spin 6s linear infinite, beacon-breathe 1.4s var(--ease) infinite alternate;
}
@keyframes beacon-spin { to { rotate: 360deg; } }
@keyframes beacon-breathe { from { scale: 0.6; opacity: 0.2; } to { scale: 1.2; opacity: 0.6; } }


.hero__title {
  margin: 0;
  max-width: 26ch;
  font: 400 clamp(30px, 3.4vw, 49px)/1.08 var(--display);
  letter-spacing: -0.005em;
  text-wrap: balance;
}

.block { --block-top: clamp(104px, 16vh, 168px); padding-top: var(--block-top); }
.label { margin: 0 0 20px; color: var(--fg); }

.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.work__list { border-top: none; }
.work__list .row:last-child { border-bottom: none; }

/* ---------- Work rows ---------- */
.row { border-bottom: 1px solid var(--line); }
.row__head {
  all: unset;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 104px 1fr auto 14px;
  align-items: baseline;
  gap: 12px;
  width: 100%;
  padding: 20px 0;
  cursor: pointer;
  transition: color 0.3s var(--ease);
}
.row__meta { color: var(--muted); transition: color 0.3s var(--ease); }
.work__list.has-active .row__head,
.work__list.has-active .row__meta { color: var(--faint); }
.work__list.has-active .row.is-active .row__head { color: var(--fg); }
.work__list.has-active .row.is-active .row__meta { color: var(--muted); }

.row__toggle { position: relative; width: 9px; height: 9px; justify-self: end; align-self: center; color: var(--muted); }
.row__toggle::before, .row__toggle::after {
  content: ""; position: absolute; left: 0; top: 50%;
  width: 9px; height: 1.5px; background: currentColor;
  transition: rotate 0.35s var(--ease);
}
.row__toggle::after { rotate: 90deg; }
.row.is-open .row__toggle::after { rotate: 0deg; }

.row__panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.5s var(--ease); }
.row.is-open .row__panel { grid-template-rows: 1fr; }
.row__panel-inner { min-height: 0; overflow: hidden; }
.row__media { position: relative; margin-top: 4px; }
.row__media > img, .row__media > video { display: block; width: 100%; height: auto; border-radius: 8px; }
.row__media--pair { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.row__media--pair > video { aspect-ratio: 416 / 900; object-fit: cover; background: transparent; }
.row__media > img, .row__media > video { opacity: 0; filter: blur(12px); transition: opacity 0.6s var(--ease), filter 0.8s var(--ease); }
.row.is-open .row__media > img, .row.is-open .row__media > video { opacity: 1; filter: none; }
.row__links { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin: -8px 0 24px; }
.row__desc { margin: 16px 0 24px; font-size: 14px; line-height: 1.45; color: var(--muted); } /* faded white, like the desktop preview */

.media-canvas { display: block; width: 100%; height: 100%; }

/* ---------- Hover preview (fixed in the open space to the right) ---------- */
.peek {
  display: none;
  position: fixed;
  top: 50%; /* set in JS to line up with the hovered list */
  /* Sits right of the column and may extend into the side margin, so the image can be larger */
  left: calc(var(--gutter) + var(--col) + var(--peek-gap));
  width: min(520px, calc(100vw - var(--gutter) - var(--col) - var(--peek-gap) - 40px));
  margin: 0;
  pointer-events: none;
  opacity: 0;
  filter: blur(3px);
  transition: opacity 0.75s var(--ease), filter 0.75s var(--ease); /* a plain fade, like the rest of the page */
}
.peek.is-visible { pointer-events: auto; }
.peek.is-shown { opacity: 1; filter: none; }
.peek__frame { position: relative; width: fit-content; max-width: 100%; margin-inline: auto; } /* media centred in the preview */
.peek__media { display: flex; justify-content: center; gap: 24px; align-items: flex-start; } /* one slot per image/video, sized in JS */
.peek__slot { display: block; flex: none; height: auto; border-radius: 8px; object-fit: cover; }
.peek__links { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 16px; }
.peek__links:empty { display: none; }
.peek__desc {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
  transition: opacity 0.35s var(--ease), filter 0.45s var(--ease);
}
.peek__desc:empty { display: none; }
.peek__title:empty { display: none; }
.peek__cap:has(.peek__title:empty):has(.peek__desc:empty) { display: none; }
.peek__cap { margin-top: 28px; transition: opacity 0.35s var(--ease), filter 0.45s var(--ease); }
.peek__cap.is-swapping { opacity: 0; filter: blur(6px); }
.peek__title, .row__headline {
  margin: 0;
  font: 700 18px/1.25 var(--body);   /* type scale: 11 labels · 14 small · 16 base · 18 headings · 20 lead · display */
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.row__headline { margin-top: 28px; }
.row__headline + .row__desc { margin-top: 10px; }


/* About: portrait shows inline on touch / narrow screens */
/* Portrait: fades in while About is mid-screen */
.about__media {
  position: relative;
  width: min(220px, 60vw);
  aspect-ratio: 752 / 920;
  border-radius: 8px;
  overflow: hidden;
  margin: 4px 0 24px;
}
.about__media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.about__media { opacity: 0; filter: blur(3px); transition: opacity 1.8s var(--ease), filter 1.8s var(--ease); }
.about__media.is-shown { opacity: 1; filter: none; }
/* About is the lead text: larger, with roomier leading */
.prose p { font-size: 20px; line-height: 1.35; letter-spacing: -0.015em; text-wrap: pretty; }
.prose p + p { margin-top: 20px; }

@media (hover: hover) and (min-width: 1000px) {
  .peek { display: block; }
  .row__panel, .row__toggle { display: none; }
  /* Wide screens: portrait in the open space to the right, centred on the whole About text */
  .about {
    display: grid;
    grid-template-columns: var(--col) min(360px, calc(100vw - 2 * var(--gutter) - var(--col) - var(--peek-gap)));
    column-gap: var(--peek-gap);
    align-items: center;
  }
  .about > .label { grid-column: 1 / -1; }
  .about > .prose { grid-column: 1; grid-row: 2; }
  .about__media { grid-column: 2; grid-row: 2; width: 100%; margin: 0; }
  .row__head { grid-template-columns: 104px 1fr auto; cursor: default; }
}

/* ---------- Experience: swipeable carousel ---------- */
.xp__viewport {
  /* Full screen width so cards slide off the edges, starting in line with the column */
  width: 100vw;
  margin-left: calc(-1 * var(--gutter));
  padding: 2px 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-left: var(--gutter);
  scrollbar-width: none;
  cursor: grab;
}
.xp__viewport::-webkit-scrollbar { display: none; }
.xp__viewport:focus-visible { outline: none; }
.xp__viewport.is-moving { scroll-snap-type: none; }
.xp__viewport.is-dragging { cursor: grabbing; user-select: none; }
.xp__track {
  display: flex;
  gap: 16px;
  width: max-content;
  list-style: none;
  margin: 0;
  padding: 0 var(--gutter);
}
.xp__card {
  background: none; /* border only */
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  width: var(--col);
  padding: clamp(22px, 2.4vw, 32px);
  border-radius: 14px;
  scroll-snap-align: start;
}
/* Experience is secondary: smaller text */
.xp__card { font-size: 14px; line-height: 1.45; }
.xp__top { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.xp__role { color: var(--muted); }
.xp__desc { margin-top: 16px; text-wrap: pretty; }

.xp__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  max-width: var(--col);
  margin-top: 18px;
}
.xp__dots { display: flex; gap: 2px; margin-left: -7px; }
.xp__dots button {
  all: unset;
  display: grid;
  place-items: center;
  width: 20px; height: 20px;
  cursor: pointer;
}
.xp__dots button::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 3px;
  background: var(--faint);
  transition: background 0.35s var(--ease), width 0.45s var(--ease);
}
.xp__dots button[aria-current="true"] { width: 32px; }
.xp__dots button[aria-current="true"]::before { background: var(--fg); width: 18px; }
.xp__dots button { transition: width 0.45s var(--ease); }
.xp__dots button:focus-visible::before { outline: 1px solid var(--fg); outline-offset: 3px; }


/* ---------- Footer ---------- */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  padding: clamp(96px, 16vh, 160px) 0 40px;
}
.footer__links { display: flex; gap: 24px; font-size: 14px; }
.footer__links a { color: var(--muted); transition: color 0.25s; }
.footer__links a:hover { color: var(--fg); }

/* Currently reading — a quiet "now playing" unit, right-aligned to the frame.
   By default it just says "Currently reading" (faded); hovering swaps in the title,
   and clicking shows the rest of the shelf. */
.reading { position: relative; display: flex; flex-direction: column; align-items: flex-end; }
.reading[hidden] { display: none; }
/* "Currently reading" and the title share one spot and swap on hover */
.reading__swap { display: grid; justify-items: end; align-items: center; }
.reading__swap > * {
  grid-area: 1 / 1;
  transition: opacity 0.3s var(--ease), filter 0.35s var(--ease), translate 0.35s var(--ease);
}
.reading__default { font-size: 11px; font-weight: 400; line-height: 1.3; color: var(--muted); text-align: right; }
.reading__now .reading__text { opacity: 0; filter: blur(4px); translate: 0 4px; }
.reading:hover .reading__now .reading__text,
.reading:focus-within .reading__now .reading__text,
.reading.is-open .reading__now .reading__text { opacity: 1; filter: none; translate: none; }
.reading:hover .reading__default,
.reading:focus-within .reading__default,
.reading.is-open .reading__default { opacity: 0; filter: blur(4px); translate: 0 -4px; }

.reading__book {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  text-align: right;
}
button.reading__book { all: unset; display: flex; align-items: center; gap: 14px; text-align: right; cursor: pointer; }
button.reading__book:focus-visible { outline: 1px solid var(--fg); outline-offset: 6px; border-radius: 4px; }
.reading__text { display: grid; gap: 2px; }
.reading__title { font-size: 14px; line-height: 1.3; white-space: nowrap; }
.reading__author { font-size: 14px; line-height: 1.3; color: var(--muted); white-space: nowrap; }
.reading__book img {
  flex: none;
  width: 30px; height: 44px;
  object-fit: cover;
  border-radius: 3px;
  outline: 1px solid var(--edge);
  outline-offset: -1px;
  transition: rotate 0.35s var(--ease), scale 0.35s var(--ease);
}
.reading__now:hover img, .reading.is-open .reading__now img { rotate: -4deg; scale: 1.06; }

/* The rest of the shelf stacks above, one after another */
.reading__list {
  position: absolute;
  right: 0;
  bottom: calc(100% + 16px);
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
  pointer-events: none;
}
.reading__list li {
  opacity: 0;
  filter: blur(6px);
  translate: 0 8px;
  transition: opacity 0.35s var(--ease), filter 0.4s var(--ease), translate 0.4s var(--ease);
  transition-delay: calc(var(--i) * 60ms);              /* closing: top book first (reverse of opening) */
}
.reading.is-open .reading__list li {
  opacity: 1; filter: none; translate: none;
  transition-delay: calc((var(--n) - var(--i) - 1) * 60ms); /* opening: nearest book first */
}

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

/* ---------- Narrow ---------- */
@media (max-width: 640px) {
  /* Phones: no portrait or reading widget */
  /* Writing: a clear gap between the publication and the date when they stack */
  .writing__list .row__date { margin-top: 10px; }
  .about__media, .reading { display: none !important; }
  .prose p { font-size: 18px; }
  /* Date drops under the title on phones */
  .row__head { grid-template-columns: 1fr auto 14px; row-gap: 4px; }
  .row__title { grid-area: 1 / 1; }
  .row__meta { grid-area: 1 / 2; }
  .row__toggle { grid-area: 1 / 3; }
  .row__date { grid-area: 2 / 1; }
  .xp__card { width: 80vw; }
  .footer { flex-direction: column-reverse; align-items: flex-end; }
  .footer__links { align-self: flex-start; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .band, .band--soft { animation: none; opacity: 1; }
  .grain { animation: none; }
  .beacon::before { animation: none; }
  .reveal { filter: none; translate: none; transition: opacity 0.4s; }
  .row__panel, .tip, .reading__list li { transition: none; }
}


/* ---------- Project links: plain links, stacked, arrow first ---------- */
.ilink {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  /* the small spaced capitals used for labels and dates */
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  transition: color 0.25s var(--ease);
}
.ilink svg { flex: none; transition: translate 0.25s var(--ease); }
.ilink:hover { color: var(--fg); }
.ilink:hover svg { translate: 1px -1px; }
.ilink:focus-visible { outline: 1px solid var(--fg); outline-offset: 3px; }

/* Inline links inside descriptions (e.g. "on stage") */
.row__desc a, .peek__desc a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--edge);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.25s;
}
.row__desc a:hover, .peek__desc a:hover { text-decoration-color: var(--fg); }


/* ---------- Headline: word-by-word arrival ---------- */
.hero__title .w {
  display: inline-block;
  opacity: 0;
  filter: blur(6px);
  translate: 0 0.18em;
  transition:
    opacity 1.1s cubic-bezier(0.25, 0.1, 0.25, 1),
    filter 1.1s cubic-bezier(0.25, 0.1, 0.25, 1),
    translate 1.1s var(--ease);
  transition-delay: var(--wd, 0s);
}
.hero__title.is-in .w { opacity: 1; filter: none; translate: none; }
@media (prefers-reduced-motion: reduce) {
  .hero__title .w { transition: none; opacity: 1; filter: none; translate: none; }
}


/* ---------- Cursor follower (from melcasey.com) ----------
   A soft dot that trails the pointer; over links and buttons it grows into a large, faint circle.
   Mouse/trackpad only; the normal cursor stays visible. */
.cursor { display: none; }
@media (any-pointer: fine) {
  .cursor {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
    display: block;
    pointer-events: none;
    will-change: transform;
  }
  .cursor__inner { fill: var(--fg); stroke: var(--fg); stroke-width: 1px; shape-rendering: geometricPrecision; opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .cursor { display: none; } }

/* ---------- Nav (styled after berryreader.com) ---------- */
.nav { position: relative; }
.nav__bar {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-right: -12px; /* no background now, so the last link's text lines up with the content edge */
}
.nav__link {
  padding: 7px 12px;
  border-radius: 9px;
  /* same small spaced capitals as the time, but solid and bold */
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg);
  transition: opacity 0.25s var(--ease);
}
/* Hover: the letters glitch and re-type themselves (see main.js) */
/* Contact: same style as the other links (it opens a menu rather than scrolling) */
.nav__contact {
  all: unset;
  box-sizing: border-box;
  padding: 7px 12px;
  border-radius: 9px;
  font: 700 11px/1.4 var(--body);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg);
  cursor: pointer;
  transition: opacity 0.25s var(--ease);
}
.nav__link:focus-visible, .nav__contact:focus-visible { outline: 1px solid var(--fg); outline-offset: 2px; }

/* Contact: hover dropdown, same style as the time tooltip */
.contact { position: relative; }
.contact__tip {
  position: absolute;
  top: calc(100% + 14px);
  right: 0;
  display: grid;
  gap: 10px;
  padding: 14px 18px 15px;
  border: 1px solid var(--edge);
  border-radius: 14px;
  white-space: nowrap;
  opacity: 0;
  filter: blur(6px);
  translate: 0 -4px;
  pointer-events: none;
  transition: opacity 0.25s var(--ease), filter 0.3s var(--ease), translate 0.3s var(--ease);
}
/* an invisible bridge so the pointer can travel from Contact down into the dropdown */
.contact__tip::before { content: ""; position: absolute; left: 0; right: 0; top: -16px; height: 16px; }
.contact:hover .contact__tip,
.contact:focus-within .contact__tip,
.contact.is-open .contact__tip { opacity: 1; filter: none; translate: none; pointer-events: auto; }
.contact__tip a {
  display: flex;
  align-items: center;
  gap: 9px;
  font: 700 14px/1.2 var(--body);
  letter-spacing: -0.01em;
  color: var(--muted);
  transition: color 0.12s linear; /* quick and crisp */
}
.contact__tip a:hover { color: var(--fg); }
.contact__tip a:focus-visible { outline: 1px solid var(--fg); outline-offset: 3px; }

@media (max-width: 640px) {
  .topbar { flex-wrap: nowrap; gap: 10px; }
  .topbar__meta { letter-spacing: 0.08em; }
  .nav__bar { gap: 0; margin-right: -7px; }
  .nav__link { padding: 6px 7px; letter-spacing: 0.1em; }
  .nav__contact { padding: 6px 7px; letter-spacing: 0.1em; }
}
@media (prefers-reduced-motion: reduce) {
  .contact__tip { transition: none; }
}

/* Nav links land with the section label clear of the sticky nav */
section[id] { scroll-margin-top: 96px; }


/* ---------- Writing: same rows as Selected work, each a link out ---------- */
.writing__list { border-top: none; }
.writing__list .row:last-child { border-bottom: none; }
.writing__list .row__head { cursor: pointer; }
.writing__list .row__meta { white-space: nowrap; }
.row__arrow { display: inline-block; vertical-align: -5px; margin-left: 5px; transition: translate 0.25s var(--ease); } /* same arrow as the project links, lighter stroke */
/* Hovering one dims the others, like the project list */
.writing__list:hover .row__head { color: var(--faint); }
.writing__list:hover .row__head .row__meta { color: var(--faint); }
.writing__list .row__head:hover, .writing__list .row__head:focus-visible { color: var(--fg); }
.writing__list .row__head:hover .row__meta { color: var(--muted); }
.writing__list .row__head:hover .row__arrow { translate: 2px -2px; }

/* ---------- Nav hover: film grain ----------
   A softly edged patch of flickering grain appears behind the link, and the word gives
   a quick projector-style flicker. */
.nav__link, .nav__contact { position: relative; isolation: isolate; }
.nav__link::before, .nav__contact::before {
  content: "";
  position: absolute;
  inset: -2px -4px;
  z-index: -1;
  border-radius: 10px;
  /* speckles in a muted dusty pink from the background band (no white) */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='90'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.58 0 0 0 0 0.34 0 0 0 0 0.41 0 0 0 3.2 -1.4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  background-size: 90px 90px;
  -webkit-mask-image: radial-gradient(closest-side, #000 45%, transparent);
  mask-image: radial-gradient(closest-side, #000 45%, transparent);
  opacity: 0;
  transition: opacity 0.35s var(--ease);
  animation: nav-grain 0.42s steps(5) infinite;
  animation-play-state: paused;
}
.nav__link:hover::before, .nav__contact:hover::before,
.nav__link:focus-visible::before, .nav__contact:focus-visible::before,
.contact:hover .nav__contact::before,
.contact:focus-within .nav__contact::before,
.contact.is-open .nav__contact::before { opacity: 0.9; animation-play-state: running; } /* stays on while you're in the dropdown */
.nav__link:hover, .nav__contact:hover { animation: nav-flicker 0.5s steps(1) 1; }
@keyframes nav-grain {
  0% { background-position: 0 0; }
  20% { background-position: -23px 11px; }
  40% { background-position: 17px -29px; }
  60% { background-position: -31px -7px; }
  80% { background-position: 9px 26px; }
  100% { background-position: 0 0; }
}
@keyframes nav-flicker {
  0% { opacity: 1; } 12% { opacity: 0.55; } 22% { opacity: 1; } 34% { opacity: 0.75; } 46% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .nav__link::before, .nav__contact::before { animation: none; }
  .nav__link:hover, .nav__contact:hover { animation: none; }
}

/* Inspections: give the video the same rounded phone corners the image has baked in
   (≈55px on a 416×900 frame, expressed as % so it scales with the video) */
video.peek__slot, .row__media--pair > video { border-radius: 13% / 6%; }

/* Writing: publication sits under the title in the small capitals; only the arrow is on the right */
.writing__list .row__title { display: grid; gap: 6px; }
.row__pub { display: block; }
.writing__list .row__meta { align-self: baseline; } /* level with the date and first line of the title */
.writing__list:hover .row__head .row__pub { color: var(--faint); }
.writing__list .row__head:hover .row__pub { color: var(--muted); }

/* Experience: company name a step up (16px, the base size used for project titles) */
.xp__co { font-size: 16px; }

/* ---------- Project media: subtle grainy drop shadow ---------- */
.peek__frame { isolation: isolate; }
/* a soft shadow that follows each image's real shape (phone corners included) */
/* box-shadow rather than drop-shadow so it can take a negative spread: the shadow is pulled in
   under the image and blurred wide, so it reads as soft depth, not a dark outline */
.peek__slot, .row__media > img, .row__media > video {
  box-shadow:
    10px 32px 100px -40px rgba(0, 0, 0, 0.28),  /* wide, soft and offset down-right */
    3px 8px 20px -14px rgba(0, 0, 0, 0.1);   /* a faint contact shadow close in */
}
/* the phone PNG has its rounded corners baked in, so round its box to match */
.row__media--pair > img, .peek__slot[src$="phone-checkin.png"] { border-radius: 13% / 6%; }
/* …and a speckled, dithered shadow pooled underneath, like grain in a print */
.peek__frame::after {
  content: "";
  position: absolute;
  z-index: -1;
  left: 16%;
  right: -2%;
  bottom: -34px;
  height: 52px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.3' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.05 0 0 0 0 0.04 0 0 0 0 0.05 0 0 0 2.6 -0.9'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23s)'/%3E%3C/svg%3E");
  background-size: 120px 120px;
  -webkit-mask-image: radial-gradient(closest-side, #000 20%, transparent);
  mask-image: radial-gradient(closest-side, #000 20%, transparent);
  opacity: 0.4;
  pointer-events: none;
}

/* ---------- About portrait: an old vertical Polaroid, slightly tilted ---------- */
.about__media.polaroid {
  --tilt: -3deg;
  aspect-ratio: auto;
  overflow: visible;
  border-radius: 2px;
  padding: 4% 4% 14%;                 /* thin even border, deeper strip at the bottom */
  background: #e8e6e6;                /* soft off-white, a step down from the page text colour */
  isolation: isolate;
  box-shadow:                         /* identical to the project images */
    10px 32px 100px -40px rgba(0, 0, 0, 0.28),
    3px 8px 20px -14px rgba(0, 0, 0, 0.1);
  /* slides in from the right (and back out) instead of fading in place */
  opacity: 0;
  filter: none;
  transform: translateX(90px) rotate(4deg);
  transition:
    opacity 0.9s var(--ease),
    transform 1.2s var(--ease);
}
.about__media.polaroid.is-shown { opacity: 1; transform: rotate(var(--tilt)); }

/* faint grain in the paper itself */
.polaroid::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E") 0 0 / 140px 140px;
  mix-blend-mode: multiply;
  opacity: 0.12;
}
.polaroid__photo {
  position: relative;
  aspect-ratio: 752 / 920;
  overflow: hidden;
  background: #2a2629;
}
/* a little less saturated, slightly soft */
.polaroid__photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.78) contrast(0.93) brightness(1.02);
}
/* faded with the site's own colours: shadows lift toward a dusky plum,
   highlights wash rose at one corner and steel blue at the other */
.polaroid__photo::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(150deg, rgb(166, 95, 110), rgb(110, 133, 150));
  mix-blend-mode: soft-light;
  opacity: 0.45;
  pointer-events: none;
}
.polaroid__fx {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 45%, transparent 60%, rgba(27, 26, 28, 0.14) 100%),
    rgb(52, 44, 54);
  background-blend-mode: normal;
  mix-blend-mode: lighten;           /* raises the deepest blacks to a faded plum */
  opacity: 0.5;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06), inset 0 1px 2px rgba(0, 0, 0, 0.1);
}
.polaroid__photo::after { /* film grain */
  content: "";
  position: absolute;
  inset: -50%;
  z-index: 2;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E") 0 0 / 160px 160px;
  mix-blend-mode: overlay;
  opacity: 0.6;
  pointer-events: none;
}

@media (hover: hover) and (min-width: 1000px) {
  .about__media.polaroid { width: min(100%, 300px); justify-self: center; }
}
@media (prefers-reduced-motion: reduce) {
  .about__media.polaroid { transform: rotate(var(--tilt)); }
}

/* Phones and tablets: the top bar hides while scrolling down and comes back on the way up */
.topbar.reveal { transition-property: opacity, filter, translate; }
.topbar.is-hidden { translate: 0 calc(-100% - 24px); }

/* Touch screens: bigger tap areas without changing the layout (padding, cancelled by negative margin) */
@media (pointer: coarse) {
  .footer__links a,
  .contact__tip a,
  .ilink,
  .clock { padding-block: 12px; margin-block: -12px; }
  .footer__links a { display: inline-block; }
  .xp__dots { margin-block: -12px; }
  .xp__dots button { width: 28px; height: 44px; }
  .xp__dots button[aria-current="true"] { width: 36px; }
}

/* Phones: a slightly smaller headline so it stays around five lines */
@media (max-width: 640px) {
  .hero__title { font-size: clamp(23px, 6.6vw, 30px); }
}
