/* ==========================================================================
   Sherry Xie — personal academic website
   Two pages: Home + CV. Single-column, sans-serif, soft rose accent.
   Inspired by kevinz-01.github.io, with a feminine palette borrowed from
   al-folio pink themes. No external fonts, no build step.
   ========================================================================== */

:root {
  --max-width: 760px;

  --color-text: #2b2b2f;
  --color-muted: #6b6b73;
  --color-faint: #9a9aa2;
  --color-bg: #fffcfd;
  --color-surface: #fdeef4;
  --color-border: #f4dfe8;

  /* Rose accent */
  --color-accent: #d9578c;
  --color-accent-dark: #b23f6c;
  --color-accent-soft: #fce2ed;
  --color-link: #c04d79;
  --color-link-hover: #9c3862;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, "Noto Sans", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
    serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  /* handwritten signature look for the name */
  --font-script: "Snell Roundhand", "Apple Chancery", "Segoe Script",
    "Brush Script MT", cursive;

  --radius: 12px;

  /* hand-drawn 5-petal flower, used as a CSS mask so it follows the theme */
  --flower: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='%23000'%3E%3Ccircle cx='12' cy='5.4' r='3.5'/%3E%3Ccircle cx='18.1' cy='9.8' r='3.5'/%3E%3Ccircle cx='15.8' cy='17' r='3.5'/%3E%3Ccircle cx='8.2' cy='17' r='3.5'/%3E%3Ccircle cx='5.9' cy='9.8' r='3.5'/%3E%3Ccircle cx='12' cy='11.8' r='2.6'/%3E%3C/g%3E%3C/svg%3E");
}

/* Reset ------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16.5px;
  line-height: 1.7;
  color: var(--color-text);
  /* soft blush glow at the top — warmth without decoration */
  background-color: var(--color-bg);
  background-image: radial-gradient(
    900px 380px at 50% -140px,
    var(--color-accent-soft),
    transparent 70%
  );
  background-repeat: no-repeat;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Typography -------------------------------------------------------------- */
/* Elegant serif headings — academic gravitas with a softer, feminine feel */
h1,
h2,
h3,
h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text);
  letter-spacing: 0;
}
h1 {
  font-size: 2rem;
  margin: 0 0 0.15rem;
}
h2 {
  font-size: 1.32rem;
  margin: 2.6rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
  position: relative;
}
/* delicate rose accent under each section heading — grows on hover */
h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 54px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--color-accent), transparent);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
h2:hover::after {
  width: 130px;
}
h3 {
  font-size: 1.05rem;
  margin: 1.6rem 0 0.5rem;
}

p {
  margin: 0 0 1rem;
}

a {
  color: var(--color-link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
a:hover {
  color: var(--color-link-hover);
  border-bottom-color: currentColor;
}

/* Divider with a little flower in the middle */
hr {
  border: none;
  /* taller band so the divider (and its flower) is easy to hover */
  height: 24px;
  background: linear-gradient(
      90deg,
      transparent,
      var(--color-accent-soft),
      var(--color-accent),
      var(--color-accent-soft),
      transparent
    )
    center / 100% 1px no-repeat;
  margin: 2.4rem 0;
  position: relative;
  overflow: visible;
}
/* clear a gap in the line so the flower sits cleanly */
hr::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 34px;
  height: 10px;
  background: var(--color-bg);
}
/* the flower itself — masked, so it takes the accent colour in both themes */
hr::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  background-color: var(--color-accent);
  -webkit-mask: var(--flower) center / contain no-repeat;
  mask: var(--flower) center / contain no-repeat;
  transition: transform 0.65s cubic-bezier(0.34, 1.56, 0.64, 1),
    background-color 0.3s ease;
}
/* hover the divider → the flower blooms and spins */
hr:hover::after {
  transform: translate(-50%, -50%) rotate(180deg) scale(1.35);
  background-color: var(--color-accent-dark);
}

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--color-surface);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* Layout ------------------------------------------------------------------ */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.4rem;
}
main {
  padding: 2.5rem 0 4rem;
  min-height: 60vh;
  animation: pagefade 0.55s ease both;
}
@keyframes pagefade {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.section {
  margin-bottom: 1.5rem;
}

/* Site header / nav ------------------------------------------------------- */
.site-header {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 58px;
}
.brand {
  font-family: var(--font-script);
  font-weight: 600;
  font-size: 1.7rem;
  line-height: 1;
  color: var(--color-accent);
  border-bottom: none;
  transition: transform 0.15s ease, color 0.15s ease;
}
.brand:hover {
  color: var(--color-accent-dark);
  border-bottom: none;
  transform: rotate(-2deg) scale(1.04);
}
.brand-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.25rem 0.35rem;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  transition: background 0.15s ease, transform 0.15s ease;
}
.theme-toggle:hover {
  background: var(--color-surface);
  transform: scale(1.12) rotate(-8deg);
}
.nav {
  display: flex;
  gap: 1.6rem;
}
.nav a {
  color: var(--color-muted);
  font-size: 0.95rem;
  border-bottom: none;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  transition: color 0.15s ease, background 0.15s ease;
}
/* soft pink pill on hover / for the current page */
.nav a:hover {
  color: var(--color-accent-dark);
  background: var(--color-accent-soft);
  border-bottom: none;
}
.nav a.is-active {
  color: var(--color-accent-dark);
  background: var(--color-accent-soft);
  font-weight: 600;
}

/* Profile block (home): text left, photo + social icons right ------------- */
.profile {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}
.profile__main {
  flex: 1 1 auto;
  min-width: 0;
}
.profile__side {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.profile__photo {
  flex: 0 0 150px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-surface);
  border: 4px solid var(--color-accent-soft);
  /* soft rose halo */
  box-shadow: 0 10px 34px rgba(208, 90, 134, 0.22),
    0 0 0 9px rgba(208, 90, 134, 0.05);
}
/* Placeholder shown when no profile.jpg is present yet */
.profile__photo--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--color-accent);
  background: var(--color-accent-soft);
}
.profile__title {
  color: var(--color-accent);
  font-weight: 600;
  font-size: 1.02rem;
  margin: 0.1rem 0 0.2rem;
}
.profile__loc {
  color: var(--color-muted);
  font-size: 0.92rem;
  margin: 0 0 1rem;
}

/* Social icons stacked under the photo ------------------------------------ */
.profile__social {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem 0.7rem;
  margin-top: 1rem;
  max-width: 160px;
}
.profile__social a {
  color: var(--color-muted);
  border-bottom: none;
  display: inline-flex;
  transition: color 0.15s ease, transform 0.15s ease;
}
.profile__social a:hover {
  color: var(--color-accent);
  border-bottom: none;
  transform: translateY(-2px);
}
.profile__social svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  display: block;
}

/* Research-areas numbered list -------------------------------------------- */
.areas {
  counter-reset: area;
  list-style: none;
  padding: 0;
  margin: 0;
}
.areas a {
  border-bottom: none;
}
.areas a:hover {
  border-bottom: 1px solid currentColor;
}
.areas li {
  position: relative;
  padding: 0.55rem 0.6rem 0.55rem 2.4rem;
  border-bottom: 1px solid var(--color-border);
  border-radius: 10px;
  transition: background 0.25s ease;
}
/* hover a research area → soft pink wash, its number tilts */
.areas li:hover {
  background: var(--color-accent-soft);
}
.areas li:hover::before {
  transform: scale(1.14) rotate(-12deg);
}
.areas li:last-child {
  border-bottom: none;
}
.areas li::before {
  counter-increment: area;
  content: counter(area);
  position: absolute;
  left: 0;
  top: 0.6rem;
  width: 1.7rem;
  height: 1.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-accent);
  background: var(--color-accent-soft);
  border-radius: 50%;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* News list --------------------------------------------------------------- */
.news-item {
  display: flex;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-border);
}
.news-item:last-child {
  border-bottom: none;
}
.news-item time {
  flex: 0 0 6rem;
  color: var(--color-accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: 0.88rem;
  padding-top: 0.05rem;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
/* hover a news row → its date pops forward slightly */
.news-item:hover time {
  transform: translateX(3px) scale(1.06);
}

/* Publications ------------------------------------------------------------ */
.pub {
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--color-border);
  transition: transform 0.25s ease;
}
.pub:last-child {
  border-bottom: none;
}
/* hover a paper → it slides over a touch and the title turns rose */
.pub:hover {
  transform: translateX(5px);
}
.pub:hover .pub__title {
  color: var(--color-accent);
}
.pub__title {
  font-weight: 600;
  transition: color 0.25s ease;
}
/* submission status shown inline with the title (lighter, italic) */
.pub__status {
  font-weight: 400;
  font-style: italic;
  color: var(--color-muted);
  font-size: 0.9rem;
}
.pub__authors {
  color: var(--color-muted);
  font-size: 0.94rem;
}
.pub__authors .me {
  color: var(--color-accent);
  font-weight: 700;
}
.pub__venue {
  font-style: italic;
  color: var(--color-muted);
  font-size: 0.94rem;
}
.pub__badge {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-accent-dark);
  background: var(--color-accent-soft);
  border-radius: 4px;
  padding: 0.1rem 0.45rem;
  margin-left: 0.4rem;
  vertical-align: middle;
}
.pub__links {
  margin-top: 0.4rem;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}
/* resource links shown as small icons (paper / code / project) */
.pub__link {
  color: var(--color-muted);
  border-bottom: none;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s ease, transform 0.15s ease;
}
.pub__link:hover {
  color: var(--color-accent);
  border-bottom: none;
  transform: translateY(-1px);
}
.pub__link svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* Simple list (service, misc) --------------------------------------------- */
.plain-list {
  padding-left: 1.2rem;
  margin: 0;
}
.plain-list li {
  margin-bottom: 0.35rem;
}

/* CV --------------------------------------------------------------------- */
.cv-entry {
  display: flex;
  gap: 1.2rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--color-border);
}
.cv-entry:last-child {
  border-bottom: none;
}
.cv-entry__date {
  flex: 0 0 8rem;
  color: var(--color-faint);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.cv-entry__body {
  flex: 1;
}
.cv-entry__body strong {
  font-weight: 700;
}
.cv-entry__body .where {
  color: var(--color-muted);
}
.cv-download {
  display: inline-block;
  margin-top: 0.5rem;
  background: var(--color-accent);
  color: #fff;
  padding: 0.45rem 1.1rem;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 600;
  border-bottom: none;
}
.cv-download:hover {
  background: var(--color-accent-dark);
  color: #fff;
  border-bottom: none;
}

/* Footer ------------------------------------------------------------------ */
.site-footer {
  border-top: 1px solid var(--color-border);
  color: var(--color-faint);
  font-size: 0.83rem;
  padding: 1.8rem 0;
}
.site-footer .container {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* States ------------------------------------------------------------------ */
.loading,
.error {
  color: var(--color-faint);
  font-style: italic;
  padding: 0.6rem 0;
}
.error {
  color: #b23f6c;
}

/* Responsive -------------------------------------------------------------- */
@media (max-width: 600px) {
  body {
    font-size: 16px;
  }
  .profile {
    flex-direction: column-reverse;
    gap: 1.3rem;
  }
  .profile__side {
    align-self: center;
  }
  .profile__photo {
    flex-basis: 130px;
    width: 130px;
    height: 130px;
  }
  .nav {
    gap: 1.1rem;
  }
  .cv-entry {
    flex-direction: column;
    gap: 0.2rem;
  }
  .cv-entry__date {
    flex-basis: auto;
  }
}

/* Dark mode: a manual choice (data-theme) wins; otherwise follow the system - */
:root[data-theme="dark"] {
  --color-text: #ede8ea;
  --color-muted: #b3a8ad;
  --color-faint: #857b80;
  --color-bg: #171315;
  --color-surface: #241a20;
  --color-border: #33262d;
  --color-accent: #eb8bb1;
  --color-accent-dark: #f3a9c8;
  --color-accent-soft: #2e1f27;
  --color-link: #eb8bb1;
  --color-link-hover: #f3a9c8;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-text: #ede8ea;
    --color-muted: #b3a8ad;
    --color-faint: #857b80;
    --color-bg: #171315;
    --color-surface: #241a20;
    --color-border: #33262d;
    --color-accent: #eb8bb1;
    --color-accent-dark: #f3a9c8;
    --color-accent-soft: #2e1f27;
    --color-link: #eb8bb1;
    --color-link-hover: #f3a9c8;
  }
}

/* Smooth transition when flipping themes */
body {
  transition: background 0.3s ease, color 0.3s ease;
}

/* Life page: photo slideshow + grid ---------------------------------------- */
.slideshow {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
  height: min(72vh, 580px);
  border-radius: 16px;
  overflow: hidden;
  background: var(--color-surface);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.14);
  animation: fadeup 0.8s ease both;
}
.slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.9s ease;
  pointer-events: none;
}
.slide.is-active {
  opacity: 1;
  pointer-events: auto;
}
/* blurred fill so portrait photos never leave empty side bars */
.slide__bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: blur(28px) brightness(0.7) saturate(1.15);
  transform: scale(1.18);
}
.slide__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain; /* show the whole photo — never crop faces */
  display: block;
  z-index: 1;
}
/* Ken Burns: slow push on the visible photo */
.slide.is-active .slide__img {
  animation: kenburns 9s ease-out both;
}
@keyframes kenburns {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}
@keyframes fadeup {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}
.slide__caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 1.4rem 1rem 0.9rem;
  color: #fff;
  font-size: 0.9rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
}
.slideshow__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  color: #333;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.slideshow__arrow:hover {
  background: #fff;
}
.slideshow__arrow--prev { left: 0.7rem; }
.slideshow__arrow--next { right: 0.7rem; }
.slideshow__dots {
  display: flex;
  gap: 0.45rem;
  justify-content: center;
  margin-top: 1rem;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-border);
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background 0.15s ease;
}
.dot.is-active { background: var(--color-accent); }

/* Row-based grid: fills left-to-right, so the last photos form the bottom row */
.life-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
  align-items: start;
  margin-top: 2.8rem;
}
.life-grid img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  cursor: pointer;
  display: block;
  background: var(--color-surface);
  /* scroll-reveal start state */
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.7s ease, transform 0.7s ease, box-shadow 0.2s ease,
    filter 0.2s ease;
}
.life-grid img.is-visible {
  opacity: 1;
  transform: none;
}
.life-grid img:hover {
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  filter: brightness(1.04);
}
@media (max-width: 620px) {
  .life-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (prefers-reduced-motion: reduce) {
  .slideshow,
  .slide.is-active .slide__img,
  .life-grid img {
    animation: none !important;
    transition: opacity 0.3s ease;
    transform: none;
    opacity: 1;
  }
}
