@import url('../style.css');

/* Cards viewer — layout & polish (สมัยกับ DM Sans) */
body.cards-page {
	font-family: 'DM Sans', system-ui, sans-serif;
	align-items: stretch;
	justify-content: flex-start;
	min-height: 100vh;
	padding: 0 1rem 2.5rem;
	box-sizing: border-box;
}

.page-header {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.75rem;
	text-align: center;
	width: 100%;
	max-width: 1200px;
	margin: 0.75rem auto 1rem;
	padding: 0.5rem 0;
	border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.page-header .toplogo {
	flex-shrink: 0;
	display: block;
	margin: 0 auto;
	cursor: hand;
	cursor: pointer;
}

.header-text {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.25rem;
	max-width: 36rem;
}

.cards-page .pagetitle {
	margin: 0;
	font-size: 1.35rem;
	font-weight: 700;
	letter-spacing: 0.02em;
}

.page-tagline {
	margin: 0;
	opacity: 0.85;
}

.cards-toolbar {
	--allcard-filter-border: rgba(255, 255, 255, 0.14);
	--allcard-filter-accent: #58a6ff;
	--allcard-filter-surface: #1f2937;
	--allcard-filter-text-dim: #9ca3af;
	width: 100%;
	max-width: 1200px;
	margin: 0 auto 1.25rem;
	padding: 0.65rem 0.85rem;
	background: rgba(0, 0, 0, 0.35);
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 12px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 0.45rem;
}

.cards-toolbar--collapsed {
	padding: 0.42rem 0.75rem;
	gap: 0;
}

.cards-toolbar--collapsed .cards-toolbar-panel {
	display: none;
}

.cards-toolbar-cap {
	flex-shrink: 0;
}

.cards-toolbar-toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	gap: 0.5rem;
	padding: 0.32rem 0.5rem;
	margin: 0;
	border: 1px solid rgba(148, 163, 184, 0.28);
	border-radius: 8px;
	background: rgba(15, 23, 42, 0.65);
	color: #cbd5e1;
	font-family: inherit;
	font-size: 0.74rem;
	font-weight: 600;
	cursor: pointer;
	text-align: left;
	transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.cards-toolbar-toggle:hover {
	border-color: rgba(88, 166, 255, 0.45);
	color: #e5e7eb;
	background: rgba(15, 23, 42, 0.82);
}

.cards-toolbar-toggle-icon {
	font-size: 1.28rem !important;
	line-height: 1 !important;
	flex-shrink: 0;
	color: #93c5fd;
	transition: transform 0.2s ease;
}

.cards-toolbar:not(.cards-toolbar--collapsed) .cards-toolbar-toggle-icon {
	transform: rotate(180deg);
}

.cards-toolbar-panel {
	display: flex;
	flex-direction: column;
	gap: 0.45rem;
	align-items: stretch;
}

.cards-toolbar-row--top {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.4rem 0.55rem;
}

.cards-search-box {
	flex: 1 1 140px;
	min-width: 120px;
	max-width: 320px;
	padding: 0.4rem 0.75rem;
	border-radius: 8px;
	border: 1px solid var(--allcard-filter-border);
	background: rgba(22, 27, 34, 0.95);
	color: #e5e7eb;
	font-family: inherit;
	font-size: 0.875rem;
}

.cards-toolbar-row--top .cards-search-box {
	padding: 0.26rem 0.55rem;
	font-size: 0.78rem;
	border-radius: 6px;
	max-width: 280px;
}

.cards-search-box::placeholder {
	color: var(--allcard-filter-text-dim);
}

.cards-search-box:focus {
	outline: 2px solid rgba(88, 166, 255, 0.45);
	outline-offset: 2px;
	border-color: rgba(88, 166, 255, 0.35);
}

.cards-toolbar-reset {
	flex-shrink: 0;
}

.cards-toolbar .cards-toolbar-row--top .button-dark.cards-toolbar-reset {
	padding: 0.26rem 0.55rem;
	font-size: 0.72rem;
	line-height: 1.2;
	border-radius: 6px;
}

/* แบบเดียวกับ /mycards — ปุ่ม pill กรองประเภท / แรร์ */
.cards-toolbar .type-filters {
	display: flex;
	gap: 0.35rem;
	flex-wrap: wrap;
	align-items: center;
	width: 100%;
}

.cards-toolbar .type-btn {
	padding: 0.22rem 0.65rem;
	border-radius: 20px;
	border: 1px solid var(--allcard-filter-border);
	background: var(--allcard-filter-surface);
	color: var(--allcard-filter-text-dim);
	font-family: inherit;
	font-size: 0.76rem;
	font-weight: 500;
	cursor: pointer;
	transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
	white-space: nowrap;
}

.cards-toolbar .type-btn.active {
	background: var(--allcard-filter-accent);
	color: #0d1117;
	border-color: var(--allcard-filter-accent);
	font-weight: 600;
}

.cards-toolbar .type-btn:hover:not(.active) {
	border-color: rgba(88, 166, 255, 0.55);
	color: #e5e7eb;
}

.cards-page .button-dark {
	padding: 0.45rem 0.9rem;
	margin: 0;
	border-radius: 8px;
	border-width: 1px;
	border-color: rgba(255, 255, 255, 0.35);
}

.cards-main.container {
	display: block;
	width: 100%;
	max-width: 1200px;
	margin: 0 auto;
}

.cards-grid {
	display: flex;
	flex-wrap: wrap;
	gap: 0.65rem;
	justify-content: center;
	align-items: flex-start;
	padding: 0.25rem 0;
}

.card-cell {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 10px;
	padding: 4px;
	background: rgba(255, 255, 255, 0.04);
	border: 1px solid transparent;
	transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.card-cell:hover {
	border-color: rgba(139, 92, 246, 0.45);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
	transform: translateY(-2px);
}

.card-cell a {
	display: block;
	line-height: 0;
	text-decoration: none;
}

.cards-page .small-img {
	width: 88px;
	height: auto;
	border-radius: 6px;
	vertical-align: middle;
}

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

@media (max-width: 640px) {
	.cards-page {
		padding: 0 0.45rem 2rem;
	}

	.cards-main.container {
		max-width: none;
	}

	.cards-toolbar .type-filters {
		width: 100%;
		overflow-x: auto;
		flex-wrap: nowrap;
		padding-bottom: 4px;
		-webkit-overflow-scrolling: touch;
	}
	.cards-toolbar .type-filters::-webkit-scrollbar {
		height: 4px;
	}
	.cards-toolbar .type-filters::-webkit-scrollbar-thumb {
		background: rgba(255, 255, 255, 0.2);
		border-radius: 3px;
	}

	.cards-toolbar-row--top {
		display: grid;
		grid-template-columns: 1fr;
		gap: 0.45rem;
		align-items: stretch;
	}

	.cards-toolbar-row--top .cards-search-box {
		flex: none;
		max-width: none !important;
		width: 100% !important;
		min-width: 0 !important;
		padding: 0.5rem 0.7rem;
		font-size: 0.9rem;
		border-radius: 8px;
		height: 2.4rem;
		box-sizing: border-box;
	}

	.cards-toolbar .cards-toolbar-row--top .button-dark.cards-toolbar-reset {
		width: 100% !important;
		padding: 0.45rem 0.7rem;
		font-size: 0.82rem;
		box-sizing: border-box;
	}

	.cards-grid {
		display: grid;
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: 0.35rem;
		justify-content: stretch;
		align-items: start;
	}

	.card-cell {
		display: block;
		width: 100%;
		padding: 2px;
	}

	.card-cell a {
		display: block;
		width: 100%;
	}

	.cards-page .small-img {
		display: block;
		width: 100%;
		max-width: none;
	}
}

/* Card read overlay — สอดคล้อง vtable/play.php */
.allcard-read-img {
	border-radius: clamp(14px, 4.5vw, 22px);
}

/* ธีมเดียวกับ #allcard-diag-term-toggle ใน keyterm panel */
#card-read-from-btn {
	box-sizing: border-box;
	margin: 0;
	text-align: center;
	border: 1px solid rgba(148, 163, 184, 0.35);
	background: rgba(15, 23, 42, 0.8);
	color: #93c5fd;
	border-radius: 8px;
	padding: 6px 8px;
	cursor: pointer;
	font: inherit;
	font-size: 0.72rem;
	line-height: 1.35;
	transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

#card-read-from-btn:hover {
	border-color: rgba(147, 197, 253, 0.45);
	background: rgba(15, 23, 42, 0.92);
	color: #bfdbfe;
}

.allcard-keyterm-popup #keyterm-popup-body::-webkit-scrollbar {
	width: 10px;
}
.allcard-keyterm-popup #keyterm-popup-body::-webkit-scrollbar-track {
	background: #0f172a;
}
.allcard-keyterm-popup #keyterm-popup-body::-webkit-scrollbar-thumb {
	background: #334155;
	border-radius: 8px;
	border: 2px solid #0f172a;
}
.allcard-keyterm-popup #keyterm-popup-body {
	scrollbar-color: #334155 #0f172a;
	scrollbar-width: thin;
}

/* From popup — ปุ่มปิดสีเทา */
#from-release-close:hover {
	background: rgba(107, 114, 128, 0.95) !important;
	border-color: rgba(255, 255, 255, 0.2) !important;
}

/* From (release set) popup ใน preview */
.allcard-from-popup-body .cover-img {
	max-width: min(300px, 88vw);
	height: auto;
}
.allcard-from-popup-body::-webkit-scrollbar {
	width: 8px;
}
.allcard-from-popup-body::-webkit-scrollbar-track {
	background: #0f172a;
}
.allcard-from-popup-body::-webkit-scrollbar-thumb {
	background: #334155;
	border-radius: 6px;
}
.allcard-from-popup-body {
	scrollbar-color: #334155 #0f172a;
	scrollbar-width: thin;
}
