/* =====================
   知合设计博客 - 自定义样式
   基于 Tailwind CSS 扩展
   ===================== */

/* 基础字体 */
html { font-size: 16px; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif; }

/* ===== Hero 区域 ===== */
.hero-gradient {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* ===== 文章卡片 ===== */
.post-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.post-card:hover {
  transform: translateY(-4px);
}

.post-card .post-thumb {
  aspect-ratio: 16/10;
  object-fit: cover;
}

/* ===== Tag 标签 ===== */
.tag-pill {
  transition: all 0.2s;
}
.tag-pill:hover {
  background: #e0e7ff !important;
  transform: translateY(-1px);
}

/* ===== 文章正文 ===== */
.article-content {
  line-height: 1.9;
  color: #1e293b;
}
.article-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e2e8f0;
  color: #0f172a;
}
.article-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: #1e293b;
}
.article-content p {
  margin-bottom: 1.25rem;
}
.article-content p:last-child {
  margin-bottom: 0;
}
.article-content a {
  color: #6366f1;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.article-content a:hover {
  color: #4f46e5;
}
.article-content pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1.25rem;
  border-radius: 0.75rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.875rem;
  line-height: 1.7;
}
.article-content code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Menlo', monospace;
  font-size: 0.875em;
}
.article-content p > code {
  background: #f1f5f9;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.875em;
  color: #e11d48;
}
.article-content img {
  border-radius: 0.75rem;
  margin: 1.5rem auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.article-content blockquote {
  border-left: 4px solid #6366f1;
  background: #f8fafc;
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  border-radius: 0 0.5rem 0.5rem 0;
  color: #475569;
}
.article-content blockquote p {
  margin-bottom: 0;
}
.article-content ul,
.article-content ol {
  margin: 1rem 0;
  padding-left: 1.5rem;
}
.article-content li {
  margin-bottom: 0.5rem;
}
.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}
.article-content th,
.article-content td {
  border: 1px solid #e2e8f0;
  padding: 0.625rem 0.75rem;
  text-align: left;
}
.article-content th {
  background: #f8fafc;
  font-weight: 600;
}
/* ===== Markdown 内容补充样式 ===== */
.article-content h1 {
  margin: 1.8rem 0 1rem;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.4;
}
.article-content h4 {
  margin: 1.4rem 0 0.6rem;
  font-size: 1.05rem;
  font-weight: 600;
}
.article-content h5,
.article-content h6 {
  margin: 1.2rem 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
}
.article-content hr {
  margin: 2rem 0;
  border: none;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border-light, #e2e8f0), transparent);
}
.article-content strong {
  font-weight: 700;
}
.article-content em {
  font-style: italic;
}
.article-content ul {
  padding-left: 1.5rem;
  list-style: disc;
}
.article-content ol {
  padding-left: 1.5rem;
  list-style: decimal;
}
.article-content li {
  margin: 0.35rem 0;
  line-height: 1.7;
}
.article-content input[type="checkbox"] {
  margin-right: 0.4rem;
  accent-color: #6366f1;
}

/* ===== 侧边栏小部件 ===== */
.sidebar-widget {
  transition: all 0.2s;
}
.sidebar-widget:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}

/* ===== 分类列表 ===== */
.category-list a {
  transition: all 0.2s;
}
.category-list a:hover {
  color: #6366f1 !important;
  padding-left: 4px;
}

/* ===== 分页 ===== */
.pagination a,
.pagination span {
  transition: all 0.2s;
}
.pagination a:hover {
  background: #eef2ff;
  border-color: #6366f1;
  color: #6366f1;
}

/* ===== 搜索高亮 ===== */
.search-highlight {
  background: #fef3c7;
  padding: 0 2px;
  border-radius: 2px;
}

/* ===== 空状态 ===== */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.float-animation {
  animation: float 3s ease-in-out infinite;
}

/* ===== 图片懒加载淡入 ===== */
img.lazy {
  opacity: 0;
  transition: opacity 0.3s;
}
img.loaded {
  opacity: 1;
}

/* ===== 响应式侧边栏 ===== */
@media (max-width: 1023px) {
  .sidebar-sticky {
    position: static !important;
  }
}

/* ===== 文章头部封面 ===== */
.article-cover {
  max-height: 400px;
  object-fit: cover;
}

/* ===== 移动端导航 ===== */
.mobile-nav {
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}
.mobile-nav.open {
  transform: translateX(0);
}
.mobile-overlay {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.mobile-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* ===== 页脚 ===== */
.footer-link {
  transition: all 0.2s;
}
.footer-link:hover {
  color: #a5b4fc !important;
}

/* ===== 滚动条美化 ===== */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* =========================================
   移动端适配优化
   ========================================= */

/* 小设备 (≤480px) 额外内边距 */
@media (max-width: 480px) {
  .max-w-6xl {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
  main.max-w-6xl {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
  }
}

/* 文章图片移动端优化 */
@media (max-width: 640px) {
  img.h-52, img[class*="h-5"],
  article .h-52 {
    height: 11rem !important;
  }
  /* 详情页大图 */
  .h-64 {
    height: 14rem !important;
  }
  /* 文章卡片内边距 */
  .p-6 {
    padding: 1.25rem !important;
  }
  .p-8 {
    padding: 1.5rem !important;
  }
  /* 英雄区 */
  .hero-section {
    padding: 1.5rem !important;
  }
  .hero-section h1 {
    font-size: 1.75rem !important;
  }
}

/* 中等设备 (641-1023px) */
@media (min-width: 641px) and (max-width: 1023px) {
  img.h-52 {
    height: 14rem !important;
  }
}

/* 触控优化 - 增加按钮触控区域 */
@media (hover: none) and (pointer: coarse) {
  a, button, .btn-like {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  .p-3 { padding: 0.875rem !important; }
}

/* 文章内页内容排版移动端优化 */
@media (max-width: 768px) {
  .article-content {
    font-size: 0.95rem;
    line-height: 1.75;
  }
}

/* 禁用高缩放字体设置 (iOS fix) */
* {
  -webkit-text-size-adjust: 100%;
}

/* toast 移动端适配 */
@media (max-width: 640px) {
  .toast {
    left: 1rem !important;
    right: 1rem !important;
    top: 1rem !important;
    z-index: 9999;
    font-size: 0.8rem;
  }
}

/* 分页链接移动端优化 */
@media (max-width: 640px) {
  .pagination a, .pagination span {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.75rem !important;
  }
}

/* 英雄区移动端压缩 */
@media (max-width: 480px) {
  .relative.overflow-hidden.rounded-2xl {
    padding: 1.25rem !important;
    margin-bottom: 1.5rem !important;
  }
  .relative.overflow-hidden.rounded-2xl h1 {
    font-size: 1.5rem !important;
  }
  .relative.overflow-hidden.rounded-2xl p {
    font-size: 0.8125rem !important;
  }
}

/* 移动端汉堡菜单用户区 */
#mobileMenu .flex.justify-between {
  padding: 0.375rem 0.25rem;
}

/* 侧边栏移动端间距 */
@media (max-width: 1023px) {
  aside.lg-w-72 {
    margin-top: 0.5rem;
  }
}

/* 评论表单移动端 */
@media (max-width: 480px) {
  #commentForm .flex.items-center.gap-3 {
    flex-direction: column;
    gap: 0.5rem;
  }
  #commentForm .flex.items-center.gap-3 input {
    width: 100%;
  }
}

/* 上一篇/下一篇移动端 */
@media (max-width: 480px) {
  .flex-col.sm-flex-row {
    gap: 0.5rem;
  }
}
