/**
 * @Date 2026-07-27
 * @Author Codex
 * @Discription 生命树场馆实时 3D 展示界面
 */

:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  --cyan: #76e9ff;
  --particle-theme: #8fffcf;
  --ink: #071523;
  --glass: rgba(5, 28, 39, 0.34);
  --line: rgba(219, 248, 255, 0.42);
  --safe-top: max(18px, env(safe-area-inset-top));
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
}

html {
  background: #071624;
  scrollbar-width: none;
}

html::-webkit-scrollbar {
  display: none;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  overflow-x: hidden;
  background: #071624;
  color: #eefcff;
}

button,
canvas {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

#app,
.scroll-story {
  position: relative;
}

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
  background: #7fc9ee;
}

.sky-fallback {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 6%, rgba(255,255,255,.92) 0 2%, transparent 20%),
    linear-gradient(155deg, #eaf8ff 0%, #8ed1f3 32%, #248fce 75%, #dff5ff 100%);
}

.webgl-mount,
.webgl-mount canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.webgl-mount canvas {
  display: block;
  outline: none;
  touch-action: none;
}

.cursor-particles {
  position: fixed;
  z-index: 16;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.grain,
.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.grain {
  z-index: 10;
  opacity: .055;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.92' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.vignette {
  z-index: 9;
  background: radial-gradient(ellipse at center, transparent 48%, rgba(1, 18, 27, .28) 100%);
  transition: background 1.4s ease;
}

.loading-screen {
  position: absolute;
  z-index: 50;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  background:
    radial-gradient(circle at 50% 48%, rgba(59, 215, 230, .24), transparent 32%),
    linear-gradient(150deg, #071a26, #0a2b37 55%, #06141e);
}

.loading-screen p {
  margin: 0;
  color: rgba(229, 252, 255, .78);
  font-size: 11px;
  letter-spacing: .42em;
  text-transform: uppercase;
}

.loading-orbit {
  position: relative;
  width: 92px;
  height: 92px;
}

.loading-orbit span {
  position: absolute;
  inset: 50%;
  width: 8px;
  height: 8px;
  margin: -4px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 18px var(--cyan);
  animation: loading-orbit 1.8s linear infinite;
}

.loading-orbit span:nth-child(2) { animation-delay: -.6s; }
.loading-orbit span:nth-child(3) { animation-delay: -1.2s; }

.loading-line {
  width: 148px;
  height: 1px;
  background: rgba(255,255,255,.15);
  overflow: hidden;
}

.loading-line i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--cyan), #fff);
  box-shadow: 0 0 12px var(--cyan);
  transition: width .25s ease;
}

@keyframes loading-orbit {
  from { transform: rotate(0deg) translateX(38px) scale(.65); opacity: .35; }
  50% { opacity: 1; transform: rotate(180deg) translateX(38px) scale(1); }
  to { transform: rotate(360deg) translateX(38px) scale(.65); opacity: .35; }
}

.hud {
  position: absolute;
  z-index: 20;
  pointer-events: none;
}

.hud-top {
  top: var(--safe-top);
  left: clamp(18px, 3vw, 46px);
  right: clamp(18px, 3vw, 46px);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-mark {
  position: relative;
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 0 12px rgba(118,233,255,.45));
}

.brand-mark span {
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 1px;
  height: 24px;
  background: rgba(240,254,255,.9);
  transform-origin: bottom;
}

.brand-mark span:nth-child(1) { transform: rotate(-38deg); }
.brand-mark span:nth-child(2) { transform: rotate(0); height: 29px; }
.brand-mark span:nth-child(3) { transform: rotate(38deg); }

.hud-state,
.quality-pill {
  display: flex;
  align-items: center;
  height: 29px;
  border: 1px solid rgba(234, 252, 255, .28);
  background: rgba(5, 25, 34, .18);
  box-shadow: inset 0 0 18px rgba(255,255,255,.04);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.hud-state {
  gap: 9px;
  padding: 0 13px;
  margin-left: auto;
  margin-right: 8px;
  color: rgba(244,254,255,.78);
  font-size: 9px;
  letter-spacing: .28em;
}

.hud-state i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
}

.quality-pill {
  justify-content: center;
  width: 42px;
  color: rgba(244,254,255,.8);
  font-size: 9px;
  letter-spacing: .16em;
}

.toolbar {
  position: absolute;
  z-index: 30;
  right: clamp(18px, 3vw, 46px);
  top: 50%;
  display: grid;
  gap: 7px;
  padding: 7px;
  border: 1px solid rgba(226, 250, 255, .23);
  background: rgba(5, 26, 35, .24);
  box-shadow: 0 16px 45px rgba(0, 21, 31, .18), inset 0 0 24px rgba(255,255,255,.035);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transform: translateY(-50%);
}

.toolbar button {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(234, 252, 255, .65);
  cursor: pointer;
  transition: color .45s cubic-bezier(.22,1,.36,1), background .45s cubic-bezier(.22,1,.36,1), transform .45s cubic-bezier(.22,1,.36,1);
}

.toolbar button::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid transparent;
  transition: border-color .45s ease, box-shadow .45s ease;
}

.toolbar button:hover,
.toolbar button:focus-visible,
.toolbar button.is-active {
  color: #f5feff;
  background: rgba(98, 224, 244, .1);
  outline: none;
}

.toolbar button:hover { transform: scale(1.08); }

.toolbar button.is-active::before {
  border-color: rgba(111, 235, 255, .48);
  box-shadow: inset 0 0 15px rgba(111, 235, 255, .08), 0 0 14px rgba(111, 235, 255, .08);
}

.toolbar svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.part-readout {
  position: absolute;
  z-index: 22;
  left: clamp(18px, 3vw, 46px);
  bottom: var(--safe-bottom);
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 170px;
  height: 38px;
  padding: 0 13px 0 8px;
  border-left: 1px solid rgba(229,252,255,.5);
  color: rgba(242, 253, 255, .88);
  background: linear-gradient(90deg, rgba(4,26,37,.24), transparent);
  backdrop-filter: blur(10px);
  transform-origin: left center;
}

.part-index {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border: 1px solid rgba(222,249,255,.24);
  color: var(--cyan);
  font-size: 8px;
  letter-spacing: .08em;
}

.part-name {
  font-size: 10px;
  letter-spacing: .18em;
  text-shadow: 0 1px 10px rgba(0,22,33,.8);
}

.scroll-meter {
  position: absolute;
  z-index: 21;
  left: 50%;
  bottom: var(--safe-bottom);
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateX(-50%);
}

.scroll-meter span {
  position: relative;
  width: min(18vw, 150px);
  height: 1px;
  overflow: hidden;
  background: rgba(229,252,255,.24);
}

.scroll-meter span i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #fff, var(--cyan));
  transform: scaleX(0);
  transform-origin: left;
}

.scroll-meter b {
  width: 5px;
  height: 5px;
  border: 1px solid rgba(239,253,255,.7);
  transform: rotate(45deg);
}

.drag-hint {
  position: absolute;
  z-index: 20;
  right: clamp(18px, 3vw, 46px);
  bottom: var(--safe-bottom);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  opacity: .75;
}

.drag-hint span {
  display: block;
  width: 30px;
  height: 1px;
  background: rgba(231,252,255,.44);
}

.drag-hint i {
  position: relative;
  display: block;
  width: 18px;
  height: 25px;
  border: 1px solid rgba(231,252,255,.55);
  border-radius: 11px;
}

.drag-hint i::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 5px;
  width: 2px;
  height: 5px;
  border-radius: 2px;
  background: #fff;
  transform: translateX(-50%);
  animation: mouse-pulse 1.8s ease-in-out infinite;
}

@keyframes mouse-pulse {
  0%, 100% { transform: translate(-50%, 0); opacity: .2; }
  45% { opacity: 1; }
  70% { transform: translate(-50%, 7px); opacity: 0; }
}

.pointer-halo {
  position: fixed;
  z-index: 45;
  left: 0;
  top: 0;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border: 1px solid color-mix(in srgb, var(--particle-theme) 68%, white);
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(111,234,255,.18), inset 0 0 12px rgba(111,234,255,.1);
  pointer-events: none;
  opacity: 0;
  transform: translate3d(-100px,-100px,0);
  will-change: transform, width, height, opacity;
  transition: width .3s ease, height .3s ease, margin .3s ease, border-color .3s ease;
}

.pointer-halo.is-hot {
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-color: var(--cyan);
}

.pointer-halo.is-screen {
  width: 68px;
  height: 68px;
  margin: -34px 0 0 -34px;
  border-color: rgba(127, 244, 255, .92);
  box-shadow: 0 0 28px rgba(91,225,255,.34), inset 0 0 18px rgba(111,234,255,.17);
}

.pointer-halo.is-screen::after {
  content: "OPEN";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #ecfdff;
  font: 600 8px/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: .16em;
}

.pointer-dot {
  position: fixed;
  z-index: 46;
  left: 0;
  top: 0;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: rgba(239, 253, 255, .96);
  box-shadow: 0 0 10px rgba(111, 234, 255, .9);
  pointer-events: none;
  opacity: 0;
  transform: translate3d(-100px,-100px,0);
  will-change: transform, opacity;
}

.review-badge {
  position: absolute;
  z-index: 40;
  top: 68px;
  left: 50%;
  padding: 7px 12px;
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(3,20,29,.56);
  color: #fff;
  font-size: 10px;
  letter-spacing: .22em;
  text-transform: uppercase;
  transform: translateX(-50%);
}

.screen-focus-label {
  position: absolute;
  z-index: 38;
  right: clamp(20px, 4vw, 64px);
  bottom: clamp(110px, 15vh, 176px);
  display: grid;
  grid-template-columns: auto minmax(0, 230px);
  gap: 7px 14px;
  width: min(320px, calc(100vw - 40px));
  padding: 14px 16px 13px;
  border: 1px solid rgba(121, 235, 255, .28);
  border-radius: 2px 18px 2px 18px;
  background: linear-gradient(135deg, rgba(1, 22, 42, .72), rgba(2, 15, 36, .32));
  box-shadow: 0 0 34px rgba(66, 200, 255, .12), inset 0 0 24px rgba(77, 223, 255, .05);
  backdrop-filter: blur(13px);
  opacity: .35;
  transform: translate3d(18px, 0, 0) scale(.96);
  transform-origin: right center;
  transition: opacity .45s ease, transform .55s cubic-bezier(.22,1,.36,1), border-color .35s ease;
  pointer-events: none;
}

.screen-focus-label.is-active {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
  border-color: color-mix(in srgb, var(--particle-theme) 72%, white);
}

.screen-focus-label span {
  grid-row: 1 / 3;
  align-self: center;
  color: var(--particle-theme);
  font: 600 10px/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: .1em;
}

.screen-focus-label strong {
  overflow: hidden;
  color: rgba(239, 253, 255, .94);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .08em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.screen-focus-label i {
  display: block;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, var(--particle-theme), transparent);
  transform: scaleX(.32);
  transform-origin: left;
  transition: transform .55s cubic-bezier(.22,1,.36,1);
}

.screen-focus-label.is-active i {
  transform: scaleX(1);
}

.portal-transition {
  position: fixed;
  z-index: 80;
  inset: -5%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(circle at center, rgba(13, 94, 201, .35), #010516 72%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  will-change: transform, opacity;
}

.portal-media {
  position: absolute;
  inset: 7%;
  background-position: center;
  background-size: cover;
  filter: saturate(1.18) contrast(1.1) brightness(.72);
  transform: scale(1);
}

.portal-transition::before,
.portal-transition::after {
  content: "";
  position: absolute;
  inset: -30%;
  background: conic-gradient(from 0deg, transparent, rgba(70, 183, 255, .48), transparent 22%, rgba(126, 73, 255, .32), transparent 48%);
  mix-blend-mode: screen;
  animation: portal-spin 3.2s linear infinite;
}

.portal-transition::after {
  animation-direction: reverse;
  animation-duration: 4.7s;
  filter: blur(24px);
}

.portal-rings {
  position: relative;
  width: min(64vw, 760px);
  aspect-ratio: 1;
}

.portal-rings i {
  position: absolute;
  inset: calc(var(--ring, 0) * 8%);
  border: 1px solid rgba(142, 228, 255, calc(.72 - var(--ring, 0) * .15));
  border-radius: 50%;
  box-shadow: 0 0 36px rgba(58, 152, 255, .24), inset 0 0 36px rgba(54, 129, 255, .18);
  animation: portal-pulse 1.7s ease-in-out infinite alternate;
}

.portal-rings i:nth-child(2) { --ring: 1; animation-delay: -.55s; }
.portal-rings i:nth-child(3) { --ring: 2; animation-delay: -1.1s; }

.portal-copy {
  position: absolute;
  z-index: 3;
  left: clamp(24px, 6vw, 96px);
  bottom: clamp(30px, 8vh, 100px);
  display: grid;
  gap: 10px;
  max-width: min(520px, 76vw);
}

.portal-copy span {
  color: #72d9ff;
  font: 500 10px/1.3 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: .22em;
}

.portal-copy strong {
  color: #fff;
  font-size: clamp(22px, 4vw, 58px);
  font-weight: 500;
  letter-spacing: -.035em;
}

body.is-entering-screen .hud,
body.is-entering-screen .toolbar,
body.is-entering-screen .part-readout,
body.is-entering-screen .screen-focus-label,
body.is-entering-screen .scroll-meter {
  pointer-events: none;
  opacity: 0 !important;
  transition: opacity .35s ease;
}

@keyframes portal-spin { to { transform: rotate(1turn) scale(1.08); } }
@keyframes portal-pulse { to { transform: scale(1.12); opacity: .42; } }

.scroll-story {
  z-index: -1;
}

.beat {
  min-height: 100svh;
}

.noscript-card {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 30px;
  background: #071624;
  color: #e8fbff;
  text-align: center;
}

body.is-night .vignette {
  background: radial-gradient(ellipse at center, transparent 36%, rgba(0, 5, 17, .62) 100%);
}

body.is-exploded .part-readout {
  border-left-color: var(--cyan);
}

@media (hover: none), (pointer: coarse) {
  .cursor-particles,
  .pointer-halo,
  .pointer-dot,
  .drag-hint {
    display: none;
  }

  .toolbar button:hover {
    transform: none;
  }
}

@media (max-width: 720px) {
  .screen-focus-label {
    right: 16px;
    bottom: 142px;
    width: calc(100vw - 32px);
  }

  .portal-rings { width: 110vw; }
  .hud-top {
    left: 16px;
    right: 16px;
  }

  .hud-state span {
    display: none;
  }

  .hud-state {
    width: 29px;
    padding: 0;
    justify-content: center;
  }

  .toolbar {
    top: auto;
    right: 50%;
    bottom: calc(var(--safe-bottom) + 48px);
    display: flex;
    transform: translateX(50%);
  }

  .part-readout {
    left: 16px;
    right: 16px;
    bottom: var(--safe-bottom);
    min-width: 0;
    max-width: calc(100vw - 32px);
  }

  .part-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .scroll-meter {
    display: none;
  }

  .quality-pill {
    width: 36px;
  }
}

/* 内置浏览器无法改变视口时使用的 375px 质量验证模式，仅由 ?mobile=1 启用。 */
html.force-mobile,
html.force-mobile body,
html.force-mobile #app,
html.force-mobile .scroll-story {
  width: 375px;
  max-width: 375px;
  overflow-x: hidden;
}

html.force-mobile .stage {
  right: auto;
  bottom: auto;
  width: 375px;
  height: 812px;
}

html.force-mobile .hud-top {
  left: 16px;
  right: 16px;
}

html.force-mobile .hud-state span,
html.force-mobile .cursor-particles,
html.force-mobile .pointer-halo,
html.force-mobile .pointer-dot,
html.force-mobile .drag-hint,
html.force-mobile .scroll-meter {
  display: none;
}

html.force-mobile .hud-state {
  width: 29px;
  padding: 0;
  justify-content: center;
}

html.force-mobile .toolbar {
  top: auto;
  right: 50%;
  bottom: calc(var(--safe-bottom) + 48px);
  display: flex;
  transform: translateX(50%);
}

html.force-mobile .part-readout {
  left: 16px;
  right: 16px;
  bottom: var(--safe-bottom);
  min-width: 0;
  max-width: 343px;
}

html.force-mobile .part-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html.force-mobile .quality-pill {
  width: 36px;
}

@media (prefers-reduced-motion: reduce) {
  .cursor-particles {
    display: none;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media (hover: hover) and (pointer: fine) {
  .stage,
  .stage button,
  .webgl-mount canvas {
    cursor: none !important;
  }
}
