/**
 * 前台「插入代码块」展示样式（合集 / 知识库共用，entry-content 内联块）。
 * 结构由 code-block.js 在 DOMContentLoaded 时补齐（标题 + 复制 + 可选行号栏）；
 * 本文件里的 .mytb-code-block__* 均针对 JS 增强后的结构。增强前只有灰底 pre/code
 * （与后台 TinyMCE 预览一致）。
 *
 * WHY 选择器带 .entry-content：主题 `.entry-content pre` 是深色代码块
 *（bg-gray-900 + 浅字），专一性与 `.mytb-code-block pre` 打平、后加载就盖过来，
 * 肉眼就是「上头一条灰、下面一块黑」。必须比主题那条多一层 class。
 */
.mytb-code-block {
	position: relative;
	margin: 1.5em 0;
	max-width: 100%;
	min-width: 0;
	border-radius: 8px;
	background: #FCFCFC;
	border: 1px solid #e5e5e5;
	overflow: hidden;
}

.mytb-code-block__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 10px 14px 0;
	background: transparent;
	border-bottom: 0;
	min-height: 24px;
}

.mytb-code-block__title {
	font-size: 13px; /* text-footnote */
	font-weight: 500;
	color: #666666;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.mytb-code-block__copy {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
	min-height: 24px;
	margin: 0;
	padding: 2px 4px;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: #666666;
	font-size: 13px; /* text-footnote */
	font-weight: 500;
	line-height: 1.4;
	cursor: pointer;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.15s ease, color 0.15s ease;
}

.mytb-code-block__copy-icon {
	display: block;
	flex: 0 0 auto;
}

.mytb-code-block:hover .mytb-code-block__copy,
.mytb-code-block:focus-within .mytb-code-block__copy,
.mytb-code-block__copy.is-copied {
	opacity: 1;
	pointer-events: auto;
}

.mytb-code-block__copy:hover,
.mytb-code-block__copy:focus-visible {
	color: #222222;
}

.mytb-code-block__copy:focus-visible {
	outline: 2px solid #111;
	outline-offset: 2px;
}

.mytb-code-block__copy.is-copied {
	color: #16794c;
}

.mytb-code-block__copy--float {
	position: absolute;
	top: 8px;
	right: 12px;
	z-index: 1;
}

.mytb-code-block__body {
	display: flex;
	align-items: stretch;
	min-width: 0;
	overflow-x: hidden;
}

.mytb-code-block__gutter {
	flex: 0 0 auto;
	margin: 0;
	padding: 14px 10px 14px 14px;
	font-family: Consolas, Monaco, 'Courier New', monospace;
	font-size: 14px; /* text-caption · 等宽代码例外 */
	line-height: 1.6;
	color: #b3b3b3;
	text-align: right;
	user-select: none;
	white-space: pre;
	border-right: 1px solid #ececec;
	background: transparent;
}

.entry-content .mytb-code-block pre,
.mytb-coll-body .mytb-code-block pre,
.mytheme-kb-entry-content .mytb-code-block pre,
.mytb-code-block pre {
	flex: 1 1 auto;
	min-width: 0;
	margin: 0;
	padding: 14px;
	overflow-x: hidden;
	overflow-wrap: anywhere;
	white-space: pre-wrap;
	border-radius: 0;
	background: transparent;
	color: #222222;
	font-size: 14px; /* text-caption · 等宽代码例外 */
}

.entry-content .mytb-code-block code,
.entry-content .mytb-code-block pre code,
.mytb-coll-body .mytb-code-block code,
.mytheme-kb-entry-content .mytb-code-block code,
.mytb-code-block code {
	font-family: Consolas, Monaco, 'Courier New', monospace;
	font-size: 14px; /* text-caption · 等宽代码例外 */
	line-height: 1.6;
	color: #222222;
	background: transparent;
	padding: 0;
	border-radius: 0;
	overflow-wrap: anywhere;
	white-space: pre-wrap;
}

@media (hover: none) {
	.mytb-code-block__copy {
		opacity: 1;
		pointer-events: auto;
		min-height: 44px;
		min-width: 44px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mytb-code-block__copy {
		transition: none;
	}
}

@media (max-width: 640px) {
	.mytb-code-block__title {
		max-width: 55%;
	}
}
