/* -- theme variables ----------------------------------------------------- */
:root,
:root[data-theme="light"] {
	color-scheme: light;
	--theme-bg: 0deg 0% 98%;
	--theme-link: 172deg 18% 41%;
	--theme-text: 203deg 11% 15%;
	--theme-accent: 351deg 66% 48%;
	--theme-accent-2: 0deg 0% 7%;
	--theme-quote: 351deg 66% 48%;
}

:root[data-theme="dark"] {
	color-scheme: dark;
	--theme-bg: 210deg 6% 12%;
	--theme-link: 330deg 49% 67%;
	--theme-text: 220deg 3% 79%;
	--theme-accent: 159deg 64% 45%;
	--theme-accent-2: 0deg 0% 93%;
	--theme-quote: 102deg 100% 86%;
}

:root {
	--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
		"Courier New", monospace;
	--max-width: 48rem;
}

/* -- reset --------------------------------------------------------------- */
*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	scroll-behavior: smooth;
}

body {
	margin: 0;
	padding: 4rem 2rem 0;
	max-width: var(--max-width);
	margin-inline: auto;
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	font-family: var(--font-mono);
	font-size: 0.875rem;
	line-height: 1.5;
	color: hsl(var(--theme-text));
	background-color: hsl(var(--theme-bg));
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6 {
	font-size: inherit;
	font-weight: inherit;
	margin: 0;
}

p,
ul,
ol,
dl,
dd,
figure,
blockquote {
	margin: 0;
}

ul,
ol {
	padding: 0;
	list-style: none;
}

img {
	max-width: 100%;
	height: auto;
	display: block;
}

button {
	font: inherit;
	color: inherit;
	background: none;
	border: 0;
	padding: 0;
	cursor: pointer;
}

a {
	color: inherit;
	text-decoration: none;
}

/* -- utilities ----------------------------------------------------------- */
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.skip-link {
	position: absolute;
	left: 0.5rem;
	top: 0.5rem;
	padding: 0.5rem 0.75rem;
	background: hsl(var(--theme-bg));
	color: hsl(var(--theme-text));
	z-index: 100;
}

.skip-link:not(:focus) {
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.title {
	font-size: 1.5rem;
	font-weight: 600;
	color: hsl(var(--theme-accent-2));
	margin-bottom: 0.5rem;
}

.cactus-link {
	background-size: 100% 6px;
	background-position: bottom;
	background-repeat: repeat-x;
	background-image: linear-gradient(
		transparent,
		transparent 5px,
		hsl(var(--theme-text)) 5px,
		hsl(var(--theme-text))
	);
	color: inherit;
}

.cactus-link:hover {
	background-image: linear-gradient(
		transparent,
		transparent 4px,
		hsl(var(--theme-link)) 4px,
		hsl(var(--theme-link))
	);
}

/* -- header -------------------------------------------------------------- */
.site-header {
	position: relative;
	display: flex;
	align-items: center;
	margin-bottom: 7rem;
}

.site-header-brand {
	display: flex;
}

.brand-link {
	display: inline-flex;
	align-items: center;
}

.matcha {
	width: 2rem;
	height: 2.5rem;
	margin-inline-end: 0.75rem;
	filter: grayscale(1);
	transition: filter 0.2s ease;
}

.brand-link:hover .matcha {
	filter: none;
}

.brand-name {
	font-size: 1.25rem;
	font-weight: 700;
}

.main-menu {
	position: absolute;
	top: 3.5rem;
	inset-inline: -1rem;
	display: none;
	flex-direction: column;
	align-items: flex-end;
	gap: 1rem;
	padding: 1rem 0;
	border-radius: 0.375rem;
	color: hsl(var(--theme-accent));
	background: hsl(var(--theme-bg) / 0.85);
	backdrop-filter: blur(8px);
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.site-header.menu-open .main-menu {
	display: flex;
	z-index: 50;
}

.main-menu-link {
	padding: 1rem;
}

.mobile-menu-button {
	position: relative;
	margin-inline-start: 1rem;
	width: 1.75rem;
	height: 1.75rem;
}

.mobile-menu-button svg {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	transition: all 0.2s ease;
}

.mobile-menu-button .icon-cross {
	color: hsl(var(--theme-accent));
	transform: scale(0);
	opacity: 0;
}

.mobile-menu-button[aria-expanded="true"] .icon-hamburger {
	transform: scale(0);
	opacity: 0;
}

.mobile-menu-button[aria-expanded="true"] .icon-cross {
	transform: scale(1);
	opacity: 1;
}

@media (min-width: 640px) {
	.site-header {
		padding-inline-start: 4.5rem;
	}
	.site-header-brand {
		flex-direction: column;
		position: relative;
	}
	.brand-link {
		display: inline-block;
	}
	.matcha {
		position: absolute;
		top: 50%;
		inset-inline-start: -4.5rem;
		margin-inline-end: 0;
		width: 4rem;
		height: 5rem;
		transform: translateY(-50%);
	}
	.brand-name {
		font-size: 1.5rem;
	}
	.main-menu {
		position: static;
		display: flex;
		flex-direction: row;
		align-items: center;
		gap: 0;
		margin-inline-start: -1rem;
		margin-top: 0.25rem;
		padding: 0;
		inset: auto;
		background: transparent;
		box-shadow: none;
		backdrop-filter: none;
	}
	.main-menu-link {
		padding: 0 1rem;
		border-inline-end: 1px dashed hsl(var(--theme-accent));
	}
	.main-menu-link:last-child {
		border-inline-end: 0;
	}
	.main-menu-link:hover {
		text-decoration: underline;
	}
	.mobile-menu-button {
		display: none;
	}
}

/* -- icon buttons -------------------------------------------------------- */
.icon-button {
	position: relative;
	width: 2.25rem;
	height: 2.25rem;
	border-radius: 0.375rem;
	padding: 0.5rem;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: box-shadow 0.15s ease;
}

.icon-button:hover {
	box-shadow: 0 0 0 2px hsl(220deg 9% 46%);
}

.icon-button[disabled] {
	cursor: default;
}

.icon-lg {
	width: 1.75rem;
	height: 1.75rem;
}

.theme-toggle {
	margin-inline-start: 0.5rem;
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
	position: absolute;
	inset-inline-start: 50%;
	top: 50%;
	width: 1.75rem;
	height: 1.75rem;
	transform: translate(-50%, -50%) scale(1);
	transition: all 0.2s ease;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
	transform: translate(-50%, -50%) scale(0);
	opacity: 0;
}

:root[data-theme="light"] .theme-toggle .icon-moon {
	transform: translate(-50%, -50%) scale(0);
	opacity: 0;
}

@media (min-width: 640px) {
	.theme-toggle {
		margin-inline-start: 1rem;
	}
}

/* -- search -------------------------------------------------------------- */
.site-search {
	margin-inline-start: auto;
}

.search-dialog {
	width: 100%;
	max-width: 100%;
	height: 100%;
	max-height: 100%;
	margin: 0;
	padding: 0;
	border: 1px solid hsl(220deg 9% 64%);
	background: hsl(var(--theme-bg));
	color: hsl(var(--theme-text));
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.search-dialog::backdrop {
	backdrop-filter: blur(4px);
}

.search-dialog-frame {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	padding: 3rem 1.5rem 1.5rem;
}

.search-close {
	margin-inline-start: auto;
	padding: 0.5rem;
	border-radius: 0.375rem;
	font-weight: 600;
	background: hsl(220deg 14% 90%);
}

:root[data-theme="dark"] .search-close {
	background: hsl(215deg 14% 28%);
}

.search-input {
	font: inherit;
	color: inherit;
	width: 100%;
	padding: 0.75rem 1rem;
	border: 1px solid hsl(220deg 9% 64%);
	border-radius: 0.375rem;
	background: transparent;
}

.search-input:focus {
	outline: 2px solid hsl(var(--theme-accent));
	outline-offset: 1px;
}

.search-results {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	overflow-y: auto;
}

.search-results li a {
	display: block;
	padding: 0.5rem 0;
}

.search-results strong {
	color: hsl(var(--theme-accent-2));
}

.search-results small {
	color: hsl(var(--theme-text) / 0.75);
}

.search-no-results {
	color: hsl(var(--theme-text) / 0.6);
	text-align: center;
}

@media (min-width: 640px) {
	.search-dialog {
		width: 83%;
		max-width: 48rem;
		height: auto;
		max-height: calc(100% - 8rem);
		min-height: 15rem;
		margin: 4rem auto auto;
		border-radius: 0.375rem;
	}
	.search-dialog-frame {
		padding: 1.5rem;
	}
}

/* -- main content -------------------------------------------------------- */
main {
	flex: 1 0 auto;
}

.section {
	margin-top: 4rem;
}

.section-title {
	font-size: 1.25rem;
	font-weight: 600;
	color: hsl(var(--theme-accent-2));
	margin-bottom: 1rem;
}

/* -- social list --------------------------------------------------------- */
.social-list {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 1rem;
}

.social-list p {
	margin: 0;
}

.social-list ul {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.social-list a {
	display: inline-block;
	padding: 0.25rem;
}

.social-list a:hover {
	color: hsl(var(--theme-link));
}

.social-icon {
	width: 1.5rem;
	height: 1.5rem;
}

/* -- post preview -------------------------------------------------------- */
.post-list {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.post-list-with-desc {
	gap: 1.5rem;
}

.post-list-item {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

@media (min-width: 640px) {
	.post-list-item {
		flex-direction: row;
		flex-wrap: wrap;
		column-gap: 0.75rem;
	}
	.post-list-with-desc .post-preview-desc {
		flex-basis: 100%;
	}
}

.post-preview-date {
	min-width: 120px;
	color: hsl(var(--theme-text) / 0.7);
}

.post-preview-title {
	margin: 0;
	font-weight: 700;
}

.post-preview-desc {
	margin: 0;
	font-style: italic;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* -- link list (experiments, talks) -------------------------------------- */
.link-list {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.link-list-item {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.link-list-item dt {
	font-weight: inherit;
}

.link-list-item dd {
	margin: 0;
}

@media (min-width: 768px) {
	.link-list-item {
		flex-direction: row;
		gap: 0.5rem;
	}
}

/* -- post page ----------------------------------------------------------- */
.post-container {
	display: block;
}

.post-article {
	word-break: break-word;
	min-width: 0;
}

@media (min-width: 1024px) {
	.post-container {
		display: flex;
		align-items: flex-start;
		column-gap: 2.5rem;
	}
	.post-article {
		flex: 1 1 auto;
	}
}

.post-description {
	font-style: italic;
	color: hsl(var(--theme-text) / 0.85);
	margin: 0.25rem 0 0.5rem;
}

.post-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	column-gap: 0.75rem;
	row-gap: 0.5rem;
}

.post-meta .post-date {
	font-weight: 600;
}

.post-updated {
	padding: 0.25rem;
	border-radius: 0.375rem;
	color: hsl(var(--theme-quote));
	background: hsl(var(--theme-quote) / 0.1);
}

.post-tags {
	margin-top: 0.75rem;
}

.icon-tag {
	width: 1.5rem;
	height: 1.5rem;
	display: inline-block;
	vertical-align: middle;
	margin-inline-end: 0.25rem;
}

.tag-link::before {
	content: "#";
}

.draft-tag {
	color: hsl(0deg 84% 60%);
}

/* -- TOC ----------------------------------------------------------------- */
.toc {
	display: none;
}

.toc h2 {
	font-weight: 700;
	font-size: 0.875rem;
	margin: 0 0 1rem;
	color: hsl(var(--theme-accent-2));
}

.toc ul {
	font-size: 0.8125rem;
	line-height: 1.5;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.toc ul ul {
	padding-inline-start: 1rem;
	margin-top: 0.5rem;
	gap: 0.375rem;
}

.toc a {
	color: hsl(var(--theme-text) / 0.8);
}

.toc a:hover {
	color: hsl(var(--theme-link));
}

@media (min-width: 1024px) {
	.toc {
		display: block;
		position: sticky;
		top: 5rem;
		order: 2;
		flex: 0 0 16rem;
		margin-inline-end: -8rem;
	}
}

/* -- back to top --------------------------------------------------------- */
.back-to-top {
	position: fixed;
	bottom: 2rem;
	inset-inline-end: 1rem;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2.5rem;
	height: 2.5rem;
	border-radius: 9999px;
	font-size: 1.875rem;
	background: hsl(220deg 14% 90%);
	border: 2px solid transparent;
	transform: translateY(7rem);
	opacity: 0;
	transition: all 0.3s ease;
	z-index: 90;
}

:root[data-theme="dark"] .back-to-top {
	background: hsl(215deg 14% 34%);
}

.back-to-top:hover {
	border-color: hsl(220deg 9% 64%);
}

.back-to-top[data-show="true"] {
	transform: translateY(0);
	opacity: 1;
}

.back-to-top svg {
	width: 1.5rem;
	height: 1.5rem;
}

@media (min-width: 640px) {
	.back-to-top {
		inset-inline-end: 2rem;
		width: 3rem;
		height: 3rem;
	}
}

/* -- posts index --------------------------------------------------------- */
.posts-layout {
	display: grid;
	row-gap: 4rem;
}

.tags-aside h2 {
	display: flex;
	align-items: center;
	font-size: 1.125rem;
	font-weight: 600;
	margin-bottom: 1rem;
}

.tag-pill-list {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.tag-pill {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.25rem 0.5rem;
	border-radius: 0.5rem;
	background: hsl(var(--theme-accent));
	color: hsl(var(--theme-bg));
}

.view-all {
	display: block;
	margin-top: 1rem;
}

.view-all a:hover {
	color: hsl(var(--theme-accent));
}

@media (min-width: 640px) {
	.posts-layout {
		grid-template-columns: 3fr 1fr;
		column-gap: 2rem;
	}
	.view-all {
		text-align: end;
	}
}

/* -- tags index ---------------------------------------------------------- */
.tag-count-list {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.tag-count-item {
	display: flex;
	align-items: center;
	column-gap: 0.5rem;
}

/* -- paginator ----------------------------------------------------------- */
.paginator {
	display: flex;
	margin-top: 3rem;
}

.paginator-prev {
	margin-inline-end: auto;
}

.paginator-next {
	margin-inline-start: auto;
}

.paginator a:hover {
	color: hsl(var(--theme-link));
}

/* -- book + reading ------------------------------------------------------ */
.book-page,
.reading-page {
	display: flex;
	flex-direction: column;
	gap: 1.5rem;
}

.book-cover {
	display: flex;
	justify-content: center;
}

.book-cover img {
	max-width: 300px;
}

.bullet-list {
	list-style: disc;
	padding-inline-start: 1.25rem;
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

/* -- footer -------------------------------------------------------------- */
.site-footer {
	margin-top: auto;
	padding: 5rem 0 1rem;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	text-align: center;
	font-weight: 600;
	color: hsl(var(--theme-text) / 0.75);
}

:root[data-theme="dark"] .site-footer {
	color: hsl(var(--theme-text) / 0.65);
}

.site-footer-nav {
	display: flex;
	column-gap: 0.5rem;
}

.site-footer-nav a {
	padding: 0.5rem 1rem;
}

@media (min-width: 640px) {
	.site-footer {
		flex-direction: row;
		justify-content: space-between;
		font-size: 0.75rem;
	}
	.site-footer-nav {
		column-gap: 0;
	}
	.site-footer-nav a {
		padding: 0 1rem;
		border-inline-end: 1px solid hsl(var(--theme-text) / 0.5);
	}
	.site-footer-nav a:last-child {
		border-inline-end: 0;
	}
	.site-footer-nav a:hover {
		color: hsl(var(--theme-text));
		text-decoration: underline;
	}
}

/* -- prose --------------------------------------------------------------- */
.prose {
	margin-top: 3rem;
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
	color: hsl(var(--theme-text));
	line-height: 1.75;
}

.prose > * {
	margin: 0;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
	position: relative;
	font-weight: 700;
	color: hsl(var(--theme-accent-2));
	margin-top: 1rem;
	line-height: 1.3;
}

.prose .heading-anchor {
	color: inherit;
	background: none;
	text-decoration: none;
}

.prose .heading-anchor::before {
	content: "#";
	position: absolute;
	inset-inline-start: -1rem;
	color: hsl(var(--theme-accent));
}

.prose .heading-anchor:hover::before {
	color: hsl(var(--theme-link));
}

.prose h1 { font-size: 1.75rem; }
.prose h2 { font-size: 1.375rem; }
.prose h3 { font-size: 1.125rem; }
.prose h4 { font-size: 1rem; }

.prose p {
	margin: 0;
}

.prose a {
	background-size: 100% 6px;
	background-position: bottom;
	background-repeat: repeat-x;
	background-image: linear-gradient(
		transparent,
		transparent 5px,
		hsl(var(--theme-text)) 5px,
		hsl(var(--theme-text))
	);
	color: inherit;
}

.prose a:hover {
	background-image: linear-gradient(
		transparent,
		transparent 4px,
		hsl(var(--theme-link)) 4px,
		hsl(var(--theme-link))
	);
}

.prose strong {
	font-weight: 700;
}

.prose blockquote {
	margin: 1rem 0;
	padding: 0 1rem;
	color: hsl(var(--theme-quote));
	border-inline-start: 0;
	font-style: italic;
}

.prose blockquote p {
	margin: 0.25rem 0;
}

.prose ul,
.prose ol {
	padding-inline-start: 1.5rem;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }

.prose li::marker {
	color: hsl(var(--theme-text));
}

.prose code {
	font-family: var(--font-mono);
	font-size: 0.875rem;
	padding: 0 0.15rem;
	border: 1px dotted hsl(220deg 9% 46%);
	border-radius: 2px;
}

.prose pre {
	margin: 1rem 0;
	padding: 1rem;
	border-radius: 4px;
	overflow-x: auto;
	font-size: 0.875rem;
	line-height: 1.7;
}

.prose pre code {
	border: 0;
	padding: 0;
	background: transparent;
	border-radius: 0;
}

.prose img {
	margin: 1rem 0;
}

.prose hr {
	border: 0;
	border-top: 1px dashed hsl(var(--theme-text) / 0.5);
	margin: 1.5rem 0;
}

.prose table {
	width: 100%;
	border-collapse: collapse;
	margin: 1rem 0;
}

.prose thead th {
	font-weight: 700;
	border-bottom: 1px dashed hsl(220deg 9% 46%);
	text-align: start;
	padding: 0.5rem;
}

.prose tbody td {
	padding: 0.5rem;
}

.prose tfoot {
	border-top: 1px dashed hsl(220deg 9% 46%);
}

.prose sup {
	margin-inline-start: 0.125rem;
}

.prose sup a {
	background: none;
}

.prose sup a::before { content: "["; }
.prose sup a::after { content: "]"; }

.prose sup a:hover {
	color: hsl(var(--theme-link));
	background: none;
	text-decoration: none;
}

.prose > :first-child {
	margin-top: 0;
}

/* Shiki emits both --shiki-light and --shiki-dark inline variables on every
   span when configured with defaultColor: false. Swap which one wins based
   on the current data-theme attribute. */

:root[data-theme="light"] .shiki,
:root[data-theme="light"] .shiki span {
	color: var(--shiki-light) !important;
	background-color: var(--shiki-light-bg) !important;
	font-style: var(--shiki-light-font-style) !important;
	font-weight: var(--shiki-light-font-weight) !important;
	text-decoration: var(--shiki-light-text-decoration) !important;
}

:root[data-theme="dark"] .shiki,
:root[data-theme="dark"] .shiki span {
	color: var(--shiki-dark) !important;
	background-color: var(--shiki-dark-bg) !important;
	font-style: var(--shiki-dark-font-style) !important;
	font-weight: var(--shiki-dark-font-weight) !important;
	text-decoration: var(--shiki-dark-text-decoration) !important;
}

