/* ==========================================================================
   VeiGame 小威游戏园 · 共享基础层
   只放四套主题共用的结构与机制；视觉皮肤见 themes.css
   主题通过 <html data-theme="glass|arcade|pixel|console"> 切换
   ========================================================================== */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro SC",
    "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei UI", "Segoe UI",
    system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { display: block; max-width: 100%; }
a { text-decoration: none; }
button { font: inherit; color: inherit; }

/* ------------------------------------------------------------- 装饰层容器 */
/* 街机：透视网格 + CRT 扫描线；玻璃：极光光晕。默认全部隐藏，由主题点亮 */
.aurora, .deco { display: none; }
.aurora[aria-hidden="true"], .deco[aria-hidden="true"] { pointer-events: none; }
.deco { position: fixed; inset: 0; z-index: 0; overflow: hidden; }

/* ------------------------------------------------------------------ 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 14px clamp(16px, 4vw, 40px) 0;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  max-width: 1240px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  flex: none;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 17px;
  color: #fff;
  background: linear-gradient(145deg, #4f9bff, #0a7cff 55%, #6f5bff);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 16px; letter-spacing: 0.2px; }
.brand-text small { font-size: 11.5px; letter-spacing: 0.4px; }

/* ------------------------------------------------------- 主题选择器（机械） */
.theme-picker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 12px;
  flex: none;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.theme-picker::-webkit-scrollbar { display: none; }

.theme-btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 7px 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 550;
  color: inherit;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  z-index: 1;
  transition: color 0.2s ease, transform 0.12s ease;
}
.theme-btn:active { transform: scale(0.96); }
.theme-btn:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }

/* 选中指示滑块：JS 负责 translateX 与宽度 */
.theme-thumb {
  position: absolute;
  top: 4px;
  left: 0;
  height: calc(100% - 8px);
  width: 0;
  border-radius: 9px;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.3, 0.9, 0.3, 1), width 0.28s cubic-bezier(0.3, 0.9, 0.3, 1);
}

/* ------------------------------------------------------------------ 视图 */
.view {
  position: relative;
  z-index: 1;
  padding: clamp(28px, 5vw, 56px) clamp(16px, 4vw, 40px) 48px;
  max-width: 1240px;
  margin: 0 auto;
}

.view-head { margin-bottom: 28px; }

.view-tagline {
  margin: 0;
  font-size: clamp(23px, 2.9vw, 31px);
  font-weight: 650;
  letter-spacing: 4px;
  line-height: 1.25;
}

.view-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------- 精选横幅（主机主题） */
.hero { display: none; }

/* ------------------------------------------------- 搜索与筛选（结构） */
.home-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 0 0 28px;
}

.home-search {
  position: relative;
  display: block;
  flex: 1 1 260px;
  max-width: 420px;
}

.home-search .doc-search-icon {
  position: absolute;
  top: 50%;
  left: 14px;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  pointer-events: none;
}

.home-search-input {
  width: 100%;
  padding: 10px 16px 10px 38px;
  border-radius: 999px;
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: box-shadow 0.22s ease, border-color 0.22s ease, background 0.22s ease;
}

.home-search-input::placeholder { opacity: 0.75; }

@media (max-width: 560px) {
  .home-search { flex-basis: 100%; max-width: none; }
}

/* ------------------------------------------------------------- 卡片墙（结构） */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: clamp(18px, 2.4vw, 28px);
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 22px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  animation: card-in 0.55s cubic-bezier(0.22, 0.85, 0.25, 1) both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

.card-cover {
  position: relative;
  isolation: isolate;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

/* 预览图：模糊后作占位底层（有截图的游戏才出现） */
.cover-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  filter: blur(7px) saturate(1.15) brightness(1.02);
  transform: scale(1.08);
  opacity: 0.75;
  pointer-events: none;
}

/* 封面上的首字母/首字水印与名称（各主题自行决定去留与样式） */
.cover-mark {
  pointer-events: none;
  user-select: none;
  line-height: 1;
}

.cover-name {
  position: relative;
  z-index: 1;
  word-break: break-word;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 22px 22px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.card-name {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.2px;
}

.card-ver {
  flex: none;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.card-summary {
  margin: 0;
  font-size: 13.8px;
  line-height: 1.72;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* 开始游戏 CTA：四套主题里三套可见，玻璃主题隐藏 */
.card-play { display: none; }

/* ------------------------------------------------------------------ 空态 */
.empty {
  padding: 64px 28px;
  text-align: center;
  border-radius: 22px;
  border: 1px dashed;
}
.empty strong { display: block; margin-bottom: 8px; font-size: 16px; }

/* ------------------------------------------------------------------ 涟漪 */
.ripple {
  position: fixed;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 120;
  background: radial-gradient(circle,
    rgba(255, 255, 255, 0) 58%,
    var(--ripple-soft, rgba(190, 220, 255, 0.45)) 67%,
    var(--ripple-strong, rgba(255, 255, 255, 0.9)) 70.5%,
    rgba(255, 255, 255, 0) 78%);
  will-change: transform, opacity;
  animation: ripple-out 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}

.ripple::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle,
    var(--ripple-soft, rgba(190, 220, 255, 0.4)) 34%,
    transparent 60%);
  animation: ripple-fade 0.9s ease forwards;
}

@keyframes ripple-out {
  0% { opacity: 0.92; transform: scale(0.3); }
  100% { opacity: 0; transform: scale(20); }
}

@keyframes ripple-fade {
  0% { opacity: 0; }
  14% { opacity: 0.9; }
  100% { opacity: 0; }
}

/* 主题切换时卡片墙重新入场 */
.theme-switching .card { animation-duration: 0.35s; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card { animation: none; }
  .ripple { display: none; }
  .theme-thumb { transition: none; }
  .theme-btn { transition: none; }
}

/* ------------------------------------------------------------- 窄屏基础 */
@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .brand-text small { display: none; }
  .theme-btn { padding: 7px 11px; font-size: 12.5px; }
  .card-body { padding: 18px 18px 20px; }
  /* 顶栏两行居中：brand 一行、主题选择器一行，避免 390 宽横向溢出 */
  .topbar { padding-top: 12px; }
  .topbar-inner { flex-wrap: wrap; justify-content: center; row-gap: 9px; }
  .brand { flex: 1 1 100%; justify-content: center; }
  .theme-picker { min-width: 0; }
}
