/**
 * uptab-nav 布局层:基础重置、壁纸、时钟、搜索框、磁贴网格容器
 */

/* ===== 全屏页重置 =====
 * 独立模板页面:去掉浏览器默认 body margin 与 WP 后台管理栏的 html margin,
 * 避免内容不足一屏时仍被撑出纵向滚动条。Dock 等悬浮层 fixed 定位,不占文档流。 */
body.uptab-nav-page {
	margin: 0;
	padding: 0;
}

body.uptab-nav-page #wpadminbar {
	display: none !important;
}

html:has(body.uptab-nav-page) {
	margin-top: 0 !important;
}

/* ---- CSS 变量(主题) ---- */
.uptab-app {
	/* 主题色与文字(静谧夜航:墨蓝主调 + 琥珀金点缀) */
	--uptab-accent: #24406b;
	--uptab-accent-soft: rgba(36, 64, 107, 0.12);
	--uptab-gold: #c9a227;
	--uptab-gold-ring: rgba(201, 162, 39, 0.45);
	--uptab-text: #1f2329;
	--uptab-text-2: #5f6672;
	--uptab-text-invert: #ffffff;

	/* 卡片 */
	--uptab-card-bg: rgba(255, 255, 255, 0.72);
	--uptab-card-bg-hover: rgba(255, 255, 255, 0.9);
	--uptab-card-border: rgba(255, 255, 255, 0.5);
	/* 双层空间阴影:贴地(近、实、小扩散) + 漂浮(远、虚、大扩散),墨蓝染色替代死黑 */
	--uptab-shadow: 0 1px 2px rgba(20, 34, 61, 0.10), 0 10px 28px rgba(20, 34, 61, 0.14);
	--uptab-shadow-hover: 0 2px 4px rgba(20, 34, 61, 0.12), 0 16px 40px rgba(20, 34, 61, 0.22);

	/* 网格(图标优先:列宽=行高=图标,间距 icon.gap 横竖统一,最小 40 含名称区) */
	--uptab-cols: 8;
	--uptab-col-gap: 40px;
	--uptab-row-gap: 40px;
	--uptab-icon-size: 56px;

	/* 圆角 */
	--uptab-radius: 18px;
	--uptab-icon-radius: 16px;

	/* 磨砂玻璃(弹出层统一语言:右键菜单/弹窗/搜索下拉) */
	--uptab-glass-bg: rgba(28, 38, 58, 0.72);
	--uptab-glass-border: rgba(255, 255, 255, 0.14);
	--uptab-glass-text: rgba(255, 255, 255, 0.92);
	--uptab-glass-text-2: rgba(255, 255, 255, 0.60);
	--uptab-glass-hover: rgba(255, 255, 255, 0.12);
	--uptab-glass-line: rgba(255, 255, 255, 0.10);
	--uptab-glass-blur: blur(20px) saturate(140%);
	--uptab-glass-shadow: 0 16px 48px rgba(10, 18, 34, 0.42);
}

.uptab-app[data-theme="dark"] {
	--uptab-text: #eef1f6;
	--uptab-text-2: #a7aebc;
	--uptab-card-bg: rgba(24, 28, 38, 0.6);
	--uptab-card-bg-hover: rgba(30, 35, 48, 0.78);
	--uptab-card-border: rgba(255, 255, 255, 0.08);
	--uptab-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
	--uptab-shadow-hover: 0 12px 32px rgba(0, 0, 0, 0.5);
}

/* ---- 根容器 ---- */
.uptab-app {
	position: relative;
	min-height: 100vh;
	min-height: 100dvh; /* 移动端地址栏动态高度修正 */
	width: 100%;
	overflow-x: hidden;
	color: var(--uptab-text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
		"Hiragino Sans GB", "Microsoft YaHei", sans-serif;
	-webkit-font-smoothing: antialiased;
	background-color: #dfe7f5;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	transition: background-color 0.3s ease;
	box-sizing: border-box;
	touch-action: manipulation; /* 触摸设备去除点击延迟与双击缩放 */
}

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

/* 壁纸遮罩(保证文字可读) */
.uptab-app__wallpaper {
	position: fixed;
	inset: 0;
	z-index: 0;
	background: inherit;
	background-size: cover;
	background-position: center;
}

/* 默认渐变壁纸:静谧夜航(浅色主调)
 * 底:柔和晨雾浅蓝白;右上淡琥珀金光晕(点缀,呼应强调色);左下墨蓝渗透(空间纵深)。
 * 多层 radial + linear 叠加,避免单一线性渐变的"AI 味"。 */
.uptab-app__wallpaper--gradient {
	background-color: #eef2f8;
	background-image:
		radial-gradient(120% 90% at 82% 12%, rgba(201, 162, 39, 0.16) 0%, rgba(201, 162, 39, 0) 42%),
		radial-gradient(130% 110% at 12% 92%, rgba(36, 64, 107, 0.22) 0%, rgba(36, 64, 107, 0) 55%),
		linear-gradient(160deg, #f4f7fc 0%, #e6edf7 46%, #dbe6f4 100%);
}

/* ---- 顶部功能区(空容器,备用) ---- */
.uptab-topbar {
	position: fixed;
	top: 18px;
	left: 18px;
	z-index: 5;
}

/* ---- 主内容容器(居中) ---- */
.uptab-app__stage {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	min-height: 100vh;
	min-height: 100dvh; /* 移动端地址栏动态高度修正 */
	padding: 2vh 4vw 8vh;
	box-sizing: border-box;
}

/* ---- 时钟区 ---- */
.uptab-clock {
	text-align: center;
	user-select: none;
	margin-top: 2vh;
	margin-bottom: 3vh;
	text-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
	color: var(--uptab-clock-color, var(--uptab-text));
}

.uptab-clock__time {
	font-size: 64px;
	font-weight: 700;
	line-height: 1;
	letter-spacing: 1px;
	font-variant-numeric: tabular-nums;
}

.uptab-clock__date {
	margin-top: 10px;
	font-size: 15px;
	font-weight: 500;
	opacity: 0.85;
}

/* ---- 搜索框 ---- */
.uptab-search {
	position: relative;
	display: flex;
	align-items: center;
	width: min(680px, 90vw);
	height: 52px;
	margin-bottom: 6vh;
	padding: 0 8px 0 6px;
	border-radius: 18px;
	background: var(--uptab-card-bg);
	border: 1px solid var(--uptab-card-border);
	box-shadow: var(--uptab-shadow);
	backdrop-filter: blur(12px) saturate(1.2);
	-webkit-backdrop-filter: blur(12px) saturate(1.2);
	transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

/* 搜索框聚焦:琥珀金焦点环(点缀之三) */
.uptab-search:focus-within {
	border-color: var(--uptab-gold, #c9a227);
	box-shadow: var(--uptab-shadow), 0 0 0 3px var(--uptab-gold-ring, rgba(201, 162, 39, 0.45));
}

.uptab-search__engine {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 6px 10px;
	border-radius: 12px;
	cursor: pointer;
	transition: background 0.2s;
}

.uptab-search__engine:hover {
	background: rgba(127, 127, 127, 0.12);
}

.uptab-search__engine-ico {
	width: 28px;
	height: 28px;
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 14px;
	font-weight: 700;
	color: #fff;
	flex: none;
}

.uptab-search__caret {
	font-size: 11px;
	opacity: 0.55;
}

.uptab-search__input {
	flex: 1;
	min-width: 0;
	height: 100%;
	border: none;
	outline: none;
	background: transparent;
	font-size: 16px;
	color: var(--uptab-text);
	padding: 0 12px;
}

.uptab-search__input::placeholder {
	color: var(--uptab-text-2);
}

/* 搜索框文字颜色(浅色/深色) */
.uptab-search--light .uptab-search__input {
	color: #ffffff;
}

.uptab-search--light .uptab-search__input::placeholder {
	color: rgba(255, 255, 255, 0.72);
}

.uptab-search--dark .uptab-search__input {
	color: var(--uptab-text);
}

.uptab-search__go {
	width: 36px;
	height: 36px;
	border: none;
	border-radius: 10px;
	background: var(--uptab-accent);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex: none;
	transition: opacity 0.2s;
}

.uptab-search__go:hover {
	opacity: 0.88;
}

/* 引擎下拉 */
.uptab-search__dropdown {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	min-width: 200px;
	padding: 6px;
	border-radius: 14px;
	background: var(--uptab-glass-bg, rgba(28, 38, 58, 0.72));
	border: 1px solid var(--uptab-glass-border, rgba(255, 255, 255, 0.14));
	color: var(--uptab-glass-text, rgba(255, 255, 255, 0.92));
	box-shadow: var(--uptab-glass-shadow, 0 16px 48px rgba(10, 18, 34, 0.42));
	backdrop-filter: var(--uptab-glass-blur, blur(20px) saturate(140%));
	-webkit-backdrop-filter: var(--uptab-glass-blur, blur(20px) saturate(140%));
	z-index: 50;
	transform-origin: top;
	animation: uptab-dropdown-in 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes uptab-dropdown-in {
	from { opacity: 0; transform: translateY(-6px) scale(0.98); }
	to { opacity: 1; transform: translateY(0) scale(1); }
}

.uptab-search__dropdown-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 12px;
	border-radius: 9px;
	cursor: pointer;
	font-size: 14px;
}

.uptab-search__dropdown-item:hover {
	background: var(--uptab-glass-hover, rgba(255, 255, 255, 0.12));
}

.uptab-search__dropdown-item.is-active {
	font-weight: 600;
	background: var(--uptab-glass-hover, rgba(255, 255, 255, 0.12));
}

.uptab-search__dropdown-divider {
	height: 1px;
	margin: 6px 4px;
	background: var(--uptab-glass-line, rgba(255, 255, 255, 0.10));
}

/* ---- 磁贴网格容器(图标优先:列宽=图标、列距/行距=gap) ---- */
.uptab-grid {
	display: grid;
	grid-template-columns: repeat(var(--uptab-cols), var(--uptab-icon-size));
	grid-auto-rows: var(--uptab-icon-size);
	column-gap: var(--uptab-col-gap);
	row-gap: var(--uptab-row-gap);
	grid-auto-flow: dense;
	justify-content: center;
}

/* 不换行模式:单排横向滚动 */
.uptab-grid[style*="grid-auto-flow: column"] {
	justify-content: start;
	padding-bottom: 8px;
}

.uptab-grid[style*="grid-auto-flow: column"]::-webkit-scrollbar {
	height: 6px;
}

.uptab-grid[style*="grid-auto-flow: column"]::-webkit-scrollbar-thumb {
	background: rgba(127, 127, 127, 0.35);
	border-radius: 3px;
}

/* 隐藏原底部区域(预留 hook) */
.uptab-app--hide-original .uptab-app__original-bottom,
.uptab-app--hide-original footer {
	display: none;
}

/* ---- 登录提示 ---- */
.uptab-login-hint {
	text-align: center;
	color: var(--uptab-text);
	font-size: 15px;
	padding: 24px 20px;
}

.uptab-login-hint a {
	color: var(--uptab-accent);
	font-weight: 600;
}

/* ---- 同步状态(左下角) ---- */
.uptab-sync {
	position: fixed;
	left: 18px;
	bottom: 16px;
	z-index: 5;
	display: flex;
	align-items: center;
	gap: 7px;
	font-size: 12px;
	color: var(--uptab-text-2);
	text-shadow: 0 1px 6px rgba(0, 0, 0, 0.2);
}

.uptab-sync__spinner {
	width: 13px;
	height: 13px;
	border: 2px solid rgba(36, 64, 107, 0.25);
	border-top-color: var(--uptab-gold, #c9a227);
	border-radius: 50%;
	animation: uptab-spin 0.7s cubic-bezier(0.5, 0.15, 0.5, 0.85) infinite;
}

@keyframes uptab-spin {
	to {
		transform: rotate(360deg);
	}
}

/* ---- 响应式 ---- */
@media (max-width: 720px) {
	.uptab-app {
		--uptab-col-gap: 28px;
		--uptab-row-gap: 28px;
	}
	.uptab-clock__time {
		font-size: 46px;
	}
}

@media (max-width: 480px) {
	.uptab-app {
		--uptab-col-gap: 24px;
		--uptab-row-gap: 24px;
	}
	.uptab-clock__time {
		font-size: 38px;
	}
}
