/**
 * Keyword Density Checker - Content Preview & Highlight Styles
 *
 * Styles for the content preview panel with inline keyword highlighting,
 * occurrence badges, navigation controls, and scroll-to functionality.
 *
 * @package AgenticWP
 */

/* ============================================
   Content Preview Panel
   ============================================ */

#content-preview-panel {
	background: var(--tool-bg);
	border: 1px solid var(--tool-border);
	border-radius: var(--tool-radius-lg);
	padding: var(--kd-card-padding);
}

#content-preview-panel .panel-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--tool-space-md);
	margin-bottom: var(--tool-space-md);
}

#content-preview-panel .panel-title {
	margin: 0;
	font-size: var(--tool-text-lg);
	font-weight: 600;
	color: var(--tool-text);
}

/* ============================================
   Content Preview Container
   ============================================ */

.content-preview {
	max-height: 400px;
	overflow-y: auto;
	padding: var(--tool-space-md);
	background: var(--tool-bg-subtle);
	border: 1px solid var(--tool-border);
	border-radius: var(--tool-radius-md);
	font-size: var(--tool-text-base);
	line-height: 1.7;
	color: var(--tool-text);
	scroll-behavior: smooth;
}

.content-preview:focus {
	outline: 2px solid var(--kd-accent);
	outline-offset: 2px;
}

.content-preview p {
	margin: 0 0 1em;
}

.content-preview p:last-child {
	margin-bottom: 0;
}

/* Empty state */
.content-preview:empty::before {
	content: 'Content preview will appear here after analysis.';
	color: var(--tool-text-muted);
	font-style: italic;
}

/* ============================================
   Keyword Highlights
   ============================================ */

.keyword-highlight {
	position: relative;
	display: inline;
	padding: 2px 4px;
	margin: 0 1px;
	background: var(--kd-highlight-bg);
	color: var(--kd-highlight-text);
	border-radius: var(--tool-radius-sm);
	cursor: pointer;
	transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.keyword-highlight:hover {
	background: var(--kd-highlight-bg-hover);
	color: var(--kd-highlight-current-text);
}

.keyword-highlight:focus {
	outline: 2px solid var(--kd-accent);
	outline-offset: 1px;
}

/* Current occurrence (selected) */
.keyword-highlight.current {
	background: var(--kd-highlight-current-bg);
	color: var(--kd-highlight-current-text);
	box-shadow: 0 0 0 2px var(--kd-accent-dark), 0 4px 8px rgba(249, 115, 22, 0.3);
}

/* ============================================
   Occurrence Badges
   ============================================ */

.occurrence-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 18px;
	height: 18px;
	padding: 0 4px;
	margin-left: 4px;
	font-size: 10px;
	font-weight: 600;
	line-height: 1;
	color: var(--tool-bg);
	background: var(--kd-accent-dark);
	border-radius: var(--tool-radius-full);
	vertical-align: middle;
}

.keyword-highlight:hover .occurrence-badge,
.keyword-highlight.current .occurrence-badge {
	background: var(--tool-bg);
	color: var(--kd-accent-dark);
}

/* ============================================
   Occurrence Navigator
   ============================================ */

.occurrence-navigator {
	display: flex;
	align-items: center;
	gap: var(--tool-space-xs);
	padding: var(--tool-space-xs) var(--tool-space-sm);
	background: var(--tool-bg-subtle);
	border-radius: var(--tool-radius-full);
}

.occurrence-navigator[hidden] {
	display: none;
}

.occurrence-navigator .nav-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px; /* WCAG 2.2 AAA touch target */
	height: 44px; /* WCAG 2.2 AAA touch target */
	padding: 0;
	background: transparent;
	border: 1px solid var(--tool-border);
	border-radius: var(--tool-radius-full);
	color: var(--tool-text);
	cursor: pointer;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.occurrence-navigator .nav-btn:hover:not(:disabled) {
	background: var(--kd-accent-bg);
	border-color: var(--kd-accent);
	color: var(--kd-accent);
}

.occurrence-navigator .nav-btn:focus {
	outline: 2px solid var(--kd-accent);
	outline-offset: 1px;
}

.occurrence-navigator .nav-btn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.occurrence-navigator .nav-btn svg {
	width: 14px;
	height: 14px;
	flex-shrink: 0;
}

.occurrence-count {
	min-width: 60px;
	font-size: var(--tool-text-sm);
	font-weight: 500;
	color: var(--tool-text);
	text-align: center;
	white-space: nowrap;
}

/* ============================================
   Scroll Indicator
   ============================================ */

.content-preview--scrolling .keyword-highlight.current {
	animation: highlight-pulse 0.6s ease-out;
}

@keyframes highlight-pulse {
	0% {
		box-shadow: 0 0 0 2px var(--kd-accent-dark), 0 4px 8px rgba(249, 115, 22, 0.3);
	}
	50% {
		box-shadow: 0 0 0 6px rgba(249, 115, 22, 0.3), 0 4px 16px rgba(249, 115, 22, 0.4);
	}
	100% {
		box-shadow: 0 0 0 2px var(--kd-accent-dark), 0 4px 8px rgba(249, 115, 22, 0.3);
	}
}

/* ============================================
   Responsive Styles
   ============================================ */

@media (max-width: 680px) {
	#content-preview-panel .panel-header {
		flex-direction: column;
		align-items: flex-start;
	}

	.occurrence-navigator {
		width: 100%;
		justify-content: center;
	}

	.content-preview {
		max-height: 300px;
		font-size: var(--tool-text-sm);
	}

	.occurrence-badge {
		min-width: 16px;
		height: 16px;
		font-size: 9px;
	}
}

/* ============================================
   Reduced Motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
	.content-preview {
		scroll-behavior: auto;
	}

	.keyword-highlight,
	.occurrence-navigator .nav-btn {
		transition: none;
	}

	.content-preview--scrolling .keyword-highlight.current {
		animation: none;
	}
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
	#content-preview-panel {
		break-inside: avoid;
		border: 1px solid #ccc;
	}

	.occurrence-navigator {
		display: none;
	}

	.content-preview {
		max-height: none;
		overflow: visible;
	}

	.keyword-highlight {
		background: #ffeb3b !important;
		color: #000 !important;
		-webkit-print-color-adjust: exact;
		print-color-adjust: exact;
	}

	.occurrence-badge {
		display: none;
	}
}

/* ============================================
   High Contrast Mode
   ============================================ */

@media (prefers-contrast: more) {
	.keyword-highlight {
		background: #ffff00;
		color: #000;
		outline: 2px solid #000;
	}

	.keyword-highlight.current {
		background: #ff6600;
		outline: 3px solid #000;
	}

	.occurrence-badge {
		background: #000;
		color: #fff;
	}
}
