/**
 * Doc MDUI - 文档内容样式
 *
 * @package Doc MDUI
 */

/* ========== 文档页头 ========== */
.post-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgb(var(--mdui-color-outline-variant));
}

.post-title {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 12px;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  color: rgb(var(--mdui-color-on-surface-variant));
  font-size: 0.8125rem;
  flex-wrap: wrap;
}

.post-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.post-meta a {
  color: rgb(var(--mdui-color-primary));
  text-decoration: none;
}

.post-meta a:hover { text-decoration: underline; }

/* ========== 正文基础 ========== */
.post-content {
  font-size: 0.9375rem;
  line-height: 1.8;
}

/* ========== 标题 ========== */
.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
  margin-top: 2em;
  margin-bottom: 0.7em;
  font-weight: 600;
  line-height: 1.35;
  color: rgb(var(--mdui-color-on-surface));
  scroll-margin-top: calc(var(--header-height) + 16px);
}

.post-content h1 { font-size: 1.5rem; border-bottom: 2px solid rgb(var(--mdui-color-outline-variant)); padding-bottom: 0.3em; }
.post-content h2 { font-size: 1.375rem; border-bottom: 1px solid rgb(var(--mdui-color-outline-variant)); padding-bottom: 0.3em; }
.post-content h3 { font-size: 1.125rem; }
.post-content h4 { font-size: 1rem; }

.post-content p { margin: 0 0 1.1em; }

.post-content a {
  color: rgb(var(--mdui-color-primary));
  text-decoration: none;
}

.post-content a:hover { text-decoration: underline; }

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  cursor: zoom-in;
  transition: opacity 0.2s;
}

.post-content img:hover { opacity: 0.9; }

.post-content blockquote {
  margin: 1.5em 0;
  padding: 14px 18px;
  border-left: 4px solid rgb(var(--mdui-color-primary));
  background-color: rgb(var(--mdui-color-secondary-container));
  border-radius: 0 8px 8px 0;
  color: rgb(var(--mdui-color-on-surface-variant));
}

.post-content blockquote p:last-child { margin-bottom: 0; }

.post-content ul,
.post-content ol { margin: 1em 0; padding-left: 2em; }

.post-content li { margin: 0.35em 0; }

/* ========== 表格 ========== */
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.875rem;
}

.post-content th,
.post-content td {
  padding: 10px 14px;
  border: 1px solid rgb(var(--mdui-color-outline-variant));
  text-align: left;
}

.post-content th {
  background-color: rgb(var(--mdui-color-surface-container));
  font-weight: 600;
}

.post-content tr:nth-child(even) {
  background-color: rgb(var(--mdui-color-surface-container-low));
}

.post-content .table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.5em 0;
  border-radius: 8px;
  border: 1px solid rgb(var(--mdui-color-outline-variant));
}

.post-content .table-wrapper::-webkit-scrollbar {
  height: 6px;
}
.post-content .table-wrapper::-webkit-scrollbar-track {
  background: transparent;
}
.post-content .table-wrapper::-webkit-scrollbar-thumb {
  background-color: rgb(var(--mdui-color-outline-variant));
  border-radius: 3px;
}

.post-content .table-wrapper table {
  width: auto;
  min-width: 100%;
  margin: 0;
  border: none;
}

/* ========== 代码块 ========== */
.post-content pre {
  background-color: rgb(var(--mdui-color-surface-container-high));
  border-radius: 10px;
  padding: 16px 18px;
  overflow-x: auto;
  margin: 1.5em 0;
  border: 1px solid rgb(var(--mdui-color-outline-variant));
  position: relative;
  font-size: 0.8125rem;
  line-height: 1.6;
}

.post-content pre code {
  background: none;
  padding: 0;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
}

.post-content code {
  background-color: rgb(var(--mdui-color-surface-container-highest));
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
  color: rgb(var(--mdui-color-error));
}

.post-content pre code { color: inherit; }

/* 代码块折叠 */
.post-content pre.code-collapsed {
  max-height: calc(20 * 1.6em + 32px);
  overflow-y: hidden;
}

.post-content pre.code-collapsed::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(to bottom, transparent, rgb(var(--mdui-color-surface-container-high)));
  pointer-events: none;
}

.code-expand-btn {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 16px;
  background: rgb(var(--mdui-color-surface-container));
  border: 1px solid rgb(var(--mdui-color-outline-variant));
  border-radius: 20px;
  color: rgb(var(--mdui-color-on-surface-variant));
  cursor: pointer;
  font-size: 0.8125rem;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 2;
  transition: background 0.2s;
}

.code-expand-btn:hover {
  background: rgb(var(--mdui-color-surface-container-highest));
}

.post-content pre.code-expanded {
  max-height: none;
}

.post-content pre.code-expanded::after {
  display: none;
}

/* ========== 复制按钮 ========== */
.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  background: rgb(var(--mdui-color-surface-container));
  border: 1px solid rgb(var(--mdui-color-outline-variant));
  border-radius: 6px;
  color: rgb(var(--mdui-color-on-surface-variant));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.code-copy-btn:hover {
  background: rgb(var(--mdui-color-surface-container-highest));
}

/* ========== 图片灯箱 ========== */
.lightbox-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.9);
  z-index: 1000;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 32px;
  user-select: none;
}

.lightbox-overlay.active {
  display: flex;
}

.lightbox-img-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.lightbox-overlay img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  object-fit: contain;
  transition: transform 0.2s ease;
  cursor: grab;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: background 0.2s;
  z-index: 2;
}

.lightbox-close:hover {
  background: rgba(255,255,255,0.3);
}

.lightbox-toolbar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 2;
}

.lightbox-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: background 0.2s;
}

.lightbox-btn:hover {
  background: rgba(255,255,255,0.3);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  transition: background 0.2s;
  z-index: 2;
}

.lightbox-nav:hover {
  background: rgba(255,255,255,0.3);
}

.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }

.lightbox-counter {
  position: absolute;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.8);
  font-size: 0.875rem;
  padding: 4px 12px;
  border-radius: 16px;
  background: rgba(0,0,0,0.4);
  z-index: 2;
}

@media (max-width: 768px) {
  .lightbox-overlay { padding: 16px; }
  .lightbox-nav { width: 40px; height: 40px; font-size: 1.5rem; }
  .lightbox-prev { left: 8px; }
  .lightbox-next { right: 8px; }
  .lightbox-toolbar { bottom: 12px; }
  .lightbox-counter { bottom: 56px; }
  .lightbox-close { top: 12px; right: 12px; }
}

/* ========== 移动端目录 FAB ========== */
.mobile-toc-fab {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgb(var(--mdui-color-primary));
  color: rgb(var(--mdui-color-on-primary));
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(var(--mdui-color-shadow), 0.3);
  z-index: 100;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.mobile-toc-fab:hover {
  transform: scale(1.05);
}

.mobile-toc-fab:active {
  transform: scale(0.95);
}

/* ========== 移动端目录面板 ========== */
.mobile-toc-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
}

.mobile-toc-overlay.active {
  display: block;
}

.mobile-toc-panel {
  display: none;
  position: fixed;
  top: 0;
  right: -300px;
  bottom: 0;
  width: 280px;
  background: rgb(var(--mdui-color-surface));
  z-index: 201;
  padding: 20px;
  overflow-y: auto;
  box-shadow: -4px 0 20px rgba(var(--mdui-color-shadow), 0.15);
  transition: right 0.25s ease;
}

.mobile-toc-panel.active {
  display: block;
  right: 0;
}

.mobile-toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgb(var(--mdui-color-outline-variant));
}

.mobile-toc-title {
  font-size: 1rem;
  font-weight: 600;
}

.mobile-toc-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: rgb(var(--mdui-color-on-surface-variant));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.mobile-toc-close:hover {
  background: rgb(var(--mdui-color-surface-container));
}

.mobile-toc-body .toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mobile-toc-body .toc-list li {
  margin: 4px 0;
}

.mobile-toc-body .toc-link {
  display: block;
  padding: 8px 12px;
  font-size: 0.8125rem;
  color: rgb(var(--mdui-color-on-surface-variant));
  text-decoration: none;
  border-radius: 6px;
  border-left: 2px solid transparent;
  transition: all 0.15s;
}

.mobile-toc-body .toc-link:hover,
.mobile-toc-body .toc-link.active {
  color: rgb(var(--mdui-color-primary));
  background-color: rgb(var(--mdui-color-primary-container));
  border-left-color: rgb(var(--mdui-color-primary));
}

.mobile-toc-body .toc-link-h3 {
  padding-left: 24px;
}

@media (max-width: 1200px) {
  .mobile-toc-fab {
    display: flex;
  }
}

/* ========== 更新记录 ========== */
.changelog-month {
  margin-bottom: 28px;
}

.changelog-month-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgb(var(--mdui-color-outline-variant));
  color: rgb(var(--mdui-color-primary));
}

.changelog-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.changelog-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}

.changelog-item:hover {
  background: rgb(var(--mdui-color-surface-container-low));
}

.changelog-date {
  font-size: 0.75rem;
  color: rgb(var(--mdui-color-on-surface-variant));
  min-width: 40px;
  font-variant-numeric: tabular-nums;
}

.changelog-cat {
  font-size: 0.6875rem;
  color: rgb(var(--mdui-color-on-surface-variant));
  background: rgb(var(--mdui-color-surface-container));
  padding: 2px 8px;
  border-radius: 4px;
  min-width: 48px;
  text-align: center;
  white-space: nowrap;
}

.changelog-title {
  font-size: 0.875rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ========== 我的归纳 ========== */
.archive-category {
  margin-bottom: 8px;
}

.archive-category-header {
  margin-bottom: 4px;
}

.archive-category-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9375rem;
  font-weight: 500;
  color: rgb(var(--mdui-color-on-surface));
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.15s;
}

.archive-category-link:hover {
  background: rgb(var(--mdui-color-surface-container-low));
}

.archive-count {
  font-size: 0.75rem;
  color: rgb(var(--mdui-color-on-surface-variant));
  background: rgb(var(--mdui-color-surface-container));
  padding: 0 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.archive-posts {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-left: 32px;
  margin-bottom: 8px;
}

.archive-post-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.875rem;
  color: rgb(var(--mdui-color-on-surface));
  transition: background 0.15s;
}

.archive-post-item:hover {
  background: rgb(var(--mdui-color-surface-container-low));
  color: rgb(var(--mdui-color-primary));
}
