@charset "utf-8";

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

html {
	/* 声明确定的宽高（可以是百分比型值），供后代元素宽高定义x%参考。
		100%相对于父元素（视口），比100vh避免了safari工具栏高度的问题
		不需要设置min-height（未理解）
	*/
	height: 100%;

	scrollbar-gutter: stable; /*为滚动条预留空间，防止滚动条在出现/隐藏间切换时影响内容宽高计算变化*/
	scroll-behavior: smooth; /*跳转至锚点时平滑滚动，而非突然跳走*/

	text-size-adjust: 100%; /*iOS 横屏字体放大问题：保持字体尺寸稳定*/

	/* 安全策略 */
	block-size: unset; /* 防止某些浏览器怪异模式 */

	/* macOS 上字体锯齿感
		不同浏览器字体渲染差异
	*/
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

:root {
	--dangerous-color: #d32f2f;
	--correct-color: #4caf50;
	--incorrect-color: #f05c6a;
	--half-correct-color: #ff9800;
}

body {
	max-inline-size: 100%;
	min-height: 100vh; /* 确保布局撑满视口高度 */
	height: 100%; /*显式定义了高度且撑满父元素（html）*/
	margin: 0;
	padding: 0;

	background-color: #f5f5f5;

	contain: layout style paint; /* 为动态内容预留空间 */

	line-height: 1.6; /*1.6是可读性最佳行高*/
	font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
	text-rendering: optimizeLegibility; /*精细字体细节*/
	overflow-wrap: break-word; /*允许在单词内换行（避免溢出）*/
	hyphens: auto; /*自动添加连字符（西文）*/
	image-rendering: optimize-contrast; /*高清图片渲染*/

	touch-action: manipulation; /*移动端点击延迟问题：立即响应触摸事件*/
}

body:focus { /*为键盘导航用户清晰焦点指示*/
	outline: 2px solid #0066cc;
}

/* 移动端优化 */
@supports (-webkit-touch-callout: none) {
	body {
		min-height: -webkit-fill-available;
		overscroll-behavior-y: contain;
	}
}

/* 深色模式 */
@media (prefers-color-scheme: dark) {
	body {
		background-color: #121212;
		color: #f0f0f0;
	}
}

/* 打印优化 */
@media print {
	body {
		background: white;
		color: black;
		font-size: 12pt;
	}

	/* 隐藏不必要元素 */
	nav, footer, .ad-banner {
		display: none;
	}
}

/* 移动端Safari特殊处理 */
@supports (-webkit-touch-callout: none) {
	body {
		min-height: -webkit-fill-available;
		/* 修复iOS下拉刷新区域 */
		overscroll-behavior-y: contain;
	}
}

@media (max-width: 1024px) {
	body {
		grid-template-columns: 1fr;
		grid-template-areas:
			'header'
			'main'
			'aside';
	}

	aside {
		width: 100%;
	}
}

/*================================设定一些元素的初始值==============================*/

template, .template, .hidden, [v-cloak], .js.container {display: none; }

h1, h2, h3 {color: #333; }

textarea {
	width: 100%;
	padding: 10px;
	border: 1px solid #ddd;
	border-radius: 4px;
	resize: vertical;
}

button {
	cursor: pointer;
	transition: background-color 0.3s;
}

i.icon {
	font-style: unset; /* <i>标签本来是做斜体的，但现在通常被用来做图标，因此要去掉本身的斜体。 */
}

/*-------------------------整个导航栏--------------------*/
body > header {
	grid-area: header; /* 若外层非grid容器，无影响。 */
	background-color: #fff;
	border-bottom: 1px solid #dee2e6;
	padding: 1rem 2rem;
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	justify-content: space-between;
	align-items: center;
}

/*-------------网站名--------------*/
body > header > .website.name {
	margin: 0;
	font-size: 1.5rem;
	font-weight: 600;
}

/*------------导航栏------------*/
body > header nav {
	display: flex;
	gap: 1.5rem;
	flex-wrap: wrap;
}

/*-----导航按钮-----*/
body > header nav a {
	text-decoration: none;
	color: #333;
	font-weight: 500;
	padding-bottom: 5px;
	border-bottom: 2px solid transparent;
	transition: border-color 0.2s, color 0.2s;
}

body > header nav a:hover, body > header nav a.active {
	color: #007bff;
	border-bottom-color: #007bff;
}

/*================================一些工具类==============================*/

.note strong {color: red; }

.correct {color: var(--correct-color); }

.incorrect {color: var(--incorrect-color); }

.half-correct {color: var(--half-correct-color); }

.dangerous-via-font {color: var(--dangerous-color); }

.dangerous-via-background {background-color: var(--dangerous-color); }

/*---------------------网站信息---------------------*/
.website.info {
	background-color: #f8f9fa;
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: 0.5em;
	text-align: center;
	font-size: 0.85rem;
	color: #6c757d;
}

.website.info .patronage.area {
	width: 120px;
	background-color: #e9ecef;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	font-style: italic;
	padding: 5px;
	border-radius: 4px;
}

.website.info .patronage.area img.qr-code {
	max-width: 100%;
	height: auto;
	margin-bottom: 5px;
}

.website.info .patronage.area .slogan {
	font-size: 0.75rem;
	color: #333;
}

.website.info p {
	margin: 0.5em;
}

.website.info a {
	color: #007bff;
	text-decoration: none;
}

.website.info a:hover {
	text-decoration: underline;
}

/*--------------可拖放调整大小的元素--------------*/
.resizable {
	display: block; /* 确保是块级元素 */
	overflow: auto; /* 必须设置且不能是visible */
	resize: both;
}

.resizable.x {resize: horizontal;}

.resizable.y {resize: vertical;}

/*---------------截断长文本---------------*/
.truncate-long-text {
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis; /*截断文本最后留个省略号*/
}

.truncate-long-text:hover {
	overflow: visible;
	text-overflow: inherit;
}

/*-------------定位-------------*/
.position-fixed {position: fixed; }

.position-fixed.in-center {
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
}

.sticky {position: sticky; }

footer.sticky {bottom: 0; }

nav.sticky {top: 0; }

/*------------文字相关------------*/
.em-as-10x-px {
	font-size: 62.5%; /* 浏览器默认字号16px，62.5%即10px，这样可令1em=10px，方便换算 */
}

/*-----------渐变色------------*/
.text-gradient { /* 渐变色字 */
	background: linear-gradient(90deg, #3498db, #2ecc71);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
}

.highlight-input {
	border: 2px solid #dce4ec;
	border-radius: 8px;
	outline: none;
	transition: all 0.3s ease;
	box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
}

.highlight-input:hover {
	border-color: #aec6d3;
}

.highlight-input:focus {
	border-color: #3498db;
	box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.25);
}

/* 模态对话框 (Modal) */
.modal-overlay {
	position: absolute;
	top: 0;
	left: 0;
	z-index: 1000;
	width: 100%;
	height: 100%;
	background-color: rgba(0, 0, 0, 0.6);
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
}

.modal-overlay.fullscreen {
	position: fixed;
}

.modal-overlay > .body {
	position: relative;
	z-index: 1001;
	box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
	border-radius: 15px;
	background: white;
	padding: 40px 50px;
	flex: unset;
	text-align: center;
	transform: scale(0.7);
	animation: zoomIn 0.5s forwards;
}

@keyframes zoomIn {
	to {
		transform: scale(1);
	}
}

.modal-overlay > .body > h2 {
	color: #27ae60;
	font-size: 2.5em;
	margin-bottom: 15px;
}

.modal-overlay > .body > p {
	color: #555;
	font-size: 1.2em;
	margin-bottom: 30px;
}

/* 撒花效果 (Confetti) */
.confetti-container {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}

.confetti {
	position: absolute;
	top: -20px;
	width: 10px;
	height: 10px;
	opacity: 0.8;
	animation: fall 5s linear infinite;
}

@keyframes fall {
	to {
		transform: translateY(100vh) rotate(360deg);
		opacity: 0;
	}
}
