/* 1. ROOT & GENERAL STYLES
/* =================================== */
:root {
	--background: #fafafa;
	--text-primary: #2d3748;
	--text-secondary: #4a5568;
	--accent-primary: #4c51bf;
	--accent-secondary: #667eea;
	--border-color: #e2e8f0;
	--shadow-color: rgba(0, 0, 0, 0.1);
}

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

body {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
	line-height: 1.7;
	color: var(--text-primary);
	background-color: var(--background);
	font-size: 16px;
	overflow-x: hidden;
}

/* 2. LAYOUT & MAIN WRAPPERS
/* =================================== */
.wrapper {
	max-width: 800px;
	margin: 0 auto;
	padding: 4rem 1.5rem 2rem; /* Add padding to account for fixed controls */
}

/* Base styles for decorative elements, to be customized by themes */
.corner, .separator, .header-decoration-top, .header-decoration-bottom, .footer-decoration-top, .footer-decoration-bottom, .window {
	display: none; /* Hidden by default, enabled by theme */
}

/* 3. FIXED UI ELEMENTS
/* =================================== */

/* Progress Bar */
.progress-bar {
	position: fixed;
	top: 0;
	left: 0;
	width: 0%;
	height: 4px;
	background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
	z-index: 2000;
	transition: width 0.15s ease;
}

/* Navigation Controls */
.controls {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.button {
	background: var(--background);
	color: var(--text-secondary);
	border: 1px solid var(--border-color);
	padding: 0.5rem 1rem;
	border-radius: 6px;
	cursor: pointer;
	transition: all 0.2s ease;
	box-shadow: 0 2px 4px var(--shadow-color);
	display: flex;
	align-items: center;
	gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
}

.button:hover {
	border-color: var(--accent-primary);
	color: var(--accent-primary);
}

/* Dropdown Theme Switcher */
.dropdown {
	position: relative;
}

.dropdown-trigger {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0.5rem 1rem;
	background: var(--background);
	border: 1px solid var(--border-color);
	border-radius: 6px;
	cursor: pointer;
	box-shadow: 0 2px 4px var(--shadow-color);
    font-size: 0.95rem;
    font-weight: 600;
}

.dropdown-menu {
	display: none;
	position: absolute;
	right: 0;
	top: calc(100% + 5px);
	background: var(--background);
	border: 1px solid var(--border-color);
	border-radius: 6px;
	box-shadow: 0 8px 16px var(--shadow-color);
	min-width: 160px;
	padding: 0.5rem;
	z-index: 1;
    margin-top: 0.1rem;
    overflow: auto;
    max-height: 400px;
}

.dropdown:hover .dropdown-menu {
	display: block; /* Simple hover effect */
}

.dropdown-item {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0.5rem 0.75rem;
	cursor: pointer;
	border-radius: 4px;
	transition: background-color 0.2s;
}

.dropdown-item:hover {
	background-color: #f1f5f9;
}

/* Status Bar */
.statusbar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #f1f5f9;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    z-index: 1000;
}


/* 4. HEADER, FOOTER & SECTIONS
/* =================================== */
.header {
	text-align: center;
	padding: 1rem 0;
	border-bottom: 2px solid var(--border-color);
	margin-bottom: 2rem;
}

.title-main {
	font-size: 3rem;
	font-weight: bold;
	color: var(--accent-primary);
}

.subtitle {
	font-size: 1.2rem;
	color: var(--text-secondary);
	margin-top: 0.5rem;
}

.footer {
	text-align: center;
	margin-top: 2rem;
	padding-top: 1rem;
	border-top: 2px solid var(--border-color);
	color: var(--text-secondary);
}

.category {
	margin-bottom: 1.5rem;
}

.title-category {
	font-size: 1.8rem;
	margin-bottom: 1.5rem;
	padding-bottom: 0.5rem;
	border-bottom: 3px solid var(--accent-secondary);
	display: inline-flex;
	align-items: center;
	gap: 10px;
}

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


/* 5. BLOG POST GRID & CARDS
/* =================================== */
.grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
	gap: 1.5rem;
}

.card {
	border: 1px solid var(--border-color);
	border-radius: 12px;
	padding: 1.5rem;
	transition: all 0.3s ease;
	box-shadow: 0 2px 8px var(--shadow-color);
	display: flex;
	flex-direction: column;
}

.card:hover {
	transform: translateY(-4px);
	box-shadow: 0 8px 25px rgba(76, 81, 191, 0.15);
}

.card-title {
	font-size: 1.3rem;
	font-weight: 600;
	margin: 0 0 0.5rem 0;
	color: var(--text-primary);
}

.card-path {
	font-size: 0.85rem;
	font-family: 'Courier New', monospace;
	color: var(--text-secondary);
	background: #f1f5f9;
	padding: 0.25rem 0.5rem;
	border-radius: 4px;
	word-break: break-all;
}

.card-meta {
	margin-top: 1rem;
	font-size: 0.9rem;
	color: var(--text-secondary);
}

.card-actions {
	margin-top: auto; /* Pushes button to the bottom */
	padding-top: 1rem;
	display: flex;
	justify-content: flex-end;
}

.button-read {
	border: none;
	font-size: 0.9rem;
	background: var(--accent-primary);
	color: white;
}

.button-read:hover {
	background: var(--accent-secondary);
	color: white;
}


/* 6. IMAGE MODAL
/* =================================== */
.modal {
	display: none;
	position: fixed;
	z-index: 2000;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	overflow: auto;
	opacity: 0;
	transition: opacity 0.3s ease;
}

.modal.modal-open {
	display: flex;
	opacity: 1;
}

.modal-overlay {
	position: absolute;
	width: 100%;
	height: 100%;
	background-color: rgba(0, 0, 0, 0.9);
	backdrop-filter: blur(5px);
}

.modal-container {
	position: relative;
	margin: auto;
	max-width: 90%;
	max-height: 90%;
	animation: zoomIn 0.3s ease;
}

.modal-close {
	position: absolute;
	top: -40px;
	right: 0;
	background: none;
	border: none;
	color: #fff;
	font-size: 2.5rem;
	cursor: pointer;
	z-index: 1;
}

.modal-content .image {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	border-radius: 8px;
	box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.image-caption {
	color: #fff;
	text-align: center;
	margin-top: 15px;
	font-style: italic;
	background: rgba(0, 0, 0, 0.7);
	padding: 10px;
	border-radius: 6px;
}

.spinner,
.modal-spinner { /* Support both class names */
	border: 4px solid rgba(255, 255, 255, 0.3);
	border-top: 4px solid #fff;
	border-radius: 50%;
	width: 40px;
	height: 40px;
	animation: spin 1s linear infinite;
	margin: auto;
}


/* 7. DYNAMICALLY LOADED MARKDOWN CONTENT
/* =================================== */

/* Apply styles only to content inside the main wrapper */
.wrapper h1, .wrapper h2, .wrapper h3, .wrapper h4, .wrapper h5, .wrapper h6 {
	font-weight: 600;
	margin: 2rem 0 1rem 0;
	line-height: 1.3;
}

.wrapper h1 {
	font-size: 2.5rem;
	border-bottom: 3px solid var(--border-color);
	padding-bottom: 0.5rem;
}

/* Override for first h1 to match old style */
.wrapper h1:first-child {
	text-align: center !important;
	border: none !important;
	color: var(--accent-primary) !important;
}

.wrapper h2 { font-size: 2rem; }
.wrapper h3 { font-size: 1.5rem; }
.wrapper h4 { font-size: 1.25rem; }
.wrapper p { margin: 1.2rem 0; text-align: justify; }
.wrapper a { color: var(--accent-primary); text-decoration: none; border-bottom: 1px solid transparent; transition: all 0.2s ease; }
.wrapper a:hover { color: var(--accent-secondary); border-bottom-color: var(--accent-primary); }
.wrapper ul, .wrapper ol { margin: 1.2rem 0; padding-left: 2rem; }
.wrapper li { margin: 0.5rem 0; }
.wrapper blockquote { margin: 2rem 0; padding: 1rem 1.5rem; background: #f7fafc; border-left: 4px solid var(--accent-primary); font-style: italic; }
.wrapper code { background: #f1f5f9; color: #e53e3e; padding: 0.2rem 0.4rem; border-radius: 4px; font-family: 'Monaco', monospace; font-size: 0.9rem; }
.wrapper pre { background: #1a202c; color: #e2e8f0; padding: 1.5rem; border-radius: 8px; overflow-x: auto; margin: 2rem 0; }
.wrapper pre code { background: transparent; color: inherit; padding: 0; }
.wrapper table { width: 100%; border-collapse: collapse; margin: 2rem 0; box-shadow: 0 2px 4px var(--shadow-color); }
.wrapper th, .wrapper td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--border-color); }
.wrapper th { background: #f8f9fa; font-weight: 600; }
.wrapper img { max-width: 100%; height: auto; border-radius: 8px; margin: 1.5rem 0; box-shadow: 0 4px 8px var(--shadow-color); cursor: pointer; transition: transform 0.2s ease; }
.wrapper img:hover { transform: scale(1.02); }
.wrapper hr { border: none; height: 2px; background: linear-gradient(90deg, transparent, var(--border-color), transparent); margin: 3rem 0; }


/* 8. HELPER & MESSAGE CLASSES
/* =================================== */
.message {
	text-align: center;
	padding: 3rem;
	font-style: italic;
	color: #666;
	border-radius: 8px;
}

.message-error {
	color: #dc3545;
	background-color: #f8d7da;
	border: 1px solid #f5c6cb;
}


/* 9. ANIMATIONS & RESPONSIVE DESIGN
/* =================================== */
@keyframes zoomIn {
	from { transform: scale(0.5); opacity: 0; }
	to { transform: scale(1); opacity: 1; }
}

@keyframes spin {
	to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
	.wrapper { padding: 5rem 1rem 2rem; }
	.title-main, .wrapper h1 { font-size: 2.5rem; }
	.grid { grid-template-columns: 1fr; gap: 1rem; }
	.wrapper h1 { font-size: 2rem; }
	.wrapper h2 { font-size: 1.5rem; }
}