/* ==========================================================================
   3D 小屋 · 样式
   基色取自示意图的暖木与夕照；文字与弹窗沿用主页的墨红+暖纸质感
   ========================================================================== */

@font-face {
  font-family: 'LXGW WenKai';
  src: url('../../assets/fonts/LXGWWenKai-Medium.subset.woff2?v=20260905a') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --font-display: 'LXGW WenKai', 'Kaiti SC', 'STKaiti', 'KaiTi', serif;
  --font-body: -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --ink: #3b2415;
  --ink-dim: rgba(59, 36, 21, 0.66);
  --paper: #fdf3e0;
  --paper-2: #f6e5c8;
  --accent: #8c1f26;
  --accent-2: #c8842f;
  --glow: rgba(255, 198, 116, 0.5);
  --shadow: 0 22px 50px rgba(38, 18, 4, 0.45);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* 类选择器里的 display 会盖过 hidden 属性，这里兜底 */
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: #1b120c;
  color: var(--paper);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
body.lb-open { overflow: hidden; }
img { display: block; max-width: 100%; }
a { color: inherit; }

/* ---------- 画布与氛围层 ---------- */
#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: default;
}
.grade {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(136% 116% at 50% 48%, transparent 38%, rgba(38, 14, 2, 0.7) 100%),
    radial-gradient(118% 88% at 50% 54%, rgba(255, 186, 108, 0.07), transparent 62%);
}
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px clamp(14px, 3vw, 30px);
  pointer-events: none;
  background: linear-gradient(180deg, rgba(30, 14, 4, 0.55), rgba(30, 14, 4, 0));
}
.topbar > * { pointer-events: auto; }
.home-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 226, 180, 0.34);
  background: rgba(48, 24, 8, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #ffeccd;
  font-size: 13px;
  text-decoration: none;
  transition: background .2s ease, transform .2s ease, border-color .2s ease;
}
.home-link:hover { background: rgba(120, 62, 20, 0.6); border-color: rgba(255, 226, 180, 0.6); transform: translateX(-2px); }
.topbar-title {
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: .08em;
  color: rgba(255, 235, 202, 0.82);
  text-shadow: 0 2px 10px rgba(30, 12, 0, 0.6);
}

/* ---------- 悬浮标签 ---------- */
.chip {
  position: fixed;
  top: 0; left: 0;
  z-index: 24;
  padding: 7px 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff8e8, #f3e0bd);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
  box-shadow: 0 10px 26px rgba(30, 12, 0, 0.45), 0 0 0 1px rgba(140, 88, 30, 0.25) inset;
  pointer-events: none;
  animation: chipIn .18s ease-out;
}
.chip::before {
  content: '';
  position: absolute;
  left: 50%; top: -5px;
  width: 10px; height: 10px;
  margin-left: -5px;
  background: #fff8e8;
  transform: rotate(45deg);
  border-radius: 2px;
}
/* 标签浮在物件上方时，箭头翻到底边 */
.chip--up::before { top: auto; bottom: -5px; }
@keyframes chipIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 弹窗（暖纸卡） ---------- */
.popup {
  position: fixed;
  top: 0; left: 0;
  z-index: 26;
  width: min(392px, calc(100vw - 32px));
  padding: 16px 16px 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--paper), var(--paper-2));
  color: var(--ink);
  box-shadow: var(--shadow), 0 0 0 1px rgba(150, 96, 34, 0.28) inset, 0 0 40px rgba(255, 176, 92, 0.18);
  animation: popIn .22s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes popIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; } }
.pp-arrow {
  position: absolute;
  width: 13px; height: 13px;
  background: var(--paper);
  transform: rotate(45deg);
  border-radius: 3px;
  box-shadow: -1px 1px 2px rgba(60, 30, 4, 0.12);
}
.pp-close {
  position: absolute;
  top: 8px; right: 10px;
  width: 28px; height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(140, 31, 38, 0.08);
  color: var(--accent);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  transition: background .18s ease, transform .18s ease;
}
.pp-close:hover { background: rgba(140, 31, 38, 0.18); transform: rotate(90deg); }

.pp-head h2 {
  margin: 0 26px 4px 0;
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: .04em;
  color: var(--accent);
}
.pp-head p { margin: 0 0 12px; font-size: 13px; line-height: 1.7; color: var(--ink-dim); }

.pp-list { display: flex; flex-direction: column; gap: 6px; max-height: min(52vh, 430px); overflow: auto; padding-right: 2px; }
.pp-app {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(160, 104, 40, 0.16);
  transition: background .18s ease, transform .18s ease, box-shadow .18s ease;
}
.pp-app:hover { background: #fff9ec; transform: translateX(2px); box-shadow: 0 6px 16px rgba(120, 70, 16, 0.16); }
.pp-thumb {
  width: 44px; height: 58px;
  object-fit: cover;
  object-position: top center;
  border-radius: 7px;
  border: 1px solid rgba(140, 90, 30, 0.25);
  background: #f0e4cc;
}
.pp-app-main { min-width: 0; }
.pp-app-title { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 700; }
.pp-app-title em {
  font-style: normal;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(140, 31, 38, 0.1);
  color: var(--accent);
}
.pp-app-desc {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-dim);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.pp-go { font-size: 12px; font-weight: 700; color: var(--accent-2); white-space: nowrap; }

.pp-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.pp-shot {
  padding: 0;
  border: 1px solid rgba(140, 90, 30, 0.22);
  border-radius: 9px;
  overflow: hidden;
  background: #efe2c8;
  cursor: pointer;
  aspect-ratio: 3 / 4;
  transition: transform .18s ease, box-shadow .18s ease;
}
.pp-shot img { width: 100%; height: 100%; object-fit: cover; }
.pp-shot:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(120, 70, 16, 0.24); }

.pp-cta {
  width: 100%;
  padding: 11px 16px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #a02528, #7d1a20);
  color: #ffeccd;
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: .06em;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(120, 24, 28, 0.32);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.pp-cta:hover { transform: translateY(-1px); filter: brightness(1.08); box-shadow: 0 14px 26px rgba(120, 24, 28, 0.4); }

/* 「返回全景视图」：卡片里的一条轻量出口，和底部那枚胶囊是同一动作 */
.pp-back {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 7px 10px;
  border: 1px dashed rgba(160, 104, 40, 0.34);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.34);
  color: var(--ink-dim);
  font-size: 12px;
  letter-spacing: .04em;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.pp-back:hover { background: #fff9ec; color: var(--accent); border-color: rgba(160, 104, 40, 0.6); }

/* ---------- 底部提示 ---------- */
.hintbar {
  position: fixed;
  left: 50%;
  bottom: clamp(10px, 2.4vh, 22px);
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(40, 20, 6, 0.42);
  border: 1px solid rgba(255, 226, 180, 0.2);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  font-size: 12px;
  color: rgba(255, 236, 205, 0.9);
  pointer-events: none;
  max-width: calc(100vw - 24px);
  overflow: hidden;
  transition: opacity .5s ease;
}
.hint-item { white-space: nowrap; }
.hint-item b { color: #ffd79a; font-weight: 700; margin-right: 3px; }
.hint-item + .hint-item { padding-left: 8px; border-left: 1px solid rgba(255, 226, 180, 0.18); }
.hint-tip { display: none; }
@media (min-width: 900px) {
  .hint-tip { display: inline; padding-left: 10px; border-left: 1px solid rgba(255, 226, 180, 0.18); color: rgba(255, 236, 205, 0.6); }
}
/* 推近之后提示条让位给「返回全景」 */
body.is-focused .hintbar { opacity: 0; }

/* ---------- 返回全景（推近后才出现） ---------- */
.backbar {
  position: fixed;
  left: 50%;
  bottom: clamp(10px, 2.4vh, 22px);
  transform: translateX(-50%);
  z-index: 21;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 226, 180, 0.34);
  background: rgba(48, 24, 8, 0.62);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  color: #ffeccd;
  font-family: var(--font-display);
  font-size: 13.5px;
  letter-spacing: .06em;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(20, 8, 0, 0.4);
  animation: backIn .32s ease both;
  transition: background .2s ease, transform .2s ease, box-shadow .2s ease;
}
.backbar:hover { background: rgba(70, 34, 10, 0.78); transform: translateX(-50%) translateY(-2px); box-shadow: 0 14px 30px rgba(20, 8, 0, 0.5); }
.backbar-arrow { color: #ffd79a; font-size: 15px; transition: transform .2s ease; }
.backbar:hover .backbar-arrow { transform: translateX(-3px); }
.backbar kbd {
  font-family: inherit;
  font-size: 10.5px;
  letter-spacing: .04em;
  padding: 1px 7px;
  border-radius: 999px;
  color: rgba(255, 236, 205, 0.72);
  border: 1px solid rgba(255, 226, 180, 0.28);
}
@keyframes backIn { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .backbar { animation: none; } }

/* ---------- 画廊 lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 2vw, 24px);
  background: rgba(24, 10, 2, 0.9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn .22s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.lightbox figure { margin: 0; max-width: min(1100px, 84vw); text-align: center; }
.lightbox img {
  max-height: 78vh;
  max-width: 100%;
  margin: 0 auto;
  border-radius: 8px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55);
  background: #2a1a10;
}
.lightbox figcaption {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 13px;
  color: rgba(255, 236, 205, 0.86);
}
.lb-idx { font-size: 11.5px; color: rgba(255, 236, 205, 0.5); letter-spacing: .08em; }
.lb-close, .lb-prev, .lb-next {
  border: 0;
  background: rgba(255, 236, 205, 0.1);
  color: #ffeccd;
  cursor: pointer;
  border-radius: 50%;
  transition: background .18s ease, transform .18s ease;
}
.lb-close { position: absolute; top: 18px; right: 20px; width: 44px; height: 44px; font-size: 24px; }
.lb-prev, .lb-next { width: 48px; height: 48px; font-size: 26px; flex: 0 0 auto; }
.lb-close:hover, .lb-prev:hover, .lb-next:hover { background: rgba(255, 236, 205, 0.24); transform: scale(1.06); }

/* ---------- 载入遮罩 / 兜底 ---------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 100% at 50% 60%, #3a2313, #150c07 70%);
  transition: opacity .8s ease, visibility .8s ease;
}
.loader.done { opacity: 0; visibility: hidden; }
.loader-inner { text-align: center; }
.loader-mark {
  display: grid;
  place-items: center;
  width: 74px; height: 74px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: linear-gradient(180deg, #b9503c, #7d1a20);
  color: #ffeccd;
  font-family: var(--font-display);
  font-size: 36px;
  box-shadow: 0 0 60px rgba(255, 168, 88, 0.35);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.05); box-shadow: 0 0 90px rgba(255, 186, 108, 0.5); } }
.loader-text {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: .22em;
  color: rgba(255, 232, 196, 0.8);
}

.fallback { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: #1b120c; padding: 24px; }
.fb-card {
  max-width: 460px;
  padding: 28px 26px;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--paper), var(--paper-2));
  color: var(--ink);
  text-align: center;
  box-shadow: var(--shadow);
}
.fb-card h1 { margin: 0 0 10px; font-family: var(--font-display); font-size: 22px; color: var(--accent); }
.fb-card p { margin: 6px 0; font-size: 13.5px; line-height: 1.7; color: var(--ink-dim); }
.fb-detail { font-family: ui-monospace, Consolas, monospace; font-size: 12px; opacity: .7; }
.fb-link { color: var(--accent); text-decoration: none; font-weight: 700; }

/* ---------- 响应式：窄屏底部抽屉 ---------- */
@media (max-width: 760px) {
  .popup {
    left: 10px !important;
    right: 10px;
    bottom: 12px !important;
    top: auto !important;
    width: auto;
    transform: none !important;
    max-height: 62vh;
    overflow: auto;
  }
  .pp-arrow { display: none; }
  .pp-list { max-height: none; }
  .hintbar { font-size: 11px; gap: 6px; padding: 7px 10px; }
  .lightbox figure { max-width: 92vw; }
  .lb-prev, .lb-next { position: absolute; bottom: 18px; }
  .lb-prev { left: 22px; }
  .lb-next { right: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .loader-mark { animation: none; }
  .popup, .chip, .lightbox { animation: none; }
}
