/**
 * ByteMD for WordPress — front-end Markdown theme.
 *
 * Deliberately framework-free and scoped to `.wp-bytemd-content` so it can be
 * dropped on top of any theme. Follows the visitor's colour scheme preference.
 */

.wp-bytemd-content {
	--wp-bytemd-fg: #1f2328;
	--wp-bytemd-muted: #59636e;
	--wp-bytemd-border: #d1d9e0;
	--wp-bytemd-code-bg: rgba(129, 139, 152, .12);
	--wp-bytemd-pre-bg: #f6f8fa;
	--wp-bytemd-link: #0969da;
	--wp-bytemd-quote: #59636e;
	--wp-bytemd-accent: #818b98;

	color: var(--wp-bytemd-fg);
	font-size: 16px;
	line-height: 1.75;
	word-wrap: break-word;
}

.wp-bytemd-content > *:first-child {
	margin-top: 0 !important;
}

.wp-bytemd-content > *:last-child {
	margin-bottom: 0 !important;
}

.wp-bytemd-content h1,
.wp-bytemd-content h2,
.wp-bytemd-content h3,
.wp-bytemd-content h4,
.wp-bytemd-content h5,
.wp-bytemd-content h6 {
	margin: 1.6em 0 .6em;
	line-height: 1.3;
	font-weight: 650;
	color: var(--wp-bytemd-fg);
}

.wp-bytemd-content h1 {
	font-size: 2em;
	padding-bottom: .3em;
	border-bottom: 1px solid var(--wp-bytemd-border);
}

.wp-bytemd-content h2 {
	font-size: 1.5em;
	padding-bottom: .3em;
	border-bottom: 1px solid var(--wp-bytemd-border);
}

.wp-bytemd-content h3 { font-size: 1.25em; }
.wp-bytemd-content h4 { font-size: 1em; }
.wp-bytemd-content h5 { font-size: .875em; }
.wp-bytemd-content h6 { font-size: .85em; color: var(--wp-bytemd-muted); }

.wp-bytemd-content p,
.wp-bytemd-content ul,
.wp-bytemd-content ol,
.wp-bytemd-content blockquote,
.wp-bytemd-content table,
.wp-bytemd-content pre {
	margin: 0 0 1.15em;
}

.wp-bytemd-content ul,
.wp-bytemd-content ol {
	padding-left: 1.6em;
}

.wp-bytemd-content li + li {
	margin-top: .25em;
}

.wp-bytemd-content li > ul,
.wp-bytemd-content li > ol {
	margin-top: .25em;
	margin-bottom: .25em;
}

/* GFM task lists */
.wp-bytemd-content li.task-list-item,
.wp-bytemd-content li:has(> input[type="checkbox"]) {
	list-style: none;
	margin-left: -1.35em;
}

.wp-bytemd-content input[type="checkbox"] {
	margin-right: .5em;
	vertical-align: middle;
}

.wp-bytemd-content a {
	color: var(--wp-bytemd-link);
	text-decoration: none;
}

.wp-bytemd-content a:hover,
.wp-bytemd-content a:focus {
	text-decoration: underline;
}

.wp-bytemd-content strong {
	font-weight: 650;
}

.wp-bytemd-content hr {
	height: 1px;
	margin: 2em 0;
	border: 0;
	background: var(--wp-bytemd-border);
}

.wp-bytemd-content blockquote {
	padding: 0 1em;
	color: var(--wp-bytemd-quote);
	border-left: .25em solid var(--wp-bytemd-border);
}

.wp-bytemd-content blockquote > :last-child {
	margin-bottom: 0;
}

.wp-bytemd-content img {
	max-width: 100%;
	height: auto;
	box-sizing: content-box;
	background: transparent;
}

.wp-bytemd-content code {
	padding: .2em .4em;
	margin: 0;
	font-size: 85%;
	font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
	background: var(--wp-bytemd-code-bg);
	border-radius: 6px;
}

.wp-bytemd-content pre {
	padding: 16px;
	overflow: auto;
	font-size: 85%;
	line-height: 1.5;
	background: var(--wp-bytemd-pre-bg);
	border-radius: 8px;
}

.wp-bytemd-content pre code {
	display: inline;
	padding: 0;
	margin: 0;
	font-size: 100%;
	background: transparent;
	border: 0;
	white-space: pre;
	word-break: normal;
	overflow-wrap: normal;
}

.wp-bytemd-content table {
	display: block;
	width: max-content;
	max-width: 100%;
	overflow: auto;
	border-spacing: 0;
	border-collapse: collapse;
	font-size: 15px;
}

.wp-bytemd-content table th,
.wp-bytemd-content table td {
	padding: 6px 13px;
	border: 1px solid var(--wp-bytemd-border);
}

.wp-bytemd-content table th {
	font-weight: 650;
	background: var(--wp-bytemd-pre-bg);
}

.wp-bytemd-content del {
	opacity: .7;
}

/* Mermaid diagrams */
.wp-bytemd-mermaid {
	margin: 0 0 1.15em;
	overflow-x: auto;
	text-align: center;
}

.wp-bytemd-mermaid svg {
	max-width: 100%;
	height: auto;
}

.wp-bytemd-mermaid-error {
	padding: 10px 14px;
	margin-bottom: 1.15em;
	border-left: 4px solid #d63638;
	background: rgba(214, 54, 56, .08);
	font-size: 14px;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Client-rendered blocks (ByteMD Viewer) */
.wp-bytemd-viewer-host {
	min-height: 1.5em;
}

/* KaTeX display math should not overflow narrow screens */
.wp-bytemd-content .katex-display {
	overflow-x: auto;
	overflow-y: hidden;
	padding: 2px 0;
}

/* -------------------------------------------------------------------------
 * Dark mode
 * ---------------------------------------------------------------------- */

@media (prefers-color-scheme: dark) {
	.wp-bytemd-content {
		--wp-bytemd-fg: #e6edf3;
		--wp-bytemd-muted: #9198a1;
		--wp-bytemd-border: #3d444d;
		--wp-bytemd-code-bg: rgba(110, 118, 129, .4);
		--wp-bytemd-pre-bg: #151b23;
		--wp-bytemd-link: #4493f8;
		--wp-bytemd-quote: #9198a1;
	}

	.wp-bytemd-content .markdown-body {
		color: var(--wp-bytemd-fg);
	}
}

/* Site owners can force a palette with a body class. */
.wp-bytemd-content.bytemd-theme-light {
	--wp-bytemd-fg: #1f2328;
	--wp-bytemd-muted: #59636e;
	--wp-bytemd-border: #d1d9e0;
	--wp-bytemd-code-bg: rgba(129, 139, 152, .12);
	--wp-bytemd-pre-bg: #f6f8fa;
	--wp-bytemd-link: #0969da;
}

.wp-bytemd-content.bytemd-theme-dark {
	--wp-bytemd-fg: #e6edf3;
	--wp-bytemd-muted: #9198a1;
	--wp-bytemd-border: #3d444d;
	--wp-bytemd-code-bg: rgba(110, 118, 129, .4);
	--wp-bytemd-pre-bg: #151b23;
	--wp-bytemd-link: #4493f8;
}
