/* ========================================
   CSS Variables - Friendly & Approachable Color Scheme
   ======================================== */
:root {
	/* Primary Colors - Soft Blue (Calm, Friendly) */
	--color-primary: #5B9BD5;
	--color-primary-dark: #4A8BC2;
	--color-primary-light: #7FB3E8;

	/* Secondary Colors - Warm Green (Growth, Encouragement) */
	--color-secondary: #52C17A;
	--color-secondary-dark: #42A869;
	--color-secondary-light: #6DD68E;

	/* Accent Color - Coral (Warm, Inviting) */
	--color-accent: #FF9A76;
	--color-accent-dark: #FF7F5C;
	--color-accent-light: #FFB599;

	/* Neutral Colors - Warm and Soft */
	--color-bg-primary: #FFF8F3;
	--color-bg-card: #FFFFFF;
	--color-bg-section: #FFF4ED;
	--color-text-primary: #2C3E50;
	--color-text-secondary: #7B8794;
	--color-text-light: white;
	--color-border: #F0E5DD;
	--color-shadow: rgba(0, 0, 0, 0.08);

	/* Success/Info/Warning - Softer versions */
	--color-success: #52C17A;
	--color-info: #5B9BD5;
	--color-warning: #FFB84D;

	/* Spacing */
	--spacing-xs: 4px;
	--spacing-sm: 8px;
	--spacing-md: 16px;
	--spacing-lg: 24px;
	--spacing-xl: 32px;
	--spacing-2xl: 48px;

	/* Typography */
	--font-family-primary: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
	--font-family-chinese: 'Noto Sans SC', 'Microsoft YaHei', 'PingFang SC', sans-serif;
	--font-size-base: 16px;
	--font-size-sm: 14px;
	--font-size-lg: 18px;
	--font-size-xl: 24px;
	--font-size-2xl: 32px;
	--font-size-3xl: 48px;

	/* Canvas & Layout */
	--canvas-size: 400px;
	--container-max-width: 1280px;
	--transition-speed: 300ms;

	/* Shadows - Softer, more friendly */
	--shadow-sm: 0 2px 4px 0 rgba(255, 154, 118, 0.08);
	--shadow-default: 0 2px 8px 0 rgba(91, 155, 213, 0.12);
	--shadow-md: 0 4px 12px -2px rgba(91, 155, 213, 0.15);
	--shadow-lg: 0 8px 20px -4px rgba(91, 155, 213, 0.18);
	--shadow-xl: 0 12px 28px -6px rgba(91, 155, 213, 0.2);

	/* Border Radius - More rounded, friendly */
	--radius-sm: 8px;
	--radius-md: 12px;
	--radius-lg: 16px;
	--radius-xl: 24px;
}

/* ========================================
   Base Styles (KISS Principle)
   ======================================== */
*, *::before, *::after {
	box-sizing: border-box;
}

html {
	font-size: 16px;
}

body {
	background: var(--color-bg-primary);
	margin: 0;
	padding: 0 var(--spacing-md) 80px;
	text-align: center;
	font-family: var(--font-family-primary);
	font-size: var(--font-size-base);
	line-height: 1.6;
}

/* ========================================
   Accessibility (WCAG 2.1 Compliance)
   ======================================== */

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

/* Skip link for keyboard navigation */
.skip-link {
	position: absolute;
	top: -40px;
	left: 0;
	background: var(--color-accent);
	color: var(--color-text-light);
	padding: var(--spacing-sm) var(--spacing-md);
	text-decoration: none;
	z-index: 100;
	font-weight: bold;
}

.skip-link:focus {
	top: 0;
}

/* Focus styles for keyboard navigation (WCAG 2.1 AAA) */
*:focus-visible {
	outline: 3px solid var(--color-accent);
	outline-offset: 2px;
}

/* Usage hint for first-time users */
.usage-hint {
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: white;
	padding: var(--spacing-md);
	border-radius: 8px;
	margin-bottom: var(--spacing-lg);
	position: relative;
	box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
	animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
	from {
		opacity: 0;
		transform: translateY(-10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.usage-hint p {
	margin: 0;
	line-height: 1.6;
}

.close-hint {
	position: absolute;
	top: var(--spacing-sm);
	right: var(--spacing-sm);
	background: rgba(255, 255, 255, 0.2);
	border: none;
	color: white;
	font-size: 24px;
	line-height: 1;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	cursor: pointer;
	transition: background 0.2s;
}

.close-hint:hover,
.close-hint:focus {
	background: rgba(255, 255, 255, 0.3);
}

/* ========================================
   Header & Footer
   ======================================== */
header {
	margin-bottom: var(--spacing-xl);
	text-align: center;
}

.title {
	color: var(--color-text-light);
	background: linear-gradient(to bottom, #333, #222);
	padding: var(--spacing-md) var(--spacing-lg);
	margin: 0;
	text-shadow: 0 0 15px var(--color-title-glow);
	box-shadow: var(--shadow-default);
	font-size: clamp(1.2rem, 4vw, 1.8rem);
}

.subtitle {
	color: var(--color-text-primary);
	font-size: 0.95rem;
	margin: var(--spacing-sm) 0 0 0;
	opacity: 0.8;
}

footer {
	margin-top: var(--spacing-xl);
	padding: var(--spacing-lg);
	color: var(--color-text-primary);
	opacity: 0.8;
}

footer a {
	color: var(--color-accent);
	text-decoration: none;
	transition: opacity var(--transition-speed);
}

footer a:hover {
	opacity: 0.7;
	text-decoration: underline;
}

/* ========================================
   Main Content Sections
   ======================================== */
main {
	max-width: 1200px;
	margin: 0 auto;
}

.input-section,
.canvas-section {
	margin-bottom: var(--spacing-lg);
}

/* ========================================
   Canvas / Target Area
   ======================================== */
#target {
	background: var(--color-bg-card);
	border: 1px solid black;
	width: 100%;
	max-width: var(--canvas-size);
	height: auto;
	aspect-ratio: 1 / 1;
	margin: 0 auto;
	box-shadow: var(--shadow-default);
	text-shadow: var(--shadow-text);
	touch-action: none; /* Better touch handling for quiz mode */
}

/* ========================================
   Forms & Inputs (DRY: Shared styles)
   ======================================== */
input, button {
	outline: none;
	font-family: inherit;
}

.char-form {
	margin: 0 0 var(--spacing-lg);
}

.char-form label {
	display: inline-block;
	margin-right: var(--spacing-sm);
	font-weight: 500;
}

.char-input {
	font-size: var(--font-size-input);
	padding: var(--spacing-sm);
	width: 40px;
	text-align: center;
	border: 1px solid var(--color-border);
	border-radius: 4px;
	transition: border-color var(--transition-speed);
}

.char-input:focus {
	border-color: var(--color-accent);
}

/* ========================================
   Buttons (DRY: Single source of truth)
   ======================================== */
button {
	background: var(--color-bg-card);
	border: 1px solid var(--color-border);
	color: var(--color-text-primary);
	cursor: pointer;
	padding: var(--spacing-sm) var(--spacing-md);
	transition: all var(--transition-speed);
	box-shadow: var(--shadow-default);
	text-shadow: var(--shadow-text);
	border-radius: 4px;
	font-size: var(--font-size-base);
	min-height: 44px; /* Touch-friendly target size (WCAG) */
}

button:hover,
button:focus {
	color: var(--color-accent);
	border-color: var(--color-accent);
	transform: translateY(-1px);
	box-shadow: 0 2px 8px var(--color-shadow);
}

button:active {
	transform: translateY(0);
	box-shadow: var(--shadow-default);
}

.char-form button {
	vertical-align: top;
}

/* ========================================
   Action Buttons Grid
   ======================================== */
.actions {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(95px, 1fr));
	gap: var(--spacing-xs);
	max-width: var(--canvas-size);
	margin: 0 auto var(--spacing-lg);
}

/* ========================================
   Responsive Design (Mobile-First)
   ======================================== */

/* Small devices (landscape phones, 576px and up) */
@media (max-width: 576px) {
	:root {
		--canvas-size: 280px;
		--font-size-base: 13px;
	}

	body {
		padding-left: var(--spacing-sm);
		padding-right: var(--spacing-sm);
	}

	.title {
		font-size: 1.2rem;
		padding: var(--spacing-sm);
	}

	.actions {
		grid-template-columns: repeat(2, 1fr);
	}

	button {
		font-size: 12px;
		padding: var(--spacing-sm);
	}
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991px) {
	:root {
		--canvas-size: 380px;
	}
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
	:root {
		--canvas-size: 450px;
	}

	.actions {
		grid-template-columns: repeat(4, 1fr);
		gap: var(--spacing-sm);
	}
}

/* ========================================
   Dark Mode Support (Progressive Enhancement)
   ======================================== */
@media (prefers-color-scheme: dark) {
	:root {
		--color-bg-primary: #1a1a1a;
		--color-bg-card: #2d2d2d;
		--color-text-primary: #e0e0e0;
		--color-border: #555;
		--color-shadow: rgba(0, 0, 0, 0.4);
	}

	#target {
		border-color: #555;
	}

	button {
		background: #2d2d2d;
	}
}

/* ========================================
   Print Styles (Progressive Enhancement)
   ======================================== */
@media print {
	body {
		background: white;
	}

	.actions,
	.char-form,
	footer {
		display: none;
	}

	#target {
		box-shadow: none;
		border: 2px solid black;
	}
}

/* ========================================
   Homepage Specific Styles
   ======================================== */

/* Hero Section */
.hero-section {
	padding: 80px 20px;
	background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
	color: white;
	margin: -15px;
	margin-bottom: 60px;
	position: relative;
	overflow: hidden;
}

.hero-section::before {
	content: '';
	position: absolute;
	top: 0;
	right: 0;
	width: 40%;
	height: 100%;
	background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y="50" font-size="80" opacity="0.1" fill="white">漢</text></svg>') no-repeat center;
	background-size: contain;
	opacity: 0.3;
}

.hero-content {
	max-width: 800px;
	margin: 0 auto;
}

.hero-title {
	font-size: 3rem;
	font-weight: 700;
	margin-bottom: 24px;
	text-shadow: 0 2px 4px rgba(0,0,0,0.2);
	position: relative;
	z-index: 1;
}

.hero-description {
	font-size: 1.2rem;
	margin-bottom: 30px;
	opacity: 0.95;
	line-height: 1.6;
}

.hero-description strong {
	font-weight: 700;
	color: white;
	background: rgba(255, 255, 255, 0.1);
	padding: 2px 6px;
	border-radius: 4px;
}

/* Value Highlights */
.value-highlights {
	display: flex;
	gap: 24px;
	justify-content: center;
	flex-wrap: wrap;
	margin: 32px 0 48px 0;
	position: relative;
	z-index: 1;
}

.value-item {
	display: flex;
	align-items: center;
	gap: 8px;
	background: rgba(255, 255, 255, 0.15);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	padding: 12px 20px;
	border-radius: 24px;
	font-size: 0.95rem;
	font-weight: 500;
	border: 1px solid rgba(255, 255, 255, 0.2);
	transition: all 0.3s ease;
}

.value-item:hover {
	background: rgba(255, 255, 255, 0.25);
	transform: translateY(-2px);
}

.value-icon {
	font-size: 1.2rem;
	font-weight: 700;
}

/* Starting Point Section */
.starting-point-section {
	margin-top: 48px;
	position: relative;
	z-index: 1;
}

.starting-point-title {
	font-size: 1.5rem;
	font-weight: 700;
	margin-bottom: 24px;
	text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.starting-point-cards {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: 20px;
	max-width: 1200px;
	margin: 0 auto;
}

.starting-card {
	background: white;
	color: var(--color-text-primary);
	padding: 32px 24px;
	border-radius: 12px;
	text-decoration: none;
	transition: all 0.3s ease;
	box-shadow: var(--shadow-lg);
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	border: 2px solid transparent;
	position: relative;
	overflow: hidden;
}

.starting-card::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 4px;
	background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
	transform: scaleX(0);
	transition: transform 0.3s ease;
}

.starting-card:hover::before {
	transform: scaleX(1);
}

.starting-card:hover {
	transform: translateY(-8px);
	box-shadow: var(--shadow-xl);
	border-color: var(--color-primary-light);
}

.starting-card .card-icon {
	font-size: 3rem;
	margin-bottom: 16px;
}

.starting-card h3 {
	font-size: 1.25rem;
	font-weight: 700;
	margin: 0 0 12px 0;
	color: var(--color-text-primary);
}

.starting-card p {
	font-size: 0.95rem;
	color: var(--color-text-secondary);
	margin: 0 0 20px 0;
	line-height: 1.5;
	flex-grow: 1;
}

.starting-card .card-cta {
	display: inline-block;
	padding: 10px 24px;
	background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
	color: white;
	border-radius: 24px;
	font-weight: 600;
	font-size: 0.9rem;
	transition: all 0.3s ease;
}

.starting-card:hover .card-cta {
	background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary));
	transform: scale(1.05);
}

/* Specialized card colors */
.starting-card.card-demo .card-cta {
	background: linear-gradient(135deg, var(--color-info), #0284c7);
}

.starting-card.card-demo:hover .card-cta {
	background: linear-gradient(135deg, #38bdf8, var(--color-info));
}

.starting-card.card-beginner .card-cta {
	background: linear-gradient(135deg, var(--color-success), var(--color-secondary-dark));
}

.starting-card.card-beginner:hover .card-cta {
	background: linear-gradient(135deg, var(--color-secondary-light), var(--color-success));
}

.starting-card.card-vocabulary .card-cta {
	background: linear-gradient(135deg, var(--color-accent), var(--color-accent-dark));
}

.starting-card.card-vocabulary:hover .card-cta {
	background: linear-gradient(135deg, var(--color-accent-light), var(--color-accent));
}

.hero-actions {
	display: flex;
	gap: 15px;
	justify-content: center;
	flex-wrap: wrap;
}

/* Button Styles */
.btn {
	display: inline-block;
	padding: 12px 30px;
	border-radius: 8px;
	text-decoration: none;
	font-weight: 600;
	transition: all 0.3s ease;
	cursor: pointer;
	border: none;
	font-size: 1rem;
}

.btn-primary {
	background: var(--color-secondary);
	color: white;
}

.btn-primary:hover {
	background: var(--color-secondary-dark);
	transform: translateY(-2px);
	box-shadow: var(--shadow-lg);
}

.btn-secondary {
	background: white;
	color: var(--color-primary);
	border: 2px solid white;
}

.btn-secondary:hover {
	background: var(--color-bg-section);
	transform: translateY(-2px);
}

.btn-large {
	padding: 15px 40px;
	font-size: 1.1rem;
}

/* Section Styles */
.section-title {
	font-size: 2rem;
	color: var(--color-text-primary);
	margin-bottom: 12px;
	font-weight: 700;
	line-height: 1.2;
	text-align: center;
}

.section-description {
	font-size: 1.063rem;
	color: var(--color-text-secondary);
	margin-bottom: 40px;
	line-height: 1.6;
	text-align: center;
	max-width: 700px;
	margin-left: auto;
	margin-right: auto;
}

/* Demo Section */
.demo-section {
	padding: 40px 20px;
	max-width: 1000px;
	margin: 0 auto;
}

.demo-container {
	background: var(--color-bg-card);
	padding: 30px;
	border-radius: 12px;
	box-shadow: 0 4px 12px var(--color-shadow);
}

/* Popular Characters Section */
.popular-section {
	padding: 60px 20px;
	background: #f8f9fa;
	margin: 40px -15px;
}

.character-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
	gap: 20px;
	max-width: 1000px;
	margin: 0 auto 40px;
	padding: 0 20px;
}

.character-card {
	background: white;
	padding: 20px 16px;
	border-radius: 12px;
	text-decoration: none;
	transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
	cursor: pointer;
	border: 2px solid var(--color-border);
	position: relative;
}

.character-card:hover {
	transform: translateY(-4px);
	box-shadow: 0 8px 16px rgba(37, 99, 235, 0.12);
	border-color: var(--color-primary-light);
}

.character-card:active {
	transform: translateY(-2px);
}

.character-card:focus-visible {
	outline: 3px solid var(--color-primary);
	outline-offset: 2px;
}

.character-card .character {
	font-size: 3rem;
	color: var(--color-text-primary);
	font-weight: 400;
	font-family: var(--font-family-chinese);
	line-height: 1;
}

.character-card .pinyin {
	font-size: 0.95rem;
	color: var(--color-primary);
	font-weight: 500;
	letter-spacing: 0.3px;
}

.character-card .meaning {
	font-size: 0.813rem;
	color: var(--color-text-secondary);
	text-align: center;
	font-weight: 400;
	line-height: 1.3;
}

.cta-container {
	text-align: center;
}

/* Learning Paths Section */
.learning-paths-section {
	padding: 60px 20px;
	max-width: var(--container-max-width);
	margin: 0 auto;
}

.learning-paths-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
	gap: 24px;
	margin-top: 40px;
}

.learning-path-card {
	background: white;
	padding: 28px 24px;
	border-radius: 12px;
	text-decoration: none;
	transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
	border: 2px solid var(--color-border);
	position: relative;
}

.learning-path-card:hover {
	transform: translateY(-4px);
	box-shadow: 0 8px 16px rgba(37, 99, 235, 0.12);
	border-color: var(--color-primary-light);
}

.learning-path-card:active {
	transform: translateY(-2px);
}

.learning-path-card:focus-visible {
	outline: 3px solid var(--color-primary);
	outline-offset: 2px;
}

.path-icon {
	font-size: 2.5rem;
	margin-bottom: 12px;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	background: var(--color-bg-secondary);
	border-radius: 12px;
}

.learning-path-card h3 {
	font-size: 1.125rem;
	color: var(--color-text-primary);
	margin-bottom: 8px;
	font-weight: 600;
	line-height: 1.3;
}

.learning-path-card p {
	color: var(--color-text-secondary);
	line-height: 1.5;
	margin-bottom: 16px;
	flex-grow: 1;
	font-size: 0.95rem;
}

.path-cta {
	color: var(--color-primary);
	font-weight: 600;
	font-size: 0.875rem;
	display: inline-flex;
	align-items: center;
	gap: 4px;
	transition: gap 0.2s ease;
}

.path-cta::after {
	content: '→';
}

.learning-path-card:hover .path-cta {
	gap: 8px;
}

/* Features Section */
.features-section {
	padding: 60px 20px;
	max-width: 1200px;
	margin: 0 auto;
}

.features-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
	gap: 30px;
	margin-top: 40px;
}

.feature-card {
	background: var(--color-bg-card);
	padding: 30px;
	border-radius: 12px;
	box-shadow: 0 2px 8px var(--color-shadow);
	transition: all 0.3s ease;
}

.feature-card:hover {
	transform: translateY(-5px);
	box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.feature-icon {
	font-size: 3rem;
	margin-bottom: 15px;
}

.feature-card h3 {
	font-size: 1.3rem;
	color: var(--color-text-primary);
	margin-bottom: 10px;
}

.feature-card p {
	color: #666;
	line-height: 1.6;
}

/* Footer Styles */
.site-footer {
	background: #2d3748;
	color: #e2e8f0;
	padding: 40px 20px 20px;
	margin: 60px -15px -80px;
}

.footer-content {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 30px;
	max-width: 1200px;
	margin: 0 auto 30px;
}

.footer-section h3 {
	color: white;
	margin-bottom: 15px;
	font-size: 1.1rem;
}

.footer-section p {
	color: #cbd5e0;
	line-height: 1.6;
}

.footer-links {
	list-style: none;
	padding: 0;
	margin: 0;
}

.footer-links li {
	margin-bottom: 10px;
}

.footer-links a {
	color: #cbd5e0;
	text-decoration: none;
	transition: color 0.3s ease;
}

.footer-links a:hover {
	color: white;
}

.footer-bottom {
	border-top: 1px solid #4a5568;
	padding-top: 20px;
	text-align: center;
}

.footer-bottom a {
	color: #667eea;
	text-decoration: none;
}

.footer-bottom a:hover {
	text-decoration: underline;
}

/* Responsive Design for Homepage */
@media (max-width: 768px) {
	.hero-title {
		font-size: 1.8rem;
	}

	.hero-description {
		font-size: 1rem;
	}

	.value-highlights {
		gap: 12px;
		margin: 24px 0 32px 0;
	}

	.value-item {
		font-size: 0.85rem;
		padding: 10px 16px;
	}

	.starting-point-title {
		font-size: 1.3rem;
		margin-bottom: 20px;
	}

	.starting-point-cards {
		grid-template-columns: 1fr;
		gap: 16px;
	}

	.starting-card {
		padding: 24px 20px;
	}

	.starting-card .card-icon {
		font-size: 2.5rem;
	}

	.starting-card h3 {
		font-size: 1.1rem;
	}

	.starting-card p {
		font-size: 0.9rem;
	}

	.hero-actions {
		flex-direction: column;
	}

	.btn {
		width: 100%;
		max-width: 300px;
	}

	.character-grid {
		grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
		gap: 15px;
	}

	.character-card .character {
		font-size: 2.5rem;
	}

	.section-title {
		font-size: 1.5rem;
	}

	.features-grid {
		grid-template-columns: 1fr;
	}

	.footer-content {
		grid-template-columns: 1fr;
		text-align: center;
	}
}