/* layout.css - 博客主页布局样式 */

/* 基础重置与全局样式 */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: url("../assets/bg.webp") center/cover fixed no-repeat;
  background-color: #f3f8ff; /* 柔光底色，防止加载瞬间白屏 */
  color: #333;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
  padding-top: 60px;
}


/* 夜间模式：保留白天壁纸 */
body.dark-mode {
  background: url("../assets/bg.webp") center/cover fixed no-repeat, #0f0f0f;
  color: #ddd;
  transition: background 0.4s ease, color 0.4s ease;
}



/* 链接样式 */
a { color: #3498db; text-decoration: none; transition: color 0.3s ease; }
a:hover, a:focus { color: #2980b9; outline: none; }

/* 标题与段落 */
h1,h2,h3,h4,h5,h6 { margin-top:0; margin-bottom:0.5em; font-weight:600; color: inherit; }
p { line-height:1.6; margin:0 0 1em 0; }

/* 图片自适应 */
img { max-width:100%; display:block; height:auto; }

/* 输入控件继承字体 */
button, input, select, textarea { font-family: inherit; font-size: 1rem; }

/* 导航按钮 */
.nav-button {
  cursor:pointer;
  user-select:none;
  padding:0.5rem;
  margin-left:0.5rem;
  border-radius:8px;
  color:#666;
  transition: background-color 0.2s ease,color 0.2s ease;
}
.nav-button:hover { background-color:#ddd; color:#333; }
body.dark-mode .nav-button { color:#bbb; }
body.dark-mode .nav-button:hover { background-color:#333; color:#eee; }

/* ===== 精确列宽布局（Grid 版） ===== */

/* 主布局容器 */
.layout {
  display: grid;
  grid-template-columns: 1fr 340px; /* 左主内容自适应，右侧栏固定340px */
  column-gap: 48px;                /* 两栏间距更宽，让右栏更靠右 */
  padding: 0 60px 0 40px;          /* 左40px，右60px，右栏更贴右侧 */
  margin: 0 auto;
  max-width: 1440px;               /* 稍加宽，主栏更舒展 */
  width: 100%;
  align-items: start;
  min-height: calc(100vh - 60px);
  box-sizing: border-box;
  margin-top: 80px;
}

/* 左侧主内容区 */
.main-content {
  grid-column: 1 / 2;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

/* 行内容布局（保持原样） */
.main-content-row {
  display: flex;
  flex-direction: row;
  gap: 24px;
}

.main-content-row > .card-grid {
  flex: 1 1 0;
  min-width: 0;
}

/* 文章列表容器 */
.grid-container, .recent-posts {
  display:flex;
  flex-direction:column;
  gap:15px;
  width:100%;
}

.recent-post-item, .card-grid > .card {
  width:100%;
  display:flex;
  flex-direction:row;
  gap:16px;
}

.post_cover { flex:0 0 150px; }

.recent-post-info {
  flex:1 1 auto;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
}

/* 右侧侧边栏 */
.sidebar {
  grid-column: 2 / 3;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-self: start;
}

/* 响应式布局 ≤ 900px */
@media (max-width:900px) {
  .layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 0 12px;
    min-height: auto;
  }
  .main-content, .sidebar {
    width: 100%;
    min-width: 0;
  }
  .main-content { order: 1; }
  .sidebar { order: 2; }
}

/* 移动端侧栏卡片更紧凑 */
@media (max-width:600px) {
  .sidebar { gap:12px; }
  .card,.neumorphic,.weather-widget,.author-card {
    padding:12px !important;
    border-radius:10px !important;
  }
}

/* 文章卡片擦亮效果 */
#articles-list > .recent-post-item:not(a)::before {
  content:"";
  position:absolute;
  top:0;
  left:0;
  width:100%;
  height:200%;
  background:linear-gradient(to right, transparent, white, transparent);
  transform:translateX(-200%);
  transition: transform 0.5s linear;
  z-index:1;
}
#articles-list > .recent-post-item:not(a):hover::before {
  transform:translateX(100%) skewX(-60deg);
}

/* 响应式字体 */
@media (max-width:900px) { body{ font-size:15px; } }
@media (max-width:768px) { body{ font-size:15px; } }
@media (max-width:600px) { body{ font-size:14px; } }
