/**
 * Library Page Styles
 * Styles for Continue Reading, Reading List, and Bookshelf sections
 */

/* ========================================
   Library Sections
   ======================================== */

.library__section {
	margin-bottom: 4rem;
}

.library__section-kicker {
	display: block;
	margin-bottom: 0.25rem;
}

.library__section-title {
	font-family: "Maax Bold";
	font-weight: 400;
	font-size: 2rem;
	margin: 0 0 1.5rem 0;
	padding-bottom: 1rem;
	border-bottom: 2px solid var(--color-line-3);
	color: var(--color-text);
}

/* ========================================
   Loading, Empty, and Error States
   ======================================== */

.library__carousel-loading,
.library__carousel-empty,
.library__bookshelf-loading,
.library__bookshelf-empty {
	padding: 3rem 1rem;
	text-align: center;
	color: var(--color-text-2);
}

.library__carousel-loading p,
.library__carousel-empty p,
.library__bookshelf-loading p,
.library__bookshelf-empty p {
	margin: 0;
	font-size: 1rem;
	line-height: 1.5;
}

.library__carousel-empty a,
.library__bookshelf-empty a {
	color: var(--color-text);
	text-decoration: underline;
}

.library__carousel-empty a:hover,
.library__bookshelf-empty a:hover {
	color: var(--color-red);
}

/* ========================================
   Card Component (Continue Reading, Reading List)
   Horizontal card: cover left, info right
   ======================================== */

.library__carousel-items {
	display: flex;
	gap: 1.5rem;
	overflow-x: auto;
	overflow-y: hidden;
	padding: 1rem 0;
	-webkit-overflow-scrolling: touch;
	scroll-snap-type: x mandatory;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.library__carousel-items::-webkit-scrollbar {
	display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
.library__carousel-items {
	-ms-overflow-style: none;
	scrollbar-width: none;
}

.library__card {
	flex: 0 0 320px;
	scroll-snap-align: start;
	display: flex;
	gap: 1rem;
	background: var(--color-background);
	border: 1px solid var(--color-line-3);
	border-radius: 4px;
	padding: 1rem;
	transition: border-color 0.2s ease;
}

.library__card:hover {
	border-color: var(--color-line);
}

.library__card-cover {
	flex-shrink: 0;
	width: 100px;
	height: 150px;
	background: var(--color-gray-light);
	border-radius: 2px;
	overflow: hidden;
}

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

.library__card-info {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.library__card-title {
	font-family: "Maax Bold";
	font-weight: 400;
	font-size: 1rem;
	margin: 0 0 0.25rem 0;
	color: var(--color-text);
	line-height: 1.3;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.library__card-subtitle {
	font-size: 0.875rem;
	margin: 0;
	color: var(--color-text-2);
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.library__card-actions {
	margin-top: auto;
	display: flex;
	gap: 0.5rem;
	padding-top: 0.75rem;
}

.library__card-actions .button {
	font-size: 0.8125rem;
	padding: 0.5rem 1rem;
}

/* ========================================
   Bookshelf Grid Layout
   New Auto-filling Grid with Stack Effect
   ======================================== */

.library__bookshelf-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
	gap: 2rem 1.5rem;
	padding: 1rem 0;
	align-items: start;
	position: relative;
}

.library__grid-item {
	display: flex;
	flex-direction: column;
	text-decoration: none;
	color: inherit;
	cursor: pointer;
	position: relative;
}

.library__grid-item .library__grid-item-title {
	text-decoration: none;
	display: inline-block;
}

.library__grid-item:hover .library__grid-item-title {
	text-underline-offset: .3rem;
	text-decoration-line: underline;
	text-decoration-skip-ink: auto;
	text-decoration-style: solid;
	text-decoration-thickness: 2px;
	text-decoration-color: currentColor;
}

.library__grid-item-cover-wrap {
	position: relative;
	width: 100%;
	aspect-ratio: 2 / 3;
	margin-bottom: 0.75rem;
	z-index: 2;
}

/* Stack effect — real images for distinct covers */
.library__grid-item-stack {
	position: absolute;
	width: 100%;
	height: 100%;
	object-fit: cover;
	border: 1px solid var(--color-line-3);
}

.library__grid-item-stack--mid {
	top: -4px;
	left: 4px;
	z-index: 0;
	box-shadow: -2px 2px 4px rgba(0,0,0,0.1);
}

.library__grid-item-stack--back {
	top: -8px;
	left: 8px;
	z-index: -1;
	box-shadow: -2px 2px 6px rgba(0,0,0,0.05);
}

.library__grid-item-cover {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	position: relative;
	z-index: 1;
	background: var(--color-gray-light);
	border: 1px solid var(--color-line-3);
}

.library__grid-item-badge {
	position: absolute;
	top: -10px;
	right: -10px;
	background: var(--color-red);
	color: var(--color-white);
	font-family: "Maax Bold", sans-serif;
	font-size: 0.75rem;
	min-width: 24px;
	height: 24px;
	padding: 0 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10;
	border-radius: 12px;
	border: 2px solid var(--color-background);
	box-sizing: border-box;
	line-height: 1;
	white-space: nowrap;
}

.library__grid-item-title {
	font-family: "Maax Bold";
	font-size: 0.9375rem;
	line-height: 1.2;
	margin: 0;
	color: var(--color-text);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* Dim other items when shelf is open */
.library__bookshelf-grid--shelf-open .library__grid-item {
	opacity: 0.5;
	transition: opacity 0.2s ease;
}

.library__bookshelf-grid--shelf-open .library__grid-item--active {
	opacity: 1;
}

.library__bookshelf-grid {
	transition: padding-bottom 0.25s ease;
}

/* Inline Shelf Setup (Overlay — doesn't push grid items) */
.library__inline-shelf {
	position: absolute;
	left: 0;
	right: 0;
	z-index: 30;
}

.library__inline-shelf-content {
	background: var(--color-background);
	display: flex;
	gap: 1.25rem;
	overflow-x: auto;
	overflow-y: hidden;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
	align-items: stretch;
	border: 1px solid var(--color-line-3);

	/* Animation */
	max-height: 0;
	padding: 0 1.5rem;
	opacity: 0;
	transition: max-height 0.25s cubic-bezier(0.25, 1, 0.5, 1), padding 0.25s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.2s ease;
	pointer-events: none;
}

.library__inline-shelf-content.is-expanded {
	max-height: 500px;
	padding: 1.5rem;
	opacity: 1;
	pointer-events: auto;
}

.library__inline-shelf-item {
	flex: 0 0 100px;
	display: flex;
	flex-direction: column;
	cursor: pointer;
	text-decoration: none;
}

.library__inline-shelf-item-cover {
	width: 100%;
	aspect-ratio: 2 / 3;
	object-fit: cover;
	margin-bottom: 0.5rem;
	border: 1px solid var(--color-line-3);
}

.library__inline-shelf-item-title {
	font-size: 0.75rem;
	font-family: "Maax Bold";
	font-weight: 400;
	color: var(--color-text);
	text-align: center;
	line-height: 1.2;
}

.library__inline-shelf-item:hover .library__inline-shelf-item-title {
	text-underline-offset: .2rem;
	text-decoration-line: underline;
	text-decoration-skip-ink: auto;
	text-decoration-style: solid;
	text-decoration-thickness: 2px;
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 480px) {
	.library__bookshelf-grid {
		grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
		gap: 1.5rem 1rem;
	}
}

@media (max-width: 768px) {
	.library__section {
		margin-bottom: 3rem;
	}

	.library__section-title {
		font-size: 1.75rem;
		margin-bottom: 1rem;
	}

	.library__card {
		flex: 0 0 280px;
		padding: 0.875rem;
	}

	.library__card-cover {
		width: 85px;
		height: 128px;
	}

	.library__carousel-loading,
	.library__carousel-empty,
	.library__bookshelf-loading,
	.library__bookshelf-empty {
		padding: 2rem 1rem;
	}
}

@media (max-width: 480px) {
	.library__section {
		margin-bottom: 2.5rem;
	}

	.library__section-title {
		font-size: 1.5rem;
		margin-bottom: 0.75rem;
	}

	.library__card {
		flex: 0 0 260px;
		padding: 0.75rem;
		gap: 0.75rem;
	}

	.library__card-cover {
		width: 75px;
		height: 112px;
	}

	.library__card-title {
		font-size: 0.9375rem;
	}

	.library__card-subtitle {
		font-size: 0.8125rem;
	}

	.library__carousel-items {
		gap: 1rem;
	}

	.library__series-card {
		padding: 1rem;
		gap: 1rem;
	}

	.library__series-card-cover {
		width: 90px;
	}

	.library__series-card-title {
		font-size: 1.125rem;
	}
}
