/* ============================================
   回到顶部按钮
   ============================================ */

.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ink-deep) 0%, var(--ink) 100%);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  z-index: 999;
  border: none;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

/* ============================================
   图片懒加载占位符
   ============================================ */

.img-placeholder {
  background: linear-gradient(135deg, var(--paper-warm) 0%, var(--paper-cool) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-lighter);
  font-size: 14px;
}

/* ============================================
   加载骨架屏
   ============================================ */

.skeleton {
  background: linear-gradient(90deg, var(--paper-warm) 25%, var(--paper) 50%, var(--paper-warm) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.skeleton-card .skeleton-img {
  width: 100%;
  height: 200px;
}

.skeleton-card .skeleton-title {
  height: 20px;
  margin: 16px;
  width: 80%;
}

.skeleton-card .skeleton-meta {
  height: 16px;
  margin: 8px 16px 16px;
  width: 60%;
}

/* ============================================
   优化滚动条
   ============================================ */

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--paper);
}

::-webkit-scrollbar-thumb {
  background: var(--ink-light);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--ink);
}

/* ============================================
   打印样式
   ============================================ */

@media print {
  .navbar,
  .hero,
  .features,
  .footer,
  .back-to-top,
  .btn {
    display: none !important;
  }

  .works-section {
    padding: 20px;
  }

  .work-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* ============================================
   无障碍优化
   ============================================ */

:focus {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* 屏幕阅读器专用 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================
   深色模式支持（可选）
   ============================================ */

@media (prefers-color-scheme: dark) {
  /* 如果用户没有手动设置，可以自动跟随系统 */
}

/* 手动切换深色模式 */
[data-theme="dark"] {
  --paper: #1a202c;
  --paper-warm: #2d3748;
  --paper-cool: #2d3748;
  --text: #e2e8f0;
  --text-light: #a0aec0;
  --text-lighter: #718096;
  --white: #2d3748;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .navbar {
  background: rgba(45, 55, 72, 0.95);
}

[data-theme="dark"] .work-card {
  background: var(--white);
}

/* ============================================
   搜索历史下拉框
   ============================================ */

#searchHistory {
  border: 1px solid rgba(26, 31, 58, 0.1);
}

#searchHistory .search-history-header {
  padding: 12px 16px;
  font-size: 12px;
  color: var(--text-lighter);
  border-bottom: 1px solid rgba(26, 31, 58, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#searchHistory .search-history-header .clear-btn {
  background: none;
  border: none;
  color: var(--text-lighter);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
}

#searchHistory .search-history-header .clear-btn:hover {
  background: rgba(26, 31, 58, 0.05);
  color: var(--text);
}

#searchHistory .search-history-item {
  padding: 10px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.2s;
}

#searchHistory .search-history-item:hover {
  background: rgba(26, 31, 58, 0.05);
}

#searchHistory .search-history-item i {
  color: var(--text-lighter);
  font-size: 14px;
}

#searchHistory .search-history-item span {
  flex: 1;
  font-size: 14px;
  color: var(--text);
}

#searchHistory .search-history-item .delete-btn {
  background: none;
  border: none;
  color: var(--text-lighter);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: none;
}

#searchHistory .search-history-item:hover .delete-btn {
  display: block;
}

#searchHistory .search-history-item .delete-btn:hover {
  color: #e53e3e;
  background: rgba(229, 62, 62, 0.1);
}

#searchHistory .search-history-empty {
  padding: 20px 16px;
  text-align: center;
  color: var(--text-lighter);
  font-size: 14px;
}

/* 深色模式 - 搜索历史 */
[data-theme="dark"] #searchHistory {
  background: var(--paper-warm);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] #searchHistory .search-history-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] #searchHistory .search-history-item span {
  color: var(--text);
}
