/* ============================================================
   背包
   网格按"种类"排，不按件数：7 枚铜钱占一格。
   稀有度只靠边框颜色区分，不加角标——角标一多就像手游。
   ============================================================ */
.bag {
  width: min(660px, calc(100vw - 48px));
  max-height: min(78vh, 700px);
  display: flex;
  flex-direction: column;
  background: var(--ink-3);
  border: 1px solid var(--line-bright);
  border-radius: var(--r-lg);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.72), 0 0 0 1px rgba(255, 255, 255, 0.02);
  overflow: hidden;
  animation: bag-in 0.3s var(--ease-out) both;
}

@keyframes bag-in {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

/* ---------- 头 ---------- */
.bag__head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.bag__title {
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: 0.3em;
  color: var(--t-0);
}

.bag__count {
  font-size: 11.5px;
  color: var(--t-2);
  font-variant-numeric: tabular-nums;
}

.bag__count b {
  color: var(--t-1);
  font-weight: 400;
}

.bag__esc {
  margin-left: auto;
  font-size: 11px;
  color: var(--t-3);
}

/* ---------- 列表 ---------- */
.bag__body {
  flex: 1;
  overflow-y: auto;
  padding: 6px 22px 18px;
}

.bag__group {
  margin-top: 16px;
}

.bag__group-name {
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--t-1);
  margin-bottom: 9px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.bag__group-name::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line-soft), transparent);
}

.bag__grid {
  display: grid;
  /* 六列定宽。和 backpack.js 里的 COLS 必须一致——
     那边按同一个数补空格子，两边对不上就会在行尾留一条缺口 */
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

/* 空格子。它存在的意义是让"9 / 24 格"这个数字有画面：
   空着的地方也是行囊的一部分，只是还没装东西。
   只给一层几乎看不见的底，不描边——描边会让半屏都是虚线框，吵 */
.bag-slot {
  /* 不写 aspect-ratio：格子是拉满一行高的（grid 默认 stretch），
     单独给宽高比会在只有空格子的那几行上比真格子高出一截 */
  min-height: 66px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.012);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.022);
}

/* ---------- 格子 ---------- */
.bag-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 11px 4px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--ink-1);
  transition: all 0.16s var(--ease);
  min-width: 0;
}

.bag-item:hover {
  background: var(--ink-3);
  border-color: var(--line-bright);
  transform: translateY(-1px);
}

.bag-item.is-active {
  background: #161d1a;
  border-color: var(--qing-dim);
}

.bag-item__glyph {
  font-size: 19px;
  line-height: 1;
  color: var(--t-2);
  transition: color 0.16s var(--ease);
}

.bag-item__name {
  font-size: 11.5px;
  color: var(--t-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.bag-item__n {
  position: absolute;
  right: 5px;
  bottom: 4px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--t-2);
  font-variant-numeric: tabular-nums;
}

.bag-item__on {
  position: absolute;
  left: 5px;
  top: 4px;
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--jin);
}

/* 稀有度：只改边框与符号色 */
.bag-item.is-fine {
  border-color: rgba(93, 202, 165, 0.28);
}
.bag-item.is-fine .bag-item__glyph {
  color: var(--qing);
}

.bag-item.is-rare {
  border-color: rgba(217, 164, 65, 0.32);
}
.bag-item.is-rare .bag-item__glyph {
  color: var(--jin);
}

/* 唯一：渐变边框走一圈。双背景裁切，边框当画布 */
.bag-item.is-unique {
  border: 1px solid transparent;
  background-image: linear-gradient(var(--ink-1), var(--ink-1)),
    linear-gradient(90deg, #ffd479, #c9a7ff, #7fd4ff, #ffd479);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  background-size: 100% 100%, 260% 100%;
  box-shadow: 0 0 16px rgba(201, 167, 255, 0.14), inset 0 0 16px rgba(201, 167, 255, 0.1);
  animation: bag-flow 4.5s linear infinite;
}

.bag-item.is-unique .bag-item__glyph {
  color: var(--zi);
  text-shadow: 0 0 10px rgba(201, 167, 255, 0.5);
}

.bag-item.is-unique .bag-item__name {
  color: var(--t-0);
}

@keyframes bag-flow {
  to { background-position: 0 0, 260% 0; }
}

/* ---------- 底部详情 ---------- */
.bag__foot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  border-top: 1px solid var(--line-soft);
  background: var(--ink-3);
  min-height: 66px;
}

.bag__foot-main {
  min-width: 0;
  flex: 1;
}

.bag__foot-name {
  font-family: var(--serif);
  font-size: 14px;
  color: var(--t-0);
  margin-bottom: 4px;
}

.bag__foot-name i {
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--t-2);
  margin-left: 8px;
}

.bag__foot-desc {
  font-size: 12px;
  line-height: 1.65;
  color: var(--t-1);
}

.bag__foot-desc.is-empty {
  color: var(--t-3);
}

.bag__use {
  flex: none;
  padding: 7px 18px;
  font-size: 12.5px;
  letter-spacing: 0.1em;
  color: var(--qing);
  border: 1px solid var(--qing-dim);
  border-radius: var(--r-sm);
  background: rgba(93, 202, 165, 0.06);
  transition: all 0.16s var(--ease);
}

.bag__use:hover {
  background: rgba(93, 202, 165, 0.14);
  border-color: var(--qing);
}

.bag__use[disabled] {
  color: var(--t-3);
  border-color: var(--line);
  background: transparent;
  cursor: default;
}

/* ---------- 窄屏 ---------- */
@media (max-width: 820px) {
  .bag {
    width: calc(100vw - 28px);
    max-height: 84vh;
  }
  .bag__head,
  .bag__body,
  .bag__foot {
    padding-left: 16px;
    padding-right: 16px;
  }
  .bag__grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }
  /* 手机上补的格子按六列算，列数变了就对不上，干脆不显示 */
  .bag-slot {
    display: none;
  }
}

.no-motion .bag-item.is-unique {
  animation: none;
}
