/* Site-wide overrides (Zensical / Material theme)
 * - Iosevka everywhere
 * - Slightly smaller type
 * - Grayscale UI (background stays white)
 */

:root {
	--md-text-font: "Iosevka";
	--md-code-font: "Iosevka";
}

/* Typography sizing */
.md-typeset {
	font-size: 0.7rem !important;
	line-height: 1.65;
}

.md-typeset code {
	font-size: 1em;
}

.md-nav {
	font-size: 0.7rem;
}

/* Grayscale palette tweaks (light mode) */
[data-md-color-scheme="default"] {
	--md-default-bg-color: #fff;
	--md-default-fg-color: rgba(28, 27, 26, 0.92);
	--md-default-fg-color--light: rgba(28, 27, 26, 0.65);
	--md-default-fg-color--lighter: rgba(28, 27, 26, 0.4);
	--md-default-fg-color--lightest: rgba(28, 27, 26, 0.1);

	/* Links / interactive elements */
	--md-primary-fg-color: rgba(28, 27, 26, 0.86);
	--md-accent-fg-color: rgba(28, 27, 26, 0.92);
	--md-accent-fg-color--transparent: rgba(28, 27, 26, 0.1);

	/* Main link color (body text links) */
	--md-typeset-a-color: rgba(28, 27, 26, 0.78);

	/* Subtle surfaces */
	--md-code-bg-color: rgb(245, 245, 245);
	--md-typeset-table-color: rgba(28, 27, 26, 0.12);
}

/* Dark mode: keep grayscale accents (avoid default blue links) */
[data-md-color-scheme="slate"][data-md-color-primary="grey"][data-md-color-accent="grey"] {
	/* Links */
	--md-typeset-a-color: rgba(230, 230, 230, 0.85);

	/* Primary/accent UI */
	--md-primary-fg-color: rgba(230, 230, 230, 0.85);
	--md-accent-fg-color: rgba(255, 255, 255, 0.9);
	--md-accent-fg-color--transparent: rgba(255, 255, 255, 0.12);
}

/* Make links feel more "document"-like */
.md-typeset a {
	color: var(--md-typeset-a-color, var(--md-accent-fg-color));
	text-decoration: underline;
	text-decoration-color: color-mix(in srgb, currentColor 25%, transparent);
	text-underline-offset: 0.12em;
}

.md-typeset a:hover {
	color: var(--md-accent-fg-color);
	text-decoration-color: color-mix(in srgb, currentColor 55%, transparent);
}

/* Sidebar link colors (work in light + dark mode) */
.md-nav__link {
	color: var(--md-default-fg-color--light);
}

.md-nav__link:hover,
.md-nav__link--active {
	color: var(--md-default-fg-color);
}

/* Remove the default top-left book icon */
.md-header__button.md-logo,
.md-nav__button.md-logo,
.md-nav__title .md-logo {
	display: none;
}

/* Make the header site name look like text, but behave like a link */
header.md-header .md-header__topic > a.md-ellipsis {
	color: inherit;
	text-decoration: none;
	cursor: pointer;
}

header.md-header .md-header__topic > a.md-ellipsis:hover {
	text-decoration: underline;
	text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
	text-underline-offset: 0.12em;
}

/* Tables: make them more compact and reduce visual chrome */
.md-typeset__table {
	--codework-table-pad-x: 0.4rem;

	display: block;
	width: 100%;

	margin: 0;
	padding: 0 0.8rem;
}

.md-typeset table:not([class]) {
	width: 100%;
	min-width: 100%;

	font-size: 0.8rem;
	line-height: 1.45;

	border: 0;
	border-top: 0.05rem solid var(--md-typeset-table-color);
	border-bottom: 0.05rem solid var(--md-typeset-table-color);
	border-radius: 0;
	box-shadow: none;
}

.md-typeset table:not([class]) th,
.md-typeset table:not([class]) td {
	padding: 0.35em var(--codework-table-pad-x);
	vertical-align: top;
}

.md-typeset table:not([class]) thead th {
	padding-top: 0.45em;
	padding-bottom: 0.45em;
}

.md-typeset table:not([class]) th:nth-child(1),
.md-typeset table:not([class]) td:nth-child(1) {
	width: 1%;
	white-space: nowrap;
}

.md-typeset table:not([class]) th:nth-child(2),
.md-typeset table:not([class]) td:nth-child(2) {
	width: 1%;
	white-space: normal;
	overflow-wrap: anywhere;
}

.md-typeset__table > table:not([class]) {
	margin: 0 calc(-1 * var(--codework-table-pad-x));
	width: calc(100% + (var(--codework-table-pad-x) * 2));
	min-width: calc(100% + (var(--codework-table-pad-x) * 2));
}

.md-typeset table:not([class]) th:nth-child(n + 3),
.md-typeset table:not([class]) td:nth-child(n + 3) {
	overflow-wrap: anywhere;
}

/* Code blocks: match the table treatment */
.md-typeset .highlight {
	--codework-code-pad-x: 0.6rem;
}

.md-typeset .highlight > pre {
	margin-left: calc(-1 * var(--codework-code-pad-x));
	margin-right: calc(-1 * var(--codework-code-pad-x));
}

.md-typeset .highlight > pre > code {
	padding-left: var(--codework-code-pad-x);
	padding-right: var(--codework-code-pad-x);
}
