/* ==========================================================================
   Aurora Star 代码高亮自定义样式（叠加在 Prism 主题之上）
   ========================================================================== */

/* 代码块容器 */
.entry-content pre {
	position: relative;
	border-radius: var(--aurora-star-radius-sm);
	font-family: var(--aurora-star-font-mono);
	font-size: 0.9em;
	line-height: 1.7;
	margin: 1.5em 0;
	padding: 18px 20px;
	overflow-x: auto;
	scrollbar-width: thin;
}

.entry-content pre[class*="language-"] {
	border-radius: var(--aurora-star-radius-sm);
	box-shadow: var(--aurora-star-shadow);
}

/* 自动换行（由主题设置控制，类名由 JS 添加） */
pre[class*="language-"].is-wrap {
	overflow-x: hidden;
	white-space: pre-wrap;
	word-break: break-word;
	word-wrap: break-word;
}

/* 换行模式与行号并存时的缩进 */
pre[class*="language-"].is-wrap.line-numbers code {
	white-space: pre-wrap;
	word-break: break-word;
	word-wrap: break-word;
}

/* ---------- 行号（通用，兼容 Gutenberg 代码块 pre 无 language 类的情况） ---------- */

/* 行号容器：为行号留出左侧空间。
   Prism 官方 CSS 要求 pre[class*=language-]，对 Gutenberg 的 pre.wp-block-code 不生效，
   此处补充通用规则。 */
pre.line-numbers {
	position: relative;
	padding-left: 3.8em;
	counter-reset: linenumber;
}

/* code 内容正常继承 */
pre.line-numbers > code {
	position: relative;
	white-space: inherit;
}

/* 行号行绝对定位在左侧预留区。
   注意：行号行由 Prism 插件 append 到 code 内部，需对齐 code 内容区。 */
.line-numbers .line-numbers-rows {
	position: absolute;
	pointer-events: none;
	top: 0;
	font-size: 100%;
	left: -3.2em;
	width: 3em;
	letter-spacing: -1px;
	border-right: 1px solid rgba(128, 128, 128, 0.3);
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
}

.line-numbers-rows > span {
	display: block;
	counter-increment: linenumber;
}

.line-numbers-rows > span:before {
	content: counter(linenumber);
	color: #999;
	display: block;
	padding-right: 0.8em;
}

/* 行号加在 code 内部时，需要覆盖 .entry-content pre 的 padding 使行号可见 */
pre.line-numbers code .line-numbers-rows {
	left: -3.2em;
}

/* 兼容：短码代码块（pre 有 language 类）行号 */
pre[class*="language-"].line-numbers {
	padding-left: 3.8em;
}

pre[class*="language-"].line-numbers > code .line-numbers-rows {
	left: -3.2em;
}

/* 工具栏（复制按钮/语言标签） */
div.code-toolbar {
	position: relative;
}

div.code-toolbar > .toolbar {
	position: absolute;
	top: 8px;
	right: 10px;
	opacity: 0;
	transition: opacity 0.2s ease;
	z-index: 5;
}

div.code-toolbar:hover > .toolbar {
	opacity: 1;
}

div.code-toolbar > .toolbar > .toolbar-item {
	display: inline-block;
	margin-left: 6px;
}

div.code-toolbar > .toolbar > .toolbar-item > a,
div.code-toolbar > .toolbar > .toolbar-item > button,
div.code-toolbar > .toolbar > .toolbar-item > span {
	color: #fff;
	font-size: 0.75em;
	background: rgba(255, 255, 255, 0.14);
	padding: 4px 10px;
	border-radius: 4px;
	border: 1px solid rgba(255, 255, 255, 0.2);
	cursor: pointer;
	transition: background 0.2s ease;
	font-family: inherit;
}

div.code-toolbar > .toolbar > .toolbar-item > a:hover,
div.code-toolbar > .toolbar > .toolbar-item > button:hover {
	background: var(--aurora-star-primary);
	text-decoration: none;
}

div.code-toolbar > .toolbar > .toolbar-item > span {
	cursor: default;
	background: rgba(0, 0, 0, 0.35);
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

/* 复制成功反馈 */
.toolbar-item .copy-to-clipboard-code-success {
	color: #4ade80 !important;
}

/* 暗色下代码区边框适配 */
html[data-theme="dark"] pre[class*="language-"] {
	border-color: var(--aurora-star-border);
}
