/* 白灰风格代码块样式文件 */

/* 随大流：系统常见等宽字体（无需加载） */
/* ui-monospace | Cascadia Code(Win) | Consolas(Win) | Monaco(macOS) | Liberation Mono(Linux) | Courier New */
.code-font {
    font-family: ui-monospace, "Cascadia Code", Consolas, Monaco, "Liberation Mono", "Courier New", monospace;
}

/* ========== 代码块容器样式 ========== */
.code-block-container {
    border-radius: 6px;
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    overflow: hidden;
    margin: 0.75rem 0;
}

/* ========== 代码块头部样式 ========== */
.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background-color: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
    transition: background-color 0.2s ease;
    min-height: 32px;
    box-sizing: border-box;
}

.code-block-header:hover {
    background-color: #f3f4f6;
}

/* 头部左侧（折叠图标 + 语言标签） */
.code-block-header-left {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 折叠/展开图标样式 */
.chevron-icon {
    width: 12px;
    height: 12px;
    color: #9ca3af;
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.chevron-icon.collapsed {
    transform: rotate(-90deg);
}

/* 语言标签样式 */
.lang-label {
    font-size: 10px;
    font-weight: 500;
    color: #4b5563;
    line-height: 1;
}

/* 复制按钮样式 */
.copy-button {
    font-size: 10px;
    color: #9ca3af;
    transition: color 0.2s ease;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px 6px;           /* 减小 padding */
    line-height: 1;
    border-radius: 3px;
}

.copy-button:hover {
    color: #4b5563;
    background-color: #e5e7eb;
}

/* ========== 代码内容区域 - 折叠动画核心（修复任意高度） ========== */
.code-content-wrapper {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.25s ease;
    overflow: hidden;
}

.code-content-wrapper > * {
    min-height: 0;
    overflow: hidden;
}

/* 折叠状态 */
.code-content-wrapper.collapsed {
    grid-template-rows: 0fr;
}

/* ========== 代码内容样式 ========== */
.code-content-wrapper pre {
    margin: 0 !important;
    padding: 10px 14px !important;
    overflow-x: auto;
    font-family: ui-monospace, "Cascadia Code", Consolas, Monaco, "Liberation Mono", "Courier New", monospace !important;
    font-size: 0.8125rem !important;     /* 13px，比正文 1rem 小一号 */
    line-height: 1.45 !important;
    color: #1f2937 !important;
    background-color: #ffffff !important;
    tab-size: 4;
}

/* code 标签样式 */
.code-content-wrapper code {
    font-family: ui-monospace, "Cascadia Code", Consolas, Monaco, "Liberation Mono", "Courier New", monospace !important;
    font-size: inherit !important;
    line-height: inherit !important;
    background: transparent !important;
    padding: 0 !important;
    color: inherit !important;
}

/* ========== 覆盖 Hugo Chroma 样式 ========== */
.code-content-wrapper .highlight {
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border-radius: 0 !important;
    border: none !important;
}

.code-content-wrapper .highlight pre {
    margin: 0 !important;
    padding: 10px 14px !important;
    background: transparent !important;
    border-radius: 0 !important;
    font-size: 0.8125rem !important;
    line-height: 1.45 !important;
}

/* 覆盖 prose 插件样式 */
.prose .code-block-container pre,
.prose .code-block-container code {
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    color: inherit !important;
    font-size: inherit !important;
    font-family: ui-monospace, "Cascadia Code", Consolas, Monaco, "Liberation Mono", "Courier New", monospace !important;
}

.prose .code-block-container .code-content-wrapper pre {
    padding: 10px 14px !important;
}

/* ========== 深色模式支持 ========== */
@media (prefers-color-scheme: dark) {
    .code-block-container {
        background-color: #1f2937;
        border-color: #374151;
    }
    
    .code-block-header {
        background-color: #111827;
        border-bottom-color: #374151;
    }
    
    .lang-label {
        color: #9ca3af;
    }
    
    .copy-button {
        color: #6b7280;
    }
    
    .copy-button:hover {
        color: #d1d5db;
        background-color: #374151;
    }
    
    .code-content-wrapper pre {
        background-color: #1f2937 !important;
        color: #e5e7eb !important;
    }
}