/* ---------------------------------------------------------------------
   Game Hub article chip (inc/game-hub-article-chip.php) - enqueued on a single
   article that actually has a chip, after style.css (handle `gnp-theme-style`),
   so no other request pays for it and the shared stylesheet stays free of Hub
   rules. Depends on style.css for the theme tokens (palette, radii, dark mode)
   and the `.gnp-article-hero` / `.gnp-hero-media` / `.gnp-hero-body` hero rules
   whose overflow it hands over to the artwork column when a chip exists.
   ------------------------------------------------------------------ */

.gnp-hub-chips {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 0.6rem;
	align-self: flex-start;
	margin-top: 1rem;
}

.gnp-hub-chip-wrap {
	position: relative;
	display: inline-flex;
	max-width: 100%;
}

/* The link sits alone in this block-level row so the Shortcode block's wpautop pass
   leaves it (and the card beside it) untouched - see inc/game-hub-article-chip.php. */
.gnp-hub-chip-row {
	display: flex;
	min-width: 0;
	max-width: 100%;
}

.gnp-hub-chip {
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	max-width: 100%;
	min-height: 2rem;
	padding: 0.3rem 0.9rem 0.3rem 0.7rem;
	color: rgba(245, 245, 247, 0.95);
	background: rgba(255, 255, 255, 0.13);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: var(--wp--custom--radius--pill);
	font-size: 0.8125rem;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
}

.gnp-hub-chip:hover,
.gnp-hub-chip:focus-visible {
	background: rgba(255, 255, 255, 0.22);
	border-color: rgba(255, 255, 255, 0.34);
}

.gnp-hub-chip:focus-visible {
	outline: 2px solid var(--wp--preset--color--on-dark);
	outline-offset: 2px;
}

.gnp-hub-chip__icon {
	flex: 0 0 auto;
	width: 1rem;
	height: 1rem;
	opacity: 0.9;
}

.gnp-hub-chip__label {
	flex: 0 0 auto;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.gnp-hub-chip__sep {
	flex: 0 0 auto;
	opacity: 0.7;
}

.gnp-hub-chip__name {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

@media (pointer: coarse) {
	.gnp-hub-chip {
		min-height: 2.5rem;
	}
}

.gnp-hub-card {
	display: none;
}

@media (min-width: 1000px) and (hover: hover) {
	/* The card hangs below the hero, so the hero can no longer clip it. The black
	   panel still rounds itself (background + radius); the rounded clip of the
	   artwork moves to its column, which now spans the full hero height so the
	   clipped corners are exactly the hero's own - the image keeps its size, its
	   vertical centring and its flush right edge. */
	.gnp-article-hero:has(.gnp-hub-chip) {
		overflow: visible;
	}

	.gnp-article-hero:has(.gnp-hub-chip) .gnp-hero-media {
		display: grid;
		align-content: center;
		align-self: stretch;
		overflow: hidden;
		border-radius: 0 var(--wp--custom--radius--lg) var(--wp--custom--radius--lg) 0;
	}

	/* From 1300px the shared .gnp-article-hero .gnp-hero-media rule in style.css
	   makes the column a centring flex column (so the ultrawide rule there can let
	   the frame follow the row); this rule is more specific and loads later, so it
	   would otherwise keep the grid above. Same centring, same clip. */
	@media (min-width: 1300px) {
		.gnp-article-hero:has(.gnp-hub-chip) .gnp-hero-media {
			display: flex;
			flex-direction: column;
			justify-content: center;
		}
	}

	.gnp-article-hero:has(.gnp-hub-chip) .gnp-hero-body {
		z-index: 20;
	}

	.gnp-hub-chip-wrap:hover .gnp-hub-card,
	:where(.gnp-hub-chip-wrap):has(.gnp-hub-chip:focus-visible) .gnp-hub-card {
		display: block;
	}

	/* Escape (assets/js/game-hub-article-chip.js) marks the wrapper; the mark is removed
	   once the pointer has left and focus is elsewhere. Higher specificity than the two
	   rules above, so it wins while the pointer is still over / focus still on the chip. */
	.gnp-hub-chips .gnp-hub-chip-wrap[data-dismissed] .gnp-hub-card {
		display: none;
	}

	/* Anchored under its own chip. The top padding is part of the card (hover
	   passes straight from chip to card, no dead gap) and holds the caret. */
	.gnp-hub-card {
		position: absolute;
		z-index: 30;
		top: 100%;
		left: 0;
		width: min(27rem, 90vw);
		padding-top: 0.7rem;
		--gnp-hub-link: #1d68c9;
	}

	.gnp-hub-card__panel {
		position: relative;
		display: grid;
		grid-template-columns: minmax(0, 1fr) 7.9rem;
		align-items: center;
		gap: 1rem;
		padding: 1.1rem 1.15rem;
		color: var(--wp--preset--color--contrast);
		background: var(--wp--preset--color--surface);
		border: 1px solid var(--wp--preset--color--border);
		border-radius: var(--wp--custom--radius--md);
		box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28), 0 2px 8px rgba(0, 0, 0, 0.14);
	}

	.gnp-hub-card__panel--no-art {
		grid-template-columns: minmax(0, 1fr);
	}

	.gnp-hub-card__panel::before {
		content: "";
		position: absolute;
		top: -0.4rem;
		left: 1.6rem;
		width: 0.75rem;
		height: 0.75rem;
		background: var(--wp--preset--color--surface);
		border-top: 1px solid var(--wp--preset--color--border);
		border-left: 1px solid var(--wp--preset--color--border);
		transform: rotate(45deg);
	}

	.gnp-hub-card__text {
		min-width: 0;
	}

	.gnp-hub-card__eyebrow {
		margin: 0;
		color: var(--wp--preset--color--muted);
		font-size: 0.6875rem;
		font-weight: 700;
		letter-spacing: 0.09em;
		line-height: 1.2;
		text-transform: uppercase;
	}

	.gnp-hub-card__title {
		margin: 0.3rem 0 0;
		font-size: 1.0625rem;
		font-weight: 700;
		letter-spacing: -0.005em;
		line-height: 1.25;
	}

	.gnp-hub-card__desc {
		display: -webkit-box;
		margin: 0.45rem 0 0;
		overflow: hidden;
		color: var(--wp--preset--color--muted);
		font-size: 0.875rem;
		line-height: 1.45;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}

	.gnp-hub-card__action {
		margin-top: 0.8rem;
	}

	.gnp-hub-card__cta {
		display: inline-block;
		color: var(--gnp-hub-link);
		font-size: 0.9375rem;
		font-weight: 700;
		text-decoration: none;
	}

	.gnp-hub-card__cta::after {
		content: "\00a0\2192";
	}

	/* The whole card is one click target (a pointer user clicking anywhere on it
	   goes to the Hub); the chip remains the keyboard stop. */
	.gnp-hub-card__cta::before {
		content: "";
		position: absolute;
		inset: 0;
		border-radius: inherit;
	}

	.gnp-hub-card__cta:hover {
		text-decoration: underline;
		text-underline-offset: 0.2em;
	}

	.gnp-hub-card__art {
		aspect-ratio: 8 / 7;
		overflow: hidden;
		background: var(--wp--preset--color--border);
		border-radius: var(--wp--custom--radius--sm);
	}

	.gnp-hub-card__img {
		display: block;
		width: 100%;
		height: 100%;
		object-fit: cover;
	}
}

/* The card's link colour in dark mode, with the same three-way gating as the
   theme tokens above (system dark unless Light was chosen; explicit Dark). */
@media (min-width: 1000px) and (hover: hover) and (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .gnp-hub-card {
		--gnp-hub-link: #6aa6f2;
	}
}

@media (min-width: 1000px) and (hover: hover) {
	:root[data-theme="dark"] .gnp-hub-card {
		--gnp-hub-link: #6aa6f2;
	}
}

@media (min-width: 1000px) and (hover: hover) and (prefers-reduced-motion: no-preference) {
	.gnp-hub-chip-wrap:hover .gnp-hub-card,
	:where(.gnp-hub-chip-wrap):has(.gnp-hub-chip:focus-visible) .gnp-hub-card {
		animation: gnp-hub-card-in 160ms ease-out 90ms backwards;
	}
}

@keyframes gnp-hub-card-in {
	from {
		opacity: 0;
		transform: translateY(-4px);
	}
}
