/* 全局样式重置 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* 基础变量 */
:root {
  --text-primary: rgb(55, 53, 47);
  --text-secondary: rgba(55, 53, 47, 0.65);
  --text-tertiary: rgba(55, 53, 47, 0.5);
  --background-primary: #ffffff;
  --background-secondary: #f7f6f3;
  --border-color: rgba(55, 53, 47, 0.09);
  --border-color-dark: rgba(55, 53, 47, 0.16);
  --hover-background: rgba(55, 53, 47, 0.03);
  --active-background: rgba(84, 72, 49, 0.08);
  --active-color: rgb(29, 27, 22);
  --link-color: rgb(35, 131, 226);
  --block-spacing: 0.5rem;
  --main-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica,
    "Apple Color Emoji", Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
  --code-font: SFMono-Regular, Menlo, Consolas, "PT Mono", "Liberation Mono",
    Courier, monospace;
  --max-width: 900px;
  --toc-shadow: rgba(0, 0, 0, 0.1) 0px 14px 28px -6px,
    rgba(0, 0, 0, 0.06) 0px 2px 4px -1px, rgba(84, 72, 49, 0.08) 0px 0px 0px 1px;
}

body {
  font-family: var(--main-font);
  color: var(--text-primary);
  line-height: 1.5;
  background-color: var(--background-primary);
}

/* 导航栏样式 */
.notion-topbar {
  width: 100%;
  height: 44px;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  background-color: var(--background-primary);
  border-bottom: 1px solid var(--border-color);
  transition: opacity 700ms, color 700ms;
  user-select: none;
}

.notion-topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  overflow: hidden;
  height: 44px;
  padding-left: 12px;
  padding-right: 10px;
}

.notion-breadcrumb {
  display: flex;
  align-items: center;
  line-height: 1.2;
  font-size: 14px;
  height: 100%;
  flex-grow: 0;
  margin-right: 8px;
  min-width: 0;
  overflow: hidden;
  flex-shrink: 1;
  max-width: calc(100% - 200px);
}

.notion-page-link {
  display: flex;
  color: var(--text-primary);
  text-decoration: none;
  user-select: none;
  transition: background 20ms ease-in;
  cursor: pointer;
  align-items: center;
  height: 24px;
  padding: 2px 6px;
  border-radius: 6px;
  white-space: nowrap;
  font-size: inherit;
  flex-shrink: 1;
  line-height: 1.2;
  min-width: 0;
}

.notion-page-link:hover {
  background-color: var(--hover-background);
}

.notion-page-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  width: 20px;
  border-radius: 0.25em;
  flex-shrink: 0;
  margin-right: 6px;
  font-weight: 500;
}

.notion-page-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.notion-breadcrumb-divider {
  margin-left: 2px;
  margin-right: 2px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.notion-button {
  user-select: none;
  transition: background 20ms ease-in;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding-right: 8px;
  padding-left: 8px;
  border-radius: 6px;
  white-space: nowrap;
  font-size: 14px;
  flex-shrink: 0;
  line-height: 1.2;
  min-width: 0;
  color: var(--text-primary);
}

.notion-button:hover {
  background-color: var(--hover-background);
}

.notion-button-group {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  min-width: 100px;
}

.notion-top-links {
  display: flex;
  margin-right: 8px;
  overflow: hidden;
}

.notion-icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 20ms ease-in;
  flex-shrink: 0;
}

.notion-icon-button:hover {
  background-color: var(--hover-background);
}

.notion-top-item {
  display: flex;
  color: inherit;
  text-decoration: none;
  user-select: none;
  transition: background 20ms ease-in;
  cursor: pointer;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 4px;
}

.notion-top-item:hover {
  background-color: var(--hover-background);
}

.notion-top-item-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
  word-break: break-word;
  margin-right: 4px;
}

.notion-border-button {
  user-select: none;
  transition: background 20ms ease-in;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border-radius: 6px;
  height: 32px;
  padding: 0px 10px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  border: 1px solid var(--border-color-dark);
  margin-left: 8px;
  flex-shrink: 0;
}

.notion-border-button:hover {
  background-color: var(--hover-background);
}

.icon-emoji {
  margin-left: 6px;
}

.menu-toggle {
  display: none;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 1.5rem;
  padding: 0 8px;
}

/* 重新设计的悬浮目录导航样式 */
.notion-toc-container {
  position: fixed;
  top: 130px;
  right: 0;
  z-index: 90;
}

/* 目录导航基本结构 */
.notion-toc {
  position: relative;
  display: flex;
  width: 56px;
}

.notion-toc-inner {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-bottom: 12px;
  padding-right: 8px;
  width: 56px;
  flex-shrink: 0;
}

.notion-toc-items {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-left: 20px;
  padding-bottom: 12px;
  height: 100%;
}

.notion-toc-item {
  cursor: pointer;
}

.notion-toc-indicator {
  height: 2px;
  transition: background 0.2s, box-shadow 0.2s, width 0.2s, margin-left 0.2s;
  box-shadow: none;
  border-radius: 2px;
}

.notion-toc-h1 {
  width: 16px;
  margin-left: 0px;
  background-color: rgba(84, 72, 49, 0.15);
}

.notion-toc-h2 {
  width: 12px;
  margin-left: 4px;
  background-color: rgba(84, 72, 49, 0.15);
}

.notion-toc-h3 {
  width: 12px;
  margin-left: 4px;
  background-color: rgba(84, 72, 49, 0.15);
}

.notion-toc-active {
  background-color: rgb(50, 48, 44);
}

/* 优化后的悬浮窗口样式 */
.notion-toc-popup {
  position: absolute;
  top: -10px; /* 向上偏移一点 */
  right: 46px; /* 与toc有部分重叠 */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.98);
  transform-origin: right top;
  transition: opacity 0.15s ease, transform 0.15s ease,
    visibility 0s linear 0.15s;
  z-index: -1; /* 这样会被toc覆盖 */
}

/* 悬浮状态显示弹窗 */
.notion-toc-container:hover .notion-toc-popup {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s;
  pointer-events: auto;
  z-index: 91; /* 悬浮时置于toc上方 */
}

/* 悬浮窗口内容 */
.notion-toc-popup-content {
  background-color: white;
  border-radius: 14px;
  box-shadow: var(--toc-shadow);
  max-height: 418px;
  overflow-y: auto;
  width: 242px;
  padding: 12px 0;
}

/* 目录项链接 */
.notion-toc-link {
  display: block;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.3;
  padding: 4px 16px;
  transition: background-color 0.15s ease, color 0.15s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notion-toc-link:hover {
  background-color: var(--hover-background);
  color: var(--text-primary);
}

.notion-toc-link-active {
  background-color: var(--active-background);
  color: var(--active-color);
}

.notion-toc-h1-link {
  margin-left: 0px;
  font-weight: 500;
}

.notion-toc-h2-link {
  margin-left: 12px;
}

.notion-toc-h3-link {
  margin-left: 24px;
}

/* 内容容器布局 - 添加顶部间距以防止导航栏遮挡 */
.notion-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: calc(3rem + 44px) 2rem 3rem; /* 顶部增加导航栏高度 */
}

/* 页面标题 */
.notion-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  line-height: 1.2;
  scroll-margin-top: 100px;
}

/* 文本块 */
.notion-block {
  margin-bottom: var(--block-spacing);
  padding: 3px 2px;
  transition: background-color 0.1s ease-in-out;
}

.notion-block:hover {
  background-color: var(--hover-background);
}

/* 段落样式 */
.notion-text {
  min-height: 1.5em;
  padding: 3px 2px;
}

/* 标题样式 */
.notion-h1 {
  font-size: 1.875rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.25rem;
  line-height: 1.3;
  scroll-margin-top: 100px;
}

.notion-h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 1.4rem;
  margin-bottom: 0.25rem;
  scroll-margin-top: 100px;
}

.notion-h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.25rem;
  scroll-margin-top: 100px;
}

/* 列表样式 */
.notion-list {
  padding-left: 1.5rem;
  margin: 0.5rem 0;
}

.notion-list-item {
  padding: 3px 0;
  min-height: 1.5em;
}

/* 待办事项 */
.notion-checkbox {
  display: flex;
  align-items: flex-start;
  margin: 0.5rem 0;
}

.notion-checkbox-input {
  margin-right: 0.5rem;
  margin-top: 0.3rem;
  border-radius: 3px;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-color);
  background-color: white;
}

.notion-checkbox-content {
  flex: 1;
}

/* 引用块 */
.notion-quote {
  border-left: 3px solid var(--text-primary);
  padding-left: 0.9rem;
  margin: 0.5rem 0;
  font-style: italic;
  color: var(--text-secondary);
}

/* 分割线 */
.notion-divider {
  width: 100%;
  height: 1px;
  background-color: var(--border-color);
  margin: 1.5rem 0;
}

/* 代码块 */
.notion-code {
  font-family: var(--code-font);
  background-color: var(--background-secondary);
  padding: 1rem;
  border-radius: 3px;
  overflow-x: auto;
  margin: 0.5rem 0;
  font-size: 0.875rem;
}

/* 图片 */
.notion-image {
  width: 100%;
  border-radius: 3px;
  margin: 0.5rem 0;
  overflow: hidden;
}

.notion-image img {
  width: 100%;
  display: block;
}

/* 表格 */
.notion-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  overflow-x: auto;
}

.notion-table th,
.notion-table td {
  border: 1px solid var(--border-color);
  padding: 0.5rem;
  text-align: left;
}

.notion-table th {
  background-color: var(--background-secondary);
  font-weight: 500;
}

/* 卡片组件 */
.notion-callout {
  display: flex;
  padding: 1rem;
  background-color: var(--background-secondary);
  border-radius: 3px;
  margin: 0.5rem 0;
}

.notion-callout-icon {
  margin-right: 0.75rem;
}

.notion-callout-content {
  flex: 1;
}

/* 响应式调整 */
@media (max-width: 1100px) {
  .notion-top-item-text {
    display: none;
  }

  .notion-page-name {
    max-width: 120px;
  }
}

@media (max-width: 900px) {
  .notion-page-name {
    max-width: 80px;
  }

  .notion-breadcrumb {
    max-width: calc(100% - 150px);
  }

  .notion-container {
    padding: calc(2rem + 44px) 1rem 2rem;
  }

  /* 在小屏幕上隐藏目录 */
  .notion-toc-container {
    display: none;
  }
}

@media (max-width: 768px) {
  .notion-title {
    font-size: 2rem;
  }

  .notion-h1 {
    font-size: 1.5rem;
  }

  .notion-h2 {
    font-size: 1.25rem;
  }

  .notion-h3 {
    font-size: 1.125rem;
  }

  /* 在较小屏幕上隐藏除第一个面包屑项外的所有面包屑 */
  .notion-page-block:not(:first-child),
  .notion-breadcrumb-divider {
    display: none;
  }

  .notion-page-block:last-of-type {
    display: flex;
  }

  .notion-breadcrumb .notion-button {
    display: none;
  }

  .notion-border-button span {
    display: none;
  }

  .notion-border-button {
    padding: 0 8px;
  }

  /* 隐藏前三个顶部链接 */
  .notion-top-item:nth-child(-n + 3) {
    display: none;
  }
}

@media (max-width: 600px) {
  /* 隐藏所有顶部链接 */
  .notion-top-links {
    display: none;
  }

  /* 显示菜单切换按钮 */
  .menu-toggle {
    display: flex;
  }

  .notion-breadcrumb {
    max-width: calc(100% - 120px);
  }
}

@media (max-width: 480px) {
  .notion-border-button {
    display: none;
  }

  .notion-breadcrumb {
    max-width: calc(100% - 80px);
  }
}

/* 封面图片容器样式 */
.notion-cover-image-container {
  width: 100%;
  height: 30vh; /* 设置一个合适的高度 */
  overflow: visible; /* 修改为visible，允许内容溢出显示 */
  position: relative; /* 添加相对定位，用于放置装饰元素 */
  margin-bottom: 0.5rem; /* 增加底部间距，为更大的螃蟹留出足够空间 */
}

.page-cover-image {
  width: 100%;
  height: 100%;
  object-fit: cover; /* 保持图片比例并填充容器 */
}

/* 修改螃蟹装饰元素样式 */
.notion-cover-image-container::after {
  content: "🦀";
  position: absolute;
  bottom: -40px; /* 调整垂直位置，确保下半部分可见 */
  left: calc(50% - var(--max-width) / 2 + 2rem); /* 保持左侧位置 */
  transform: translateX(0);
  font-size: 64px; /* 保持字体大小 */
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.9); /* 保持文字阴影 */
  z-index: 6; /* 提高z-index确保显示在最上层 */
  line-height: 1;
  pointer-events: none; /* 防止干扰鼠标事件 */
}

/* 响应式调整 */
@media (max-width: 900px) {
  .notion-cover-image-container::after {
    left: 1rem;
    font-size: 56px;
  }

  .notion-cover-image-container {
    margin-bottom: 3rem;
  }
}

@media (max-width: 768px) {
  .notion-cover-image-container {
    height: 25vh;
    margin-bottom: 2.5rem;
  }

  .notion-cover-image-container::after {
    font-size: 48px;
    bottom: -30px;
  }
}

@media (max-width: 480px) {
  .notion-cover-image-container {
    height: 20vh;
    margin-bottom: 2rem;
  }

  .notion-cover-image-container::after {
    font-size: 40px;
    bottom: -25px;
  }
}
