/* ============================================================
   Emad Study Guide — Enhanced Stylesheet
   ============================================================ */

/* --- Fonts (Google Fonts via CDN — works offline with system fallbacks) --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Source+Code+Pro:wght@400;500&family=Playfair+Display:wght@600;700;800&display=swap');

:root {
	/* Palette */
	--bg: #f5f0e6;
	--surface: #fffbf4;
	--surface-alt: #f9f4ea;
	--surface-strong: #ede4d0;
	--text: #1a1d21;
	--text-secondary: #3d4148;
	--muted: #6b737d;
	--accent: #0e7c6b;
	--accent-light: #14b8a6;
	--accent-strong: #0d5d53;
	--accent-bg: rgba(14, 124, 107, 0.07);
	--accent-bg-hover: rgba(14, 124, 107, 0.13);
	--border: #d5c8ab;
	--border-light: #e6dbc4;
	--code-bg: #1b2530;
	--code-text: #e8edf3;
	--code-keyword: #7dd3fc;
	--code-string: #a5d6a7;
	--code-comment: #6b7d8e;
	--warn: #c2410c;
	--warn-bg: rgba(194, 65, 12, 0.06);
	--success: #16a34a;
	--success-bg: rgba(22, 163, 74, 0.06);
	--shadow-sm: 0 2px 8px rgba(41, 37, 27, 0.04);
	--shadow: 0 8px 32px rgba(41, 37, 27, 0.07);
	--shadow-lg: 0 16px 48px rgba(41, 37, 27, 0.10);
	--radius: 16px;
	--radius-sm: 10px;
	--max-width: 1120px;
	--transition: 0.2s ease;
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	scroll-behavior: smooth;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	font-size: 115%;
}

body {
	margin: 0;
	font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	color: var(--text);
	background:
		radial-gradient(ellipse at 0% 0%, rgba(14, 124, 107, 0.10), transparent 45%),
		radial-gradient(ellipse at 100% 100%, rgba(194, 65, 12, 0.04), transparent 40%),
		linear-gradient(175deg, #faf7f0 0%, var(--bg) 100%);
	background-attachment: fixed;
	line-height: 1.72;
	font-size: 1rem;
}

::selection {
	background: rgba(14, 124, 107, 0.22);
	color: var(--text);
}

/* --- Links --- */
a {
	color: var(--accent-strong);
	text-decoration-thickness: 1px;
	text-underline-offset: 2px;
	transition: color var(--transition);
}

a:hover {
	color: var(--accent-light);
}

a:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 3px;
	border-radius: 4px;
}

/* --- Layout --- */
header,
main,
footer {
	width: min(calc(100% - 2.5rem), var(--max-width));
	margin: 0 auto;
}

header {
	padding: 3.5rem 0 2rem;
}

main {
	padding-bottom: 5rem;
}

/* --- Shared Card Styles --- */
.hero,
.content-card,
.subject-nav,
.diagram,
.todo,
.note,
.timeline {
	background: var(--surface);
	border: 1px solid var(--border-light);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	transition: box-shadow var(--transition), border-color var(--transition);
}

/* --- Hero --- */
.hero {
	padding: 2.5rem 2.25rem 2rem;
	position: relative;
	overflow: hidden;
}

.hero::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 4px;
	background: linear-gradient(90deg, var(--accent), var(--accent-light), var(--accent));
	border-radius: var(--radius) var(--radius) 0 0;
}

/* --- Typography --- */
.hero p,
.content-card p,
.subject-grid p,
.todo li,
li {
	font-size: 1rem;
	color: var(--text-secondary);
}

.hero>p:first-of-type,
.content-card>p:first-of-type {
	color: var(--text);
}

code,
pre {
	font-size: 0.92rem;
}

h1,
h2,
h3 {
	font-family: 'Playfair Display', 'Palatino Linotype', 'Book Antiqua', Palatino, serif;
	letter-spacing: -0.01em;
	color: var(--text);
	line-height: 1.3;
}

h1 {
	font-size: clamp(2.4rem, 4.5vw, 3.6rem);
	font-weight: 800;
	margin-bottom: 0.6rem;
	background: linear-gradient(135deg, var(--text) 60%, var(--accent-strong));
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
}

h2 {
	font-size: 1.65rem;
	font-weight: 700;
	margin-top: 2.8rem;
	padding-bottom: 0.45rem;
	border-bottom: 2px solid var(--border-light);
	position: relative;
}

h2::after {
	content: '';
	position: absolute;
	bottom: -2px;
	left: 0;
	width: 48px;
	height: 2px;
	background: var(--accent);
	border-radius: 1px;
}

h3 {
	font-size: 1.2rem;
	font-weight: 700;
	margin-top: 2rem;
	color: var(--accent-strong);
}

.eyebrow {
	text-transform: uppercase;
	letter-spacing: 0.14em;
	font-size: 0.75rem;
	font-weight: 600;
	color: var(--accent);
	margin-bottom: 0.3rem;
}

/* --- Meta pills --- */
.meta,
.subject-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 0.6rem;
	padding: 0;
	list-style: none;
	margin-top: 1.2rem;
}

.meta li,
.subject-meta li {
	background: var(--accent-bg);
	color: var(--accent-strong);
	padding: 0.35rem 0.85rem;
	border-radius: 999px;
	font-size: 0.82rem;
	font-weight: 500;
	letter-spacing: 0.01em;
	border: 1px solid rgba(14, 124, 107, 0.12);
}

/* --- Subject Grid (Index Page) --- */
.subject-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 1.1rem;
	margin: 2.4rem 0 3.5rem;
}

.subject-grid article {
	background: var(--surface);
	border: 1px solid var(--border-light);
	border-radius: var(--radius-sm);
	padding: 1.25rem 1.35rem;
	transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
	position: relative;
}

.subject-grid article:hover {
	transform: translateY(-3px);
	box-shadow: var(--shadow-lg);
	border-color: var(--accent);
}

.subject-grid article::after {
	content: '\2192';
	position: absolute;
	top: 1.25rem;
	right: 1.25rem;
	font-size: 1.1rem;
	color: var(--muted);
	opacity: 0;
	transition: opacity var(--transition), transform var(--transition);
}

.subject-grid article:hover::after {
	opacity: 1;
	transform: translateX(3px);
}

.subject-grid h2 {
	margin-top: 0;
	font-size: 1.1rem;
	border-bottom: 0;
	padding-bottom: 0;
	line-height: 1.4;
}

.subject-grid h2::after {
	display: none;
}

.subject-grid h2 a {
	text-decoration: none;
	color: var(--text);
	transition: color var(--transition);
}

.subject-grid h2 a:hover {
	color: var(--accent);
}

.subject-grid p {
	margin: 0.5rem 0 0;
	font-size: 0.92rem;
	line-height: 1.55;
}

/* --- Content Cards --- */
.content-card,
.todo,
.note,
.timeline,
.subject-nav {
	padding: 1.5rem 1.6rem;
}

.content-card {
	margin-bottom: 1.6rem;
}

.content-card ul,
.todo ul,
.timeline ul {
	padding-left: 1.3rem;
}

.content-card ul li,
.todo ul li,
.timeline ul li {
	margin-bottom: 0.35rem;
}

/* --- Diagrams --- */
.diagram {
	padding: 1.2rem 1.4rem;
	margin: 1.2rem 0;
	overflow-x: auto;
	background: var(--surface-alt);
	border: 1px dashed var(--border);
}

.diagram pre {
	margin: 0;
	white-space: pre-wrap;
	font-family: 'Source Code Pro', 'Courier New', monospace;
	font-size: 0.88rem;
	background: transparent;
	color: var(--text);
	padding: 0;
	border-radius: 0;
}

/* --- Notes & Warnings --- */
.note {
	border-left: 4px solid var(--accent);
	background: linear-gradient(90deg, var(--accent-bg), var(--surface) 40%);
	padding: 1.1rem 1.5rem;
	margin: 1.2rem 0;
}

.note p {
	margin: 0;
	color: var(--text-secondary);
	font-style: italic;
}

.warning {
	border-left-color: var(--warn);
	background: linear-gradient(90deg, var(--warn-bg), var(--surface) 40%);
}

/* --- Code Blocks --- */
pre {
	background: var(--code-bg);
	color: var(--code-text);
	padding: 1.2rem 1.4rem;
	border-radius: var(--radius-sm);
	overflow-x: auto;
	border: 1px solid rgba(255, 255, 255, 0.06);
	line-height: 1.6;
	position: relative;
}

pre::before {
	content: 'python';
	position: absolute;
	top: 0.5rem;
	right: 0.75rem;
	font-size: 0.68rem;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: rgba(255, 255, 255, 0.25);
	font-family: 'Inter', sans-serif;
	font-weight: 600;
}

.diagram pre::before {
	content: none;
}

code {
	font-family: 'Source Code Pro', 'Courier New', monospace;
}

p>code,
li>code,
td>code {
	background: var(--accent-bg);
	color: var(--accent-strong);
	padding: 0.15rem 0.45rem;
	border-radius: 5px;
	font-size: 0.88em;
	border: 1px solid rgba(14, 124, 107, 0.10);
}

/* --- Subject Navigation --- */
.subject-nav {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 1rem;
	margin: 2rem 0;
	background: var(--surface-alt);
}

.subject-nav a {
	text-decoration: none;
	font-weight: 600;
	font-size: 0.95rem;
	padding: 0.5rem 1rem;
	border-radius: var(--radius-sm);
	transition: background var(--transition), color var(--transition);
}

.subject-nav a:hover {
	background: var(--accent-bg-hover);
	color: var(--accent-strong);
}

/* --- To-Do / Checklist --- */
.todo {
	margin-top: 2rem;
}

.todo h2 {
	margin-top: 0.5rem;
}

.checklist {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: 1.1rem;
	margin-top: 0.5rem;
}

.checklist section {
	background: var(--accent-bg);
	border: 1px solid rgba(14, 124, 107, 0.10);
	border-radius: var(--radius-sm);
	padding: 1.1rem 1.2rem;
	transition: border-color var(--transition);
}

.checklist section:hover {
	border-color: var(--accent);
}

.checklist h3 {
	margin-top: 0;
	font-size: 1rem;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--accent);
}

.checklist ul {
	padding-left: 1.1rem;
}

.checklist li {
	margin-bottom: 0.4rem;
	font-size: 0.95rem;
}

/* --- Tables --- */
table {
	width: 100%;
	border-collapse: separate;
	border-spacing: 0;
	margin: 1.2rem 0;
	border: 1px solid var(--border-light);
	border-radius: var(--radius-sm);
	overflow: hidden;
}

th,
td {
	padding: 0.8rem 1rem;
	text-align: left;
	vertical-align: top;
	border-bottom: 1px solid var(--border-light);
}

th {
	background: var(--surface-strong);
	font-weight: 600;
	font-size: 0.9rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--accent-strong);
}

td {
	font-size: 0.95rem;
}

tr:last-child td {
	border-bottom: none;
}

tbody tr:hover {
	background: var(--accent-bg);
}

/* --- Timeline --- */
.timeline {
	margin: 1.2rem 0;
	border-left: 3px solid var(--accent);
	padding-left: 1.6rem;
}

.timeline h3 {
	margin-top: 0;
}

.timeline li {
	position: relative;
	padding-left: 0.5rem;
}

/* --- Footer --- */
footer {
	padding: 0 0 3.5rem;
	text-align: center;
	color: var(--muted);
	font-size: 0.9rem;
}

footer p {
	border-top: 1px solid var(--border-light);
	padding-top: 1.5rem;
}

/* --- Scrollbar Enhancement --- */
::-webkit-scrollbar {
	width: 8px;
	height: 8px;
}

::-webkit-scrollbar-track {
	background: transparent;
}

::-webkit-scrollbar-thumb {
	background: var(--border);
	border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
	background: var(--muted);
}

/* --- Print Styles --- */
@media print {
	body {
		background: white;
	}

	.hero,
	.content-card,
	.todo,
	.note,
	.timeline,
	.subject-nav,
	.diagram {
		box-shadow: none;
		border: 1px solid #ccc;
	}

	.subject-grid article:hover {
		transform: none;
	}
}

/* --- Responsive --- */
@media (max-width: 720px) {
	header {
		padding-top: 2rem;
	}

	.hero {
		padding: 1.8rem 1.4rem 1.5rem;
	}

	.content-card,
	.todo,
	.note,
	.timeline,
	.subject-nav {
		padding: 1.1rem 1.15rem;
	}

	.subject-nav {
		flex-direction: column;
		gap: 0.5rem;
	}

	.subject-nav a {
		text-align: center;
	}

	.hero,
	.content-card,
	.subject-nav,
	.todo,
	.note,
	.timeline,
	.diagram {
		border-radius: var(--radius-sm);
	}

	.subject-grid {
		grid-template-columns: 1fr;
	}

	.checklist {
		grid-template-columns: 1fr;
	}

	h1 {
		font-size: 2rem;
	}

	h2 {
		font-size: 1.4rem;
	}

	pre {
		font-size: 0.82rem;
		padding: 1rem;
	}
}

/* --- Theme Headings --- */
.theme-heading {
	font-family: var(--font-display);
	font-size: 1.1rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.12em;
	color: var(--accent);
	margin-top: 3rem;
	margin-bottom: 0.5rem;
	padding-bottom: 0.3rem;
	border-bottom: 2px solid var(--border-light);
}