/*
	Hybrid shell styles for Pathfinder traditional theme.
	Keeps SVG task rendering, migrates outer layout to semantic HTML/CSS.
*/

:root {
	--pf-bg: #EDF4FD;
	--pf-card-bg: #FFFFFF;
	--pf-text: #333;
	--pf-muted: #6f7785;
	--pf-brand: #4A6CF7;
	--pf-border: #E5E4E6;
	--pf-shadow: 0 2px 16px rgba(229, 228, 230, 0.6);
}

*, *::before, *::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

html,
body {
	height: 100%;
}

body {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	background: var(--pf-bg);
	color: var(--pf-text);
}

/* Scoped redesign overrides for PF2nr/PF3ml/PF4mr pages */
.pf-redesign #loading-msg,
.pf-redesign #progress-container {
	display: none !important;
}

.pf-redesign #test-welcome > rect,
.pf-redesign #feedback-inst > rect,
.pf-redesign #feedback > rect,
.pf-redesign #instructions > rect,
.pf-redesign #example > rect,
.pf-redesign #ending rect,
.pf-redesign #submission-error rect {
	opacity: 0 !important;
	fill: transparent !important;
	stroke: none !important;
}

.pf-redesign .ok-btn rect,
.pf-redesign #submit-btn-container use,
.pf-redesign .nextBtn-disabled,
.pf-redesign .nextBtn-enabled {
	fill: var(--pf-brand) !important;
	stroke: none !important;
	opacity: 1 !important;
	transition: opacity 0.2s ease, fill 0.2s ease;
}

.pf-redesign .ok-btn:hover rect,
.pf-redesign #submit-btn-container use:hover,
.pf-redesign .nextBtn-enabled:hover {
	fill: #3a59d4 !important;
	opacity: 1 !important;
	cursor: pointer;
}

.pf-redesign .ok-btn:active rect,
.pf-redesign #submit-btn-container use:active,
.pf-redesign .nextBtn-enabled:active {
	fill: #2f49b0 !important;
}

.pf-redesign .ok-btn text,
.pf-redesign .nextBtn-text {
	fill: #fff !important;
	stroke: none !important;
	font-weight: 600;
}

.results-screen {
	display: none;
	width: 100%;
	height: 100%;
	flex-direction: column;
	justify-content: center;
	gap: 32px;
}

.results-screen[style*="display: flex"] {
	opacity: 1;
}

.results-header {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	text-align: center;
}

.results-title {
	font-size: 36px;
	font-weight: 700;
}

.results-subtitle {
	font-size: 16px;
	color: var(--pf-muted);
	max-width: 560px;
}

.results-body {
    display: flex;
    align-items: center;
    justify-content: center;
	flex-direction: row;
	align-items: center;
	gap: 32px;
	width: 100%;
}

.results-chart-card {
	width: 100%;
	max-width: 360px;
	aspect-ratio: 1 / 1;
	padding: 16px;
	border-radius: 18px;
	background: #f6f8ff;
	box-shadow: inset 0 0 0 1px rgba(74, 108, 247, 0.15);
}

#results-chart {
	width: 100% !important;
	height: 100% !important;
}

.results-legend {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.results-legend-row {
	display: grid;
	grid-template-columns: 16px 1fr;
	align-items: center;
	gap: 12px;
	font-size: 15px;
}

.results-legend-color {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: #4A6CF7;
}

.results-legend-row:nth-child(1) .results-legend-color { background: #4A6CF7; }
.results-legend-row:nth-child(2) .results-legend-color { background: #38BDF8; }
.results-legend-row:nth-child(3) .results-legend-color { background: #F59E0B; }
.results-legend-row:nth-child(4) .results-legend-color { background: #22C55E; }
.results-legend-row:nth-child(5) .results-legend-color { background: #EC4899; }

.results-legend-title {
	color: var(--pf-text);
}

@media (max-width: 600px) {
	.results-body {
		align-items: center;
	}

	.results-legend {
		width: 100%;
		max-width: 420px;
	}
}

.pf-app {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-height: 0;
}

.pf-header {
	display: flex;
	align-items: center;
	padding: 16px 32px;
	background: var(--pf-bg);
}

.pf-branding {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 16px;
	font-weight: 600;
	color: var(--pf-text);
}

.pf-logo-icon {
	width: 28px;
	height: 28px;
	border-radius: 4px;
	background: var(--pf-brand);
	flex-shrink: 0;
}

.page {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 32px;
	min-height: 0;
}

.card.task-card {
	background: var(--pf-card-bg);
	border-radius: 16px;
	box-shadow: var(--pf-shadow);
	padding: 48px 64px;
	width: 100%;
	max-width: 1320px;
	height: 100%;
	max-height: 860px;
	display: flex;
	flex-direction: column;
	align-items: center;
	position: relative;
}

#task-container {
	margin: 0;
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	position: relative;
}

#item-container {
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	position: relative;
}

#svg-container {
	position: absolute;
	top: 0;
	left: 0;
}

#svg-content {
	max-width: 100%;
	max-height: 100%;
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Focus visibility for keyboard navigation */
*:focus-visible {
	outline: 2px solid var(--pf-brand);
	outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}

/* Mobile & tablet optimizations */
@media (max-width: 900px) {
	.pf-header {
		padding: 12px 20px;
	}

	.page {
		padding: 20px;
	}

	.card.task-card {
		padding: 32px 40px;
		border-radius: 12px;
		max-height: none;
	}
}

@media (max-width: 768px) {
	.pf-header {
		padding: 10px 16px;
	}

	.pf-branding {
		font-size: 15px;
	}

	.page {
		padding: 16px;
	}

	.card.task-card {
		padding: 24px 32px;
		border-radius: 12px;
	}
}

@media (max-width: 480px) {
	.pf-header {
		padding: 8px 12px;
	}

	.pf-logo-icon {
		width: 24px;
		height: 24px;
	}

	.pf-branding {
		font-size: 14px;
	}

	.page {
		padding: 12px;
	}

	.card.task-card {
		padding: 16px 20px;
		border-radius: 10px;
	}
}

/* ---- HTML UI Components from Sample Design ---- */

/* Item screens */
.item-screen,
.instructions-screen,
.ending-screen {
	display: none;
	width: 100%;
	height: 100%;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 24px;
	opacity: 0;
	transition: opacity 0.3s ease;
}

/* Visible state - applied via JavaScript */
.item-screen[style*="display: flex"],
.instructions-screen[style*="display: flex"],
.ending-screen[style*="display: flex"] {
	opacity: 1;
}

.item-screen .card,
.instructions-screen .card,
.ending-screen .card {
	background: transparent;
	box-shadow: none;
	padding: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 24px;
	width: 100%;
	max-width: 680px;
	position: relative;
}

/* Timer */
.timer {
	position: absolute;
	top: -30px;
	left: 0;
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 14px;
	color: var(--pf-text);
}

.timer.timer--urgent {
	color: #E53935;
}

.timer-icon {
	font-size: 16px;
}

.timer-value {
	font-weight: 500;
}

/* Section label */
.section-label {
	font-size: 14px;
	color: #888;
	letter-spacing: 0.5px;
	text-align: center;
	margin-top: 8px;
}

/* Card title */
.card-title {
	font-size: 28px;
	font-weight: 600;
	color: var(--pf-brand);
	text-align: center;
	margin: 0;
}

/* Card instructions */
.card-instructions {
	font-size: 18px;
	color: var(--pf-text);
	text-align: center;
	line-height: 1.5;
}

/* Card body */
.card-body {
	font-size: 16px;
	color: var(--pf-text);
	line-height: 1.8;
	text-align: left;
	width: 100%;
}

.card-body p {
	margin-bottom: 8px;
}

.card-body strong {
	font-weight: 600;
	color: var(--pf-brand);
}

/* Buttons */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 14px 40px;
	border-radius: 8px;
	border: none;
	font-size: 16px;
	font-weight: 500;
	cursor: pointer;
	transition: opacity 0.2s, background-color 0.2s;
	width: 100%;
	max-width: 320px;
	font-family: inherit;
}

.btn-primary {
	background-color: var(--pf-brand);
	color: #fff;
}

.btn-primary:hover {
	background-color: #3a59d4;
}

.btn-primary:disabled {
	background-color: #a0b0f5;
	cursor: not-allowed;
}

/* Options grid (2-column) */
.options-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
	width: 100%;
}

/* Option button */
.option-btn {
	padding: 14px 20px;
	border-radius: 8px;
	border: 1.5px solid var(--pf-border);
	background: #fff;
	font-size: 16px;
	color: var(--pf-text);
	cursor: pointer;
	text-align: center;
	transition: border-color 0.15s, background 0.15s;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	font-family: inherit;
}

.option-btn:hover {
	border-color: var(--pf-brand);
}

.option-btn.selected {
	border-color: var(--pf-brand);
	color: var(--pf-brand);
	background: #f0f4ff;
}

.option-btn.correct {
	border-color: #43A047;
	color: #43A047;
	background: #f0fdf4;
}

.option-btn.wrong {
	border-color: #E53935;
	color: #E53935;
	background: #fff5f5;
}

/* Timeout overlay */
.timeout-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(255, 255, 255, 0.95);
	display: none;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	z-index: 10;
}

.timeout-message {
	font-size: 24px;
	font-weight: 600;
	color: #E53935;
	margin: 0;
}

.timeout-submessage {
	font-size: 16px;
	color: var(--pf-muted);
	margin: 0;
}

/* End message */
.pf-end-message {
	font-size: 24px;
	font-weight: 400;
	color: var(--pf-text);
	text-align: center;
	line-height: 1.6;
	margin: 0;
}

/* Keyboard */
.keyboard {
	width: 100%;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.keyboard-row {
	display: flex;
	justify-content: center;
	gap: 6px;
}

.key-btn {
	width: 44px;
	height: 44px;
	border-radius: 6px;
	border: 1.5px solid var(--pf-border);
	background: #fff;
	font-size: 15px;
	font-weight: 500;
	color: var(--pf-text);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: border-color 0.1s, background 0.1s;
	font-family: inherit;
}

.key-btn:hover {
	border-color: var(--pf-brand);
	background: #f0f4ff;
}

.key-btn.selected {
	border-color: var(--pf-brand);
	color: var(--pf-brand);
	background: #f0f4ff;
}

/* Word display */
.word-display {
	font-size: 36px;
	font-weight: 600;
	color: var(--pf-brand);
	letter-spacing: 2px;
	text-align: center;
}

.word-display .blank {
	display: inline-block;
	min-width: 28px;
	border-bottom: 3px solid var(--pf-brand);
	margin: 0 2px;
}

.word-display.wrong-word {
	color: #E53935;
}

/* Keyboard toggle */
.keyboard-toggle {
	font-size: 14px;
	color: #888;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 6px;
	text-decoration: none;
	align-self: center;
}

.keyboard-toggle:hover {
	color: var(--pf-brand);
}

/* Responsive adjustments for UI components */
@media (max-width: 768px) {
	.options-grid {
		grid-template-columns: 1fr;
	}
	
	.card-title {
		font-size: 24px;
	}
	
	.option-btn {
		padding: 12px 16px;
		font-size: 15px;
	}
	
	.btn {
		padding: 12px 32px;
		font-size: 15px;
	}
}

@media (max-width: 480px) {
	.card-title {
		font-size: 20px;
	}
	
	.card-body {
		font-size: 14px;
	}
	
	.option-btn {
		padding: 10px 12px;
		font-size: 14px;
	}
	
	.btn {
		padding: 10px 24px;
		font-size: 14px;
	}
	
	.timeout-message {
		font-size: 20px;
	}
	
	.timeout-submessage {
		font-size: 14px;
	}
}
