/* static/css/main.css — Carrot Space 风格（亮色三栏布局） */

::view-transition-old(root) { animation: none; z-index: -1; }
::view-transition-new(root) { animation: none; z-index:  1; }

:root {
  --bg:           #ffffff;
  --bg-soft:      #f8f9fb;
  --surface:      #ffffff;
  --border:       #e8eaed;
  --text:         #1a1a2e;
  --text-muted:   #6c757d;
  --text-light:   #9e9e9e;
  --primary:      #4051b5;
  --primary-soft: #e8eaf6;
  --primary-dark: #303f9f;
  --success:      #2e7d32;
  --danger:       #c62828;
  --warning:      #f57f17;
  --code-bg:      #f5f7f9;
  --heading:      #214FA8;
  --radius:       6px;
  --left-w:       240px;
  --right-w:      200px;
  --header-h:     60px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.08);
}

html[data-theme="dark"] {
  --bg:           #0d1117;
  --bg-soft:      #161b22;
  --surface:      #0d1117;
  --border:       #30363d;
  --text:         #e6edf3;
  --text-muted:   #8b949e;
  --text-light:   #6e7681;
  --primary:      #79c0ff;
  --primary-soft: #0d2744;
  --primary-dark: #a5d6ff;
  --success:      #3fb950;
  --danger:       #f85149;
  --warning:      #d29922;
  --code-bg:      #161b22;
  --heading:      #6AB0FF;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.4);
}

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

html { font-size: 18px; }

body {
  background: var(--surface);
  color: var(--text);
  font: 1.1rem/1.75 -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
        'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }

/* ══════════════════════════════════════════════
   Header
══════════════════════════════════════════════ */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 200;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 24px;
}

.holiday-badge {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; flex-shrink: 0;
  padding: 4px 10px 4px 4px;
  border-radius: 14px;
  transition: background .2s;
  cursor: pointer;
}
.holiday-badge:hover { background: var(--primary-soft); text-decoration: none; }

.hb-emoji {
  font-size: 1.8rem; line-height: 1;
  display: inline-block;
  animation: hb-wobble 2.4s ease-in-out infinite;
  transform-origin: bottom center;
}
@keyframes hb-wobble {
  0%,100% { transform: rotate(-8deg); }
  50%      { transform: rotate(8deg); }
}

.hb-body  { display: flex; flex-direction: column; line-height: 1.2; }
.hb-top   { display: flex; align-items: baseline; gap: 2px; }
.hb-num   {
  font-size: 1.45rem; font-weight: 900; letter-spacing: -.03em;
  background: var(--hb-grad, linear-gradient(135deg,#ff9a56,#ff6b35));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hb-unit  { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); }
.hb-name  { font-size: 0.68rem; color: var(--text-muted); letter-spacing: .04em; }

/* 顶部分类导航 */
.top-nav {
  display: flex; align-items: center; gap: 4px;
  margin: 0 24px; flex: 1;
}
.top-nav-item {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
}
.top-nav-item:hover {
  color: var(--primary);
  background: var(--primary-soft);
  text-decoration: none;
}
.top-nav-item.active {
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 600;
}

.header-right {
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
}

.header-search {
  display: flex; align-items: center;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 20px; overflow: hidden;
  transition: border-color .15s;
}
.header-search:focus-within { border-color: var(--primary); }
.search-input {
  border: none; outline: none; background: transparent;
  padding: 5px 12px; font-size: 0.85rem; font-family: inherit;
  color: var(--text); width: 160px;
}
.search-btn {
  border: none; background: transparent; cursor: pointer;
  padding: 5px 10px; font-size: 0.85rem; color: var(--text-muted);
  transition: color .15s;
}
.search-btn:hover { color: var(--primary); }
.header-link {
  font-size: 0.875rem; color: var(--text-muted);
  text-decoration: none; padding: 4px 8px;
}
.header-link:hover { color: var(--primary); text-decoration: none; }

.btn-admin {
  background: var(--primary); color: #fff !important;
  padding: 5px 14px; border-radius: 20px;
  font-size: 0.85rem; font-weight: 500;
  text-decoration: none;
}
.btn-admin:hover {
  background: var(--primary-dark);
  text-decoration: none; color: #fff !important;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: var(--radius);
  line-height: 1;
  transition: border-color .15s, color .15s;
}
.theme-toggle:hover { border-color: var(--primary); color: var(--primary); }

/* ══════════════════════════════════════════════
   三栏主布局
══════════════════════════════════════════════ */
.page-layout {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--left-w) 1fr var(--right-w);
  gap: 0;
  min-height: calc(100vh - var(--header-h) - 56px);
  align-items: start;
}

/* ── 左侧导航栏 ── */
.left-sidebar {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 24px 0 24px 16px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

/* 自定义滚动条（左侧栏） */
.left-sidebar::-webkit-scrollbar { width: 4px; }
.left-sidebar::-webkit-scrollbar-track { background: transparent; }
.left-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── 导航分组 ── */
.nav-section { margin-bottom: 20px; }

.nav-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 0 12px 8px;
  margin-bottom: 4px;
}

.nav-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  color: #e879a0;
}

.nav-group-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-item-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.nav-section-title.active-cat {
  color: var(--primary);
}

.nav-group-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius) 0 0 var(--radius);
  transition: all .15s;
}
.nav-group-title:hover {
  color: var(--primary);
  background: var(--primary-soft);
  text-decoration: none;
}

.nav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  font-size: 0.875rem;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius) 0 0 var(--radius);
  transition: all .15s;
  line-height: 1.4;
}
.nav-item:hover {
  color: var(--primary);
  background: var(--primary-soft);
  text-decoration: none;
}
.nav-item.active {
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 600;
  border-left: 3px solid var(--primary);
  padding-left: 9px;
}

.nav-arrow {
  font-size: 1rem;
  color: var(--text-light);
  flex-shrink: 0;
  margin-left: 4px;
}
.nav-item.active .nav-arrow,
.nav-item:hover .nav-arrow { color: var(--primary); }

.nav-count {
  background: var(--bg-soft);
  color: var(--text-light);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 0.75rem;
  flex-shrink: 0;
  margin-left: 4px;
}

.nav-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 0 8px;
}

.nav-empty { padding: 8px 12px; font-size: 0.85rem; color: var(--text-light); }

/* ── 主内容区 ── */
.main-content {
  min-width: 0;
  padding: 28px 32px;
  background: var(--bg);
}

/* ── 右侧 TOC ── */
.right-sidebar {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 24px 16px 24px 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
}
.right-sidebar::-webkit-scrollbar { width: 4px; }
.right-sidebar::-webkit-scrollbar-track { background: transparent; }
.right-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.toc-widget { padding: 0 12px; }

.toc-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

#toc-content { margin-left: 4px; }

/* 每个条目用 box-shadow 拼出连续竖线 */
.toc-item {
  position: relative;
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: none;
  line-height: 1.5;
  margin-bottom: 0;
  transition: color .15s, box-shadow .15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: inset 1.5px 0 0 0 var(--border);
}

/* 短横 tick */
.toc-item::before {
  content: '';
  position: absolute;
  top: 50%;
  height: 1.5px;
  width: 8px;
  background: var(--border);
  transform: translateY(-50%);
  transition: background .15s;
}

.toc-item:hover {
  color: var(--primary);
  text-decoration: none;
  box-shadow: inset 2px 0 0 0 var(--primary);
}
.toc-item:hover::before { background: var(--primary); }

.toc-item.active {
  color: var(--heading);
  font-weight: 600;
  box-shadow: inset 2px 0 0 0 var(--heading);
}
.toc-item.active::before { background: var(--heading); }

/* H1 — tick 紧靠竖线 */
.toc-h1 { padding: 5px 4px 5px 14px; font-weight: 600; font-size: 0.83rem; }
.toc-h1::before { left: 0; }

/* H2 — tick 缩进一级 */
.toc-h2 { padding: 4px 4px 4px 26px; }
.toc-h2::before { left: 12px; }

/* H3 — tick 缩进二级 */
.toc-h3 { padding: 4px 4px 4px 36px; font-size: 0.78rem; }
.toc-h3::before { left: 22px; }

/* ══════════════════════════════════════════════
   文章卡片（列表页）
══════════════════════════════════════════════ */
.post-list { }

.post-card {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow .2s, border-color .2s, transform .15s;
}
.post-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 20px rgba(64,81,181,.12);
  transform: translateY(-1px);
}

.post-card-body {
  flex: 1;
  padding: 24px 28px;
  min-width: 0;
}

.post-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0;
  line-height: 1.4;
}
.post-card-title a { color: var(--text); text-decoration: none; }
.post-card-title a:hover { color: var(--primary); }

.post-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.post-title-row .btn-edit {
  flex-shrink: 0;
}

.post-meta {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--text-muted)
}
.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
}
.meta-item a { color: var(--text-muted); text-decoration: none; }
.meta-item a:hover { color: var(--primary); text-decoration: underline; }
.meta-icon { width: 14px; height: 14px; flex-shrink: 0; color: #e879a0; }
.tag-sep { color: var(--border); }
.meta-tag-link { font-style: italic; }

.post-card-preview {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 400;
  margin-top: 8px;
  line-height: 1.5;
}

.post-card-cover {
  width: 220px;
  flex-shrink: 0;
}
.post-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.post-card-arrow {
  width: 48px;
  flex-shrink: 0;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.5rem;
  opacity: 0.7;
  transition: opacity .2s;
  user-select: none;
}
.post-card:hover .post-card-arrow { opacity: 1; }

/* 兼容旧页面 */
.post-card h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: 8px; }
.post-card h2 a { color: var(--text); text-decoration: none; }
.post-card h2 a:hover { color: var(--primary); }
.post-category {
  background: var(--primary-soft); color: var(--primary);
  padding: 2px 10px; border-radius: 12px;
  font-size: 0.75rem; font-weight: 600; text-decoration: none;
}
.post-category:hover { background: var(--primary); color: #fff; text-decoration: none; }
.post-summary {
  color: var(--text-muted); font-size: 0.875rem; line-height: 1.65;
  display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
}
.post-tags-inline { margin-top: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.read-more { display: inline-block; margin-top: 14px; font-size: 0.85rem; color: var(--primary); font-weight: 500; }
.read-more:hover { text-decoration: none; color: var(--primary-dark); }

/* 空状态 */
.empty-state {
  text-align: center; padding: 80px 20px; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state p { margin-bottom: 8px; }

/* ══════════════════════════════════════════════
   页面标题
══════════════════════════════════════════════ */
.page-header { margin-bottom: 24px; }
.page-header h1 {
  font-size: 1.4rem; font-weight: 700; color: var(--text);
}
.page-header .breadcrumb {
  font-size: 0.85rem; color: var(--text-muted); margin-top: 4px;
}

/* ══════════════════════════════════════════════
   标签
══════════════════════════════════════════════ */
.tag-item {
  background: var(--code-bg);
  color: var(--text-muted);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-style: italic;
  text-decoration: none;
  border: 1px solid var(--border);
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tag-count {
  font-size: 0.7rem;
  background: var(--border);
  color: var(--text-light);
  border-radius: 8px;
  padding: 0 5px;
  line-height: 1.6;
}
.tag-item:hover .tag-count {
  background: var(--primary);
  color: #fff;
}
.tag-item:hover {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
  text-decoration: none;
}

/* ══════════════════════════════════════════════
   Alert
══════════════════════════════════════════════ */
.alert {
  padding: 10px 16px; border-radius: var(--radius);
  margin-bottom: 14px; font-size: 0.9rem;
  border-left: 4px solid;
}
.alert-success { background: #e8f5e9; border-color: #2e7d32; color: #1b5e20; }
.alert-danger  { background: #ffebee; border-color: #c62828; color: #b71c1c; }
.alert-warning { background: #fff8e1; border-color: #f57f17; color: #e65100; }
.alert-info    { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); }

/* ══════════════════════════════════════════════
   分页
══════════════════════════════════════════════ */
.pagination {
  display: flex; gap: 6px; margin-top: 28px; justify-content: center;
  flex-wrap: wrap;
}
.pagination a,
.pagination span {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: all .15s;
  text-decoration: none;
}
.pagination a:hover {
  border-color: var(--primary); color: var(--primary);
  text-decoration: none; background: var(--primary-soft);
}
.pagination .current {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

/* ══════════════════════════════════════════════
   按钮通用
══════════════════════════════════════════════ */
.btn {
  display: inline-block; padding: 8px 20px;
  border-radius: var(--radius); font-size: 0.875rem;
  cursor: pointer; border: 1px solid transparent;
  text-decoration: none; font-family: inherit;
  font-weight: 500; transition: all .15s;
  line-height: 1.4;
}
.btn-primary {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-dark); border-color: var(--primary-dark);
  text-decoration: none; color: #fff;
}
.btn-secondary {
  background: var(--surface); color: var(--text-muted);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--bg-soft); color: var(--text);
  text-decoration: none;
}
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b71c1c; text-decoration: none; color: #fff; }
.btn-sm { padding: 4px 12px; font-size: 0.8rem; }

/* ══════════════════════════════════════════════
   Footer
══════════════════════════════════════════════ */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 18px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  background: var(--surface);
  display: flex;
  justify-content: center;
  gap: 10px;
  align-items: center;
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--primary); text-decoration: none; }

/* ── 回到顶部按钮 ── */
.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 224px;
  z-index: 300;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: #e91e63;
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.back-to-top:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ══════════════════════════════════════════════
   响应式
══════════════════════════════════════════════ */
@media (max-width: 1100px) {
  :root { --right-w: 0px; }
  .page-layout {
    grid-template-columns: var(--left-w) 1fr;
  }
  .right-sidebar { display: none; }
}

@media (max-width: 768px) {
  .page-layout {
    grid-template-columns: 1fr;
  }
  .left-sidebar {
    display: none;
  }
  .main-content { padding: 16px; }
  .top-nav { display: none; }
  .header-inner { padding: 0 16px; }
}
