/* COLOR VARIABLES ========================= */
:root {
	--bg: #f5f5f5;
	--text: #333;
	--meta: #777;
	--link: #0066cc;
	--link-visited: #6a0dad;
	--border: #ddd;
	--blockquote-border: #ccc;
	--blockquote-text: #555;
	--page-pad: 20px;
	--side-w: 220px;
	--side-gap: 40px;
}

/* DARK MODE ========================= */
html.dark {
	color-scheme: dark;

	--bg: #0f1115;
	--text: #e6e6e6;
	--meta: #9aa0a6;
	--link: #8ab4f8;
	--link-visited: #c084fc;
	--border: #2a2f36;
	--blockquote-border: #3b3f45;
	--blockquote-text: #b6bcc6;
}

/* FONT ========================= */
@font-face {
	font-family: "Lato";
	src: url("../res/fonts/Lato-Regular.ttf") format("truetype");
	font-weight: 400;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "Lato";
	src: url("../res/fonts/Lato-Italic.ttf") format("truetype");
	font-weight: 400;
	font-style: italic;
	font-display: swap;
}

@font-face {
	font-family: "Lato";
	src: url("../res/fonts/Lato-Bold.ttf") format("truetype");
	font-weight: 700;
	font-style: normal;
	font-display: swap;
}

/* BASE LAYOUT ========================= */
html { background: var(--bg); }

body {
	container-type: inline-size;
	font-family: 'Lato', Arial, sans-serif;
	background: var(--bg);
	color: var(--text);
	max-width: 1060px;
	margin-inline: auto;
	padding: 0 var(--page-pad);
	line-height: 1.7;
	font-size: 16px;
}

section {
	scroll-margin-top: 10px;
}

h1, h2, h3 { margin-top: 30px; }
h2 {
	border-bottom: 1px solid var(--border);
	padding-bottom: 5px;
}

.meta {
	color: var(--meta);
	font-size: 14px;
	margin-bottom: 25px;
}

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

p { margin-bottom: 18px; }

blockquote {
	border-left: 4px solid var(--blockquote-border);
	padding-left: 16px;
	margin: 25px 0;
	color: var(--blockquote-text);
	font-style: italic;
}

blockquote p { margin-bottom: 0; }
cite { font-size: 14px; }

img, video, iframe { border-radius: 8px; }

hr {
	border: none;
	border-top: 1px solid var(--border);
	margin: 40px 0;
}

footer {
	margin-block: 40px;
	font-size: 12px;
	color: var(--meta);
	text-align: center;
}

/* LAYOUT: content column + sticky right sidebar ========================= */
.layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) var(--side-w);
	column-gap: var(--side-gap);
	align-items: start;
}

.layout:has(> .sidebar.compact) { --side-w: 180px; --side-gap: 32px; }

.layout > main { min-width: 0; margin-top: 40px; }
.layout > main > :first-child { margin-block: 0; }
.layout > main > section:first-child { padding-top: 0; }
.layout > main > section:first-child > h2:first-child { margin-top: 0; }

/* SIDEBAR ========================= */
.sidebar {
	position: sticky;
	top: 24px;
	max-height: calc(100vh - 48px);
	overflow-y: auto;
	box-sizing: border-box;
	z-index: 5;
	background: var(--bg);
	margin-top: -12px;
	padding: 12px 12px 12px 24px;
	border-left: 1px solid var(--border);
	font-size: 14px;
	line-height: 1.6;
	scrollbar-width: none;
	-ms-overflow-style: none;
}

.sidebar::-webkit-scrollbar {
	display: none;
}

.sidebar a,
.sidebar a:visited { color: var(--text); }
.sidebar a:hover { color: var(--link); }

.brand {
	display: block;
	margin-bottom: 14px;
}

.brand:hover { text-decoration: none; }

.brand-name {
	font-size: 18px;
	font-weight: 700;
}

.avatar {
	display: block;
	width: 100%;
	aspect-ratio: 3 / 3.5;
	margin-bottom: 14px;
	border-radius: 6px;
	overflow: hidden;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.avatar img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	scale: 1.7;
	border-radius: 0;
}

.sidebar .tagline {
	margin: 0 0 8px;
	color: var(--meta);
}

.sidebar .bio { margin: 0 0 24px; }

.side-group {
	display: flex;
	flex-direction: column;
	margin-bottom: 20px;
}

.sidebar .side-label {
	margin: 0 0 2px;
	color: var(--meta);
	font-size: 12px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.side-group a[aria-current] { font-weight: 700; }

.sidebar .social a { color: var(--link); }
.sidebar .social a:visited { color: var(--link-visited); }
.sidebar .social a:hover { color: var(--link); }

.side-tools {
	display: flex;
	gap: 18px;
}

#theme-toggle {
	background: none;
	border: none;
	padding: 0;
	font: inherit;
	color: var(--link);
	cursor: pointer;
}

#theme-toggle:hover {
	background: var(--link);
	color: var(--bg);
}

/* ARTICLES SECTION ========================= */
.articles nav {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 1rem;
}

.articles ul {
	list-style: none;
	padding: 0;
	margin: 0;
}

.articles.archive ul {
	columns: 2 18rem;
	column-gap: 2rem;
}

.articles ul li {
	display: flex;
	gap: 1.25rem;
	break-inside: avoid;
}

.articles ul time {
	flex: none;
	opacity: 0.6;
	font-variant-numeric: tabular-nums;
}

.articles .year {
	font-weight: bold;
	margin-top: 1rem;
	break-after: avoid;
}

.articles .series-group {
	align-items: flex-start;
}

.articles .series-block {
	flex: 1;
	min-width: 0;
}

.articles .series-name {
	font-weight: 700;
}

.articles .series-count {
	margin-left: 0.6rem;
	color: var(--meta);
	font-size: 13px;
}

.articles .parts {
	margin: 0.15rem 0 0.5rem;
	padding-left: 0.9rem;
	border-left: 2px solid var(--border);
}

.articles .parts li {
	gap: 0.75rem;
}

.articles .part-no {
	flex: none;
	min-width: 3.2rem;
	color: var(--meta);
	font-size: 14px;
}

.articles .series-block ul.parts {
	columns: auto;
}

.articles .series-block a,
.articles .series-name {
	overflow-wrap: anywhere;
}

/* BLOGROLL ========================= */
.blogroll {
	list-style: none;
	padding: 0;
	margin: 0;
	columns: 2 18rem;
	column-gap: 32px;
}

.blogroll li {
	break-inside: avoid;
	padding: 8px 0;
	border-bottom: 1px solid var(--border);
}

.blogroll a {
	font-weight: 700;
}

.blogroll span {
	display: block;
	color: var(--meta);
	font-size: 14px;
	line-height: 1.5;
}

/* PROJECTS SECTION ========================= */
.projects-grid {
	margin-top: 25px;
	columns: 160px;
	column-gap: 16px;
}

.project {
	display: block;
	break-inside: avoid;
	margin-bottom: 16px;
	text-decoration: none;
	border-radius: 8px;
}
.project:hover { background: rgba(0,0,0,0.02); }

.project img {
	display: block;
	object-fit: cover;
	width: 100%;
	margin: 0;
	transition: transform 0.35s ease;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
.project:hover img { transform: translateY(-5px); }

/* NOW SECTION ========================= */
.now-grid {
	display: grid;
	grid-template-columns: repeat(2,1fr);
	gap: 18px;
	margin-top: 25px;
}

.now-card {
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: 16px;
}

.now-card h3 {
	margin: 0 0 8px 0;
	font-size: 16px;
}

.now-card p {
	margin: 0;
	font-size: 14px;
}

/* BOOKS SECTION ========================= */
.books-grid {
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	gap: 32px 20px;
	margin-top: 25px;
}

.book-card {
	width: 100%;
	height: 100%;
	text-align: center;
}

.book-card img {
	width: 100%;
	aspect-ratio: 2 / 3;
	object-fit: cover;
	transition: transform 0.3s ease;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.book-card img:hover {
	transform: translateY(-5px);
}

.book-card h3 {
	font-size: 15px;
	margin: 10px 0 4px 0;
	color: var(--text);
}

.book-card .author {
	font-size: 13px;
	color: var(--meta);
	margin: 0;
}

/* RESPONSIVE DESIGN ========================= */
@container (max-width: 759px) {
	.layout:has(> .sidebar.compact) { grid-template-columns: minmax(0, 1fr); }

	.sidebar.compact {
		text-align: left;
		position: static;
		order: -1;
		max-height: none;
		overflow: visible;
		margin-top: 0;
		display: flex;
		flex-wrap: wrap;
		align-items: baseline;
		gap: 6px 22px;
		margin-bottom: 28px;
		padding: 0 0 14px;
		border-left: none;
		border-bottom: 1px solid var(--border);
	}

	.sidebar.compact .brand { margin: 0; }

	.sidebar.compact .side-group {
		align-items: normal;
		flex-direction: row;
		flex-wrap: wrap;
		gap: 0 16px;
		margin: 0;
	}

	.sidebar.compact .side-tools { margin-left: auto; justify-content: flex-start; }
}

@container (max-width: 779px) {
	.layout { grid-template-columns: minmax(0, 1fr); }

	.sidebar {
		text-align: left;
		position: static;
		order: -1;
		max-height: none;
		overflow: visible;
		margin-top: 0;
		margin-bottom: 32px;
		padding: 0 0 20px;
		border-left: none;
		border-bottom: 1px solid var(--border);
	}

	.side-tools { justify-content: flex-start; }

	.avatar { max-width: 240px; }

	.sidebar .bio { margin-bottom: 18px; }

	.side-group {
		align-items: normal;
		flex-direction: row;
		flex-wrap: wrap;
		gap: 0 16px;
		margin-bottom: 14px;
	}

	.sidebar .side-label { flex-basis: 100%; }
}

@media (max-width: 768px) {
	body {
		max-width: 90%;
	}

	.now-grid { grid-template-columns: 1fr; }

	.books-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
}

@media (max-width: 650px) {
	.projects-grid { columns: 100px; }
}

@media (max-width: 520px) {
	.articles .series-group {
		flex-direction: column;
		gap: 0.1rem;
		margin-top: 0.4rem;
	}

	.articles .parts {
		margin-bottom: 0.4rem;
	}

	.articles .parts li {
		gap: 0.6rem;
	}

	.articles .part-no {
		min-width: 2.8rem;
		font-size: 13px;
	}
}

@media (max-width: 425px) {
	:root { --page-pad: 16px; }

	body {
		font-size: 15px;
	}

	h1 { font-size: 26px; }
	h2 { font-size: 22px; }
	h3 { font-size: 18px; }

	.now-card { padding: 14px; }
	.now-card h3 { font-size: 15px; }
	.now-card p { font-size: 14px; }

	.projects-grid { columns: 120px; }
}
