/* Base typography, local fonts, layout shell, and progressive motion primitives. */
@font-face {
  font-family: "Outfit";
  src: url("../../assets/fonts/outfit-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Ma Shan Zheng";
  src: url("../../assets/fonts/mashanzheng-name.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; background: var(--bg-primary); }

body {
  position: relative;
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg-primary);
  background-image: radial-gradient(
    ellipse 90% 380px at 50% -120px,
    color-mix(in srgb, var(--accent-blue) 5.5%, transparent),
    transparent 74%
  );
  background-repeat: no-repeat;
  background-position: top center;
  color: var(--text-primary);
  font-family: "Outfit", "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: var(--font-size-base);
  font-weight: 400;
  line-height: 1.65;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--motion-medium) ease, color var(--motion-medium) ease;
}

::selection {
  background: color-mix(in srgb, var(--accent-blue) 20%, var(--bg-primary));
  color: var(--text-primary);
}
a { color: var(--link-color); text-decoration: none; transition: color var(--motion-fast) ease; }
a:hover { color: var(--accent-orange); }
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 3px;
  border-radius: 6px;
}
img { display: block; max-width: 100%; }
figure, blockquote, p { margin: 0; }
button, summary { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
strong { font-weight: 600; color: var(--text-primary); }
.ui-icon { width: 15px; height: 15px; flex-shrink: 0; display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Subtle top reading progress indicator */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 60;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-orange));
  transform-origin: 0 50%;
  transform: scaleX(var(--scroll-progress));
  pointer-events: none;
  opacity: 0.85;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 100;
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--accent-blue);
  box-shadow: var(--shadow-sm);
}
.skip-link:focus { top: 12px; }

/* Use padding-top instead of collapsing margin-top on the first section so body always starts cleanly at y=0. */
.page-shell {
  display: flow-root;
  width: min(940px, calc(100% - 400px));
  margin: 0 auto;
  padding-top: 68px;
}
.page-section { scroll-margin-top: 42px; margin-top: 52px; }
.page-section:first-child { margin-top: 0; }
.page-section:focus, .page-section:focus-visible { outline: none; }
.page-section:focus-visible > .section-heading .section-title,
.profile:focus-visible .name {
  width: fit-content;
  outline: 2px solid var(--accent-blue);
  outline-offset: 4px;
  border-radius: 4px;
}

/* Dark mode brand icon adjustments */
[data-theme="dark"] img[src*="github.svg"] { filter: invert(1) brightness(0.95); }
[data-theme="dark"] img[src*="project.svg"] { filter: brightness(1.75) saturate(0.95); }
[data-theme="dark"] img[src*="arxiv.svg"] { filter: brightness(1.38); }
[data-theme="dark"] img[src*="acl-anthology.svg"] { filter: brightness(1.22); }

/* Motion is progressive enhancement: without JavaScript, all content stays visible. */
.js .profile .name,
.js .profile .profile-tags,
.js .profile .profile-intro,
.js .profile .profile-links,
.js .profile .profile-portrait {
  animation: profile-enter var(--motion-slow) var(--ease-out) both;
}
.js .profile .profile-tags { animation-delay: 50ms; }
.js .profile .profile-intro:nth-of-type(1) { animation-delay: 90ms; }
.js .profile .profile-intro:nth-of-type(2) { animation-delay: 135ms; }
.js .profile .profile-links { animation-delay: 175ms; }
.js .profile .profile-portrait { animation-delay: 100ms; }

@keyframes profile-enter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

[data-reveal-item].reveal-initial {
  animation: reveal-item-enter var(--motion-slow) var(--ease-out) var(--reveal-delay, 110ms) both;
}

@keyframes reveal-item-enter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

[data-reveal-item].reveal-pending {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--motion-medium) var(--ease-out) var(--reveal-delay, 0ms), transform var(--motion-medium) var(--ease-out) var(--reveal-delay, 0ms);
}
[data-reveal-item].reveal-pending.is-visible { opacity: 1; transform: translateY(0); }

.filter-item-enter { animation: filter-item-enter var(--motion-medium) var(--ease-out) var(--filter-enter-delay, 0ms) both; }

@keyframes filter-item-enter {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}
