/* ============================================================================
 * main.css —— 布局与组件
 * ==========================================================================*/

/* ── 区块基础 ───────────────────────────────────────────────────────────── */
.section {
  position: relative;
  padding: clamp(74px, 9vw, 132px) 0;
}
.section--hero {
  padding-top: clamp(118px, 16vh, 180px);
  padding-bottom: clamp(32px, 5vw, 64px);
}

.sec-head {
  max-width: 640px;
  margin-bottom: clamp(30px, 4vw, 54px);
}
.sec-title {
  margin-top: 10px;
  font-size: var(--fs-h2);
  letter-spacing: -.03em;
}
.sec-desc {
  margin-top: 14px;
  color: var(--fg-2);
  font-size: .97rem;
}

/* ── 导航 ───────────────────────────────────────────────────────────────── */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 60;
  padding-top: max(16px, env(safe-area-inset-top));
  transition: padding-top var(--dur-2) var(--ease);
}
.nav > .wrap { position: relative; }

.nav__bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 10px 9px 14px;
  border-radius: var(--r-full);
  transition: padding var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease),
              box-shadow var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.nav.is-stuck { padding-top: max(10px, env(safe-area-inset-top)); }
.nav.is-stuck .nav__bar {
  padding: 7px 8px 7px 12px;
  background: var(--panel);
  box-shadow: 0 22px 44px -32px rgb(0 0 0 / .9), inset 0 1px 0 var(--rim-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.brand__mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--invert-bg);
  color: var(--invert-fg);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .04em;
}
.brand__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}
.brand__name {
  font-size: .94rem;
  font-weight: 600;
  letter-spacing: -.01em;
}
.brand__role {
  font-size: .71rem;
  color: var(--fg-3);
  white-space: nowrap;
}

.nav__links {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}
.nav__link {
  position: relative;
  padding: .48em .8em;
  border-radius: var(--r-full);
  font-size: .9rem;
  color: var(--fg-2);
  transition: color var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease);
}
.nav__link:hover { color: var(--fg); background: var(--glass-2); }
.nav__link.is-active { color: var(--fg); }
.nav__link.is-active::after {
  content: "";
  position: absolute;
  left: 50%; bottom: 1px;
  width: 4px; height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: currentColor;
}

.nav__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}
.nav__links + .nav__actions { margin-left: 6px; }

.burger {
  position: relative;
  display: block;
  width: 17px;
  height: 12px;
}
.burger i {
  position: absolute;
  left: 0;
  width: 100%;
  height: 1.5px;
  border-radius: 2px;
  background: currentColor;
  transition: transform var(--dur-2) var(--ease), opacity var(--dur-2) var(--ease);
}
.burger i:first-child { top: 0; }
.burger i:last-child { bottom: 0; }
.is-open .burger i:first-child { transform: translateY(5.5px) rotate(45deg); }
.is-open .burger i:last-child { transform: translateY(-5.5px) rotate(-45deg); }
.nav__burger { display: none; }

/* 主题按钮：明暗两个图标切换 */
.icon--sun, .icon--moon { transition: transform .5s var(--ease-out), opacity .3s; }
html[data-theme="dark"] .icon--sun { display: none; }
html[data-theme="light"] .icon--moon { display: none; }

/* ── 首屏 ───────────────────────────────────────────────────────────────── */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr);
  gap: clamp(30px, 5vw, 62px);
  align-items: center;
  min-height: min(80svh, 780px);
}

.hero__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.hero__title {
  margin-top: 14px;
  font-size: var(--fs-h1);
  letter-spacing: -.045em;
  color: var(--fg);
  background-image: linear-gradient(176deg, var(--fg) 8%, var(--fg-2) 135%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero__role {
  margin-top: 12px;
  font-size: clamp(.92rem, 1.3vw, 1.02rem);
  letter-spacing: .02em;
  color: var(--fg-2);
}

.hero__tagline {
  margin-top: 22px;
  max-width: 34em;
  font-size: clamp(1.02rem, 1.5vw, 1.22rem);
  line-height: 1.7;
  color: var(--fg-2);
}

.hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 34px;
}

.hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 40px;
  margin-top: 42px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}
.meta__k {
  display: block;
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.meta__v {
  display: block;
  margin-top: 3px;
  font-size: .9rem;
  color: var(--fg);
}

.hero__side { display: flex; justify-content: flex-end; }

/* 终端卡片 */
.terminal {
  width: min(100%, 460px);
  overflow: hidden;
  font-size: .78rem;
}
.terminal__bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.terminal__bar .dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--fg-2);
}
.terminal__bar .dot:nth-child(1) { opacity: .28; }
.terminal__bar .dot:nth-child(2) { opacity: .5; }
.terminal__bar .dot:nth-child(3) { opacity: .8; }
.terminal__title {
  margin-left: 8px;
  font-size: .72rem;
  color: var(--fg-3);
}
.terminal__body {
  margin: 0;
  padding: 18px 18px 22px;
  min-height: 178px;
  font-size: .76rem;
  line-height: 1.95;
  color: var(--fg-3);
  white-space: pre-wrap;
  word-break: break-word;
}
.t-line { display: block; animation: line-in .5s var(--ease-out) both; animation-delay: calc(var(--i, 0) * .26s); }
.t-line.is-cmd { color: var(--fg); }
.t-line.is-out { color: var(--fg-2); }
@keyframes line-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.caret {
  display: inline-block;
  width: 6px; height: 1em;
  vertical-align: -2px;
  background: var(--fg);
  animation: blink 1.1s steps(1, end) infinite;
}
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

.scroll-hint {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: clamp(28px, 5vw, 56px);
  font-size: .68rem;
  letter-spacing: .26em;
  color: var(--fg-3);
}
.scroll-hint__line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line-2), transparent);
}

/* ── 项目卡片 ───────────────────────────────────────────────────────────── */
.grid { display: grid; gap: clamp(16px, 2.2vw, 24px); }
.grid--projects { grid-template-columns: repeat(auto-fill, minmax(min(100%, 318px), 1fr)); }

.card {
  display: flex;
  flex-direction: column;
  padding: 20px;
  border-radius: var(--r-lg);
  transition: transform .5s var(--ease-out), border-color .4s var(--ease-out),
              box-shadow .5s var(--ease-out);
}
.card:hover {
  transform: translateY(-6px);
  border-color: var(--line-2);
  box-shadow: 0 46px 90px -50px rgb(0 0 0 / .92), inset 0 1px 0 var(--rim-soft);
}

.card__cover {
  position: relative;
  display: flex;
  align-items: flex-end;
  height: 118px;
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  background:
    radial-gradient(120% 150% at 6% 0%, var(--glass-2), transparent 62%),
    repeating-linear-gradient(115deg, var(--line) 0 1px, transparent 1px 24px);
}
.card__mono {
  font-family: var(--font-mono);
  font-size: 3.6rem;
  font-weight: 600;
  line-height: .84;
  color: var(--fg);
  opacity: .13;
  transform: translateY(7px);
  transition: opacity .5s var(--ease-out), transform .5s var(--ease-out);
}
.card:hover .card__mono { opacity: .24; transform: none; }

.card__metric {
  position: absolute;
  top: 12px; right: 12px;
  padding: .24em .66em;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--glass-strong);
  font-family: var(--font-mono);
  font-size: .68rem;
  color: var(--fg-2);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.card__title { font-size: var(--fs-h3); letter-spacing: -.02em; }
.card__summary {
  flex: 1;
  margin-top: 10px;
  font-size: .9rem;
  line-height: 1.75;
  color: var(--fg-2);
}
.card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}
.card__foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: var(--fs-xs);
  color: var(--fg-3);
}
.card__links {
  display: flex;
  gap: 14px;
  margin-left: auto;
}
.card__link {
  display: inline-flex;
  align-items: center;
  gap: .38em;
  color: var(--fg-2);
  transition: color var(--dur-2) var(--ease);
}
.card__link:hover { color: var(--fg); }
.card__link .icon { width: 15px; height: 15px; }

@media (min-width: 780px) {
  .card--featured { grid-column: span 2; }
  .card--featured .card__cover { height: 168px; }
  .card--featured .card__mono { font-size: 5rem; }
  .card--featured .card__summary { font-size: .95rem; max-width: 62ch; }
}

/* ── 技能 ───────────────────────────────────────────────────────────────── */
.skills {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 258px), 1fr));
  gap: clamp(14px, 2vw, 22px);
}
.skill-group { padding: 22px; border-radius: var(--r-lg); }
.skill-group__title {
  font-family: var(--font-mono);
  font-size: .74rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.skill-list {
  display: flex;
  flex-direction: column;
  margin-top: 14px;
}
.skill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: .58em 0;
  border-bottom: 1px solid var(--line);
}
.skill:last-child { border-bottom: 0; }
.skill__name { font-size: .9rem; }
.skill__dots { display: inline-flex; gap: 4px; flex: none; }
.skill__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--line-2);
}
.skill__dot.is-on { background: var(--fg); }

/* ── 时间线 ─────────────────────────────────────────────────────────────── */
.timeline {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 2.2vw, 24px);
}
.timeline::before {
  content: "";
  position: absolute;
  left: 7px; top: 14px; bottom: 14px;
  width: 1px;
  background: linear-gradient(180deg, var(--line-2), var(--line) 55%, transparent);
}
.tl { position: relative; padding-left: 38px; }
.tl__node {
  position: absolute;
  left: 0; top: 26px;
  display: grid;
  place-items: center;
  width: 15px; height: 15px;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  background: var(--bg);
}
.tl__node::after {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--fg);
}
.tl--edu .tl__node::after {
  width: 6px; height: 6px;
  background: transparent;
  border: 1px solid var(--fg-2);
}
.tl__card { padding: 22px 24px; border-radius: var(--r-lg); }
.tl__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 16px;
}
.tl__role { font-size: var(--fs-h3); }
.tl__period {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-3);
}
.tl__org {
  margin-top: 5px;
  font-size: .89rem;
  color: var(--fg-2);
}
.tl__points {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 15px;
}
.tl__point {
  position: relative;
  padding-left: 18px;
  font-size: .9rem;
  line-height: 1.72;
  color: var(--fg-2);
}
.tl__point::before {
  content: "";
  position: absolute;
  left: 0; top: .68em;
  width: 8px; height: 1px;
  background: var(--line-2);
}
.tl__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }

/* ── 文章列表 ───────────────────────────────────────────────────────────── */
.posts { border-top: 1px solid var(--line); }
.post {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  padding: 22px 14px;
  border-bottom: 1px solid var(--line);
  transition: background-color var(--dur-2) var(--ease), padding-left .4s var(--ease-out);
}
.post:hover { background: var(--glass); padding-left: 22px; }
.post__date {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-3);
}
.post__title { font-size: 1.02rem; font-weight: 500; letter-spacing: -.01em; }
.post__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 7px;
  font-size: var(--fs-xs);
  color: var(--fg-3);
}
.post__meta .sep { opacity: .5; }
.post__summary {
  max-width: 68ch;
  margin-top: 9px;
  font-size: .88rem;
  line-height: 1.7;
  color: var(--fg-2);
}
.post__go {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--fg-3);
  transition: transform .4s var(--ease-out), color var(--dur-2) var(--ease),
              border-color var(--dur-2) var(--ease);
}
.post__go .icon { width: 15px; height: 15px; }
.post:hover .post__go { transform: translateX(4px); color: var(--fg); border-color: var(--line-2); }

/* ── 关于 ───────────────────────────────────────────────────────────────── */
.about {
  display: grid;
  grid-template-columns: minmax(0, 268px) minmax(0, 1fr);
  gap: clamp(24px, 4vw, 54px);
  align-items: start;
}
.about__card { padding: 16px; border-radius: var(--r-lg); }
.about__avatar {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--r-md);
  object-fit: cover;
  background: var(--glass-2);
  border: 1px solid var(--line);
}
.about__facts {
  display: flex;
  flex-direction: column;
  gap: 11px;
  margin-top: 18px;
}
.fact {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
  font-size: .84rem;
}
.fact:last-child { border-bottom: 0; padding-bottom: 0; }
.fact__k { flex: none; color: var(--fg-3); }
.fact__v { color: var(--fg-2); text-align: right; }

.about__body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.about__p {
  font-size: .98rem;
  line-height: 1.85;
  color: var(--fg-2);
}
.about__p:first-of-type { color: var(--fg); font-size: 1.04rem; }

.now {
  margin-top: 12px;
  padding: 20px 22px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
}
.now__title {
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.now__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
}

/* ── 联系 ───────────────────────────────────────────────────────────────── */
.contact {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(30px, 5vw, 60px);
  text-align: center;
}
.contact__body {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 700px;
}
.contact__body .sec-title { margin-top: 12px; }
.contact__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 26px;
}
.socials {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 30px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}
.social {
  display: inline-flex;
  align-items: center;
  gap: .5em;
  padding: .5em .95em;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--glass);
  font-size: .86rem;
  color: var(--fg-2);
  transition: transform var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease),
              border-color var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease);
}
.social:hover {
  transform: translateY(-2px);
  color: var(--fg);
  border-color: var(--line-2);
  background: var(--glass-2);
}
.social .icon { width: 16px; height: 16px; }

/* ── 页脚 ───────────────────────────────────────────────────────────────── */
.footer {
  margin-top: clamp(40px, 7vw, 90px);
  padding: 34px 0 46px;
  border-top: 1px solid var(--line);
}
.footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.footer__copy {
  font-size: var(--fs-sm);
  color: var(--fg-3);
}
.link-quiet {
  font-family: var(--font-mono);
  font-size: .74rem;
  letter-spacing: .12em;
  color: var(--fg-3);
  transition: color var(--dur-2) var(--ease);
}
.link-quiet:hover { color: var(--fg); }

/* ── 响应式 ─────────────────────────────────────────────────────────────── */
@media (max-width: 1000px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    gap: 40px;
  }
  .hero__side { justify-content: flex-start; }
  .terminal { width: min(100%, 560px); }
  .hero__meta { gap: 14px 32px; margin-top: 34px; }
}

@media (max-width: 880px) {
  html { scroll-padding-top: 84px; }

  .nav__burger { display: grid; }
  .nav__links {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    z-index: 5;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    margin-left: 0;
    padding: 10px;
    border: 1px solid var(--glass-brd);
    border-radius: var(--r-lg);
    background: var(--panel);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    backdrop-filter: blur(24px) saturate(160%);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    /* visibility 用 0s 切换：打开时立即可见，关闭时等淡出结束再隐藏。
       不要让它参与时长过渡，否则某些渲染时序下会残留 hidden。 */
    transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease),
                visibility 0s linear var(--dur-2);
  }
  .nav__links.is-open {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease),
                visibility 0s linear 0s;
  }
  .nav__link { padding: .68em .9em; font-size: .98rem; }
  .nav__link.is-active { background: var(--glass-2); }
  .nav__link.is-active::after { display: none; }
  /* 移动端菜单是绝对定位的，操作按钮要重新靠右（覆盖上面的相邻兄弟规则） */
  .nav__bar .nav__actions { margin-left: auto; }
}

@media (max-width: 760px) {
  .post {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 14px;
    padding: 20px 10px;
  }
  .post__date { grid-column: 1; }
  .post__body { grid-column: 1 / -1; }
  .post__go { grid-row: 1 / span 2; align-self: center; }
  .post:hover { padding-left: 16px; }

  .about { grid-template-columns: minmax(0, 1fr); }
  .about__card { max-width: 320px; }

  .tl { padding-left: 28px; }
  .timeline::before { left: 6px; }
  .tl__node { top: 20px; width: 13px; height: 13px; }
  .tl__card { padding: 18px 18px; }
}

@media (max-width: 560px) {
  .brand__role { display: none; }
  .hero__cta .btn { flex: 1 1 auto; justify-content: center; }
  .contact__actions .btn { flex: 1 1 auto; justify-content: center; }
}
