/* =========================================================
   pages.css — 各页面专属样式
   包含：Hero、技能卡片、数据统计、页面标题、项目、博客、
         留言板、表单与错误提示
   ========================================================= */

/* =========================================================
   一、首页 —— Hero 区域
   ========================================================= */
.hero {
  padding: 72px 0 56px;
  background: linear-gradient(135deg, var(--bg-alt) 0%, var(--bg) 100%);
}

.hero-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
}

.hero-text {
  flex: 1 1 480px;
}

.hero-hello {
  color: var(--text-muted);
  font-size: 1.05rem;
}

.hero-name {
  margin: 4px 0 8px;
  font-size: clamp(2.2rem, 6vw, 3.2rem);
  line-height: 1.2;
  letter-spacing: -1px;
  color: var(--primary);
}

.hero-role {
  margin-bottom: 16px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
}

.hero-desc {
  max-width: 46ch;
  margin-bottom: 16px;
  color: var(--text-muted);
}

.hero-typing {
  min-height: 1.8em;
  margin-bottom: 26px;
  font-size: 1.05rem;
  color: var(--text-muted);
}

.typed {
  font-weight: 700;
  color: var(--text);
}

/* 打字机光标闪烁 */
.cursor {
  display: inline-block;
  margin-left: 2px;
  font-weight: 700;
  color: var(--primary);
  animation: blink 1s step-end infinite;
}

.hero-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.hero-avatar {
  flex: 0 0 auto;
  animation: float 5s ease-in-out infinite;
  filter: drop-shadow(0 18px 30px rgba(99, 102, 241, 0.28));
}

/* =========================================================
   二、通用区块与标题
   ========================================================= */
.section {
  padding: 56px 0;
}

.section-alt {
  background-color: var(--bg-alt);
}

.section-title {
  position: relative;
  margin-bottom: 8px;
  font-size: 1.8rem;
  letter-spacing: -0.5px;
}

/* 标题下方的小装饰条 */
.section-title::after {
  content: "";
  display: block;
  width: 56px;
  height: 4px;
  margin-top: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.section-subtitle {
  margin-bottom: 32px;
  color: var(--text-muted);
}

/* =========================================================
   三、技能卡片
   ========================================================= */
.skill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.skill-card {
  text-align: left;
}

/* hover 上浮 + 阴影加深 */
.skill-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.skill-icon {
  font-size: 1.8rem;
  line-height: 1;
  margin-bottom: 12px;
}

.skill-name {
  margin-bottom: 8px;
  font-size: 1.15rem;
}

.skill-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
}

/* =========================================================
   四、数据统计
   ========================================================= */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 20px;
  text-align: center;
}

.stat-item strong {
  display: block;
  font-size: 2.2rem;
  line-height: 1.2;
  color: var(--primary);
}

.stat-item span {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* =========================================================
   五、项目展示页
   ========================================================= */
.page-header {
  margin-bottom: 28px;
}

/* 分类筛选按钮栏 */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 28px;
}

.filter-btn {
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background-color: var(--card-bg);
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 500;
  transition: color var(--transition), background-color var(--transition),
    border-color var(--transition), transform var(--transition);
}

.filter-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.filter-btn.active {
  background-color: var(--primary-solid);
  border-color: var(--primary-solid);
  color: var(--on-primary);
}

/* 项目卡片网格：自适应列数 */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 22px;
}

.project-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.project-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.project-title {
  font-size: 1.15rem;
}

.project-desc {
  flex: 1 1 auto;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.project-link {
  margin-top: 4px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  transition: color var(--transition), transform var(--transition);
}

.project-link:hover {
  color: var(--primary-dark);
}

/* 空结果提示 */
.empty-tip {
  padding: 32px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  color: var(--text-muted);
}

/* =========================================================
   六、博客页
   ========================================================= */
/* 仅在视觉上隐藏，仍对屏幕阅读器可见 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.search-bar {
  position: relative;
  max-width: 520px;
  margin-bottom: 28px;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 16px;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background-color: var(--card-bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:hover {
  border-color: var(--primary);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.post-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.post-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.post-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.post-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.post-title {
  font-size: 1.2rem;
}

.post-date {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.post-summary {
  font-size: 0.94rem;
  color: var(--text-muted);
}

.post-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.post-link {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  transition: color var(--transition);
}

.post-link:hover {
  color: var(--primary-dark);
}

/* =========================================================
   七、表单通用样式（留言板与联系页共用）
   ========================================================= */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

.form-row label {
  font-size: 0.92rem;
  font-weight: 600;
}

.form-row input,
.form-row textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-row input::placeholder,
.form-row textarea::placeholder {
  color: var(--text-muted);
}

.form-row input:hover,
.form-row textarea:hover {
  border-color: var(--primary);
}

.form-row input:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

/* 校验失败时的输入框样式 */
.form-row input.invalid,
.form-row textarea.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* 错误提示：默认占位但不影响布局稳定性 */
.error-msg {
  min-height: 1.2em;
  font-size: 0.82rem;
  /* 使用变量以适配暗色背景下的对比度 */
  color: var(--danger);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* =========================================================
   八、留言板
   ========================================================= */
.guestbook-form {
  margin-bottom: 36px;
}

.list-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  font-size: 1.25rem;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background-color: var(--primary-solid);
  color: var(--on-primary);
  font-size: 0.8rem;
  font-weight: 600;
}

.guest-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.guest-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guest-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.guest-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-right: 56px;
}

.guest-name {
  color: var(--primary);
}

.guest-time {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.guest-body {
  font-size: 0.94rem;
  color: var(--text-muted);
  /* 保留用户输入的换行，同时防止超长字符串撑破卡片 */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.guest-delete {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background-color: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  transition: color var(--transition), border-color var(--transition), background-color var(--transition);
}

/* 固定使用较深的红色，白字在任何主题下都能达到 AA 对比度 */
.guest-delete:hover {
  color: #ffffff;
  background-color: #dc2626;
  border-color: #dc2626;
}

/* =========================================================
   九、联系页
   ========================================================= */
.contact-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  /* 不使用 align-items: start —— 那会让左侧 aside 高度等于卡片高度，
     内部 sticky 卡片失去可滚动行程而失效。默认 stretch 才能吸顶。 */
}

.required {
  color: var(--danger);
}

.info-card {
  position: sticky;
  top: calc(var(--nav-h) + 20px);
}

.info-title {
  margin-bottom: 16px;
  font-size: 1.15rem;
}

.info-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.info-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.94rem;
  color: var(--text-muted);
}

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

.info-note {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.contact-form {
  display: block;
}

/* 校验通过后的成功提示 */
.success-msg {
  margin-top: 18px;
  padding: 14px 18px;
  border: 1px solid #10b981;
  border-radius: 8px;
  background-color: rgba(16, 185, 129, 0.1);
  color: #10b981;
  font-size: 0.94rem;
  font-weight: 500;
  animation: fadeInUp 0.4s ease both;
}

/* =========================================================
   十、响应式
   ========================================================= */
@media (max-width: 768px) {
  .hero {
    padding: 48px 0 40px;
  }

  .hero-inner {
    flex-direction: column-reverse;
    text-align: center;
  }

  /* 主轴翻转为垂直后，flex-basis:480px 会变成高度，
     使 hero 底部多出约 150px 空白，这里改回按内容自适应 */
  .hero-text {
    flex-basis: auto;
  }

  .hero-desc {
    margin-left: auto;
    margin-right: auto;
  }

  .hero-buttons {
    justify-content: center;
  }

  /* 移动端各页区块标题居中，卡片内部文字仍保持左对齐 */
  .section-title,
  .section-subtitle {
    text-align: center;
  }

  .section-title::after {
    margin-left: auto;
    margin-right: auto;
  }

  .search-bar {
    max-width: none;
    margin-left: auto;
    margin-right: auto;
  }

  .filter-bar {
    justify-content: center;
  }

  /* 联系页在平板及以下改为单列，信息卡片不再吸顶 */
  .contact-layout {
    grid-template-columns: 1fr;
  }

  .info-card {
    position: static;
  }
}

@media (max-width: 480px) {
  .hero-avatar svg {
    width: 170px;
    height: 170px;
  }

  /* 小屏下所有卡片网格退化为单列 */
  .skill-grid,
  .project-grid,
  .guest-list {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column;
  }

  .post-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}
