/*
 * ねこよみ図書館のトップだけ。
 * 図解の個別ページ、ヘッダー、フッター、他の機能の見た目は変えない。
 */

body.nekoyomi-zukai-library-page .wp-block-post-title,
body.nekoyomi-zukai-library-page .entry-header .entry-title {
	display: none !important;
}

body.nekoyomi-zukai-library-page {
	padding-bottom: calc(88px + env(safe-area-inset-bottom));
}

.nekoyomi-library {
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	margin: 0 auto;
	padding: 8px 0 calc(36px + env(safe-area-inset-bottom));
	color: #4a3f6b;
	font-size: 16px;
	line-height: 1.7;
}

.nekoyomi-library *,
.nekoyomi-library *::before,
.nekoyomi-library *::after {
	box-sizing: border-box;
}

.nekoyomi-library h1,
.nekoyomi-library h2,
.nekoyomi-library h3 {
	margin: 0;
	color: #5f3a8d !important;
	font-weight: 800;
	line-height: 1.45 !important;
}

.nekoyomi-library h1 {
	font-size: 26px !important;
	letter-spacing: 0.02em;
}

.nekoyomi-library h2,
.nekoyomi-library h3 {
	display: flex;
	align-items: center;
	gap: 8px;
}

.nekoyomi-library h2 {
	font-size: 20px !important;
}

.nekoyomi-library h3 {
	margin: 16px 4px 10px;
	font-size: 16px !important;
}

.nekoyomi-library h3::before {
	content: none;
}

.nekoyomi-library h2::before {
	content: "";
	flex: 0 0 18px;
	width: 18px;
	height: 18px;
	background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath fill='%23f1b248' d='M9 1.2l1.7 4.2 4.5.4-3.4 2.9 1 4.4L9 10.8 5.2 13.1l1-4.4L2.8 5.8l4.5-.4z'/%3E%3C/svg%3E");
}

.nekoyomi-library p {
	margin: 0;
}

.nekoyomi-library a {
	color: #5f3a8d !important;
	text-decoration: none;
}

.nekoyomi-library a:focus-visible {
	outline: 3px solid #b99af4;
	outline-offset: 3px;
}

.nekoyomi-library-hero,
.nekoyomi-library-shelf,
.nekoyomi-library-notice {
	border: 1px solid #efe4c8;
	border-radius: 28px;
	background: #fffdf8;
	box-shadow: 0 12px 32px rgba(123, 107, 184, 0.1);
}

.nekoyomi-library-hero {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0;
	margin: 0 0 16px;
	padding: 8px 6px 12px;
	background:
		radial-gradient(circle at 18% 18%, rgba(185, 154, 244, 0.28), transparent 26%),
		radial-gradient(circle at 86% 12%, rgba(255, 138, 138, 0.22), transparent 24%),
		#fffdf8;
	overflow: hidden;
}

.nekoyomi-library-hero-art {
	width: 100%;
	max-width: 720px;
	margin: 0 auto 10px;
	aspect-ratio: 517 / 285;
	border-radius: 18px;
	background: #faf3e1;
}

.nekoyomi-library-hero-art img {
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: none;
	object-fit: contain;
	object-position: center;
	border-radius: 18px;
}

.nekoyomi-library-hero-copy {
	width: 100%;
	padding: 0 4px 2px;
	text-align: center;
}

.nekoyomi-library-hero h1 {
	font-size: clamp(24px, 7vw, 30px) !important;
	text-align: center !important;
	white-space: nowrap;
}

.nekoyomi-library-lead {
	margin: 8px 0 0;
	color: #4a3f6b;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.7;
	white-space: normal;
	overflow-wrap: anywhere;
}

.nekoyomi-library-notice {
	margin: 0 0 18px;
	padding: 14px 16px;
	color: #5f3a8d;
	font-weight: 700;
}

.nekoyomi-library-shelf {
	margin: 0 0 16px;
	padding: 18px 12px 16px;
}

.nekoyomi-library-shelf-head {
	margin: 0 4px 14px;
}

.nekoyomi-library-shelf-head p {
	margin-top: 4px !important;
	color: #6d5a8a;
	font-size: 14px;
}

.nekoyomi-library-search {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 8px;
	margin: 0;
}

.nekoyomi-library-search-label,
.nekoyomi-library-filter-label {
	color: #9b7cc8;
	font-size: 13px;
	font-weight: 800;
}

.nekoyomi-library-search-label {
	grid-column: 1 / -1;
}

.nekoyomi-library-filter-label {
	margin: 0 4px 8px !important;
}

.nekoyomi-library-search input {
	width: 100%;
	min-width: 0;
	min-height: 46px;
	margin: 0;
	padding: 8px 14px;
	border: 1px solid #dbc69a;
	border-radius: 999px;
	background: #fff;
	color: #4a3f6b;
	font: inherit;
	font-size: 16px !important;
}

.nekoyomi-library-submit {
	min-height: 46px;
	margin: 0;
	padding: 8px 16px;
	border: 0;
	border-radius: 999px;
	background: #5f3a8d !important;
	color: #fffdf8 !important;
	font: inherit;
	font-size: 15px !important;
	font-weight: 800;
	line-height: 1.2 !important;
}

.nekoyomi-library-summary {
	margin: 0 4px 12px !important;
	color: #6d5a8a;
	font-size: 14px;
}

.nekoyomi-library-categories,
.nekoyomi-library-seals,
.nekoyomi-library-cards {
	margin: 0;
	padding: 0;
	list-style: none;
}

.nekoyomi-library-categories {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 10px;
}

.nekoyomi-library-categories a,
.nekoyomi-library-categories label,
.nekoyomi-library-clear-categories {
	display: flex;
	align-items: center;
	min-height: 52px;
	padding: 10px 12px 10px 16px;
	border-radius: 16px;
	background:
		linear-gradient(#d6b25e, #d6b25e) left / 8px 100% no-repeat,
		#faf6ee;
	font-size: 15px !important;
	font-weight: 800;
	line-height: 1.4 !important;
	box-shadow: inset 0 0 0 1px #efe4c8;
}

.nekoyomi-library-categories li:nth-child(3n + 1) a,
.nekoyomi-library-categories li:nth-child(3n + 1) label,
.nekoyomi-library-categories li:nth-child(3n + 1) .nekoyomi-library-clear-categories {
	background:
		linear-gradient(#ff8a8a, #ff8a8a) left / 8px 100% no-repeat,
		#fff8f6;
}

.nekoyomi-library-categories li:nth-child(3n + 2) a,
.nekoyomi-library-categories li:nth-child(3n + 2) label,
.nekoyomi-library-categories li:nth-child(3n + 2) .nekoyomi-library-clear-categories {
	background:
		linear-gradient(#b99af4, #b99af4) left / 8px 100% no-repeat,
		#faf7ff;
}

.nekoyomi-library-categories a[aria-current="true"],
.nekoyomi-library-categories label:has(input:checked) {
	box-shadow: inset 8px 0 0 #5f3a8d, inset 0 0 0 2px #5f3a8d;
}

.nekoyomi-library-seals a[aria-current="true"] .nekoyomi-library-seal-face,
.nekoyomi-library-seals label:has(input:checked) .nekoyomi-library-seal-face {
	border-color: #5f3a8d;
	box-shadow: 0 0 0 3px #5f3a8d;
}

.nekoyomi-library-results {
	margin-top: 18px;
}

.nekoyomi-library-status {
	margin: 0 4px 12px !important;
	color: #6d5a8a;
	font-size: 14px;
}

.nekoyomi-library-status.is-error {
	color: #6d2c24;
}

.nekoyomi-library-results.is-loading {
	opacity: 0.72;
}

.nekoyomi-library-seal-shelf {
	position: relative;
	padding-bottom: 40px;
	background-color: #fffdf8;
	background-image:
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath fill='%23f1b248' d='M9 1.2l1.7 4.2 4.5.4-3.4 2.9 1 4.4L9 10.8 5.2 13.1l1-4.4L2.8 5.8l4.5-.4z'/%3E%3C/svg%3E"),
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath fill='%23e7c56a' d='M9 1.2l1.7 4.2 4.5.4-3.4 2.9 1 4.4L9 10.8 5.2 13.1l1-4.4L2.8 5.8l4.5-.4z'/%3E%3C/svg%3E"),
		linear-gradient(#e7d3a4, #e7d3a4),
		linear-gradient(#f4ead6, #f4ead6),
		radial-gradient(rgba(214, 178, 94, 0.16) 0.7px, transparent 0.8px);
	background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, repeat;
	background-position: right 14px top 16px, right 34px top 30px, center bottom 14px, center bottom 14px, 0 0;
	background-size: 14px 14px, 8px 8px, calc(100% - 28px) 8px, calc(100% - 36px) 8px, 7px 7px;
}

.nekoyomi-library-seal-shelf h2::before {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath fill='%23d6b25e' d='M1.6 3.4c2.2-.7 4.1-.2 5.2.8v10.4c-1.2-.8-3.1-1.1-5.2-.4V3.4z'/%3E%3Cpath fill='%23e8c97a' d='M16.4 3.4c-2.2-.7-4.1-.2-5.2.8v10.4c1.2-.8 3.1-1.1 5.2-.4V3.4z'/%3E%3Cpath fill='%235f3a8d' d='M8.5 4.6h1v9.2h-1z'/%3E%3C/svg%3E");
}

.nekoyomi-library-seal-shelf .nekoyomi-library-shelf-head,
.nekoyomi-library-seals {
	position: relative;
	z-index: 1;
}

.nekoyomi-library-seals {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 14px 6px;
}

.nekoyomi-library-seals a,
.nekoyomi-library-seals label {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	min-width: 0;
	text-align: center;
}

.nekoyomi-library-seal-face {
	display: flex;
	align-items: center;
	justify-content: center;
	width: min(68px, 100%);
	aspect-ratio: 1 / 1;
	padding: 5px;
	overflow: hidden;
	border: 2px solid #e4d3a4;
	border-radius: 50%;
	background: #fffdf8;
	box-shadow: 0 0 0 3px #f6efe2;
}

.nekoyomi-library-seal-face img {
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: none;
	object-fit: contain;
}

.nekoyomi-library-seal-name {
	display: -webkit-box;
	max-width: 100%;
	overflow: hidden;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	overflow-wrap: anywhere;
	color: #5f3a8d;
	font-size: 12px;
	font-weight: 800;
	line-height: 1.35;
}

.nekoyomi-library-cards {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px;
}

.nekoyomi-library-card {
	min-width: 0;
	overflow: hidden;
	border: 1px solid #efe4c8;
	border-radius: 18px;
	background: #fff;
}

.nekoyomi-library-card a {
	display: flex;
	flex-direction: column;
	height: 100%;
}

.nekoyomi-library-card-media {
	display: flex;
	align-items: center;
	justify-content: center;
	aspect-ratio: 1 / 1;
	background: #fffdf8;
}

.nekoyomi-library-card-media img {
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: none;
	object-fit: contain;
}

.nekoyomi-library-card-placeholder {
	width: 46%;
	height: 62%;
	border-radius: 6px 8px 6px 6px;
	background:
		linear-gradient(#fffdf8, #fffdf8) 8px 10px / 18px 4px no-repeat,
		linear-gradient(#ff8a8a, #b99af4);
	box-shadow: 4px 6px 0 rgba(95, 58, 141, 0.08);
}

.nekoyomi-library-card-body {
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding: 8px 10px 12px;
}

.nekoyomi-library-card-category {
	color: #9b7cc8;
	font-size: 11px;
	font-weight: 800;
	line-height: 1.4;
}

.nekoyomi-library-card-title {
	display: -webkit-box;
	overflow: hidden;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	color: #5f3a8d;
	font-size: 14px;
	font-weight: 800;
	line-height: 1.45;
}

.nekoyomi-library-empty {
	margin: 0 4px !important;
	padding: 22px 14px;
	border-radius: 16px;
	background:
		linear-gradient(#d6b25e, #d6b25e) center bottom / 100% 8px no-repeat,
		#faf6ee;
	color: #6d5a8a;
	font-size: 14px;
	text-align: center;
}

@media (min-width: 720px) {
	.nekoyomi-library-hero {
		padding: 12px 12px 16px;
	}

	.nekoyomi-library-hero h1 {
		font-size: 34px !important;
	}

	.nekoyomi-library-categories {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.nekoyomi-library-seals {
		grid-template-columns: repeat(5, minmax(0, 1fr));
	}

	.nekoyomi-library-seal-face {
		width: min(84px, 100%);
	}

	.nekoyomi-library-seal-name {
		font-size: 13px;
	}

	.nekoyomi-library-cards {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: 16px;
	}

	.nekoyomi-library-shelf {
		padding: 22px 18px 18px;
	}

	.nekoyomi-library-seal-shelf {
		padding-bottom: 40px;
	}
}

@media (min-width: 980px) {
	.nekoyomi-library-cards {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

.nekoyomi-library-finder {
	padding-top: 12px;
	padding-bottom: 12px;
}

.nekoyomi-library-finder-toggle {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	min-height: 52px;
	margin: 0;
	padding: 10px 16px;
	border: 2px solid #5f3a8d;
	border-radius: 16px;
	background: #fffdf8;
	color: #4a3f6b;
	font: inherit;
	font-size: 18px !important;
	font-weight: 800;
	line-height: 1.3 !important;
	text-align: left;
	cursor: pointer;
}

.nekoyomi-library-finder-toggle::before {
	content: "";
	flex: 0 0 18px;
	width: 18px;
	height: 18px;
	background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath fill='%23f1b248' d='M9 1.2l1.7 4.2 4.5.4-3.4 2.9 1 4.4L9 10.8 5.2 13.1l1-4.4L2.8 5.8l4.5-.4z'/%3E%3C/svg%3E");
}

.nekoyomi-library-finder-toggle::after {
	content: "";
	width: 9px;
	height: 9px;
	margin-left: auto;
	border-right: 2px solid #5f3a8d;
	border-bottom: 2px solid #5f3a8d;
	transform: translateY(-2px) rotate(45deg);
}

.nekoyomi-library-finder-toggle[aria-expanded="true"] {
	border-bottom-right-radius: 0;
	border-bottom-left-radius: 0;
	background: #5f3a8d;
	color: #fffdf8;
}

.nekoyomi-library-finder-toggle[aria-expanded="true"]::after {
	border-color: #fffdf8;
	transform: translateY(2px) rotate(225deg);
}

.nekoyomi-library-finder-toggle:focus-visible {
	outline: 3px solid #f1b248;
	outline-offset: 2px;
}

.nekoyomi-library-search[hidden] {
	display: none !important;
}

.nekoyomi-library-finder.is-open .nekoyomi-library-search {
	margin-top: 0;
	padding: 14px 8px 4px;
	border: 2px solid #5f3a8d;
	border-top: 0;
	border-radius: 0 0 16px 16px;
	background: #fffdf8;
}

.nekoyomi-library-categories {
	gap: 8px;
	margin-bottom: 4px;
}

.nekoyomi-library-categories label,
.nekoyomi-library-clear-categories {
	position: relative;
	width: 100%;
	min-height: 44px;
	cursor: pointer;
}

.nekoyomi-library-clear-categories {
	border: 0;
	font: inherit;
	text-align: left;
}

.nekoyomi-library-categories input,
.nekoyomi-library-seals input {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
}

.nekoyomi-library-categories label:focus-within,
.nekoyomi-library-seals label:focus-within,
.nekoyomi-library-clear-categories:focus-visible {
	outline: 3px solid #b99af4;
	outline-offset: 3px;
}

.nekoyomi-library-categories label:has(input:checked) span::after {
	content: "✓";
	margin-left: auto;
	color: #5f3a8d;
}

.nekoyomi-library-seals label {
	position: relative;
	cursor: pointer;
}

.nekoyomi-library-seal-extra {
	margin-top: 8px;
}

.nekoyomi-library-seal-extra summary {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 42px;
	padding: 8px 12px;
	border-radius: 999px;
	background: #faf6ee;
	box-shadow: inset 0 0 0 1px #efe4c8;
	color: #5f3a8d;
	font-size: 14px;
	font-weight: 800;
	cursor: pointer;
	list-style: none;
}

.nekoyomi-library-seal-extra summary::-webkit-details-marker {
	display: none;
}

.nekoyomi-library-seal-toggle-open {
	display: none;
}

.nekoyomi-library-seal-extra[open] .nekoyomi-library-seal-toggle-closed {
	display: none;
}

.nekoyomi-library-seal-extra[open] .nekoyomi-library-seal-toggle-open {
	display: inline;
}

.nekoyomi-library-seal-extra-body {
	overflow: hidden;
	padding-top: 10px;
}

@media (prefers-reduced-motion: no-preference) {
	.nekoyomi-library-seal-extra[open] .nekoyomi-library-seal-extra-body {
		animation: nekoyomi-library-unfold 0.28s ease;
	}
}

@keyframes nekoyomi-library-unfold {
	from {
		opacity: 0;
		transform: translateY(-6px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.nekoyomi-library-seal-note,
.nekoyomi-library-selected,
.nekoyomi-library-count {
	margin: 8px 4px 0 !important;
	color: #6d5a8a;
	font-size: 13px;
}

.nekoyomi-library-selected:empty,
.nekoyomi-library-seal-note:empty {
	display: none;
}

.nekoyomi-library-chip {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	margin: 2px 4px 2px 0;
	padding: 2px 8px;
	border-radius: 999px;
	background: #faf6ee;
	box-shadow: inset 0 0 0 1px #efe4c8;
}

.nekoyomi-library-chip button {
	margin: 0;
	padding: 0 2px;
	border: 0;
	background: transparent !important;
	color: #5f3a8d !important;
	font: inherit;
	font-weight: 800;
	line-height: 1;
}

.nekoyomi-library-actions {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	gap: 8px;
	margin-top: 8px;
}

.nekoyomi-library-clear {
	min-height: 46px;
	margin: 0;
	padding: 8px 12px;
	border: 1px solid #e4d3a4;
	border-radius: 999px;
	background: transparent !important;
	color: #6d5a8a !important;
	font: inherit;
	font-size: 13px !important;
	font-weight: 800;
}

#nekoyomi-library-results-heading {
	scroll-margin-top: calc(96px + env(safe-area-inset-top));
}

.nekoyomi-library-more {
	display: block;
	width: 100%;
	min-height: 46px;
	margin: 12px 0 0;
	padding: 8px 16px;
	border: 1px solid #e4d3a4;
	border-radius: 999px;
	background: #fffdf8 !important;
	color: #5f3a8d !important;
	font: inherit;
	font-size: 15px !important;
	font-weight: 800;
}

.nekoyomi-library-card-seal {
	color: #c47a4a;
	font-size: 11px;
	font-weight: 800;
	line-height: 1.4;
}

.nekoyomi-library-clear {
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	text-decoration: none;
}

.nekoyomi-library-pages {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin: 14px 0 0;
}

.nekoyomi-library-page,
.nekoyomi-library-pages-fallback a {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-width: 44px;
	min-height: 44px;
	margin: 0;
	padding: 8px 12px;
	border: 1px solid #e4d3a4;
	border-radius: 999px;
	background: #fffdf8 !important;
	color: #5f3a8d !important;
	font: inherit;
	font-size: 15px !important;
	font-weight: 800;
	line-height: 1;
	text-decoration: none;
}

.nekoyomi-library-page.is-current {
	border-color: #5f3a8d;
	background: #5f3a8d !important;
	color: #fffdf8 !important;
}

.nekoyomi-library-page-gap {
	color: #6d5a8a;
	font-weight: 800;
}

.nekoyomi-library-pages-fallback {
	margin: 8px 0 0;
	text-align: center;
}
