/* ============================================================
   云卡商城 · 样式模块 05/11 —— 05-brand-hero.css
   ------------------------------------------------------------
   职责：品牌图标瓦片、首页主视觉轮播、后台横幅实时预览、旧横幅降级
   涵盖：§14A §14B §14C §14D

   ⚠️ 加载顺序即层叠顺序，请勿调整 <link> 的先后。
      本文件由 style.css 按分节边界切出，规则未做任何重排。
   ============================================================ */

/* ============================================================
   14A · 品牌图标瓦片
   ------------------------------------------------------------
   统一形态：品牌色底 + 白色 logo。颜色由 JS 侧用
   U.darkenForWhite() 自动压暗，保证白 logo 的对比度 ≥ 4.5:1，
   因此宝可梦黄、PUBG 橙这类亮色也不会糊。
   ============================================================ */
.brand-tile {
  flex: none;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: var(--r-md);
  background: var(--tile, var(--brand));
  color: #fff;
  line-height: 0;
}
.brand-tile .brand-svg {
  width: 62%;
  height: 62%;
  display: block;
  color: #fff;
}
/* 只覆盖「硬编码色值」的填充，保留 currentColor 与 none 的原意，
   否则会把描边型图标（arcticons）填死。
   :not(.brand-full) 是给全彩图形的豁免 —— 精灵球这类自带配色的图形
   一旦被刷成 currentColor 就只剩个白饼，所以必须放过它。 */
.brand-tile .brand-svg:not(.brand-full) [fill^="#"] { fill: currentColor; }
.brand-tile .brand-svg:not(.brand-full) [stroke^="#"] { stroke: currentColor; }

/* 全彩图形：不铺品牌底色（底色会和图形自身配色打架） */
.brand-tile.bt-full { background: transparent; }
.brand-tile.bt-full .brand-svg { width: 100%; height: 100%; }

.brand-tile.bt-plain { background: var(--surface-3); color: var(--text-2); }
.brand-tile.bt-plain .brand-svg { color: currentColor; }
.brand-tile.bt-plain .ico-svg { width: 55%; height: 55%; }
.brand-tile.bt-emoji { font-size: 55%; line-height: 1; }

/* 官方位图（品牌官网抓取的真实 App 图标）：本身已是彩色圆角方块，铺满即可，
   不需要再加底色或内边距，否则会出现「画中画」的双层边框。 */
.brand-tile.is-img { background: transparent; }
.brand-tile.is-img img {
  object-fit: contain;
  object-position: center;
}

/* 尺寸：数字对应像素，命名与 .thumb-* 对齐 */
.brand-tile.bt-xs { width: 32px; height: 32px; border-radius: var(--r-sm); }
.brand-tile.bt-sm { width: 44px; height: 44px; border-radius: var(--r-sm); }
.brand-tile.bt-md { width: 56px; height: 56px; }
.brand-tile.bt-lg { width: 72px; height: 72px; border-radius: var(--r-lg); }
.brand-tile.bt-xl { width: 96px; height: 96px; border-radius: var(--r-lg); }
.brand-tile.bt-2xl { width: 128px; height: 128px; border-radius: var(--r-lg); }

/* ============================================================
   14B · 首页主视觉轮播
   ============================================================ */
.hero {
  position: relative;
  margin-top: var(--sp-5);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--surface);
  isolation: isolate;
}
.hero-track {
  /* 用 grid 把四张叠在同一格：轨道高度由最高的那张决定，
     不需要写死 min-height，窄屏下文案变高也不会被裁掉。 */
  display: grid;
}

.hero-slide {
  grid-area: 1 / 1;
  display: grid;
  opacity: 0;
  visibility: hidden;
  transform: translateX(2.5%);
  transition: opacity 480ms ease, transform 600ms cubic-bezier(.22, .9, .3, 1),
    visibility 0s linear 600ms;
}
.hero-slide.on {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}

/* 品牌色底纹：用 --tile-rgb 做低透明度叠加，两套主题都能自适应 */
.hero-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(760px 460px at 88% 8%, rgb(var(--tile-rgb, 37 99 235) / .42), transparent 64%),
    linear-gradient(112deg, rgb(var(--tile-rgb, 37 99 235) / .16) 0%, transparent 58%);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  z-index: var(--z-base);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-8);
  padding: var(--sp-10);
}

/* ---- 文案：逐条错峰入场 ---- */
.hero-copy > * {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 460ms ease, transform 560ms cubic-bezier(.22, .9, .3, 1);
}
.hero-slide.on .hero-copy > * { opacity: 1; transform: none; }
.hero-slide.on .hero-copy > *:nth-child(1) { transition-delay: 80ms; }
.hero-slide.on .hero-copy > *:nth-child(2) { transition-delay: 150ms; }
.hero-slide.on .hero-copy > *:nth-child(3) { transition-delay: 220ms; }
.hero-slide.on .hero-copy > *:nth-child(4) { transition-delay: 290ms; }
.hero-slide.on .hero-copy > *:nth-child(5) { transition-delay: 360ms; }

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3);
  margin-bottom: var(--sp-4);
  border: 1px solid rgb(var(--tile-rgb, 37 99 235) / .5);
  border-radius: var(--r-full);
  background: rgb(var(--tile-rgb, 37 99 235) / .14);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  width: max-content;
  max-width: 100%;
}
.hero-title {
  font-size: var(--fs-4xl);
  font-weight: var(--fw-black);
  letter-spacing: -.6px;
  line-height: 1.15;
  color: var(--text);
}
.hero-sub {
  margin-top: var(--sp-3);
  max-width: 34em;
  color: var(--text-2);
  font-size: var(--fs-md);
  line-height: var(--lh-relaxed);
}
.hero-points {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-5);
  margin-top: var(--sp-4);
}
.hero-points li {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1h);
  color: var(--text-2);
  font-size: var(--fs-sm);
}
.hero-points li::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgb(var(--tile-rgb, 37 99 235) / .95);
  flex: none;
}
.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
}
.hero-btn {
  background: var(--tile, var(--brand));
  border-color: var(--tile, var(--brand));
  color: #fff;
}
.hero-btn:hover { filter: brightness(1.1); background: var(--tile, var(--brand)); border-color: var(--tile, var(--brand)); }
.hero-btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--text);
}
.hero-btn-ghost:hover { background: var(--surface-2); border-color: var(--text-3); }

/* ---- 右侧大号品牌图形 ----
   ⚠️ position:relative 是必需的，不是装饰：里面的 <img> 用绝对定位铺满，
   少了它，图片会去找更上层的定位祖先（实测被撑成 1238×319）。
   同样的 relative 也在 .thumb / .thumb / .brand-tile / .goods-hero 上，
   改这一组样式时请一起检查。 */
.hero-art {
  position: relative;
  width: 176px;
  height: 176px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: var(--r-xl);
  background: var(--tile, var(--brand));
  color: #fff;
  box-shadow: 0 18px 44px rgb(var(--tile-rgb, 37 99 235) / .34);
  transform: scale(.94) rotate(-4deg);
  opacity: 0;
  transition: opacity 520ms ease, transform 700ms cubic-bezier(.22, .9, .3, 1);
  transition-delay: 120ms;
}
.hero-slide.on .hero-art { opacity: 1; transform: none; }
.hero-art .brand-svg { width: 58%; height: 58%; display: block; color: #fff; }
.hero-art .brand-svg:not(.brand-full) [fill^="#"] { fill: currentColor; }
.hero-art .brand-svg:not(.brand-full) [stroke^="#"] { stroke: currentColor; }
/* 全彩图形当 hero 主图（如精灵球）：
   换成中性底板（跟随主题的 surface），图形本身的红/白/黑才读得出来 ——
   压在品牌色底上会糊成一片。投影保留，仍是一张「卡」。 */
.hero-art.is-full { background: var(--surface); }
.hero-art.is-full .brand-svg { width: 82%; height: 82%; }
/* 官方位图：图标自带配色，去掉底色与内发光，铺满即可 */
.hero-art.is-img { background: transparent; box-shadow: none; }
.hero-art.is-img img { object-fit: contain; object-position: center; }
/* 官方主视觉大图：是「有构图的整张画」，不是图标 ——
   留白会让它显得像贴歪的贴图，所以铺满 + 裁切，并保留投影让它像一张卡。 */
.hero-art.is-art { background: transparent; }

/* ---- 控件 ---- */
.hero-arrow {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-top: -20px;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--tr), background var(--tr), color var(--tr), border-color var(--tr);
}
.hero:hover .hero-arrow,
.hero:focus-within .hero-arrow { opacity: 1; }
.hero-arrow:hover { background: var(--surface-2); border-color: var(--line-strong); color: var(--text); }
.hero-arrow.prev { left: var(--sp-4); }
.hero-arrow.next { right: var(--sp-4); }

.hero-dots {
  position: absolute;
  left: 50%;
  bottom: var(--sp-4);
  z-index: 2;
  display: flex;
  gap: var(--sp-1h);
  transform: translateX(-50%);
}
.hero-dot {
  position: relative;
  width: 30px;
  height: 4px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--r-full);
  background: var(--line-2);
  cursor: pointer;
  transition: width var(--tr), background var(--tr);
}
.hero-dot:hover { background: var(--line-strong); }
.hero-dot.on { width: 48px; background: rgb(var(--tile-rgb, 37 99 235) / .3); }
.hero-dot-bar {
  position: absolute;
  inset: 0;
  background: var(--tile, var(--brand));
  transform: scaleX(0);
  transform-origin: left center;
}
.hero-dot.on .hero-dot-bar { animation: heroProg 6500ms linear forwards; }
.hero-paused .hero-dot.on .hero-dot-bar { animation-play-state: paused; }
@keyframes heroProg {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* ============================================================
   14C · 后台「横幅管理」的实时预览
   ============================================================ */
.bn-prev-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.bn-prev-wrap {
  padding: var(--sp-3);
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-2);
}
/* 用 iframe 才能让 @media 按手机宽度生效（详见 assets/banner-preview.html 顶部注释） */
.bn-prev-frame {
  display: block;
  width: 100%;
  height: 220px;
  margin: 0 auto;
  border: 0;
  background: transparent;
  transition: width var(--tr);
}
/* 降级分支：iframe 不可用时在弹窗里直接渲染 */
.bn-prev { width: 100%; }
.bn-prev .hero { margin-top: 0; }
.bn-prev .hero-arrow { display: none; }

/* ============================================================
   14D · 旧版静态横幅（保留作为无品牌图形时的降级样式）
   ============================================================ */
.banner {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 240px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--surface);
  text-align: center;
}
.banner .inner { position: relative; z-index: var(--z-base); padding: var(--sp-10) var(--sp-6); }
.banner h1 { color: var(--text); font-size: var(--fs-4xl); font-weight: var(--fw-black); }
.banner h1 .grad { color: var(--brand-fg); }
.banner p { margin-top: var(--sp-3); color: var(--text-2); font-size: var(--fs-md); }
.banner .cta { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-3); margin-top: var(--sp-6); }

/* Constrain reusable cover tiles inside cart and order thumbnail frames. */
.thumb > .brand-tile { width: 100%; height: 100%; border-radius: inherit; }
