/* =========================================================
   Design tokens
   Change these and the whole page follows.
   ========================================================= */
:root {
  --ink:      #1c1e22;  /* body text          — 15.0:1 on white */
  --muted:    #5d646f;  /* secondary text     —  6.0:1 on white */
  --accent:   #1d4ed8;  /* links              —  6.7:1 on white */
  --accent-deep: #1a3f9e;  /* on tinted backgrounds — 8.4:1 on --accent-soft */
  --accent-soft: #eef2ff;  /* venue tag background */
  --rule:     #e3e5e9;  /* hairlines          */
  --rule-strong: #ccd2dc;  /* hairlines on hover */
  --bg:       #ffffff;
  --bg-soft:  #f7f8fa;  /* image placeholders */

  /* Kept deliberately shallow — these read as paper, not as floating cards */
  --shadow-sm: 0 1px 2px rgb(16 24 40 / 5%);
  --shadow-md: 0 2px 4px rgb(16 24 40 / 5%), 0 10px 24px rgb(16 24 40 / 7%);
  --shadow-lg: 0 12px 40px rgb(16 24 40 / 18%);

  /* 4/8px spacing rhythm */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-6: 24px;
  --s-8: 32px;
  --s-12: 48px;
  --s-16: 64px;

  --measure: 760px;     /* content width */
  --radius: 6px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
               Helvetica, Arial, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 17px;
  line-height: 1.65;
  /* Slightly tighter tracking reads better at this size on light backgrounds */
  letter-spacing: -0.003em;
}

/* A soft wash behind the header, fading to white by the time the content starts.
   Gives the page a top without drawing another rule across it. */
body::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 420px;
  background: linear-gradient(180deg, #f4f7fb 0%, rgb(244 247 251 / 0%) 100%);
  z-index: -1;
  pointer-events: none;
}

::selection {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.page {
  max-width: var(--measure);
  margin: 0 auto;
  padding: var(--s-16) var(--s-6) var(--s-12);
}

img { max-width: 100%; height: auto; display: block; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 150ms ease-out;
}
a:hover { color: var(--ink); }

/* Visible keyboard focus everywhere — never remove this without a replacement */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: var(--s-4);
  top: var(--s-4);
  z-index: 10;
  padding: var(--s-2) var(--s-3);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  text-decoration: none;
}

/* =========================================================
   Header
   ========================================================= */
.intro {
  display: flex;
  align-items: flex-start;
  gap: var(--s-8);
  margin-bottom: var(--s-16);
}

/* Square, not a circle: a circular frame clips the corners, and the portrait is a
   full scene that should stay intact. `contain` guarantees no crop even if a
   non-square image is swapped in later. */
.avatar {
  flex: 0 0 auto;
  width: 220px;
  height: 220px;
  border-radius: 10px;
  object-fit: contain;
  background: var(--bg-soft);
  box-shadow: var(--shadow-md);
}

.intro-text { min-width: 0; }

h1 {
  margin: 0;
  font-size: 38px;
  line-height: 1.15;
  font-weight: 650;
  letter-spacing: -0.028em;
}

.tagline {
  margin: var(--s-2) 0 0;
  font-size: 17px;
  font-weight: 500;
  color: var(--accent-deep);
}

.affiliations {
  margin: var(--s-3) 0 0;
  padding: 0;
  list-style: none;
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
}
.affiliations li + li { margin-top: var(--s-1); }

.contact {
  margin: var(--s-4) 0 0;
  font-size: 15px;
  color: var(--muted);
}

/* =========================================================
   Sections
   ========================================================= */
.section { margin-bottom: var(--s-16); }

h2 {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin: 0 0 var(--s-6);
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink);
}
.section h2::before {
  content: "";
  flex: 0 0 auto;
  width: 20px;
  height: 2px;
  border-radius: 1px;
  background: var(--accent);
}

.section p { margin: 0 0 var(--s-4); }
.section p:last-child { margin-bottom: 0; }

/* =========================================================
   Publications
   ========================================================= */
.pub-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.pub {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--s-6);
  align-items: start;
}
.pub + .pub {
  margin-top: var(--s-12);
  padding-top: var(--s-12);
  border-top: 1px solid var(--rule);
}

.pub-thumb {
  display: block;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-soft);
  box-shadow: var(--shadow-sm);
  /* Reserving the box keeps the list from reflowing as thumbnails load */
  aspect-ratio: 16 / 10;
  transition: border-color 180ms ease-out, box-shadow 180ms ease-out;
}
/* Hovering anywhere in the entry lifts its figure, so the whole row reads as one unit */
.pub:hover .pub-thumb {
  border-color: var(--rule-strong);
  box-shadow: var(--shadow-md);
}
/* `contain`, not `cover`: these are wide multi-panel figures and cropping them to a
   16:10 box cuts off the parts that carry the meaning. */
.pub-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.pub-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.38;
  font-weight: 600;
  letter-spacing: -0.012em;
}
.pub-title a {
  color: var(--ink);
  text-decoration: none;
}
.pub-title a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.pub-authors {
  margin: var(--s-2) 0 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
}
.pub-authors .self {
  color: var(--ink);
  font-weight: 600;
}

/* Venue as a tag rather than grey italics — it is the line readers scan for,
   so it earns the only patch of colour in the entry. */
.pub-venue {
  display: inline-block;
  margin: var(--s-3) 0 0;
  padding: 3px var(--s-3);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
}

.pub-desc {
  margin: var(--s-3) 0 0;
  font-size: 15px;
  line-height: 1.55;
}

.pub-links {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s-3);
  margin: var(--s-3) 0 0;
  font-size: 14px;
}

/* A real element, not a pseudo-element on the link. Generated content inside an <a>
   inherits its underline and colour and joins its hit area — which is what made the
   old separators look and behave like links. */
.pub-sep {
  color: var(--rule);
  user-select: none;
}

/* A button that reads as a link — it opens a dialog rather than navigating,
   so it must be a <button>, but it belongs visually with its neighbours. */
.bib-btn {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  cursor: pointer;
  transition: color 150ms ease-out;
}
.bib-btn:hover { color: var(--ink); }

/* =========================================================
   BibTeX dialog
   ========================================================= */
.bib-dialog {
  width: min(680px, calc(100vw - 2 * var(--s-6)));
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 10px;
  color: var(--ink);
  background: var(--bg);
  box-shadow: var(--shadow-lg);
}
.bib-dialog::backdrop { background: rgb(0 0 0 / 45%); }

.bib-inner { padding: var(--s-6); }

.bib-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-4);
}
.bib-head h2 {
  margin: 0;
  padding: 0;
  border: 0;
}

.bib-close,
.bib-copy {
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  /* 44px minimum touch target */
  min-height: 44px;
  cursor: pointer;
  transition: border-color 150ms ease-out, color 150ms ease-out;
}
.bib-close:hover,
.bib-copy:hover { border-color: var(--accent); color: var(--accent); }

.bib-copy { margin-top: var(--s-4); }

.bib-dialog pre {
  margin: 0;
  padding: var(--s-4);
  border-radius: var(--radius);
  background: var(--bg-soft);
  /* Long BibTeX lines scroll inside the block instead of widening the dialog */
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
}

/* =========================================================
   Experience
   ========================================================= */
.exp-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.exp + .exp { margin-top: var(--s-6); }

/* Org left, dates right — the ledger alignment reads as a CV at a glance.
   Wrapping puts the date on its own line rather than squeezing the name. */
.exp-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2) var(--s-3);
}

.exp-org {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}
.exp-org a {
  color: var(--ink);
  text-decoration: none;
}
.exp-org a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.exp-date {
  font-size: 13px;
  color: var(--muted);
  /* Equal-width digits keep the two date ranges aligned with each other */
  font-variant-numeric: tabular-nums;
}

.exp-desc {
  margin: var(--s-2) 0 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--muted);
}

/* =========================================================
   Footer
   ========================================================= */
.footer {
  padding-top: var(--s-6);
  border-top: 1px solid var(--rule);
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}
.footer p { margin: 0; }

/* =========================================================
   Small screens
   ========================================================= */
@media (max-width: 640px) {
  body { font-size: 16px; }

  .page { padding: var(--s-12) var(--s-4) var(--s-8); }

  .intro {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--s-6);
    margin-bottom: var(--s-12);
  }

  .avatar { width: 180px; height: 180px; }

  .affiliations { font-size: 14px; }

  h1 { font-size: 28px; }

  .section { margin-bottom: var(--s-12); }

  /* Thumbnail above text reads better than a cramped two-column row */
  .pub {
    grid-template-columns: 1fr;
    gap: var(--s-3);
  }
}

/* =========================================================
   Preferences
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .skip-link { display: none; }
  .page { max-width: none; padding: 0; }
  a { color: var(--ink); }
}
