/**
 * 增强样式 - UI 优化和动画增强
 */

/* ============================================================================
   快捷键帮助弹窗
   ============================================================================ */
.shortcut-help-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 200ms ease;
}

.shortcut-help-modal.is-visible {
  opacity: 1;
}

.shortcut-help-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.shortcut-help-dialog {
  position: relative;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.shortcut-help-modal.is-visible .shortcut-help-dialog {
  transform: scale(1);
}

.shortcut-help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
}

.shortcut-help-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.shortcut-help-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 120ms ease;
}

.shortcut-help-close:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

.shortcut-help-close:active {
  transform: scale(0.95);
}

.shortcut-help-content {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(80vh - 88px);
}

.shortcut-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: var(--section-bg);
  transition: background 120ms ease;
}

.shortcut-item:hover {
  background: var(--hover-bg);
}

.shortcut-item kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--card-bg);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}

.shortcut-item span {
  font-size: 14px;
  color: var(--text-secondary);
}

/* 移动端优化 */
@media (max-width: 640px) {
  .shortcut-help-dialog {
    width: 95%;
    max-height: 90vh;
  }

  .shortcut-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================================
   焦点可见性优化
   ============================================================================ */
button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--status-green);
  outline-offset: 2px;
  transition: outline 120ms ease;
}

/* ============================================================================
   卡片入场动画
   ============================================================================ */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.model-card {
  animation: slideInUp 300ms cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

.model-card:nth-child(1) { animation-delay: 0ms; }
.model-card:nth-child(2) { animation-delay: 40ms; }
.model-card:nth-child(3) { animation-delay: 80ms; }
.model-card:nth-child(4) { animation-delay: 120ms; }
.model-card:nth-child(5) { animation-delay: 160ms; }
.model-card:nth-child(6) { animation-delay: 200ms; }
.model-card:nth-child(7) { animation-delay: 240ms; }
.model-card:nth-child(8) { animation-delay: 280ms; }
.model-card:nth-child(9) { animation-delay: 320ms; }

/* ============================================================================
   性能优化 - CSS Containment
   ============================================================================ */
.metric-card,
.model-card,
.model-stat-item {
  contain: layout style paint;
}

/* 频繁变化的元素使用 will-change */
.model-card:hover,
.metric-card:hover,
button:active {
  will-change: transform, box-shadow;
}

/* ============================================================================
   减少动效模式支持
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 平滑滚动 */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* ============================================================================
   打印样式优化
   ============================================================================ */
@media print {
  .shortcut-help-modal,
  .toast,
  button,
  .model-toolbar,
  .model-pagination,
  video,
  #theme-background-video {
    display: none !important;
  }

  .model-card,
  .metric-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  body {
    background: white !important;
    color: black !important;
  }
}

/* ============================================================================
   高对比度模式支持
   ============================================================================ */
@media (prefers-contrast: high) {
  .model-card,
  .metric-card,
  button {
    border-width: 2px;
  }

  button:hover,
  .model-card:hover {
    outline: 2px solid currentColor;
    outline-offset: 2px;
  }
}
