/* ============================================================
   macOS Desktop Theme - Animations & Transitions
   ============================================================ */

/* 全局过渡 */
* {
  -webkit-tap-highlight-color: transparent;
}

/* 窗口打开动画 */
@keyframes windowScaleIn {
  0% {
    opacity: 0;
    transform: scale(0.9) translateY(30px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes windowFadeIn {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes windowSlideUp {
  0% {
    opacity: 0;
    transform: translateY(100%);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Dock 图标弹跳 */
@keyframes dockBounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-12px);
  }
}

.dock-item.bounce .dock-icon {
  animation: dockBounce 0.5s ease;
}

/* 状态栏时间刷新 */
@keyframes timePulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* 桌面图标悬停光泽 */
.desktop-icon::before,
.desktop-file-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.5s;
  pointer-events: none;
}

.desktop-icon:hover::before,
.desktop-file-item:hover::before {
  left: 100%;
}

/* 内容淡入 */
@keyframes contentFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.window-content > * {
  animation: contentFadeIn 0.4s var(--macos-transition) both;
}

/* 链接下划线动画 */
.markdown-body a {
  position: relative;
}

/* 按钮涟漪效果 */
@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 1;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

/* 加载动画 */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--macos-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* 渐入动画类 */
.fade-in {
  animation: fadeIn 0.5s ease both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.slide-up {
  animation: slideUp 0.5s ease both;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.scale-in {
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 窗口拖拽时的样式 */
.macos-window.dragging {
  transition: none !important;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4) !important;
}

/* Dock 图标放大过渡 */
.dock-item,
.dock-icon {
  will-change: transform;
}

/* 平滑滚动条 */
.window-content,
.post-content-wrapper,
.page-content,
.archive-content,
.category-content,
.tag-content,
.post-toc-sidebar,
.desktop-widgets,
.search-results {
  scroll-behavior: smooth;
}

/* 图片懒加载淡入 */
img[loading="lazy"] {
  opacity: 0;
  transition: opacity 0.3s ease;
}

img[loading="lazy"].loaded {
  opacity: 1;
}

/* 焦点样式 */
:focus-visible {
  outline: 2px solid var(--macos-blue);
  outline-offset: 2px;
  border-radius: 4px;
}

/* 选中文本动画 */
::selection {
  transition: background 0.2s;
}
