/* fx.css — 全站共享的动效层（首页 / 求职雷达 / 英语听力 / 经济学人）。
   只做增强：浏览器不支持的特性会自动退化成原来的样子；
   系统开启「减少动态效果」时，这里的动画全部关闭。 */

:root {
  --fx-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --fx-ease-in: cubic-bezier(0.4, 0, 1, 1);
  /* 带一点回弹的弹簧曲线；支持 linear() 的浏览器用更真实的阻尼弹簧 */
  --fx-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --fx-spring: linear(0, 0.006, 0.025 2.8%, 0.101 6.1%, 0.539 18.9%, 0.721 25.3%, 0.849 31.5%, 0.937 38.1%, 0.968 41.8%, 0.991 45.7%, 1.006 50.1%, 1.015 55%, 1.017 63.9%, 1.001 85.9%, 1);
  }
}

/* ---------- 跨页过渡：站内跳转时淡出旧页、上浮新页 ---------- */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: fx-page-out 0.2s var(--fx-ease-in) both; }
::view-transition-new(root) { animation: fx-page-in 0.42s var(--fx-ease) both; }
@keyframes fx-page-out { to { opacity: 0; transform: translateY(-8px); } }
@keyframes fx-page-in { from { opacity: 0; transform: translateY(12px); } }

/* 切换深浅色：从点击位置画圆扩散（由 fx.js 打上 fx-theme-vt 标记） */
:root.fx-theme-vt::view-transition-old(root) { animation: none; }
:root.fx-theme-vt::view-transition-new(root) {
  animation: fx-circle 0.62s var(--fx-ease) both;
}
@keyframes fx-circle {
  from { clip-path: circle(0 at var(--fx-vt-x, 50%) var(--fx-vt-y, 0%)); }
  to { clip-path: circle(var(--fx-vt-r, 150vmax) at var(--fx-vt-x, 50%) var(--fx-vt-y, 0%)); }
}

/* ---------- 原生 <dialog>：弹性进场，柔和退场 ---------- */
dialog {
  opacity: 0;
  transform: translateY(16px) scale(0.965);
  transition:
    opacity 0.24s var(--fx-ease),
    transform 0.36s var(--fx-ease),
    overlay 0.24s allow-discrete,
    display 0.24s allow-discrete;
}
dialog[open] { opacity: 1; transform: none; }
@starting-style {
  dialog[open] { opacity: 0; transform: translateY(16px) scale(0.965); }
}
dialog::backdrop {
  opacity: 0;
  transition: opacity 0.24s ease, overlay 0.24s allow-discrete, display 0.24s allow-discrete;
}
dialog[open]::backdrop { opacity: 1; }
@starting-style {
  dialog[open]::backdrop { opacity: 0; }
}

/* 弹窗本身获得焦点时不画轮廓（焦点框会被圆角裁成两侧的黑边） */
dialog:focus-visible, [role="dialog"]:focus-visible { outline: none; }

/* 听力页用 hidden 属性控制的弹层与抽屉 */
.stats-modal:not([hidden]) { animation: fx-fade 0.22s ease both; }
.stats-modal:not([hidden]) > * { animation: fx-pop 0.38s var(--fx-ease) both; }
.wordbook-drawer:not([hidden]) { animation: fx-slide-in 0.36s var(--fx-ease) both; }
@keyframes fx-fade { from { opacity: 0; } }
@keyframes fx-pop { from { opacity: 0; transform: translateY(14px) scale(0.97); } }
@keyframes fx-slide-in { from { transform: translateX(100%); } }
/* 退场：由 fx.js 的 fxHide 先加 fx-leaving，动画结束后再真正隐藏 */
.stats-modal.fx-leaving { animation: fx-fade-out 0.2s ease forwards; }
.stats-modal.fx-leaving > * { animation: fx-pop-out 0.2s var(--fx-ease-in) forwards; }
.wordbook-drawer.fx-leaving { animation: fx-slide-out 0.24s var(--fx-ease-in) forwards; }
/* 正在退场的遮罩不再拦截点击，关闭后可以立刻点到下面的内容 */
:is(.stats-modal, .wordbook-drawer).fx-leaving { pointer-events: none; }
@keyframes fx-fade-out { to { opacity: 0; } }
@keyframes fx-pop-out { to { opacity: 0; transform: translateY(10px) scale(0.97); } }
@keyframes fx-slide-out { to { transform: translateX(100%); } }

/* 局部切换（栏目、期号）：只让目标区域淡出旧内容、上浮新内容，页面其余部分不动 */
:root.fx-local-vt::view-transition-old(root),
:root.fx-local-vt::view-transition-new(root) { animation: none; }
::view-transition-group(fx-swap) { animation-duration: 0.42s; animation-timing-function: var(--fx-ease); }
::view-transition-old(fx-swap) { animation: fx-fade-out 0.14s ease both; }
::view-transition-new(fx-swap) { animation: fx-swap-in 0.42s var(--fx-ease) both; }
@keyframes fx-swap-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- 卡片：跟随指针的柔光 ---------- */
@media (hover: hover) and (pointer: fine) {
  :is(.card, .course-card, .episode-card, .job-card, .company-card) {
    isolation: isolate;
  }
  :is(.card, .course-card, .episode-card, .job-card, .company-card)::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(
      280px circle at var(--fx-x, 50%) var(--fx-y, 50%),
      color-mix(in srgb, var(--fx-glow, #8ab4ff) 26%, transparent),
      transparent 70%
    );
    transition: opacity 0.35s ease;
  }
  :is(.card, .course-card, .episode-card, .job-card, .company-card):hover::after { opacity: 1; }
  .card { position: relative; --fx-glow: var(--blue, #8ab4ff); }
  :is(.course-card, .episode-card) { --fx-glow: var(--listen-green, #3fae7a); }
  :is(.job-card, .company-card) { position: relative; }
}

/* ---------- 按压反馈 ---------- */
:is(button, .nav-link, .pill-link, .primary-link, .top-action):active:not(:disabled) { scale: 0.97; }

/* ---------- 分区内元素依次出现（fx-entering 由脚本在进入视口时短暂加上） ---------- */
.fx-entering :is(.now-grid, .moments-grid, .link-grid, .traits) > * {
  animation: fx-rise 0.62s var(--fx-ease) backwards;
}
.fx-entering :is(.now-grid, .moments-grid, .link-grid, .traits) > :nth-child(2) { animation-delay: 0.06s; }
.fx-entering :is(.now-grid, .moments-grid, .link-grid, .traits) > :nth-child(3) { animation-delay: 0.12s; }
.fx-entering :is(.now-grid, .moments-grid, .link-grid, .traits) > :nth-child(4) { animation-delay: 0.18s; }
.fx-entering :is(.now-grid, .moments-grid, .link-grid, .traits) > :nth-child(n + 5) { animation-delay: 0.24s; }
@keyframes fx-rise { from { opacity: 0; transform: translateY(14px); } }

/* ---------- 标签页隐藏时暂停所有循环动画，省电也更跟手 ---------- */
:root.fx-paused *,
:root.fx-paused *::before,
:root.fx-paused *::after { animation-play-state: paused !important; }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  dialog, dialog::backdrop { transition: none; }
  .stats-modal:not([hidden]),
  .stats-modal:not([hidden]) > *,
  .wordbook-drawer:not([hidden]),
  .stats-modal.fx-leaving, .stats-modal.fx-leaving > *, .wordbook-drawer.fx-leaving,
  .fx-entering :is(.now-grid, .moments-grid, .link-grid, .traits) > * { animation: none; }
  :is(button, .nav-link, .pill-link, .primary-link, .top-action):active:not(:disabled) { scale: none; }
}
