/* ==========================================================================
   1. 首页背景设置 (严格区分亮色/暗色模式)
   ========================================================================== */

/* 1.0 全局默认：没有任何背景图 */
body {
  background-image: none;
}

/* 1.1 【仅在 亮色模式 + 首页】生效的背景配置 */
/* 注意选择器写法：body[data-md-color-scheme="default"] 表示只选中亮色模式的 body */
body[data-md-color-scheme="default"]:has(.hero-layout) {
  /* 请确认 assets/home-bg.png 路径正确 */
  background-image: url('https://lh-0124.github.io/LHstudy/assets/home-bg.png') !important;
  background-size: cover !important;
  background-attachment: fixed !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}

/* 1.2 【仅在 亮色模式 + 首页】内容区域透明化 */
/* 必须限定在 default 模式，否则暗色模式下也会变透明，导致看不清文字 */
body[data-md-color-scheme="default"]:has(.hero-layout) .md-main,
body[data-md-color-scheme="default"]:has(.hero-layout) .md-container,
body[data-md-color-scheme="default"]:has(.hero-layout) .md-content,
body[data-md-color-scheme="default"]:has(.hero-layout) .md-content__inner,
body[data-md-color-scheme="default"]:has(.hero-layout) .md-grid,
body[data-md-color-scheme="default"]:has(.hero-layout) article, 
body[data-md-color-scheme="default"]:has(.hero-layout) main {
  background-color: transparent !important;
  background: transparent !important;
  box-shadow: none !important;
}

/* 1.3 【仅在 暗色模式】强制移除背景 */
/* 即使是首页，只要切换到 slate 模式，就强制去掉背景图并恢复默认黑底 */
body[data-md-color-scheme="slate"] {
  background-image: none !important;
  background-color: var(--md-default-bg-color) !important;
}



/* ==========================================================================
   2. 首页布局结构 (Home Layout)
   ========================================================================== */
.hero-layout {
  display: flex;
  justify-content: center;
  /* align-items: center; 取消居中对齐，让两侧高度自然对齐 */
  gap: 50px;
  padding: 40px 0;
  max-width: 1200px;
  margin: 0 auto;
}

.left-column {
  flex: 0 0 480px; 
  display: flex;
  flex-direction: column;
  gap: 20px;
  /* 确保左侧有内容撑开高度 */
}

.right-column {
  flex: 1; 
  display: flex;
  /* justify-content: center; 删除对齐方式，让其填满 */
  flex-direction: column; /* 改为纵向布局，以适应四宫格的高度 */
}

/* 移动端适配 */
@media screen and (max-width: 960px) {
  .hero-layout {
    flex-direction: column-reverse;
    padding: 20px;
    gap: 30px;
  }
  .left-column { flex: auto; width: 100%; }
  /* 移动端右侧（图片栏）样式调整 */
  .right-column {
    width: 100%;
    height: auto; /* 移动端高度自适应 */
  }
  .image-grid {
    height: auto !important; /* 移动端网格高度自适应 */
    aspect-ratio: 1 / 1; /* 移动端保持正方形比例，或者根据需要调整 */
  }
}


/* ==========================================================================
   3. 卡片样式 (Cards)
   ========================================================================== */

/* --- 3.1 个人简介主卡片 --- */
.intro-card {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  padding: 25px;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  border: 1.5px solid var(--md-primary-fg-color); 
}

[data-md-color-scheme="slate"] .intro-card {
  background: var(--md-default-bg-color);
  border: 1px solid var(--md-default-fg-color--lightest);
}

.intro-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.intro-header h2 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--md-primary-fg-color);
}

.badge {
  background: var(--md-primary-fg-color);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
}

.slogan {
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--md-default-fg-color--light);
  margin-bottom: 15px;
  border-bottom: 1px solid rgba(0,0,0,0.1);
  padding-bottom: 10px;
}

.intro-text {
  font-size: 0.95rem;
  line-height: 1.6;
}

/* --- 3.2 社交卡片 --- */
.social-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.social-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.9);
  padding: 15px;
  border-radius: 12px;
  text-decoration: none !important;
  transition: all 0.2s ease;
  border: 1.5px solid var(--md-primary-fg-color);
}

.social-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 15px rgba(0,0,0,0.15);
  background: white; 
}

[data-md-color-scheme="slate"] .social-card {
  background: var(--md-default-bg-color);
  border: 1px solid var(--md-default-fg-color--lightest);
}

.social-card img, .social-card svg {
  width: 40px; height: 40px; border-radius: 8px;
}
.social-card svg { fill: #333; }
[data-md-color-scheme="slate"] .social-card svg { fill: #eee; }

.social-info { display: flex; flex-direction: column; }
.social-title { font-weight: bold; color: var(--md-default-fg-color); font-size: 0.9rem; }
.social-id { font-size: 0.8rem; color: var(--md-default-fg-color--light); }

/* --- 3.3 按钮组 --- */
.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.btn-grid .md-button {
  width: 100%;
  text-align: center;
  font-weight: bold;
  padding: 12px 0;
  border-radius: 8px;
  background: rgba(255,255,255,0.9); 
  border: 1.5px solid var(--md-primary-fg-color);
  color: var(--md-primary-fg-color);
}

.btn-grid .md-button--primary {
  background: var(--md-primary-fg-color);
  color: white;
}

[data-md-color-scheme="slate"] .btn-grid .md-button {
  background: transparent;
  border-color: var(--md-default-fg-color--lightest);
  color: var(--md-default-fg-color);
}
[data-md-color-scheme="slate"] .btn-grid .md-button:hover {
  border-color: var(--md-primary-fg-color);
  color: var(--md-primary-fg-color);
}

/* --- 3.4 右侧四宫格图片 --- */
.image-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 15px;
  
  /* 核心修复：强制宽高比为 1:1 (正方形)，防止被图片撑爆 */
  aspect-ratio: 1 / 1; 
  /* 限制最大高度，防止在大屏上过于巨大，大致匹配左侧内容高度 */
  max-height: 550px; 
  /* 宽度填满右侧列 */
  width: 100%;
  
  /* 居中放置，防止左侧内容较少时右侧太靠上 */
  margin: 0 auto;
}

.grid-item {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0,0,0,0.1);
  /* 移除 height: 100%，由 grid 自身比例控制 */
  width: 100%;
  height: 100%;
}

.grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* 关键：裁剪图片以填满格子，不拉伸变形 */
  display: block;
  transition: transform 0.3s ease;
}

.grid-item:hover img {
  transform: scale(1.05);
}

.img-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  text-align: center;
  padding: 10px;
  font-size: 0.95rem;
  font-weight: bold;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.grid-item:hover .img-caption {
  opacity: 1;
}

/* 移动端特殊处理：移除最大高度限制，允许自适应 */
@media screen and (max-width: 960px) {
  .image-grid {
    max-height: none; 
    /* 移动端保持正方形，或者改为 auto 随图片高度 */
    aspect-ratio: 1 / 1; 
  }
}

/* ==========================================================================
   4. 时间轴样式 (Timeline)
   ========================================================================== */

.timeline {
  position: relative;
  max-width: 800px;
  margin: 20px auto;
  padding-left: 20px;
}

/* 左侧竖线 */
.timeline::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 6px;
  width: 2px;
  background: #e0e0e0;
}

/* 每个时间节点 */
.timeline-item {
  position: relative;
  margin-bottom: 40px;
  padding-left: 30px;
}

/* 节点圆点 */
.timeline-item::before {
  content: '';
  position: absolute;
  left: 0; top: 5px;
  width: 14px; height: 14px;
  background: var(--md-primary-fg-color);
  border-radius: 50%;
  border: 3px solid var(--md-default-bg-color); /* 镂空效果 */
  z-index: 1;
}

.timeline-date {
  font-weight: bold;
  font-size: 0.9rem;
  color: var(--md-default-fg-color--light);
  margin-bottom: 5px;
}

.timeline-content {
  background: var(--md-default-bg-color);
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

[data-md-color-scheme="slate"] .timeline-content {
  border-color: #404040; /* 暗色模式边框 */
}

/* 标题和标签 */
.timeline-content h3 { margin-top: 0; margin-bottom: 0.5rem; font-size: 1.1rem; }
.tag {
  display: inline-block;
  background: var(--md-primary-fg-color--light);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  margin-top: 10px;
}