/*
 * Centomila Theme — Page Transitions & Skeleton Loaders
 *
 * View Transition API animations + skeleton placeholders shown during
 * AJAX content swaps. Colours match the theme's dark palette.
 *
 * @since 1.5.0
 */

/* ─── Accessibility: SPA route changes ─── */

/*
 * Visually-hidden ARIA live region (page-transitions.js announces the new page
 * title here on each SPA swap) — standard screen-reader-only pattern.
 */
.cm-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/*
 * <main> is given tabindex="-1" and focused programmatically after each swap so
 * keyboard / screen-reader users land in the new content. It is not in the tab
 * order, so suppressing its focus ring is correct and avoids a flashed outline.
 */
main[tabindex="-1"]:focus {
	outline: none;
}

/* ─── View Transitions API ─── */

/*
 * Suppress the default cross-fade on root — the skeleton loader already
 * provides visual continuity. This prevents the "flash" between states.
 */
::view-transition-old(root),
::view-transition-new(root) {
	animation: none;
}

/* Keep header & footer stable during transitions */
.centomila-header {
	view-transition-name: cm-header;
}

.centomila-footer {
	view-transition-name: cm-footer;
}

/* Player bar should never animate during transitions */
#cm-player-bar {
	view-transition-name: cm-player;
}

/* Suppress animations on header/footer/player */
::view-transition-old(cm-header),
::view-transition-new(cm-header),
::view-transition-old(cm-footer),
::view-transition-new(cm-footer),
::view-transition-old(cm-player),
::view-transition-new(cm-player) {
	animation: none;
}

/* ─── Skeleton Pulse Animation ─── */

@keyframes cm-skeleton-shimmer {
	0% {
		background-position: -200% 0;
	}
	100% {
		background-position: 200% 0;
	}
}

.cm-skeleton-pulse {
	background: linear-gradient(
		90deg,
		rgba(244, 244, 244, 0.04) 25%,
		rgba(244, 244, 244, 0.10) 50%,
		rgba(244, 244, 244, 0.04) 75%
	);
	background-size: 200% 100%;
	animation: cm-skeleton-shimmer 1.5s ease-in-out infinite;
}

/* ─── Skeleton: Grid (Archives/Listings) ─── */

.cm-skeleton-grid {
	display: grid;
	grid-template-columns: repeat( var(--cm-skel-cols, 3), 1fr );
	gap: 4rem;
	max-width: var(--wp--style--global--wide-size, 1280px);
	margin: 0 auto;
	padding: 0 var(--wp--preset--spacing--50, 1.5rem);
}

.cm-skeleton-card {
	overflow: hidden;
}

.cm-skeleton-img {
	aspect-ratio: 1;
	width: 100%;
}

.cm-skeleton-body {
	background: rgba(244, 244, 244, 0.03);
	padding: 1rem;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.5rem;
}

.cm-skeleton-line {
	height: 0.875rem;
}

.cm-skeleton-line--title {
	width: 70%;
	height: 1rem;
}

.cm-skeleton-line--meta {
	width: 40%;
}

.cm-skeleton-line--badge {
	width: 75%;
	height: 2rem;
	margin-top: 0.25rem;
	border-radius: 0;
}

/* ─── Skeleton: Single (Release/Software/Portfolio) ─── */

.cm-skeleton-single {
	max-width: var(--wp--style--global--wide-size, 1280px);
	margin: 0 auto;
	padding: 0 var(--wp--preset--spacing--50, 1.5rem);
}

.cm-skeleton-columns {
	display: grid;
	grid-template-columns: 60% 1fr;
	gap: var(--wp--preset--spacing--60, 2.5rem);
}

.cm-skeleton-col-left {
	min-width: 0;
}

.cm-skeleton-cover {
	aspect-ratio: 1;
	width: 100%;
}

.cm-skeleton-col-right {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	padding-top: 0.5rem;
}

.cm-skeleton-line--heading {
	width: 80%;
	height: 1.5rem;
}

.cm-skeleton-line--sub {
	width: 50%;
}

.cm-skeleton-line--full {
	width: 100%;
}

.cm-skeleton-line--medium {
	width: 60%;
}

.cm-skeleton-line--short {
	width: 35%;
}

/* ─── Skeleton: Generic (About, Contact, etc.) ─── */

.cm-skeleton-generic {
	max-width: var(--wp--style--global--content-size, 720px);
	margin: 0 auto;
	padding: 0 var(--wp--preset--spacing--50, 1.5rem);
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

/* ─── Content appearance (no flash) ─── */

.cm-content-enter {
	animation: cm-content-in 0.15s ease-out both;
}

@keyframes cm-content-in {
	from { opacity: 0.6; }
	to   { opacity: 1; }
}

/* ─── Skeleton: Archive Page (heading + grid) ─── */

.cm-skeleton-archive {
	max-width: var(--wp--style--global--wide-size, 1280px);
	margin: 0 auto;
	padding: 0 var(--wp--preset--spacing--50, 1.5rem);
}

.cm-skeleton-heading {
	display: block;
	text-align: center;
	text-transform: uppercase;
	letter-spacing: 0.3rem;
	font-size: 2rem;
	font-weight: 700;
	color: transparent;
	margin-bottom: var(--wp--preset--spacing--60, 2.5rem);
	line-height: 1.2;
}

/* ─── Player Bar Placeholder ─── */

#cm-player-bar {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 9998;
	/* Hidden by default — the music plugin will show it */
	display: none;
}

/* When player is active, add bottom padding so footer isn't hidden behind it */
body.cm-player-active {
	padding-bottom: var(--cm-player-height, 72px);
}

/* ─── Responsive: Skeleton Grid ─── */

@media (max-width: 781px) {
	.cm-skeleton-grid {
		grid-template-columns: 1fr !important;
	}

	.cm-skeleton-columns {
		grid-template-columns: 1fr;
	}

	.cm-skeleton-col-right {
		align-items: center;
		text-align: center;
	}

	.cm-skeleton-line--heading,
	.cm-skeleton-line--sub,
	.cm-skeleton-line--full,
	.cm-skeleton-line--short,
	.cm-skeleton-line--medium {
		align-self: center;
	}
}

@media (min-width: 782px) and (max-width: 959px) {
	.cm-skeleton-grid {
		grid-template-columns: repeat(2, 1fr) !important;
	}
}
