/* ------------------------------------------------------------------
   Pond: a personal site built on an ink painting of carp.
   ------------------------------------------------------------------ */
:root {
  --paper: #dad1c3;
  --paper-light: #e4ddd1;
  --wash: 228, 221, 209;            /* soft paper glow behind text, as r,g,b */
  --ink: #26303a;
  --ink-soft: #4d5864;
  --ink-faint: rgba(38, 48, 58, 0.38);
  --seal: #a8362b;
  --display: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --body: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --ease-out: cubic-bezier(.22, .8, .24, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: inherit; }
img { display: block; }
.defs { position: absolute; }

/* --- Name / seal, top-left -------------------------------------- */
.mark {
  position: fixed; top: 22px; left: 24px; z-index: 20;
}
.mark__link {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none;
}
.seal {
  width: 36px; height: 36px;
  user-select: none;
}
.mark__name {
  font-family: var(--display);
  font-size: 21px; font-weight: 500; letter-spacing: .04em;
}

/* --- The pond ---------------------------------------------------- */
.pond {
  position: fixed; inset: 0;
  overflow: hidden;
  transition: opacity .9s ease, transform 1.1s var(--ease-out), filter .9s ease;
}
.stage {
  position: absolute; left: 0; top: 0;
  width: 1922px; height: 1381px;
  transform-origin: 0 0;
  transform: translate(var(--tx, 0px), var(--ty, 0px)) rotate(var(--rot, 0deg)) scale(var(--s, .5));
}
.stage__bg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  user-select: none;
  /* melt the painting's edges into the page */
  -webkit-mask-image:
    linear-gradient(to right, transparent, #000 6%, #000 94%, transparent),
    linear-gradient(to bottom, transparent, #000 7%, #000 93%, transparent);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(to right, transparent, #000 6%, #000 94%, transparent),
    linear-gradient(to bottom, transparent, #000 7%, #000 93%, transparent);
  mask-composite: intersect;
}

/* --- Fish -------------------------------------------------------- */
.fish {
  position: absolute;
  left: calc(var(--x) * 1px); top: calc(var(--y) * 1px);
  width: calc(var(--w) * 1px); height: calc(var(--h) * 1px);
  outline: none;
  pointer-events: none; /* clicks are hit-tested against the fish's pixels in JS */
  transition: opacity .6s ease;
  -webkit-tap-highlight-color: transparent;
}
.fish__sway {
  position: absolute; inset: 0;
  transform-origin: var(--px) var(--py);
  animation: sway var(--dur) ease-in-out var(--delay) infinite;
}
.fish img {
  width: 100%; height: 100%;
  user-select: none; pointer-events: none;
  filter: url(#water);
  animation: drift calc(var(--dur) * 1.7) ease-in-out var(--delay) infinite;
  transition: transform .8s var(--ease-out);
}
/* while swimming, the fish is drawn by js/swim.js on a canvas */
.fish .swimmer { position: absolute; pointer-events: none; }
.fish.swimming { z-index: 3; } /* the fish on the move passes over the others */
.fish.gl-swim img { visibility: hidden; }
.evening .fish .swimmer { filter: var(--moon); }

/* rotate gently around the head, so the tail does the swaying */
@keyframes sway {
  0%, 100% { transform: rotate(-0.9deg); }
  50%      { transform: rotate(1.1deg); }
}
@keyframes drift {
  0%, 100% { transform: translate(0, 0); }
  33%      { transform: translate(5px, -4px); }
  66%      { transform: translate(-4px, 3px); }
}

/* hover / focus / legend highlight */
.stage.has-lit .fish:not(.lit) { opacity: .45; }
.fish.lit img { transform: translate(0, -3px) scale(1.012); }
.fish:focus-visible .fish__label { text-decoration: underline; text-underline-offset: .2em; }

.fish__label {
  position: absolute;
  left: var(--lx); top: var(--ly);
  transform: translate(-50%, calc(-100% + 6px));  /* (lx, ly) is the label's bottom-centre */
  font-family: var(--display);
  font-style: italic;
  font-size: calc(var(--fs, 22px) / var(--s, .5));
  letter-spacing: .03em;
  color: var(--ink);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .45s ease, transform .6s var(--ease-out);
  text-shadow: 0 0 calc(10px / var(--s, .5)) var(--label-glow, var(--paper-light)), 0 0 calc(4px / var(--s, .5)) var(--label-glow, var(--paper-light));
}
.fish__label::before {
  content: "";
  display: block;
  width: calc(26px / var(--s, .5)); height: calc(1px / var(--s, .5));
  margin: 0 auto calc(6px / var(--s, .5));
  background: var(--ink-faint);
}
.fish.lit .fish__label { opacity: 1; transform: translate(-50%, -100%); }

/* names appear only on hover; touch screens just tap the fish or use the menu */
@media (hover: none) { .fish__label { display: none; } }
/* when the pond is turned for a tall screen, keep the names upright */
.rotated .fish__label { transform-origin: 50% 100%; transform: translate(-50%, calc(-100% + 6px)) rotate(90deg); }
.rotated .fish.lit .fish__label { transform: translate(-50%, -100%) rotate(90deg); }
.rotated .ripple { width: 120px; height: 220px; margin: -110px 0 0 -60px; }

.signature {
  position: absolute; right: 14px; top: 16px;
  display: none; height: auto; opacity: .9;
  pointer-events: none; user-select: none;
}
.rotated .signature { display: block; }

/* --- Ripples ----------------------------------------------------- */
.ripples { position: absolute; inset: 0; pointer-events: none; }
.ripple {
  position: absolute;
  width: 220px; height: 120px;
  margin: -60px 0 0 -110px;
  border-radius: 50%;
  border: 2px solid var(--ripple, rgba(38, 48, 58, .22));
  transform: scale(.05);
  opacity: 0;
  animation: ripple 3.4s cubic-bezier(.2, .6, .3, 1) forwards;
}
.ripple.r2 { animation-delay: .35s; border-width: 1.5px; }
@keyframes ripple {
  0%   { transform: scale(.05); opacity: 0; }
  12%  { opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* --- Legend (the visible menu) ---------------------------------- */
.legend {
  position: fixed; left: 50%; bottom: 18px; z-index: 10;
  transform: translateX(-50%);
  padding: 14px 56px 10px;
  text-align: center;
  white-space: nowrap;
  background: radial-gradient(closest-side, rgba(var(--wash),.92), rgba(var(--wash),.7) 60%, rgba(var(--wash),0));
  transition: opacity .6s ease;
}
.legend ul {
  display: inline-flex; gap: 6px; margin: 0; padding: 0; list-style: none;
}
.legend li + li::before {
  content: "·"; margin-right: 6px; color: var(--ink-faint);
}
.legend a {
  font-family: var(--display); font-size: 19px; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase; font-size: 14px;
  text-decoration: none; color: var(--ink-soft);
  padding: 6px 6px;
  transition: color .3s ease;
}
.legend a:hover, .legend a:focus-visible, .legend a.lit { color: var(--ink); }

/* --- Leaving the pond -------------------------------------------- */
body.leaving .legend { opacity: 0; }
body.leaving .fish__label { opacity: 0 !important; }
body.leaving .stage.has-lit .fish:not(.lit) { opacity: 1; }
.pond.away { opacity: 0; filter: blur(3px); pointer-events: none; }

/* --- Sections ("another part of the pond") ----------------------- */
.shore {
  position: fixed; inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  opacity: 0;
  transition: opacity .8s ease;
}
.shore.shown { opacity: 1; }
.shore[hidden] { display: none; }
.shore__bg {
  position: fixed; inset: -4%;
  background: url(../assets/background.webp) var(--bgpos, 80% 90%) / 140% auto no-repeat, var(--paper);
  opacity: .32;
  filter: blur(1.5px);
  pointer-events: none;
  transform: translate(var(--bgx, 0), var(--bgy, 0));
  transition: transform 1.4s var(--ease-out);
}
@media (max-aspect-ratio: 1/1) {
  .shore__bg { background-size: auto 115%, auto; }
}
.shore.shown .shore__bg { --bgx: 0 !important; --bgy: 0 !important; }
.shore::before {
  /* soft wash so the text has calm paper behind it */
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 60% 80% at 50% 45%, rgba(var(--wash),.92), rgba(var(--wash),.55) 70%, rgba(var(--wash),.2));
}

.section {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
  padding: 120px 24px 80px;
  font-size: 18px; line-height: 1.7;
}
.section[hidden] { display: none; }
.section > *:not(.section__fish) {
  opacity: 0; transform: translateY(14px);
  transition: opacity .8s ease, transform 1s var(--ease-out);
}
.shore.shown .section > * { opacity: 1; transform: none; }
.shore.shown .section > :nth-child(2) { transition-delay: .25s; }
.shore.shown .section > :nth-child(3) { transition-delay: .35s; }
.shore.shown .section > :nth-child(4) { transition-delay: .45s; }
.shore.shown .section > :nth-child(n+5) { transition-delay: .55s; }

.section__fish {
  width: 240px; margin: 0 0 18px -8px;
  opacity: 0;
}
.section__fish img {
  width: 100%; height: auto;
  animation: sway 9s ease-in-out infinite, drift 14s ease-in-out infinite;
  transform-origin: 95% 50%;
}
.section[data-route="music"] .section__fish { width: 170px; }
.section[data-route="music"] .section__fish img { transform-origin: 5% 10%; }
.shore.shown .section__fish { animation: swim-in 1.6s var(--ease-out) .1s forwards; }
@keyframes swim-in {
  from { opacity: 0; transform: translateX(calc(var(--in, -1) * 120px)); }
  to   { opacity: 1; transform: none; }
}

.eyebrow {
  margin: 0;
  font-family: var(--display);
  text-transform: uppercase; letter-spacing: .22em; font-size: 13px; font-weight: 600;
  color: var(--seal);
}
.section h1:focus { outline: none; }
.section h1 {
  margin: 6px 0 22px;
  font-family: var(--display); font-weight: 500;
  font-size: clamp(38px, 6vw, 54px); line-height: 1.08; letter-spacing: -.005em;
}
.section h2 {
  margin: 48px 0 12px;
  font-family: var(--display); font-weight: 600;
  font-size: 15px; text-transform: uppercase; letter-spacing: .18em;
  color: var(--ink-soft);
}
.lede { font-size: 20px; color: var(--ink-soft); }
.section a { text-decoration-color: var(--ink-faint); text-underline-offset: .18em; }
.section a:hover { text-decoration-color: var(--seal); }
.soon {
  font-family: var(--display); font-style: italic;
  font-size: 24px; color: var(--ink-soft);
}

.links { display: flex; gap: 22px; padding: 0; list-style: none; margin-top: 32px; }

.posts { list-style: none; padding: 0; margin: 28px 0 0; }
.posts a {
  display: grid; grid-template-columns: 100px 1fr; gap: 16px; align-items: baseline;
  padding: 16px 0; border-top: 1px solid var(--ink-faint);
  text-decoration: none;
}
.posts li:last-child a { border-bottom: 1px solid var(--ink-faint); }
.posts time { font-size: 14px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.posts span { font-family: var(--display); font-size: 24px; font-weight: 500; }
.posts a:hover span { color: var(--seal); }

.tracks { margin: 28px 0; border-top: 1px solid var(--ink-faint); }
.track {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: baseline;
  padding: 14px 0; border-bottom: 1px solid var(--ink-faint);
}
.track__n { font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.track__t { font-family: var(--display); font-size: 22px; font-weight: 500; }
.track__m { font-size: 14px; color: var(--ink-soft); }

/* --- Professional: résumé laid out like a scroll of notes --- */
.section h3 {
  margin: 0; font-family: var(--display); font-weight: 600;
  font-size: 28px; line-height: 1.15;
}
.job__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 16px; }
.job__meta { margin: 0; font-size: 15px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* roles hang off a thin ink line, the current one marked with a seal-red dot */
.roles { list-style: none; margin: 18px 0 0; padding: 0 0 0 26px; position: relative; }
.roles::before {
  content: ""; position: absolute; left: 5px; top: 10px; bottom: 14px; width: 1px;
  background: linear-gradient(var(--ink-faint), var(--ink-faint) 80%, transparent);
}
.role { position: relative; padding-bottom: 22px; }
.role::before {
  content: ""; position: absolute; left: -26px; top: 9px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--paper); border: 1px solid var(--ink-soft);
}
.role--now::before { background: var(--seal); border-color: var(--seal); }
.role h4 { margin: 0 0 6px; font-family: var(--display); font-weight: 600; font-size: 21px; line-height: 1.25; }
.role ul { margin: 0; padding-left: 1.1em; font-size: 16.5px; line-height: 1.6; }
.role li { margin: 4px 0; }
.role li::marker { color: var(--ink-faint); }

.h2-note { margin: -6px 0 10px; font-size: 15px; color: var(--ink-soft); font-style: italic; }
.papers { list-style: none; margin: 0; padding: 0; }
.papers li {
  display: grid; grid-template-columns: 84px 1fr; gap: 16px; align-items: baseline;
  padding: 11px 0; border-top: 1px solid var(--ink-faint);
}
.papers li:last-child { border-bottom: 1px solid var(--ink-faint); }
.papers > li > :first-child { font-size: 14px; color: var(--ink-soft); }
.papers a { text-decoration: none; }
.papers a:hover cite { color: var(--seal); }
.papers a cite { transition: color .2s ease; }
.section .papers-sub {
  margin: 34px 0 6px; font-family: var(--display); font-weight: 600;
  font-size: 13px !important; text-transform: uppercase; letter-spacing: .16em; color: var(--ink-soft);
}
.papers time { font-size: 14px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.papers cite { font-style: normal; font-family: var(--display); font-size: 21px; font-weight: 500; line-height: 1.3; }



.back {
  position: fixed; left: 24px; bottom: 24px; z-index: 5;
  font-family: var(--display); font-style: italic; font-size: 17px;
  text-decoration: none; color: var(--ink-soft);
  padding: 8px 14px 8px 30px;
  background: rgba(var(--wash),.8);
  border-radius: 999px;
  backdrop-filter: blur(4px);
  opacity: 0; transition: opacity .6s ease .6s, color .3s ease;
}
.back::before {
  content: ""; position: absolute; left: 13px; top: 50%;
  width: 10px; height: 1px; background: currentColor;
}
.shore.shown .back { opacity: 1; }
.back:hover { color: var(--ink); }

body[data-view="section"] .mark__name { opacity: .9; }

@media (max-width: 560px) {
  .mark { top: 16px; left: 16px; }
  .mark__name { font-size: 19px; }
  .fish__label { --fs: 17px; }
  .legend { bottom: 12px; padding: 10px 16px 8px; }
  .legend ul { gap: 4px; }
  .legend li + li::before { margin-right: 4px; }
  .legend a { font-size: 12px; letter-spacing: .1em; padding: 6px 2px; }
  .section { padding: 96px 16px 100px; font-size: 17px; }
  .section__fish { width: 180px; }
  .section h3 { font-size: 25px; }
  .papers li { grid-template-columns: 1fr; gap: 2px; }
  .papers cite { font-size: 20px; }
  .posts a { grid-template-columns: 1fr; gap: 2px; }
  .back { left: 16px; bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .fish__sway, .fish img, .section__fish img { animation: none !important; }
  .fish img { filter: none; }
  .evening .fish img { filter: var(--moon); }
  .ripple { display: none; }
  .pond, .shore, .section > * { transition-duration: .3s !important; }
}

/* ------------------------------------------------------------------
   Evening: after dark (visitor's local time) the pond is moonlit.
   The painting is dimmed and cooled; the ink stays dark.
   ------------------------------------------------------------------ */
body.evening {
  --paper: #1b2229;
  --paper-light: #26303a;
  --wash: 24, 31, 39;
  --ink: #dfe5ec;
  --ink-soft: #a9b4c1;
  --ink-faint: rgba(200, 212, 226, 0.3);
  --seal: #d0675a;
  --label-glow: #121820;
  --ripple: rgba(215, 228, 245, .28);
}
body { transition: background-color 1.2s ease; }
/* dim and cool the painting and fish (not the stage, so names stay bright) */
.evening .stage__bg { filter: var(--moon); }
.evening .fish img { filter: url(#water) var(--moon); }
body.evening { --moon: brightness(.5) saturate(.5) sepia(.25) hue-rotate(175deg) saturate(1.3) contrast(1.05); }
body.evening { font-weight: 400; }
.evening .stage.has-lit .fish:not(.lit) { opacity: .6; }
/* a faint pool of moonlight, upper right */
.evening .pond::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 55% 45% at 72% 18%, rgba(205, 220, 240, .14), transparent 70%);
  mix-blend-mode: screen;
}
.evening .stage__bg { /* fade further so the edges sink into the dark page */
  -webkit-mask-image:
    linear-gradient(to right, transparent, #000 10%, #000 90%, transparent),
    linear-gradient(to bottom, transparent, #000 11%, #000 89%, transparent);
  mask-image:
    linear-gradient(to right, transparent, #000 10%, #000 90%, transparent),
    linear-gradient(to bottom, transparent, #000 11%, #000 89%, transparent);
}
.evening .seal { filter: brightness(.85) saturate(.9); }
.evening .signature { filter: brightness(.55) saturate(.6); }
.evening .shore__bg { filter: blur(1.5px) brightness(.45) saturate(.5); opacity: .5; }
.evening .section__fish img { filter: brightness(.62) saturate(.6); }
.evening .legend a.lit, .evening .legend a:hover { color: #f3f6fa; }

/* on section pages, a soft band of paper behind the name so scrolled text
   fades out underneath it instead of colliding with it */
body[data-view="section"] .mark::before {
  content: ""; position: fixed; left: 0; right: 0; top: 0; height: 84px; z-index: -1;
  background: linear-gradient(rgba(var(--wash), .97) 55%, rgba(var(--wash), 0));
  pointer-events: none;
}
