/**
 * WP OTP Auth 前台表单样式。
 *
 * 设计取向：贴合参考设计的极简卡片 —— 白底、圆角输入框、蓝色聚焦边、黑色主按钮。
 * 只用一层 .wpota- 前缀的类名，不依赖主题的具体结构，也不会覆盖主题全局样式。
 *
 * 断点：
 *   > 768px  PC：固定 420px 宽卡片居中
 *   <= 768px 平板/手机：卡片撑满，间距收紧
 *   <= 480px 手机：进一步压缩内边距，按钮与输入框保持 44px 以上可点区域
 */

/* 全屏遮罩：表单出现时背景模糊并压暗，把视线聚到卡片上。
   点击遮罩空白处等价于点右上角关闭。

   正确做法（用户提供的参考）：
   - 遮罩层用 background: rgba(0,0,0,0.5) —— 货真价实的半透明黑色；
   - 登录卡片本身 background:#fff 不透明，不受遮罩影响；
   - 可选加 backdrop-filter: blur(6px) 增加朦胧感。

   之前的错误：一直调遮罩底色的浓度（38%→18%→6%），但底下的
   登录页面本身是白色的，6% 黑叠在白底上 = 还是白色。
   正确答案是足够的暗度（50%），不是更淡。 */
/* 登录页的 H1 由 PHP 过滤置空（class-frontend.php: hide_login_page_title），
   主题仍会输出一个空的 <h1 class="entry-title">，这里把空壳收掉。 */
body.wpota-login-page .entry-title:empty {
	display: none;
}

/* 蜜罐字段（0.10.0）：彻底移出屏幕且不占布局、不可交互。
   不用 display:none —— 某些群发脚本会跳过 display:none 的字段，
   移出屏幕对它们反而「像」一个正常字段。 */
.wpota-hp {
	position: absolute !important;
	left: -9999px !important;
	top: -9999px !important;
	width: 1px !important;
	height: 1px !important;
	opacity: 0 !important;
	pointer-events: none !important;
	border: 0 !important;
	padding: 0 !important;
}

.wpota-overlay {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	overflow-y: auto;
	background: rgba(0, 0, 0, 0.5);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
}

.wpota-overlay .wpota-auth {
	margin: 0;
	max-height: 92vh;
	overflow-y: auto;
}

.wpota-auth {
	position: relative;
	box-sizing: border-box;
	width: 100%;
	max-width: 420px;
	margin: 24px auto;
	padding: 32px 28px 28px;
	background: var(--wpota-card-bg, #fff);
	border-radius: var(--wpota-card-radius, 14px);
	box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
	font-size: 15px;
	line-height: 1.5;
	color: #1f1f1f;
}

.wpota-auth * {
	box-sizing: border-box;
}

/*
 * 已登录提示卡（0.11.2，用户 2026-10-31 实机：卡片压在导航栏上）：
 * 独立居中、抬到主题头部之上，不再贴着页面顶部。
 */
.wpota-auth--notice {
	position: relative;
	z-index: 2;
	margin: 64px auto 24px;
	text-align: center;
}

/*
 * 0.12.4（用户 2026-11-03，PC 与手机都实测压字）：头部两行。
 *
 * 第一行只放「←」「✕」两个 32px 圆形按钮，标题独占第二行；
 * 之前按钮 absolute、标题 padding:0，长标题（英文第二屏最明显）
 * 直接压在按钮上。视觉不变：按钮 32px 圆、#9aa0a6、hover #f1f3f4，
 * 标题字号/字重/居中不变，卡片圆角阴影内边距不变。
 *
 * 结构：.wpota-auth__head > back（隐藏时 display:none）+ close。
 * close 的 margin-left:auto 保证第一层（没有 back）时 ✕ 仍在右端。
 */
.wpota-auth__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	min-height: 32px;
	margin: 0 0 12px;
}

/* 右上角关闭：回到进入本页之前的那个页面 */
.wpota-auth__close {
	position: static;
	top: auto;
	right: auto;
	flex: 0 0 32px;
	margin-left: auto;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	background: transparent;
	color: #9aa0a6;
	font-size: 22px;
	line-height: 32px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	border-radius: 50%;
	transition: background 0.15s ease, color 0.15s ease;
}

/*
 * 0.12.14：圆形里的 ✕ 几何居中后视觉上仍偏高（用户 2026-11-14 复验）。
 * 圆的视觉重心略低于几何中心，所以给图标 0.5 CSS px 的光学补偿——0.5 在
 * DPR 2 上正好是一个物理像素，不会糊。只作用于关闭按钮，返回箭头不动；
 * transform 不参与布局，点击区域、焦点环、hover 底色都不受影响。
 */
.wpota-auth__close > .wpota-auth__icon {
	transform: translateY(0.5px);
}

.wpota-auth__close:hover {
	background: #f1f3f4;
	color: #1f1f1f;
}

/*
 * 返回上一层：左上角一个左箭头（0.12.4 起在 .wpota-auth__head 第一行）。
 *
 * 只在进入第二层及以后出现（第一层没有上一层可回），由 JS 切 hidden。
 * 位置在关闭按钮的左侧，视觉上是一对：← 关闭。
 */
.wpota-auth__back {
	position: static;
	top: auto;
	left: auto;
	flex: 0 0 32px;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	background: transparent;
	color: #9aa0a6;
	font-size: 22px;
	line-height: 32px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	border-radius: 50%;
	transition: background 0.15s ease, color 0.15s ease;
}

.wpota-auth__back:hover {
	background: #f1f3f4;
	color: #1f1f1f;
}

.wpota-auth__back[hidden] {
	display: none;
}

.wpota-auth__title {
	margin: 0 0 10px;
	padding: 0;
	font-size: 24px;
	font-weight: 700;
	line-height: 1.3;
	text-align: center;
	color: #111;
}

/* 一句话提示：未注册自动建号 */
.wpota-auth__hint {
	margin: 0 0 18px;
	font-size: 14px;
	line-height: 1.5;
	text-align: center;
	color: #5f6368;
}

.wpota-field {
	margin-bottom: 14px;
}

.wpota-input {
	width: 100%;
	height: 48px;
	padding: 0 14px;
	border: 1px solid #e0e0e0;
	border-radius: var(--wpota-input-radius, 8px);
	background: #fff;
	font-size: 15px;
	color: #1f1f1f;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/*
 * 0.11.0 统一焦点环（T3）。
 *
 * 原来只有 .wpota-input:focus（特异性 0,2,0）。Astra 的
 * input[type="tel"]:focus 一类的规则是 0,2,1，主题因此把蓝边改回
 * --ast-border-color / #046BD2、把 box-shadow 置 none —— 用户实际看不到
 * 任何焦点反馈（Chrome 实测修复前 computed borderColor = rgb(4,107,210)、
 * boxShadow = none；Firefox 同理）。
 * 这里把选择器提到 .wpota-auth 作用域（0,3,0）压过主题，并同时覆盖
 * :focus 与 :focus-visible（后者是键盘 Tab 进来时的状态）。
 *
 * outline:none 是防御性声明：Astra 还有一条
 * `.woocommerce-js input[type="text"]:focus { outline-style: unset;
 * outline-width: thin }`（0,3,1），它本身就压掉原生 outline；本规则的
 * 焦点环靠 border-color + box-shadow 呈现，不依赖 outline。只限定
 * .wpota- 前缀，不碰主题。
 */
.wpota-input:focus,
.wpota-input:focus-visible,
.wpota-auth .wpota-input:focus,
.wpota-auth .wpota-input:focus-visible {
	outline: none;
	border-color: #1a73e8;
	box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.12);
}

.wpota-input:disabled {
	background: #f6f7f9;
	color: #9aa0a6;
	cursor: not-allowed;
}

.wpota-input.is-invalid {
	border-color: #d93025;
}

/* 验证码行：重发按钮 */
.wpota-code-row {
	display: flex;
	gap: 8px;
	align-items: stretch;
	margin-top: 10px;
}

.wpota-code-row .wpota-input {
	flex: 1 1 auto;
	letter-spacing: 4px;
}

.wpota-resend {
	display: block;
	width: 100%;
	height: var(--wpota-btn-height, 44px);
	padding: 0 var(--wpota-btn-px-secondary, 14px);
	border: 1px solid var(--wpota-focus-color, #1a73e8);
	border-radius: var(--wpota-btn-radius, 10px);
	background: #fff;
	color: var(--wpota-focus-color, #1a73e8);
	font-size: 14px;
	white-space: nowrap;
	cursor: pointer;
	transition: background 0.15s ease;
}

/*
 * 0.11.3：重发按钮与主按钮同一套键盘焦点环（用户 2026-10-31 口径：
 * 键盘 Tab 才出环、鼠标不画环；令牌值来自 wp_head）。
 */
.wpota-resend:focus-visible {
	outline: var(--wpota-focus-width, 2px) solid var(--wpota-focus-color, #1a73e8);
	outline-offset: 2px;
}

.wpota-resend:focus:not(:focus-visible) {
	outline: none;
}

.wpota-resend:hover:not(:disabled) {
	background: #f0f6ff;
}

.wpota-resend:disabled {
	border-color: #e0e0e0;
	color: #9aa0a6;
	cursor: default;
}

/*
 * 0.11.3：主按钮全部改读全局令牌（后台「界面风格 → 按钮样式（全局）」）。
 *
 *   --wpota-btn-height / -radius / -border / -min-width / -weight
 *   --wpota-btn-px-main / -fs-main
 *   --wpota-btn-primary-bg|text|border
 *   --wpota-btn-primary-hover-bg|text|border
 *   --wpota-focus-width / --wpota-focus-color / --wpota-focus-offset
 *
 * 高度 48 → 44 是有意统一（账户页原本就是 44，用户 2026-10-31 口径）。
 * 悬停只换颜色、不画聚焦环；键盘 :focus-visible 才出环。
 */
.wpota-btn {
	display: block;
	width: 100%;
	height: var(--wpota-btn-height, 44px);
	min-width: var(--wpota-btn-min-width, 0);
	margin-top: 18px;
	padding: 0 var(--wpota-btn-px-main, 18px);
	border: var(--wpota-btn-border, 1px) solid var(--wpota-btn-primary-border, #111111);
	border-radius: var(--wpota-btn-radius, 10px);
	background: var(--wpota-btn-primary-bg, #111111);
	color: var(--wpota-btn-primary-text, #ffffff);
	font-size: var(--wpota-btn-fs-main, 16px);
	font-weight: var(--wpota-btn-weight, 500);
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.wpota-btn:hover:not(:disabled) {
	background: var(--wpota-btn-primary-hover-bg, #000000);
	color: var(--wpota-btn-primary-hover-text, #ffffff);
	border-color: var(--wpota-btn-primary-hover-border, #000000);
}

.wpota-btn:disabled {
	opacity: calc(var(--wpota-btn-disabled, 55) / 100);
	cursor: progress;
}

/* 记住我 */
.wpota-remember {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 14px 0 0;
	font-size: 14px;
	color: #5f6368;
	cursor: pointer;
}

/*
 * 0.11.0 键盘焦点可见性（T3）：主题把 input 的原生 outline 清零
 * （Astra: `input { outline: none }`），按钮和「记住我」勾选框因此必须
 * 自带一圈可见焦点环，否则键盘用户看不出焦点落在哪。只限定 .wpota-
 * 前缀，不改主题的其它控件。
 */
.wpota-btn:focus-visible,
.wpota-remember input[type="checkbox"]:focus-visible {
	outline: var(--wpota-focus-width, 2px) solid var(--wpota-focus-color, #1a73e8);
	outline-offset: var(--wpota-focus-offset, 2px);
}

/* 鼠标点击不画环（0.11.3 统一规格：只有键盘才出焦点环）。 */
.wpota-btn:focus:not(:focus-visible),
.wpota-remember input[type="checkbox"]:focus:not(:focus-visible) {
	outline: none;
}

.wpota-remember input {
	width: 16px;
	height: 16px;
	margin: 0;
}

/* 底部留白（文案由 JS 按阶段填充） */
.wpota-auth__foot {
	margin: 20px 0 0;
	text-align: center;
	font-size: 14px;
	color: #5f6368;
}

/* 提示条 */
.wpota-msg {
	display: none;
	margin-bottom: 14px;
	padding: 10px 12px;
	border-radius: 8px;
	font-size: 14px;
	line-height: 1.45;
	word-break: break-word;
}

.wpota-msg.is-visible {
	display: block;
}

.wpota-msg--error {
	background: #fdecea;
	color: #a52714;
}

.wpota-msg--ok {
	background: #e6f4ea;
	color: #137333;
}

.wpota-msg--info {
	background: #e8f0fe;
	color: #174ea6;
}

.wpota-turnstile {
	margin: 0;
	/*
	 * invisible 模式不占位；容器保留供 CF 挂载 iframe。
	 *
	 * 不要再用 height:0 + overflow:hidden 把它裁掉（0.10.9 移除）：
	 * Cloudflare 在需要交互时会在这个容器里挂一层可见的挑战，
	 * 零高度 + 裁切会让挑战层显示不全；iOS Safari 上还会出现黑屏。
	 */
	min-height: 0;
}

/* 平板 */
@media (max-width: 768px) {
	/*
	 * 移动端关掉全屏毛玻璃（0.10.9）。
	 *
	 * iOS Safari 的已知问题：position:fixed 全屏元素 + backdrop-filter，
	 * 在软键盘弹出/收起（输入框聚焦切换）时会整屏变黑、只剩一个转圈，
	 * 而且每一层浮层都要一次全屏合成 —— 页面里一旦有多份表单，
	 * iPhone 直接卡死。站点的浮层底色本来就接近透明（1% 不透明度），
	 * 去掉虚化视觉上几乎无差别，但移动端的合成开销归零。
	 */
	.wpota-overlay {
		-webkit-backdrop-filter: none;
		backdrop-filter: none;
	}

	.wpota-auth {
		max-width: 100%;
		margin: 16px auto;
		padding: 28px 22px 24px;
		border-radius: 12px;
	}

	.wpota-auth__title {
		font-size: 22px;
	}
}

/* 手机 */
@media (max-width: 480px) {
	.wpota-auth {
		margin: 8px auto;
		padding: 24px 16px 20px;
		box-shadow: none;
		border-radius: 0;
	}

	.wpota-auth__title {
		font-size: 20px;
		margin-bottom: 18px;
	}

	.wpota-code-row {
		flex-direction: column;
	}

	.wpota-resend {
		width: 100%;
	}
}

/* ---------------------------------------------------------------- 主题 --- */

/* 主色：后台「界面风格」可改，按钮与链接统一跟从。 */
/*
 * 0.11.3：旧的 --wpota-primary / --wpota-btn-text 两条规则会以更高特异性
 * 覆盖 .wpota-btn 的令牌（0,2,0 > 0,1,0），这里改成读同一组令牌，
 * 保证后台改「按钮样式（全局）」真的生效。
 */
.wpota-auth .wpota-btn {
	background: var(--wpota-btn-primary-bg, #111111);
	color: var(--wpota-btn-primary-text, #ffffff);
	border-color: var(--wpota-btn-primary-border, #111111);
}

.wpota-auth .wpota-btn:hover:not(:disabled) {
	background: var(--wpota-btn-primary-hover-bg, #000000);
	color: var(--wpota-btn-primary-hover-text, #ffffff);
	border-color: var(--wpota-btn-primary-hover-border, #000000);
	opacity: 1;
}

.wpota-auth .wpota-resend:not(:disabled) {
	color: var(--wpota-focus-color, #1a5fd7);
}

/*
 * 暗色适配。
 *
 * 之前是后台一个「明亮 / 暗色」的手动开关，但切换之后自定义的配色
 * 并不会跟着变 —— 两套主题、两份自定义，配置起来很别扭，界面上看着
 * 也不一致。
 *
 * 改成跟随访客系统的 prefers-color-scheme：
 * 系统是暗色的，弹窗就是暗色的；系统是亮色的，就是亮色的。
 * 站长想固定颜色，用「卡片背景色」「主色」这两个设置项就够了。
 *
 * 想强制某个样子，加这段 CSS 即可：
 *   .wpota-auth { background: #fff !important; color: #111 !important; }
 */
@media (prefers-color-scheme: dark) {
	.wpota-auth {
		background: #16181c;
		color: #e6e8eb;
		border-color: #2a2e35;
	}

	.wpota-auth .wpota-auth__title {
		color: #e6e8eb;
	}

	.wpota-auth .wpota-auth__hint {
		color: #9aa0a8;
	}

	.wpota-auth .wpota-input {
		background: #1d2025;
		border-color: #33373f;
		color: #e6e8eb;
	}

	.wpota-auth .wpota-input:focus {
		border-color: #4a7fdb;
		box-shadow: 0 0 0 3px rgba(74, 127, 219, 0.25);
	}

	.wpota-auth .wpota-auth__close {
		color: #9aa0a8;
	}

	.wpota-auth .wpota-auth__back {
		color: #9aa0a8;
	}

	.wpota-auth .wpota-msg--ok {
		background: #12281a;
		color: #7ee2a0;
	}

	.wpota-auth .wpota-msg--error {
		background: #2d1416;
		color: #ff9c9c;
	}
}
