/* ==========================================================================
   Zhi Yang — homepage
   Direction: "Editorial calm" — a quietly set single column, one accent,
   a rounded photo with an apricot tile behind it, and one small Bernese
   Mountain Dog lying at the very bottom of the page (eyes open by day, asleep after dark).
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;

  --paper: #FAF7F1;
  --paper-2: #F2EDE3;
  --ink: #1D2230;
  --ink-2: #4A5060;
  --ink-3: #626878;
  --rule: #E2DACC;
  --rule-strong: #D3C9B8;
  --accent: #A3441D;
  --accent-tint: rgba(163, 68, 29, 0.08);
  --accent-line: rgba(163, 68, 29, 0.38);
  --heart: #C4532C;
  --select: rgba(163, 68, 29, 0.18);
  --highlight: rgba(240, 165, 132, 0.36);   /* the apricot highlighter under the tagline */
  --photo-tile: rgba(232, 144, 106, 0.40);   /* the apricot tile behind the photo */
  --photo-shadow: 0 1px 2px rgba(29, 34, 48, 0.05), 0 12px 32px -18px rgba(29, 34, 48, 0.30);

  /* Bernese Mountain Dog colours */
  --bmd-coat: #24232B;
  --bmd-white: #FBF8F1;
  --bmd-tan: #C0683A;
  --bmd-ear: #383742;
  --bmd-eye: #0E0D12;
  --bmd-line: #1D2230;
  --bmd-soft: #4A4955;
  --bmd-shut: #B9BECA;
  --bmd-outline: #5F6373;   /* the footer dog's outline: soft slate, so it shows on the black coat */
  /* the footer dog: eyes open in light mode, asleep in dark mode */
  --dog-awake: inline;
  --dog-asleep: none;

  --display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --serif: "Newsreader", "Iowan Old Style", Charter, "Palatino Linotype", Georgia, serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --cjk: "Songti SC", "STSong", "Noto Serif CJK SC", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;

  /* The photo. --photo-pos: which part of profile.jpg stays in view (x y);
     raise x to show more of the right side. --photo-zoom: 1 shows the whole
     height; 1.12 zooms in a little so the water bottle at the lower-left
     corner of the picture stays out of the frame. */
  --photo-pos: 64% 38%;
  --photo-zoom: 1.12;
  --photo-w: 236px;      /* width of the photo on wide screens */
  --photo-r: 32px;       /* corner roundness */
  --measure: 44rem;
  --gutter: clamp(16px, 5vw, 32px);
  --section-gap: clamp(3rem, 7vw, 4.25rem);
  --header-h: 54px;
  --paw-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21.2c-3.4 0-6.1-1.8-6.1-4.3 0-2 1.6-3.4 3.1-4.9.9-.9 1.8-1.9 3-1.9s2.1 1 3 1.9c1.5 1.5 3.1 2.9 3.1 4.9 0 2.5-2.7 4.3-6.1 4.3z'/%3E%3Cellipse cx='4.6' cy='10.2' rx='1.9' ry='2.5'/%3E%3Cellipse cx='9.1' cy='5.6' rx='2' ry='2.7'/%3E%3Cellipse cx='14.9' cy='5.6' rx='2' ry='2.7'/%3E%3Cellipse cx='19.4' cy='10.2' rx='1.9' ry='2.5'/%3E%3C/svg%3E") center / contain no-repeat;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #111726;
    --paper-2: #172034;
    --ink: #ECE7DC;
    --ink-2: #B9BECA;
    --ink-3: #9AA1B1;
    --rule: #252F45;
    --rule-strong: #34405A;
    --accent: #F0A584;
    --accent-tint: rgba(240, 165, 132, 0.10);
    --accent-line: rgba(240, 165, 132, 0.42);
    --heart: #F0A584;
    --select: rgba(240, 165, 132, 0.25);
    --highlight: rgba(240, 165, 132, 0.22);
    --photo-tile: rgba(196, 117, 70, 0.42);
    --photo-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 14px 34px -20px rgba(0, 0, 0, 0.7);
    --bmd-coat: #272A36;
    --bmd-ear: #353948;
    --bmd-white: #E7E3DA;
    --bmd-tan: #C47546;
    --bmd-line: #68728E;
    --bmd-soft: #4A536C;
    --bmd-outline: #68728E;
    --dog-awake: none;
    --dog-asleep: inline;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #111726;
  --paper-2: #172034;
  --ink: #ECE7DC;
  --ink-2: #B9BECA;
  --ink-3: #9AA1B1;
  --rule: #252F45;
  --rule-strong: #34405A;
  --accent: #F0A584;
  --accent-tint: rgba(240, 165, 132, 0.10);
  --accent-line: rgba(240, 165, 132, 0.42);
  --heart: #F0A584;
  --select: rgba(240, 165, 132, 0.25);
  --highlight: rgba(240, 165, 132, 0.22);
  --photo-tile: rgba(196, 117, 70, 0.42);
  --photo-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 14px 34px -20px rgba(0, 0, 0, 0.7);
  --bmd-coat: #272A36;
  --bmd-ear: #353948;
  --bmd-white: #E7E3DA;
  --bmd-tan: #C47546;
  --bmd-line: #68728E;
  --bmd-soft: #4A536C;
  --bmd-outline: #68728E;
  --dog-awake: none;
  --dog-asleep: inline;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* keep anchored headings and focused links clear of the sticky bar */
  scroll-padding-top: var(--header-h);
}
/* script.js adds .smooth-scroll once the page and its fonts have loaded. A cold
   load of a #link therefore jumps instantly, so the late web-font swap can't
   leave the heading hidden under the sticky bar; later link clicks glide. */
html.smooth-scroll { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.62;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
  transition: background-color 0.35s ease, color 0.35s ease;
}

::selection { background: var(--select); }

img, svg { display: block; max-width: 100%; }

p, ul, ol, h1, h2, h3 { margin: 0; }
ul, ol { padding: 0; list-style: none; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: var(--accent-line);
  transition: color 0.15s ease, text-decoration-color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}
a:hover { text-decoration-color: currentColor; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}
main:focus { outline: none; }

/* ...plus a little breathing room above a heading you jump to */
main section[id], .pub[id], .entry[id] { scroll-margin-top: 1rem; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: 12px;
  z-index: 50;
  padding: 8px 14px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  font: 600 0.875rem/1.2 var(--sans);
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 0.2s ease;
}
.skip-link:focus { transform: none; }

.wrap {
  width: 100%;
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- Header (sticky; a hairline appears once you scroll) ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--paper);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s ease, background-color 0.35s ease;
}
.site-header.is-stuck { border-bottom-color: var(--rule); }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--header-h);
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px clamp(16px, 3vw, 26px);
}
.site-nav a {
  position: relative;
  display: inline-block;
  padding: 6px 0;
  color: var(--ink-2);
  font: 500 0.875rem/1.2 var(--sans);
  letter-spacing: 0.01em;
  text-decoration: none;
}
.site-nav a:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent-line); text-underline-offset: 0.35em; }
.site-nav a[aria-current="true"] { color: var(--ink); }
/* a tiny terracotta paw marks the section you are reading */
.site-nav a[aria-current="true"]::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -5.5px;
  background: var(--accent);
  -webkit-mask: var(--paw-mask);
  mask: var(--paw-mask);
  transform: rotate(-12deg);
}

/* Theme toggle: a tiny Bernese face */
.theme-toggle {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-right: -8px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.theme-toggle[hidden] { display: none; }
.theme-toggle:hover { background: var(--paper-2); }
.theme-toggle svg { width: 30px; height: 30px; overflow: visible; }
.theme-toggle .coat { fill: var(--bmd-coat); }
.theme-toggle .ear { fill: var(--bmd-ear); }
.theme-toggle .white { fill: var(--bmd-white); }
.theme-toggle .tan { fill: var(--bmd-tan); }
.theme-toggle .nose, .theme-toggle .eye { fill: var(--bmd-eye); }
.theme-toggle .glint { fill: #fff; }
.theme-toggle .line { stroke: var(--bmd-line); stroke-width: 1px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.theme-toggle .tt-sun circle { fill: var(--accent); }
.theme-toggle .tt-sun path { fill: none; stroke: var(--accent); stroke-width: 1.3px; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.theme-toggle .tt-moon { fill: var(--accent); }
.theme-toggle .shut { fill: none; stroke: var(--bmd-shut); stroke-width: 1.2px; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.theme-toggle .cap { fill: var(--accent); }
.theme-toggle .cuff, .theme-toggle .pom { fill: var(--bmd-white); }
.theme-toggle .tt-face { transform-box: view-box; transform-origin: 29px 56px; transition: transform 0.3s ease; }
.theme-toggle:hover .tt-face { transform: rotate(-6deg); }
.theme-toggle .tt-moon, .theme-toggle .tt-asleep { display: none; }
/* night: the toggle's dog puts on its nightcap */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .tt-sun,
  :root:not([data-theme="light"]) .theme-toggle .tt-awake { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .tt-moon,
  :root:not([data-theme="light"]) .theme-toggle .tt-asleep { display: inline; }
}
:root[data-theme="dark"] .theme-toggle .tt-sun,
:root[data-theme="dark"] .theme-toggle .tt-awake { display: none; }
:root[data-theme="dark"] .theme-toggle .tt-moon,
:root[data-theme="dark"] .theme-toggle .tt-asleep { display: inline; }

/* ---------- Hero: text on the left, photo on the right ----------
   Three parts: intro (kicker, name, tagline), figure (photo), body (links,
   email addresses). Wide screens: the photo sits in the right column, its top
   level with the top of the text. Phones (further down): intro, photo, body, stacked. */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--photo-w);
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "intro figure"
    "body  figure";
  column-gap: 44px;
  margin-top: clamp(1.75rem, 5vw, 3rem);
}
.hero-intro { grid-area: intro; min-width: 0; }
.hero-body { grid-area: body; min-width: 0; }

.kicker {
  color: var(--accent);
  font: 600 0.75rem/1.4 var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
/* Break only between phrases, never inside "Data Science" or "William & Mary".
   Beside the photo the kicker is set on two lines: role / place. */
.kicker > span:not(.dot) { white-space: nowrap; }
.kicker .dot-last { display: none; }
.kicker-place { display: block; }

h1 {
  margin-top: 0.55rem;
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2.6rem, 7.4vw, 3.6rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
  color: var(--ink);
}
h1 .cjk {
  display: inline-block;
  margin-left: 0.28em;
  font-family: var(--cjk);
  font-weight: 400;
  font-size: 0.46em;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  vertical-align: 0.12em;
}

.tagline {
  margin-top: 1rem;
  color: var(--ink-2);
  font-style: italic;
  font-size: 1.2rem;
  line-height: 1.5;
  text-wrap: pretty;
}
/* a soft apricot highlighter under the tagline, line by line */
.hl {
  padding: 0 0.12em;
  margin: 0 -0.06em;
  background: linear-gradient(to bottom, transparent 56%, var(--highlight) 56%, var(--highlight) 90%, transparent 90%);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  color: var(--ink);
}
.contact {
  display: grid;
  grid-template-columns: repeat(3, max-content);
  gap: 2px 22px;
  margin-top: 1.15rem;
}
.contact a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 0;
  color: var(--ink);
  font: 500 0.9rem/1.2 var(--sans);
  text-decoration: none;
}
.contact a:hover { color: var(--accent); }
.contact svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.email-list {
  display: inline-grid;        /* as wide as the longer address, so the Copy buttons line up */
  gap: 5px;
  margin-top: 0.7rem;
}
.email-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px 12px;
  color: var(--ink-3);
  font: 500 0.84rem/1.4 var(--sans);
  letter-spacing: 0.01em;
}
.email-text {
  color: var(--ink-2);
  -webkit-user-select: all;
  user-select: all;
}
.copy-btn {
  padding: 2px 9px 3px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-3);
  font: 600 0.7rem/1.3 var(--sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}
.copy-btn[hidden] { display: none; }
.copy-btn:hover { color: var(--accent); border-color: var(--accent-line); }
.copy-btn.is-done { color: var(--accent); border-color: var(--accent-line); background: var(--accent-tint); }

/* ---------- Photo: rounded frame + tinted tile ---------- */
.hero-figure {
  grid-area: figure;
  position: relative;
  isolation: isolate;          /* keeps the tile just behind the photo */
  width: var(--photo-w);
  align-self: start;           /* top of the photo level with the top of the text */
  margin-top: 4px;
  justify-self: end;
  margin-right: 16px;          /* nudged in, so the tile behind it ends level with the text column */
}
/* the soft tile peeking out behind the photo */
.hero-figure::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: var(--photo-r);
  background: var(--photo-tile);
  transform: rotate(5deg) translate(14px, 6px);
}
.photo-frame {
  position: relative;
  overflow: hidden;
  isolation: isolate;          /* Safari: clip the zoomed photo to the rounded corners */
  aspect-ratio: 11 / 12;
  border-radius: var(--photo-r);
  background: var(--paper-2);
  box-shadow: var(--photo-shadow);
}
.portrait {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--photo-pos);
  transform: scale(var(--photo-zoom));
  transform-origin: var(--photo-pos);
}

/* ---------- About (rest of the bio) ---------- */
.about { margin-top: 2.9rem; }
.about p + p { margin-top: 1.05em; }

/* ---------- Sections ---------- */
main > section:not(.hero):not(.about) { margin-top: var(--section-gap); }

h2 {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 1.35rem;
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.6rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink);
}
h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
  transform: translateY(0.12em);
}

h3 {
  font-family: var(--display);
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.003em;
}

.muted { color: var(--ink-2); }
.nowrap { white-space: nowrap; }

/* Interests, in two tiers */
.tag-tier {
  display: grid;
  grid-template-columns: 3.4rem minmax(0, 1fr);
  align-items: start;
  gap: 10px;
}
.tag-tier + .tag-tier { margin-top: 12px; }
.tier-label {
  padding-top: 8px;
  color: var(--ink-3);
  font: 600 0.6875rem/1.4 var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.tags li {
  padding: 6px 14px 7px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  color: var(--ink-2);
  font: 500 0.875rem/1.25 var(--sans);
}
.tags-core li {
  border-color: var(--accent-line);
  background: var(--accent-tint);
  color: var(--accent);
  font-weight: 600;
}

/* Publications */
.pub { padding: 1.5rem 0; }
.pub:first-child { padding-top: 0.2rem; }
.pub + .pub { border-top: 1px solid var(--rule); }

.pub-badges {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0.55rem;
}
.badge {
  display: inline-block;
  padding: 3px 9px 3px;
  border: 1px solid var(--accent-line);
  border-radius: 4px;
  background: var(--accent-tint);
  color: var(--accent);
  font: 650 0.6875rem/1.3 var(--sans);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.badge-preprint {
  background: transparent;
  border-style: dashed;
}
.pub-year {
  color: var(--ink-3);
  font: 500 0.8125rem/1 var(--sans);
  font-variant-numeric: tabular-nums;
}

.pub-title {
  font-size: 1.24rem;
  line-height: 1.3;
  text-wrap: pretty;
}
.pub-authors {
  margin-top: 0.45rem;
  color: var(--ink-2);
  font-size: 1.02rem;
}
.me {
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--accent-line);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.2em;
}
.pub-venue {
  color: var(--ink-2);
  font-style: italic;
  font-size: 1rem;
  line-height: 1.5;
}
.pub-summary {
  margin-top: 0.6rem;
  padding-left: 14px;
  border-left: 2px solid var(--rule);
  color: var(--ink-2);
  font-size: 0.98rem;
  line-height: 1.55;
}
.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 0.85rem;
}
.pub-links a {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 13px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  color: var(--accent);
  font: 600 0.78rem/1.2 var(--sans);
  letter-spacing: 0.04em;
  text-decoration: none;
}
.pub-links a:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-tint);
}

/* Entries: projects, education, teaching */
.entry { padding: 0.95rem 0; }
.entry:first-child { padding-top: 0.15rem; }
.entry + .entry { border-top: 1px solid var(--rule); }

.entry-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 20px;
}
.entry-head h3 {
  font-size: 1.1rem;
  line-height: 1.35;
  text-wrap: pretty;
}
.when {
  flex: none;
  color: var(--ink-3);
  font: 500 0.8125rem/1.4 var(--sans);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.entry-place {
  margin-top: 0.1rem;
  color: var(--ink-2);
  font-style: italic;
  font-size: 1.02rem;
}
.entry-body {
  margin-top: 0.3rem;
  color: var(--ink-2);
  font-size: 1.02rem;
  line-height: 1.55;
}
.entry-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin-top: 0.4rem;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px 2px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  color: var(--ink-3);
  font: 650 0.66rem/1.45 var(--sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.pill-live {
  border-color: var(--accent-line);
  background: var(--accent-tint);
  color: var(--accent);
}
.pill-live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pill-note {
  border-color: transparent;
  background: var(--paper-2);
  color: var(--ink-2);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  text-transform: none;
}
.meta-link {
  font: 600 0.8rem/1.4 var(--sans);
  letter-spacing: 0.02em;
}
.entry-compact .entry-meta { margin-top: 0.3rem; }
.entry-compact .entry-head h3 { font-size: 1.02rem; }

/* Honors */
.honors li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 24px;
  padding: 0.6rem 0;
  font-size: 1.02rem;
  line-height: 1.5;
}
.honors li:first-child { padding-top: 0.1rem; }
.honors li + li { border-top: 1px solid var(--rule); }
.honors time, .honors .date {
  flex: none;
  color: var(--ink-3);
  font: 500 0.8125rem/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- Footer: paw prints lead along the line to the dog ---------- */
.site-footer {
  margin-top: clamp(2.25rem, 5vw, 3rem);
  padding-bottom: clamp(2rem, 6vw, 3.25rem);
  /* Size of the dog: the width of its drawing, about 101px (the height
     follows). Phones use a smaller value under "Responsive" below. */
  --dog-w: 101.475px;
}
/* The strip above the line: the paw prints, the dog, and room above it for
   the heart that floats up when you pet it. Make it taller if you make the
   dog much bigger (phones: under "Responsive" below). */
.footer-ground {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 14px;
  height: 90px;
}

/* three paw prints on the way to the dog: toes toward it, fainter further back */
.paw-trail {
  display: flex;
  align-items: flex-end;
  gap: 15px;
  padding-bottom: 4px;        /* just above the line */
  color: var(--ink-3);
}
.paw-trail svg { width: 12px; height: 12px; fill: currentColor; }
.paw-trail svg:nth-child(1) { rotate: 82deg; translate: 0 -4px; opacity: 0.36; }
.paw-trail svg:nth-child(2) { rotate: 98deg; opacity: 0.48; }
.paw-trail svg:nth-child(3) { rotate: 82deg; translate: 0 -4px; opacity: 0.6; }

.footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  padding-top: 1.1rem;
  border-top: 1px solid var(--rule-strong);   /* the line the dog lies on */
  color: var(--ink-3);
  font: 500 0.8125rem/1.5 var(--sans);
}
.footer-row .sep { margin: 0 0.35em; }
.footer-row a { color: var(--ink-2); text-decoration: none; }
.footer-row a:hover { color: var(--accent); }

/* ---------- The Bernese Mountain Dog (awake by day, asleep after dark) ----------
   A real button ("Pet the dog" / "Pet the sleeping dog"). Its drawing is in index.html,
   the breathing and petting in script.js. */
.dog {
  position: relative;
  flex: none;
  width: var(--dog-w);
  aspect-ratio: 196 / 84;     /* the drawing's own shape */
  margin-right: 1.5px;        /* its box ends just inside the column */
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.dog:focus-visible { outline-offset: 4px; }

/* The drawing faces right; mirrored, the dog faces back along its paw prints. */
.dog-art {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: scaleX(-1);
}

/* Paint (the colours are the --bmd-* tokens at the top of this file). The
   outline: every part is drawn twice, a 3px stroke underneath (.ol, so 1.5px
   shows outside) and the fill on top (.fl). */
.dog-art {
  --dog-line: var(--bmd-outline);
  --dog-sheen: var(--bmd-soft);
  --dog-toe: var(--bmd-soft);
  --c-coat: var(--bmd-coat);
  --c-tan: var(--bmd-tan);
  --c-white: var(--bmd-white);
}
.dog-art .far { --c-coat: var(--bmd-ear); }   /* the far front paw, a shade back */
@supports (color: color-mix(in oklab, red, blue)) {
  .dog-art { --dog-toe: color-mix(in oklab, var(--bmd-white) 62%, var(--bmd-coat)); }
  .dog-art .far { --c-coat: color-mix(in oklab, var(--bmd-coat) 72%, var(--bmd-soft)); }
}
.dog-art .fl { fill: var(--c-coat); stroke: none; }
.dog-art .ol {
  --ol: var(--dog-line);   /* read by the parts' inline stroke */
  --olw: 3px;
  fill: var(--dog-line);
}
.dog-art .ground-shadow { fill: var(--ink); opacity: 0.07; }
/* Its eyes. Light mode: open (dark brown, with a glint). Dark mode: closed,
   a soft lid line with lashes, and the z's show. Which one shows is set by
   --dog-awake / --dog-asleep with the theme colours at the top of this file. */
.dog-art .eye-open { display: var(--dog-awake); }
.dog-art .lid, .dog-art .z-group { display: var(--dog-asleep); }
.dog-art .eye-iris { fill: #3B2417; stroke: #7A5640; stroke-width: 0.7px; vector-effect: non-scaling-stroke; }
.dog-art .eye-glint { fill: #FFFFFF; }
.dog-art .lid { fill: none; stroke: #8A93AD; stroke-width: 1px; stroke-linecap: round; vector-effect: non-scaling-stroke; }
/* the z's, mirrored back so they read the right way round */
.dog-art .z {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.1px;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform-box: fill-box;
}
.dog-art .z2 { stroke-width: 2.4px; }
.dog-art .z-group { transform-box: fill-box; transform-origin: 50% 50%; transform: scaleX(-1); }

/* the heart that floats up over its back when you pet it */
.dog .heart {
  position: absolute;
  left: 48.8%;
  top: -5.5px;
  width: 15px;
  height: 15px;
  margin-left: -7.5px;
  fill: var(--heart);
  opacity: 0;
  pointer-events: none;
}

/* Breathing: while the footer is on screen, script.js now and then adds
   .is-stirring and sets --breaths, the number of slow breaths to take (awake,
   it blinks once in each; asleep, its z's drift); then the animation ends by
   itself, so nothing loops for ever. Petting it (.is-petted) shows the heart and thumps its tail.
   --breath-time is how long one breath takes: slow it down or speed it up
   here (script.js follows along by itself). */
.dog { --breath-time: 5.2s; }
.dog-art .s-breathe { transform-box: view-box; transform-origin: 96px 82px; }
.dog-art .s-head { transform-box: view-box; transform-origin: 150px 80px; }
.dog-art .s-tail { transform-box: view-box; transform-origin: 36px 80px; }
.dog.is-stirring .s-breathe { animation: s-breathe var(--breath-time) ease-in-out var(--breaths, 1); }
.dog.is-stirring .s-head { animation: s-head var(--breath-time) ease-in-out var(--breaths, 1); }
.dog.is-stirring .z1 { animation: z-drift var(--breath-time) ease-in-out var(--breaths, 1); }
.dog.is-stirring .z2 { animation: z-drift2 var(--breath-time) ease-in-out var(--breaths, 1); }
.dog-art .eye-open { transform-box: fill-box; transform-origin: 50% 55%; }
.dog.is-stirring .eye-open { animation: blink var(--breath-time) ease-in-out var(--breaths, 1); }
.dog.is-petted .s-tail { animation: thump 0.26s ease-in-out 6 alternate; }
.dog.is-petted .heart { animation: heart-rise 1.6s ease-out forwards; }
/* Without JavaScript (script.js marks the page .js when it runs), pressing
   the dog still shows the heart, which fades a moment after you let go. */
html:not(.js) .dog .heart { transition: opacity 0.6s ease-in 0.5s; }
html:not(.js) .dog:active .heart { opacity: 1; transition: none; }

@keyframes s-breathe {
  0%, 100% { transform: scale(1, 1); }
  45%      { transform: scale(1.012, 1.045); }
}
@keyframes s-head {
  0%, 100% { transform: translateY(0); }
  45%      { transform: translateY(-0.9px); }
}
@keyframes z-drift {
  0%, 100% { opacity: 1; transform: translate(0, 0); }
  50%      { opacity: 0.35; transform: translate(2.5px, -4px); }
}
/* the big z drifts a beat later in the same breath, so both are still at its end */
@keyframes z-drift2 {
  0%, 18%, 100% { opacity: 1; transform: translate(0, 0); }
  62%           { opacity: 0.35; transform: translate(2.5px, -4px); }
}
/* one quick blink, late in each breath */
@keyframes blink {
  0%, 60%, 68%, 100% { transform: scaleY(1); }
  64%                { transform: scaleY(0.1); }
}
@keyframes thump {
  from { transform: rotate(0deg); }
  to   { transform: rotate(-4deg); }
}
@keyframes heart-rise {
  0%   { opacity: 0; transform: translateY(5px) scale(0.5); }
  18%  { opacity: 1; transform: translateY(0) scale(1.1); }
  30%  { transform: translateY(-1px) scale(1); }
  100% { opacity: 0; transform: translateY(-16px) scale(0.95); }
}

/* ---------- Responsive ---------- */

/* Tablets: keep two columns, shrink the photo a little */
@media (max-width: 820px) {
  :root { --photo-w: clamp(196px, 28vw, 224px); }
  .hero { column-gap: 40px; }
  .hero-figure { margin-right: 10px; }
  .hero-figure::before { transform: rotate(4deg) translate(9px, 5px); }
}

/* Phones: stack — name and tagline, then the photo (centred), then the rest */
@media (max-width: 640px) {
  :root { --photo-w: min(230px, 64vw); }
  body { font-size: 1.0625rem; line-height: 1.6; }

  .hero {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas:
      "intro"
      "figure"
      "body";
    margin-top: 1.25rem;
  }
  .hero-figure { justify-self: center; margin: 2rem 0 1.9rem; }
  .hero-figure::before { transform: rotate(4deg) translate(8px, 4px); }

  .kicker { font-size: 0.6875rem; letter-spacing: 0.1em; }
  .kicker .dot-last { display: inline; }
  .kicker-place { display: inline; }
  h1 { font-size: clamp(2.3rem, 11vw, 2.8rem); }
  h1 .cjk { font-size: 0.5em; }
  .tagline { margin-top: 0.85rem; font-size: 1.12rem; }
  .contact { display: grid; grid-template-columns: repeat(3, max-content); gap: 2px 22px; }

  .about { margin-top: 2.25rem; }
  h2 { font-size: 1.42rem; gap: 14px; }

  /* interests: each small label sits above its pills, so the pills get the full width */
  .tag-tier { grid-template-columns: minmax(0, 1fr); gap: 7px; }
  .tag-tier + .tag-tier { margin-top: 16px; }
  .tier-label { padding-top: 0; }
  .tags { gap: 8px; }
  .tags li { padding: 5px 12px 6px; font-size: 0.84rem; }

  .entry-head { flex-direction: column; gap: 1px; }
  .honors li { flex-direction: column; gap: 0; }

  /* a slightly smaller dog, a shorter strip and closer paw prints */
  .site-footer { --dog-w: 89.175px; }
  .footer-ground { height: 82px; }
  .paw-trail { gap: 12px; }
}
/* Mobile nav: one scrollable row with a soft fade at the edge */
@media (max-width: 600px) {
  :root { --header-h: 50px; }
  .header-inner { gap: 6px; }
  .site-nav {
    flex: 1;
    min-width: 0;
    margin-left: calc(-1 * var(--gutter));
    padding-left: var(--gutter);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }
  .site-nav.is-scrolled-x {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 22px, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, transparent, #000 22px, #000 calc(100% - 28px), transparent);
  }
  .site-nav.is-at-end {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 22px);
    mask-image: linear-gradient(to right, transparent, #000 22px);
  }
  .site-nav::-webkit-scrollbar { display: none; }
  /* 6px of extra room above and below (cancelled by the negative margin) so the
     scroller doesn't clip the focus ring. script.js scrolls a focused link clear
     of the edge fades. */
  .site-nav { padding-block: 6px; margin-block: -6px; }
  .site-nav ul { flex-wrap: nowrap; gap: 0 20px; width: max-content; padding: 0 28px 0 2px; }
  .site-nav a { padding: 8px 0; font-size: 0.86rem; }
  .theme-toggle { margin-right: -6px; }
}

/* Narrow phones: the kicker goes back to two lines, links wrap freely */
@media (max-width: 379px) {
  .kicker .dot-last { display: none; }
  .kicker-place { display: block; }
}
@media (max-width: 359px) {
  .contact { display: flex; flex-wrap: wrap; gap: 2px 18px; }
}

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    transition-delay: 0s !important;
  }
  .theme-toggle:hover .tt-face { transform: none; }
  html.smooth-scroll { scroll-behavior: auto; }
  /* The dog lies quite still: no breathing, blinking, drifting z's or
     thumping tail, and a pet just shows the heart over its back. */
  .dog .s-breathe, .dog .s-head, .dog .s-tail, .dog .z, .dog .eye-open, .dog .heart { animation: none !important; }
  .dog.is-petted .heart { opacity: 1; }
}

/* ---------- Windows High Contrast / forced colours ---------- */
@media (forced-colors: active) {
  .site-nav a[aria-current="true"]::before { forced-color-adjust: none; background: CanvasText; }
  .dog-art .ol { --ol: CanvasText; fill: CanvasText; }
  .site-nav a[aria-current="true"] { text-decoration: underline; text-underline-offset: 0.35em; }
}

/* ---------- Print ---------- */
@media print {
  .site-header, .footer-ground, .skip-link, .copy-btn { display: none !important; }
  .hero-figure::before { display: none; }
  .footer-row { border-top-color: #999; }
  body { background: #fff; color: #000; }
  a { color: inherit; }
}
