/* 好福田 - YouTube风格移动优先样式 */
/* 编码: UTF-8 */

/* ========== 基础重置 ========== */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  line-height: 1.6;
  color: #374151;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

/* ========== 触摸优化 ========== */
a, button {
  touch-action: manipulation;
}

/* ========== 隐藏滚动条 ========== */
.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

/* ========== 分类标签栏 ========== */
.category-tab {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.category-tab:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.category-tab.active {
  background: #1f2937;
  color: white;
  border-color: #1f2937;
}

/* ========== YouTube风格视频卡片 ========== */
.video-card-yt {
  display: block;
  background: white;
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.video-card-yt:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

.video-card-yt:active {
  transform: scale(0.98);
}

/* 16:9缩略图容器 */
.thumbnail-container {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 */
  background: #e5e7eb;
  overflow: hidden;
}

.thumbnail-container img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.video-card-yt:hover .thumbnail-container img {
  transform: scale(1.05);
}

.thumbnail-container .duration {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
}

.video-card-yt .info {
  padding: 0.75rem;
}

.video-card-yt .title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1f2937;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-card-yt .meta {
  margin-top: 0.375rem;
  font-size: 0.75rem;
  color: #6b7280;
}

/* ========== 旧版视频卡片（保留兼容） ========== */
.video-card {
  @apply flex bg-white rounded-xl shadow-md p-2 transition-all duration-300 hover:shadow-lg hover:-translate-y-0.5 active:scale-[0.98];
  overflow: hidden;
}

.video-card__thumbnail {
  @apply relative w-[120px] min-w-[120px] h-[68px] bg-gray-200 rounded-md overflow-hidden;
}

.video-card__thumbnail img {
  @apply w-full h-full object-cover;
}

.video-card__duration {
  @apply absolute bottom-1 right-1 bg-black/60 text-white text-[10px] font-bold px-1 py-0.5 rounded-sm;
}

.video-card__info {
  @apply flex flex-col justify-center flex-1 p-2 py-0 min-w-0;
}

.video-card__title {
  @apply font-semibold text-gray-800 text-sm leading-tight;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-card__meta {
  @apply text-xs text-gray-500 mt-1;
}

/* ========== 视频播放页 ========== */
.video-player-container {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 */
  background: #000;
}

.video-player-container video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ========== 音频播放器按钮 ========== */
.audio-player-btn {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #fbbf24;
  transition: all 0.2s ease;
}

.audio-player-btn:hover {
  background: linear-gradient(135deg, #fde68a 0%, #fbbf24 100%);
  box-shadow: 0 2px 8px rgba(251, 191, 36, 0.4);
}

.audio-player-btn:active {
  transform: scale(0.98);
}

/* 音频播放器展开区域 */
.audio-player-expanded {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #fbbf24;
}

.audio-player-expanded audio {
  width: 100%;
  height: 40px;
  border-radius: 0.5rem;
}

/* 旧版音频播放器（保留兼容） */
.audio-player {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-radius: 0.75rem;
  padding: 1rem;
  margin-top: 1rem;
}

.audio-player audio {
  width: 100%;
  height: 40px;
}

/* ========== 侧边栏相关视频 ========== */
.related-video-item {
  display: flex;
  background: white;
  border-radius: 0.5rem;
  padding: 0.5rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

.related-video-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  background: #f9fafb;
}

/* ========== 文本截断 ========== */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ========== 首页分类行展示 ========== */
.category-row {
  margin-bottom: 2rem;
}

/* 横向滚动视频卡片 */
.video-card-horizontal {
  width: 280px;
  min-width: 280px;
}

/* 移动端适配 */
@media (max-width: 640px) {
  .video-card-horizontal {
    width: 240px;
    min-width: 240px;
  }
}

/* 横向滚动条优化 */
.overflow-x-auto::-webkit-scrollbar {
  height: 6px;
}

.overflow-x-auto::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.overflow-x-auto::-webkit-scrollbar-track {
  background: transparent;
}

/* iOS 平滑滚动 */
.overflow-x-auto {
  -webkit-overflow-scrolling: touch;
}

/* ========== 加载状态 ========== */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}

.loading::after {
  content: "";
  width: 24px;
  height: 24px;
  border: 2px solid #fbbf24;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== 空状态 ========== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #9ca3af;
}

.empty-state__icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

/* ========== 返回按钮 ========== */
.back-button {
  display: inline-flex;
  align-items: center;
  color: #b45309;
  font-size: 0.875rem;
  padding: 0.5rem 0;
  touch-action: manipulation;
}

.back-button:active {
  opacity: 0.7;
}

/* ========== 媒体查询 - 平板及以上 ========== */
@media (min-width: 768px) {
  .video-card__thumbnail {
    width: 160px;
    min-width: 160px;
    height: 90px;
  }

  .video-card__title {
    font-size: 1rem;
  }

  .video-card__duration {
    font-size: 0.75rem;
    padding: 2px 6px;
  }

  .video-card-yt .title {
    font-size: 1rem;
  }

  .video-card-yt .meta {
    font-size: 0.8125rem;
  }
}

/* ========== 安全区域适配（iPhone X+）========== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  footer {
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  }
}
