/*
 * 2026-11-10 菊间手机端交互动画
 * 只加动效，不改任何尺寸、颜色、字体和布局；系统开了“减少动态效果”就全部不生效。
 */

@media (max-width: 720px) and (prefers-reduced-motion: no-preference) {
  :root {
    --jj-spring-soft: cubic-bezier(0.22, 1, 0.36, 1);
    --jj-spring-pop: cubic-bezier(0.34, 1.4, 0.64, 1);
  }

  /* ---------- 按下：微缩、轻沉，松手弹回（照新家 0.4.8 的手感） ---------- */

  html[data-site="juhua"] :is(
    .claude-rail-menu button,
    .conversation-open,
    .claude-new-chat,
    .claude-settings-entry,
    .composer-model-pill,
    .image-attach-button,
    .send-button,
    .stop-button,
    .message-regenerate-button,
    .claude-thinking-summary
  ) {
    transition: transform 280ms var(--jj-spring-pop), background-color 200ms ease, opacity 200ms ease;
    -webkit-tap-highlight-color: transparent;
  }

  html[data-site="juhua"] :is(.claude-rail-menu button, .conversation-open, .claude-thinking-summary):active {
    transform: scale(0.975) translateY(1px);
    transition-duration: 90ms;
  }

  html[data-site="juhua"] :is(.claude-new-chat, .claude-settings-entry, .composer-model-pill):active {
    transform: scale(0.95) translateY(1px);
    transition-duration: 90ms;
  }

  html[data-site="juhua"] :is(.image-attach-button, .send-button, .stop-button, .message-regenerate-button):active {
    transform: scale(0.88);
    transition-duration: 90ms;
  }

  /* ---------- 侧边栏打开：内容依次滑入 ---------- */

  html[data-site="juhua"] .conversation-rail.is-open :is(
    .claude-rail-heading,
    .claude-rail-menu button,
    .claude-rail-section-label,
    .conversation-item,
    .claude-rail-foot
  ) {
    animation: jj-rail-in 520ms var(--jj-spring-soft) both;
  }
  html[data-site="juhua"] .conversation-rail.is-open .claude-rail-heading { animation-delay: 30ms; }
  html[data-site="juhua"] .conversation-rail.is-open .claude-rail-menu button:nth-child(1) { animation-delay: 60ms; }
  html[data-site="juhua"] .conversation-rail.is-open .claude-rail-menu button:nth-child(2) { animation-delay: 85ms; }
  html[data-site="juhua"] .conversation-rail.is-open .claude-rail-section-label { animation-delay: 110ms; }
  html[data-site="juhua"] .conversation-rail.is-open .conversation-item:nth-child(1) { animation-delay: 130ms; }
  html[data-site="juhua"] .conversation-rail.is-open .conversation-item:nth-child(2) { animation-delay: 150ms; }
  html[data-site="juhua"] .conversation-rail.is-open .conversation-item:nth-child(3) { animation-delay: 170ms; }
  html[data-site="juhua"] .conversation-rail.is-open .conversation-item:nth-child(4) { animation-delay: 190ms; }
  html[data-site="juhua"] .conversation-rail.is-open .conversation-item:nth-child(5) { animation-delay: 210ms; }
  html[data-site="juhua"] .conversation-rail.is-open .conversation-item:nth-child(6) { animation-delay: 230ms; }
  html[data-site="juhua"] .conversation-rail.is-open .conversation-item:nth-child(n+7) { animation-delay: 250ms; }
  html[data-site="juhua"] .conversation-rail.is-open .claude-rail-foot { animation: jj-rise-in 560ms var(--jj-spring-soft) 160ms both; }

  @keyframes jj-rail-in {
    from { opacity: 0; transform: translate3d(-14px, 0, 0); }
    to { opacity: 1; transform: none; }
  }

  @keyframes jj-rise-in {
    from { opacity: 0; transform: translate3d(0, 14px, 0); }
    to { opacity: 1; transform: none; }
  }

  /* ---------- 消息出现：她的气泡从右下角轻轻弹出，回复淡入上浮 ---------- */

  html[data-site="juhua"] .message.user {
    transform-origin: 100% 100%;
    animation: jj-bubble-in 420ms var(--jj-spring-pop) both;
  }

  html[data-site="juhua"] .message.assistant {
    animation: jj-reply-in 480ms var(--jj-spring-soft) both;
  }

  /* 整列重画（切换对话、每 10 秒的成员信息刷新）时不再放入场动画，只有新消息才放；标记由 App 打上 */
  html[data-site="juhua"] .message[data-jj-quiet] {
    animation: none !important;
  }

  @keyframes jj-bubble-in {
    from { opacity: 0; transform: translate3d(0, 10px, 0) scale(0.92); }
    to { opacity: 1; transform: none; }
  }

  @keyframes jj-reply-in {
    from { opacity: 0; transform: translate3d(0, 12px, 0); }
    to { opacity: 1; transform: none; }
  }

  /* ---------- 新对话页：标志和问候语缓缓浮现 ---------- */

  html[data-site="juhua"] .chat-panel.is-empty-chat .claude-empty-center > * {
    animation: jj-rise-in 640ms var(--jj-spring-soft) both;
  }
  html[data-site="juhua"] .chat-panel.is-empty-chat .claude-empty-center > :nth-child(1) {
    animation: jj-mark-in 760ms var(--jj-spring-pop) both;
  }
  html[data-site="juhua"] .chat-panel.is-empty-chat .claude-empty-center > :nth-child(2) { animation-delay: 90ms; }
  html[data-site="juhua"] .chat-panel.is-empty-chat .claude-empty-center > :nth-child(3) { animation-delay: 150ms; }

  @keyframes jj-mark-in {
    from { opacity: 0; transform: scale(0.6) rotate(-40deg); }
    to { opacity: 1; transform: none; }
  }

  /* ---------- 输入框有字时发送键弹出 ---------- */

  html[data-site="juhua"] .chat-panel.has-composer-content .send-button {
    animation: jj-pop-in 360ms var(--jj-spring-pop) both;
  }

  @keyframes jj-pop-in {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: none; }
  }

  /* ---------- 思考摘要右侧箭头：按下时往右轻推 ---------- */

  html[data-site="juhua"] .claude-thinking-chevron {
    transition: transform 280ms var(--jj-spring-pop);
  }
  html[data-site="juhua"] .claude-thinking-summary:active .claude-thinking-chevron {
    transform: translateX(3px);
  }

  /* ---------- 思考面板：从底部整块滑上来（iOS 弹出面板的曲线），背后暗色同步淡入 ---------- */

  /*
   * 面板起始位置在屏幕下方之外。容器原本可滚动，iOS 打开时把焦点给关闭键会顺手把容器滚下去，
   * 面板滑回后整块顶到屏幕上半截。改成不可滚动的裁切，滚动只留在面板正文里。
   */
  html[data-site="juhua"] .claude-thinking-dialog {
    overflow: clip !important;
  }
  html[data-site="juhua"] .claude-thinking-dialog .claude-thinking-sheet {
    opacity: 1;
    transform: translate3d(0, 105%, 0);
    transition:
      transform 240ms cubic-bezier(0.4, 0, 1, 1),
      height 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  html[data-site="juhua"] .claude-thinking-dialog.is-open .claude-thinking-sheet {
    transform: translate3d(0, 0, 0);
    transition:
      transform 380ms cubic-bezier(0.32, 0.72, 0, 1),
      height 420ms cubic-bezier(0.32, 0.72, 0, 1);
  }
  html[data-site="juhua"] .claude-thinking-dialog.is-dragging .claude-thinking-sheet {
    transition: none;
  }
  html[data-site="juhua"] .claude-thinking-dialog::backdrop {
    transition: background-color 360ms ease;
  }
  html[data-site="juhua"] .claude-thinking-dialog:not(.is-open)::backdrop {
    background: rgba(20, 20, 19, 0);
  }
}
