:root {
	/* Colors - Light theme (default) */
	--primary-color: #2d8a6e;
	--secondary-color: #4b5563;
	--dark-blue: #1f2933;

	--background-color: #fbfbf8;
	--surface-color: #ffffff;
	--off-white: #f4f7f5;

	--text-color: #1f2933;
	--text-muted: #5b6770;
	--pure-black: #000000;
	--light-gray: #eef4f1;
	--border-color: #dde5e1;

	/* Hero & Page Header */
	--hero-bg: linear-gradient(135deg, #1f2933 0%, #1a3a3a 100%);
	--page-header-bg: #f0f7f4;
	--page-header-text: #1f2933;

	/* Typography & Layout */
	--font-family: "Poppins", sans-serif;
	--container-width: 1140px;
	--border-radius: 12px;

	/* Shadows */
	--shadow: 0 10px 30px rgba(31, 51, 41, 0.08);
}

/* Dark theme applied via class on <html> */
html.dark {
	--primary-color: #6ed3ae;
	--secondary-color: #aab7b8;
	--dark-blue: #0f1a17;
	--pure-black: #ffffff;

	--background-color: #0b1411;
	--surface-color: #162521;
	--off-white: #0b1411;

	--text-color: #e0eae5;
	--text-muted: #9fb7ad;

	--light-gray: #20332c;
	--border-color: #2d4039;

	/* Hero & Page Header */
	--hero-bg: linear-gradient(135deg, #162521 0%, #1a3a2e 100%);
	--page-header-bg: #162521;
	--page-header-text: #e0eae5;

	--shadow: 0 14px 40px rgba(0, 0, 0, 0.65);
}

/* =========================
   GLOBAL STYLES
   ========================= */
* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

html {
	scroll-behavior: smooth;
	font-size: 100%;
}

body {
	font-family: var(--font-family);
	line-height: 1.6; /* Standardized for Poppins */
	color: var(--text-color);
	background-color: var(--background-color);
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	-webkit-font-smoothing: antialiased;
}

main {
	flex-grow: 1;
}

.container {
	max-width: var(--container-width);
	margin: 0 auto;
	padding: 0 15px; /* Increased slightly for better mobile gutters */
}

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

/* =========================
   HEADER & NAVIGATION
   ========================= */
.header {
	background-color: var(--surface-color);
	box-shadow: var(--shadow);
	padding: 10px 0; /* Tightened padding */
	position: sticky;
	top: 0;
	z-index: 1000;
}

.navbar {
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.logo {
	display: flex;
	align-items: center;
	gap: 12px;
	text-decoration: none;
	color: var(--text-color);
	font-size: 1.25rem;
	font-weight: 700;
}

.logo img {
	height: 45px;
	width: auto;
}

.nav-menu {
	display: flex;
	align-items: center;
	gap: 30px;
}

.nav-links {
	display: flex;
	list-style: none;
	gap: 30px;
}

.nav-links a {
	text-decoration: none;
	color: var(--text-color);
	font-weight: 500;
	position: relative;
	padding: 5px 0;
	transition: color 0.3s ease;
}

.nav-links a::after {
	content: "";
	position: absolute;
	bottom: 0;
	left: 0;
	width: 0;
	height: 2px;
	background-color: var(--primary-color);
	transition: width 0.3s ease;
}

.nav-links a:hover {
	color: var(--primary-color);
}

.nav-links a:hover::after {
	width: 100%;
}

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

.dropdown-menu {
	display: none;
	position: absolute;
	top: 100%;
	left: 0;
	background-color: var(--surface-color);
	list-style: none;
	min-width: 200px;
	padding: 10px 0;
	box-shadow: var(--shadow);
	border-radius: var(--border-radius);
	z-index: 999;
	border: 1px solid var(--border-color);
}

.dropdown-menu a {
	display: block;
	padding: 10px 20px;
	color: var(--text-color);
	text-decoration: none;
	transition: background 0.2s;
}

.dropdown-menu a:hover {
	background-color: var(--light-gray);
	color: var(--primary-color);
}

.dropdown:hover .dropdown-menu {
	display: block;
}

/* =========================
   HAMBURGER
   ========================= */
.hamburger {
	display: none;
	cursor: pointer;
	background: none;
	border: none;
	padding: 5px;
}

.hamburger .bar {
	display: block;
	width: 25px;
	height: 3px;
	margin: 5px 0;
	background-color: var(--text-color);
	transition: all 0.3s ease;
	border-radius: 3px;
}

.hamburger.active .bar:nth-child(2) {
	opacity: 0;
}
.hamburger.active .bar:nth-child(1) {
	transform: translateY(8px) rotate(45deg);
}
.hamburger.active .bar:nth-child(3) {
	transform: translateY(-8px) rotate(-45deg);
}

/* =========================
   THEME TRANSITION
   ========================= */
body,
.header,
.footer,
.semester-card,
.subject-card,
.chapter-card,
.year-sidebar,
.main-content-area,
.dropdown-menu,
.nav-menu,
.page-header,
.exam-paper,
.exam-instructions,
.answer,
.question-number {
	transition:
		background-color 0.35s ease,
		color 0.35s ease,
		border-color 0.35s ease,
		box-shadow 0.35s ease;
}

/* =========================
   THEME TOGGLE
   ========================= */
.theme-toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	background: none;
	border: 2px solid var(--border-color);
	border-radius: 50%;
	width: 40px;
	height: 40px;
	cursor: pointer;
	color: var(--text-color);
	transition:
		background-color 0.3s ease,
		color 0.3s ease,
		border-color 0.3s ease,
		transform 0.3s ease;
	flex-shrink: 0;
}

.theme-toggle:hover {
	background-color: var(--light-gray);
	border-color: var(--primary-color);
	color: var(--primary-color);
	transform: rotate(15deg);
}

.theme-icon {
	width: 20px;
	height: 20px;
}

/* Light mode: show moon (click to go dark), hide sun */
.sun-icon {
	display: none;
}
.moon-icon {
	display: block;
}

/* Dark mode: show sun (click to go light), hide moon */
html.dark .sun-icon {
	display: block;
}
html.dark .moon-icon {
	display: none;
}

/* =========================
   BUTTONS
   ========================= */
.btn {
	padding: 12px 28px;
	border-radius: var(--border-radius);
	font-weight: 600;
	border: 2px solid transparent;
	cursor: pointer;
	transition: all 0.3s ease;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.btn-primary {
	background-color: var(--primary-color);
	color: #ffffff !important;
}

.btn-primary:hover {
	filter: brightness(1.1);
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(63, 174, 143, 0.3);
}

.btn-secondary {
	background: transparent;
	color: var(--primary-color);
	border-color: var(--primary-color);
}

.btn-secondary:hover {
	background-color: var(--primary-color);
	color: #ffffff;
}

/* =========================
   PAGE HEADER
   ========================= */
.page-header {
	background-color: var(--page-header-bg);
	color: var(--page-header-text);
	padding: 0px 15px;
	text-align: center;
	border-bottom: 4px solid var(--primary-color);
	transition:
		background-color 0.35s ease,
		color 0.35s ease,
		border-color 0.35s ease;
}

/* =========================
   FOOTER
   ========================= */
.footer {
	background-color: var(--surface-color);
	color: var(--text-color);
	padding: 40px 0 20px;
	margin-top: auto;
}

.footer-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 40px;
	margin-bottom: 40px;
}

.footer-links-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0;
}

.footer-column {
	display: flex;
	flex-direction: column;
}

.footer-heading {
	color: var(--text-color);
	font-size: 1.1rem;
	font-weight: 700;
	margin-bottom: 20px;
	position: relative;
	text-transform: uppercase;
	letter-spacing: 1px;
}

.footer-heading::after {
	content: "";
	width: 30px;
	height: 2px;
	background-color: var(--primary-color);
	position: absolute;
	bottom: -5px;
	left: 0;
}

.footer-about {
	color: var(--text-muted);
	line-height: 1.6;
	font-size: 0.95rem;
}

.footer-links {
	list-style: none;
}

.footer-links li {
	margin-bottom: 12px;
}

.footer-links a {
	color: var(--text-muted);
	text-decoration: none;
	transition:
		color 0.3s ease,
		padding-left 0.3s ease;
}

.footer-links a:hover {
	color: var(--primary-color);
	padding-left: 5px;
}

.social-icons {
	display: flex;
	gap: 15px;
	margin-top: 15px;
}

.social-icons a img {
	width: 24px;
	height: 24px;
	transition: transform 0.3s ease;
}

.social-icons a:hover img {
	transform: translateY(-3px);
}

.footer-bottom {
	border-top: 1px solid var(--border-color);
	text-align: center;
	padding-top: 20px;
	font-size: 0.85rem;
	color: var(--text-muted);
}

.footer-legal-links {
	margin-top: 6px;
}

.footer-legal-links a,
.footer-legal-links a:visited {
	color: var(--text-muted);
	text-decoration: none;
	transition:
		color 0.3s ease,
		padding-left 0.3s ease;
}

.footer-legal-links a:hover {
	color: var(--primary-color);
	padding-left: 5px;
}

.footer-dot {
	margin: 0 6px;
}

/* =========================
   MEDIA QUERIES
   ========================= */
@media (max-width: 768px) {
	.hamburger {
		display: block;
	}

	.nav-menu {
		position: fixed;
		top: 0;
		right: -100%; /* Fully hidden off-screen */

		height: 100vh;
		background-color: var(--surface-color);
		flex-direction: column;
		padding: 100px 30px;
		transition:
			right 0.4s cubic-bezier(0.4, 0, 0.2, 1),
			background-color 0.35s ease;
		box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
	}

	.nav-menu.active {
		right: 0;
	}

	.nav-links {
		flex-direction: column;
		width: 100%;
		gap: 20px;
	}

	.nav-links a {
		font-size: 1.1rem;
		width: 100%;
	}

	.dropdown-menu {
		position: static;
		box-shadow: none;
		border: none;
		padding-left: 20px;
		display: block; /* Show links in mobile drawer */
		background: transparent;
	}
	.page-header h1 {
		padding-top: 10px;
		font-size: 1.5rem;
	}
	.page-header p {
		font-size: 1rem;
	}
}

@media (max-width: 480px) {
	.footer-grid {
		grid-template-columns: 1fr;
	}

	.footer-column:nth-child(4) {
		display: none;
	}
}

.subject-nav-section {
	background-color: var(--off-white);
	padding: 20px 0;
	border-bottom: 1px solid var(--border-color);
	transition:
		background-color 0.35s ease,
		border-color 0.35s ease;
}

.subject-nav {
	display: flex;
	justify-content: center;
	gap: 15px;
	flex-wrap: wrap;
}

.subject-nav .btn-primary {
	box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
	transition: transform 0.3s ease;
}

@media (max-width: 767px) {
	.subject-nav {
		flex-wrap: nowrap;
		overflow-x: auto;
		gap: 10px;
	}

	.subject-nav .btn {
		padding: 8px 14px;
		font-size: 0.85rem;
		white-space: nowrap;
		flex-shrink: 0;
	}
}
