/* Spatial Hub - Pearlescent Gel Visual Layer */

:root {
  --spatial-hub-z: 10050;
  --spatial-hub-bg: transparent;
  --spatial-hub-card-radius: 20px;

  --spatial-hub-cyan: var(--color-cyan-fluid, hsl(168, 70%, 85%));
  --spatial-hub-peach: var(--color-peach-fluid, hsl(15, 85%, 90%));
  --spatial-hub-violet: var(--color-violet-fluid, hsl(270, 80%, 88%));
  --spatial-hub-sky: var(--color-sky-blue-fluid, hsl(205, 85%, 90%));
}

.info-bottom-row {
  cursor: pointer;
}

.spatial-hub-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--spatial-hub-z);
  background: var(--spatial-hub-bg);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 140ms ease, visibility 140ms ease;
}

.spatial-hub-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.spatial-hub-scene {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  filter: saturate(1.4);
}

.spatial-hub-card {
  position: fixed;
  left: initial; /* 覆盖初始值，允许JS动态设置 */
  top: initial; /* 覆盖初始值，允许JS动态设置 */
  width: 248px;
  max-width: calc(100vw - 24px);
  max-height: min(50vh, 390px);
  border-radius: var(--spatial-hub-card-radius);
  overflow: visible;  /* 允许按钮显示在圆角外面 */
  color: #334155;
  z-index: 10;
  transform-origin: 36px 0;
  opacity: 0;
  isolation: isolate;
}

.spatial-hub-card-surface {
  position: relative;
  width: 100%;
  max-height: min(50vh, 390px);
  border-radius: var(--spatial-hub-card-radius);
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 20% 30%, rgba(214, 196, 224, 0.4) 0%, transparent 42%),
    radial-gradient(circle at 80% 70%, rgba(194, 222, 214, 0.35) 0%, transparent 42%),
    radial-gradient(circle at 52% 62%, rgba(211, 218, 230, 0.28) 0%, transparent 48%),
    rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  box-shadow:
    0 18px 38px rgba(15, 23, 42, 0.28),
    0 6px 14px rgba(15, 23, 42, 0.22);
}

.spatial-hub-refresh-btn {
  position: absolute;
  top: -9px;
  right: -9px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.72) 0%, rgba(255, 255, 255, 0.2) 38%, transparent 60%),
    rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.2);
  cursor: pointer;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow:
    0 4px 10px rgba(15, 23, 42, 0.24),
    inset 0 1px 3px rgba(255, 255, 255, 0.58);
  mix-blend-mode: normal;
}

.spatial-hub-refresh-btn:hover {
  transform: scale(1.05);
  box-shadow:
    0 6px 14px rgba(15, 23, 42, 0.28),
    inset 0 1px 3px rgba(255, 255, 255, 0.68);
}

.spatial-hub-refresh-btn:active {
  transform: scale(0.95);
}

.spatial-hub-refresh-btn:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.spatial-hub-refresh-btn.is-loading .refresh-icon {
  animation: spatialHubRefreshSpin 0.9s linear infinite;
}

.refresh-icon {
  width: 14px;
  height: 14px;
  stroke: #334155;
  transition: transform 0.3s ease;
}

.spatial-hub-refresh-btn:hover .refresh-icon {
  transform: rotate(15deg);
}

.spatial-hub-card-surface::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    linear-gradient(115deg,
      #ff0000 0%,
      #ff8000 20%,
      #ffff00 40%,
      #00ff00 60%,
      #0000ff 80%,
      #8000ff 100%);
  background-size: 400% 400%;
  filter: blur(10px) saturate(180%);
  mix-blend-mode: overlay;
  opacity: 0.15;
  will-change: transform, background-position;
  animation: spatialRainbowFlow 4s ease-in-out infinite alternate;
  animation-play-state: paused;
}

.spatial-hub-card-surface::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    radial-gradient(58% 52% at 20% 22%, #ff0000 0%, transparent 58%),
    radial-gradient(56% 54% at 80% 30%, #00ff00 0%, transparent 60%),
    radial-gradient(60% 56% at 54% 78%, #0000ff 0%, transparent 62%);
  filter: blur(7px) saturate(180%);
  mix-blend-mode: overlay;
  opacity: 0.10;
  will-change: transform, opacity;
  animation: spatialRainbowDrift 3.5s ease-in-out infinite alternate;
  animation-play-state: paused;
}

.spatial-hub-overlay.active .spatial-hub-card-surface::before,
.spatial-hub-overlay.active .spatial-hub-card-surface::after {
  animation-play-state: running;
  opacity: 0.20;
}

/* 为减少动画偏好设置提供支持，但保留核心功能 */
@media (prefers-reduced-motion: reduce) {
  .spatial-hub-overlay,
  .spatial-hub-card {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }

  .blob,
  .spatial-hub-scene::before {
    animation: none !important;
  }
  
  /* 在减少动画模式下，暂停彩虹特效动画，但仍保持视觉效果 */
  .spatial-hub-card-surface::before,
  .spatial-hub-card-surface::after {
    animation-play-state: paused !important;
  }
  
  /* 在减少动画模式下，确保激活时不会播放动画 */
  .spatial-hub-overlay.active .spatial-hub-card-surface::before,
  .spatial-hub-overlay.active .spatial-hub-card-surface::after {
    animation-play-state: paused !important;
  }
}

/* 确保在正常模式下动画能够正确播放 */
@media (prefers-reduced-motion: no-preference) {
  .spatial-hub-overlay.active .spatial-hub-card-surface::before,
  .spatial-hub-overlay.active .spatial-hub-card-surface::after {
    animation-play-state: running !important;
    opacity: 0.20;
  }
}

/* 强制在正常环境下运行动画，使用更具体的选择器和更高的优先级 */
.spatial-hub-overlay.active .spatial-hub-card-surface::before,
.spatial-hub-overlay.active .spatial-hub-card-surface::after {
  animation-play-state: running !important;
  opacity: 0.20 !important;
}


.spatial-hub-overlay.active .spatial-hub-card {
  animation: spatialHubJellyIn 560ms cubic-bezier(0.34, 1.56, 0.64, 1) both !important;
}

.spatial-hub-overlay.closing .spatial-hub-card {
  animation: spatialHubQuickOut 380ms cubic-bezier(0.34, 0, 0.64, 1) both !important;
}

.gel-slab-card,
.liquid-glass-card {
  background:
    radial-gradient(circle at 20% 30%, rgba(214, 196, 224, 0.4) 0%, transparent 42%),
    radial-gradient(circle at 80% 70%, rgba(194, 222, 214, 0.35) 0%, transparent 42%),
    radial-gradient(circle at 52% 62%, rgba(211, 218, 230, 0.28) 0%, transparent 48%),
    rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  box-shadow:
    0 18px 38px rgba(15, 23, 42, 0.28),
    0 6px 14px rgba(15, 23, 42, 0.22);
}

.iridescent-border {
  position: relative;
}

.iridescent-border::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: none;
}

.specular-highlight {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(255, 255, 255, 0.24) 0%, rgba(255, 255, 255, 0.08) 20%, transparent 50%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0%, transparent 20%);
  pointer-events: none;
  mix-blend-mode: normal;
  opacity: 0.45;
  z-index: 2;
}

.spatial-hub-noise {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  z-index: 1;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.02'/%3E%3C/svg%3E");
}

/* 磨砂杂色纹理增强 */
.satin-texture {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.12;
  z-index: 1;
  mix-blend-mode: overlay;
  background-image:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.15'/%3E%3C/svg%3E"),
    linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%, rgba(0,0,0,0.05) 100%);
  mask-image: radial-gradient(ellipse at center, rgba(0,0,0,0.8) 0%, transparent 70%);
  border-radius: inherit;
}

.blob {
  position: absolute;
  filter: blur(78px);
  border-radius: 50%;
  z-index: 0;
  mix-blend-mode: screen;
  animation: spatialBlobFloat 18s ease-in-out infinite;
  animation-play-state: paused;
  opacity: 0.32;
}

.spatial-hub-overlay.active .blob {
  animation-play-state: running;
  will-change: transform;
}

.blob-cyan {
  width: 380px;
  height: 380px;
  top: -40px;
  left: -70px;
  background: var(--spatial-hub-cyan);
}

.blob-peach {
  width: 300px;
  height: 300px;
  top: 20px;
  right: -60px;
  background: var(--spatial-hub-peach);
  filter: blur(92px);
}

.blob-violet {
  width: 320px;
  height: 320px;
  bottom: -120px;
  left: -20px;
  background: var(--spatial-hub-violet);
  filter: blur(90px);
}

.blob-sky {
  width: 260px;
  height: 260px;
  top: 180px;
  right: 80px;
  background: var(--spatial-hub-sky);
  filter: blur(102px);
}

.spatial-hub-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px 11px 9px;
  max-height: min(68vh, 620px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.spatial-hub-grabber {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.28);
  margin: 0 auto 2px;
}

.spatial-hub-sync-status {
  max-height: 0;
  margin: 0;
  color: rgba(71, 85, 105, 0.92);
  font-size: 10px;
  line-height: 1.25;
  letter-spacing: 0.01em;
  opacity: 0;
  overflow: hidden;
  transition: max-height 200ms ease, margin 200ms ease, opacity 150ms ease 50ms;
  pointer-events: none;
}

.spatial-hub-sync-status.active {
  max-height: 14px;
  margin: 1px 0 2px;
  opacity: 1;
  transition: max-height 200ms ease, margin 200ms ease, opacity 150ms ease;
}

.spatial-hub-header-row {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: flex-start;
  min-height: 34px;
}

.spatial-hub-header-row > div:not(.spatial-hub-weather-chip) {
  flex: 1;
  min-width: 0;
  /* 只给左侧文字块预留空间，避免误伤温度胶囊 */
  padding-right: 68px;
}

.spatial-hub-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.location-title {
  font-size: 15px;
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  color: #1f2937;
  text-shadow: 0 2px 4px rgba(255, 255, 255, 0.9);
}

.spatial-hub-online-dot-wrap {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.spatial-hub-online-dot-wrap::before {
  display: none;
}

.spatial-hub-online-dot {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.location-meta {
  text-align: left;
  font-size: 8px;
  color: rgba(100, 116, 139, 0.86);
  letter-spacing: 0.06em;
  text-transform: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
  font-weight: 600;
}

.spatial-hub-weather-chip {
  position: absolute;
  top: 2px;
  right: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: auto;
  min-width: unset;
  max-width: unset;
  flex: 0 0 auto;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  border: 0.5px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  padding: 3px 7px;
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.6), 0 2px 8px rgba(226, 194, 246, 0.15);
  overflow: hidden;
}

.spatial-hub-weather-chip .material-symbols-outlined {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 11px;
  height: 11px;
  font-size: 11px;
  line-height: 1;
  color: #334155;
  font-variation-settings: 'wght' 200;
  transform: translateY(-0.5px);
}

.weather-text {
  display: inline-block;
  font-size: 6.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1;
  color: #475569;
}

.spatial-hub-distance-block {
  width: 100%;
  padding: 2px 1px;
}

.spatial-hub-distance-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 8px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #94a3b8;
  font-weight: 600;
}

.distance-value {
  color: #cbd5e1; /* 比原来的 #94a3b8 更淡一个度 */
  flex: 0 0 auto; /* 防止被挤压 */
  padding: 0 8px; /* 添加左右间距，使其视觉居中 */
}

.distance-value {
  font-size: 10px;
  color: #334155;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.glowing-thread {
  position: relative;
  width: 100%;
  height: 1px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.3);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.02);
}

.glowing-thread-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 72%;
  border-radius: inherit;
  background: #ffffff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 1), 0 0 4px rgba(255, 255, 255, 0.8);
}

.light-spark {
  position: absolute;
  top: 50%;
  left: calc(72% - 3px);
  width: 6px;
  height: 6px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 12px 4px rgba(255, 255, 255, 1), 0 0 24px 6px rgba(168, 240, 227, 0.6);
}

.spatial-hub-bottom-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.activity-text {
  margin: 8px 0 0;
  max-width: 56%;
  color: rgba(71, 85, 105, 0.9);
  font-size: 10px;
  line-height: 1.35;
  font-style: italic;
  letter-spacing: 0.01em;
}

.spatial-hub-modules {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex-shrink: 0;
}

.glass-module {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  white-space: nowrap;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  border: 0.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.6), 0 2px 8px rgba(226, 194, 246, 0.15);
}

.glass-module .material-symbols-outlined {
  font-size: 12px;
  color: #334155;
  font-variation-settings: 'wght' 200;
}

.glass-module-text {
  font-size: 6.5px;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
}

@keyframes spatialHubRefreshSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes spatialBlobFloat {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(2.2%, -2.2%, 0) scale(1.045);
  }
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes spatialRainbowFlow {
  0% {
    transform: translate3d(-2.4%, -1.8%, 0) scale(1.01);
    background-position: 0% 18%;
  }
  50% {
    transform: translate3d(2.2%, 1.6%, 0) scale(1.06);
    background-position: 58% 82%;
  }
  100% {
    transform: translate3d(-1.6%, -1.2%, 0) scale(1.03);
    background-position: 100% 24%;
  }
}

@keyframes spatialRainbowDrift {
  0% {
    transform: translate3d(-2.2%, -1.4%, 0) scale(0.99);
    opacity: 0.42;
  }
  50% {
    transform: translate3d(2.4%, 1.3%, 0) scale(1.04);
    opacity: 0.60;
  }
  100% {
    transform: translate3d(0.4%, -1.8%, 0) scale(1.01);
    opacity: 0.46;
  }
}

@keyframes spatialHubJellyIn {
  0% {
    transform: translate3d(0, -12px, 0) scale(0.94);
    opacity: 0;
    filter: blur(1px);
  }
  48% {
    transform: translate3d(0, 0, 0) scale(1.015);
    opacity: 1;
    filter: blur(0.3px);
  }
  72% {
    transform: translate3d(0, 0, 0) scale(0.992);
    opacity: 1;
    filter: blur(0.5px);
  }
  100% {
    transform: translate3d(0, 0, 0) scale(1);
    opacity: 1;
    filter: blur(0px);
  }
}

@keyframes spatialHubQuickOut {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
    opacity: 1;
    box-shadow:
      0 18px 38px rgba(15, 23, 42, 0.24),
      0 6px 14px rgba(15, 23, 42, 0.18);
  }
  48% {
    transform: translate3d(0, 0, 0) scale(0.99);
    opacity: 0.92;
    box-shadow:
      0 12px 28px rgba(15, 23, 42, 0.18),
      0 4px 10px rgba(15, 23, 42, 0.14);
  }
  100% {
    transform: translate3d(0, 0, 0) scale(0.96);
    opacity: 0;
    filter: blur(0.5px);
    box-shadow:
      0 4px 12px rgba(15, 23, 42, 0.10),
      0 2px 6px rgba(15, 23, 42, 0.06);
  }
}

