/* =============================================================================
   潜龙元创 · 全站 UI 动效与响应式增强层（ui-motion.css）
   -----------------------------------------------------------------------------
   作用：
   1) 统一 200-500ms 的交互节奏：页面转场、按钮按压、列表入场、抽屉/弹窗过渡；
   2) 补齐移动端 m-app 的点击水波纹、回弹、标签栏与标题栏反馈；
   3) 补齐 PC 端 1280 / 1440 / 1920 下的内容宽度、栅格与悬停层次；
   4) 所有效果均为渐进增强，脚本/样式失效时页面内容与功能不受影响。
   引入顺序：各页面自身样式 → mobile-adapt.css → 本文件
   ============================================================================= */

/* ===================== 1. 动效令牌 ===================== */
:root {
  --ui-ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --ui-ease-decel: cubic-bezier(0.1, 0.9, 0.2, 1);
  --ui-ease-accel: cubic-bezier(0.7, 0, 1, 0.5);
  --ui-ease-spring: cubic-bezier(0.16, 1.16, 0.28, 1);
  --ui-dur-fast: 200ms;
  --ui-dur-base: 260ms;
  --ui-dur-mid: 320ms;
  --ui-dur-slow: 420ms;
  --ui-dur-slower: 500ms;
}

/* ===================== 2. 页面转场 ===================== */
/* 站内跳转离场（ui-motion.js 添加 .ui-leaving） */
html.ui-leaving {
  pointer-events: none;
}

html.ui-leaving body {
  opacity: 0 !important;
  transition: opacity 220ms var(--ui-ease-accel) !important;
}

/* 兼容 win11-motion.js 的离场类，把 160ms 提升到 220ms */
html.win-leaving body {
  transition-duration: 220ms !important;
}

/* ===================== 3. 通用按压 / 焦点反馈 ===================== */
button,
[role="button"],
input[type="submit"],
input[type="button"],
.btn,
.cta-button {
  transition-duration: var(--ui-dur-fast) !important;
}

.ui-pressed {
  transform: scale(0.97) !important;
  filter: brightness(0.97);
  transition-duration: var(--ui-dur-fast) !important;
}

button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--win11-accent, #0078D4);
  outline-offset: 2px;
}

/* 页脚 / 文档内链接：220ms 颜色过渡 */
footer a,
.doc a,
.m-foot a {
  transition: color 220ms var(--ui-ease-standard),
              opacity 220ms var(--ui-ease-standard);
}

/* 点击水波纹（由 ui-motion.js 注入 .ui-ripple） */
.ui-ripple-host {
  position: relative !important;
  overflow: hidden !important;
}

.ui-ripple {
  position: absolute;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.12;
  pointer-events: none;
  transform: scale(0);
  animation: ui-ripple 460ms var(--ui-ease-decel) forwards;
}

@keyframes ui-ripple {
  60% { opacity: 0.08; }
  to {
    transform: scale(1);
    opacity: 0;
  }
}

/* 兼容并柔化 win11 水波纹节奏（620ms → 460ms） */
.win-ripple {
  animation-duration: 460ms !important;
}

/* ===================== 4. 滚动显现系统 ===================== */
html.ui-ready .ui-reveal:not(.ui-in) {
  opacity: 0;
  transform: translate3d(0, 16px, 0);
}

html.ui-ready .ui-reveal.ui-in {
  animation: ui-reveal-in 380ms var(--ui-ease-decel) backwards;
  animation-delay: var(--ui-delay, 0ms);
}

@keyframes ui-reveal-in {
  from {
    opacity: 0;
    transform: translate3d(0, 16px, 0);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 列表逐项上浮：子项在容器进入视口后依次出现 */
html.ui-ready .ui-stagger:not(.ui-in) > * {
  opacity: 0;
  transform: translate3d(0, 10px, 0);
}

html.ui-ready .ui-stagger.ui-in > * {
  animation: ui-item-in var(--ui-dur-mid) var(--ui-ease-decel) backwards;
  animation-delay: calc(var(--ui-i, 0) * 20ms);
}

html.ui-ready .ui-stagger > *:nth-child(1)  { --ui-i: 0; }
html.ui-ready .ui-stagger > *:nth-child(2)  { --ui-i: 1; }
html.ui-ready .ui-stagger > *:nth-child(3)  { --ui-i: 2; }
html.ui-ready .ui-stagger > *:nth-child(4)  { --ui-i: 3; }
html.ui-ready .ui-stagger > *:nth-child(5)  { --ui-i: 4; }
html.ui-ready .ui-stagger > *:nth-child(6)  { --ui-i: 5; }
html.ui-ready .ui-stagger > *:nth-child(7)  { --ui-i: 6; }
html.ui-ready .ui-stagger > *:nth-child(8)  { --ui-i: 7; }
html.ui-ready .ui-stagger > *:nth-child(9)  { --ui-i: 8; }
html.ui-ready .ui-stagger > *:nth-child(n+10) { --ui-i: 9; }

@keyframes ui-item-in {
  from {
    opacity: 0;
    transform: translate3d(0, 10px, 0);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 卡片入场（展开的新内容） */
@keyframes ui-card-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 图片载入柔化 */
html.ui-ready img.ui-img-ready {
  animation: ui-img-in 320ms var(--ui-ease-standard) both;
}

@keyframes ui-img-in {
  from { opacity: 0.35; }
  to   { opacity: 1; }
}

/* ===================== 5. 移动端 m-app 交互 ===================== */
@media (max-width: 768px) {
  .m-app {
    -webkit-tap-highlight-color: transparent;
  }

  /* 列表项：200ms 按压反馈 */
  .m-cell,
  .m-stat,
  .m-profile-edit,
  .m-btn,
  .m-text-btn,
  .m-titlebar-action {
    transition: background-color 200ms var(--ui-ease-standard),
                transform 200ms var(--ui-ease-standard),
                opacity 200ms var(--ui-ease-standard),
                color 200ms var(--ui-ease-standard) !important;
  }

  .m-cell:active,
  .m-stat:active,
  .m-btn:active,
  .m-text-btn:active,
  .m-profile-edit:active,
  .m-titlebar-action:active {
    transform: scale(0.985);
  }

  .m-btn:active,
  .m-profile-edit:active,
  .m-titlebar-action:active {
    transform: scale(0.96);
  }

  /* 列表箭头与缩略图：按压时轻微位移，强化可点击感 */
  .m-cell-arrow {
    transition: transform 200ms var(--ui-ease-standard);
  }

  .m-cell:active .m-cell-arrow {
    transform: translateX(2px);
  }

  .m-cell-thumb img {
    transition: transform 240ms var(--ui-ease-decel);
  }

  .m-cell:active .m-cell-thumb img {
    transform: scale(1.04);
  }

  /* 品牌强调色统一：移动端交互主色与桌面端保持一致 */
  .m-tab.is-active {
    color: var(--win11-accent, #0078D4);
  }

  .m-btn-primary {
    background: var(--win11-accent, #0078D4);
  }

  .m-btn-primary:active {
    background: var(--win11-accent-active, #005A9E);
  }

  .m-btn-outline {
    border-color: var(--win11-accent, #0078D4);
    color: var(--win11-accent, #0078D4) !important;
  }

  .m-btn-outline:active {
    background: rgba(0, 120, 212, 0.08);
  }

  /* 底部标签栏：220ms 颜色/缩放过渡 + 激活图标弹簧 */
  .m-tab {
    transition: color 220ms var(--ui-ease-standard),
                opacity 220ms var(--ui-ease-standard),
                transform 220ms var(--ui-ease-standard) !important;
  }

  .m-tab:active {
    transform: scale(0.92);
    opacity: 0.6;
  }

  .m-tab.is-active .m-tab-icon {
    animation: ui-tab-pop 360ms var(--ui-ease-spring) both;
  }

  @keyframes ui-tab-pop {
    0%   { transform: translateY(0) scale(1); }
    55%  { transform: translateY(-2px) scale(1.12); }
    100% { transform: translateY(-1px) scale(1.05); }
  }

  /* 标题栏滚动后出现轻量分层阴影 */
  .m-titlebar {
    transition: box-shadow 240ms var(--ui-ease-standard),
                background-color 240ms var(--ui-ease-standard) !important;
  }

  .m-titlebar.ui-scrolled {
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04),
                0 6px 18px rgba(0, 0, 0, 0.06) !important;
  }

  /* 展开的“更多”列表项滑入 */
  .m-group.is-expanded .m-cell.is-extra {
    animation: ui-item-in var(--ui-dur-mid) var(--ui-ease-decel);
  }

  /* 抽屉遮罩与面板 */
  .mnav-backdrop {
    transition: opacity 240ms var(--ui-ease-standard),
                visibility 240ms var(--ui-ease-standard) !important;
  }

  .mnav-drawer {
    transition: transform 300ms var(--ui-ease-decel),
                visibility 300ms var(--ui-ease-decel) !important;
  }

  body.mnav-open .mnav-links li {
    animation: ui-drawer-item-in 300ms var(--ui-ease-decel) backwards;
  }

  body.mnav-open .mnav-links li:nth-child(1) { animation-delay: 0ms; }
  body.mnav-open .mnav-links li:nth-child(2) { animation-delay: 22ms; }
  body.mnav-open .mnav-links li:nth-child(3) { animation-delay: 44ms; }
  body.mnav-open .mnav-links li:nth-child(4) { animation-delay: 66ms; }
  body.mnav-open .mnav-links li:nth-child(5) { animation-delay: 88ms; }
  body.mnav-open .mnav-links li:nth-child(6) { animation-delay: 110ms; }
  body.mnav-open .mnav-links li:nth-child(7) { animation-delay: 132ms; }
  body.mnav-open .mnav-links li:nth-child(n+8) { animation-delay: 154ms; }

  @keyframes ui-drawer-item-in {
    from {
      opacity: 0;
      transform: translateX(18px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  /* 汉堡按钮形变为关闭图标 */
  .mnav-toggle span {
    transition: transform 220ms var(--ui-ease-standard),
                opacity 200ms var(--ui-ease-standard) !important;
  }

  body.mnav-open .mnav-toggle span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }

  body.mnav-open .mnav-toggle span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0.2);
  }

  body.mnav-open .mnav-toggle span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }

  /* 抽屉导航项按压与过渡 */
  .mnav-links a {
    transition: background-color 200ms var(--ui-ease-standard),
                color 200ms var(--ui-ease-standard),
                transform 200ms var(--ui-ease-standard) !important;
  }

  .mnav-links a:active {
    transform: scale(0.985);
  }

  .mnav-close {
    transition: background-color 200ms var(--ui-ease-standard),
                transform 200ms var(--ui-ease-standard) !important;
  }

  .mnav-close:active {
    transform: scale(0.94) !important;
  }

  /* 登录 / 注册 / 合规文档：移动端卡片入场 */
  .login-card,
  .signup-card,
  .wrap > .doc,
  body > .doc {
    animation: ui-card-in 420ms var(--ui-ease-spring) both;
  }

  /* 产品详情弹窗：移动端底部抽屉式入场 */
  .product-modal-overlay {
    animation: ui-overlay-in 220ms var(--ui-ease-standard) both;
  }

  .product-modal {
    animation: ui-sheet-in 320ms var(--ui-ease-decel) both !important;
  }

  @keyframes ui-sheet-in {
    from {
      opacity: 0;
      transform: translateY(36px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

@keyframes ui-overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ===================== 6. PC 端交互与层次 ===================== */
@media (min-width: 769px) {
  /* 导航项：220ms 过渡 + 按压 */
  .nav-links a {
    transition: color 220ms var(--ui-ease-standard),
                background-color 220ms var(--ui-ease-standard),
                transform 220ms var(--ui-ease-standard) !important;
  }

  .nav-links a:active {
    transform: scale(0.97);
  }

  /* 卡片：统一 300-420ms 的浮起与图片缓动 */
  .product-card,
  .project-card,
  .news-card,
  .download-card,
  .contact-card,
  .license-card,
  .member-card,
  .service-card,
  .stat-box,
  .favorite-card,
  .order-card,
  .team-intro {
    transition: transform var(--ui-dur-base) var(--ui-ease-decel),
                box-shadow var(--ui-dur-mid) var(--ui-ease-decel),
                border-color var(--ui-dur-base) var(--ui-ease-decel),
                background-color var(--ui-dur-base) var(--ui-ease-decel);
  }

  .product-card:active,
  .project-card:active,
  .news-card:active,
  .download-card:active,
  .contact-card:active,
  .license-card:active,
  .member-card:active,
  .service-card:active,
  .stat-box:active {
    transform: scale(0.985);
  }

  .product-card:hover,
  .project-card:hover,
  .news-card:hover,
  .download-card:hover,
  .contact-card:hover,
  .license-card:hover,
  .member-card:hover,
  .service-card:hover,
  .stat-box:hover {
    transform: translateY(-4px);
  }

  .product-image img,
  .team-overview-img,
  .news-card img,
  .member-avatar img {
    transition: transform 480ms var(--ui-ease-decel);
  }

  .product-card:hover .product-image img {
    transform: scale(1.055);
  }

  .member-card:hover .member-avatar img {
    transform: scale(1.05);
  }

  /* 系统入口卡片 */
  .sys-card {
    transition: background-color 220ms var(--ui-ease-standard),
                box-shadow 260ms var(--ui-ease-standard),
                border-color 220ms var(--ui-ease-standard),
                transform 220ms var(--ui-ease-standard);
  }

  .sys-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.09);
  }

  .sys-card:active {
    transform: scale(0.985);
  }

  .systems-section.is-expanded .sys-card.is-extra {
    animation: ui-card-in var(--ui-dur-mid) var(--ui-ease-decel);
  }

  .sys-go i,
  .sys-toggle-btn i,
  .view-more i,
  .news-read-more i {
    transition: transform 220ms var(--ui-ease-standard);
  }

  .sys-card:hover .sys-go i,
  .view-more a:hover i,
  .view-more button:hover i,
  .news-card:hover .news-read-more i {
    transform: translateX(4px);
  }

  /* 产品横板列表 */
  .product-row {
    transition: transform 240ms var(--ui-ease-decel),
                box-shadow 280ms var(--ui-ease-decel),
                border-color 240ms var(--ui-ease-standard) !important;
  }

  .product-row:hover {
    transform: translateX(4px);
  }

  .product-row:active {
    transform: scale(0.995);
  }

  .product-row-actions .btn {
    transition: background-color 200ms var(--ui-ease-standard),
                border-color 200ms var(--ui-ease-standard),
                color 200ms var(--ui-ease-standard),
                transform 200ms var(--ui-ease-standard),
                box-shadow 240ms var(--ui-ease-standard) !important;
  }

  .product-row-actions .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 120, 212, 0.18);
  }

  /* 列表页工具栏：吸顶 + 亚克力 */
  .list-toolbar {
    position: sticky;
    top: 84px;
    z-index: 30;
    background: rgba(255, 255, 255, 0.88);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    backdrop-filter: blur(14px) saturate(160%);
    transition: box-shadow 280ms var(--ui-ease-standard),
                border-color 280ms var(--ui-ease-standard),
                background-color 280ms var(--ui-ease-standard);
  }

  .list-toolbar:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.07);
    border-color: rgba(0, 120, 212, 0.18);
  }

  .search-field {
    transition: border-color 240ms var(--ui-ease-standard),
                background-color 240ms var(--ui-ease-standard),
                box-shadow 240ms var(--ui-ease-standard);
  }

  .search-field:focus-within {
    box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.16);
  }

  .search-field button {
    min-width: 44px;
    min-height: 36px;
    border-radius: 8px;
    transition: background-color 200ms var(--ui-ease-standard),
                color 200ms var(--ui-ease-standard),
                transform 200ms var(--ui-ease-standard);
  }

  .search-field button:active {
    transform: scale(0.94);
  }

  .back-link {
    transition: color 200ms var(--ui-ease-standard),
                transform 220ms var(--ui-ease-standard);
  }

  .back-link:hover {
    transform: translateX(-4px);
  }

  /* 下载分类按钮 */
  .category-btn {
    transition: color 220ms var(--ui-ease-standard),
                background-color 220ms var(--ui-ease-standard),
                border-color 220ms var(--ui-ease-standard),
                transform 220ms var(--ui-ease-standard),
                box-shadow 240ms var(--ui-ease-standard);
  }

  .category-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 120, 212, 0.18);
  }

  .category-btn:active {
    transform: scale(0.96);
  }

  .download-card .download-icon {
    transition: transform 320ms var(--ui-ease-spring),
                background-color 240ms var(--ui-ease-standard);
  }

  .download-card:hover .download-icon {
    transform: scale(1.08) rotate(-3deg);
    background: rgba(0, 120, 212, 0.14);
  }

  /* 主按钮 / 次级按钮 */
  .btn,
  .btn-download,
  .btn-info,
  .btn-file-download,
  .btn-login,
  .btn-signup,
  .cta-button,
  .view-more a,
  .view-more button,
  .news-page-btn,
  .help-chips a,
  .topbar a.back,
  .doc .back {
    transition: background-color 220ms var(--ui-ease-standard),
                border-color 220ms var(--ui-ease-standard),
                color 220ms var(--ui-ease-standard),
                box-shadow 260ms var(--ui-ease-standard),
                transform 220ms var(--ui-ease-standard) !important;
  }

  .btn:active,
  .btn-download:active,
  .btn-info:active,
  .btn-file-download:active,
  .btn-login:active,
  .btn-signup:active,
  .cta-button:active,
  .view-more a:active,
  .view-more button:active,
  .news-page-btn:active,
  .help-chips a:active,
  .doc .back:active {
    transform: scale(0.97);
  }

  .view-more button[aria-expanded="true"] .toggle-icon {
    transform: rotate(180deg);
  }

  .view-more .toggle-icon {
    transition: transform 240ms var(--ui-ease-standard);
  }

  /* 登录 / 注册卡片入场 */
  .login-card,
  .signup-card {
    animation: ui-card-in 420ms var(--ui-ease-spring) both;
  }

  .login-header,
  .signup-header {
    animation: ui-fade-down 380ms var(--ui-ease-decel) both;
  }

  @keyframes ui-fade-down {
    from {
      opacity: 0;
      transform: translateY(-10px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  .form-group {
    transition: transform 220ms var(--ui-ease-standard);
  }

  .form-input {
    transition: border-color 200ms var(--ui-ease-standard),
                box-shadow 200ms var(--ui-ease-standard),
                background-color 200ms var(--ui-ease-standard),
                transform 220ms var(--ui-ease-standard);
  }

  .form-input:focus {
    transform: translateY(-1px);
  }

  /* 帮助中心 */
  .help-chips a:hover {
    transform: translateY(-2px);
  }

  .side-doc,
  .side-sub,
  .toc a {
    transition: color 200ms var(--ui-ease-standard),
                background-color 200ms var(--ui-ease-standard),
                transform 200ms var(--ui-ease-standard);
  }

  .side-doc:hover,
  .side-sub:hover,
  .toc a:hover {
    transform: translateX(3px);
  }

  /* 文件列表 */
  .file-item {
    transition: background-color 200ms var(--ui-ease-standard);
  }

  .file-item:hover {
    background: rgba(0, 120, 212, 0.035);
  }

  /* 文档阅读页 */
  .doc {
    animation: ui-card-in 420ms var(--ui-ease-decel) both;
  }

  .toc {
    animation: ui-fade-down 400ms var(--ui-ease-decel) both;
  }

  /* 产品详情弹窗（桌面） */
  .product-modal {
    animation: ui-card-in 320ms var(--ui-ease-spring) both !important;
  }

  .product-modal-overlay {
    animation: ui-overlay-in 220ms var(--ui-ease-standard) both;
  }

  /* 页头文字与章节标题的轻微层次 */
  .page-header h1,
  .hero h1 {
    letter-spacing: -0.02em;
  }

  /* 团队区块在大屏居中，避免文字行过长 */
  .team-overview {
    width: min(calc(100% - 4rem), 1400px);
    margin-left: auto;
    margin-right: auto;
  }
}

/* ===================== 7. 桌面大屏布局细化 ===================== */
@media (min-width: 1024px) {
  .services-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1200px) {
  /* 产品列表页：卡片栅格化，不再是单列长条 */
  #listGrid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.75rem;
    align-items: stretch;
  }

  #listGrid > .product-card {
    height: 100%;
  }

  #listGrid > .empty-state {
    grid-column: 1 / -1;
  }

  /* 首页队员卡片：两列居中，避免单行过宽 */
  .members-section .members-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 920px;
    margin-left: auto;
    margin-right: auto;
  }

  /* 新闻卡片三列，阅读宽度更舒适 */
  .news-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .news-list > .no-data,
  .news-list > .news-no-data {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1440px) {
  nav,
  .services,
  .section-spacing,
  .news-section {
    max-width: 1480px;
  }

  .page-header {
    padding-left: 2.5rem;
    padding-right: 2.5rem;
  }

  .section-subtitle {
    margin-bottom: 3.5rem;
  }
}

@media (min-width: 1680px) {
  nav,
  .services,
  .section-spacing,
  .news-section {
    max-width: 1560px;
  }

  .team-overview {
    width: min(calc(100% - 4rem), 1560px);
  }

  .systems-section {
    max-width: 1320px;
  }

  .hero h1 {
    font-size: 3.7rem;
  }

  .hero p {
    font-size: 1.35rem;
  }

  .page-header h1 {
    font-size: 3.1rem;
  }

  .page-header p {
    font-size: 1.3rem;
  }

  .section-title {
    font-size: 2.4rem;
  }

  .product-info {
    padding: 2.25rem;
  }

  .download-grid {
    gap: 1.75rem;
  }
}

/* ===================== 8. 减少动态效果 ===================== */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto !important;
  }

  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }

  html.ui-ready .ui-reveal,
  html.ui-ready .ui-reveal:not(.ui-in),
  html.ui-ready .ui-stagger:not(.ui-in) > * {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
  }
}
