/* 全局样式 */
:root {
  --primary-color: #e74c3c;
  --secondary-color: #3498db;
  --text-color: #333;
  --text-light: #7f8c8d;
  --bg-color: #f5f5f5;
  --white: #fff;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --transition: all 0.3s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  overflow-x: hidden;
}

a {
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
}

a:hover {
  color: var(--primary-color);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* 导航栏 */
nav {
  background: var(--white);
  padding: 1rem;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

nav .container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
  gap: 1rem;
}

nav .logo {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--primary-color);
  white-space: nowrap;
  transition: var(--transition);
}

nav .logo:hover {
  transform: scale(1.05);
}

nav ul {
  display: flex;
  list-style: none;
  gap: 0.5rem;
  flex-wrap: nowrap;
  flex: 1;
  justify-content: flex-end;
  min-width: 0;
}

nav ul li {
  flex: 0 1 auto;
  min-width: 0;
}

nav ul li a {
  padding: 0.5rem 0.8rem;
  display: block;
  border-radius: var(--radius);
  transition: var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

nav ul li a:hover {
  background: var(--primary-color);
  color: var(--white);
  transform: translateY(-2px);
}

/* 主内容区域 */
main {
  min-height: calc(100vh - 200px);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* 视频网格 */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

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

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

.video-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.video-card h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

.video-card p {
  font-size: 0.95rem;
  color: var(--text-light);
}

/* 按钮样式 */
.btn {
  display: inline-block;
  padding: 0.8rem 1.5rem;
  background: var(--primary-color);
  color: var(--white);
  border-radius: var(--radius);
  transition: var(--transition);
  border: none;
  cursor: pointer;
  font-size: 1rem;
}

.btn:hover {
  background: #c0392b;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

/* 返回顶部按钮 */
#backToTop {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 50px;
  height: 50px;
  background: var(--primary-color);
  color: var(--white);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
  z-index: 99;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#backToTop:hover {
  background: #c0392b;
  transform: translateY(-5px);
}

#backToTop.show {
  display: flex;
}

/* 响应式设计 */
@media (max-width: 768px) {
  nav .container {
    flex-wrap: nowrap;
    gap: 0.5rem;
  }

  nav .logo {
    font-size: 1.2rem;
    margin-right: 0.5rem;
  }

  nav ul {
    gap: 0.2rem;
    flex: 1;
    min-width: 0;
  }

  nav ul li a {
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
  }

  .video-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
  }

  .hero h1,
  .page-header h1 {
    font-size: 1.5rem !important;
  }

  #backToTop {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    bottom: 1rem;
    right: 1rem;
  }
}

@media (max-width: 480px) {
  nav ul li a {
    padding: 0.3rem 0.4rem;
    font-size: 0.75rem;
  }

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

  .hero,
  .page-header {
    padding: 1.5rem 1rem !important;
  }
}

/* UI 风格变体 */
.ui-style-0 { --primary-color: #e74c3c; }
.ui-style-1 { --primary-color: #3498db; }
.ui-style-2 { --primary-color: #2ecc71; }
.ui-style-3 { --primary-color: #9b59b6; }
.ui-style-4 { --primary-color: #f39c12; }
.ui-style-5 { --primary-color: #1abc9c; }
.ui-style-6 { --primary-color: #e67e22; }
.ui-style-7 { --primary-color: #34495e; }
.ui-style-8 { --primary-color: #c0392b; }
.ui-style-9 { --primary-color: #8e44ad; }
.ui-style-10 { --primary-color: #16a085; }
.ui-style-11 { --primary-color: #27ae60; }
.ui-style-12 { --primary-color: #2980b9; }
.ui-style-13 { --primary-color: #f1c40f; }
.ui-style-14 { --primary-color: #d35400; }
.ui-style-15 { --primary-color: #2c3e50; }

/* 动画效果 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.video-card,
.resource-item,
.rank-item,
.topic-item,
.latest-item {
  animation: fadeIn 0.5s ease-out;
}

/* 加载动画 */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(231, 76, 60, 0.3);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 0.8s linear infinite;
}

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

/* 打印样式 */
@media print {
  nav,
  footer,
  #backToTop {
    display: none;
  }

  body {
    background: white;
  }

  .video-card,
  .resource-item {
    break-inside: avoid;
  }
}
