/* ── CSS Custom Properties ─────────────────────────────────────────────── */
:root {
	--color-bg: #f5f3ef;
	--color-surface: #ffffff;
	--color-text: #2c2c2c;
	--color-text-muted: #6b6b6b;
	--color-accent: #4a6fa5;
	--color-accent-hover: #3a5a8a;
	--color-border: #e0ddd7;
	--radius: 8px;
	--shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
	--shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.12);
	--max-width: 1200px;
	--header-height: 64px;
}

/* ── Reset & Base ──────────────────────────────────────────────────────── */
*,
*::before,
*::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

body {
	font-family:
		-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
		Cantarell, sans-serif;
	background: var(--color-bg);
	color: var(--color-text);
	line-height: 1.5;
	min-height: 100vh;
}

/* ── Header ────────────────────────────────────────────────────────────── */
.app-header {
	position: sticky;
	top: 0;
	z-index: 10;
	background: var(--color-surface);
	border-bottom: 1px solid var(--color-border);
	padding: 0 24px;
	height: var(--header-height);
	display: flex;
	align-items: center;
	gap: 24px;
	box-shadow: var(--shadow);
}

.app-header h1 {
	font-size: 1.25rem;
	font-weight: 600;
	white-space: nowrap;
}

#search {
	flex: 1;
	max-width: 400px;
	height: 40px;
	padding: 0 16px;
	border: 1px solid var(--color-border);
	border-radius: 20px;
	font-size: 0.95rem;
	background: var(--color-bg);
	outline: none;
	transition: border-color 0.2s;
}

#search:focus {
	border-color: var(--color-accent);
}

/* ── Book Grid ─────────────────────────────────────────────────────────── */
main {
	max-width: var(--max-width);
	margin: 0 auto;
	padding: 24px;
}

.book-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	gap: 20px;
}

.book-card {
	background: var(--color-surface);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	overflow: hidden;
	text-decoration: none;
	color: inherit;
	transition:
		box-shadow 0.2s,
		transform 0.15s;
	display: flex;
	flex-direction: column;
}

.book-card:hover {
	box-shadow: var(--shadow-hover);
	transform: translateY(-2px);
}

.book-card-cover {
	width: 100%;
	aspect-ratio: 2 / 3;
	object-fit: cover;
	background: var(--color-bg);
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--color-text-muted);
	font-size: 2.5rem;
}

.book-card-cover img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.book-card-info {
	padding: 12px 14px;
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.book-card-title {
	font-size: 0.9rem;
	font-weight: 600;
	line-height: 1.3;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.book-card-author {
	font-size: 0.8rem;
	color: var(--color-text-muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ── Empty / Error / Loading States ───────────────────────────────────── */
.empty-state {
	text-align: center;
	padding: 64px 24px;
	color: var(--color-text-muted);
}

.empty-state h2 {
	margin-bottom: 8px;
	color: var(--color-text);
}

.empty-state .empty-icon {
	font-size: 3rem;
	margin-bottom: 12px;
}

.hidden {
	display: none !important;
}

/* ── Spinner ───────────────────────────────────────────────────────────── */
@keyframes spin {
	from {
		transform: rotate(0deg);
	}
	to {
		transform: rotate(359deg);
	}
}

.spinner {
	display: inline-block;
	animation: spin 1.2s linear infinite;
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
	.app-header {
		padding: 0 12px;
		gap: 12px;
	}
	.app-header h1 {
		font-size: 1.1rem;
	}
	.book-grid {
		grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
		gap: 12px;
	}
	main {
		padding: 12px;
	}
}
