/*
 * "Premiado" seal ([textual_selo_premiado] and the trabalhos grid cards).
 *
 * Base state is OPEN on purpose: with no JavaScript, or under
 * prefers-reduced-motion, the word must be there. js/main.js sets
 * `html.textual-js` only when motion is welcome, and that is what opts the
 * seal into collapsing to icon-only.
 */

.textual-selo {
	--selo-bg: #fbb118;
	--selo-fg: #000;
	--selo-dur: 0.38s;
	--selo-ease: cubic-bezier(0.22, 0.61, 0.36, 1);

	position: relative;
	display: inline-flex;
	align-items: center;
	/* No gap: the icon/label spacing lives inside the label so it collapses with it. */
	gap: 0;
	border-radius: 999px;
	overflow: hidden;
	background: var(--selo-bg);
	color: var(--selo-fg);
	line-height: 1;
	box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.6);
	transition: padding var(--selo-dur) var(--selo-ease);
}

.textual-selo__icone {
	flex: none;
	display: block;
}

.textual-selo__rotulo {
	display: grid;
	grid-template-columns: 1fr;
	transition: grid-template-columns var(--selo-dur) var(--selo-ease);
}

/* The grid item must be padding-free: padding on it survives a 0fr column and
   would stop the seal from ever closing to a circle. The spacing lives on
   __palavra, which the overflow clips away with the rest of the word. */
.textual-selo__texto {
	min-width: 0;
	overflow: hidden;
}

.textual-selo__palavra {
	display: block;
	white-space: nowrap;
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	padding-inline: 0.45rem 0.15rem;
}

/* Accessible name: the visible label is clipped while collapsed, so it is
   aria-hidden and this copy carries the word for assistive tech at all times. */
.textual-selo__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* Variante grade — mark pinned to the card corner. */

/* Padding-right matches the open state, so the no-JS and reduced-motion seal
   is identical to the opened one; html.textual-js tightens it into a circle. */
.textual-selo--grade {
	position: absolute;
	top: clamp(0.9rem, 2vw, 1.25rem);
	right: clamp(0.9rem, 2vw, 1.25rem);
	z-index: 2;
	padding: 0.55rem 0.85rem 0.55rem 0.55rem;
}

.textual-selo--grade .textual-selo__icone {
	width: 1.35rem;
	height: 1.35rem;
}

/* Variante hero — larger, in flow, above the single's title. */

.textual-selo--hero {
	padding: 0.4rem 0.8rem 0.4rem 0.8rem;
}

.textual-selo--hero .textual-selo__icone {
	width: 1.6rem;
	height: 1.6rem;
}

.textual-selo--hero .textual-selo__palavra {
	font-size: 0.82rem;
	padding-inline: 0.55rem 0.2rem;
}

/* Collapsed state — only where motion is welcome (html.textual-js). */

html.textual-js .textual-selo .textual-selo__rotulo {
	grid-template-columns: 0fr;
}

html.textual-js .textual-selo--grade {
	padding-right: 0.55rem;
}

html.textual-js .textual-selo--hero {
	padding-right: 0.7rem;
}

/* Open again: on hover/focus of the card (grade), or once JS opens it for
   good (touch grids and every hero). */

html.textual-js .textual-selo.is-aberto .textual-selo__rotulo {
	grid-template-columns: 1fr;
}

html.textual-js .textual-selo--grade.is-aberto {
	padding-right: 0.85rem;
}

html.textual-js .textual-selo--hero.is-aberto {
	padding-right: 1rem;
}

/* Pointer-driven reveal. Scoped to (hover: hover) so touch devices never rely
   on an interaction they cannot perform — there, JS opens the seal instead.
   The .ttg-card coupling is deliberate: the card is the hover target, and the
   grade variant only ever exists inside one. */
@media (hover: hover) {
	html.textual-js .ttg-card:hover .textual-selo--grade .textual-selo__rotulo,
	html.textual-js .ttg-card:focus-visible .textual-selo--grade .textual-selo__rotulo {
		grid-template-columns: 1fr;
	}

	html.textual-js .ttg-card:hover .textual-selo--grade,
	html.textual-js .ttg-card:focus-visible .textual-selo--grade {
		padding-right: 0.85rem;
	}

	/* Sweep again on hover/focus. The delay lets the label finish opening
	   first, so the light crosses the full pill instead of a growing one —
	   the same order the automatic path uses. Leaving before it opens simply
	   never plays it, which keeps incidental mouse-overs quiet. */
	html.textual-js .ttg-card:hover .textual-selo--grade::after,
	html.textual-js .ttg-card:focus-visible .textual-selo--grade::after {
		animation: textual-selo-brilho 0.9s var(--selo-ease) var(--selo-dur);
	}
}

/* Brilho — a specular sweep crossing the seal once. Transform only. */

.textual-selo::after {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	width: 60%;
	pointer-events: none;
	background: linear-gradient(
		105deg,
		rgba(255, 255, 255, 0) 0%,
		rgba(255, 255, 255, 0.85) 50%,
		rgba(255, 255, 255, 0) 100%
	);
	transform: translateX(-180%);
}

html.textual-js .textual-selo.is-brilhando::after {
	animation: textual-selo-brilho 0.9s var(--selo-ease);
}

@keyframes textual-selo-brilho {
	from {
		transform: translateX(-180%);
	}
	to {
		transform: translateX(340%);
	}
}

/* Reduced motion: seal stays open, nothing moves. The html.textual-js guard
   already covers this (main.js does not set the class), but the explicit
   override protects the component if it is ever used outside that gate. */
@media (prefers-reduced-motion: reduce) {
	.textual-selo,
	.textual-selo .textual-selo__rotulo {
		transition: none;
	}

	html.textual-js .textual-selo .textual-selo__rotulo {
		grid-template-columns: 1fr;
	}

	html.textual-js .textual-selo--grade {
		padding-right: 0.85rem;
	}

	html.textual-js .textual-selo--hero {
		padding-right: 1rem;
	}

	.textual-selo::after {
		display: none;
	}
}
