/* ============================================================
   Renxu Bao — personal homepage
   Typography and metrics follow the AcadHomepage look:
   Trebuchet MS, 15px base, 1.5 line-height, 925px (1280px wide)
   content column, hairline rules at #f2f3f3.
   Dark mode is the same layout on an inverted palette.
   ============================================================ */

:root {
  --bg: #ffffff;
  --fg: #494e52;          /* body text */
  --fg-strong: #2f3338;   /* headings, strong */
  --muted: #7a8288;       /* nav links, meta */
  --muted-strong: #5c6266;
  --line: #f2f3f3;        /* heading rules, borders */
  --line-2: #efefef;      /* paper separators */
  --bar: #bdc1c4;         /* nav hover bar */
  --accent: #224b8d;      /* links */
  --badge: #00369f;
  --thumb-shadow: 3px 3px 6px #888;

  --sans: "Trebuchet MS", "Lucida Grande", "Lucida Sans Unicode", Helvetica,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;

  --wrap: 925px;
}

@media (min-width: 80em) { :root { --wrap: 1280px; } }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181b;
    --fg: #c6cad0;
    --fg-strong: #eef0f3;
    --muted: #8e949c;
    --muted-strong: #aeb4bb;
    --line: rgba(255, 255, 255, 0.11);
    --line-2: rgba(255, 255, 255, 0.08);
    --bar: rgba(255, 255, 255, 0.3);
    --accent: #8cb0ec;
    --badge: #2f5fb8;
    --thumb-shadow: 3px 3px 10px rgba(0, 0, 0, 0.65);
  }
}

:root[data-theme="dark"] {
  --bg: #16181b;
  --fg: #c6cad0;
  --fg-strong: #eef0f3;
  --muted: #8e949c;
  --muted-strong: #aeb4bb;
  --line: rgba(255, 255, 255, 0.11);
  --line-2: rgba(255, 255, 255, 0.08);
  --bar: rgba(255, 255, 255, 0.3);
  --accent: #8cb0ec;
  --badge: #2f5fb8;
  --thumb-shadow: 3px 3px 10px rgba(0, 0, 0, 0.65);
}

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

html {
  font-size: 15px;
  background-color: var(--bg);
  scroll-behavior: smooth;
  scroll-padding-top: 4em;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--fg);
  font-family: var(--sans);
  line-height: 1.5;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.is-loading { overflow: hidden; }

h1, h2, h3, h4 {
  font-family: var(--sans);
  font-weight: bold;
  color: var(--fg-strong);
  line-height: 1.3;
}

p { margin: 0 0 0.5em; }

ul, ol { margin: 0.5em 0 1em; padding-inline-start: 2em; }
li { margin-bottom: 0.5em; }

em { font-style: italic; }
strong { color: var(--fg-strong); }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease-in-out;
}
a:hover { text-decoration: underline; }

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

::selection { background: var(--accent); color: #fff; }

.icon {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

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

.skip-link {
  position: fixed;
  top: 0.6em;
  left: 50%;
  z-index: 60;
  padding: 0.5em 1em;
  background: var(--fg-strong);
  color: var(--bg);
  font-size: 0.875em;
  transform: translate(-50%, -300%);
  transition: transform 0.25s ease;
}
.skip-link:focus-visible { transform: translate(-50%, 0); }

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

/* ============================================================
   Intro — done in about 1.6s
   ============================================================ */

.intro {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: var(--bg);
  cursor: pointer;
  will-change: clip-path;
}

html:not(.js) .intro { display: none; }

.intro__stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1em;
  padding: 0 1em;
}

.intro__name {
  font-size: clamp(2.6rem, 8vw, 5.4rem);
  font-weight: bold;
  line-height: 1;
  letter-spacing: -0.015em;
  color: var(--fg-strong);
  white-space: nowrap;
}

/* one mask per character, built by main.js */
.intro__name .ch {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  padding: 0.1em 0 0.16em;
  margin-bottom: -0.16em;
}
.intro__name .ch > span { display: inline-block; }
.js .is-loading .intro__name .ch > span { transform: translateY(105%); }

.intro__rule {
  position: relative;
  display: block;
  width: min(300px, 46vw);
  height: 1px;
  background: var(--line);
}
.intro__rule::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bar);
  transform: scaleX(0);
}

/* ============================================================
   Masthead
   ============================================================ */

.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.masthead__inner {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0.5em 1em;
  display: flex;
  align-items: center;
  gap: 1em;
}

.masthead__home {
  font-weight: bold;
  color: var(--fg-strong);
  padding-right: 2em;
}
.masthead__home:hover { text-decoration: none; color: var(--fg-strong); }

.masthead__menu { margin-left: auto; display: flex; }

.masthead__menu a {
  position: relative;
  display: block;
  margin: 0 1rem;
  padding: 0.5rem 0;
  color: var(--muted);
  white-space: nowrap;
}
.masthead__menu a:last-child { margin-right: 0; }
.masthead__menu a::before {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 4px;
  background: var(--bar);
  transform: scaleX(0);
  transition: transform 0.2s ease-in-out;
}
.masthead__menu a:hover { color: var(--muted-strong); text-decoration: none; }
.masthead__menu a:hover::before { transform: scaleX(1); }
.masthead__menu a.is-active { color: var(--fg-strong); }
.masthead__menu a.is-active::before { transform: scaleX(1); }

.masthead__tools { display: flex; align-items: center; gap: 0.2em; margin-left: 0.6em; }

.iconbtn {
  display: grid;
  place-items: center;
  width: 2.1em;
  height: 2.1em;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s ease-in-out;
}
.iconbtn:hover { color: var(--fg-strong); }
.iconbtn .icon { width: 1.15em; height: 1.15em; grid-area: 1 / 1; }

/* one icon at a time, depending on the resolved theme */
.icon--moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon--sun { display: none; }
  :root:not([data-theme="light"]) .icon--moon { display: block; }
}
:root[data-theme="dark"] .icon--sun { display: none; }
:root[data-theme="dark"] .icon--moon { display: block; }
:root[data-theme="light"] .icon--sun { display: block; }
:root[data-theme="light"] .icon--moon { display: none; }

.iconbtn--menu { display: none; position: relative; }
.navicon, .navicon::before, .navicon::after {
  display: block;
  width: 1.1em;
  height: 2px;
  background: currentColor;
  transition: transform 0.2s ease-in-out;
}
.navicon { position: relative; }
.navicon::before, .navicon::after { content: ""; position: absolute; left: 0; top: 0; }
.navicon::before { transform: translateY(-6px); }
.navicon::after { transform: translateY(6px); }
.masthead.is-open .navicon { background: transparent; }
.masthead.is-open .navicon::before { transform: rotate(45deg); }
.masthead.is-open .navicon::after { transform: rotate(-45deg); }

/* ============================================================
   Layout: sidebar + content
   ============================================================ */

.main {
  max-width: var(--wrap);
  margin: 1em auto 0;
  padding: 0 1em;
  display: grid;
  grid-template-columns: 15.2542372881% minmax(0, 1fr);
  column-gap: 5.9322033898%;   /* 1.69% margin + 4.24% padding, as in the original */
  align-items: start;
}

/* ---------- Sidebar ---------- */

.sidebar { font-size: 1em; }

@media (min-width: 64em) {
  .sidebar { position: sticky; top: 5em; }
}

.author__avatar img {
  max-width: 175px;
  min-width: 75px;
  width: 100%;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.author__name {
  margin: 10px 0;
  font-size: 1.4em;
}

.author__bio {
  margin: 10px 0 20px;
  color: var(--muted);
}

.author__urls {
  margin: 0;
  padding: 0;
  list-style: none;
}
.author__urls li {
  display: flex;
  align-items: center;
  gap: 0.6em;
  margin: 0;
  padding: 0.125em 0;
  color: var(--muted);
}
.author__urls a {
  display: flex;
  align-items: center;
  gap: 0.6em;
  color: inherit;
}
.author__urls a:hover { color: var(--accent); text-decoration: none; }
.author__urls .icon { color: var(--muted); }

.author__urls li.author__pitch {
  display: block;
  margin-bottom: 1em;
  white-space: normal;
  color: var(--fg);
}

/* ---------- Content ---------- */

.page__content { min-width: 0; }

.page__content h2 {
  margin: 1em 0 0.5em;
  padding-bottom: 0.5em;
  font-size: 1.4em;
  border-bottom: 1px solid var(--line);
}

.section { scroll-margin-top: 4.5em; }

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

.paper-box {
  display: flex;
  justify-content: left;
  align-items: center;
  flex-direction: row;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line-2);
  padding: 2em 0;
}
.paper-box:last-child { border-bottom: 0; }

.paper-box .paper-box-image {
  display: flex;
  justify-content: left;
  min-width: 200px;
  max-width: 40%;
  order: 1;
}
.paper-box .paper-box-image > div { position: relative; width: 100%; }
.paper-box .paper-box-image img {
  width: 100%;
  max-width: 400px;
  box-shadow: var(--thumb-shadow);
  object-fit: cover;
}

.badge {
  position: absolute;
  z-index: 2;
  margin-top: 0.5em;
  margin-left: -0.5em;
  padding-left: 1rem;
  padding-right: 1rem;
  color: #fff;
  background-color: var(--badge);
  font-size: 0.8em;
}

.paper-box .paper-box-text {
  max-width: 60%;
  order: 2;
  padding-left: 2em;
}
.paper-box .paper-box-text p { margin-bottom: 0.4em; }
.paper-box .paper-box-text ul { margin: 0.5em 0 0; }
.paper-box .paper-box-text li { margin-bottom: 0; }

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

.foot {
  display: flex;
  justify-content: space-between;
  gap: 1em;
  margin-top: 2.5em;
  padding: 1em 0 2.5em;
  border-top: 1px solid var(--line);
  font-size: 0.8125em;
  color: var(--muted);
}

/* ============================================================
   Reveal on scroll (held back until the intro hands over)
   ============================================================ */

.js .reveal { opacity: 0; transform: translateY(12px); }
.js .reveal.is-in {
  opacity: 1;
  transform: none;
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(.16, 1, .3, 1);
}

.js body.is-loading .masthead,
.js body.is-loading .main { opacity: 0; }

/* ============================================================
   Small screens
   ============================================================ */

@media (max-width: 64em) {
  .main {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 1.5em;
  }

  /* sidebar becomes a header row, as in the original on mobile */
  .profile {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    column-gap: 1.2em;
    align-items: center;
  }
  .author__avatar { grid-row: span 2; }
  .author__avatar img { max-width: 110px; }
  .author__name { margin-top: 0; }
  .author__urls { grid-column: 2; }
  .author__urls li { display: inline-flex; margin-right: 1.2em; }
  .author__urls li.author__pitch { display: block; margin-bottom: 0.6em; }

  .paper-box .paper-box-image {
    justify-content: center;
    width: 100%;
    max-width: 100%;
    order: 2;
  }
  .paper-box .paper-box-image > div { max-width: 400px; }
  .paper-box .paper-box-text {
    max-width: 100%;
    order: 1;
    padding-left: 0;
    padding-bottom: 1em;
  }
  .badge { margin-left: 0; }
}

@media (max-width: 48em) {
  .masthead__menu {
    position: absolute;
    top: 100%;
    right: 1em;
    left: 1em;
    flex-direction: column;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--bg);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
  }
  .masthead.is-open .masthead__menu { opacity: 1; transform: none; pointer-events: auto; }
  .masthead__menu a { margin: 0; padding: 0.6em 0.8em; border-bottom: 1px solid var(--line); }
  .masthead__menu a:last-child { border-bottom: 0; }
  .masthead__menu a::before { display: none; }

  .iconbtn--menu { display: grid; }
  .masthead__home { margin-right: auto; }
}

@media (max-width: 30em) {
  .profile { grid-template-columns: minmax(0, 1fr); }
  .author__avatar { grid-row: auto; }
  .author__urls { grid-column: 1; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

@media print {
  .masthead, .intro, .skip-link { display: none !important; }
  .main { display: block; max-width: none; }
  body { background: #fff; color: #000; }
}
