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

html, body {
  min-height: 100%;
}

body {
  font-family: "Noto Serif SC", "STSong", "SimSun", serif;
  background:
    radial-gradient(ellipse at top, #2a3a52 0%, #1a2236 50%, #0f1521 100%);
  color: #e8e0d0;
  line-height: 1.7;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  padding: 40px 20px 80px;
}

.moon {
  position: fixed;
  top: 8%;
  right: 12%;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff8d6 0%, #f0d77a 60%, transparent 70%);
  box-shadow: 0 0 80px 20px rgba(255, 230, 150, 0.15);
  opacity: 0.85;
  z-index: 0;
  pointer-events: none;
}

/* ========== 容器 ========== */
.container {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
}

/* ========== 头部 ========== */
.header {
  text-align: center;
  margin-bottom: 50px;
}

.title {
  font-family: "Ma Shan Zheng", "STKaiti", "KaiTi", serif;
  font-size: 3.2rem;
  font-weight: 400;
  letter-spacing: 0.4em;
  color: #f5e9c8;
  text-shadow: 0 0 20px rgba(245, 233, 200, 0.25);
  margin-bottom: 16px;
}

.divider {
  width: 80px;
  height: 1px;
  background: linear-gradient(to right, transparent, #a89c82, transparent);
  margin: 20px auto;
}

.subtitle {
  font-size: 1rem;
  color: #a89c82;
  letter-spacing: 0.4em;
  font-weight: 300;
}

/* ========== 筛选区 ========== */
.filters {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(245, 233, 200, 0.12);
  border-radius: 6px;
  padding: 24px 28px;
  margin-bottom: 32px;
  backdrop-filter: blur(4px);
}

/* 类型 tab */
.type-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  border-bottom: 1px solid rgba(245, 233, 200, 0.08);
  padding-bottom: 18px;
  flex-wrap: wrap;
}

.type-tab {
  padding: 8px 22px;
  background: transparent;
  border: 1px solid rgba(245, 233, 200, 0.18);
  border-radius: 20px;
  color: #a89c82;
  font-family: inherit;
  font-size: 0.95rem;
  letter-spacing: 0.15em;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
}

.type-tab:hover {
  color: #f5e9c8;
  border-color: rgba(245, 233, 200, 0.4);
  background: rgba(245, 233, 200, 0.04);
}

.type-tab.active {
  color: #1a2236;
  background: linear-gradient(135deg, #f5e9c8 0%, #e8d8a0 100%);
  border-color: #f5e9c8;
  box-shadow: 0 2px 10px rgba(245, 233, 200, 0.2);
}

.search-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 220px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #a89c82;
  font-size: 1.1rem;
  pointer-events: none;
}

#searchInput {
  width: 100%;
  padding: 12px 14px 12px 40px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(245, 233, 200, 0.15);
  border-radius: 4px;
  color: #e8e0d0;
  font-family: inherit;
  font-size: 1rem;
  letter-spacing: 0.05em;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

#searchInput::placeholder {
  color: #6e6552;
}

#searchInput:focus {
  border-color: rgba(245, 233, 200, 0.4);
  background: rgba(0, 0, 0, 0.3);
}

.author-filter {
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(245, 233, 200, 0.15);
  border-radius: 4px;
  color: #e8e0d0;
  font-family: inherit;
  font-size: 1rem;
  letter-spacing: 0.05em;
  outline: none;
  cursor: pointer;
  min-width: 160px;
  transition: border-color 0.2s;
}

.author-filter:focus {
  border-color: rgba(245, 233, 200, 0.4);
}

.author-filter option {
  background: #1a2236;
  color: #e8e0d0;
}

.grade-filter {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(245, 233, 200, 0.15);
  border-radius: 4px;
  color: #e8e0d0;
  font-family: inherit;
  font-size: 1rem;
  letter-spacing: 0.05em;
  outline: none;
  cursor: pointer;
  min-width: 160px;
  transition: border-color 0.2s;
}

.grade-filter:focus {
  border-color: rgba(245, 233, 200, 0.4);
}

.grade-filter option {
  background: #1a2236;
  color: #e8e0d0;
}

.stats {
  margin-top: 16px;
  font-size: 0.9rem;
  color: #8a7f66;
  letter-spacing: 0.1em;
  text-align: right;
}

.stats span {
  color: #f5e9c8;
  font-weight: 600;
}

/* ========== 卡片网格 ========== */
.poem-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.poem-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(245, 233, 200, 0.1);
  border-radius: 4px;
  padding: 22px 22px 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.poem-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(to bottom, transparent, #a89c82, transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.poem-card:hover {
  transform: translateY(-2px);
  border-color: rgba(245, 233, 200, 0.3);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.poem-card:hover::before {
  opacity: 1;
}

/* 卡片头部（徽章 + 词牌/曲牌名 + 年级标签） */
.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  min-height: 22px;
  flex-wrap: wrap;
}

.type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  line-height: 1.5;
}

.type-badge.type-shi {
  background: rgba(195, 145, 80, 0.2);
  color: #d4a86a;
  border: 1px solid rgba(195, 145, 80, 0.35);
}

.type-badge.type-ci {
  background: rgba(140, 180, 200, 0.2);
  color: #9bc4d8;
  border: 1px solid rgba(140, 180, 200, 0.35);
}

.type-badge.type-qu {
  background: rgba(180, 130, 180, 0.2);
  color: #d4a0d4;
  border: 1px solid rgba(180, 130, 180, 0.35);
}

.type-badge.type-qing {
  background: rgba(130, 190, 140, 0.2);
  color: #90c898;
  border: 1px solid rgba(130, 190, 140, 0.35);
}

.type-badge.type-modern {
  background: rgba(200, 170, 100, 0.2);
  color: #d0b870;
  border: 1px solid rgba(200, 170, 100, 0.35);
}

/* 年级标签 */
.grade-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.5;
  margin-left: auto;
}

.grade-primary {
  background: rgba(120, 200, 140, 0.15);
  color: #90d8a0;
  border: 1px solid rgba(120, 200, 140, 0.3);
}

.grade-middle {
  background: rgba(100, 160, 220, 0.15);
  color: #80b8e8;
  border: 1px solid rgba(100, 160, 220, 0.3);
}

.grade-high {
  background: rgba(200, 120, 120, 0.15);
  color: #e8a0a0;
  border: 1px solid rgba(200, 120, 120, 0.3);
}

.grade-extra {
  background: rgba(180, 160, 200, 0.15);
  color: #c8b0d8;
  border: 1px solid rgba(180, 160, 200, 0.3);
}

.cipai-tag {
  font-size: 0.78rem;
  color: #a89c82;
  letter-spacing: 0.1em;
  font-weight: 300;
}

.card-title {
  font-family: "Ma Shan Zheng", "STKaiti", "KaiTi", serif;
  font-size: 1.4rem;
  color: #f5e9c8;
  margin-bottom: 6px;
  letter-spacing: 0.1em;
}

.card-author {
  font-size: 0.85rem;
  color: #a89c82;
  letter-spacing: 0.15em;
}

.author-link {
  cursor: pointer;
  color: #d4a86a;
  transition: color 0.2s, text-decoration 0.2s;
}

.author-link:hover {
  color: #f5e9c8;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.card-preview {
  margin-top: 14px;
  font-size: 0.92rem;
  color: #b8ad94;
  line-height: 1.6;
  letter-spacing: 0.08em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-arrow {
  color: #6e6552;
  font-size: 1.2rem;
  transition: color 0.2s, transform 0.2s;
}

.poem-card:hover .card-arrow {
  color: #f5e9c8;
  transform: translateX(2px);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.speak-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(245, 233, 200, 0.2);
  border-radius: 50%;
  background: rgba(245, 233, 200, 0.05);
  color: #f5e9c8;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.25s ease;
}

.speak-btn:hover {
  background: rgba(245, 233, 200, 0.15);
  border-color: rgba(245, 233, 200, 0.4);
  transform: scale(1.1);
}

.speak-btn:active {
  transform: scale(0.95);
}

/* 弹窗内朗诵按钮 */
.modal-actions {
  display: flex;
  justify-content: center;
  margin: 20px 0 0;
}

.speak-btn-modal {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border: 1px solid rgba(245, 233, 200, 0.3);
  border-radius: 24px;
  background: rgba(245, 233, 200, 0.08);
  color: #f5e9c8;
  font-family: inherit;
  font-size: 0.95rem;
  letter-spacing: 0.2em;
  cursor: pointer;
  transition: all 0.25s ease;
}

.speak-btn-modal:hover {
  background: rgba(245, 233, 200, 0.15);
  border-color: rgba(245, 233, 200, 0.5);
}

.speak-btn-modal:active {
  transform: scale(0.95);
}

.speak-icon {
  font-size: 1.1rem;
}

/* ========== 空状态 ========== */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: #8a7f66;
}

.empty-state p {
  font-size: 1.1rem;
  letter-spacing: 0.15em;
  margin-bottom: 8px;
}

.empty-hint {
  font-size: 0.9rem !important;
  color: #6e6552;
}

/* ========== 详情弹窗 ========== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.25s ease;
}

.modal[hidden] {
  display: none;
}

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

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 15, 25, 0.85);
  backdrop-filter: blur(6px);
}

.modal-content {
  position: relative;
  background: linear-gradient(160deg, #1f2a3e 0%, #141c2c 100%);
  border: 1px solid rgba(245, 233, 200, 0.2);
  border-radius: 6px;
  padding: 48px 48px 56px;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
  animation: slideUp 0.3s ease;
}

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

.modal-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  color: #a89c82;
  font-size: 1.8rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
  line-height: 1;
  border-radius: 50%;
  transition: background 0.2s, color 0.2s;
  /* 移动端优化：禁用双击缩放延迟、提升优先级、关闭高亮 */
  z-index: 10;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.modal-close:hover {
  background: rgba(245, 233, 200, 0.08);
  color: #f5e9c8;
}

.modal-close:active {
  background: rgba(245, 233, 200, 0.15);
  color: #f5e9c8;
}

.modal-cipai {
  text-align: center;
  font-size: 0.9rem;
  color: #9bc4d8;
  letter-spacing: 0.4em;
  margin-bottom: 8px;
  font-weight: 300;
}

.modal-cipai[hidden] {
  display: none;
}

.modal-title {
  font-family: "Ma Shan Zheng", "STKaiti", "KaiTi", serif;
  font-size: 2rem;
  color: #f5e9c8;
  text-align: center;
  letter-spacing: 0.2em;
  margin-bottom: 6px;
}

.modal-author {
  text-align: center;
  font-size: 0.95rem;
  color: #a89c82;
  letter-spacing: 0.3em;
  margin-bottom: 12px;
}

.modal-divider {
  width: 60px;
  height: 1px;
  background: linear-gradient(to right, transparent, #a89c82, transparent);
  margin: 0 auto 32px;
}

.modal-content-text {
  font-size: 1.25rem;
  line-height: 2.4;
  color: #e8e0d0;
  text-align: center;
  letter-spacing: 0.2em;
}

.modal-content-text p {
  margin-bottom: 4px;
}

/* ========== 响应式 ========== */
@media (max-width: 600px) {
  body {
    padding: 24px 14px 60px;
  }
  .title {
    font-size: 2rem;
    letter-spacing: 0.3em;
  }
  .subtitle {
    font-size: 0.85rem;
  }
  .filters {
    padding: 18px;
  }
  .type-tabs {
    gap: 6px;
  }
  .type-tab {
    padding: 6px 14px;
    font-size: 0.85rem;
  }
  .author-filter {
    width: 100%;
  }
  .poem-list {
    grid-template-columns: 1fr;
  }
  .modal-content {
    padding: 40px 28px 44px;
  }
  .modal-title {
    font-size: 1.6rem;
  }
  .modal-content-text {
    font-size: 1.1rem;
  }
  /* 移动端关闭按钮加大到 44x44，符合 Apple/Material 设计规范的最小点击区 */
  .modal-close {
    top: 8px;
    right: 8px;
    width: 44px;
    height: 44px;
    font-size: 2rem;
  }
  .moon {
    width: 70px;
    height: 70px;
    top: 4%;
    right: 6%;
  }
}

/* ========== 顶部主导航 ========== */
.main-nav {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 36px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(245, 233, 200, 0.12);
  border-radius: 30px;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

.nav-btn {
  flex: 1;
  padding: 10px 20px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 24px;
  color: #a89c82;
  font-family: inherit;
  font-size: 1rem;
  letter-spacing: 0.2em;
  cursor: pointer;
  transition: all 0.25s ease;
}

.nav-btn:hover {
  color: #f5e9c8;
  background: rgba(245, 233, 200, 0.05);
}

.nav-btn.active {
  color: #1a2236;
  background: linear-gradient(135deg, #f5e9c8 0%, #e8d8a0 100%);
  border-color: #f5e9c8;
  box-shadow: 0 2px 10px rgba(245, 233, 200, 0.2);
  font-weight: 600;
}

/* ========== 视图切换 ========== */
.view[hidden] {
  display: none;
}

.author-intro {
  text-align: center;
  margin-bottom: 32px;
}

.section-title {
  font-family: "Ma Shan Zheng", "STKaiti", "KaiTi", serif;
  font-size: 2.2rem;
  color: #f5e9c8;
  letter-spacing: 0.3em;
  margin-bottom: 8px;
}

.section-desc {
  font-size: 0.95rem;
  color: #a89c82;
  letter-spacing: 0.15em;
}

.section-desc span {
  color: #f5e9c8;
  font-weight: 600;
  margin: 0 4px;
}

/* ========== 朝代分组小标题 ========== */
.dynasty-header {
  font-family: "Ma Shan Zheng", "STKaiti", "KaiTi", serif;
  font-size: 1.3rem;
  color: #f5e9c8;
  letter-spacing: 0.3em;
  margin: 24px 8px 14px;
  padding-left: 12px;
  border-left: 3px solid #d4a86a;
  text-shadow: 0 0 10px rgba(245, 233, 200, 0.15);
}

.dynasty-header:first-child {
  margin-top: 0;
}

/* ========== 作者卡片 ========== */
.author-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.author-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(245, 233, 200, 0.1);
  border-radius: 4px;
  padding: 22px 22px 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.author-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(to bottom, transparent, #d4a86a, transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.author-card:hover {
  transform: translateY(-2px);
  border-color: rgba(245, 233, 200, 0.3);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.author-card:hover::before {
  opacity: 1;
}

.author-name {
  font-family: "Ma Shan Zheng", "STKaiti", "KaiTi", serif;
  font-size: 1.6rem;
  color: #f5e9c8;
  margin-bottom: 6px;
  letter-spacing: 0.15em;
}

.author-meta {
  font-size: 0.85rem;
  color: #9bc4d8;
  letter-spacing: 0.15em;
  margin-bottom: 12px;
}

.author-preview {
  font-size: 0.9rem;
  color: #b8ad94;
  line-height: 1.6;
  letter-spacing: 0.05em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.author-card .card-arrow {
  color: #6e6552;
}

.author-card:hover .card-arrow {
  color: #f5e9c8;
  transform: translateX(2px);
}

/* ========== 创作背景展开 ========== */
.modal-background {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px dashed rgba(245, 233, 200, 0.15);
}

.bg-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  background: rgba(245, 233, 200, 0.05);
  border: 1px solid rgba(245, 233, 200, 0.2);
  border-radius: 4px;
  color: #f5e9c8;
  font-family: inherit;
  font-size: 0.95rem;
  letter-spacing: 0.2em;
  cursor: pointer;
  transition: all 0.25s ease;
}

.bg-toggle:hover {
  background: rgba(245, 233, 200, 0.1);
  border-color: rgba(245, 233, 200, 0.4);
}

.bg-icon {
  font-size: 1.1rem;
}

.bg-arrow {
  margin-left: auto;
  font-size: 0.85rem;
  color: #a89c82;
  transition: transform 0.3s;
}

.bg-toggle[aria-expanded="true"] .bg-arrow {
  transform: rotate(180deg);
}

.bg-content {
  margin-top: 16px;
  padding: 18px 20px;
  background: rgba(245, 233, 200, 0.04);
  border-left: 3px solid #d4a86a;
  border-radius: 0 4px 4px 0;
  color: #d4caaa;
  font-size: 0.98rem;
  line-height: 1.9;
  letter-spacing: 0.05em;
  animation: bgFade 0.3s ease;
}

.bg-content[hidden] {
  display: none;
}

@keyframes bgFade {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== 移动端适配 ========== */
@media (max-width: 600px) {
  .main-nav {
    max-width: 100%;
  }
  .nav-btn {
    padding: 8px 14px;
    font-size: 0.9rem;
  }
  .section-title {
    font-size: 1.7rem;
  }
  .author-list {
    grid-template-columns: 1fr;
  }
  .author-name {
    font-size: 1.4rem;
  }
}
