/* modal.css */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background-color: rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    visibility 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal.show {
  opacity: 1;
  visibility: visible;
}

/* 新增：当显示时，让内容面板滑入视图 */
.modal.show .modal-content {
  transform: translateX(-50%) translateY(0);
}

/* 拖动横条样式 - 优化设计 */
.drag-handle {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 5px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.3),
    rgba(255, 255, 255, 0.6),
    rgba(255, 255, 255, 0.3)
  );
  border-radius: 3px;
  cursor: grab;
  z-index: 30;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.drag-handle:hover {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.4),
    rgba(255, 255, 255, 0.8),
    rgba(255, 255, 255, 0.4)
  );
  transform: translateX(-50%) scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.drag-handle:active {
  cursor: grabbing;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.5),
    rgba(255, 255, 255, 0.9),
    rgba(255, 255, 255, 0.5)
  );
  transform: translateX(-50%) scale(0.95);
}

#markdown-content {
  padding: 32px 28px 28px 28px;
  overflow-y: auto;
  flex-grow: 1;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  line-height: 1.75;
  color: #2c2c2c;
  position: relative;
  z-index: 0;
  /* 优化滚动条样式 */
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

#markdown-content::-webkit-scrollbar {
  width: 6px;
}

#markdown-content::-webkit-scrollbar-track {
  background: transparent;
}

#markdown-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
  transition: background 0.3s ease;
}

#markdown-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* 在内容区域添加标题样式 - 优化设计 */
#markdown-content .content-title {
  font-size: 2em;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 28px 0;
  padding-bottom: 16px;
  border-bottom: 2px solid rgba(0, 0, 0, 0.08);
  background: linear-gradient(135deg, #333, #555);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal-content {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(92vw, 800px);
  max-height: 85vh;

  /* 优化磨砂玻璃效果 */
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(40px) saturate(200%);
  -webkit-backdrop-filter: blur(40px) saturate(200%);

  border-radius: 20px 20px 0 0;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-bottom: none;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.15), 0 -4px 20px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);

  /* 优化动画 */
  transform: translateX(-50%) translateY(100%);
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);

  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 优化内容样式 */
#markdown-content h1,
#markdown-content h3 {
  color: #1a1a1a;
  font-weight: 600;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  padding-bottom: 0.5em;
  margin-bottom: 1em;
  margin-top: 1.5em;
}

#markdown-content h2 {
  color: #1a1a1a;
  font-weight: 600;
  padding-bottom: 0.5em;
  margin-bottom: 0.1em; /* 进一步减小二级标题与后续内容的间距 */
  margin-top: 1.5em;
}

#markdown-content h1:first-child,
#markdown-content .content-title {
  margin-top: 0;
}

#markdown-content h1 {
  font-size: 1.8em;
}
#markdown-content h2 {
  font-size: 1.5em;
}
#markdown-content h3 {
  font-size: 1.3em;
}

#markdown-content p {
  text-align: justify;
}

#markdown-content ul,
#markdown-content ol {
  padding-left: 1.8em;
  margin-bottom: 1.2em;
  margin-top: 0.05em; /* 进一步减小列表与前面标题的间距 */
}

#markdown-content li {
  margin-bottom: 0.6em;
}

#markdown-content blockquote {
  border-left: 4px solid #e0e0e0;
  padding-left: 1.5em;
  margin: 1.5em 0;
  color: #666;
  font-style: italic;
}

#markdown-content code {
  background: rgba(0, 0, 0, 0.05);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
  font-size: 0.9em;
}

#markdown-content pre {
  background: rgba(0, 0, 0, 0.05);
  padding: 1.2em;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1.5em 0;
}

#markdown-content pre code {
  background: none;
  padding: 0;
}

/* 移动端适配 */
@media (max-width: 768px) {
  .modal-content {
    width: 100vw;
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
    left: 0;
    transform: translateX(0%) translateY(100%);
  }

  .modal.show .modal-content {
    transform: translateX(0%) translateY(0);
  }

  #markdown-content {
    padding: 28px 20px 20px 20px;
  }

  #markdown-content .content-title {
    font-size: 1.6em;
    margin-bottom: 20px;
  }
}

/* 平板适配 */
@media (min-width: 769px) and (max-width: 1024px) {
  .modal-content {
    width: min(85vw, 700px);
    max-height: 80vh;
  }
}
