/* In-place Term Popover component styles (Task A-160).
   Stazora Design System compliant:
   - Role tokens only (no hex, rgba, raw px font sizes, raw radii, or shadow literals).
   - Namespaced with .stz-term- prefix.
   - Touch targets >= 44px (var(--stz-hit)) and interactive font size >= 14px (var(--stz-fs-sub)).
   - Motion is enabled for everyone (effects stay on for all users).
*/

.stz-term-ref {
	color: var(--stz-link);
	text-decoration: underline;
	text-decoration-style: dotted;
	text-decoration-thickness: 1px;
	text-underline-offset: var(--stz-space-1);
	position: relative;
	cursor: pointer;
	border-radius: var(--stz-radius-control);
	transition: background-color var(--stz-dur-press) var(--stz-ease-press), color var(--stz-dur-press) var(--stz-ease-press);
}

.stz-term-ref:hover {
	text-decoration-thickness: 2px;
	background-color: var(--stz-fill);
}

.stz-term-ref:focus-visible {
	outline: 3px solid var(--stz-focus);
	outline-offset: 2px;
	background-color: var(--stz-fill);
}

.stz-term-ref[aria-expanded="true"] {
	background-color: var(--stz-fill-hover);
	text-decoration-style: solid;
}

/* Touch hit expansion for coarse pointers (min 44px target) */
@media (pointer: coarse) {
	.stz-term-ref::after {
		content: "";
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		min-width: var(--stz-hit);
		min-height: var(--stz-hit);
		width: 100%;
		height: 100%;
		pointer-events: auto;
	}
}

/* Popover card container */
.stz-term-popover {
	position: absolute;
	z-index: var(--stz-z-raised);
	width: min(22rem, calc(100vw - var(--stz-space-6)));
	background-color: var(--stz-surface);
	border: 1px solid var(--stz-hairline);
	border-radius: var(--stz-radius-panel);
	box-shadow: var(--stz-shadow-popover);
	padding: var(--stz-space-4) var(--stz-space-5);
	box-sizing: border-box;
	opacity: 0;
	transform: translateY(var(--stz-space-1));
	pointer-events: none;
	visibility: hidden;
	transition: opacity var(--stz-dur-fade) var(--stz-ease), transform var(--stz-dur-fade) var(--stz-ease), visibility var(--stz-dur-fade);
}

.stz-term-popover.stz-term-open {
	opacity: 1;
	transform: translateY(0);
	pointer-events: auto;
	visibility: visible;
}

.stz-term-popover[data-placement="top"] {
	transform: translateY(calc(var(--stz-space-1) * -1));
}

.stz-term-popover[data-placement="top"].stz-term-open {
	transform: translateY(0);
}

/* Popover header row: title + close button */
.stz-term-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: var(--stz-space-3);
	margin-bottom: var(--stz-space-2);
}

.stz-term-title {
	font-family: var(--stz-font);
	font-size: var(--stz-fs-title3);
	font-weight: var(--stz-fw-semibold);
	line-height: var(--stz-lh-title);
	letter-spacing: var(--stz-track-title);
	color: var(--stz-text);
	margin: 0;
}

/* 44px close button */
.stz-term-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: var(--stz-hit);
	min-height: var(--stz-hit);
	padding: 0;
	margin: calc(var(--stz-space-1) * -1) calc(var(--stz-space-2) * -1) 0 0;
	border: 0;
	background-color: var(--stz-fill);
	color: var(--stz-text);
	border-radius: 50%;
	cursor: pointer;
	font-family: var(--stz-font);
	font-size: var(--stz-fs-title3);
	line-height: 1;
	flex-shrink: 0;
	transition: background-color var(--stz-dur-press) var(--stz-ease-press), transform var(--stz-dur-press) var(--stz-ease-press);
}

.stz-term-close:hover {
	background-color: var(--stz-fill-hover);
}

.stz-term-close:active {
	background-color: var(--stz-fill-press);
	transform: scale(0.97);
}

.stz-term-close:focus-visible {
	outline: 3px solid var(--stz-focus);
	outline-offset: 2px;
}

/* Popover definition paragraph */
.stz-term-desc {
	font-family: var(--stz-font);
	font-size: var(--stz-fs-body);
	line-height: var(--stz-lh-body);
	letter-spacing: var(--stz-track-body);
	color: var(--stz-text);
	margin: 0 0 var(--stz-space-4) 0;
	overflow-wrap: break-word;
}

/* Popover footer: full explanation link */
.stz-term-footer {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	border-top: 1px solid var(--stz-hairline);
	padding-top: var(--stz-space-3);
}

.stz-term-more {
	display: inline-flex;
	align-items: center;
	min-height: var(--stz-hit);
	font-family: var(--stz-font);
	font-size: var(--stz-fs-sub);
	font-weight: var(--stz-fw-medium);
	color: var(--stz-link);
	text-decoration: underline;
	text-underline-offset: var(--stz-space-1);
	border-radius: var(--stz-radius-control);
	transition: color var(--stz-dur-press) var(--stz-ease-press);
}

.stz-term-more:hover {
	text-decoration-thickness: 2px;
	color: var(--stz-cta-hover);
}

.stz-term-more:focus-visible {
	outline: 3px solid var(--stz-focus);
	outline-offset: 2px;
}

/* Increased contrast adjustments */
@media (prefers-contrast: more) {
	.stz-term-popover {
		border-color: var(--stz-ring);
		box-shadow: var(--stz-ring-contrast);
	}
	.stz-term-close {
		border: 1px solid var(--stz-hairline);
	}
}

/* Forced colours mode (Windows high contrast) */
@media (forced-colors: active) {
	.stz-term-popover {
		border: 2px solid CanvasText;
	}
	.stz-term-close {
		border: 1px solid ButtonText;
	}
	.stz-term-more {
		color: LinkText;
	}
}
