/* ===== 蔡梓溢的生活随笔 - 主样式表 ===== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  /* 锚点跳转时给 sticky 顶栏（56px）留出偏移，避免标题被遮挡 */
  scroll-padding-top: 72px;
  /* 全站黑白（致哀用）：移除本行即可恢复彩色 */
  filter: grayscale(100%);
}

body {
  background-color: #fefff5;
  color: #333;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC",
               "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 70px;
}

/* 全局链接：统一为棕色，保留下划线 */
a {
  color: #8b7355;
  text-decoration: underline;
}

a:visited {
  color: #8b7355;
}

a:hover {
  color: #4a3f2b;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: #fefff5;
  border-bottom: 1px solid #e8e4d8;
  padding: 0 2rem;
  height: 56px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.site-header .site-title {
  font-family: "SimSun", "宋体", "Noto Serif CJK SC", serif;
  font-size: 1.3rem;
  font-weight: bold;
  color: #4a3f2b;
  text-decoration: none;
  letter-spacing: 2px;
  justify-self: start;
}

.site-header .site-nav {
  justify-self: center;
}

.main-container {
  width: 100%;
  max-width: 720px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  flex: 1;
  display: flex;
  gap: 2rem;
}

.content-main {
  flex: 1;
  min-width: 0;
}

.content-sidebar {
  width: 240px;
  flex-shrink: 0;
}

.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background-color: #4a3f2b;
  color: #ccc;
  font-size: 0.8rem;
  text-align: center;
  padding: 12px 1rem;
  line-height: 1.6;
}

.site-footer a {
  color: #c4b896;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.post-list {
  list-style: none;
}

.post-list-item {
  padding: 1.5rem 0;
  border-bottom: 1px solid #e8e4d8;
}

.post-list-item:first-child {
  padding-top: 0;
}

.post-list-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.post-list-title a {
  color: #4a3f2b;
  text-decoration: none;
}

.post-list-title a:hover {
  color: #8b7355;
}

.post-list-date {
  font-size: 0.85rem;
  color: #999;
  margin-bottom: 0.5rem;
}

.post-list-excerpt {
  font-size: 0.95rem;
  color: #666;
  line-height: 1.7;
}

.blog-post {
  max-width: 720px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.blog-post h1 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
  color: #4a3f2b;
}

.blog-post .post-meta {
  color: #999;
  font-size: 0.9rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e8e4d8;
}

.blog-post .post-content h2 {
  font-size: 1.4rem;
  margin-top: 2rem;
  margin-bottom: 0.8rem;
  color: #4a3f2b;
}

.blog-post .post-content h3 {
  font-size: 1.15rem;
  margin-top: 1.5rem;
  margin-bottom: 0.6rem;
}

.blog-post .post-content p {
  margin-bottom: 1rem;
}

.blog-post .post-content blockquote {
  border-left: 4px solid #c4b896;
  padding-left: 1rem;
  color: #666;
  margin: 1rem 0;
}

.blog-post .post-content pre {
  background-color: #4a3f2b;
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
  margin: 1rem 0;
}

.blog-post .post-content code {
  background-color: #f5f2e8;
  padding: 0.15em 0.4em;
  border-radius: 3px;
  font-size: 0.9em;
}

.blog-post .post-content pre code {
  background: none;
  padding: 0;
}

.blog-post .post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.blog-post .post-content ul,
.blog-post .post-content ol {
  margin: 0.5rem 0 1rem 1.5rem;
}



@media (max-width: 600px) {
  .main-container {
    padding: 0 1rem;
  }
  .site-header {
    padding: 0 1rem;
  }
  .site-header .site-title {
    font-size: 1.1rem;
  }
  .site-footer {
    font-size: 0.7rem;
    padding: 8px 0.5rem;
  }
}

@media print {
  body {
    padding-bottom: 0;
  }
  .site-footer {
    position: static;
  }
}

/* ===== 侧栏日历 ===== */

.sidebar-card {
  background: #f8f6ee;
  border: 1px solid #e8e4d8;
  border-radius: 8px;
  padding: 0.9rem 0.7rem;
  margin-bottom: 1rem;
}

.sidebar-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #4a3f2b;
  margin-bottom: 0.5rem;
  text-align: center;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.cal-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #4a3f2b;
  white-space: nowrap;
}

.cal-btn {
  background: #f0ede3;
  border: 1px solid #ddd8cb;
  border-radius: 4px;
  color: #4a3f2b;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 3px 8px;
  transition: background 0.15s, color 0.15s;
}

.cal-btn:hover {
  background: #4a3f2b;
  color: #fefff5;
  border-color: #4a3f2b;
}

.cal-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fcfaf4;
  border: 1px solid #e8e4d8;
  border-radius: 6px;
}

.cal-table th {
  font-size: 0.7rem;
  font-weight: 500;
  color: #999;
  text-align: center;
  padding: 3px 0;
  border-bottom: 1px solid #e8e4d8;
}

.cal-table td {
  text-align: center;
  vertical-align: middle;
  padding: 2px 0;
}

.cal-empty {
  visibility: hidden;
}

.cal-day {
  position: relative;
  line-height: 1;
  padding: 3px 0;
}

.cal-day-num {
  display: block;
  font-size: 0.82rem;
  color: #333;
  line-height: 1.5;
}

.cal-has-post .cal-day-num {
  color: #4a3f2b;
  font-weight: 600;
}

.cal-today .cal-day-num {
  background: #4a3f2b;
  color: #fefff5;
  border-radius: 50%;
  width: 1.4em;
  margin: 0 auto;
}

.cal-dot {
  display: block;
  width: 5px;
  height: 5px;
  margin: 1px auto 0;
  background: #81c784;
  border-radius: 50%;
}

/* ===== 月份导航行 ===== */

.month-nav {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid #e8e4d8;
}

.month-nav-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #4a3f2b;
  min-width: 7em;
  text-align: center;
}

.month-nav .cal-btn {
  padding: 4px 10px;
  font-size: 0.9rem;
}

/* ===== 无博文提示 ===== */

.no-posts {
  text-align: center;
  padding: 3rem 0;
  color: #999;
  font-size: 1.1rem;
}


@media (max-width: 960px) {
  .content-sidebar {
    display: none;
  }
  .month-nav {
    display: flex;
  }
}

/* ===== 顶栏导航 ===== */

.site-nav {
  display: flex;
  gap: 1.2rem;
  align-items: center;
}

.site-nav a {
  color: #8b7355;
  text-decoration: none;
  font-size: 0.95rem;
  white-space: nowrap;
  transition: color 0.15s;
}

.site-nav a:hover,
.site-nav a.active {
  color: #4a3f2b;
  font-weight: 600;
}

/* ===== 搜索框 ===== */

.search-box {
  position: relative;
  justify-self: end;
}

#searchInput {
  width: 140px;
  padding: 5px 10px;
  border: 1px solid #ddd8cb;
  border-radius: 4px;
  background: #f8f6ee;
  color: #333;
  font-size: 0.85rem;
  outline: none;
  transition: width 0.2s, border-color 0.2s;
}

#searchInput:focus {
  width: 200px;
  border-color: #c4b896;
  background: #fefff5;
}

#searchInput::placeholder {
  color: #bbb;
}

.search-results {
  position: absolute;
  top: 100%;
  right: 0;
  width: 300px;
  max-height: 400px;
  overflow-y: auto;
  background: #fefff5;
  border: 1px solid #e8e4d8;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  margin-top: 4px;
  z-index: 200;
}

.search-result-item {
  display: block;
  padding: 10px 12px;
  border-bottom: 1px solid #f0ede3;
  text-decoration: none;
  color: #333;
  transition: background 0.1s;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: #f8f6ee;
}

.search-result-title {
  font-size: 0.95rem;
  color: #4a3f2b;
}

@media (max-width: 700px) {
  .site-header {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    height: auto;
    padding: 8px 1rem;
    gap: 6px;
  }
  .site-header .site-title {
    grid-column: 1;
    grid-row: 1;
    font-size: 1.1rem;
  }
  .site-nav {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    gap: 0.8rem;
  }
  .site-nav a {
    font-size: 0.82rem;
  }
  .search-box {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }
  #searchInput {
    width: 100%;
  }
  #searchInput:focus {
    width: 100%;
  }
  .search-results {
    width: 100%;
    right: auto;
    left: 0;
  }
}