/* 收藏 / 提醒 / 分享（engagement.js 专用）。必须接在 ui.css 之后加载：
 * 后面这几段要覆盖 .hd 的排布和手机上 .item / .offer 的格子分区。
 * 不动 ui.css 里原有规则，只在这三个地方补：顶部入口、卡片上那排按钮、弹层。 */

/* ===== 1. 顶栏入口：我的收藏 / 提醒 ===== */

/* 顶栏的排布归 ui.css 管（现在是竖着两行：上面一行牌子/入口/搜索/登录，下面一行分类横排）。
   这里只留一句「搜索框可以被压窄」，别再动 .hd 自己。2026-09-12 照搬设计稿之后，
   收藏/提醒那两个入口已经搬进 .hd__in 里了；原来那两句把 .hd 摆成一横排，会把分类那排
   顶到屏幕右边去，手机上整页都能左右拖。 */
.hd .search { min-width: 0; }

#engagement-nav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 28px 0 14px;
}
.bj-nav__btn {
  position: relative;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-2);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s, color .15s;
}
.bj-nav__btn .ic { width: 17px; height: 17px; }
.bj-nav__btn:hover { background: var(--sunken); color: var(--text); border-color: var(--line-strong); }
.bj-nav__count {
  position: absolute;
  top: -5px;
  right: -5px;
  font-style: normal;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  min-width: 16px;
  padding: 3px 4px;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--surface);
}
.bj-nav__dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--surface);
}
.bj-nav__short { display: none; }

/* ===== 2. 卡片上那排：收藏 / 提醒 / 分享 ===== */

/* 桌面：整行铺满，摆在操作按钮下面、摊开的各家报价上面 */
.item__engagement,
.offer__engagement {
  grid-column: 1 / -1;
  min-width: 0;
}
.item__engagement { margin-top: 10px; }
.offer__engagement { margin-top: 8px; }
.item__engagement:empty,
.offer__engagement:empty { display: none; }

.bj-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.bj-actions__btn {
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.bj-actions__btn:hover { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.bj-actions__btn.is-on { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); font-weight: 600; }
.bj-actions__btn[disabled] { opacity: 0.55; cursor: default; }
/* 列表行上那三个按钮的小图标版（见 engagement.js 的 compact）：三个小方块横着一排，
   不许折行——折了行就把整个商品行撑高一倍，跟设计稿那行对不上。 */
.bj-actions--compact { flex-wrap: nowrap; gap: 4px; }
.bj-actions__btn--icon {
  width: 28px; height: 28px; padding: 0; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
}
.bj-actions__btn--icon .ic { width: 13px; height: 13px; }
.bj-actions__btn--icon[data-bijia-action="favorite"].is-on .ic,
.bj-actions__btn--icon[data-bijia-action="alert"].is-on .ic { fill: currentColor; }

/* ===== 3. 手机上把 engage 挤进原来的格子分区 ===== */
/* ui.css 的手机断点是 max-width: 900px，这里跟着它走，覆盖 .item / .offer 的分区：
   原样是从 ui.css 抄下来的，只在最后多一行 engage。 */

@media (max-width: 900px) {
  /* 顶栏在手机上排几行由 ui.css 定（牌子 + 右上角按钮 / 搜索 / 分类横排）。
     这里原来给 .hd 钉了死高度、又让它 wrap：竖着排的容器一 wrap 就分成左右两列，
     分类那排被甩到屏幕右边，整页跟着能左右拖（2026-09-12 修）。高度和换行都别再写。 */
  /* 手机上还是两个方块图标（跟设计稿右上角那个铃铛一个样子），只是小一号 */
  .bj-nav__btn { width: 32px; height: 32px; padding: 0; }
  .bj-nav__btn .ic { width: 15px; height: 15px; }
  .bj-nav__count { min-width: 15px; font-size: 10px; padding: 2px 4px; }
  .bj-nav__dot { top: 6px; right: 6px; }

  .item {
    grid-template-areas:
      "main main main main"
      "price stock sales action"
      "engage engage engage engage"
      "offers offers offers offers";
  }
  .item__engagement { grid-area: engage; margin-top: 0; }

  .offer {
    grid-template-areas:
      "name name name name"
      "price stock sales action"
      "engage engage engage engage";
  }
  .offer__engagement { grid-area: engage; margin-top: 0; }

  .bj-actions { gap: 6px; }
  .bj-actions__btn { height: 32px; padding: 0 10px; font-size: 12.5px; }
}

/* 商品卡上的三个图标是手机最常点的收藏、提醒、分享。只放大这一处；
   顶栏、详情和弹层仍沿用各自的尺寸，避免整站无关控件一起变大。 */
@media (max-width: 760px) {
  .row__acts .bj-actions--compact { gap: 8px; }
  .row__acts .bj-actions__btn--icon { width: 44px; height: 44px; }
  .row__acts .bj-actions__btn--icon .ic { width: 16px; height: 16px; }
}

/* ===== 4. 弹层 ===== */

body.bj-lock { overflow: hidden; }

.bj-layer {
  position: fixed;
  inset: 0;
  z-index: 58;              /* 在 toast(60) 和登录框(70) 下面，盖住大厅(50)和列表 */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.bj-layer__mask {
  position: absolute;
  inset: 0;
  background: rgba(15, 20, 32, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.bj-layer__card {
  position: relative;
  width: min(680px, 100%);
  max-height: min(86vh, 900px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
  overflow: hidden;
}
.bj-layer__head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--line);
}
.bj-layer__head-text { min-width: 0; }
.bj-layer__title {
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bj-layer__sub { margin: 4px 0 0; font-size: 12.5px; color: var(--text-3); }
.bj-layer__close {
  flex: 0 0 auto;
  margin-left: auto;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  font-size: 22px;
  line-height: 1;
  color: var(--text-3);
  display: inline-grid;
  place-items: center;
}
.bj-layer__close:hover { background: var(--sunken); color: var(--text); }

.bj-layer__tabs { display: flex; gap: 4px; padding: 10px 20px 0; border-bottom: 1px solid var(--line); }
/* 「我的收藏」整页里的那一排标签：页面上没有浮层那种内边距，自己给 */
.bj-tabs--page { padding: 0 0 10px; }
.bj-body--page { padding: 0 0 40px; }
.bj-tab {
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
}
.bj-tab:hover { color: var(--text); }
.bj-tab[aria-selected="true"] { color: var(--text); font-weight: 600; border-color: var(--accent); }
.bj-tab__count {
  margin-left: 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-text);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 6px;
}

.bj-layer__body {
  padding: 16px 20px 20px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 900px) {
  .bj-layer { padding: 0; align-items: flex-end; }
  .bj-layer__card {
    width: 100%;
    max-height: 92vh;
    border-radius: 18px 18px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bj-layer__head { padding-top: calc(18px + env(safe-area-inset-top)); }
}

/* ===== 5. 列表行、标签、按钮 ===== */

.bj-state { padding: 28px 8px; text-align: center; color: var(--text-2); font-size: 14px; }
.bj-state p { margin: 0 0 12px; }
.bj-state--error { color: var(--danger); }

.bj-list { display: flex; flex-direction: column; gap: 10px; }
.bj-list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.bj-list-head__text { font-size: 12.5px; color: var(--text-3); }

.bj-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.bj-row--unread { border-color: #c7d7fe; background: #f8faff; }
.bj-row__main { min-width: 0; }
.bj-row__title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.4;
}
.bj-row__meta { margin-top: 3px; font-size: 12.5px; color: var(--text-2); overflow-wrap: anywhere; }
.bj-row__warn { margin-top: 4px; font-size: 12.5px; color: var(--warn); }
.bj-row__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.bj-row__actions { display: flex; flex-wrap: wrap; gap: 8px; }

.bj-tag {
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 4px 7px;
  border-radius: 6px;
  color: var(--accent-text);
  background: var(--accent-soft);
}
.bj-tag--warn { color: var(--warn); background: #fffbeb; }
.bj-tag--off { color: var(--text-3); background: var(--sunken); }

.bj-btn {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.bj-btn:hover { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.bj-btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.bj-btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.bj-btn[disabled] { opacity: 0.55; cursor: default; }
.bj-actions-row { display: flex; gap: 10px; margin: 14px 0; }
.bj-actions-row .bj-btn { flex: 1 1 0; height: 40px; }

.bj-target { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fbfbfc; }
.bj-section-title { margin: 16px 0 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }

/* ===== 6. 提醒设置表单 ===== */

.bj-form { display: flex; flex-direction: column; gap: 12px; }
.bj-check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.bj-check input { width: 17px; height: 17px; accent-color: var(--accent); }
.bj-field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--text-2); }
.bj-field input {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  font-size: 14px;
  color: var(--text);
}
.bj-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.bj-form__actions { display: flex; gap: 10px; }
.bj-form__actions .bj-btn { flex: 1 1 0; height: 40px; }
.bj-note {
  margin: 0;
  padding: 9px 11px;
  border-radius: 9px;
  background: var(--sunken);
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.5;
}
.bj-note--info { background: var(--accent-soft); color: var(--accent-text); }
.bj-note--warn { background: #fffbeb; color: var(--warn); }
.bj-error { margin: 0; color: var(--danger); font-size: 12.5px; }
.bj-tip { margin: 0; color: var(--text-3); font-size: 12px; line-height: 1.5; }

/* ===== 7. 海报与分享 ===== */

.bj-share { display: flex; flex-direction: column; }
.bj-poster { display: flex; justify-content: center; }
.bj-poster__canvas {
  width: 100%;
  max-width: 320px;
  height: auto;
  display: block;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.bj-offers { display: flex; flex-direction: column; }
.bj-offer {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.bj-offer__name { min-width: 0; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bj-offer__price { flex: 0 0 auto; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
