/* Kexin Wang — personal site
   Single stylesheet. No build step, no dependencies. */

:root {
  --bg:        #fbfaf7;
  --panel:     #ffffff;
  --ink:       #17171a;
  --ink-2:     #5c5c66;
  --ink-3:     #8b8b95;
  --rule:      #e3e0d8;
  --accent:    #9a4426;
  --sans:      -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", sans-serif;
  --measure:   78rem;
  --gap:       clamp(1.25rem, 3vw, 2rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:    #111114;
    --panel: #191920;
    --ink:   #f0eeea;
    --ink-2: #a8a6b0;
    --ink-3: #75737e;
    --rule:  #2c2c35;
    --accent:#d98a67;
  }
}

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

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.075rem);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

a { color: inherit; text-decoration-color: var(--ink-3); text-underline-offset: 0.18em; }
a:hover { color: var(--accent); text-decoration-color: currentColor; }

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

.skip {
  position: absolute; left: -9999px;
  background: var(--panel); padding: 0.6rem 1rem; z-index: 10;
}
.skip:focus { left: 1rem; top: 1rem; }

/* ---------- shell ---------- */

header.site, main, footer.site {
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 5vw, 2.5rem);
}

header.site {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-block: clamp(1.5rem, 4vw, 2.5rem) 0;
}

.wordmark {
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  text-decoration: none;
}

header.site nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.5rem;
  font-size: 0.86rem;
}
header.site nav a { color: var(--ink-2); text-decoration: none; }
header.site nav a:hover { color: var(--accent); }

/* ---------- intro ---------- */

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(180px, 22vw, 260px);
  gap: var(--gap);
  align-items: start;
  padding-block: clamp(3rem, 9vw, 5.5rem) clamp(2.5rem, 6vw, 4rem);
}

.intro-text { order: -1; }

/* Source is square and already tightly cropped on the face — show it square so
   nothing gets trimmed off the sides. */
.portrait {
  width: 100%;
  height: auto;          /* beat the height="" presentational hint, or aspect-ratio is ignored */
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 3px;
  filter: grayscale(1) contrast(1.03);
}

h1 {
  font-size: clamp(1.8rem, 1.2rem + 2.4vw, 2.7rem);
  line-height: 1.15;
  letter-spacing: -0.028em;
  font-weight: 600;
  margin: 0 0 1.15rem;
  text-wrap: balance;
}

.lede {
  font-size: clamp(1.05rem, 1rem + 0.35vw, 1.2rem);
  color: var(--ink-2);
  max-width: 34em;
  margin: 0 0 1.4rem;
}

.meta {
  font-size: 0.86rem;
  line-height: 1.8;
  color: var(--ink-3);
  max-width: 40em;
  margin: 0;
}

/* ---------- sections ---------- */

section + section { margin-top: clamp(3.5rem, 9vw, 6rem); }

/* Groups inside the work section sit closer together than top-level sections. */
.group + .group { margin-top: clamp(2.75rem, 6vw, 4.25rem); }

h2 {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--ink);
  margin: 0 0 1.75rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--rule);
}

/* ---------- work grid ---------- */

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: clamp(1.5rem, 2.6vw, 2.1rem) clamp(1.25rem, 2.2vw, 1.75rem);
}

.card figure {
  margin: 0 0 0.9rem;
  overflow: hidden;
  border-radius: 3px;
  background: var(--panel);
  border: 1px solid var(--rule);
}

/* If a photo is missing, the browser falls back to rendering alt text inside the
   box — style it so that reads as a caption rather than a broken page. */
.card figure img {
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--ink-3);
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  object-position: center top;
  transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.card:hover figure img { transform: scale(1.025); }

/* Paper teaser figures are diagrams, not photos — show them whole rather than
   cropping, on the white they were drawn against. */
.card--paper figure { background: #fff; }
.card--paper figure img {
  object-fit: contain;
  padding: 0.5rem;
}
.card--paper:hover figure img { transform: none; }

/* A card whose artifact is a text — the venue stands in for the image. */
.plate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-align: center;
  aspect-ratio: 3 / 2;
  margin-bottom: 1.1rem;
  padding: 1.5rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--panel);
}
.plate span:first-child { font-size: 1.05rem; font-weight: 600; color: var(--ink); }
.plate span + span { font-size: 0.8rem; color: var(--ink-3); }

@media (prefers-reduced-motion: reduce) {
  .card figure img, .card:hover figure img { transition: none; transform: none; }
}

.kicker,
.tags {
  font-size: 0.76rem;
  color: var(--ink-3);
  margin: 0;
}

.kicker { margin-bottom: 0.35rem; }

.card h3 {
  font-size: 1.06rem;
  font-weight: 600;
  letter-spacing: -0.011em;
  margin: 0 0 0.5rem;
}

.card p:not(.kicker):not(.tags):not(.links) {
  margin: 0 0 0.85rem;
  color: var(--ink-2);
  font-size: 0.875rem;
  line-height: 1.55;
}

.tags { line-height: 1.6; }

.links {
  font-size: 0.78rem;
  margin: 0.7rem 0 0;
}
.links a { text-decoration: none; border-bottom: 1px solid var(--rule); padding-bottom: 1px; }
.links a:hover { border-bottom-color: currentColor; }

.status {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--ink-3);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.1rem 0.45rem;
  white-space: nowrap;
}

/* ---------- papers ---------- */

.papers {
  list-style: none;
  margin: 0;
  padding: 0;
}

.papers li {
  padding: 1.15rem 0;
  border-bottom: 1px solid var(--rule);
}
.papers li:first-child { padding-top: 0; }

.pub-title {
  margin: 0 0 0.3rem;
  font-size: 1.02rem;
  line-height: 1.45;
  text-wrap: pretty;
}

.pub-authors {
  margin: 0 0 0.3rem;
  font-size: 0.9rem;
  color: var(--ink-2);
}
.pub-authors b { font-weight: 600; color: var(--ink); }

.pub-venue {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.8rem;
  color: var(--ink-3);
}

/* ---------- about ---------- */

.prose { max-width: 36em; }
.papers { max-width: 46em; }
.prose p { margin: 0 0 1.1rem; color: var(--ink-2); }
.prose p:last-child { margin-bottom: 0; }

/* ---------- contact ---------- */

.contact {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 36em;
}

.contact li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--rule);
}

.contact span {
  flex: 0 0 5.5rem;
  font-size: 0.86rem;
  color: var(--ink-3);
  padding-top: 0.15rem;
}

.contact a { text-decoration: none; border-bottom: 1px solid var(--rule); }
.contact a:hover { border-bottom-color: currentColor; }

/* ---------- footer ---------- */

footer.site {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  margin-top: clamp(4rem, 10vw, 7rem);
  padding-block: 1.5rem clamp(2rem, 5vw, 3.5rem);
  border-top: 1px solid var(--rule);
  font-size: 0.8rem;
  color: var(--ink-3);
}
footer.site p { margin: 0; }
footer.site a { text-decoration: none; }

/* ---------- narrow ---------- */

@media (max-width: 640px) {
  .intro {
    grid-template-columns: 1fr;
    padding-block: 2.25rem 2.5rem;
  }
  .portrait {
    order: -1;
    width: clamp(130px, 38vw, 180px);
    margin-bottom: 0.75rem;
  }
  .intro-text { order: 0; }
  .contact span { flex-basis: 100%; }
}