/* CSS Custom Properties for theming */
:root {
	/* Light theme colors */
	--bg-color: #ffffff;
	--text-color: #000000;
	--text-secondary: #333333;
	--text-muted: #666666;
	--text-light: #888888;
	--link-color: #0066cc;
	--link-hover: #0052a3;
	--border-color: #000000;
	--tag-bg: #eeeeee;
	--tag-text: #000000;
	--theme-btn-bg: #f5f5f5;
	--theme-btn-hover: #e0e0e0;
	--theme-btn-text: #333333;
	--org-link-color: #4d79a4;
	--org-link-hover: #3d5998;
}

/* Dark theme colors */
[data-theme="dark"] {
	--bg-color: #1a1a1a;
	--text-color: #e0e0e0;
	--text-secondary: #d0d0d0;
	--text-muted: #b0b0b0;
	--text-light: #888888;
	--link-color: #4d9eff;
	--link-hover: #66b3ff;
	--border-color: #e0e0e0;
	--tag-bg: #2d2d2d;
	--tag-text: #e0e0e0;
	--theme-btn-bg: #2d2d2d;
	--theme-btn-hover: #3d3d3d;
	--theme-btn-text: #e0e0e0;
	--org-link-color: #7ba7d7;
	--org-link-hover: #8bb5e3;
}

html {
	margin: 0;
	/* font-family: "Computer Modern Sans", sans-serif; */
	font-family: "Fira Sans", "Liberation Sans", sans-serif;
	color: var(--text-color);
	background-color: var(--bg-color);
	transition: background-color 0.3s ease, color 0.3s ease;
}

body {
	margin: 1em;
	display: flex;
	flex-direction: column;
	gap: 0.8em;
}

p,
blockquote,
h1,
h2,
h3 {
	margin: 0;
}

li {
	margin: 0;
}

section {
	h2 {
		border-bottom: solid 1.5px var(--border-color);
		margin-bottom: 0.4em;
		transition: border-color 0.3s ease;
	}
	> ul {
		padding-inline-start: 0;
		list-style-type: none;
		display: flex;
		flex-direction: column;
		gap: 0.8em;
	}
}

header {
	display: flex;
	flex-direction: row;
	align-items: baseline;
	gap: 0.5em;
	
	* {
		display: inline-block;
	}

	> address {
		font-size: 0.9em;
	}
	
	.date {
		font-family: "Courier New", Courier, monospace;
		font-size: 0.9em;
	}
}

/* Main header styling */
body > header {
	flex-direction: column;
	align-items: flex-start;
	gap: 0.2em;
	max-width: 100%;
	
	h1 {
		font-size: 1.5em;
		font-weight: 600;
		max-width: 100%;
		word-wrap: break-word;
	}
	
	address {
		font-style: normal;
		max-width: 100%;
		overflow-wrap: break-word;
		word-break: break-word;
		line-height: 1.4;
		
		a {
			color: var(--link-color);
			text-decoration: none;
			position: relative;
			transition: color 0.3s ease;
			display: inline-block;
			max-width: 100%;
			overflow-wrap: break-word;
		}
		
		a::after {
			content: '';
			position: absolute;
			width: 0;
			height: 1px;
			bottom: -2px;
			left: 0;
			background-color: var(--link-hover);
			transition: width 0.3s ease;
		}
		
		a:hover {
			color: var(--link-hover);
		}
		
		a:hover::after {
			width: 100%;
		}
	}
}

img.logo {
	width: 1em;
	height: 1em;
	filter: grayscale(0.6);
	border-radius: 2px;
}

ul {
	padding-inline-start: 20px;
	margin: 0;
	
	li {
		margin: 0;
		
		h3 {
			display: inline-block;
		}
	}
}

ul.tag-list {
	padding: 2px 0;
	padding-top: 4px;
	padding-inline-start: 0;
	display: flex;
	flex-direction: row;
	gap: 10px;
	flex-wrap: wrap;
	
	li {
		display: block;
		padding: 2px 6px;
		border-radius: 2px;
		background-color: var(--tag-bg);
		color: var(--tag-text);
		font-size: 0.8em;
		font-family: "Courier New", Courier, monospace;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		transition: background-color 0.3s ease, color 0.3s ease;
	}
}

section#work,
section#education {
	.date {
		margin-left: auto;
	}
	
	li > header {
		display: flex;
		align-items: center;
		gap: 0.5em;
		margin-bottom: 0.4em;
		
		h3 {
			margin: 0;
		}
		
		span:not(.date) {
			font-size: 0.9em;
			color: var(--text-muted);
			transition: color 0.3s ease;
		}
	}
	
	li > div {
		margin-left: 1.5em;
	}
}

section#education {
	img.logo {
		display: none;
	}
}

section#projects,
section#skills {
	& > ul {
		display: grid;
		grid-template-columns: 1fr 1fr;
		grid-gap: 0.8em;

		li {
			margin: 0;
			display: block;
			
			h3 {
				margin-bottom: 0.4em;
				
				a {
					color: var(--link-color);
					text-decoration: none;
					font-weight: inherit;
					display: inline-flex;
					align-items: center;
					gap: 0.3em;
					position: relative;
					transition: color 0.3s ease;
				}
				
				a::after {
					content: '';
					position: absolute;
					width: 0;
					height: 1px;
					bottom: -2px;
					left: 0;
					background-color: var(--link-hover);
					transition: width 0.3s ease;
				}
				
				a:hover {
					color: var(--link-hover);
				}
				
				a:hover::after {
					width: calc(100% - 1.2em);
				}
				
				.external-link {
					font-size: 0.8em;
					opacity: 0.7;
					transition: opacity 0.2s ease;
				}
				
				a:hover .external-link {
					opacity: 1;
				}
			}
			
			p {
				margin-bottom: 0.4em;
				font-size: 0.95em;
				line-height: 1.4;
			}
		}
	}
}

section#certifications {
	li {
		h3 {
			margin-bottom: 0.4em;
			
			a {
				color: var(--link-color);
				text-decoration: none;
				font-weight: inherit;
				display: inline-flex;
				align-items: center;
				gap: 0.3em;
				position: relative;
				transition: color 0.3s ease;
			}
			
			a::after {
				content: '';
				position: absolute;
				width: 0;
				height: 1px;
				bottom: -2px;
				left: 0;
				background-color: var(--link-hover);
				transition: width 0.3s ease;
			}
			
			a:hover {
				color: var(--link-hover);
			}
			
			a:hover::after {
				width: calc(100% - 1.2em);
			}
			
			.external-link {
				font-size: 0.8em;
				opacity: 0.7;
				transition: opacity 0.2s ease;
			}
			
			a:hover .external-link {
				opacity: 1;
			}
		}
		
		p {
			margin-bottom: 0.4em;
			font-size: 0.95em;
			line-height: 1.4;
		}
		
		p.org-link {
			a {
				color: var(--org-link-color);
				text-decoration: none;
				position: relative;
				transition: color 0.3s ease;
			}
			
			a::after {
				content: '';
				position: absolute;
				width: 0;
				height: 1px;
				bottom: -1px;
				left: 0;
				background-color: var(--org-link-hover);
				transition: width 0.3s ease;
			}
			
			a:hover {
				color: var(--org-link-hover);
			}
			
			a:hover::after {
				width: 100%;
			}
		}
	}
}

section#basics {
	display: flex;
	flex-direction: column;
	gap: 0.5em;
	
	p {
		font-size: 1.1em;
		color: var(--text-secondary);
		transition: color 0.3s ease;
	}
}

/* Button Container */
.button-container {
	position: fixed;
	top: 1em;
	right: 1em;
	display: flex;
	gap: 0.8em;
	z-index: 1000;
	flex-wrap: wrap;
	align-items: flex-start;
	justify-content: flex-end;
}

button#theme-toggle {
	position: relative;
	top: 0;
	right: 0;
	padding: 8px 16px;
	background: var(--theme-btn-bg);
	color: var(--theme-btn-text);
	border: 1px solid var(--text-muted);
	border-radius: 6px;
	cursor: pointer;
	font-family: "Fira Sans", "Liberation Sans", sans-serif;
	font-size: 0.85em;
	font-weight: 500;
	display: flex;
	align-items: center;
	gap: 8px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	transition: all 0.3s ease;
	min-width: fit-content;
	white-space: nowrap;
	overflow: hidden;
}

button#theme-toggle:hover {
	background: var(--theme-btn-hover);
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

button#theme-toggle:active {
	transform: translateY(0);
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

button#theme-toggle svg {
	flex-shrink: 0;
	transition: transform 0.3s ease;
}

/* Responsive design */
/* Large tablets and small desktops */
@media (max-width: 1024px) {
	body {
		margin: 0.8em;
	}
	
	.button-container {
		top: 0.8em;
		right: 0.8em;
	}
	
	section#projects > ul,
	section#skills > ul {
		grid-gap: 0.8em;
	}
	
	button#theme-toggle {
		padding: 6px 14px;
		font-size: 0.85em;
	}
}

/* Tablets */
@media (max-width: 768px) {
	body {
		margin: 0.6em;
		gap: 0.8em;
	}
	
	.button-container {
		top: 0.6em;
		right: 0.6em;
	}
	
	/* Make grids single column */
	section#projects > ul,
	section#skills > ul {
		grid-template-columns: 1fr;
		grid-gap: 0.8em;
	}
	
	/* Header adjustments */
	body > header {
		text-align: left;
		gap: 0.3em;
		
		h1 {
			font-size: 1.3em;
			line-height: 1.2;
		}
		
		address {
			font-size: 0.85em;
			line-height: 1.4;
			
			/* Add spacing between links */
			a {
				margin-right: 0.5em;
			}
			
			/* Hide separators and stack links on small screens */
			a::before {
				content: '';
				display: block;
				margin: 0.2em 0;
			}
			
			a:first-child::before {
				display: none;
			}
		}
	}
	
	/* Work and education sections */
	section#work li > header,
	section#education li > header {
		flex-direction: column;
		align-items: flex-start;
		gap: 0.2em;
		
		.date {
			margin-left: 0;
			font-size: 0.8em;
			color: var(--text-light);
			transition: color 0.3s ease;
		}
	}
	
	section#work li > div,
	section#education li > div {
		margin-left: 1em;
	}
	
	/* Adjust section headers */
	section h2 {
		font-size: 1.2em;
		margin-bottom: 0.4em;
	}
	
	/* Tag list adjustments */
	ul.tag-list {
		gap: 6px;
		
		li {
			font-size: 0.75em;
			padding: 2px 5px;
		}
	}
	
	/* Button adjustments */
	button#theme-toggle {
		padding: 6px 12px;
		font-size: 0.8em;
		gap: 6px;
		
		svg {
			width: 14px;
			height: 14px;
		}
	}
}

/* Small tablets and large phones */
@media (max-width: 640px) {
	body {
		margin: 0.5em;
		gap: 0.7em;
	}
	
	.button-container {
		top: 0.5em;
		right: 0.5em;
	}
	
	/* Header */
	body > header {
		h1 {
			font-size: 1.2em;
			font-weight: 600;
		}
		
		address {
			font-size: 0.8em;
			word-break: break-word;
			
			/* Hide the separator dots and stack links */
			a {
				display: block;
				margin: 0.1em 0;
			}
			
			/* Hide text nodes (the · separators) */
			text-align: left;
		}
	}
	
	/* Basics section */
	section#basics p {
		font-size: 1em;
		line-height: 1.5;
	}
	
	/* Section spacing */
	section > ul {
		gap: 0.8em;
	}
	
	/* Projects and certifications */
	section#projects li,
	section#certifications li {
		h3 {
			font-size: 1em;
			line-height: 1.3;
			margin-bottom: 0.4em;
		}
		
		p {
			font-size: 0.9em;
			line-height: 1.4;
			margin-bottom: 0.4em;
		}
	}
	
	/* Work experience adjustments */
	section#work li > div,
	section#education li > div {
		margin-left: 0.5em;
	}
	
	/* Button positioning */
	button#theme-toggle {
		padding: 5px 10px;
		font-size: 0.75em;
	}
}

/* Mobile phones */
@media (max-width: 480px) {
	body {
		margin: 0.4em;
		gap: 0.6em;
	}
	
	.button-container {
		top: 0.4em;
		right: 0.4em;
	}
	
	/* Header optimizations */
	body > header {
		h1 {
			font-size: 1.1em;
			line-height: 1.2;
		}
		
		address {
			font-size: 0.75em;
			
			/* Stack contact info vertically on very small screens */
			a {
				display: block;
				margin: 0.2em 0;
				max-width: 100%;
				overflow: hidden;
				text-overflow: ellipsis;
			}
		}
	}
	
	/* Section headers */
	section h2 {
		font-size: 1.1em;
		margin-bottom: 0.3em;
	}
	
	/* Reduce spacing */
	section > ul {
		gap: 0.6em;
	}
	
	/* Work and education */
	section#work li > header,
	section#education li > header {
		gap: 0.1em;
		
		h3 {
			font-size: 0.95em;
		}
		
		span:not(.date) {
			font-size: 0.8em;
		}
		
		.date {
			font-size: 0.75em;
		}
	}
	
	section#work li > div,
	section#education li > div {
		margin-left: 0;
		font-size: 0.9em;
	}
	
	/* Projects and certifications */
	section#projects li,
	section#certifications li {
		h3 {
			font-size: 0.95em;
			
			a {
				line-height: 1.3;
			}
		}
		
		p {
			font-size: 0.85em;
			line-height: 1.4;
		}
	}
	
	/* Skills section */
	section#skills li h3 {
		font-size: 0.95em;
		margin-bottom: 0.3em;
	}
	
	/* Tag lists */
	ul.tag-list {
		gap: 4px;
		
		li {
			font-size: 0.7em;
			padding: 1px 4px;
		}
	}
	
	/* Logo sizing */
	img.logo {
		width: 0.9em;
		height: 0.9em;
	}
	
	/* Button */
	button#theme-toggle {
		padding: 4px 8px;
		font-size: 0.7em;
		gap: 4px;
		
		svg {
			width: 12px;
			height: 12px;
		}
	}
}

/* Stack buttons vertically on very small screens */
@media (max-width: 520px) {
	.button-container {
		flex-direction: column;
		gap: 0.5em;
		align-items: flex-end;
	}
	
	button#theme-toggle {
		padding: 6px 10px;
		font-size: 0.75em;
	}
}

/* Hide button text for small screens */
@media (max-width: 445px) {
	button#theme-toggle {
		padding: 8px;
		width: 40px;
		height: 40px;
		border-radius: 50%;
		justify-content: center;
		font-size: 0;
		gap: 0;
		min-width: 40px;
		max-width: 40px;
		
		svg {
			width: 16px;
			height: 16px;
		}
		
		#theme-text {
			display: none;
		}
	}
}

/* Very small mobile phones */
@media (max-width: 360px) {
	body {
		margin: 0.3em;
		gap: 0.5em;
	}
	
	.button-container {
		top: 0.3em;
		right: 0.3em;
	}
	
	/* Ultra-compact header */
	body > header {
		h1 {
			font-size: 1em;
			font-weight: 600;
		}
		
		address {
			font-size: 0.7em;
			
			a {
				display: block;
				margin: 0.15em 0;
				max-width: 100%;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}
		}
	}
	
	/* Minimal spacing */
	section > ul {
		gap: 0.5em;
	}
	
	section h2 {
		font-size: 1em;
	}
	
	/* Compact text */
	section#work li > header h3,
	section#education li > header h3,
	section#projects li h3,
	section#certifications li h3,
	section#skills li h3 {
		font-size: 0.9em;
	}
	
	/* Ultra-small tags */
	ul.tag-list li {
		font-size: 0.65em;
		padding: 1px 3px;
	}
	
	/* Override button styling for very small screens */
	button#theme-toggle {
		padding: 6px;
		width: 36px;
		height: 36px;
		
		svg {
			width: 14px;
			height: 14px;
		}
	}
}

@media print {
	@page {
		size: A4 portrait;
		margin: 0.4in 0.5in;
		/* Hide browser headers and footers */
		margin-top: 0.2in;
		margin-bottom: 0.2in;
	}
	
	/* Remove browser default headers/footers */
	html {
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}
	
	/* Force light theme for printing */
	* {
		background-color: white !important;
		color: black !important;
	}
	
	button#theme-toggle,
	.button-container,
	#print-modal {
		display: none !important;
		visibility: hidden !important;
	}
	
	a {
		color: #0066cc !important;
		text-decoration: none !important;
	}
	
	a::after {
		display: none !important;
	}
	
	body {
		margin: 0;
		padding: 0;
		font-size: 9px;
		line-height: 1.15;
		background-color: white !important;
		color: black !important;
		gap: 0.3em;
	}
	
	/* Optimize header */
	body > header {
		margin-bottom: 0.2em;
		gap: 0.05em;
		
		h1 {
			font-size: 1.3em;
			font-weight: 600;
			margin-bottom: 0.05em;
		}
		
		address {
			font-size: 0.8em;
			line-height: 1.15;
		}
	}
	
	/* Optimize sections */
	section {
		page-break-inside: avoid;
		margin-bottom: 0.25em;
		
		h2 {
			font-size: 1em;
			margin-bottom: 0.2em;
			border-bottom: 1px solid black !important;
			padding-bottom: 0.05em;
		}
		
		> ul {
			gap: 0.2em;
		}
	}
	
	/* Basics section optimization */
	section#basics {
		margin-bottom: 0.2em;
		
		p {
			font-size: 0.95em;
			line-height: 1.2;
		}
	}
	
	/* Work and Education sections */
	section#work li,
	section#education li {
		margin-bottom: 0.2em;
		
		> header {
			margin-bottom: 0.15em;
			gap: 0.2em;
			
			h3 {
				font-size: 0.95em;
				margin: 0;
			}
			
			span:not(.date) {
				font-size: 0.75em;
			}
			
			.date {
				font-size: 0.75em;
				font-weight: normal;
			}
		}
		
		> div {
			margin-left: 1em;
			
			p {
				font-size: 0.8em;
				line-height: 1.2;
				margin-bottom: 0.15em;
			}
			
			ul {
				margin-bottom: 0.15em;
				
				li {
					font-size: 0.75em;
					line-height: 1.15;
					margin-bottom: 0.05em;
				}
			}
		}
	}
	
	/* Projects section - switch to single column for print */
	section#projects > ul {
		grid-template-columns: 1fr !important;
		gap: 0.15em;
		
		li {
			h3 {
				font-size: 0.9em;
				margin-bottom: 0.1em;
			}
			
			p {
				font-size: 0.8em;
				line-height: 1.15;
				margin-bottom: 0.1em;
			}
		}
	}
	
	/* Certifications - compact layout */
	section#certifications {
		li {
			margin-bottom: 0.15em;
			
			h3 {
				font-size: 0.85em;
				margin-bottom: 0.05em;
			}
			
			p {
				font-size: 0.75em;
				line-height: 1.15;
				margin-bottom: 0.05em;
			}
			
			p.org-link {
				font-size: 0.7em;
				margin-bottom: 0.1em;
			}
		}
	}
	
	/* Skills section - switch to single column for print */
	section#skills > ul {
		grid-template-columns: 1fr !important;
		gap: 0.1em;
		
		li {
			h3 {
				font-size: 0.85em;
				margin-bottom: 0.08em;
			}
		}
	}
	
	/* Tag lists optimization */
	ul.tag-list {
		gap: 3px;
		padding-top: 0.05em;
		
		li {
			font-size: 0.65em;
			padding: 1px 3px;
			background-color: #f5f5f5 !important;
			border: 1px solid #ddd;
			color: black !important;
			margin-bottom: 0;
		}
	}
	
	/* Logo optimization */
	img.logo {
		width: 0.8em;
		height: 0.8em;
	}
	
	/* Remove extra spacing */
	p,
	blockquote,
	h1,
	h2,
	h3 {
		margin: 0;
	}
	
	ul {
		margin: 0;
		padding-inline-start: 16px;
	}
	
	/* Force content to fit on one page */
	html,
	body {
		height: auto !important;
		overflow: visible !important;
	}
}
