/* ============================================================
   3D 动效层 · 仅电脑端
   语言：透视、卡片按指针倾斜、扇形向观者展开、弹窗从上方翻入。
   表面一律哑光：磨砂 backdrop-filter、白色内反光条、发光 text-shadow
   全部撤掉，深度只靠 css I 的双向 neu 阴影来做。
   只在交互时动——静止不放循环动画。
   ============================================================ */

:root {
  --m3-ease: cubic-bezier(.22, 1, .36, 1);
  --m3-snap: cubic-bezier(.2, .9, .25, 1.28);
  --m3-p: 1000px;
  --m3-shadow-rest: 0 10px 26px rgba(90, 74, 54, .16), 6px 6px 14px var(--neu-shadow-dark, rgba(166, 160, 146, .38)), -6px -6px 14px var(--neu-shadow-light, rgba(255, 255, 255, .82));
  --m3-shadow-tilt: 0 26px 54px rgba(90, 74, 54, .24), 8px 8px 18px var(--neu-shadow-dark, rgba(166, 160, 146, .4)), -8px -8px 18px var(--neu-shadow-light, rgba(255, 255, 255, .86));
}

/* ============================================================
   1. 哑光化：撤掉反光与发光
   ============================================================ */
.fan-item,
.welcome-card,
.contact-card,
.contact-item,
.contact-close,
body.home .toast,
body.home .nav.scrolled {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  background: var(--c-panel) !important;
}

/* 顶栏已经 92% 不透明，那层 blur 只提供玻璃味、不提供可读性：撤掉，
   把透明度补到 97%，压在照片上也不糊字。 */
.nav {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  background-color: rgba(250, 249, 245, .97) !important;
}

body.home .fan-item,
body.home .welcome-card,
body.home .contact-card {
  border: 1px solid var(--c-line) !important;
}

/* 那道 115° 斜着扫过去的白色高光 */
.fan-item::after,
.welcome-card::after,
.contact-card::after {
  display: none !important;
}

/* 发光：标题、kicker、弹窗字、品牌点、侧栏线 */
.hero-title,
.kicker,
.welcome-card,
.contact-title,
.contact-link,
.fan-item span,
body.home .side-text {
  text-shadow: none !important;
}

body.home .brand::before,
body.home .side-line {
  box-shadow: none !important;
}

/* 侧栏那条 2s 无限脉冲的线：静止不该一直喘气 */
body.home .side-line {
  animation: none !important;
  background: var(--c-line-2) !important;
  transition: background .3s var(--m3-ease), width .38s var(--m3-ease);
}

body.home .side-hint:hover .side-line,
body.home .side-hint.open .side-line {
  background: var(--c-clay) !important;
  width: 62px;
}

/* 悬停不再靠"变亮"，改成实色描边 + 抬升 */
.fan-item:hover,
.contact-item:hover,
.welcome-card:hover {
  background: var(--c-panel) !important;
}

.contact-item:hover {
  border-color: var(--c-clay-lt) !important;
}

/* 弹窗遮罩：不要磨砂，只要一层压暗的暖色纱 */
.welcome-pop,
.contact-pop {
  background: rgba(41, 36, 30, .38) !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

/* ============================================================
   2. 阅读性：正文有节、字距归位、对比拉满
   ============================================================ */
body.home .hero-mid {
  color: var(--c-ink) !important;
  font-size: 18px;
  max-width: 34ch;
  line-height: 1.7;
}

body.home .hero-fine {
  color: var(--c-ink-3) !important;
  font-size: 13.5px;
  max-width: 40ch;
  line-height: 1.75;
}

body.home .hero-title {
  max-width: 21ch;
  line-height: 1.2;
}

body.home .contact-sec-sub,
body.home .contact-item .ci-l {
  color: var(--c-ink-3) !important;
}

body.home .contact-item .ci-c {
  color: var(--c-muted) !important;
}

body.home .contact-sec-t {
  color: var(--c-ink-2) !important;
}

body.home .contact-sec-t::before {
  background: var(--c-clay) !important;
}

body.home .contact-title {
  color: var(--c-ink) !important;
}

body.home .contact-title::before,
body.home .contact-title::after {
  background: var(--c-line-2) !important;
}

body.home .contact-close {
  color: var(--c-muted) !important;
  border-color: var(--c-line) !important;
}

body.home .contact-close:hover {
  color: var(--c-ink) !important;
  background: var(--c-paper-3) !important;
}

body.home .fan-item span {
  color: var(--c-ink) !important;
}

body.home .side-text,
body.home .side-hint {
  color: var(--c-ink-2) !important;
}

/* ============================================================
   3. 卡片指针倾斜
   JS 用事件委托：指针停在卡片上时才加 .tl-on 并写 --tx/--ty。
   静止时不写 transform，页面原来的 .reveal 滚动渐显完全不受影响；
   opacity 一并列进 transition，免得把原来的淡入改成瞬变。
   选择器写成 类+类 是为了压过 .reveal.in 的 transform:none。
   ============================================================ */
.unit,
.genre,
.topic,
.deep,
.taste .card {
  transform-style: preserve-3d;
  transition: transform .62s var(--m3-ease), box-shadow .42s var(--m3-ease),
    border-color .3s ease, opacity .7s ease;
}

.unit.tl-on,
.genre.tl-on,
.topic.tl-on,
.deep.tl-on,
.taste .card.tl-on {
  will-change: transform;
  transform: perspective(var(--m3-p)) rotateX(var(--tx, 0deg)) rotateY(var(--ty, 0deg)) translateZ(0);
  transition: transform .1s linear, box-shadow .3s var(--m3-ease), border-color .3s ease, opacity .7s ease;
  box-shadow: var(--m3-shadow-tilt) !important;
}

.unit.tl-on > *,
.genre.tl-on > *,
.topic.tl-on > *,
.deep.tl-on > *,
.taste .card.tl-on > * {
  transform: translateZ(14px);
}

/* ============================================================
   3b. 3D 按键：悬停时整块往后翻起，按下时翻回来压在桌面上
       （claude-core 已经把阴影交给 css I 的 neu，这里只加转动）
   ============================================================ */
.pill-btn,
.ctl,
.btn,
.tab,
.opt {
  transform-style: preserve-3d;
  transition: transform .2s var(--m3-ease), box-shadow .3s var(--m3-ease), background-color .2s ease, color .2s ease;
}

.pill-btn:hover,
.ctl:hover,
.btn:hover,
.opt:hover,
.tab:hover {
  transform: perspective(620px) translateZ(7px) rotateX(-7deg);
}

.pill-btn:active,
.ctl:active,
.btn:active,
.opt:active,
.tab:active {
  transform: perspective(620px) translateZ(0) rotateX(11deg) translateY(2px);
  transition-duration: .09s;
}

/* ============================================================
   4. 弹窗：从上方翻入，落定即停
   ============================================================ */
.welcome-pop,
.contact-pop {
  perspective: 900px;
}

.welcome-card,
.contact-card {
  transform: rotateX(-22deg) translateY(26px) scale(.94);
  transform-origin: 50% 100%;
  opacity: 0;
  box-shadow: var(--m3-shadow-rest) !important;
  transition: transform .5s var(--m3-snap), opacity .3s ease;
}

.welcome-pop.show .welcome-card,
.contact-pop.show .contact-card {
  transform: rotateX(0) translateY(0) scale(1);
  opacity: 1;
}

.welcome-pop.show .welcome-card {
  transition-delay: .04s;
}

.contact-pop.show .contact-card {
  transition-delay: .06s;
}

/* 列表项跟着错峰浮起，像一副牌摊开 */
.contact-pop.show .contact-item {
  animation: m3-deal .42s var(--m3-ease) both;
}

.contact-pop.show .contact-item { animation-delay: .12s; }
.contact-pop.show .contact-item + .contact-item { animation-delay: .19s; }
.contact-pop.show .contact-item + .contact-item + .contact-item { animation-delay: .26s; }

@keyframes m3-deal {
  from {
    opacity: 0;
    transform: rotateX(-14deg) translateY(12px);
  }
  to {
    opacity: 1;
    transform: rotateX(0) translateY(0);
  }
}

/* KFC 那张：翻得更急，像个巴掌拍上来 */
.welcome-pop#kfcPop .welcome-card {
  transform: rotateZ(-7deg) rotateX(-26deg) translateY(34px) scale(.9);
}

.welcome-pop#kfcPop.show .welcome-card {
  transform: rotateZ(0) rotateX(0) translateY(0) scale(1);
}

/* ============================================================
   5. 扇形导航：向观者 swing 出来，而不只是平面旋转
   ============================================================ */
body.home .fan {
  perspective: 760px;
  perspective-origin: 100% 0;
}

body.home .fan-item {
  box-shadow: var(--m3-shadow-rest) !important;
  transform: rotate(var(--a)) translateX(0) scale(.3) rotate(calc(-1 * var(--a))) rotateY(38deg) translateZ(-70px);
  transition: transform .58s var(--m3-snap), opacity .3s ease, box-shadow .4s var(--m3-ease);
}

body.home .side-hint:hover .fan-item,
body.home .side-hint.open .fan-item {
  transform: rotate(var(--a)) translateX(calc(-1 * var(--r))) scale(1) rotate(calc(-1 * var(--a))) rotateY(0deg) translateZ(0);
}

body.home .side-hint:hover .fan-item:hover,
body.home .side-hint.open .fan-item:hover {
  transform: rotate(var(--a)) translateX(calc(-1 * var(--r) - 10px)) scale(1.07) rotate(calc(-1 * var(--a))) translateZ(24px);
  box-shadow: var(--m3-shadow-tilt) !important;
}

/* ============================================================
   6. hero：纯色背景板 + 开屏收场后的正文交接
   ============================================================ */

/* ---------- 开屏收场后的交接：正文翻起，扇形跟着甩出来 ----------
   默认状态完全可见，.hero-in 由 JS 加上——没有 JS 时正文照常显示。 */
body.home .hero-inner {
  perspective: 820px;
}

body.home .hero-inner.hero-in > * {
  animation: m3-rise .58s var(--m3-ease) both;
}

body.home .hero-inner.hero-in > *:nth-child(1) { animation-delay: 0s; }
body.home .hero-inner.hero-in > *:nth-child(2) { animation-delay: .07s; }
body.home .hero-inner.hero-in > *:nth-child(3) { animation-delay: .14s; }
body.home .hero-inner.hero-in > *:nth-child(4) { animation-delay: .21s; }

@keyframes m3-rise {
  from {
    opacity: 0;
    transform: translateY(20px) rotateX(-11deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ============================================================
   7. 一次性入场：只在"内容刚出现"的那一刻翻一下，跑完即停
      （常驻动画一律不做——见 theme/motion-3d.js 的静止归零约定。
       文档页卡片已有 .reveal 滚动渐显，不再叠第二层入场。）
   ============================================================ */
/* PDF 读完才露脸：整块纸页绕上边缘翻起来 */
.reader-frame {
  transform-origin: 50% 100%;
}

.reader-frame.tl-in {
  animation: m3-page-in .62s var(--m3-ease) both;
}

@keyframes m3-page-in {
  from {
    opacity: 0;
    transform: perspective(1300px) rotateX(-9deg) translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 声场图鉴：换设备时信息板绕下边缘抬起来 */
.stage #info {
  transform-origin: 50% 100%;
}

.stage #info.tl-in {
  animation: m3-panel-in .46s var(--m3-ease) both;
}

@keyframes m3-panel-in {
  from {
    opacity: 0;
    transform: perspective(1000px) rotateX(15deg) translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 404：那行嘲讽绕上边缘立起来，悬停时歪头看你 */
.err h1 {
  transform-origin: 50% 0;
  animation: m3-stand .7s var(--m3-snap) both;
}

.err h1:hover {
  transform: perspective(760px) rotateY(9deg) rotateX(-5deg);
}

.err hr {
  transform-origin: 50% 50%;
  animation: m3-wipe .8s var(--m3-ease) .12s both;
}

@keyframes m3-stand {
  from {
    opacity: 0;
    transform: perspective(900px) rotateX(-48deg) translateY(26px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes m3-wipe {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

/* JS 判定"开过了"之后，动画属性整个撤掉，回到 claude-core 的渐显 */
.m3-gone {
  animation: none !important;
}

/* ============================================================
   8. 尊重"减少动态效果"
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .unit.tl-on,
  .genre.tl-on,
  .topic.tl-on,
  .deep.tl-on,
  .taste .card.tl-on,
  .unit.tl-on > *,
  .genre.tl-on > *,
  .topic.tl-on > *,
  .deep.tl-on > *,
  .taste .card.tl-on > *,
  .pill-btn:hover,
  .ctl:hover,
  .btn:hover,
  .opt:hover,
  .tab:hover,
  .pill-btn:active,
  .ctl:active,
  .btn:active,
  .opt:active,
  .tab:active,
  .err h1:hover,
  body.home .fan-item {
    transform: none !important;
    transition: none !important;
    will-change: auto;
  }
  .reader-frame.tl-in,
  .stage #info.tl-in,
  .err h1,
  .err hr {
    animation: none !important;
  }
  body.home .hero-inner.hero-in > * {
    animation: none !important;
    opacity: 1;
    transform: none;
  }
  .welcome-card,
  .contact-card {
    transform: none !important;
    transition: opacity .2s linear !important;
  }
  .contact-pop.show .contact-item {
    animation: none !important;
    opacity: 1;
  }
  body.home .side-line {
    transition: none;
  }
}
