/* 八桂同根 · 云展厅 — 三维展厅样式 */

:root {
  --ink: #0b0d12;
  --paper: #e8e5e1;
  --warm: #d8c9a8;
  --dim: rgba(232, 229, 225, 0.56);
  --line: rgba(232, 229, 225, 0.16);
  --glass: rgba(12, 14, 19, 0.62);
  --mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, Consolas, monospace;
  --sans: "PingFang SC", "HarmonyOS Sans SC", "Source Han Sans SC", "Noto Sans SC",
    "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #05060a;
  color: var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#scene.dragging {
  cursor: grabbing;
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(120% 100% at 50% 50%, transparent 42%, rgba(4, 5, 8, 0.72) 100%),
    linear-gradient(to bottom, rgba(4, 5, 8, 0.5), transparent 22%, transparent 78%, rgba(4, 5, 8, 0.6));
}

/* ---------- HUD ---------- */
.hud-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(0.9rem, 2.4vw, 1.7rem) clamp(1rem, 3vw, 2.4rem);
  pointer-events: none;
}

.hud-top::before {
  content: "";
  position: absolute;
  inset: 0;
  top: -100%;
  height: 240%;
  background: linear-gradient(to bottom, rgba(4, 5, 8, 0.82), rgba(4, 5, 8, 0.3) 55%, transparent);
  pointer-events: none;
  z-index: -1;
}

.hud-top > * {
  pointer-events: auto;
}

.back {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  color: rgba(232, 229, 225, 0.7);
  text-decoration: none;
  padding: 0.35rem 0;
  transition: color 0.3s ease;
}

.back:hover {
  color: #fff;
}

.hud-title {
  font-size: 0.8rem;
  letter-spacing: 0.5em;
  font-weight: 500;
  color: rgba(232, 229, 225, 0.82);
}

.hud-title span {
  opacity: 0.4;
}

.chapter {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.24em;
  color: rgba(232, 229, 225, 0.62);
}

/* ---------- projected placards ---------- */
.labels {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  overflow: hidden;
}

.placard {
  position: absolute;
  transform: translate(-50%, -50%);
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.5s ease;
  will-change: transform, opacity;
}

.placard .k {
  display: block;
  font-family: var(--mono);
  font-size: 0.52rem;
  letter-spacing: 0.35em;
  color: rgba(236, 231, 222, 0.62);
  margin-bottom: 0.5rem;
}

.placard .t {
  display: block;
  font-size: clamp(0.9rem, 1.6vw, 1.22rem);
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  font-weight: 500;
  color: #f4f1ea;
  text-shadow: 0 0 24px rgba(0, 0, 0, 0.95), 0 1px 8px rgba(0, 0, 0, 0.9);
}

.placard .e {
  display: block;
  margin-top: 0.42rem;
  font-family: var(--mono);
  font-size: 0.5rem;
  letter-spacing: 0.18em;
  color: rgba(236, 231, 222, 0.46);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.9);
}

/* ---------- rail ---------- */
.rail {
  position: fixed;
  z-index: 6;
  left: 50%;
  bottom: clamp(1.1rem, 3vh, 2rem);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: clamp(0.5rem, 1.6vw, 1.2rem);
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.5);
  border: 1px solid rgba(232, 229, 225, 0.1);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
}

.rail button {
  appearance: none;
  border: 0;
  background: none;
  padding: 0.3rem 0.45rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: rgba(232, 229, 225, 0.42);
  font-family: var(--mono);
  font-size: 0.55rem;
  letter-spacing: 0.16em;
  transition: color 0.3s ease;
}

.rail button::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
  transition: opacity 0.3s ease, box-shadow 0.3s ease;
}

.rail button[aria-current="true"] {
  color: var(--warm);
}

.rail button[aria-current="true"]::before {
  opacity: 1;
  box-shadow: 0 0 10px rgba(216, 201, 168, 0.9);
}

.rail button:hover {
  color: rgba(240, 238, 233, 0.85);
}

.rail .rail-name {
  display: none;
}

@media (min-width: 900px) {
  .rail button[aria-current="true"] .rail-name {
    display: inline;
  }
}

.hint {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: calc(clamp(1.1rem, 3vh, 2rem) + 3.4rem);
  transform: translateX(-50%);
  margin: 0;
  font-family: var(--mono);
  font-size: 0.56rem;
  letter-spacing: 0.16em;
  color: rgba(232, 229, 225, 0.34);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.8s ease;
}

.hint.gone {
  opacity: 0;
}

/* ---------- crosshair + interaction prompt ---------- */
.crosshair {
  position: fixed;
  z-index: 5;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: rgba(240, 238, 233, 0.5);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 0 12px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.25s ease, background 0.25s ease;
}

.crosshair.on {
  opacity: 1;
}

.crosshair.hot {
  background: #e8cfa2;
  transform: scale(1.9);
}

.prompt {
  position: fixed;
  z-index: 6;
  left: 50%;
  top: 50%;
  transform: translate(-50%, 48px);
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  padding: 0.5rem 0.9rem;
  border: 1px solid rgba(232, 229, 225, 0.2);
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.18em;
  color: rgba(240, 238, 233, 0.82);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s linear 0.25s;
  pointer-events: none;
}

.prompt.on {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 42px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.prompt-key {
  display: grid;
  place-items: center;
  min-width: 1.35rem;
  height: 1.35rem;
  border-radius: 4px;
  border: 1px solid rgba(232, 229, 225, 0.3);
  color: #e8cfa2;
  font-size: 0.6rem;
}

/* ---------- touch movement pad ---------- */
.pad {
  position: fixed;
  z-index: 7;
  left: clamp(0.9rem, 3vw, 1.6rem);
  bottom: clamp(1rem, 3vh, 1.8rem);
  display: none;
  grid-template-columns: repeat(3, 2.5rem);
  grid-template-rows: repeat(3, 2.5rem);
  gap: 0.25rem;
  touch-action: none;
}

.pad-btn {
  appearance: none;
  border: 1px solid rgba(232, 229, 225, 0.18);
  border-radius: 10px;
  background: rgba(8, 10, 14, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: rgba(240, 238, 233, 0.72);
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.pad-btn:active,
.pad-btn.held {
  background: rgba(232, 207, 162, 0.24);
  color: #fff;
}

.pad-up {
  grid-column: 2;
  grid-row: 1;
}

.pad-left {
  grid-column: 1;
  grid-row: 2;
}

.pad-right {
  grid-column: 3;
  grid-row: 2;
}

.pad-down {
  grid-column: 2;
  grid-row: 3;
}

/* ---------- jump button (touch) ---------- */
.jump-btn {
  position: fixed;
  z-index: 7;
  right: clamp(0.9rem, 3vw, 1.6rem);
  bottom: calc(clamp(1rem, 3vh, 1.8rem) + 3.4rem);
  width: 4.1rem;
  height: 4.1rem;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  appearance: none;
  border: 1px solid rgba(232, 229, 225, 0.22);
  border-radius: 50%;
  background: rgba(8, 10, 14, 0.52);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: rgba(240, 238, 233, 0.86);
  font-family: var(--sans);
  font-size: 1.05rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s ease, transform 0.12s ease;
}

.jump-btn span {
  font-family: var(--mono);
  font-size: 0.4rem;
  letter-spacing: 0.22em;
  opacity: 0.5;
}

.jump-btn:active,
.jump-btn.held {
  background: rgba(232, 207, 162, 0.26);
  transform: scale(0.94);
}

/* ---------- exhibit panel ---------- */
.panel {
  position: fixed;
  z-index: 8;
  top: 0;
  right: 0;
  height: 100%;
  width: min(28rem, 100vw);
  padding: clamp(3.4rem, 6vh, 4.6rem) clamp(1.3rem, 2.6vw, 2rem) 2rem;
  background: linear-gradient(to left, rgba(6, 7, 11, 0.94) 60%, rgba(6, 7, 11, 0.72));
  border-left: 1px solid rgba(232, 229, 225, 0.12);
  backdrop-filter: blur(22px) saturate(115%);
  -webkit-backdrop-filter: blur(22px) saturate(115%);
  transform: translateX(100%);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.62s cubic-bezier(0.22, 0.8, 0.2, 1), opacity 0.4s ease, visibility 0s linear 0.62s;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel.open {
  transform: none;
  opacity: 1;
  visibility: visible;
  transition: transform 0.62s cubic-bezier(0.22, 0.8, 0.2, 1), opacity 0.4s ease;
}

.panel-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 1px solid rgba(232, 229, 225, 0.22);
  background: none;
  color: rgba(232, 229, 225, 0.8);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.3s ease, color 0.3s ease;
}

.panel-close:hover {
  background: rgba(232, 229, 225, 0.12);
  color: #fff;
}

.panel-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 0.4rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(232, 229, 225, 0.25) transparent;
}

.panel-scroll::-webkit-scrollbar {
  width: 4px;
}

.panel-scroll::-webkit-scrollbar-thumb {
  background: rgba(232, 229, 225, 0.24);
  border-radius: 2px;
}

.panel-no {
  margin: 0 0 0.8rem;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.4em;
  color: var(--warm);
  opacity: 0.85;
}

.panel h2 {
  margin: 0;
  font-size: clamp(1.55rem, 3.2vw, 2.05rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.panel-sub {
  margin: 0.7rem 0 0;
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--dim);
  letter-spacing: 0.03em;
}

.panel-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6rem, 1fr));
  gap: 0.9rem 1rem;
  margin: 1.5rem 0 1.7rem;
  padding: 1rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.panel-stats div {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.panel-stats dt {
  font-family: var(--mono);
  font-size: 0.52rem;
  letter-spacing: 0.2em;
  color: rgba(232, 229, 225, 0.4);
}

.panel-stats dd {
  margin: 0;
  font-size: 0.88rem;
  letter-spacing: 0.02em;
}

.panel-body p {
  margin: 0 0 1.05rem;
  font-size: 0.86rem;
  line-height: 1.95;
  color: rgba(232, 229, 225, 0.8);
  text-align: justify;
  letter-spacing: 0.01em;
}

.panel-body p:first-child {
  color: rgba(240, 238, 233, 0.94);
}

.panel-video {
  margin: 1.6rem 0 0;
  border: 1px solid var(--line);
  background: #000;
}

.panel-video video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  background: #000;
}

.panel-video figcaption {
  padding: 0.6rem 0.8rem;
  font-family: var(--mono);
  font-size: 0.54rem;
  letter-spacing: 0.16em;
  color: rgba(232, 229, 225, 0.42);
  border-top: 1px solid var(--line);
}

.panel-note {
  margin: 1.6rem 0 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.56rem;
  line-height: 1.9;
  letter-spacing: 0.12em;
  color: rgba(232, 229, 225, 0.36);
}

/* ---------- loading ---------- */
.boot {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: #05060a;
  transition: opacity 0.9s ease, visibility 0s linear 0.9s;
}

.boot.done {
  opacity: 0;
  visibility: hidden;
}

.boot-inner {
  width: min(20rem, 70vw);
  text-align: center;
}

.boot-mark {
  margin: 0 0 1.4rem;
  font-size: 1rem;
  letter-spacing: 0.55em;
  text-indent: 0.55em;
  color: rgba(232, 229, 225, 0.9);
}

.boot-mark span {
  display: block;
  margin-top: 0.5rem;
  font-family: var(--mono);
  font-size: 0.48rem;
  letter-spacing: 0.3em;
  color: rgba(232, 229, 225, 0.34);
}

.boot-bar {
  height: 1px;
  background: rgba(232, 229, 225, 0.14);
  overflow: hidden;
}

.boot-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--warm);
  transition: width 0.35s ease;
}

.boot-txt {
  margin: 0.9rem 0 0;
  font-family: var(--mono);
  font-size: 0.55rem;
  letter-spacing: 0.24em;
  color: rgba(232, 229, 225, 0.4);
}

/* ---------- fallback ---------- */
.fallback {
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow-y: auto;
  background: #08090d;
  padding: clamp(1.5rem, 6vw, 5rem) clamp(1.2rem, 6vw, 4rem);
}

.fallback-inner {
  max-width: 44rem;
  margin: 0 auto;
}

.fallback h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  margin: 0 0 0.8rem;
}

.fallback p {
  font-size: 0.86rem;
  line-height: 1.8;
  color: var(--dim);
}

.fallback article {
  padding: 1.6rem 0;
  border-top: 1px solid var(--line);
}

.fallback article img {
  width: 100%;
  max-width: 26rem;
  display: block;
  margin: 0 0 1rem;
}

.fallback article h2 {
  margin: 0 0 0.6rem;
  font-size: 1.2rem;
}

.fallback-foot a {
  color: rgba(232, 229, 225, 0.7);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-decoration: none;
}

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  .hud-title {
    display: none;
  }

  .pad {
    display: grid;
  }

  .jump-btn {
    display: flex;
  }

  .hint {
    font-size: 0.5rem;
    letter-spacing: 0.1em;
    bottom: calc(clamp(1rem, 3vh, 1.8rem) + 8.8rem);
    white-space: normal;
    max-width: 13rem;
    text-align: center;
    line-height: 1.7;
  }

  .rail {
    gap: 0.35rem;
    padding: 0.45rem 0.6rem;
  }

  .rail button {
    padding: 0.3rem 0.3rem;
    font-size: 0.5rem;
  }

  .panel {
    top: auto;
    bottom: 0;
    height: min(64vh, 100%);
    width: 100%;
    border-left: 0;
    border-top: 1px solid rgba(232, 229, 225, 0.14);
    transform: translateY(100%);
    padding: 2.6rem 1.15rem 1.2rem;
    border-radius: 18px 18px 0 0;
  }

  .panel.open {
    transform: none;
  }

  .placard .t {
    letter-spacing: 0.2em;
  }
}

@media (prefers-reduced-motion: reduce) {
  .panel,
  .boot {
    transition-duration: 0.01ms !important;
  }
}
