/* ============================================================
   home.css · 首页 3D 虚拟空间（仅 Index 页引用）
   舞台为「纸框中的暗色空间」：与站点纸/墨双主题和谐共存。
   ============================================================ */

/* ============================================================
   全屏虚拟空间：首页 hero 占满整个视口，header 融入 3D 空间
   仅作用于含 .hero3d 的页面（首页），不影响其他页面
   ============================================================ */

/* 首页主区域解除 1080 约束，让 3D 满宽铺满；下方内容重新居中 */
body:has(.hero3d) .site-main {
  max-width: none;
  padding-left: 0;
  padding-right: 0;
  padding-top: 0;
}
body:has(.hero3d) .site-main .hero3d { margin: 0; }
body:has(.hero3d) .site-main > *:not(.hero3d):not(.h3d-sr) {
  max-width: 1080px;
  margin-left: auto;
  margin-right: auto;
  padding-left: calc(var(--gap) * 3);
  padding-right: calc(var(--gap) * 3);
}
/* 首页仅保留 3D 虚拟空间，隐藏全局页脚以呈现纯净单屏体验 */
body:has(.hero3d) .site-footer { display: none; }

/* ---------- 3D 舞台（全屏无框） ---------- */
.hero3d {
  position: relative;
  height: 100svh;
  min-height: 480px;
  margin: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: #0b0f16; /* 与场景背景一致，加载时不闪白 */
  /* 顶部为透明 header 让出空间，box-sizing 保证总高不溢出视口 */
  padding-top: 64px;
  box-sizing: border-box;
}

.hero3d-stage {
  position: absolute;
  inset: 0;
  cursor: grab;
  touch-action: pan-y; /* 竖向滑动留给页面滚动，横向拖拽旋转场景 */
}
.hero3d-stage:active { cursor: grabbing; }
.hero3d-stage.is-hover { cursor: pointer; }

.hero3d-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.9s ease;
}
.hero3d-stage.is-on canvas { opacity: 1; }

/* 加载指示（JS 成功后隐藏；无 JS 时直接走降级视图） */
.hero3d-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(242, 237, 226, 0.55);
  font-size: 14px;
  letter-spacing: 0.2em;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
.hero3d-stage.is-on .hero3d-loading,
.hero3d-stage.is-failed .hero3d-loading { opacity: 0; }
html:not(.js) .hero3d-loading { display: none; }


/* ---------- 操作提示 ---------- */
.hero3d-hint {
  position: absolute;
  right: calc(var(--gap) * 3);
  bottom: calc(var(--gap) * 3);
  z-index: 3;
  margin: 0;
  padding: 6px 14px;
  border: 1px solid rgba(242, 237, 226, 0.22);
  border-radius: 999px;
  background: rgba(11, 15, 22, 0.55);
  color: rgba(242, 237, 226, 0.82);
  font-size: 13px;
  letter-spacing: 0.05em;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.hero3d-stage:not(.is-on) ~ .hero3d-hint { opacity: 0; }


/* ---------- 传送门跳转过渡 ---------- */
.h3d-warp {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: radial-gradient(circle at 50% 50%,
    var(--warp-color, #22d3ee) 0%, #0b0f16 78%);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.h3d-warp.on { opacity: 1; }

/* ---------- 悬停介绍 tooltip（固定定位，贴近指针） ---------- */
.hero3d-tip {
  position: fixed;
  z-index: 40;
  max-width: min(320px, 78vw);
  padding: 12px 14px;
  border: 1px solid rgba(45, 212, 191, 0.35);
  border-radius: 14px;
  background: rgba(11, 16, 26, 0.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  color: #f2ede2;
  font-size: 14px;
  line-height: 1.6;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .18s ease, transform .18s ease;
}
.hero3d-tip.show { opacity: 1; transform: none; }
.hero3d-tip-t {
  margin: 0 0 6px 0;
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  color: #5eead4;
}
.hero3d-tip-d { margin: 0; color: rgba(226, 222, 210, 0.85); }
@media (prefers-reduced-motion: reduce) {
  .hero3d-tip { transition: none; }
}

/* ---------- 降级视图（无 JS / WebGL 失败） ---------- */
.hero3d-fallback {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--gap) * 3);
  padding: calc(var(--gap) * 5) calc(var(--gap) * 3);
  background: var(--paper);
  text-align: center;
  overflow-y: auto;
}
/* 无 JS（html 无 .js 标记）或 WebGL 初始化失败时展示 */
html:not(.js) .hero3d-fallback,
.hero3d-stage.is-failed ~ .hero3d-fallback { display: flex; }
.hero3d-fallback .hero-fb { max-width: var(--measure); }
.hero3d-fallback .hero-fb h1 {
  font-family: var(--font-serif);
  font-size: clamp(28px, 5vw, 44px);
  color: var(--ink);
  margin: 0 0 var(--gap);
}
.hero3d-fallback .hero-fb-note { color: var(--ink-muted); margin: 0 0 calc(var(--gap) * 2); }
.hero3d-fallback .facets { margin-top: calc(var(--gap) * 2); }
.hero3d-fallback .facets a { font-size: 22px; }

/* 无障碍入口（视觉隐藏） */
.h3d-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}


/* ---------- 移动端 ---------- */
@media (max-width: 640px) {
  .hero3d {
    height: 100svh;
    min-height: 420px;
    padding-top: 96px; /* header 在小屏可能折行，预留更多安全距离 */
  }
  .hero3d-hint { right: var(--gap); bottom: var(--gap); font-size: 12px; padding: 4px 10px; }
}

/* ---------- header 融入 3D 空间（仅首页） ---------- */
/* 默认透明玻璃浮层，悬浮在 3D 之上，像空间的一部分；
   滚动进入纸面内容后补一层暗色玻璃底，保证可读。 */
body:has(.hero3d) .site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: transparent;
  border-bottom: 1px solid transparent;
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  transition: background .35s ease, backdrop-filter .35s ease, border-color .35s ease;
  z-index: 20;
}
body:has(.hero3d) .site-header.scrolled {
  background: rgba(11, 15, 22, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom-color: rgba(242, 237, 226, 0.12);
}

/* 透明 header 上的导航文字采用亮色，落在暗色 3D 上 */
body:has(.hero3d) .brand,
body:has(.hero3d) .nav-links a,
body:has(.hero3d) .view-switcher a,
body:has(.hero3d) .theme-toggle {
  color: rgba(242, 237, 226, 0.92);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
}
body:has(.hero3d) .nav-links a:hover,
body:has(.hero3d) .nav-links a.active { color: #ffffff; text-decoration: none; }
body:has(.hero3d) .nav-links a.active { color: #5eead4; }
body:has(.hero3d) .theme-toggle { border-color: rgba(242, 237, 226, 0.3); }
body:has(.hero3d) .view-switcher a.active { color: #f5efe4; border-bottom-color: #5eead4; }

@media (prefers-reduced-motion: reduce) {
  body:has(.hero3d) .site-header { transition: none; }
}

/* 首页去 Header 后的浮动主题切换按钮（替代原 header 内的 #theme-toggle） */
.theme-float-toggle {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(242, 237, 226, 0.3);
  background: rgba(10, 16, 26, 0.5);
  color: rgba(242, 237, 226, 0.92);
  font: 600 15px/1 "Noto Serif SC", "Songti SC", serif;
  cursor: pointer;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s ease, background 0.2s ease;
}
.theme-float-toggle:hover { transform: scale(1.06); background: rgba(10, 16, 26, 0.7); }

/* ===== 游戏档案卡（点击 3D 首页第一层 idCard 弹出）===== */
.hero3d-archive {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 48px);
  opacity: 0;
  transition: opacity 0.28s ease;
}
.hero3d-archive[data-open="true"] {
  display: flex;
  opacity: 1;
}

.hero3d-archive-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 40%, rgba(45, 212, 191, 0.10), rgba(10, 16, 26, 0.72) 55%, rgba(0, 0, 0, 0.85) 100%);
  backdrop-filter: blur(18px) saturate(1.05);
  -webkit-backdrop-filter: blur(18px) saturate(1.05);
  cursor: zoom-out;
}

.hero3d-archive-card {
  position: relative;
  width: min(94vw, 1040px);
  max-height: 86vh;
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(280px, 1.15fr);
  gap: clamp(20px, 3vw, 36px);
  padding: clamp(20px, 3vw, 36px);
  border-radius: 20px;
  background:
    linear-gradient(160deg, rgba(45, 212, 191, 0.08), rgba(94, 234, 212, 0.02) 38%, rgba(10, 16, 26, 0.92) 100%),
    rgba(10, 16, 26, 0.86);
  border: 1px solid rgba(45, 212, 191, 0.32);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(45, 212, 191, 0.10) inset,
    0 0 80px rgba(45, 212, 191, 0.18);
  color: #F2EDE2;
  font-family: var(--font-ui, "Segoe UI", system-ui, sans-serif);
  overflow: hidden;
  transform: translateY(18px) scale(0.96);
  transition: transform 0.32s cubic-bezier(.2,.8,.2,1);
}
.hero3d-archive[data-open="true"] .hero3d-archive-card {
  transform: translateY(0) scale(1);
}
.hero3d-archive-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 12%, rgba(94, 234, 212, 0.18), transparent 45%),
    radial-gradient(circle at 90% 88%, rgba(45, 212, 191, 0.14), transparent 50%);
  mix-blend-mode: screen;
}

/* 关闭按钮 */
.hero3d-archive-close {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(242, 237, 226, 0.22);
  background: rgba(10, 16, 26, 0.55);
  color: #F2EDE2;
  font: 600 18px/1 var(--font-ui, system-ui, sans-serif);
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}
.hero3d-archive-close:hover {
  background: rgba(45, 212, 191, 0.22);
  border-color: rgba(45, 212, 191, 0.55);
  transform: rotate(90deg);
}

/* 左侧 portrait（TCG 卡面） */
.hero3d-archive-frame {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: clamp(20px, 3vw, 36px);
  z-index: 1;
}
.hero3d-archive-portrait {
  position: relative;
  aspect-ratio: 3 / 4;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(45, 212, 191, 0.18), rgba(10, 16, 26, 0.92)),
    #0A101A;
  border: 1px solid rgba(240, 198, 116, 0.45);
  box-shadow:
    0 0 0 2px rgba(10, 16, 26, 0.85) inset,
    0 12px 28px rgba(0, 0, 0, 0.45),
    0 0 24px rgba(240, 198, 116, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero3d-archive-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.2s ease;
}
.hero3d-archive-img[src=""],
.hero3d-archive-img:not([src]) {
  display: none;
}
.hero3d-archive-portrait-fallback {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font: 700 clamp(56px, 9vw, 96px)/1 var(--font-ui, system-ui, sans-serif);
  color: rgba(242, 237, 226, 0.92);
  background:
    radial-gradient(circle at 30% 25%, rgba(45, 212, 191, 0.35), transparent 55%),
    radial-gradient(circle at 80% 75%, rgba(240, 198, 116, 0.28), transparent 60%),
    linear-gradient(160deg, #0F2231, #0A101A 70%);
  letter-spacing: 0.02em;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.45);
}
.hero3d-archive[data-fallback="true"] .hero3d-archive-img { opacity: 0; }
.hero3d-archive[data-fallback="true"] .hero3d-archive-portrait-fallback { display: flex; }

.hero3d-archive-rarity {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 10px;
  text-align: center;
  font: 700 12px/1 var(--font-ui, system-ui, sans-serif);
  letter-spacing: 0.4em;
  color: #F0C674;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  animation: hero3d-archive-rarity-pulse 2.6s ease-in-out infinite;
}
@keyframes hero3d-archive-rarity-pulse {
  0%, 100% { opacity: 0.7; }
  50%      { opacity: 1; }
}

/* 右侧 meta */
.hero3d-archive-meta {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding-top: 4px;
  z-index: 1;
}
.hero3d-archive-eyebrow {
  font: 600 11px/1.4 var(--font-ui, system-ui, sans-serif);
  letter-spacing: 0.32em;
  color: #5EEAD4;
  text-transform: uppercase;
}
.hero3d-archive-title {
  margin: 0;
  font: 700 clamp(22px, 2.4vw, 30px)/1.2 var(--font-ui, system-ui, sans-serif);
  color: #F2EDE2;
  word-break: break-word;
}
.hero3d-archive-desc {
  margin: 0;
  font: 400 14px/1.65 var(--font-ui, system-ui, sans-serif);
  color: rgba(242, 237, 226, 0.78);
  max-height: 9.2em;
  overflow: auto;
}

/* Stat 进度条 */
.hero3d-archive-stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}
.hero3d-archive-stat {
  display: grid;
  grid-template-columns: 56px 1fr 36px;
  align-items: center;
  gap: 10px;
}
.hero3d-archive-stat-label {
  font: 600 11px/1 var(--font-ui, system-ui, sans-serif);
  letter-spacing: 0.18em;
  color: rgba(242, 237, 226, 0.7);
}
.hero3d-archive-stat-bar {
  position: relative;
  display: block;
  height: 8px;
  border-radius: 999px;
  background: rgba(242, 237, 226, 0.08);
  border: 1px solid rgba(45, 212, 191, 0.18);
  overflow: hidden;
}
.hero3d-archive-stat-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--bar, #2DD4BF), rgba(94, 234, 212, 0.85));
  box-shadow: 0 0 8px rgba(45, 212, 191, 0.45);
  transition: width 0.6s cubic-bezier(.2,.8,.2,1);
}
.hero3d-archive-stat-val {
  text-align: right;
  font: 700 12px/1 var(--font-mono, ui-monospace, "JetBrains Mono", Consolas, monospace);
  color: #5EEAD4;
}

/* Tag chip */
.hero3d-archive-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.hero3d-archive-tag {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(45, 212, 191, 0.38);
  background: rgba(45, 212, 191, 0.08);
  color: #5EEAD4;
  font: 500 12px/1 var(--font-ui, system-ui, sans-serif);
}

/* 窄屏堆叠 */
@media (max-width: 760px) {
  .hero3d-archive-card {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    max-height: 90vh;
    overflow: auto;
  }
  .hero3d-archive-frame { flex-direction: column; }
  .hero3d-archive-portrait { max-width: 260px; margin: 0 auto; }
  .hero3d-archive-meta { padding-top: 0; }
}

/* 减弱动效 */
@media (prefers-reduced-motion: reduce) {
  .hero3d-archive,
  .hero3d-archive-card,
  .hero3d-archive-rarity,
  .hero3d-archive-stat-bar i {
    transition: none;
    animation: none;
  }
}
