/* ---------------------------------------------------------------
   Design tokens. Light palette is defined here in full; the two
   blocks below only redefine values, never introduce new ones.
   --------------------------------------------------------------- */
:root {
  --paper:      #fbfaf9;
  --surface:    #ffffff;
  --ink:        #1a1615;
  --ink-soft:   #4d4644;
  --ink-mute:   #7c7471;
  --rule:       #e7e1df;
  --accent:     #bd2437;
  --accent-dim: #fae9eb;
  --rule-accent:#ecc8cd;
  --focus:      #c04553;

  --font-display: "Newsreader", Georgia, "Times New Roman", serif;
  --font-body:    "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --measure: 34rem;
  --gutter:  8.5rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:      #141110;
    --surface:    #1c1817;
    --ink:        #ece8e6;
    --ink-soft:   #bcb4b1;
    --ink-mute:   #8e8683;
    --rule:       #332d2c;
    --accent:     #ea8f96;
    --accent-dim: #332225;
    --rule-accent:#4d3035;
    --focus:      #e08b90;
  }
}

:root[data-theme="dark"] {
  --paper:      #141110;
  --surface:    #1c1817;
  --ink:        #ece8e6;
  --ink-soft:   #bcb4b1;
  --ink-mute:   #8e8683;
  --rule:       #332d2c;
  --accent:     #ea8f96;
  --accent-dim: #332225;
  --rule-accent:#4d3035;
  --focus:      #e08b90;
}

/* --------------------------------------------------------------- */

html { font-size: 15.5px; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 54rem;
  margin: 0 auto;
  padding-inline: 1.5rem;
  padding-block: 1.5rem 5rem;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { color: var(--ink); }

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

/* --- Navigation ------------------------------------------------- */

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.75rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding-bottom: 2.25rem;
}
.nav a {
  color: var(--accent);
  text-decoration: none;
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] {
  color: var(--accent);
  font-weight: 500;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 2px;
}

/* --- Masthead --------------------------------------------------- */

.masthead { display: flex; flex-direction: column; gap: 1.05rem; }

h1.name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.2rem, 5.4vw, 2.95rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0;
  text-wrap: balance;
}

.affiliation {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: -0.5rem 0 0;
  line-height: 1.5;
}

.bio {
  max-width: var(--measure);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0;
}
.bio strong { color: var(--ink); font-weight: 600; }

.contact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
}
.contact a { text-decoration: none; border-bottom: 1px solid var(--accent-dim); }
.contact a:hover { border-bottom-color: var(--accent); }

/* --- Section headings ------------------------------------------- */

.section { padding-top: 2.6rem; }

h2.section-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1.15rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule-accent);
}

/* --- Updates: date gutter + entry ------------------------------- */

.updates { display: flex; flex-direction: column; }

.update {
  display: grid;
  grid-template-columns: var(--gutter) 1fr;
  gap: 0 1.5rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--rule);
}
.update:last-child { border-bottom: none; }

.update-date {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--accent);
  padding-top: 0.28rem;
  font-variant-numeric: tabular-nums;
}
.update-title {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  line-height: 1.35;
  margin: 0;
  font-weight: 450;
}
.update-title a {
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--rule-accent);
}
.update-title a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.update-venue {
  font-size: 0.875rem;
  color: var(--ink-mute);
  margin: 0.15rem 0 0;
}

/* --- Papers ----------------------------------------------------- */

.papers { display: flex; flex-direction: column; }

.paper {
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--rule);
  max-width: 44rem;
}
.paper:last-child { border-bottom: none; }
.paper[hidden] { display: none; }

.paper-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.3;
  margin: 0;
  text-wrap: balance;
}
.paper-authors {
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin: 0.35rem 0 0;
}
.paper-venue {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin: 0.4rem 0 0;
}
.paper-abstract {
  font-size: 0.9375rem;
  color: var(--ink-soft);
  margin: 0.85rem 0 0;
  max-width: var(--measure);
}
.paper-links {
  display: flex;
  gap: 1rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  margin-top: 0.85rem;
}

/* --- Citation block --------------------------------------------- */

.cite { margin-top: 0.85rem; }

.cite summary {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--accent);
  cursor: pointer;
  list-style: none;
  width: fit-content;
}
.cite summary::-webkit-details-marker { display: none; }
.cite summary::before { content: "+"; width: 0.7em; }
.cite[open] summary::before { content: "\2013"; }
.cite summary:hover { color: var(--ink); }

.cite-body {
  margin-top: 0.7rem;
  padding: 0.85rem 0 0.85rem 0.95rem;
  border-left: 2px solid var(--accent-dim);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.7rem;
  max-width: 44rem;
}

pre.bibtex {
  margin: 0;
  width: 100%;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.6;
  color: var(--ink-soft);
  tab-size: 2;
}

.copy {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.22rem 0.65rem;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background-color 0.12s;
}
.copy:hover { border-color: var(--accent); background: var(--accent-dim); }
.copy[data-state="done"] { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }

/* --- Writing list ----------------------------------------------- */

.writing {
  display: grid;
  grid-template-columns: var(--gutter) 1fr;
  gap: 0 1.5rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--rule);
}
.writing:last-child { border-bottom: none; }
.writing-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  padding-top: 0.3rem;
  font-variant-numeric: tabular-nums;
}
.writing-title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 450;
  line-height: 1.35;
  margin: 0;
}
.writing-title a {
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--rule-accent);
}
.writing-title a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.writing-note {
  font-size: 0.9rem;
  color: var(--ink-mute);
  margin: 0.25rem 0 0;
  max-width: var(--measure);
}

/* --- Footer ----------------------------------------------------- */

.foot {
  margin-top: 5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  max-width: 44rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.foot-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0;
}
.foot-text {
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--ink-mute);
  margin: 0;
}
.foot-updated {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin: 0.35rem 0 0;
}

/* --- Narrow screens --------------------------------------------- */

@media (max-width: 34rem) {
  .update, .writing { grid-template-columns: 1fr; gap: 0.3rem; }
  .update-date, .writing-meta { padding-top: 0; order: 2; }
  .page { padding-block: 1.5rem 4rem; }
  .nav { padding-bottom: 2.5rem; gap: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* --- Portrait beside the masthead (home page only) ---------------
   Two columns on a wide screen so the photo costs no vertical space
   and Updates stays above the fold. Below 46rem the column reverses,
   putting the photo above the name the way a phone layout expects.
   ----------------------------------------------------------------- */

.intro {
  display: flex;
  align-items: flex-start;
  gap: 2.5rem;
}

.intro .masthead { flex: 1 1 auto; min-width: 0; }

.portrait {
  flex: 0 0 13.5rem;
  margin: 0;
}

.portrait img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  border-radius: 3px;
}

@media (max-width: 46rem) {
  .intro {
    flex-direction: column-reverse;
    gap: 1.6rem;
  }
  .portrait {
    flex: none;
    width: min(11rem, 50%);
  }
}
