/*
 * Note covers (VOY-1546, shared with VOY-1547). Server half: inc/note-cover.php.
 *
 * Loaded only on a page that renders a cover or a topic-aware block.
 */

/*
 * Topic colour. --vy-topic paints the chip and the cover's glow; it may be a
 * colour-mix(). The field palette may not: the field runtime parses only
 * 6-digit hex, so --vy-field-mid and --vy-field-hot name tokens that resolve
 * to one. Content systems has no token of its own, so its chip mixes the two
 * colours it sits between and its field draws in both.
 */
.vy-topic-seo { --vy-topic: var(--service-seo); --vy-field-mid: var(--color-cyan-500); --vy-field-hot: var(--color-cyan-400); }
.vy-topic-wordpress { --vy-topic: var(--service-wordpress); --vy-field-mid: var(--color-violet-450); --vy-field-hot: var(--color-violet-300); }
.vy-topic-ai { --vy-topic: var(--service-ai); --vy-field-mid: var(--color-service-ai-700); --vy-field-hot: var(--color-service-ai-500); }
.vy-topic-content { --vy-topic: color-mix(in oklab, var(--service-seo) 55%, var(--service-wordpress)); --vy-field-mid: var(--color-violet-300); --vy-field-hot: var(--color-cyan-400); }
.vy-topic-marketing { --vy-topic: var(--service-marketing); --vy-field-mid: var(--color-magenta-450); --vy-field-hot: var(--color-magenta-400); }

/*
 * Service colour (VOY-1611). inc/note-service.php adds vy-practice-<practice>
 * to a service tag, a guide tile and a chip: the practice's own token, which
 * is what the round 2 boards paint each service in. It sets --vy-topic too, so
 * a service tag reuses the topic chip's look below.
 */
.vy-practice-seo { --vy-service: var(--service-seo); --vy-topic: var(--service-seo); }
.vy-practice-wordpress { --vy-service: var(--service-wordpress); --vy-topic: var(--service-wordpress); }
.vy-practice-ai { --vy-service: var(--service-ai); --vy-topic: var(--service-ai); }
.vy-practice-social { --vy-service: var(--service-social); --vy-topic: var(--service-social); }
.vy-practice-ads { --vy-service: var(--service-ads); --vy-topic: var(--service-ads); }

/* The fallback for a post with no topic. Zero specificity, so the topic
   classes above win although they sit on the same element. */
:where(.vy-note-cover) {
	--vy-topic: var(--accent-bright);
	--vy-field-mid: var(--color-violet-300);
	--vy-field-hot: var(--color-violet-500);
}

.vy-note-cover {
	position: relative;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	border: 1px solid var(--border-1);
	border-radius: 6px;
	background: var(--bg-panel);
	/*
	 * The field palette. voyager/ascii-field reads these from the element it
	 * hydrates (getComputedStyle), so setting them here repaints the cover by
	 * topic without touching the block. Hex tokens only; see above.
	 */
	--wp--preset--color--field-bg: var(--color-indigo-900);
	--wp--preset--color--field-dim: var(--color-bone-300);
	--wp--preset--color--field-mid: var(--vy-field-mid);
	--wp--preset--color--field-hot: var(--vy-field-hot);
	--wp--preset--color--field-accent: var(--vy-field-hot);
	--wp--preset--color--info: var(--vy-field-hot);
}

/* The topic glow over the field. The runtime fills its canvas with field-bg on
   every frame, so the glow sits above it and screens the glyphs. */
.vy-note-cover::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	background: radial-gradient(120% 90% at 80% 15%, color-mix(in srgb, var(--vy-topic) 20%, transparent), transparent 60%);
	mix-blend-mode: screen;
	pointer-events: none;
}

.vy-note-cover > .voyager-ascii-field {
	position: absolute;
	inset: 0;
	min-height: 0 !important; /* the block writes an inline min-height floor */
	margin: 0;
}

/*
 * The static poster: the design system's groundtrack render, shown only where
 * no field canvas sits inside the cover (the ascii_field flag is off, so the
 * block is not registered and only its overlay content renders).
 */
.vy-note-cover:not(:has(.voyager-ascii-field__canvas))::before {
	content: "";
	position: absolute;
	inset: 0;
	background: url("../../design-system/assets/ascii/blog-groundtrack.png") center / cover no-repeat;
	opacity: 0.55;
	pointer-events: none;
}

.vy-note-cover .vy-note-cover__seed {
	position: absolute;
	left: 14px;
	bottom: 12px;
	z-index: 2;
	margin: 0;
	font-family: var(--wp--preset--font-family--mono);
	font-size: 9.5px;
	line-height: 1;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--fg-4);
}

.vy-note-cover .voyager-ascii-field__content {
	position: static;
}

/* The topic chip: a square in the topic colour, then the label. */
.vy-note-topic {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	margin: 0;
	font-family: var(--wp--preset--font-family--mono);
	font-size: 10.5px;
	line-height: 1.2;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--vy-topic, var(--fg-4));
}

.vy-note-topic::before {
	content: "";
	flex: none;
	width: 6px;
	height: 6px;
	border-radius: 1px;
	background: currentColor;
}
