/* 革命历史风格主题变量 */
:root {
  --primary-red: #9e1f28; /* 革命红 */
  --dark-red: #7a0f1a;
  --gold: #d4af37; /* 金色点缀 */
  --dark-gray: #2c2c2c; /* 深灰背景 */
  --medium-gray: #3a3a3a;
  --light-gray: #f5f5f5;
  --beige: #f8f3e9; /* 米黄色背景 */
  --brown: #8b4513; /* 棕色边框 */
  --white: #ffffff;
  --text-dark: #333333;
  --text-light: #666666;
  --font-main: "Microsoft YaHei", "SimHei", "Helvetica Neue", Arial, sans-serif;
  --font-title: "SimHei", "Microsoft YaHei", sans-serif;
}

/* 重置与基础样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-main);
  padding: 20px;
  background: var(--light-gray);
  background-image: linear-gradient(to bottom, #f8f3e9 0%, #f0e6d6 100%);
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: var(--white);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--brown);
  position: relative;
}

.container::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(to right, var(--primary-red), var(--gold), var(--primary-red));
  border-radius: 8px 8px 0 0;
}

/* 标题样式 */
h1 {
  text-align: center;
  color: var(--primary-red);
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--gold);
  font-size: 28px;
  font-family: var(--font-title);
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
  letter-spacing: 2px;
  position: relative;
}

h1::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 2px;
  background: var(--primary-red);
}

/* 搜索框 */
.search-box {
  margin: 20px 0;
}

#searchInput {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid #ddd;
  border-radius: 4px;
  font-size: 16px;
  font-family: var(--font-main);
  background-color: #fdfdfd;
  transition: all 0.3s ease;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%239e1f28" width="18" height="18"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>');
  background-repeat: no-repeat;
  background-position: 15px center;
  padding-left: 45px;
}

#searchInput:focus {
  border-color: var(--primary-red);
  outline: none;
  box-shadow: 0 0 0 3px rgba(158, 31, 40, 0.2);
}

/* 字母导航 */
.alphabet-nav-container {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  padding: 12px 0;
  margin: 15px 0 25px 0;
  border-radius: 8px;
  border: 1px solid #e6d6b5;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
}

.alphabet-nav {
  display: flex;
  overflow-x: auto;
  padding: 5px 10px;
  white-space: nowrap;
  min-height: 50px;
  align-items: center;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-red) #f0f0f0;
}

.alphabet-nav::-webkit-scrollbar {
  height: 6px;
}

.alphabet-nav::-webkit-scrollbar-track {
  background: #f0f0f0;
  border-radius: 3px;
}

.alphabet-nav::-webkit-scrollbar-thumb {
  background: var(--primary-red);
  border-radius: 3px;
}

.letter-link {
  padding: 10px 15px;
  margin: 0 3px;
  background: var(--white);
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  text-decoration: none;
  color: var(--primary-red);
  font-weight: bold;
  font-size: 16px;
  min-width: 45px;
  text-align: center;
  transition: all 0.2s ease;
  font-family: var(--font-title);
}

.letter-link:hover {
  background: var(--primary-red);
  color: var(--white);
  border-color: var(--primary-red);
  transform: translateY(-2px);
}

.letter-link.active {
  background: var(--primary-red);
  color: var(--white);
  border-color: var(--primary-red);
  box-shadow: 0 3px 8px rgba(158, 31, 40, 0.3);
}

.letter-link.empty {
  color: #aaa;
  background: #f9f9f9;
  border-color: #eee;
  cursor: not-allowed;
}

.nav-indicator {
  text-align: center;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-light);
  font-style: italic;
}

/* 字母分组 */
.letter-group {
  margin: 30px 0;
  scroll-margin-top: 120px;
}

.letter-header {
  background: linear-gradient(to right, var(--primary-red), var(--dark-red));
  color: var(--white);
  padding: 15px 20px;
  margin-bottom: 20px;
  border-radius: 8px;
  font-size: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-left: 5px solid var(--gold);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}

.letter-count {
  background: var(--white);
  color: var(--primary-red);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: bold;
  border: 1px solid var(--gold);
}

/* 人物列表 */
.person-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.person-item {
  display: flex;
  padding: 20px;
  border: 1px solid #e6d6b5;
  border-radius: 8px;
  background: var(--white);
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.person-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary-red);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.person-item:hover {
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
  border-color: var(--primary-red);
  transform: translateY(-3px);
}

.person-item:hover::before {
  opacity: 1;
}

.person-img {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 20px;
  border: 3px solid #f1f1f1;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
}

.person-item:hover .person-img {
  transform: scale(1.05);
  border-color: var(--gold);
}

.person-info {
  flex: 1;
}

.person-name {
  font-weight: bold;
  color: var(--text-dark);
  margin-bottom: 8px;
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-title);
  position: relative;
  padding-bottom: 5px;
}

.person-name::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 40px;
  height: 2px;
  background: var(--gold);
}

.person-intro {
  color: var(--text-light);
  font-size: 14px;
  line-height: 1.6;
}

/* 查看更多按钮样式 */
.read-more-btn {
  color: var(--primary-red);
  font-size: 12px;
  margin-top: 8px;
  cursor: pointer;
  display: inline-block;
  font-weight: bold;
  padding: 4px 10px;
  border-radius: 3px;
  background: #fff5f5;
  border: 1px solid var(--primary-red);
  transition: all 0.2s ease;
  font-family: var(--font-main);
}

.read-more-btn:hover {
  background: var(--primary-red);
  color: white;
}

/* PC端默认显示5行 */
.person-intro {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.6;
  max-height: 8em;
  transition: max-height 0.3s ease;
}

/* 展开后的样式 */
.person-item.expanded .person-intro {
  -webkit-line-clamp: unset;
  display: block;
  max-height: none;
  overflow: visible;
}

/* 加载、错误、无数据状态 */
.loading, .error, .no-data {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
  font-size: 16px;
}

.error {
  color: var(--primary-red);
}

.loading::before {
  content: "";
  display: block;
  width: 40px;
  height: 40px;
  margin: 0 auto 15px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--primary-red);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 返回顶部按钮 */
.back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--primary-red);
  color: var(--white);
  border: none;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(158, 31, 40, 0.3);
  z-index: 1000;
  display: none;
  transition: all 0.3s ease;
  font-family: var(--font-title);
}

.back-to-top:hover {
  background: var(--dark-red);
  transform: translateY(-5px);
  box-shadow: 0 6px 20px rgba(158, 31, 40, 0.4);
}

/* 响应式设计 */
@media (max-width: 768px) {
  body {
    padding: 10px;
    background: #f8f3e9;
  }
  
  .container {
    padding: 15px;
  }
  
  .alphabet-nav-container {
    padding: 8px 0;
    margin: 10px 0 15px 0;
  }
  
  .alphabet-nav {
    padding: 5px;
    min-height: 45px;
  }
  
  .letter-link {
    padding: 8px 12px;
    font-size: 15px;
    min-width: 40px;
    margin: 0 2px;
  }
  
  .letter-group {
    scroll-margin-top: 100px;
    margin: 25px 0;
  }
  
  .letter-header {
    padding: 12px 15px;
    font-size: 18px;
    margin-bottom: 15px;
  }
  
  .person-list {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .person-item {
    padding: 15px;
  }
  
  .person-img {
    width: 60px;
    height: 60px;
    margin-right: 15px;
  }
  
  .person-name {
    font-size: 16px;
  }
  
  /* 移动端默认显示3行 */
  .person-intro {
    font-size: 13px;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    max-height: 4.2em;
  }
  
  .back-to-top {
    bottom: 20px;
    right: 20px;
    width: 45px;
    height: 45px;
    font-size: 18px;
  }
  
  h1 {
    font-size: 24px;
  }
  
  #searchInput {
    padding: 12px 15px 12px 42px;
    font-size: 15px;
  }
}

@media (max-width: 480px) {
  .alphabet-nav {
    min-height: 42px;
  }
  
  .letter-link {
    padding: 7px 10px;
    font-size: 14px;
    min-width: 38px;
  }
  
  .letter-group {
    scroll-margin-top: 95px;
  }
  
  .letter-header {
    padding: 10px 12px;
    font-size: 16px;
  }
  
  .letter-count {
    padding: 4px 10px;
    font-size: 13px;
  }
  
  .person-img {
    width: 55px;
    height: 55px;
    margin-right: 12px;
  }
  
  .person-intro {
    font-size: 12px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .person-list {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
  }
}

/* 性能优化：图片加载效果 */
.person-img {
  background-color: #f0f0f0;
  background-image: linear-gradient(45deg, #e0e0e0 25%, transparent 25%, transparent 75%, #e0e0e0 75%, #e0e0e0), 
                    linear-gradient(45deg, #e0e0e0 25%, transparent 25%, transparent 75%, #e0e0e0 75%, #e0e0e0);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}
/* 移动端搜索按钮样式 */
.mobile-search-btn {
    display: none;
}

/* 移动端特定优化 */
@media (max-width: 768px) {
    .mobile-search-btn {
        display: block !important;
        margin-top: 10px;
        padding: 12px 20px;
        background: var(--primary-red);
        color: white;
        border: none;
        border-radius: 4px;
        font-size: 16px;
        cursor: pointer;
        width: 100%;
        font-family: var(--font-main);
        transition: all 0.3s ease;
    }
    
    .mobile-search-btn:active {
        background: var(--dark-red);
        transform: translateY(2px);
    }
    
    /* 移动端搜索输入优化 */
    #searchInput {
        font-size: 16px !important; /* 防止iOS自动缩放 */
    }
    
    /* 确保触摸目标足够大 */
    .letter-link {
        min-width: 44px !important;
        min-height: 44px !important;
    }
    
    .person-item {
        touch-action: manipulation;
    }
}