/* ==========================================================================
   Qinxi Yu — homepage
   ========================================================================== */

/* Palette from the Chainsaw Man vol. 1 cover: vermilion field, acid-lime
   splatter, mustard logo, deep-red numeral, heavy black ink. The colored
   bands stay the same in both themes; only the paper sections flip. */
:root {
  --c-orange: #f6ae86;
  --c-orange-deep: #e04e24;
  --c-lime: #d9ea9a;
  --c-yellow: #f2c230;
  --c-red: #b8141c;
  --c-black: #1b1715;
  --c-paper: #f7f5f0;
  --c-pink: #f0d5c6;

  --paper: var(--c-pink);
  --ink: var(--c-black);
  --ink-2: #45403c;
  --ink-3: #6f6560;
  --rule: rgba(27, 23, 21, 0.16);
  --tint: rgba(27, 23, 21, 0.05);
  --panel: var(--c-black);
  --accent: var(--c-orange);
  --red: var(--c-red);

  --serif: "Instrument Serif", "Iowan Old Style", "Times New Roman", serif;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --max: 920px;
  --gutter: clamp(16px, 4vw, 40px);
  /* side padding that centers content at --max inside a full-bleed band */
  --inset: max(var(--gutter), calc((100% - var(--max)) / 2 + var(--gutter)));
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #12100f;
    --ink: #f1ede6;
    --ink-2: #bcb6ae;
    --ink-3: #7d7770;
    --rule: rgba(241, 237, 230, 0.13);
    --tint: rgba(241, 237, 230, 0.05);
    --panel: #f1ede6;
    --accent: #ff6236;
    --red: #ff5a4c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #12100f;
  --ink: #f1ede6;
  --ink-2: #bcb6ae;
  --ink-3: #7d7770;
  --rule: rgba(241, 237, 230, 0.13);
  --tint: rgba(241, 237, 230, 0.05);
  --panel: #f1ede6;
  --accent: #ff6236;
  --red: #ff5a4c;
  color-scheme: dark;
}

/* Colored bands: re-scope the ink tokens so everything inside reads on them. */
.band-orange,
.band-lime {
  --ink: var(--c-black);
  --ink-2: rgba(27, 23, 21, 0.84);
  --ink-3: rgba(27, 23, 21, 0.62);
  --rule: rgba(27, 23, 21, 0.28);
  --tint: rgba(27, 23, 21, 0.08);
  --panel: var(--c-black);
  color: var(--ink);
}
.band-orange {
  --accent: var(--c-paper);
  background: var(--c-orange);
}
.band-lime {
  --accent: var(--c-red);
  background: var(--c-lime);
}
.band-lime ::selection {
  background: var(--c-black);
  color: var(--c-lime);
}

/* ---------- Base ---------- */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 64px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.65;
  font-weight: 380;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--c-lime);
  color: var(--c-black);
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s;
}
a:hover {
  color: var(--accent);
}

.intro__bio a,
.news a {
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.intro__bio a:hover,
.news a:hover {
  text-decoration-color: var(--accent);
}

b,
strong {
  font-weight: 560;
}

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

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

/* ---------- Top bar ---------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1.5px solid transparent;
  transition: border-color 0.3s;
}
.bar.is-scrolled {
  border-bottom-color: var(--c-black);
}
.bar__in {
  display: flex;
  align-items: center;
  gap: 28px;
  height: 60px;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.bar__name {
  font-family: var(--serif);
  font-size: 22px;
  opacity: 0;
  transition: opacity 0.3s, color 0.2s;
}
.bar.is-scrolled .bar__name {
  opacity: 1;
}
.bar__nav {
  margin-left: auto;
  display: flex;
  gap: 24px;
  font-size: 14px;
  font-weight: 500;
}

.theme {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  width: 32px;
  height: 32px;
  margin-right: -6px;
  display: grid;
  place-items: center;
  cursor: pointer;
  border-radius: 50%;
}
.theme:hover {
  background: var(--tint);
}
.theme svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}
.theme svg path {
  fill: currentColor;
  stroke: none;
}

/* ---------- Intro ---------- */

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 340px);
  gap: clamp(28px, 5vw, 48px);
  align-items: start;
  padding: clamp(32px, 7vw, 72px) var(--inset) clamp(56px, 8vw, 88px);
}

h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(56px, 8.5vw, 84px);
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 0;
}

.intro__bio {
  margin-top: 28px;
}

.intro__bio p {
  margin: 0 0 1em;
  color: var(--ink-2);
}
.intro__bio strong {
  color: var(--ink);
}

.intro__links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 28px 0 0;
  font-size: 14.5px;
  font-weight: 500;
}
.intro__links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--c-black);
  color: var(--c-paper);
  transition: background-color 0.2s, color 0.2s;
}
.intro__links a:hover {
  background: var(--c-yellow);
  color: var(--c-black);
}
.intro__links svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
  flex: none;
}

.intro__photo {
  width: 100%;
  height: auto;
  border: 2px solid var(--c-black);
  box-shadow: 8px 8px 0 var(--c-orange-deep);
  margin-top: 8px;
}

/* ---------- Sections ---------- */

.sec {
  padding: 48px var(--inset) 64px;
}
.sec h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 36px;
  line-height: 1;
  margin: 0 0 28px;
}
.sec h2::before {
  content: "";
  display: inline-block;
  width: 0.3em;
  height: 0.3em;
  margin-right: 0.3em;
  vertical-align: 0.12em;
  background: var(--ink);
}

/* ---------- News ---------- */

.news {
  list-style: none;
  margin: 0;
  padding: 0;
}
.news li {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 16px;
  padding: 6px 0;
}
.news time {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-3);
  padding-top: 2px;
}
.news p {
  margin: 0;
  color: var(--ink-2);
}
.news b {
  font-weight: 560;
  color: var(--ink);
}

/* ---------- Publications ---------- */

.pubs {
  list-style: none;
  margin: 0;
  padding: 0;
}
.pub {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  padding: 20px 0;
}
.pub + .pub {
  border-top: 1px solid var(--rule);
}
.pub__thumb {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1.5px solid var(--panel);
  background: var(--tint);
  transition: box-shadow 0.2s, transform 0.2s;
}
.pub:hover .pub__thumb {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--c-orange-deep);
}
.pub__thumb img,
.pub__thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pub__title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 22px;
  line-height: 1.22;
  margin: 0 0 6px;
}
.authors {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink-3);
  margin: 0 0 8px;
}
.authors b {
  color: var(--c-black);
  font-weight: 560;
  background: var(--c-lime);
  padding: 0 3px;
}
.authors sup {
  color: var(--red);
}
.authors__toggle {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--ink-2);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
}
.authors__toggle:hover {
  color: var(--accent);
}

.pub__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 16px;
  margin: 0;
  font-size: 14px;
  font-weight: 500;
}
.pub__venue {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--c-paper);
  background: var(--c-red);
  padding: 1px 7px;
}

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

.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 24px;
  padding: 32px var(--inset) 40px;
  background: var(--c-black);
  border-top: 6px solid var(--c-orange);
  color: rgba(247, 245, 240, 0.6);
  font-size: 14px;
}
.foot a {
  color: var(--c-lime);
  font-weight: 500;
  margin-right: auto;
}
.foot a:hover {
  color: var(--c-yellow);
}

/* ---------- Small screens ---------- */

@media (max-width: 860px) {
  .intro {
    grid-template-columns: minmax(0, 1fr);
  }
  .intro__photo {
    grid-row: 1;
    width: calc(100% - 8px);
    max-width: 560px;
    margin: 0;
  }
}

@media (max-width: 680px) {
  .bar__nav {
    gap: 18px;
  }
  .pub {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }
  .pub__thumb {
    aspect-ratio: 16 / 9;
  }
  .news li {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 8px 0;
  }
}

@media (max-width: 420px) {
  .bar__nav a:first-child {
    display: none;
  }
}

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