:root {
  --primary-color: #8b5cf6;
  --secondary-color: #f7fafc;
  --text-color: #2d3748;
  --light-gray: #e2e8f0;
  --dark-gray: #4a5568;
  --border-radius: 8px;
  --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-family);
}

body {
  font-family: var(--font-family);
  line-height: 1.6;
  color: var(--text-color);
  background-color: #f8f9fa;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 25%, #f093fb 50%, #f5576c 75%, #4facfe 100%);
  background-size: 300% 300%;
  animation: techGradient 8s ease infinite;
  color: white;
  padding: 40px 0;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 15px 35px rgba(102, 126, 234, 0.2);
  border-bottom-left-radius: var(--border-radius);
  border-bottom-right-radius: var(--border-radius);
}

/* 科技网格背景 */
header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
  background-size: 30px 30px;
  animation: gridMove 20s linear infinite;
  opacity: 0.6;
}

/* 几何图形装饰 */
header::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.3) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.2) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
  animation: geometricPulse 6s ease-in-out infinite;
}

/* 科技线条效果 */
header .container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
  animation: scanLine 3s ease-in-out infinite;
  z-index: 2;
}

/* 浮动几何图形 */
header .container::after {
  content: '';
  position: absolute;
  top: 20%;
  right: 10%;
  width: 60px;
  height: 60px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  animation: orbitRotate 10s linear infinite;
  z-index: 2;
}

/* 添加更多几何装饰 */
header .container {
  position: relative;
}

header .container>*::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 5%;
  width: 40px;
  height: 40px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  transform: rotate(45deg);
  animation: squarePulse 4s ease-in-out infinite;
  z-index: 2;
}

@keyframes techGradient {
  0% {
    background-position: 0% 50%;
  }

  25% {
    background-position: 100% 50%;
  }

  50% {
    background-position: 100% 100%;
  }

  75% {
    background-position: 0% 100%;
  }

  100% {
    background-position: 0% 50%;
  }
}

@keyframes gridMove {
  0% {
    transform: translate(0, 0);
  }

  100% {
    transform: translate(30px, 30px);
  }
}

@keyframes geometricPulse {

  0%,
  100% {
    opacity: 0.3;
    transform: scale(1);
  }

  50% {
    opacity: 0.7;
    transform: scale(1.1);
  }
}

@keyframes scanLine {

  0%,
  100% {
    opacity: 0;
    transform: translateY(0);
  }

  50% {
    opacity: 1;
    transform: translateY(100px);
  }
}

@keyframes orbitRotate {
  0% {
    transform: rotate(0deg);
    border-color: rgba(255, 255, 255, 0.3);
  }

  25% {
    border-color: rgba(255, 255, 255, 0.6);
  }

  50% {
    transform: rotate(180deg);
    border-color: rgba(255, 255, 255, 0.3);
  }

  75% {
    border-color: rgba(255, 255, 255, 0.6);
  }

  100% {
    transform: rotate(360deg);
    border-color: rgba(255, 255, 255, 0.3);
  }
}

@keyframes squarePulse {

  0%,
  100% {
    opacity: 0.2;
    transform: rotate(45deg) scale(1);
  }

  50% {
    opacity: 0.6;
    transform: rotate(45deg) scale(1.2);
  }
}

header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  font-weight: 600;
  position: relative;
  z-index: 1;
}

.filters {
  margin: 30px 0;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

#search {
  padding: 12px 15px;
  border: 1px solid var(--light-gray);
  border-radius: var(--border-radius);
  font-size: 1rem;
  width: 100%;
  font-family: var(--font-family);
}

.tags-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  position: relative;
  min-height: 40px;
}

/* 折叠状态的滚动容器 - 保持多行布局 */
.tags-filter.collapsed {
  position: relative;
  overflow: hidden;
  max-height: 120px; /* 限制显示约3行标签的高度 */
}

.scrolling-tags-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
}

.tags-scrolling-content {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  will-change: transform;
  animation: scrollTagsVertical 40s linear infinite;
  /* 创建足够的内容高度以实现滚动 */
  padding-bottom: 120px;
}

.tags-filter.collapsed .tag-button {
  flex-shrink: 0;
}

/* 展开状态重置样式 */
.tags-filter.expanded {
  flex-wrap: wrap;
  max-height: none;
  overflow: visible;
}

.tags-filter.expanded .scrolling-tags-wrapper {
  display: none;
}

/* 垂直滚动动画 - 保持多行布局 */
@keyframes scrollTagsVertical {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-50%);
  }
}

/* 复制标签样式 */
.tag-duplicate {
  opacity: 1;
}

/* 添加渐变遮罩效果，让滚动更自然 */
.tags-filter.collapsed::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 30px;
  background: linear-gradient(transparent, #f8f9fa);
  pointer-events: none;
  z-index: 1;
}

.tags-filter.collapsed .tag-toggle-btn {
  position: absolute;
  bottom: 5px;
  right: 10px;
  z-index: 2;
  background: #f8f9fa;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 浮动的"全部"按钮样式 */
.tags-filter.collapsed .tag-all-floating {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  background: #f8f9fa;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: normal;
  font-family: var(--font-family);
  border: 1px solid var(--light-gray);
}

.tags-filter.collapsed .tag-all-floating:hover {
  background-color: rgba(139, 92, 246, 0.1);
}

.tags-filter.collapsed .tag-all-floating.active {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.tag-button {
  background-color: rgba(139, 92, 246, 0.05);
  border: 1px solid var(--light-gray);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: normal;
  font-family: var(--font-family);
}

.tag-button:hover {
  background-color: rgba(139, 92, 246, 0.1);
}

.tag-button.active {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.tag-toggle-btn {
  background: var(--secondary-color);
  border: 1px solid var(--light-gray);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 1.3rem;
  cursor: pointer;
  margin-left: 10px;
  font-family: var(--font-family);
  transition: background 0.2s, color 0.2s;
  color: var(--primary-color);
  box-shadow: 0 1px 4px rgba(94, 114, 228, 0.08);
}

.tag-toggle-btn:hover {
  background: var(--light-gray);
  color: #222;
}

.cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 25px;
  margin-bottom: 50px;
}

.card {
  background-color: white;
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--box-shadow);
  transition: transform 0.3s, opacity 0.2s ease-in-out;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.card:hover {
  transform: translateY(-5px);
}

.card-image {
  width: 100%;
  height: 0;
  padding-bottom: 56.25%;
  /* 16:9 aspect ratio (720/1280 = 0.5625) */
  position: relative;
  overflow: hidden;
  background-color: #f8f9fa;
}

.card-image img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 5px;
  font-family: var(--font-family);
}

.card-function {
  color: var(--primary-color);
  font-size: 0.9rem;
  margin-bottom: 10px;
  font-weight: normal;
  font-family: var(--font-family);
}

.card-description {
  margin-bottom: 15px;
  color: var(--text-color);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: normal;
  font-size: 0.95rem;
  font-family: var(--font-family);
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 15px;
}

.card-tag {
  background-color: var(--secondary-color);
  border-radius: 15px;
  padding: 4px 10px;
  font-size: 0.8rem;
  color: var(--dark-gray);
  font-weight: normal;
  font-family: var(--font-family);
}

.card-link {
  display: inline-block;
  background-color: var(--primary-color);
  color: white;
  padding: 8px 15px;
  border-radius: var(--border-radius);
  text-decoration: none;
  font-weight: normal;
  transition: background-color 0.2s;
  margin-top: auto;
  text-align: center;
  width: 100%;
  font-family: var(--font-family);
}

.card-link:hover {
  background-color: #7c3aed;
}

.loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 50px;
  font-size: 1.2rem;
  color: var(--dark-gray);
  font-family: var(--font-family);
}

footer {
  background-color: var(--secondary-color);
  padding: 20px 0;
  text-align: center;
  border-top: 1px solid var(--light-gray);
  margin-top: 30px;
  font-family: var(--font-family);
}

@media (max-width: 768px) {
  .cards-container {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }

  header h1 {
    font-size: 2rem;
  }
}

@media (min-width: 769px) {
  .cards-container {
    grid-template-columns: repeat(4, 1fr);
  }
}