/*
 * Styling for the bookshelf webapp. The design is intentionally simple and
 * uses only plain CSS – no frameworks – to keep the footprint small. It
 * provides a responsive layout and a modal dialog for book details.
 */

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

body {
	/* Use a warm beige palette and a modern sans serif font for a cosy feel */
	font-family: "Inter", Arial, Helvetica, sans-serif;
	background-color: #f4eee9;
	color: #3b2a23;
	line-height: 1.5;
}

header {
	background: linear-gradient(to bottom, #c4926c 0%, #896845 70%);
	color: #fff7ef;
	padding: 1rem 1.5rem;
	text-align: center;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

header h1 {
	font-size: 2rem;
	font-weight: 600;
	margin-bottom: 0.3rem;
}

header p {
	font-size: 0.95rem;
	opacity: 0.85;
	font-weight: 400;
}

/* Filter controls styling */
#controls {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.5rem 1rem;
	font-size: 0.9rem;
	background-color: #f7f3ee;
	border-bottom: 1px solid #dcd2c5;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

#controls label {
	margin-right: 0.25rem;
}

#controls select {
	padding: 4px 6px;
	font-size: 0.9rem;
}

main {
	padding: 1rem;
}

/* Bookshelf container uses flexbox to arrange book covers. A repeating
  linear gradient on the background simulates wooden shelves by adding
  a thin board at the bottom of each row. The custom property
  --shelf-height should match the height of each book card plus gap
  to align the lines correctly. */
.bookshelf {
	--shelf-height: 250px;
	--shelf-thickness: 25px;
	display: flex;
	flex-wrap: wrap;
	gap: 40px 20px;
	justify-content: center;
	align-items: flex-end;
	padding: 1rem;
	position: relative;
}

/* Shelves overlay using pseudo-element to render on top of books */
.bookshelf::after {
	content: "";
	position: absolute;
	top: 1rem;
	left: 0;
	width: 100%;
	height: calc(100%);
	background-image: repeating-linear-gradient(
		to bottom,
		transparent 0,
		transparent 205px,
		#ecb082 205px,
		#b58a5b 222px,
		#624f42 222px,
		#f4eee9 230px
	);
	background-size: 100% var(--shelf-height);
	pointer-events: none;
}

/* Each spine is a narrow vertical strip. The writing-mode property makes
   the book title run vertically. Rotating 180 degrees improves the reading
   direction so that the text reads bottom to top like a real book spine. */

/* A book card displays the front cover. Hovering slightly enlarges the
   book and increases the shadow. */
/* Book card: 3D block effect with perspective. Each card includes a shadow,
   a subtle tilt, and a faux bottom shelf board underneath. */
/* A book card displays the front cover with a simple drop shadow. Hovering
   moves the book slightly upward and intensifies the shadow. */
.book {
	width: 140px;
	height: 210px;
	border-radius: 5px;
	overflow: hidden;
	position: relative;
	cursor: pointer;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
	transition:
		transform 0.25s ease,
		box-shadow 0.25s ease;
}

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

.book:hover {
	transform: translateY(-6px);
	box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

/* Placeholder for books without covers */
.book-placeholder {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, #8e6c52 0%, #6b5241 100%);
	color: #fff;
	font-size: 0.75rem;
	padding: 0.5rem;
	text-align: center;
	word-wrap: break-word;
	overflow: hidden;
	line-height: 1.3;
}

/* Badge: small label indicating read/unread status. Appears in the
   top left of each book card. */
.badge {
	position: absolute;
	top: 4px;
	left: 4px;
	background: rgba(0, 0, 0, 0.7);
	color: #fff;
	padding: 2px 6px;
	font-size: 0.6rem;
	border-radius: 3px;
	text-transform: uppercase;
	pointer-events: none;
}

.badge.read {
	background: rgba(60, 100, 60, 0.8);
}

.badge.unread {
	background: rgba(100, 60, 60, 0.8);
}

/* Modal overlay: covers the entire viewport with a semi-transparent
   background. Hidden by default via the `.hidden` class. */
.modal {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.5);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	z-index: 1000;
}

.hidden {
	display: none;
}

.modal-content {
	position: relative;
	background: #f8f5f0;
	color: #3b2a23;
	padding: 1.5rem;
	border-radius: 5px;
	max-width: 450px;
	width: 100%;
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
	text-align: center;
}

/* Adjust the modal image to fill more of the card for covers */
.modal-content img {
	max-width: 220px;
	height: auto;
	margin-bottom: 1rem;
	margin-left: auto;
	margin-right: auto;
	display: block;
	border-radius: 4px;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.modal-content h2 {
	margin-bottom: 0.5rem;
	font-size: 1.4rem;
}

/* Author text should be italic for subtle emphasis */
#bookAuthor {
	font-style: italic;
	margin-bottom: 0.5rem;
}

#bookStatus {
	display: inline-block;
	background: rgba(0, 0, 0, 0.7);
	color: #fff;
	padding: 4px 10px;
	font-size: 0.75rem;
	border-radius: 3px;
	text-transform: uppercase;
	margin-bottom: 0.5rem;
}

#bookStatus.read {
	background: rgba(60, 100, 60, 0.8);
}

#bookStatus.unread {
	background: rgba(100, 60, 60, 0.8);
}

.modal-content p {
	margin-bottom: 0;
	font-size: 1rem;
}

/* Close button for modal */
.close {
	position: absolute;
	top: 8px;
	right: 12px;
	font-size: 1.5rem;
	font-weight: bold;
	color: #666;
	cursor: pointer;
	transition: color 0.2s;
}

.close:hover {
	color: #000;
}

/* Responsive adjustments for small screens */
@media (max-width: 600px) {
	.spine {
		width: 24px;
		height: 150px;
		font-size: 0.55rem;
	}
	.modal-content {
		max-width: 90%;
	}
	.modal-content img {
		max-width: 150px;
	}
	header h1 {
		font-size: 1.5rem;
	}
}
