/* ============================================================
   图廊 TTGallery · 主壳与侧栏（系列 / 角色）
   参考 Wallhaven：侧栏只做精确定位，视觉全部让给图片
   ============================================================ */

/* ══ 主壳：侧栏 + 展厅 ══ */
.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  gap: var(--shell-gap);
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-5) var(--pad-x) var(--sp-7);
}

/* ══ 侧栏 ══ */
.rail {
  position: sticky;
  top: calc(var(--topbar-h) + var(--sp-5));
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  max-height: calc(100vh - var(--topbar-h) - var(--sp-7));
  overflow-y: auto;
  scrollbar-width: thin;
}
.rail-block { display: flex; flex-direction: column; gap: var(--sp-2); }
.rail-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
  margin: 0;
  font-size: var(--fs-2xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}
.rail-hint {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  opacity: 0.8;
}

/* —— 系列：纯文本行 + 右侧计数 —— */
.opt-list { display: flex; flex-direction: column; gap: 1px; }
.opt-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: 6px var(--sp-2);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  color: var(--text-mid);
  text-align: left;
  background: none;
  border: 0;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.opt-item:hover { background: var(--surface); color: var(--text); }
.opt-item.is-active {
  font-weight: 500;
  color: var(--text);
  background: var(--bg-elev);
  box-shadow: inset 0 0 0 1px var(--line);
}
.opt-num {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}

/* —— 角色：头像格 —— */
.char-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-2) 6px;
}
.char-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}
.char-av {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--surface);
  border-radius: var(--r-sm);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease);
  opacity: 0.86;
}
.char-av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.char-tile:hover .char-av { opacity: 1; box-shadow: inset 0 0 0 1px var(--line-2); }
.char-tile.is-active .char-av {
  opacity: 1;
  box-shadow: inset 0 0 0 2px var(--ink);
}
.char-name {
  max-width: 100%;
  overflow: hidden;
  font-size: var(--fs-2xs);
  line-height: 1.3;
  color: var(--text-mid);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.char-tile.is-active .char-name { font-weight: 500; color: var(--text); }
.char-count {
  position: absolute;
  right: 2px;
  bottom: 2px;
  padding: 0 3px;
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1.6;
  color: var(--veil-ink);
  background: var(--badge-bg);
  border-radius: 3px;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
}
.char-tile:hover .char-count,
.char-tile.is-active .char-count { opacity: 1; }

/* —— 清除筛选 —— */
.reset-btn {
  align-self: flex-start;
  padding: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  color: var(--text-mid);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line-2);
  cursor: pointer;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.reset-btn:hover { color: var(--text); border-color: var(--text); }
.reset-btn:disabled { color: var(--text-dim); border-color: var(--line); cursor: default; }

/* ══ 展厅结果栏 ══ */
.hall { min-width: 0; }
.hall-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding-bottom: var(--sp-3);
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--line);
}
.hall-count {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  white-space: nowrap;
}
.active-path {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.path-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  color: var(--text-mid);
  background: var(--surface);
  border: 0;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.path-chip:hover { color: var(--text); background: var(--surface-2); }
.path-chip b { font-weight: 500; }
.path-chip i { font-style: normal; opacity: 0.55; }
.path-chip:hover i { opacity: 1; }

.density {
  display: flex;
  gap: 2px;
  flex: none;
  padding: 2px;
  background: var(--surface);
  border-radius: var(--r-sm);
}
.density button {
  padding: 1px 8px;
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  color: var(--text-dim);
  background: none;
  border: 0;
  border-radius: 3px;
  cursor: pointer;
}
.density button.is-active {
  color: var(--text);
  background: var(--bg-elev);
  box-shadow: var(--shadow-1);
}

/* ══ 响应式 ══ */
@media (max-width: 1080px) {
  :root { --rail-w: 168px; --shell-gap: 20px; --pad-x: 16px; }
  .char-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--sp-4);
    padding: var(--sp-3) var(--sp-3) var(--sp-6);
  }
  .rail {
    position: static;
    max-height: none;
    padding-bottom: var(--sp-3);
    overflow: visible;
    border-bottom: 1px solid var(--line);
  }
  .char-grid {
    display: flex;
    gap: 6px;
    padding-bottom: var(--sp-1);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .char-tile { flex: 0 0 52px; }
  .reset-btn { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
