:root {
  --paper: var(--paper-light, #f0e9dc);          /* light oat; try others with ?paper= (see colours.html) */
  --ink: #1b1b1a;
  --muted: #8a8780;
  --rule: #d9d5cb;
  --rule: color-mix(in srgb, var(--paper), #5a4e3a 20%);
  --img-blend: multiply;                          /* white product backgrounds melt into the paper */
  --img-filter: brightness(1.07) contrast(1.05);
  --invert: none;                                 /* black line-art logos flip to white in dark mode */
  --serif: "EB Garamond", "Times New Roman", serif;
  --sans: "Inter", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --swiss: "Helvetica Neue", Helvetica, "Inter", Arial, sans-serif;
  --bar-h: 40px;
  --serif-tracking: -0.04em;  /* letter spacing for all serif text: -4% */
}

/* Dark mode: follows the Mac/phone setting, unless the visitor picks with the moon toggle */
:root[data-theme="dark"] {
  --paper: #151514;
  --ink: #f0e9dc;               /* the light-mode cream */
  --muted: #8f8c85;
  --rule: #2e2d2a;
  --img-blend: normal;
  --img-filter: none;
  --invert: invert(1) sepia(.8) brightness(.94); /* black logos turn cream, not white */
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #151514;
    --ink: #f0e9dc;               /* the light-mode cream */
    --muted: #8f8c85;
    --rule: #2e2d2a;
    --img-blend: normal;
    --img-filter: none;
    --invert: invert(1) sepia(.8) brightness(.94); /* black logos turn cream, not white */
    color-scheme: dark;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
body.home { height: 100vh; height: 100svh; overflow: hidden; }
/* Gentle fade on load (not on body, so the cursor's blend keeps working) */
.name, .now, .stage, .index-toggle, .j-top, .j-main { animation: fade-in 1s ease backwards; }
.stage { animation-delay: .1s; }
@keyframes fade-in { from { opacity: 0; } }
a { color: inherit; text-decoration: none; }
img { display: block; }

/* ---------- Dot cursor ---------- */
.has-cursor, .has-cursor * { cursor: none !important; }
.cursor {
  position: fixed;
  top: 0; left: 0;
  width: 14px; height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: #fff;
  mix-blend-mode: difference;
  pointer-events: none;
  z-index: 1000;
  transition: width .25s, height .25s, margin .25s, opacity .2s;
}
.cursor.big { width: 44px; height: 44px; margin: -22px 0 0 -22px; }
.cursor.mid { width: 24px; height: 24px; margin: -12px 0 0 -12px; }
.cursor.gone { opacity: 0; }
.cursor.hide { opacity: 0; }

/* Image peek that follows the cursor over a word (fun: true) */
.peek {
  position: fixed;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 999;
}
.peek-inner {
  width: 168px;
  height: 168px;
  margin: -190px 0 0 22px; /* sits above-right of the cursor so the word stays readable */
  transform: rotate(var(--tilt, 0deg)) scale(.4);
  opacity: 0;
  transition: opacity .25s ease, transform .45s cubic-bezier(.3,1.6,.5,1);
}
.peek.on .peek-inner { opacity: 1; transform: rotate(var(--tilt, 0deg)) scale(1); }

/* Easter egg (every 8th hover): tips over past upside down, then one small swing back to rest just off 180° */
.peek-spin { width: 100%; height: 100%; }
.peek-spin.flip { animation: flip-swing 1.4s cubic-bezier(.35,.6,.35,1) forwards; }
@keyframes flip-swing {
  0%   { transform: rotate(0deg); }
  50%  { transform: rotate(188deg); }
  78%  { transform: rotate(170deg); }
  100% { transform: rotate(176deg); }
}
.peek.gone .peek-inner { opacity: 0; }
.peek img { width: 100%; height: 100%; object-fit: contain; } /* no backdrop, so transparent cut-outs float with no box */
.peek-inner.cover img { object-fit: cover; }

.name {
  position: fixed;
  top: 16px; left: 20px;
  z-index: 2;
  font-family: var(--swiss);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.01em;
}
/* London time + weather, under the name */
.now {
  position: fixed;
  top: 35px; left: 20px;
  z-index: 2;
  font: 11px var(--mono);
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
  white-space: nowrap;
}
.now { display: flex; align-items: center; gap: 0; }
.now > * + *::before { content: "·"; margin: 0 .6em; }
.now-weather { display: inline-flex; align-items: center; gap: .4em; font: inherit; color: inherit; letter-spacing: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.now-weather::before { margin-right: .2em !important; }
.now-weather:hover { color: var(--ink); }

/* Weather easter egg: effects layer, and a little shake for thunder */
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; } /* behind the name (z 2) */
.marquee.shake { animation: shake .45s ease; }
@keyframes shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.now-icon { width: 13px; height: 13px; }

/* ---------- Rows ---------- */
/* Three bands: space above, the rows, space below. The rows never move;
   the card lives in the bottom band and opening it changes nothing above. */
.stage {
  height: 100vh;
  height: 100svh;
  display: grid;
  grid-template-rows: minmax(0, .8fr) auto minmax(0, 1.2fr);
  padding: 64px 0 76px;
  overflow: hidden;
}
/* Rows are moved by app.js so they can be dragged and flicked */
.marquee {
  grid-row: 2;
  overflow: hidden;
  padding: 28px 0;              /* room so the top and bottom rows (g, y, accents) aren't clipped... */
  margin: -28px 0;              /* ...without moving the rows */
  touch-action: pan-y;          /* horizontal swipes go to the rows, not the browser */
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.row {
  display: flex;
  width: max-content;
  will-change: transform;
}
.row a, .row img { -webkit-user-drag: none; -webkit-touch-callout: none; }
.dragging .item { pointer-events: none; }
.item { transition: opacity .35s ease; }
.marquee.filtered .item { opacity: .12; }
.marquee.filtered .item.on { opacity: 1; }

.row-set { display: flex; align-items: center; white-space: nowrap; }
.item, .label {
  display: inline-flex;
  align-items: center;
  font-family: var(--serif);
  font-size: clamp(36px, min(6vw, 8.5vh), 112px);
  line-height: 1.22; /* room for descenders (g, y, p) */
  letter-spacing: var(--serif-tracking);
  padding-right: 0.28em;
}
.label { font-family: var(--sans); font-size: 11px; color: var(--muted); padding-right: 1.5em; }
/* Hover only on mouse/trackpad, so taps on phones don't leave words stuck in italic */
@media (hover: hover) { .item.link:hover .word { font-style: italic; } }
/* Every image sits in the same-sized box, so cut-outs and photos read consistently.
   Cut-outs (default) are fitted inside the box; photos with "fit: cover" fill it. */
.pic {
  display: inline-block;
  flex-shrink: 0;
  width: 0.9em;
  height: 0.72em;
  margin-left: 0.22em;
  background: var(--paper); /* backdrop for the blend below */
}
.pic img, .card-pic img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* White / light-grey product backgrounds melt into the page */
  mix-blend-mode: var(--img-blend);
  filter: var(--img-filter);
}
.pic.cover img, .card-pic.cover img { object-fit: cover; }
.inv img { filter: var(--invert); }
/* Cut-outs and logos keep their own width at the same height, so wide logos aren't shrunk */
.pic:not(.cover):not(.icon) { width: auto; }
.pic:not(.cover):not(.icon) img { width: auto; max-width: 1.7em; }
.pic.icon { width: 0.48em; height: 0.48em; margin-left: 0.24em; background: none; }
.pic.icon svg { display: block; width: 100%; height: 100%; }
.item .comma { margin-left: 0.02em; }

/* ---------- Card under the rows ---------- */
.card { grid-row: 3; min-height: 0; padding-top: 28px; display: flex; flex-direction: column; }
.card-inner {
  position: relative;
  background: var(--paper);
  display: flex;
  gap: 20px;
  align-items: flex-start;
  width: min(520px, calc(100% - 32px));
  min-height: 0;
  flex: 0 1 auto;
  margin: 0 auto;
  overflow: hidden;             /* the picture stays put; only the text scrolls */
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity .4s ease, transform .5s cubic-bezier(.2,.7,.2,1);
}
.card-text::-webkit-scrollbar { display: none; }
.has-entry .card-inner { opacity: 1; transform: none; pointer-events: auto; }
.has-entry .card-inner.swap { opacity: 0; transform: translateY(3px); transition-duration: .2s; }

.card-pic { display: block; width: 96px; height: 96px; flex-shrink: 0; background: var(--paper); }
.card-text {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  max-height: 100%;
  align-self: stretch;
  padding-right: 24px;
  padding-bottom: 24px;
  overflow-x: hidden;            /* up and down only */
  overflow-y: auto;
  touch-action: pan-y;
  overscroll-behavior: contain;
  scrollbar-width: none;
  /* soft fade where long entries scroll */
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent);
}
.card h2 { font-family: var(--serif); font-weight: 400; font-size: 26px; line-height: 1.05; letter-spacing: var(--serif-tracking); }
.card-sub { font: 10.5px var(--mono); text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-top: 6px; }
.card-body { font-family: var(--mono); font-size: 12px; line-height: 1.65; margin-top: 14px; }
.card-body > * + * { margin-top: 1em; }
.card-body blockquote, .e-body blockquote { border-left: 1px solid var(--muted); padding-left: 14px; font-style: italic; color: var(--ink); }
.card-body a, .card-more { text-decoration: underline; text-underline-offset: 3px; }
.card-title { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.card-more { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; font: 10.5px var(--mono); text-transform: uppercase; letter-spacing: .03em; }
.card-more-arrow { width: 11px; height: 11px; transform: rotate(90deg); transition: transform .2s; } /* the pixel chevron, pointing right */
.card-more:hover .card-more-arrow { transform: rotate(90deg) translateY(-2px); }
.card-close {
  position: sticky; top: 4px; float: right; margin-right: -20px; /* stays visible while the text scrolls */
  width: 20px; height: 20px; display: grid; place-items: center;
  background: none; border: 0; color: var(--muted);
}
.card-close:hover { color: var(--ink); }

/* Large-image templates: layout "image-top" or "image-bottom" */
.card-inner.large { flex-direction: column; align-items: stretch; gap: 16px; }
.card-inner.large .card-pic { width: 100%; height: 20vh; height: 20svh; }
.card-inner.large .card-pic img { object-position: left center; }
.card-inner.image-bottom .card-pic { order: 2; }
/* Wide photo above the text: the whole card scrolls, the photo is pinned and collapses (see app.js) */
.card-inner.image-top {
  display: block;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  padding-bottom: 24px;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent);
}
.card-inner.image-top::-webkit-scrollbar { display: none; }
.card-inner.image-top .card-pic { position: sticky; top: 0; z-index: 1; display: block; width: 100%; }
.card-inner.image-top .pic-spacer { display: block; }
.card-inner.image-top .card-text {
  overflow: visible; max-height: none; padding: 16px 24px 0 0;
  -webkit-mask-image: none; mask-image: none;
}
.card-inner.image-top .card-close { top: 64px; }
.card-pic.duo { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 100%; gap: 8px; overflow: hidden; }
.card-pic.duo img { min-width: 0; min-height: 0; height: 100%; object-position: center 30%; }

/* ---------- Diary layout, used on journal pages ---------- */
.entry-card, .j-main { max-width: 520px; }
.e-head { padding-bottom: 28px; border-bottom: 1px solid var(--rule); margin-bottom: 28px; }
.e-head h1, .e-head p {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1;
  letter-spacing: var(--serif-tracking);
}
.e-head p { color: var(--muted); }
/* details under a journal title (number, date, place): one small line, like the cards */
.e-head p.e-sub { font: 11px var(--mono); text-transform: uppercase; letter-spacing: .03em; margin-top: 14px; }

.e-body { font-family: var(--mono); font-size: 12.5px; line-height: 1.7; }
.e-body > * + * { margin-top: 1.4em; }
.e-body a { text-decoration: underline; text-underline-offset: 3px; }
.e-img { width: 100%; max-width: 280px; margin-top: 40px; background: var(--rule); }

.e-meta { margin-top: 40px; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .02em; }
.e-meta div { border-top: 1px solid var(--rule); padding: 8px 0 10px; }
.e-meta dt { color: var(--muted); }

/* ---------- Pop-up index ---------- */
.index-toggle {
  position: fixed;
  left: 50%; bottom: 14px;
  transform: translateX(-50%);
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
  z-index: 11;
  transition: bottom .45s cubic-bezier(.2,.7,.2,1);
}
.index-toggle svg { width: 24px; height: 24px; transition: transform .45s cubic-bezier(.2,.7,.2,1); }
.index-open .index-toggle { bottom: calc(var(--bar-h) + 14px); }
.index-open .index-toggle svg { transform: rotate(180deg); }

.index-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  background: var(--paper);
  border-top: 1px solid var(--ink);
  transform: translateY(100%);
  transition: transform .45s cubic-bezier(.2,.7,.2,1);
  z-index: 10;
}
.index-open .index-bar { transform: none; }
.filters { display: flex; align-items: center; gap: 0; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button {
  font: inherit; background: none; border: 0; color: var(--ink); cursor: pointer; padding: 2px;
  white-space: nowrap;
}
.filters button + button::before {
  content: ""; display: inline-block; width: 3px; height: 3px; background: var(--ink);
  vertical-align: middle; margin: -2px 10px 0 6px;
}
.filters button.on { text-decoration: underline; text-underline-offset: 3px; }
.bar-right { display: flex; align-items: center; gap: 14px; white-space: nowrap; }
.bar-right .short { display: none; }
.theme-toggle { display: grid; place-items: center; width: 22px; height: 22px; background: none; border: 0; color: var(--ink); cursor: pointer; }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle:hover { color: var(--muted); }
.index-bar a:hover, .filters button:hover { color: var(--muted); }

/* ---------- Journal pages ---------- */
.j-top { display: flex; justify-content: space-between; padding: 16px 20px; }
.j-top #site-name { font-family: var(--swiss); font-weight: 700; font-size: 13px; letter-spacing: -0.01em; }
.j-top a:hover { color: var(--muted); }
.j-main { padding: 12vh 20px 160px max(20px, 10vw); box-sizing: content-box; }

/* Journal list: one entry per line — big serif title, small picture, little date (like the home rows) */
.j-main.archive { max-width: none; padding: 9vh 20px 160px; }
.j-heading { font: 400 clamp(40px, min(6vw, 8.5vh), 112px)/1.1 var(--serif); letter-spacing: var(--serif-tracking); margin-bottom: 4vh; }
.j-index { list-style: none; }
/* flows like text, so the picture and date stay right after the last word when a long title wraps */
.j-index li {
  font-family: var(--serif);
  font-size: clamp(36px, min(6vw, 8.5vh), 112px);
  line-height: 1.22;
  letter-spacing: var(--serif-tracking);
}
.j-tail { white-space: nowrap; } /* picture + date never split across lines */
.j-index .pic { display: inline-block; vertical-align: -0.04em; margin-left: 0.25em; }
.j-when { display: inline-block; vertical-align: text-top; margin-left: 0.6em; font: 11px var(--mono); letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
@media (hover: hover) { .j-index a:hover .j-word { font-style: italic; } }

.post-nav {
  display: flex; justify-content: space-between; gap: 16px;
  margin-top: 56px; padding-top: 10px; border-top: 1px solid var(--rule);
  font: 11px var(--mono); text-transform: uppercase;
}
.post-nav a:hover { color: var(--muted); }

/* Desktop: a wider card with a larger photo on the left, so text spreads out and rarely needs scrolling */
@media (min-width: 761px) {
  .card-inner:not(.large) { width: min(820px, calc(100% - 64px)); gap: 28px; }
  /* text that fits doesn't need the scroll fade or its padding */
  .card-text { padding-bottom: 0; -webkit-mask-image: none; mask-image: none; }
  .card { padding-top: 20px; }
  /* photo fills the card's height (up to 260px) so it's never clipped */
  .card-inner:not(.large) .card-pic { width: 200px; height: auto; min-height: 180px; max-height: 260px; align-self: stretch; }
  /* rows sit a little higher on desktop, leaving more room for the card */
  .stage { grid-template-rows: minmax(0, .6fr) auto minmax(0, 1.4fr); }
  .card h2 { font-size: 30px; }
}

@media (max-width: 760px) {
  /* phones: a shorter label so Career · About · Journal · Contact all fit on one line */
  .bar-right .long { display: none; }
  .bar-right .short { display: inline; }
  .bar-right { gap: 12px; }
  .name { left: 16px; }
  .now { left: 16px; font-size: 10px; }
  .index-bar { padding: 0 16px; }
  .j-top { padding: 16px; }
  .card-inner { gap: 14px; }
  .card { padding-top: 20px; }
  .card-inner:not(.large) .card-pic { width: 72px; height: 72px; }
  .card-inner.large .card-pic { height: 14vh; height: 14svh; }
  .card h2 { font-size: 22px; }
  .j-main { padding: 8vh 16px 140px; }
  .j-main.archive { padding: 7vh 16px 120px; }
}


/* Weather effect test panel (only with ?weather=test) */
.fx-test { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 20; display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.fx-test button { font: 10.5px var(--mono); text-transform: uppercase; letter-spacing: .03em; padding: 5px 9px; background: var(--paper); color: var(--ink); border: 1px solid var(--ink); cursor: pointer; }
.fx-test button:hover { background: var(--ink); color: var(--paper); }

/* Hover peek for social links: your handle + a little "opens in a new tab" icon */
.peek-text { display: none; }
.peek-inner.text { width: auto; height: auto; margin: -46px 0 0 18px; }
.peek-inner.text img { display: none; }
.peek-inner.text .peek-text {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font: 13px var(--mono); letter-spacing: .01em; color: var(--ink);
  background: var(--paper); border: 1px solid var(--ink); padding: 6px 9px;
}
.peek-ext { width: 12px; height: 12px; }

/* Email card */
.card-icon { display: grid; place-items: center; color: var(--muted); }
.card-icon svg { width: 40%; height: 40%; }
.card h2.card-email { font-size: 28px; word-break: break-all; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.card-btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: 10.5px var(--mono); text-transform: uppercase; letter-spacing: .03em;
  padding: 8px 12px; border: 1px solid var(--ink); background: none; color: var(--ink); cursor: pointer;
}
.card-btn svg { width: 12px; height: 12px; }
.card-btn:hover, .card-btn.done { background: var(--ink); color: var(--paper); }
