/* 评论抽屉样式 */
.comment-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0;
  background-color: rgba(255, 255, 255, 0.98); /* 增加不透明度 */
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.1);
  z-index: 2000;
  transition: height 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateZ(0);
  will-change: height;
  /* 适配全面屏手机底部安全区域 */
  padding-bottom: env(safe-area-inset-bottom, 0);
  padding-bottom: constant(safe-area-inset-bottom, 0); /* iOS 11.0 */
}

.comment-drawer.open {
  height: 80vh; /* 降低高度以确保在各种手机浏览器上都能正常关闭 */
}

.comment-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  background-color: inherit;
  z-index: 2005; /* 确保头部始终可见 */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.comment-drawer-title {
  font-size: 1.1rem;
  font-weight: 500;
  margin: 0;
}

.comment-drawer-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  padding: 8px;
  color: var(--primary-color);
  cursor: pointer;
  position: relative;
  z-index: 2010; /* 确保关闭按钮始终在最上层 */
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-right: -8px;
  transition: all 0.2s ease;
}

.comment-drawer-close:hover {
  background-color: rgba(var(--primary-color-rgb), 0.1);
  transform: scale(1.1);
}

.comment-drawer-close:active {
  transform: scale(0.95);
}

.comment-drawer-handle {
  width: 40px;
  height: 5px;
  background-color: var(--divider-color);
  border-radius: 3px;
  margin: 10px auto;
  cursor: pointer;
}

.comment-drawer-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0)); /* 适配全面屏底部安全区域 */
  touch-action: pan-y;
  background-color: transparent;
  overscroll-behavior: contain; /* 防止过度滚动影响页面 */
  position: relative;
  z-index: 2000;
}

/* 确保giscus容器在抽屉中正确显示 */
.comment-drawer-content .giscus-drawer-container {
  width: 100%;
  margin-top: 10px;
  min-height: 400px;
  display: block !important;
  visibility: visible !important;
  position: relative;
  z-index: 10;
}

/* 确保giscus iframe在抽屉中正确显示 */
.comment-drawer-content iframe.giscus-frame,
iframe.giscus-frame {
  border: none !important;
  width: 100% !important;
  min-height: 500px !important;
  height: 500px !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  position: static !important;
  z-index: 10 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: visible !important;
}

/* 确保giscus容器内的所有元素都可见 */
.giscus-drawer-container * {
  visibility: visible !important;
  display: block !important;
}

/* 深色模式适配 */
.dark-mode .comment-drawer {
  background-color: rgba(33, 33, 33, 0.95);
  color: #fff;
}

.dark-mode .comment-drawer-header {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

/* 移动端适配 */
@media (min-width: 769px) {
  .comment-drawer {
    display: none !important; /* 非移动设备强制不显示 */
  }
}

/* 动画效果 */
.comment-drawer-enter {
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.comment-drawer-exit {
  animation: slideDown 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUp {
  from {
    height: 0;
  }
  to {
    height: 80vh;
  }
}

@keyframes slideDown {
  from {
    height: 80vh;
  }
  to {
    height: 0;
  }
}

/* Android设备特殊处理 */
.android-device .comment-drawer {
  transform: translateZ(0);
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* 确保滚动条样式美观 */
.comment-drawer-content::-webkit-scrollbar {
  width: 4px;
}

.comment-drawer-content::-webkit-scrollbar-thumb {
  background-color: var(--primary-color);
  border-radius: 4px;
}

.comment-drawer-content::-webkit-scrollbar-track {
  background: transparent;
}
