/* ==========================================================================
   Haoning Deng — personal homepage
   Layout: profile (left) · tabs + content (middle) · news (right)
   Collapses to two columns on tablets and one column on phones.
   ========================================================================== */

:root {
  --bg: #f3f4f7;
  --card: #ffffff;
  --card-inset: #f7f8fa;
  --text: #1c1d21;
  --text-2: #4b505a;
  --muted: #8b909a;
  --line: #e6e8ec;
  --accent: #5b5bd6;
  --accent-soft: #eeeefc;
  --accent-ink: #4a49b8;
  --link: #2f5bb7;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.04), 0 8px 28px rgb(16 24 40 / 0.05);
  --radius: 20px;
  --radius-sm: 14px;
  --gap: 24px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue",
          "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #171a20;
    --card-inset: #1d2129;
    --text: #e9ebef;
    --text-2: #b6bbc4;
    --muted: #7f858f;
    --line: #272b33;
    --accent: #8e8ef5;
    --accent-soft: #24253d;
    --accent-ink: #b4b4ff;
    --link: #93b2ff;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3);
    color-scheme: dark;
  }
}

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

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s, color 0.15s;
}
a:hover { text-decoration-color: currentColor; }

a:focus-visible,
.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-fill { fill: currentColor; stroke: none; }

/* ---------- Layout ---------- */

.layout {
  max-width: 1320px;
  margin: 0 auto;
  padding: 32px 24px 40px;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr) 292px;
  grid-template-areas:
    "side main news"
    ".    foot .";
  gap: var(--gap);
  align-items: start;
}

.sidebar  { grid-area: side; position: sticky; top: 32px; }
.main     { grid-area: main; min-width: 0; }
.news-col { grid-area: news; position: sticky; top: 32px; }

/* ---------- Cards ---------- */

.card {
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 32px;
}
.section-group > .card + .card { margin-top: var(--gap); }
.main > .section-group + .section-group { margin-top: var(--gap); }

/* Clicking a tab scrolls the section to just below the sticky tab bar.
   --scroll-offset is measured by js/main.js; 110px is the fallback. */
.section-group { scroll-margin-top: var(--scroll-offset, 110px); }

.section-label {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---------- Profile card ---------- */

.profile-card {
  padding: 22px 20px 20px;
  text-align: center;
}

.avatar {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  object-fit: cover;
}
.avatar-placeholder {
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, #c7cdfb 0%, #ddd3fb 55%, #f3dcef 100%);
  color: #fff;
  font-size: 64px;
  font-weight: 600;
  letter-spacing: 0.02em;
  user-select: none;
}
@media (prefers-color-scheme: dark) {
  .avatar-placeholder { background: linear-gradient(140deg, #3a3f7a 0%, #4b3f7a 55%, #6a3f6c 100%); }
}

.name {
  margin-top: 18px;
  font-size: 1.5rem;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.name-zh {
  margin-left: 6px;
  font-size: 0.8em;
  font-weight: 500;
  color: var(--text-2);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 550;
  letter-spacing: 0.02em;
}
.chip .icon { width: 13px; height: 13px; }

.role {
  margin-top: 12px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.55;
}

.contact-list {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  text-align: left;
}
.contact-list a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 10px;
  color: var(--text-2);
  font-size: 14px;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}
.contact-list a span { min-width: 0; overflow-wrap: anywhere; }
.contact-list a:hover { background: var(--card-inset); color: var(--text); }

/* ---------- Tabs ---------- */

/* Sticky strip that holds the tab bar; its background hides content scrolling under it. */
.tabs-wrap {
  position: sticky;
  top: 0;
  z-index: 10;
  margin-top: -32px;          /* reach up into the layout's top padding */
  padding: 32px 0 var(--gap);
  background: linear-gradient(to bottom, var(--bg) calc(100% - 12px), transparent);
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 6px;
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.tab {
  padding: 8px 18px;
  border-radius: 999px;
  color: var(--text-2);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.18s, color 0.18s, box-shadow 0.18s;
}
.tab:hover { background: var(--accent-soft); color: var(--accent-ink); }
.tab[aria-current="true"] {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent);
}


/* ---------- Text ---------- */

.card p { color: var(--text-2); line-height: 1.75; }
.card p + p { margin-top: 14px; }

.lead {
  color: var(--text) !important;
  font-size: 1.18rem;
  line-height: 1.65 !important;
}

/* ---------- Timeline (education / work) ---------- */

.timeline {
  position: relative;
  padding-left: 24px;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--line);
}

.tl-item { position: relative; }
.tl-item + .tl-item { margin-top: 22px; }
.tl-item::before {
  content: "";
  position: absolute;
  left: -24px;
  top: 7px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--accent);
}
/* Filled dot = ongoing; hollow dot = completed */
.tl-item.is-current::before { background: var(--accent); }

.tl-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}
.tl-title {
  font-size: 1rem;
  font-weight: 620;
  line-height: 1.45;
}
.tl-date {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tl-sub {
  margin-top: 2px;
  color: var(--text-2);
  font-size: 15px;
}
.tl-place { color: var(--muted); }
.tl-place::before { content: "· "; }
.card .tl-note {
  margin-top: 4px;
  font-size: 14px;
  line-height: 1.6;
}
.tl-list {
  margin-top: 8px;
  padding-left: 18px;
  list-style: disc;
  color: var(--text-2);
  font-size: 15px;
  line-height: 1.65;
}
.tl-list li + li { margin-top: 4px; }
.tl-list li::marker { color: var(--muted); }

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

.pub {
  display: flex;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.pub + .pub { margin-top: 12px; }
.pub:hover {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
  box-shadow: 0 4px 16px rgb(16 24 40 / 0.05);
}

.pub-venue {
  flex: 0 0 104px;
  height: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--accent-soft), color-mix(in srgb, var(--accent-soft) 40%, var(--card)));
  color: var(--accent-ink);
}
.pub-venue-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.pub-venue-year {
  font-size: 12px;
  font-weight: 550;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

.pub-body { min-width: 0; }
.pub-title {
  font-size: 1rem;
  font-weight: 620;
  line-height: 1.45;
}
.card .pub-authors {
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.55;
}
.pub-authors sup { font-size: 0.7em; margin-left: 1px; }
.pub-authors .me {
  color: var(--text);
  font-weight: 650;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--text) 40%, transparent);
  text-underline-offset: 3px;
}
.pub-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.pub-tag,
.pub-link {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 550;
  line-height: 1.6;
}
.pub-tag {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.pub-link {
  border: 1px solid var(--line);
  color: var(--text-2);
  text-decoration: none;
}
.pub-link::after { content: " \2197"; }
.pub-link:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.card .pub-note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12.5px;
}

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

.news-card { padding: 24px 22px; }

.section-label-dot { margin-bottom: 16px; }
.section-label-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: -4px;
}

.news-item {
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  background: var(--card-inset);
  border: 1px solid var(--line);
}
.news-item + .news-item { margin-top: 10px; }

.news-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.news-date {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
}
.badge-new {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.03em;
}
.card .news-text {
  color: var(--text);
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.5;
}

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

.site-footer {
  grid-area: foot;
  margin-top: 4px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ==========================================================================
   Tablet: profile left, content + news stacked on the right
   ========================================================================== */

@media (max-width: 1120px) {
  .layout {
    grid-template-columns: 260px minmax(0, 1fr);
    grid-template-areas: none;
  }
  /* Children of <main> become grid items, so News can be placed after Home */
  .main { display: contents; }
  .sidebar { grid-column: 1; grid-row: 1 / span 6; }
  .tabs-wrap, .section-group, .news-col, .site-footer { grid-area: auto / 2; }
  .tabs-wrap   { order: 1; padding-bottom: 12px; margin-bottom: -12px; }
  #home        { order: 2; }
  .news-col    { order: 3; position: static; }
  #experience  { order: 4; }
  #beyond      { order: 5; }
  .site-footer { order: 6; }
  .main > .section-group + .section-group { margin-top: 0; }

  .profile-card { padding-left: 18px; padding-right: 18px; }
}

/* ==========================================================================
   Phone: single column, compact profile, sticky tabs
   ========================================================================== */

@media (max-width: 760px) {
  :root { --gap: 16px; --radius: 18px; }
  body { font-size: 15.5px; }

  .layout {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px 16px calc(28px + env(safe-area-inset-bottom));
  }
  .sidebar { position: static; grid-column: 1; grid-row: auto; order: 0; }
  .tabs-wrap, .section-group, .news-col, .site-footer { grid-area: auto / 1; }

  .card { padding: 22px 20px; }

  /* Profile becomes a horizontal header card */
  .profile-card {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    column-gap: 16px;
    align-items: center;
    padding: 16px;
    text-align: left;
  }
  .avatar { width: 84px; border-radius: 16px; }
  .avatar-placeholder { font-size: 30px; }
  .name { margin-top: 0; font-size: 1.3rem; }
  .chip { margin-top: 6px; }
  .role { margin-top: 6px; font-size: 13.5px; }

  .contact-list {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
    padding-top: 12px;
  }
  .contact-list a {
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--card-inset);
    border: 1px solid var(--line);
    font-size: 13.5px;
  }

  /* Tab bar sits right under the screen edge once it sticks */
  .tabs-wrap { margin-top: -8px; padding-top: 8px; }
  .tab {
    flex: 1;
    text-align: center;
    padding: 9px 8px;
  }

  .lead { font-size: 1.08rem; }

  .tl-head { flex-direction: column; gap: 0; }
  .tl-date { order: -1; margin-bottom: 1px; }
  .tl-place { display: block; }
  .tl-place::before { content: none; }

  .news-card { padding: 20px 18px; }

  .pub { flex-direction: column; gap: 8px; padding: 14px; }
  .pub-venue {
    flex: none;
    align-self: flex-start;
    height: auto;
    flex-direction: row;
    gap: 6px;
    padding: 2px 10px;
    border-radius: 999px;
  }
  .pub-venue-name { font-size: 12px; }
  .pub-venue-year { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
