/* ============ 残月仓库 · 样式 ============ */

:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #e2e8f0;
  --text: #1f2a37;
  --muted: #6b7a8d;
  --accent: #3b6ea5;
  --accent-deep: #2c5577;
  --accent-soft: #eef3f9;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(24, 39, 56, .05), 0 4px 14px rgba(24, 39, 56, .05);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC",
               "Noto Sans CJK SC", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

.wrap {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .92em;
  background: #eef1f5;
  border-radius: 4px;
  padding: 1px 5px;
}

/* ---------- 头部 ---------- */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 18px;
  padding-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.brand-mark svg { width: 22px; height: 22px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 17px; letter-spacing: .5px; }
.brand-text em {
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
}

.brand-note {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------- 工具栏 ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 26px;
}

.search {
  position: relative;
  flex: 1 1 320px;
  min-width: 0;
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: #9aa7b5;
  pointer-events: none;
}

.search input {
  width: 100%;
  padding: 11px 38px 11px 40px;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.search input::-webkit-search-cancel-button { display: none; }

.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 110, 165, .12);
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  line-height: 1;
  font-size: 18px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.search-clear:hover { background: #eef1f5; color: var(--text); }

.toolbar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- 按钮 ---------- */
.btn {
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
  padding: 9px 16px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .12s ease;
}

.btn:hover { border-color: #c8d2dd; background: #f8fafc; }

.btn:active { transform: translateY(1px); }

.btn-primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }

.btn-sm { font-size: 13px; padding: 7px 12px; }

/* ---------- 标签筛选条 ---------- */
.tags-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.tags-bar:empty { margin-top: 0; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 13px;
  padding: 6px 13px;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .15s ease;
}

.chip:hover {
  border-color: #c8d2dd;
  color: var(--text);
  transform: translateY(-1px);
}

.chip-n {
  font-size: 11.5px;
  color: #9aa7b5;
  font-variant-numeric: tabular-nums;
}

/* 标签配色（与录入说明.txt 的标签类名表一一对应） */
.chip.tag-pcgame      { background: #eaf1fa; border-color: #cfe0ee; color: #2c5f8a; }
.chip.tag-pcgame .chip-n { color: #6f8fa8; }
.chip.tag-mobilegame  { background: #e9f4ec; border-color: #cde6d6; color: #2f7a4a; }
.chip.tag-mobilegame .chip-n { color: #6f9c80; }
.chip.tag-vanilla     { background: #eaebf8; border-color: #d6d8ee; color: #444fa0; }
.chip.tag-vanilla .chip-n { color: #7d80b3; }
.chip.tag-modified    { background: #f1ecfb; border-color: #e0d8f2; color: #5f4bb0; }
.chip.tag-modified .chip-n { color: #8f83c4; }
.chip.tag-plugin      { background: #fbf1e3; border-color: #efdcc4; color: #a8641f; }
.chip.tag-plugin .chip-n { color: #b58a5c; }
.chip.tag-assist      { background: #fceef5; border-color: #f2d5e2; color: #a83a72; }
.chip.tag-assist .chip-n { color: #bd8299; }
.chip.tag-app         { background: #e6f2f7; border-color: #cbe4ee; color: #2a7695; }
.chip.tag-app .chip-n { color: #6d95a8; }
.chip.tag-other       { background: #f2f4f7; border-color: #e4e8ee; color: #6b7a8d; }
.chip.tag-other .chip-n { color: #9aa7b5; }

.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chip.is-active .chip-n { color: rgba(255, 255, 255, .75); }

/* ---------- 文件列表 ---------- */
.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
  padding-bottom: 40px;
}

.file-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 15px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .18s ease;
}

.file-card:hover {
  border-color: #c9d8e8;
  border-left-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(24, 39, 56, .06), 0 10px 26px rgba(24, 39, 56, .1);
}

.file-body { flex: 1; min-width: 0; }

.file-name {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
  word-break: break-all;
}

.file-desc {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.file-desc-empty { color: #a3aeb9; font-style: italic; }

.file-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.chip-tag {
  font-size: 12px;
  line-height: 1.5;
  padding: 1px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.chip-tag.tag-pcgame     { background: #eef4fa; color: #2c5f8a; }
.chip-tag.tag-mobilegame { background: #eeF6f0; color: #2f7a4a; }
.chip-tag.tag-vanilla    { background: #eef0f8; color: #444fa0; }
.chip-tag.tag-modified   { background: #f5f2fc; color: #5f4bb0; }
.chip-tag.tag-plugin     { background: #fdf4e8; color: #a8641f; }
.chip-tag.tag-assist     { background: #fdf1f6; color: #a83a72; }
.chip-tag.tag-app        { background: #eef6fa; color: #2a7695; }
.chip-tag.tag-other      { background: #f3f5f7; color: #6b7a8d; }

.file-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: none;
}

mark {
  background: #fff2c9;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

/* ---------- 空状态 ---------- */
.empty {
  padding: 56px 24px;
  text-align: center;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}

.empty p { margin: 0 0 6px; }
.empty p:last-child { margin-bottom: 0; font-size: 13px; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal[hidden] { display: none; }

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(22, 32, 44, .45);
  backdrop-filter: blur(2px);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(16, 28, 40, .24);
  padding: 24px 26px 20px;
  animation: pop .16s ease-out;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.modal-close {
  position: absolute;
  right: 14px;
  top: 12px;
  width: 30px;
  height: 30px;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.modal-close:hover { background: #f1f4f8; color: var(--text); }

.modal-title {
  margin: 0 0 8px;
  font-size: 17px;
  word-break: break-all;
  padding-right: 34px;
}

.modal-desc {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-desc:empty { display: none; }

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.modal-meta {
  margin: 0 0 20px;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 13px;
}

.modal-meta div {
  display: flex;
  gap: 10px;
  padding: 3px 0;
}

.modal-meta dt {
  flex: none;
  width: 76px;
  color: var(--muted);
}

.modal-meta dd {
  margin: 0;
  flex: 1;
  min-width: 0;
  word-break: break-all;
}

.modal-meta dd.muted { color: #9aa7b5; }

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---------- 提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(90vw, 460px);
  padding: 11px 18px;
  font-size: 13.5px;
  color: #fff;
  background: #2b3644;
  border-radius: 9px;
  box-shadow: 0 8px 24px rgba(16, 28, 40, .25);
}

.toast[hidden] { display: none; }

/* ---------- 页脚 ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--card);
  padding: 22px 0 30px;
  font-size: 12.5px;
  color: var(--muted);
}

.site-footer p { margin: 0 0 4px; }
.site-footer p:last-child { margin-bottom: 0; }
.site-footer .legal { color: #9aa7b5; }

/* ---------- 响应式 ---------- */
@media (max-width: 620px) {
  body { font-size: 14.5px; }

  .header-inner { padding-top: 16px; padding-bottom: 16px; }
  .brand-note { flex-basis: 100%; }

  .toolbar { margin-top: 20px; }
  .toolbar-meta { width: 100%; justify-content: space-between; }

  .file-card { flex-wrap: wrap; gap: 12px; padding: 15px; }
  .file-actions { flex-direction: row; width: 100%; }
  .file-actions .btn { flex: 1; }

  .modal-card { padding: 22px 18px 18px; }
  .modal-actions .btn { flex: 1 1 100%; }
}

/* ---------- 动态效果 ---------- */

@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

@keyframes chipIn {
  from { opacity: 0; transform: translateY(6px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: none; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes maskIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes countFlash {
  0%   { color: var(--accent); transform: translateY(-2px); }
  100% { color: var(--muted); transform: none; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 页头与工具栏：进页时自上而下淡入 */
.site-header { animation: fadeDown .45s ease both; }
.toolbar { animation: fadeIn .45s ease .06s both; }

/* 标签筛选条：逐枚弹出 */
.tags-bar .chip { animation: chipIn .24s ease both; }

/* 文件卡片：列表内容变化时逐条上浮入场 */
.file-card.is-in { animation: cardIn .26s ease both; }

/* 入场错峰，最多 8 级，再多就一起出现，避免长列表拖太久 */
.file-card.is-in:nth-child(2) { animation-delay: 40ms; }
.file-card.is-in:nth-child(3) { animation-delay: 80ms; }
.file-card.is-in:nth-child(4) { animation-delay: 120ms; }
.file-card.is-in:nth-child(5) { animation-delay: 160ms; }
.file-card.is-in:nth-child(6) { animation-delay: 200ms; }
.file-card.is-in:nth-child(7) { animation-delay: 240ms; }
.file-card.is-in:nth-child(n + 8) { animation-delay: 280ms; }

.tags-bar .chip:nth-child(2) { animation-delay: 30ms; }
.tags-bar .chip:nth-child(3) { animation-delay: 60ms; }
.tags-bar .chip:nth-child(4) { animation-delay: 90ms; }
.tags-bar .chip:nth-child(5) { animation-delay: 120ms; }
.tags-bar .chip:nth-child(6) { animation-delay: 150ms; }
.tags-bar .chip:nth-child(7) { animation-delay: 180ms; }
.tags-bar .chip:nth-child(n + 8) { animation-delay: 210ms; }

/* 空状态 */
.empty { animation: fadeIn .3s ease both; }

/* 弹窗遮罩淡入 */
.modal-mask { animation: maskIn .22s ease both; }

/* 提示条上滑出现 */
.toast { animation: toastIn .26s ease both; }

/* 结果计数变化时轻轻闪一下 */
.count-flash { animation: countFlash .5s ease both; }

/* 下载按钮等待探测时，文字前转一个小加载点 */
.btn { position: relative; }

.btn.is-loading::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 8px;
  vertical-align: -2px;
  border: 2px solid rgba(0, 0, 0, .18);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.btn-primary.is-loading::before {
  border-color: rgba(255, 255, 255, .45);
  border-top-color: #fff;
}

/* 系统开了「减少动态效果」就全部关掉，只留功能 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
