/**
 * Card Collection - bloc de l'index et styles communs
 *
 * Format de reference : 64 x 89 mm -> aspect-ratio 64 / 89
 * Independant du theme : uniquement des classes prefixees .cc-
 *
 * @copyright (c) 2024, Verturin
 * @license GNU General Public License, version 2 (GPL-2.0)
 */

/* =============================================================
 * BLOC DE L'INDEX
 * ============================================================= */

.cc-index {
	--cc-ratio: 64 / 89;
	--cc-line: rgba(0, 0, 0, .10);
	--cc-muted: #6b7280;
	--cc-rare: #3b82f6;
	--cc-ultra: #a855f7;
	--cc-legendary: #f59e0b;
}

@media (prefers-color-scheme: dark) {
	.cc-index {
		--cc-line: rgba(255, 255, 255, .12);
		--cc-muted: #9ca3af;
	}
}

.cc-index-stats {
	float: right;
	width: auto !important;
	padding-right: 12px;
	font-size: .9em;
	white-space: nowrap;
}

.cc-index-body {
	padding: 16px;
}

.cc-index-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
	gap: 14px;
	margin: 0 0 16px;
	padding: 0;
	list-style: none;
}

.cc-index-grid li {
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Pochette au format exact d'une carte 64 x 89 mm */
.cc-index-card {
	position: relative;
	display: block;
	aspect-ratio: var(--cc-ratio);
	border-radius: 8px;
	overflow: hidden;
	background: var(--cc-line);
	box-shadow: 0 1px 3px rgba(0,0,0,.10), 0 6px 14px rgba(0,0,0,.08);
	text-decoration: none;
	transition: transform .18s ease, box-shadow .18s ease;
}

.cc-index-card:hover,
.cc-index-card:focus-visible {
	transform: translateY(-3px);
	box-shadow: 0 4px 10px rgba(0,0,0,.12), 0 14px 30px rgba(0,0,0,.16);
	text-decoration: none;
}

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

.cc-index-noimage {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	padding: 8px;
	font-size: .76em;
	text-align: center;
	color: var(--cc-muted);
	background: repeating-linear-gradient(
		45deg,
		transparent, transparent 8px,
		rgba(0,0,0,.03) 8px, rgba(0,0,0,.03) 16px
	);
}

/* Liseré de rareté */
.cc-index-card::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	border: 2px solid transparent;
	pointer-events: none;
}

.cc-index-card[data-rarity="rare"]::after       { border-color: var(--cc-rare); }
.cc-index-card[data-rarity="ultra_rare"]::after { border-color: var(--cc-ultra); }
.cc-index-card[data-rarity="legendary"]::after  {
	border-color: var(--cc-legendary);
	box-shadow: inset 0 0 16px rgba(245,158,11,.35);
}

.cc-index-flag {
	position: absolute;
	top: 6px;
	left: 6px;
	padding: 2px 7px;
	border-radius: 999px;
	background: rgba(139,92,246,.92);
	color: #fff;
	font-size: .64em;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .04em;
}

.cc-index-caption {
	position: absolute;
	inset: auto 0 0 0;
	padding: 18px 8px 7px;
	background: linear-gradient(to top, rgba(0,0,0,.88), rgba(0,0,0,0));
	color: #fff;
}

.cc-index-name {
	display: block;
	font-size: .78em;
	font-weight: 700;
	line-height: 1.2;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.cc-index-meta {
	display: block;
	font-size: .68em;
	opacity: .82;
}

.cc-index-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	justify-content: center;
	padding-top: 4px;
}

.cc-index-empty {
	margin: 0 0 16px;
	padding: 24px;
	text-align: center;
	color: var(--cc-muted);
	border: 2px dashed var(--cc-line);
	border-radius: 10px;
}

@media (max-width: 700px) {
	.cc-index-grid {
		grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
		gap: 10px;
	}

	.cc-index-stats {
		float: none;
		display: block;
		padding: 4px 12px 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cc-index-card {
		transition: none;
	}
}

/* =============================================================
 * BADGES DE RARETE (catalogue, vue carte)
 * ============================================================= */

.cards-rarity,
.cc-rarity {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 999px;
	font-size: .7em;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .04em;
	color: #fff;
}

.cards-rarity-common,     .cc-rarity-common     { background: #94a3b8; }
.cards-rarity-rare,       .cc-rarity-rare       { background: #3b82f6; }
.cards-rarity-ultra_rare, .cc-rarity-ultra_rare { background: #a855f7; }
.cards-rarity-legendary,  .cc-rarity-legendary  { background: #f59e0b; }

/* =============================================================
 * LOGO ET ICONES
 * ============================================================= */

.cc-nav-icon {
	width: 16px;
	height: 16px;
	margin-right: 5px;
	vertical-align: -3px;
	opacity: .85;
}

.cc-logo {
	display: block;
	height: 46px;
	width: auto;
	margin-bottom: 6px;
}

.cc-title-with-logo {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
}

@media (max-width: 560px) {
	.cc-logo { height: 38px; }
}

/* =============================================================
 * SECTIONS PAR TYPE SUR L'INDEX
 * ============================================================= */

.cc-index-section + .cc-index-section {
	margin-top: 22px;
	padding-top: 18px;
	border-top: 1px solid var(--cc-line, rgba(0, 0, 0, .1));
}

.cc-index-section-head {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: baseline;
	justify-content: space-between;
	margin-bottom: 12px;
}

.cc-index-section-title {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: .84em;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .05em;
}

.cc-index-section-count {
	padding: 1px 8px;
	border-radius: 999px;
	background: var(--cc-line, rgba(0, 0, 0, .1));
	font-size: .92em;
	font-weight: 600;
	letter-spacing: 0;
}

.cc-index-section-link {
	font-size: .82em;
	font-weight: 600;
	text-decoration: none;
}

/* Grisé des objets non possédés, sur l'index aussi */
.cc-index-card[data-owned="0"] img {
	opacity: .38;
	filter: grayscale(72%) contrast(88%);
	transition: opacity .2s ease, filter .2s ease;
}

.cc-index-card[data-owned="0"]:hover img {
	opacity: .78;
	filter: grayscale(28%);
}
