/* ==========================================================================
   jaywen · motion layer
   交互与动效层。加载顺序在 styles.css 之后，只做增量，不改原有 token。
   技术栈：View Transitions API / CSS Scroll-Driven Animations / @starting-style
           / linear() 弹簧缓动 / 指针驱动的微交互（零依赖、零外部请求）
   ========================================================================== */

:root {
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --ease-spring: linear(0, .42 8%, .9 22%, 1.08 34%, 1.06 46%, .99 66%, 1);
  --dur-fast: .18s;
  --dur: .38s;
  --dur-slow: .72s;
}

/* --------------------------------------------------------------- 1. 跨页过渡
   跨文档视图过渡（Chrome 126+）。同一份 HTML 从 / 跳到 /articles/ 时，
   有 view-transition-name 的元素会独立过渡，其余走整页交叉淡出。 */

@view-transition {
  navigation: auto;
}

::view-transition-old(root) {
  animation: vt-out .26s var(--ease-in-out) both;
}
::view-transition-new(root) {
  animation: vt-in .42s var(--ease-out) both;
}

@keyframes vt-out {
  to { opacity: 0; transform: translateY(-6px); }
}
@keyframes vt-in {
  from { opacity: 0; transform: translateY(10px); }
}

/* 共享元素：页头与首页标题跨页时保持连续 */
.site-header { view-transition-name: site-header; }
.hero h1 { view-transition-name: hero-title; }

/* 页头在过渡中不倾斜、不缩放 */
::view-transition-group(site-header) { animation-duration: .34s; }
::view-transition-group(hero-title) { animation-duration: .46s; }

/* --------------------------------------------------------------- 2. 页面跳转进度条 */

.page-progress {
  position: fixed; inset: 0 auto auto 0; z-index: 90;
  width: 0; height: 2px; pointer-events: none;
  background: linear-gradient(90deg, var(--accent), #d98a63 60%, var(--sage));
  box-shadow: 0 0 12px rgba(201, 100, 66, .45);
  opacity: 0;
  transition: width .6s var(--ease-out), opacity .3s ease;
}
.page-progress.is-active { opacity: 1; }
.page-progress.is-done { width: 100% !important; opacity: 0; transition: width .2s ease, opacity .35s ease .12s; }

/* --------------------------------------------------------------- 3. 首屏入场 */

.hero__copy > * {
  animation: rise-in .78s var(--ease-out) both;
}
.hero__copy > *:nth-child(1) { animation-delay: .04s; }
.hero__copy > *:nth-child(2) { animation-delay: .10s; }
.hero__copy > *:nth-child(3) { animation-delay: .17s; }
.hero__copy > *:nth-child(4) { animation-delay: .24s; }
.hero__copy > *:nth-child(5) { animation-delay: .31s; }

@keyframes rise-in {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: none; }
}

.site-header {
  animation: header-in .6s var(--ease-out) both;
}
@keyframes header-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------- 4. 滚动入场
   scroll-driven animation：动画进度直接绑定滚动位置，不占用主线程。 */

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .band > .shell > .eyebrow,
    .section-head,
    .content-tile,
    .archive-row,
    .listing-head,
    .filter-bar,
    .index-card,
    .membership-card,
    .author-card,
    .ip-figure,
    .ip-face,
    .post-toc,
    .related,
    .article-nav,
    .doc-meta,
    .ip-showcase__intro,
    .statbar__item,
    .about-head,
    .about-p,
    .punch,
    .task-row li,
    .duo-card,
    .dom,
    .flow__row,
    .chain li,
    .criteria__item,
    .costcurve,
    .belief,
    .timeline__item,
    .pullquote,
    .formula,
    .about-tail p,
    .idcard,
    .login-card,
    .login-aside {
      animation: reveal-up .9s linear both;
      animation-timeline: view();
      animation-range: entry 4% entry 52%;
    }

    /* 同一行里的卡片错开，避免整排同时冒出来 */
    .content-grid--latest > .content-tile:nth-child(2),
    .content-grid--four > .content-tile:nth-child(2) { animation-range: entry 10% entry 60%; }
    .content-grid--latest > .content-tile:nth-child(3),
    .content-grid--four > .content-tile:nth-child(3) { animation-range: entry 16% entry 66%; }
    .content-grid--latest > .content-tile:nth-child(4),
    .content-grid--four > .content-tile:nth-child(4) { animation-range: entry 22% entry 72%; }
    .content-grid--latest > .content-tile:nth-child(5) { animation-range: entry 26% entry 76%; }
    .content-grid--latest > .content-tile:nth-child(6) { animation-range: entry 30% entry 80%; }

    .ip-faces > .ip-face:nth-child(2) { animation-range: entry 8% entry 56%; }
    .ip-faces > .ip-face:nth-child(3) { animation-range: entry 12% entry 60%; }
    .ip-faces > .ip-face:nth-child(4) { animation-range: entry 16% entry 64%; }

    /* 自述页的网格同样错峰，避免整排同时冒出来 */
    .statbar__item:nth-child(2),
    .task-row li:nth-child(2),
    .dom:nth-child(2),
    .criteria__item:nth-child(2),
    .chain li:nth-child(2) { animation-range: entry 10% entry 58%; }
    .statbar__item:nth-child(3),
    .task-row li:nth-child(3),
    .dom:nth-child(3),
    .criteria__item:nth-child(3),
    .chain li:nth-child(3) { animation-range: entry 14% entry 62%; }
    .statbar__item:nth-child(4),
    .task-row li:nth-child(4),
    .criteria__item:nth-child(4),
    .chain li:nth-child(4) { animation-range: entry 18% entry 66%; }
    .task-row li:nth-child(5),
    .chain li:nth-child(5) { animation-range: entry 22% entry 70%; }
    .chain li:nth-child(6) { animation-range: entry 26% entry 74%; }
  }
}

@keyframes reveal-up {
  from { opacity: 0; transform: translateY(26px) scale(.985); }
  to { opacity: 1; transform: none; }
}

/* 首屏内的卡片不参与滚动动画（已在视口里，会瞬间跳到终态） */
.hero [data-reveal],
.hero__copy [data-reveal] {
  animation: none !important;
}

/* --------------------------------------------------------------- 5. hero 光标光晕与网格 */

.hero {
  position: relative;
  isolation: isolate;
  /* blend 需要一个不透明基准，否则图片是与其下方的"透明"混合 */
  background: var(--bg);
  /* 光晕/环境光是绝对定位且故意外溢的装饰，裁掉水平逸出，避免整页横滚。
     clip 不会把另一轴变成 scroll，也不创建滚动容器，IP 的 blend 不受影响。 */
  overflow-x: clip;
}

.hero__ambient {
  position: absolute; inset: -10% -6%;
  z-index: -1; pointer-events: none;
  background:
    radial-gradient(420px circle at var(--mx, 62%) var(--my, 42%), rgba(201, 100, 66, .13), transparent 62%),
    radial-gradient(520px circle at calc(100% - var(--mx, 62%)) calc(100% - var(--my, 42%)), rgba(168, 182, 155, .13), transparent 66%);
  opacity: 0;
  transition: opacity .6s var(--ease-out);
}
.hero:hover .hero__ambient { opacity: 1; }

/* 纸面上的细网格，滚出时轻微上移 —— 给静态版式一点纵深 */
.hero::before {
  content: '';
  position: absolute; inset: 0; z-index: -2;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(20, 20, 19, .028) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(20, 20, 19, .028) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 70% 62% at 50% 44%, #000 30%, transparent 78%);
  animation: grid-drift linear both;
  animation-timeline: scroll(root);
  animation-range: 0 60vh;
}
@keyframes grid-drift {
  to { background-position: 0 40px, 0 40px; }
}

/* --------------------------------------------------------------- 6. IP 形象舞台 */

.hero__visual {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  margin: 0; padding: 0;
  border: 0; background: transparent; box-shadow: none;
}

.hero__visual .hero__ip {
  position: relative; z-index: 2;
  display: block;
  width: auto;
  height: min(72svh, 706px);
  max-width: 100%;
  object-fit: contain;
  /* darken：纯白底取页面纸色，深色主体与彩色装饰块原样保留。
     前提是 hero 有不透明底色（见上方 .hero 的 background） */
  mix-blend-mode: darken;
  -webkit-mask-image:
    linear-gradient(to bottom, transparent 0, #000 3.2%, #000 94%, transparent 100%),
    linear-gradient(to right, transparent 0, #000 2.4%, #000 97.6%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(to bottom, transparent 0, #000 3.2%, #000 94%, transparent 100%),
    linear-gradient(to right, transparent 0, #000 2.4%, #000 97.6%, transparent 100%);
  mask-composite: intersect;
  animation: ip-enter 1.05s var(--ease-spring) both .08s, ip-breathe 7.5s ease-in-out infinite 1.2s;
  translate: var(--ip-x, 0) var(--ip-y, 0);
  will-change: transform;
}

@keyframes ip-enter {
  from { opacity: 0; transform: translateY(46px) scale(.94); }
  to { opacity: 1; transform: none; }
}
@keyframes ip-breathe {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}

/* 背后的赤陶光晕 */
.hero__halo {
  position: absolute; z-index: 1;
  top: 4%; left: 50%; translate: -50% 0;
  width: min(132%, 470px); aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201, 100, 66, .15), rgba(201, 100, 66, .05) 46%, transparent 68%);
  filter: blur(6px);
  animation: halo-pulse 9s ease-in-out infinite;
}
@keyframes halo-pulse {
  0%, 100% { opacity: .85; scale: 1; }
  50% { opacity: 1; scale: 1.06; }
}

/* 一道极细的圆环，缓慢自转 */
.hero__ring {
  position: absolute; z-index: 1;
  top: 0; left: 50%; translate: -50% 0;
  width: min(126%, 452px); aspect-ratio: 1;
  border-radius: 50%;
  border: 1px dashed rgba(201, 100, 66, .22);
  animation: ring-spin 64s linear infinite;
}
@keyframes ring-spin {
  to { rotate: 360deg; }
}

/* 落地阴影 */
.hero__shadow {
  position: absolute; z-index: 0;
  bottom: 6%; left: 50%; translate: -50% 0;
  width: 52%; height: 26px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(20, 20, 19, .16), transparent 70%);
  filter: blur(10px);
  animation: shadow-breathe 7.5s ease-in-out infinite 1.2s;
}
@keyframes shadow-breathe {
  0%, 100% { scale: 1; opacity: .9; }
  50% { scale: .9; opacity: .62; }
}

/* 浮动信息片 */
.hero__chip {
  position: absolute; z-index: 3;
  padding: 9px 13px;
  background: rgba(250, 249, 245, .88);
  border: 1px solid var(--line-strong);
  font: 500 10px/1.5 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 18px rgba(20, 20, 19, .06);
  animation: chip-in .7s var(--ease-spring) both;
}
.hero__chip b { color: var(--ink); font-weight: 700; }
.hero__chip--tl { top: 8%; left: -16%; animation-delay: .5s; }
.hero__chip--br { bottom: 17%; right: -14%; animation-delay: .62s; }
@keyframes chip-in {
  from { opacity: 0; transform: translateY(10px) scale(.94); }
  to { opacity: 1; transform: none; }
}

.hero__visual figcaption {
  position: relative; z-index: 2;
  margin-top: 20px;
  border: 0; padding: 0;
  font-size: 13px; font-weight: 500;
  letter-spacing: .04em;
  color: var(--dim);
  text-align: center;
}

/* 窄屏：去掉光晕与浮动片，避免压到文字 */
@media (width <= 900px) {
  .hero::before { display: none; }
  .hero__chip { display: none; }
  .hero__ring { display: none; }
  .hero__visual .hero__ip { height: min(52svh, 460px); }
}

/* --------------------------------------------------------------- 7. 磁性按钮 */

.button, .nav-menu__trigger, .auth-link, .admin-btn {
  transition:
    background-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    transform var(--dur) var(--ease-spring),
    box-shadow var(--dur) var(--ease-out);
  will-change: transform;
}

.button[data-magnetic] { position: relative; }
.button[data-magnetic]::after {
  content: '';
  position: absolute; inset: -1px;
  border-radius: inherit;
  background: radial-gradient(120px circle at var(--bx, 50%) var(--by, 50%), rgba(255, 255, 255, .34), transparent 62%);
  opacity: 0;
  transition: opacity var(--dur) var(--ease-out);
  pointer-events: none;
}
.button[data-magnetic]:hover::after { opacity: 1; }
.button:active { transform: scale(.972) !important; }

/* --------------------------------------------------------------- 8. 卡片倾斜与高光 */

[data-tilt] {
  transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .5s var(--ease-out);
  transform-style: preserve-3d;
}
[data-tilt].is-tilting {
  transition: transform .08s linear;
}

.content-tile, .index-card, .membership-card {
  position: relative;
  transition:
    transform .42s var(--ease-out),
    box-shadow .42s var(--ease-out),
    border-color .3s var(--ease-out);
}
.content-tile::after,
.index-card::after,
.membership-card::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  background: radial-gradient(260px circle at var(--cx, 50%) var(--cy, 0%), rgba(201, 100, 66, .10), transparent 68%);
  opacity: 0;
  transition: opacity .42s var(--ease-out);
  pointer-events: none;
}
@media (hover: hover) {
  .content-tile:hover,
  .index-card:hover,
  .membership-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--line-strong);
  }
  .content-tile:hover::after,
  .index-card:hover::after,
  .membership-card:hover::after { opacity: 1; }
}

/* --------------------------------------------------------------- 9. 数字滚动 */

.hero__stats strong {
  font-variant-numeric: tabular-nums;
  transition: color var(--dur) var(--ease-out);
}
.hero__stats strong.is-counting { color: var(--accent); }

/* --------------------------------------------------------------- 10. 链接与导航微交互 */

.site-nav a,
.nav-menu__item,
.footer a,
.site-footer__inner a {
  position: relative;
}
.nav-menu__item::after,
.site-footer__inner nav a::after {
  content: '';
  position: absolute; left: 0; bottom: -3px;
  width: 100%; height: 1px;
  background: currentColor;
  transform: scaleX(0); transform-origin: left;
  transition: transform .34s var(--ease-out);
}
.nav-menu__item:hover::after,
.site-footer__inner nav a:hover::after { transform: scaleX(1); }

.nav-menu__panel,
.auth-menu__panel {
  transform-origin: top left;
  transition:
    opacity .26s var(--ease-out),
    transform .34s var(--ease-spring),
    visibility .26s;
}

/* 页头滚过首屏后收紧 */
.site-header {
  transition: background-color .4s var(--ease-out), box-shadow .4s var(--ease-out), padding .4s var(--ease-out);
}
.site-header.is-stuck {
  background: rgba(245, 244, 237, .86);
  backdrop-filter: blur(14px) saturate(1.1);
  box-shadow: 0 1px 0 var(--line), 0 8px 28px rgba(20, 20, 19, .05);
}

/* 阅读进度条底色改渐变 */
.nav-progress {
  background: linear-gradient(90deg, var(--accent), #d98a63 55%, var(--sage));
  transition: width .1s linear;
}

/* --------------------------------------------------------------- 11. 表单与反馈 */

.field input,
.subscribe-form input {
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur) var(--ease-out), background-color var(--dur-fast) ease;
}
.subscribe-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(201, 100, 66, .12);
}

.form-note {
  transition: opacity .3s ease, transform .3s var(--ease-out);
}

/* 订阅成功时露出开心表情 */
.form-note.is-ok {
  display: flex; align-items: center; gap: 8px;
}
.form-note.is-ok::before {
  content: '';
  width: 26px; height: 26px;
  flex: 0 0 26px;
  background: url('/assets/jaywen-face-happy.jpg') center/cover no-repeat;
  border-radius: 50%;
  animation: pop-in .5s var(--ease-spring) both;
}
.form-note.is-error::before {
  content: '';
  width: 26px; height: 26px;
  flex: 0 0 26px;
  background: url('/assets/jaywen-face-wow.jpg') center/cover no-repeat;
  border-radius: 50%;
}
.form-note.is-error { display: flex; align-items: center; gap: 8px; }

@keyframes pop-in {
  from { opacity: 0; transform: scale(.4) rotate(-12deg); }
  to { opacity: 1; transform: none; }
}

/* 收藏按钮 */
.bookmark-button {
  transition: transform .3s var(--ease-spring), color .2s ease;
}
.bookmark-button.is-bookmarked { color: var(--accent); transform: scale(1.16); }

/* --------------------------------------------------------------- 12. 作者卡 */

.author-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: center; gap: 18px;
  margin-top: 56px; padding: 22px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  border-radius: var(--radius);
  transition: border-color var(--dur) var(--ease-out), transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.author-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.author-card__avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  object-fit: cover;
  filter: saturate(.94);
  transition: filter var(--dur) var(--ease-out), transform .5s var(--ease-spring);
}
.author-card:hover .author-card__avatar {
  filter: saturate(1.06);
  transform: scale(1.05) rotate(-2deg);
}
.author-card__name {
  margin: 0;
  font-family: var(--display);
  font-size: 19px; font-weight: 600; color: var(--ink);
  display: flex; align-items: baseline; gap: 9px;
}
.author-card__name span {
  font-family: var(--sans);
  font-size: 12px; font-weight: 500; color: var(--dim);
  letter-spacing: .04em;
}
.author-card__bio {
  margin: 5px 0 0;
  font-size: 13.5px; line-height: 1.6; color: var(--muted);
}
.author-card__link {
  font-size: 13px; font-weight: 600; color: var(--accent);
  white-space: nowrap;
  transition: gap .3s var(--ease-out);
}
.author-card__link:hover { text-decoration: underline; text-underline-offset: 4px; }

@media (width <= 640px) {
  .author-card { grid-template-columns: 52px minmax(0, 1fr); row-gap: 12px; padding: 18px; }
  .author-card__avatar { width: 52px; height: 52px; }
  .author-card__link { grid-column: 2; }
}

/* --------------------------------------------------------------- 13. 关于页 IP 展示 */

.ip-showcase {
  padding-block: 88px 96px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg), var(--paper-deep));
}

.ip-showcase__intro {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  align-items: center; gap: 56px;
}

.ip-portrait {
  position: relative;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
  background: var(--paper);
}
.ip-portrait img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .8s var(--ease-out), filter .6s var(--ease-out);
}
.ip-portrait:hover img { transform: scale(1.06); filter: saturate(1.05); }
.ip-portrait__ring {
  position: absolute; inset: -10px;
  border-radius: 50%;
  border: 1px dashed rgba(201, 100, 66, .3);
  animation: ring-spin 48s linear infinite;
  pointer-events: none;
}

.ip-intro__text h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(38px, 5vw, 62px);
  font-weight: 600; line-height: 1;
  letter-spacing: -.02em;
  color: var(--ink);
}
.ip-intro__role {
  margin: 12px 0 0;
  font: 500 12px/1.6 var(--mono);
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent);
}
.ip-attrs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin: 26px 0 0;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.ip-attrs dt {
  font: 600 10px/1 var(--mono);
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 7px;
}
.ip-attrs dd { margin: 0; font-size: 14px; line-height: 1.55; color: var(--text); }

.ip-faces {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-top: 56px;
}
.ip-face {
  margin: 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.ip-face__frame {
  display: block;
  width: 100%; max-width: 128px;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  transition: border-color .3s ease, box-shadow .4s ease, transform .5s var(--ease-spring);
}
.ip-face__frame img {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 52% 24%;
  transform: scale(1.42);
  transition: transform .55s var(--ease-spring);
}
.ip-face:hover .ip-face__frame {
  border-color: var(--accent);
  box-shadow: 0 12px 28px rgba(201, 100, 66, .18);
  transform: translateY(-5px);
}
.ip-face:hover .ip-face__frame img { transform: scale(1.52); }
.ip-face:hover img {
  transform: translateY(-6px) scale(1.04);
  border-color: var(--accent);
  box-shadow: 0 12px 28px rgba(201, 100, 66, .18);
}
.ip-face figcaption {
  font: 500 11px/1 var(--mono);
  letter-spacing: .1em;
  color: var(--dim);
}

.ip-figures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin-top: 34px;
}
.ip-figure {
  margin: 0;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .35s ease, box-shadow .4s var(--ease-out), transform .4s var(--ease-out);
}
.ip-figure:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}
.ip-figure img {
  display: block; width: 100%; height: auto;
  transition: transform .7s var(--ease-out);
}
.ip-figure:hover img { transform: scale(1.03); }
.ip-figure figcaption {
  display: flex; flex-direction: column; gap: 4px;
  padding: 15px 18px;
  border-top: 1px solid var(--line);
}
.ip-figure figcaption b { font-size: 13px; font-weight: 600; color: var(--ink); }
.ip-figure figcaption span { font-size: 12.5px; line-height: 1.55; color: var(--muted); }

@media (width <= 900px) {
  .ip-showcase__intro { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .ip-portrait { width: 180px; }
  .ip-attrs { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .ip-figures { grid-template-columns: minmax(0, 1fr); }
}
@media (width <= 540px) {
  .ip-faces { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ip-showcase { padding-block: 64px 72px; }
}

/* --------------------------------------------------------------- 14. 404 */

.notfound {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  align-items: center; gap: 60px;
  min-height: min(70svh, 620px);
  padding-block: 80px;
}
.notfound h1 {
  margin: 10px 0 0;
  font-family: var(--display);
  font-size: clamp(40px, 6vw, 76px);
  font-weight: 600; line-height: 1.04;
  letter-spacing: -.02em;
}
.notfound p { margin: 18px 0 0; color: var(--muted); font-size: 17px; }
.notfound__figure {
  position: relative; margin: 0;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.notfound__frame {
  position: relative; z-index: 2;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  animation: ip-breathe 7s ease-in-out infinite;
}
.notfound__frame img {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 52% 24%;
  transform: scale(1.42);
}
.notfound__figure figcaption {
  font: 500 11px/1.5 var(--mono);
  letter-spacing: .1em;
  color: var(--dim);
}
@media (width <= 760px) {
  .notfound { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .notfound__figure { width: 160px; }
}

/* --------------------------------------------------------------- 15. 无障碍与降级 */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  /* JS 会写 inline style，这里必须 !important 才能压住 */
  .hero__ip { translate: none !important; }
  .button[data-magnetic] { transform: none !important; }
  .page-progress { display: none; }
}

/* 触摸设备：取消倾斜与光标相关效果 */
@media (hover: none) {
  [data-tilt] { transform: none !important; }
  .hero__ambient { display: none; }
}

html { scrollbar-gutter: stable; }

/* --------------------------------------------------------------- 16. 窄屏页头重排
   390px 下原布局会把「登录」挤到第三行，这里让导航独占一行、五个入口均分。
   关键：必须一并清掉上一断点留下的 min-width: 72px，否则五个入口总宽超出
   shell（358px），nowrap 会把整行顶出视口，产生 84px 的横向滚动。 */

@media (width <= 620px) {
  .site-header__inner {
    flex-wrap: wrap;
    row-gap: 10px;
    padding-block: 12px;
    min-height: 0;
    gap: 10px;
  }
  .site-nav {
    width: 100%;
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 2px;
    font-size: 12.5px;
  }
  .site-nav .nav-menu,
  .site-nav .auth-menu { width: auto; min-width: 0; }
  .site-nav .nav-menu__trigger,
  .site-nav .membership-link,
  .site-nav .auth-link {
    width: auto; min-width: 0;
    padding-inline: 6px;
    white-space: nowrap;
  }
  .site-nav .auth-menu__panel { right: 0; left: auto; transform-origin: top right; }
  .site-nav .nav-menu__panel { left: 0; right: auto; transform-origin: top left; }
  /* 第三个导航（Research）靠右，panel 左对齐会顶出视口，改右对齐 */
  .site-nav .nav-menu:nth-of-type(3) .nav-menu__panel {
    left: auto; right: 0; transform-origin: top right;
  }
  /* 保险：panel 收起时仍占 scrollWidth，页头裁掉水平逸出，杜绝整页横滚 */
  .site-header { overflow-x: clip; }
}

@media (width <= 380px) {
  .site-nav { font-size: 11.5px; gap: 0; }
  .site-nav .nav-menu__trigger,
  .site-nav .membership-link,
  .site-nav .auth-link { padding-inline: 4px; }
}
