/* macOS 风格代码块样式 */

/* 代码块容器 - 支持 Shiki 和普通 pre */
article .post_content .astro-code,
article .post_content pre {
  position: relative;
  margin: 1.5rem 0;
  padding: 0;
  border-radius: 0.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  background: #282c34 !important;
}

/* 亮色模式代码块 */
:root:not(.darkmode) article .post_content .astro-code,
:root:not(.darkmode) article .post_content pre {
  background: #fafafa !important;
}

/* macOS 窗口标题栏 */
article .post_content .astro-code::before,
article .post_content pre::before {
  content: '';
  display: block;
  height: 2.5rem;
  background: linear-gradient(to bottom, #e8e8e8, #d1d1d1);
  border-bottom: 1px solid #b3b3b3;
  position: relative;
}

/* 暗色模式标题栏 */
.darkmode article .post_content .astro-code::before,
.darkmode article .post_content pre::before {
  background: linear-gradient(to bottom, #3c3c3c, #2d2d2d);
  border-bottom: 1px solid #1a1a1a;
}

/* macOS 三个彩色按钮 */
article .post_content .astro-code::after,
article .post_content pre::after {
  content: '';
  position: absolute;
  top: 0.875rem;
  left: 0.875rem;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: #ff5f57;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.1),
    1.25rem 0 0 0 #febc2e,
    1.25rem 0 0 1px rgba(0, 0, 0, 0.1),
    2.5rem 0 0 0 #28c840,
    2.5rem 0 0 1px rgba(0, 0, 0, 0.1);
}

/* 代码内容区域 */
article .post_content .astro-code code,
article .post_content pre code {
  display: block;
  padding: 1.25rem 1.5rem;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Consolas', monospace;
  font-size: 0.875rem;
  line-height: 1.7;
  overflow-x: auto;
  background: transparent !important;
}

/* 暗色模式代码文本颜色 */
.darkmode article .post_content .astro-code code,
.darkmode article .post_content pre code {
  color: #abb2bf;
}

/* 亮色模式代码文本颜色 */
:root:not(.darkmode) article .post_content .astro-code code,
:root:not(.darkmode) article .post_content pre code {
  color: #24292e;
}

/* 语言标签（如果需要显示） */
article .post_content .astro-code[data-language]::before,
article .post_content pre[data-language]::before {
  content: attr(data-language);
  position: absolute;
  top: 0.5rem;
  right: 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #8e8e93;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  z-index: 1;
}

/* 滚动条样式 */
article .post_content .astro-code code::-webkit-scrollbar,
article .post_content pre code::-webkit-scrollbar {
  height: 0.5rem;
}

article .post_content .astro-code code::-webkit-scrollbar-track,
article .post_content pre code::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 0.25rem;
}

article .post_content .astro-code code::-webkit-scrollbar-thumb,
article .post_content pre code::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 0.25rem;
}

article .post_content .astro-code code::-webkit-scrollbar-thumb:hover,
article .post_content pre code::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.5);
}

/* 暗色模式滚动条 */
.darkmode article .post_content .astro-code code::-webkit-scrollbar-track,
.darkmode article .post_content pre code::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

.darkmode article .post_content .astro-code code::-webkit-scrollbar-thumb,
.darkmode article .post_content pre code::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
}

.darkmode article .post_content .astro-code code::-webkit-scrollbar-thumb:hover,
.darkmode article .post_content pre code::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* 行号样式（如果启用） */
article .post_content .astro-code .line::before {
  content: '';
  display: inline-block;
  width: 1rem;
  margin-right: 1rem;
  text-align: right;
  color: rgba(0, 0, 0, 0.3);
  user-select: none;
}

.darkmode article .post_content .astro-code .line::before {
  color: rgba(255, 255, 255, 0.3);
}

/* 高亮行样式 */
article .post_content .astro-code .line.highlighted {
  background: rgba(255, 255, 255, 0.05);
  border-left: 3px solid var(--theme);
  padding-left: calc(1.5rem - 3px);
}

/* 复制按钮样式 */
article .post_content .copy-code-button {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 0.375rem;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-2px);
  transition: all 0.2s ease;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(8px);
}

/* 暗色模式复制按钮 */
.darkmode article .post_content .copy-code-button {
  background: rgba(60, 60, 60, 0.9);
  color: #e5e7eb;
  border-color: rgba(255, 255, 255, 0.15);
}

/* hover 显示按钮 */
article .post_content pre:hover .copy-code-button,
article .post_content .astro-code:hover .copy-code-button {
  opacity: 1;
  transform: translateY(0);
}

/* 按钮 hover 效果 */
article .post_content .copy-code-button:hover {
  background: rgba(255, 255, 255, 1);
  border-color: rgba(0, 0, 0, 0.2);
  transform: translateY(0) scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.darkmode article .post_content .copy-code-button:hover {
  background: rgba(70, 70, 70, 1);
  border-color: rgba(255, 255, 255, 0.25);
}

/* 按钮按下效果 */
article .post_content .copy-code-button:active {
  transform: translateY(0) scale(0.95);
}

/* 复制成功状态 */
article .post_content .copy-code-button.copied {
  background: #10b981;
  color: white;
  border-color: #059669;
}

.darkmode article .post_content .copy-code-button.copied {
  background: #10b981;
  color: white;
  border-color: #059669;
}

/* 复制失败状态 */
article .post_content .copy-code-button.copy-error {
  background: #ef4444;
  color: white;
  border-color: #dc2626;
}

.darkmode article .post_content .copy-code-button.copy-error {
  background: #ef4444;
  color: white;
  border-color: #dc2626;
}

/* 按钮图标 */
article .post_content .copy-code-button svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  stroke: currentColor;
}

/* 按钮文字 */
article .post_content .copy-code-button .copy-text {
  white-space: nowrap;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* 移动端优化 - 始终显示按钮 */
@media (max-width: 768px) {
  article .post_content .copy-code-button {
    opacity: 0.8;
  }
}

/* 移除之前 Prism 相关的样式 */
article .post_content .copy-to-clipboard-button {
  display: none !important;
}

article .post_content .code-toolbar {
  display: block;
}

/* 确保代码块不受之前样式影响 */
article .post_content pre.line-numbers,
article .post_content pre[class*=language-].line-numbers {
  padding-left: 0;
}

article .post_content pre .line-numbers-rows {
  display: none;
}

/* 确保内联代码不受影响 */
article .post_content code:not([class]) {
  padding: 0.2rem 0.3rem;
  margin: auto 0.2rem;
  font-size: 0.75rem;
  vertical-align: bottom;
  background: var(--C);
  border-radius: 0.25rem;
  color: #fff;
  font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;
  letter-spacing: 0;
}

/* 确保 pre 内的 code 不应用内联样式 */
article .post_content pre code:not([class]) {
  padding: 0;
  margin: 0;
  background: transparent;
  color: inherit;
  vertical-align: baseline;
}

