/*
 * 短链页共用样式
 * 所有流程页面共用这一份，改颜色圆角间距只改这里。
 * 页面引用时带版本号：<link rel="stylesheet" href="/css/link.css?v=20261028">
 */

:root {
	--brand: #876EB7;
	--brand-deep: #7C63AC;
	--brand-darker: #6A5399;
	--paper: #F7F5FB;
	--ink: #211B2E;
	--muted: #6F6879;

	/* 以下几项由 js/theme.js 按厨房接口的 theme_color 覆盖。
	   单独列出来，是为了在没拿到主题色时也有一致的观感 */
	--tint: #F3EFFA;
	--tint-2: #F1EEF7;
	--glow: rgba(124, 99, 172, .7);
	--ring: rgba(135, 110, 183, .1);
	--shadow: rgba(63, 44, 96, .35);
	--shadow-2: rgba(63, 44, 96, .05);
}

* {
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
}

html {
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 32px 20px;
	background: radial-gradient(120% 90% at 50% 0%, var(--tint) 0%, var(--paper) 58%, var(--tint-2) 100%);
	color: var(--ink);
	font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

/* Vue 挂载点：卡片和弹框要当成 body 的直接子元素来排，自己不能占一层 */
#app {
	display: contents;
}

/* 卡片固定占位，内容就绪后整体淡入，加载过程不抖动 */
.card {
	width: 100%;
	max-width: 360px;
	min-height: 392px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 40px 26px;
	border-radius: 26px;
	background: #fff;
	text-align: center;
	box-shadow: 0 22px 60px -28px var(--shadow), 0 2px 6px var(--shadow-2);
}

.card>* {
	opacity: 0;
	transform: translateY(6px);
	transition: opacity .24s ease, transform .24s ease;
}

.card[data-ready="1"]>* {
	opacity: 1;
	transform: none;
}

/* 日志不受淡入影响：页面还没渲染出来时也要能看见错误 */
.card #debug {
	opacity: 1;
	transform: none;
}

.avatar {
	flex: 0 0 auto;
	width: 74px;
	height: 74px;
	border-radius: 22px;
	overflow: hidden;
	background: var(--tint);
	box-shadow: 0 0 0 6px var(--ring);
}

.avatar img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* 菜单详情页：菜品大图优先，有图时头像让位（JS 里给 avatar 加 hidden） */
.avatar[hidden] {
	display: none;
}

.dish {
	width: 100%;
	margin-top: -6px;
}

.dish[hidden] {
	display: none;
}

/* 4:3 定高比用 padding-top 撑，不用 aspect-ratio —— X5 内核（Chrome < 88）不认 */
.dish .photo {
	position: relative;
	width: 100%;
	padding-top: 75%;
	border-radius: 18px;
	overflow: hidden;
	background: var(--tint);
}

/* 图彻底加载不出来时（老设备不认 webp 且 jpg 也失败）：留住占位框，
   页面看着像「图糊了」，而不是整块消失、页面像没数据 */
.dish .photo.broken {
	background: var(--tint);
}

.dish .photo.broken::after {
	content: '图片加载失败';
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	font-size: 13px;
	color: var(--muted);
}

.dish .photo img {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.title {
	margin: 20px 0 0;
	font-size: 20px;
	line-height: 1.4;
	font-weight: 600;
	letter-spacing: .01em;
}

.desc {
	margin: 8px 0 0;
	font-size: 14px;
	line-height: 1.65;
	color: var(--muted);
}

.desc[hidden] {
	display: none;
}

/* 按钮这一行的高度常驻：微信开放标签接管的那一刻，卡片里的内容不会上下跳 */
.act {
	position: relative;
	width: 100%;
	min-height: 52px;
	margin-top: 28px;
}

.act[hidden] {
	display: none;
}

/* 开放标签盖在原生按钮的同一位置上（绝对定位，不参与排版）：
   标签就位就是「原位替换」，既不撑高也不移动，看起来按钮没换过 */
#slot {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
}

.btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 52px;
	padding: 0 18px;
	border: 0;
	border-radius: 14px;
	font-family: inherit;
	font-size: 16px;
	font-weight: 600;
	letter-spacing: .04em;
	cursor: pointer;
}

.btn[hidden] {
	display: none;
}

.btn-primary {
	background: var(--brand-deep);
	color: #fff;
	box-shadow: 0 10px 24px -10px var(--glow);
}

.btn-primary:active {
	transform: scale(.972);
	background: var(--brand-darker);
}

.btn-text {
	height: 42px;
	margin-top: 6px;
	background: transparent;
	color: var(--muted);
	font-weight: 500;
}

/* 微信开放标签必须撑满容器，否则点不到。
   投影写在宿主元素上：标签内部是影子 DOM、读不到页面样式，但宿主元素还在
   页面里，能直接用页面的 CSS 变量 —— 跟原生 .btn-primary 的投影一模一样，
   接管瞬间看不出按钮换过 */
#slot wx-open-launch-app {
	display: block;
	width: 100%;
	border-radius: 14px;
	box-shadow: 0 10px 24px -10px var(--glow);
}

/* 弹框 */
.mask {
	position: fixed;
	inset: 0;
	z-index: 20;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: rgba(33, 27, 46, .42);
	opacity: 0;
	visibility: hidden;
	transition: opacity .2s ease;
}

.mask.show {
	opacity: 1;
	visibility: visible;
}

.dialog {
	width: 100%;
	max-width: 300px;
	padding: 26px 22px 14px;
	border-radius: 20px;
	background: #fff;
	text-align: center;
	transform: translateY(8px) scale(.98);
	transition: transform .22s ease;
}

.mask.show .dialog {
	transform: none;
}

.dialog h2 {
	margin: 0;
	font-size: 17px;
	font-weight: 600;
}

.dialog p {
	margin: 10px 0 20px;
	font-size: 14px;
	line-height: 1.65;
	color: var(--muted);
}

/* 带 debug=1 才出现 */
#debug {
	margin: 14px 0 0;
	font-size: 12px;
	line-height: 1.6;
	text-align: left;
	word-break: break-all;
	color: #B3261E;
}

#debug:empty {
	display: none;
}

/* 测试态角标（ces 下默认出现，正式页带 ?debug=1 才出现）
   默认隐藏是必须的：Vue 挂载前模板里的元素已经渲染出来了，
   不做这一步就会先亮一下「测试页」再消失 */
.badge {
	display: none;
	position: fixed;
	top: 12px;
	right: 12px;
	z-index: 30;
	padding: 3px 9px;
	border-radius: 100px;
	background: rgba(179, 38, 30, .1);
	color: #B3261E;
	font-size: 11px;
	font-weight: 600;
	pointer-events: none;
}

/* Vue 挂载后由 :class 打开 */
.badge.on {
	display: block;
}

@media (prefers-reduced-motion: reduce) {

	.card>*,
	.mask,
	.dialog {
		transition: none;
	}
}
