/*
 * SPDX-License-Identifier: MIT
 * Copyright (c) 2025 Runxi Yu <https://runxiyu.org>
 * Copyright (c) 2024 Drew Devault <https://drewdevault.com>
 */

/* Base styles */
html {
	font-family: system-ui, sans-serif;
	--bg: hsl(32, 98%, 92%);
	--fg: #1E1F21;
	--boxbg: hsl(32, 60%, 88%);
	--border: rgb(180, 180, 180);
	--border-radius: .32rem;
	--dim-text-color: #333;
	--link-color: #24527d;
	--text-decoration-color: #CCC;
	color: var(--fg);
	background-color: var(--bg);
}
@media(prefers-color-scheme:dark) {
	html {
		--bg: #1E1F21;
		--fg: #EEEFF1;
		--dim-text-color: #999;
		--boxbg: #2E2F31;
		--border: rgb(80, 80, 80);
		--link-color: #5ca7ed;
		--text-decoration-color: #474747;
	}
}

/* Font styles */
code, pre, .monospace {
	font-family: "Inconsolata", "DejaVu Sans Mono", monospace;
}

/* Font-related customizations for particular text types */
.literary, .serif {
	font-family: "TeX Gyre Pagella", "Palatino", serif;
}
.chinese, .fat-lines {
	line-height: 1.5em;
}
.poem {
	max-width: 35rem;
	white-space: nowrap;
}

/* Body width and centering */
body {
	margin: 0 auto;
	padding: 1rem;
	max-width: 920px;
}

body.wider-body {
	max-width: 1150px;
}

/* Headings */
h1 {
	margin-top: 0;
	font-size: 1.5rem;
}

/* Flex columns */
.flexcols {
	display: flex;
	flex-direction: row;
	gap: 5rem;
	align-items: top;
}

@media(max-width: 50rem) {
	.flexcols {
		flex-wrap: wrap;
		gap: 3rem;
	}
}

.flexcols > .flexcol {
	min-width: 18em;
	width: 100%;
	margin-left: auto;
	margin-right: auto;
}

/* Index Page Styles */
.index .article-list .article {
	margin-bottom: 1rem;
}

.index .article-list .date {
	display: block;
	color: var(--dim-text-color);
}

.index aside {}

.index aside img {
	display: block;
	margin: 0 auto 1rem;
	border-radius: 5px;
}

.index aside dt {
	font-size: .9rem;
}

.index aside dd {
	margin-left: 0;
}

.index aside dd:not(:last-child) {
	margin-bottom: .5rem;
}

.index aside ul {
	margin-left: 0;
	padding-left: 1.5rem;
}

.index aside ul > li + li {
	margin-top: .3rem;
	margin-left: 0;
}

@media(max-width: 50rem) {
	.index aside .hide-when-narrow {
		display: none;
	}
}

/* Article Styles */
article {
	margin: 0 auto;
	max-width: 720px;
	line-height: 1.3;
}

article img, article video, article iframe {
	display: block !important;
	margin: 0 auto !important;
	max-width: 90%;
}

@media(max-width: 640px) {
	article img, article video, article iframe {
		max-width: calc(100% - 2rem);
	}
}

article sup {
	line-height: 1;
}

article .comment {
	margin: 2rem auto 0;
	max-width: 80%;
	color: var(--dim-text-color);
}

/* Link Styles */
a:link {
	text-decoration-color: var(--text-decoration-color);
	color: var(--link-color);
}

a:visited {
	text-decoration-color: var(--text-decoration-color);
	color: var(--link-color);
}

/* Footnote Styles */
.footnotes {
	font-size: .85rem;
}

/* Footer Styles */
footer {
	margin-top: 2rem;
	text-align: center;
	font-size: .8rem;
	color: var(--dim-text-color);
}

/* Float Image Styles */
.float-img {
	float: right;
	display: inline;
	padding-left: 1rem;
}

@media(max-width: 640px) {
	.float-img {
		display: block;
		float: none;
		padding-left: inherit;
	}
}

/* Preformatted Text Styles */
pre {
	background-color: #272822;
	padding: .25rem 1rem;
	margin: 0 -1rem;
	max-width: 100%;
	overflow-x: auto;
}

/* Summary/Details Styles */
summary {
	cursor: pointer;
	background-color: var(--boxbg);
	padding: .25rem 1rem;
	margin: 0 -1rem;
}

details[open] {
	border-bottom: 1rem solid var(--boxbg);
	margin: 0 -1rem 1rem;
	padding: 0 1rem;
}

/* Text Alignment Styles */
.text-center {
	text-align: center;
}

/* Blockquote Styles */
blockquote {
	background-color: var(--boxbg);
	padding: 3px;
	margin-left: 0;
	margin-right: 0;
}

blockquote ul {
	margin-top: 0;
	margin-bottom: 0;
	margin-left: 0;
}

blockquote blockquote {
	margin-right: 0;
	margin-left: 0;
}

blockquote p:first-child {
	margin-top: 0;
}

blockquote p:last-child {
	margin-bottom: 0;
}

/* Definition List Styles */
dl {
	display: grid;
	grid-template-columns: auto 1fr;
	grid-gap: .2rem 1rem;
}

dl dt {
	font-weight: 700;
	grid-column-start: 1;
}

dl dd {
	grid-column-start: 2;
	margin: 0;
}

/* Alert Box Styles */
.alert {
	padding: .5rem;
	border: 1px solid transparent;
	margin-bottom: 1rem;
}

.alert.alert-danger {
	background: #f8d7da;
	color: #721c24;
	border-color: #f5c6cb;
}

.alert.alert-info {
	background: #d1ecf1;
	color: #0c5460;
	border-color: #bee5eb;
}

/* Opacity Styles */
.almost-transparent {
	opacity: 10%;
}

.almost-transparent:hover {
	opacity: 50%;
}

/* Index Text Area Styles */
.index-text-area {
	opacity: 50%;
	margin-top: 2rem;
}

/* Table Styles */
table {
	margin-top: 0.4em;
	font-size: 90%;
	margin-bottom: 0.4em;
	border: var(--border) solid 1px;
	border-spacing: 0;
	border-radius: var(--border-radius);
	border-collapse: separate;
	overflow: hidden;
}

table.wide {
	width: 100%;
}

table > tr:not(:last-child) > td,
table > tr:not(:last-child) > th,
table > thead,
table > thead > tr > th,
table > thead > tr > td,
table > tbody,
table > tbody > tr:not(:last-child) > th,
table > tbody > tr:not(:last-child) > td,
table > tfoot > tr:not(:last-child) > th,
table > tfoot > tr:not(:last-child) > td,
table > tfoot:not(:last-child) {
	border-bottom: var(--border) solid 1px;
}

table td:not(:last-child),
table th:not(:last-child) {
	border-right: var(--border) solid 1px;
}

th[scope~="row"] {
	text-align: left;
}

td {
	text-align: left;
	height: 1.25rem;
	padding: 3px 5px;
}

table.fat td {
	padding: 6px 5px;
}

td.th-like, th {
	background-color: var(--boxbg) !important;
	font-weight: bold;
	padding: 3px 5px;
}

th.min, td.min {
	width: 0;
	min-width: fit-content;
	white-space: nowrap;
}

/* Workaround for Firefox bug 217769 */
tbody:empty {
	display: none;
}

table > tbody:after {
	content: "";
}

/* 
 * vim: ts=8 sw=8 noexpandtab
 */
