/* 平台首页 · 新版布局（v2）：彩色开头 + 搜索、最近逛过、热门商品、行业筛选、紧凑的店铺卡片。
   只有模版的 layout 是 v2 时服务器才会加载这个文件，叠在 home.css 上面。
   颜色和装饰由模版文件（/home-tpl/<编号>.css）定，约定这几个变量：
     --hero-a / --hero-b   开头色带从上到下的两个颜色（手机上顶栏也是 --hero-a）
     --hero-ink            色带上的文字颜色
     --accent / --accent-ink   强调色（选中的行业、角标、入驻卡片）和它上面的文字
     --hero-art            色带右上角的装饰图；--hero-art-size 它的大小
     --greet-bg / --greet-ink  节日问候语小标签的底色和文字
   节日模版还可以给 .hero-band::before 加自己的效果（比如飘雪）
   版式不同的模版（简约黑白、大图画报、霓虹夜色、市集手账、便当格子）在自己的样式文件里重排卡片，
   能用的钩子：店铺卡片上的 data-p（有几张商品图）和「进店」按钮 .s-go2（默认不显示）、热门商品的名次 .hp-n、
   开头的 #heroMosaic 和 #heroStats（模版登记里 ui.hero / ui.stats 决定填不填，营业格子带 --p 营业比例）、ui.eyebrow = date 时开头小字是今天的日期 */
:root {
  --hero-a: #5b5bd6; --hero-b: #7560ea; --hero-ink: #ffffff;
  --accent: #5b5bd6; --accent-ink: #ffffff;
  --hero-art: none; --hero-art-size: auto 128px;
  --greet-bg: color-mix(in srgb, var(--hero-ink) 18%, transparent); --greet-ink: var(--hero-ink);
  --price: #dc2f3f; /* 首页上的价格统一用一个颜色，不跟各店的主题走，免得一排商品五颜六色 */
  --top-h: 58px;
}
@media (prefers-color-scheme: dark) { :root { --price: #ff7a85; } }
body::before { display: none; } /* 不用经典布局顶部那层淡底色 */
main { padding-bottom: 28px; }

/* ---------- 顶栏 ---------- */
.top { --mark-bg: var(--accent); --mark-ink: var(--accent-ink); transition: background-color .25s ease-out, color .25s ease-out; }
.top .mark { background: var(--mark-bg); color: var(--mark-ink); transition: background-color .25s ease-out, color .25s ease-out; }
html.scrolled .top { box-shadow: 0 1px 0 var(--line); }
/* 手机上：还在开头色带范围内时，顶栏和色带是一整块颜色；滑过去之后换成普通的浅底 */
@media (max-width: 719px) {
  #btnApply { display: none; } /* 商户入驻放到店铺列表后面，顶栏留给顾客 */
  html:not(.scrolled) .top { background: var(--hero-a); color: var(--hero-ink); backdrop-filter: none; -webkit-backdrop-filter: none; --mark-bg: color-mix(in srgb, var(--hero-ink) 20%, transparent); --mark-ink: var(--hero-ink); }
  html:not(.scrolled) .top .pill { background: color-mix(in srgb, var(--hero-ink) 16%, transparent); box-shadow: none; }
}

/* ---------- 开头：色带、问候语、标题、搜索 ---------- */
.hero-band { position: relative; overflow: hidden; border-radius: 0 0 26px 26px; background: linear-gradient(to bottom, var(--hero-a), var(--hero-b)); color: var(--hero-ink); }
.hero-band::after, .hero::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: var(--hero-art) no-repeat right top / var(--hero-art-size); }
.hero::after { display: none; }
.hero { position: relative; z-index: 1; padding: 4px 2px 22px; }
.hero > * { position: relative; z-index: 1; }
.greet { display: inline-flex; align-items: center; max-width: 100%; min-height: 26px; margin-bottom: 9px; padding: 3px 11px; border-radius: 999px; background: var(--greet-bg); color: var(--greet-ink); font-size: 12.5px; font-weight: 700; line-height: 1.35; }
.hero h1 { font-size: 25px; max-width: 78%; }
.hero p { color: color-mix(in srgb, var(--hero-ink) 80%, transparent); }
.search { height: 50px; margin-top: 16px; background: #fff; color: #17181c; box-shadow: 0 8px 22px rgba(15, 16, 30, .16); }
.search svg { stroke: #7b7f8a; }
.search input::placeholder { color: #7b7f8a; }
.search:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--hero-ink) 50%, transparent), 0 8px 22px rgba(15, 16, 30, .16); }
.q-clear { background: #f0f1f4; color: #7b7f8a; }
@media (prefers-color-scheme: dark) {
  .search { background: #1f2026; color: #f2f3f5; }
  .q-clear { background: #2b2d35; color: #9a9eaa; }
}
/* 宽屏：色带变成一块圆角横幅，顶栏保持普通样子 */
@media (min-width: 720px) {
  .hero-band { overflow: visible; border-radius: 0; background: none; color: inherit; }
  .hero-band::after { display: none; }
  .hero { margin-top: 8px; padding: 36px 40px 40px; border-radius: 28px; overflow: hidden; background: linear-gradient(120deg, var(--hero-a), var(--hero-b)); color: var(--hero-ink); --hero-art-size: auto 100%; }
  .hero::after { display: block; background-position: right 28px top; }
  .hero h1 { font-size: 32px; max-width: 70%; }
  .hero p { font-size: 15px; }
  .search { max-width: 540px; height: 52px; margin-top: 20px; }
}

/* ---------- 小标题 ---------- */
.sec-h { margin: 20px 2px 10px; }
.sec-h h2 { font-size: 16.5px; font-weight: 800; color: var(--text); }

/* ---------- 横着滑的一排（最近逛过、热门商品）：手机上滑到屏幕边 ---------- */
.row-x { display: flex; gap: 10px; margin: 0 -16px; padding: 2px 16px 8px; overflow-x: auto; scroll-snap-type: x proximity; scroll-padding-left: 16px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.row-x::-webkit-scrollbar { display: none; }

/* 最近逛过 */
.rc { position: relative; flex: none; width: 68px; display: flex; flex-direction: column; align-items: center; gap: 6px; color: inherit; text-decoration: none; scroll-snap-align: start; transition: transform .35s var(--spring); }
.rc:active { transform: scale(.92); }
.rc .logo { width: 56px; height: 56px; border-radius: 18px; box-shadow: var(--shadow); }
.rc b { max-width: 100%; font-size: 12px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc em { position: absolute; top: -4px; right: 0; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; border: 2px solid var(--bg); display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-style: normal; font-size: 11px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rc.off .logo { opacity: .6; filter: saturate(.6); }

/* 热门商品。名次 .hp-n 默认不显示，做排行榜样式的模版自己打开 */
.hp-n { display: none; }
/* 店铺卡片上的「进店」按钮：默认不显示，橱窗、故事卡片这类模版自己打开 */
.s-go2 { display: none; }
.hp { flex: none; width: 122px; display: flex; flex-direction: column; padding-bottom: 10px; border-radius: 16px; overflow: hidden; background: var(--card); box-shadow: var(--shadow); color: inherit; text-decoration: none; scroll-snap-align: start; transition: transform .35s var(--spring); }
.hp:active { transform: scale(.96); }
.hp .pic { width: 122px; border-radius: 0; }
.hp b { margin: 8px 10px 0; font-size: 13px; font-weight: 600; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hp em { margin: 2px 10px 0; font-style: normal; font-size: 14.5px; font-weight: 800; color: var(--price); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hp small { margin: 1px 10px 0; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hp.off .pic img { opacity: .6; filter: saturate(.7); }

/* ---------- 行业筛选：往下滑时吸在顶栏下面 ---------- */
.cats { position: sticky; top: var(--top-h); z-index: 5; display: flex; gap: 8px; margin: 12px -16px -8px; padding: 8px 16px; overflow-x: auto; scrollbar-width: none; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px); }
.cats::-webkit-scrollbar { display: none; }
.cat { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px 0 11px; border-radius: 999px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); color: var(--sub); font-size: 13.5px; font-weight: 600; white-space: nowrap; transition: transform .35s var(--spring), background-color .15s, color .15s; }
.cat svg { flex: none; width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cat:active { transform: scale(.93); }
.cat.on { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.filter[aria-pressed="true"] { background: var(--ok-bg); }

/* ---------- 店铺卡片 ---------- */
.grid { gap: 12px; }
.shop2 { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 14px; border-radius: 20px; background: var(--card); box-shadow: var(--shadow); color: inherit; text-decoration: none; transition: transform .4s var(--spring), box-shadow .25s ease-out; }
.shop2:active { transform: scale(.975); }
.shop2:focus-visible, .hp:focus-visible, .rc:focus-visible, .cat:focus-visible, .join:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (hover: hover) {
  .shop2:hover, .hp:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
  .join:hover .join-go { transform: translateX(3px); }
}
.grid.intro .shop2 { animation: rise .55s var(--smooth) both; animation-delay: calc(var(--i, 0) * 60ms); }
.shop2 .s-head { gap: 11px; }
.shop2 .logo { width: 46px; height: 46px; border-radius: 14px; font-size: 20px; }
.shop2 .s-tx b { font-size: 16px; }
.shop2 .s-tx small { font-size: 12.5px; }
.st { flex: none; align-self: flex-start; display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.st i { position: relative; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st.open { background: var(--ok-bg); color: var(--ok); }
.st.open i::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: currentColor; animation: ping 2.4s ease-out infinite; }
.st.closed { background: var(--field); color: var(--muted); }
.shop2 .s-pics { gap: 6px; }
.shop2 .pic { position: relative; border-radius: 12px; }
.shop2 .pic em { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(12, 14, 20, .52); color: #fff; font-style: normal; font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.shop2.off .pic img { opacity: .6; filter: saturate(.7); }
.shop2.off .pic { opacity: 1; filter: none; }
.s-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 24px; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.s-meta > span:first-child { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-meta u { text-decoration: none; color: var(--warn); font-weight: 600; }
.s-meta .tag { flex: none; height: 24px; padding: 0 9px; font-size: 12px; }

/* ---------- 商户入驻 ---------- */
.join { display: flex; align-items: center; gap: 12px; margin-top: 22px; padding: 14px 16px; border-radius: 20px; background: color-mix(in srgb, var(--accent) 9%, var(--card)); color: inherit; text-decoration: none; }
.join-ic { flex: none; width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); }
.join-ic svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.join-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.join-tx b { font-size: 15px; }
.join-tx small { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.join-go { flex: none; width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .25s ease-out; }
@media (min-width: 720px) { .join { max-width: 540px; margin-left: auto; margin-right: auto; } }

.dlg-btn { background: var(--accent); color: var(--accent-ink); }
.dlg input:focus, .dlg select:focus, .dlg textarea:focus { box-shadow: 0 0 0 2px var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .shop2, .hp, .rc, .cat, .join-go, .top, .top .mark { transition: none; }
  .grid.intro .shop2, .st.open i::after { animation: none !important; }
}

/* 宽屏没有手指可以滑：热门商品排成整齐的一行，放不下的不显示 */
@media (min-width: 720px) and (hover: hover) {
  .hot-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); grid-template-rows: auto; grid-auto-rows: 0; column-gap: 12px; row-gap: 0; overflow: hidden; padding-top: 6px; padding-bottom: 0; }
  .hot-row .hp { width: auto; margin-bottom: 18px; } /* 下面留的空放卡片的阴影；第二排起的卡片正好被裁在外面 */
  .hot-row .hp .pic { width: 100%; }
}
