/**
 * 头像裁剪层样式
 * ------------------------------------------------------------------
 * 全部颜色取自站点 CSS 变量（--cl-*），因此会自动跟随
 * 用户的配色方案（蓝/绿/紫/粉/橙/黄）与深色模式，无需单独适配。
 */

/* ---------------- 根容器与遮罩 ---------------- */

.ac-root {
	position: fixed;
	inset: 0;
	z-index: 1080;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	pointer-events: none;
	transition: opacity .18s ease;
	/* 防止 iOS 上背景滚动 */
	touch-action: none;
	/* 焦点由脚本管理，不显示默认描边 */
	outline: none;
}

/* 节点只在打开期间存在，因此无需 visibility 控制显隐。
   这里用 opacity + pointer-events，保证打开瞬间即可获得焦点。 */
.ac-root.ac-visible {
	opacity: 1;
	pointer-events: auto;
}

.ac-mask {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: var(--cl-modal-backdrop, rgba(0, 0, 0, .55));
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
}

/* ---------------- 卡片 ---------------- */

.ac-card {
	position: relative;
	width: 100%;
	max-width: 430px;
	max-height: calc(100vh - 32px);
	display: flex;
	flex-direction: column;
	padding: 16px;
	background: var(--cl-primary-bg-color, #ffffff);
	border-radius: var(--cl-primary-border-radius, 16px);
	box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .45);
	transform: translateY(14px) scale(.97);
	opacity: 0;
	transition: transform .22s cubic-bezier(.22, 1, .36, 1), opacity .22s ease;
	overflow: hidden;
}

.ac-root.ac-visible .ac-card {
	transform: translateY(0) scale(1);
	opacity: 1;
}

/* ---------------- 标题栏 ---------------- */

.ac-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding: 0 2px 12px;
}

.ac-title-box {
	min-width: 0;
}

.ac-title {
	font-size: 17px;
	font-weight: 600;
	line-height: 1.35;
	color: var(--cl-primary-text-color, #14171a);
}

.ac-sub {
	margin-top: 3px;
	font-size: 12px;
	line-height: 1.5;
	color: var(--cl-primary-text-color, #5b7083);
	opacity: .62;
}

/* ---------------- 图标按钮 ---------------- */

.ac-icon-btn {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--cl-primary-text-color, #14171a);
	opacity: .55;
	cursor: pointer;
	transition: background .15s ease, opacity .15s ease;
	-webkit-tap-highlight-color: transparent;
}

.ac-icon-btn:hover,
.ac-icon-btn:focus-visible {
	opacity: .9;
	background: var(--cl-secondary-bg-color, rgba(0, 0, 0, .06));
	outline: none;
}

.ac-icon-btn:active {
	transform: scale(.94);
}

/* ---------------- 裁剪舞台 ---------------- */

.ac-stage {
	position: relative;
	width: 100%;
	aspect-ratio: 1 / 1;
	margin-bottom: 14px;
	border-radius: 50%;
	overflow: hidden;
	background: #12161c;
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
	/* 让 Cropper 的 canvas 完全填满 */
	line-height: 0;
}

/* 圆形边框：给裁剪区一个明确的视觉边界 */
.ac-stage::after {
	content: '';
	position: absolute;
	inset: 0;
	z-index: 5;
	border-radius: 50%;
	box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .8);
	pointer-events: none;
}

.ac-img {
	display: block;
	max-width: 100%;
	opacity: 0;
	transition: opacity .2s ease;
}

.ac-root.ac-visible .ac-img {
	opacity: 1;
}

/* ---------------- Cropper 定制：圆形预览 ---------------- */

.ac-root .cropper-view-box {
	border-radius: 50%;
	outline: 0;
}

.ac-root .cropper-face {
	border-radius: 50%;
	background-color: transparent;
}

/* 固定比例、不可缩放，四角手柄没有意义 */
.ac-root .cropper-line,
.ac-root .cropper-point {
	display: none;
}

.ac-root .cropper-crop-box {
	border-radius: 50%;
}

.ac-root .cropper-modal {
	opacity: .62;
}

/* 三分参考线调淡，避免圆形预览里显得杂乱 */
.ac-root .cropper-dashed {
	border-color: rgba(255, 255, 255, .22);
	opacity: 1;
}

/* ---------------- 缩放条 ---------------- */

.ac-tools {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 0 2px 6px;
}

.ac-zoom-btn {
	width: 28px;
	height: 28px;
	opacity: .6;
}

.ac-slider {
	flex: 1 1 auto;
	width: 100%;
	height: 22px;
	margin: 0;
	background: transparent;
	-webkit-appearance: none;
	appearance: none;
	cursor: pointer;
}

.ac-slider::-webkit-slider-runnable-track {
	height: 4px;
	border-radius: 999px;
	background: var(--cl-secondary-border-color, rgba(0, 0, 0, .12));
}

.ac-slider::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 18px;
	height: 18px;
	margin-top: -7px;
	border: 0;
	border-radius: 50%;
	background: var(--cl-primary-color, #067aff);
	box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
	transition: transform .12s ease;
}

.ac-slider:active::-webkit-slider-thumb {
	transform: scale(1.12);
}

.ac-slider::-moz-range-track {
	height: 4px;
	border-radius: 999px;
	background: var(--cl-secondary-border-color, rgba(0, 0, 0, .12));
}

.ac-slider::-moz-range-thumb {
	width: 18px;
	height: 18px;
	border: 0;
	border-radius: 50%;
	background: var(--cl-primary-color, #067aff);
	box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}

.ac-slider:focus-visible {
	outline: 2px solid var(--cl-primary-color, #067aff);
	outline-offset: 4px;
	border-radius: 999px;
}

/* ---------------- 次级操作 ---------------- */

.ac-extra {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding-bottom: 14px;
}

.ac-text-btn {
	padding: 6px 14px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	font-size: 13px;
	line-height: 1.4;
	color: var(--cl-primary-text-color, #14171a);
	opacity: .58;
	cursor: pointer;
	transition: background .15s ease, opacity .15s ease;
	-webkit-tap-highlight-color: transparent;
}

.ac-text-btn:hover,
.ac-text-btn:focus-visible {
	opacity: .95;
	background: var(--cl-secondary-bg-color, rgba(0, 0, 0, .06));
	outline: none;
}

.ac-text-btn:active {
	transform: scale(.96);
}

/* ---------------- 底部按钮 ---------------- */

.ac-foot {
	display: flex;
	gap: 10px;
	padding-top: 14px;
	border-top: 1px solid var(--cl-secondary-border-color, rgba(0, 0, 0, .08));
}

.ac-btn {
	flex: 1 1 0;
	height: 44px;
	padding: 0 16px;
	border: 0;
	border-radius: 12px;
	font-size: 14px;
	font-weight: 600;
	line-height: 44px;
	text-align: center;
	cursor: pointer;
	transition: transform .12s ease, opacity .15s ease, background .15s ease;
	-webkit-tap-highlight-color: transparent;
}

.ac-btn:active {
	transform: scale(.98);
}

.ac-btn-ghost {
	background: var(--cl-secondary-bg-color, rgba(0, 0, 0, .05));
	color: var(--cl-primary-text-color, #14171a);
}

.ac-btn-ghost:hover {
	opacity: .82;
}

.ac-btn-primary {
	background: var(--cl-primary-color, #067aff);
	color: #fff;
	box-shadow: 0 6px 18px -6px var(--cl-primary-color, #067aff);
}

.ac-btn-primary:hover {
	filter: brightness(1.06);
}

.ac-btn:disabled {
	opacity: .55;
	cursor: default;
	transform: none;
	filter: none;
}

/* 处理中时锁住整个交互层 */
.ac-root.ac-busy .ac-stage,
.ac-root.ac-busy .ac-tools,
.ac-root.ac-busy .ac-extra {
	pointer-events: none;
	opacity: .6;
}

/* ---------------- 移动端 ---------------- */

@media (max-width: 560px) {
	.ac-mask {
		padding: 0;
		align-items: flex-end;
	}

	.ac-card {
		max-width: 100%;
		max-height: 94vh;
		border-radius: 20px 20px 0 0;
		/* 底部必须留出安全区 + 常规间距，否则按钮会贴边被圆角裁掉 */
		padding: 14px 16px calc(18px + env(safe-area-inset-bottom, 0px));
		transform: translateY(100%);
	}

	.ac-root.ac-visible .ac-card {
		transform: translateY(0);
	}

	/* 限制圆形舞台不超过视口高度的 46%，保证竖屏/横屏都不溢出 */
	.ac-stage {
		max-width: min(92%, 44vh);
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 12px;
	}

	.ac-btn {
		height: 46px;
		line-height: 46px;
	}

	.ac-extra {
		padding-bottom: 12px;
	}
}

/* 尊重"减少动效"偏好 */
@media (prefers-reduced-motion: reduce) {
	.ac-root,
	.ac-card,
	.ac-img {
		transition: none;
	}

	.ac-card {
		transform: none;
		opacity: 1;
	}
}
