/* 星图 · The Celestial Atlas —— 桌面端专属；茶金/玫瑰铂金恒定色（与 memory-book.css 同一套，不进 CSS 变量） */

/* ── 0. 色板与公共字面 ── */
.sm-orb-root,
.sm-overlay {
  --sm-gold: #f3e0c6;
  --sm-gold-dim: rgba(246, 228, 198, 0.55);
  --sm-gold-hair: rgba(246, 228, 198, 0.16);
  --sm-text: rgba(249, 232, 214, 0.92);
  --sm-dim: rgba(248, 222, 197, 0.46);
  --sm-faint: rgba(248, 226, 199, 0.28);
  --sm-ink: #04060b;
  font-family: 'Cormorant Garamond', 'Times New Roman', serif;
}

/* ── 1. 悬浮 AI 球（书开着才在：书遮罩的直接子元素） ── */
.sm-orb-root {
  position: absolute;
  z-index: 4;
  /* 窄桌面自动左收、不越出视口；right 公式的 119 是让球心的补偿量，改宽度要重算 */
  right: max(12px, calc(50vw - min(590px, 46vw) - 119px));
  top: 56%;
  width: 176px;
  height: 176px;
  margin-top: -88px;
  pointer-events: none;
}

/* 书裡开着阅读层时不进星图（阅读层几乎满屏，球会压字） */
.memory-book-overlay.sm-reading .sm-orb-root {
  display: none;
}

/* 拖动中：跟手，别跟过渡打架 */
.sm-orb-root.dragging .sm-orb {
  cursor: var(--pl-cursor-grabbing, grabbing);
}

/* 球体（WebGL 画布；拿不到 WebGL 时换 .sm-orb-fallback 的静态玻璃球） */
.sm-orb {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: var(--pl-cursor-grab, grab);
  pointer-events: auto;
  touch-action: none;
  -webkit-appearance: none;
  appearance: none;
}

.sm-orb-core {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 0 22px rgba(246, 220, 178, 0.14);
  transition: box-shadow 0.5s ease;
}

.sm-orb:hover .sm-orb-core,
.sm-orb-root.open .sm-orb-core {
  box-shadow: 0 0 30px rgba(248, 226, 190, 0.22), 0 0 9px rgba(255, 240, 212, 0.10);
}

/* 拿不到 WebGL 的兜底球（不参与动画，只保证不出现空洞） */
.sm-orb-fallback {
  display: none;
}

.sm-orb-root.gl-off .sm-orb-core {
  display: none;
}

.sm-orb-root.gl-off .sm-orb-fallback {
  display: block;
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 248, 232, 0.95) 0%, rgba(250, 226, 190, 0.42) 15%, transparent 46%),
    radial-gradient(circle at 64% 72%, rgba(244, 192, 198, 0.30), transparent 54%),
    radial-gradient(circle at 50% 50%, #6b4b30 0%, #2a1d14 56%, #0a0b12 100%);
  box-shadow:
    inset 0 0 0 0.5px rgba(246, 228, 198, 0.32),
    inset -3px -4px 12px rgba(0, 0, 0, 0.55),
    0 0 26px rgba(246, 220, 178, 0.18);
  animation: smOrbFallbackBreath 6.4s ease-in-out infinite alternate;
}

/* 外晕：极淡的呼吸光（只在开书时活着） */
.sm-orb-halo {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 132px;
  height: 132px;
  margin: -66px 0 0 -66px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(246, 224, 190, 0.15) 0%, rgba(196, 206, 232, 0.05) 40%, transparent 70%);
  animation: smOrbHalo 7.5s ease-in-out infinite alternate;
  pointer-events: none;
}

/* 光带：后半截画布压在球下层、前半截浮在球上层 —— 球体天然挡住绕到背后的那截 */
.sm-orb-ring-back,
.sm-orb-ring-front {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.sm-orb-ring-back {
  z-index: 0;
}

.sm-orb-ring-front {
  z-index: 3;
}

/* 两颗选项小球：位置 / 缩放 / 明暗全由 JS 每帧写（沿光带走，永远正着不翻转） */
.sm-orb-menu {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* 小球本体：没有边框、也没有球壳，只在图标底下垫一团光（transform / opacity 由 JS 每帧写） */
.sm-bubble {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: #fdf1dc;
  cursor: var(--pl-cursor-pointer, pointer);
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate3d(0, 0, 0) scale(0.86);
  will-change: transform, opacity;
}

/* 底光：正中一点暖金，向外晕成冰蓝再散开；深底上是光，浅底上自然收成一小圈阴影 */
.sm-bubble::before {
  content: '';
  position: absolute;
  inset: -18px;
  border-radius: 50%;
  pointer-events: none;
  background:
    radial-gradient(circle, rgba(250, 232, 200, 0.40) 0%, rgba(246, 216, 176, 0.20) 30%, rgba(168, 198, 238, 0.09) 52%, transparent 72%),
    radial-gradient(circle, rgba(6, 8, 16, 0.50) 0%, rgba(6, 8, 16, 0.20) 26%, transparent 50%);
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.sm-bubble svg {
  position: relative;
  width: 19px;
  height: 19px;
  opacity: 0.94;
  stroke-width: 1.5;
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.95)) drop-shadow(0 0 2px rgba(0, 0, 0, 0.85)) drop-shadow(0 0 8px rgba(246, 216, 176, 0.45));
  transition: opacity 0.3s ease;
}

.sm-bubble:hover svg {
  opacity: 1;
}

.sm-bubble:hover::before {
  transform: scale(1.22);
}

.sm-bubble-label {
  position: absolute;
  left: 50%;
  top: 44px;
  transform: translateX(-50%);
  font-size: 0.62rem;
  letter-spacing: 2px;
  color: #f8e8cc;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8), 0 0 10px rgba(0, 0, 0, 0.5);
}

.sm-bubble:hover .sm-bubble-label {
  opacity: 0.95;
}

@keyframes smOrbHalo {
  from {
    opacity: 0.55;
    transform: scale(0.94);
  }

  to {
    opacity: 1;
    transform: scale(1.06);
  }
}

@keyframes smOrbFallbackBreath {
  from {
    opacity: 0.82;
    transform: scale(0.99);
  }

  to {
    opacity: 1;
    transform: scale(1.01);
  }
}

/* ── 2. 全屏星图 ── */
.sm-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 110% at 50% 42%, #0a0d16 0%, #06080f 46%, #04060b 100%);
  cursor: var(--pl-cursor-grab, grab);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  opacity: 0;
  transition: opacity 0.55s ease;
  overflow: hidden;
}

.sm-overlay.on {
  opacity: 1;
}

.sm-overlay.dragging {
  cursor: var(--pl-cursor-grabbing, grabbing);
}

.sm-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* 胶片颗粒 + 暗角 + 暖光：复古星图的“纸感” */
.sm-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.085;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

.sm-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(72% 62% at 50% 46%, transparent 40%, rgba(2, 3, 6, 0.42) 78%, rgba(2, 3, 6, 0.76) 100%),
    radial-gradient(58% 44% at 46% 38%, rgba(255, 226, 188, 0.07), transparent 72%);
}

/* 四角 L 形角饰（与书同款，淡一档） */
.sm-corner {
  position: absolute;
  width: 26px;
  height: 26px;
  pointer-events: none;
  opacity: 0.5;
}

.sm-corner.tl {
  left: 22px;
  top: 20px;
  border-left: 1px solid rgba(246, 228, 198, 0.55);
  border-top: 1px solid rgba(246, 228, 198, 0.55);
}

.sm-corner.tr {
  right: 22px;
  top: 20px;
  border-right: 1px solid rgba(246, 228, 198, 0.55);
  border-top: 1px solid rgba(246, 228, 198, 0.55);
}

.sm-corner.bl {
  left: 22px;
  bottom: 20px;
  border-left: 1px solid rgba(246, 228, 198, 0.55);
  border-bottom: 1px solid rgba(246, 228, 198, 0.55);
}

.sm-corner.br {
  right: 22px;
  bottom: 20px;
  border-right: 1px solid rgba(246, 228, 198, 0.55);
  border-bottom: 1px solid rgba(246, 228, 198, 0.55);
}

/* —— 顶部标题与纪元条 —— */
.sm-head {
  position: absolute;
  left: 0;
  right: 0;
  top: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.sm-title {
  font-family: 'Kapakana', 'Cormorant Garamond', serif;
  font-size: clamp(1.8rem, 3.1vw, 2.6rem);
  font-weight: 400;
  letter-spacing: 3px;
  color: #dcc8b0;
  text-shadow: 0 1px 0 rgba(90, 60, 30, 0.3), 0 0 22px rgba(220, 200, 176, 0.22);
  line-height: 1.1;
}

.sm-subtitle {
  margin-top: 4px;
  font-family: 'Inter', sans-serif;
  font-size: 0.6rem;
  font-weight: 380;
  letter-spacing: 9px;
  color: rgba(248, 218, 199, 0.5);
  padding-left: 9px;
}

.sm-epochs {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 18px;
  padding: 0 4px;
}

.sm-epoch {
  position: relative;
  border: 0;
  padding: 2px 0 5px;
  background: none;
  color: rgba(248, 226, 199, 0.42);
  font-family: inherit;
  font-size: 0.66rem;
  letter-spacing: 1.6px;
  cursor: var(--pl-cursor-pointer, pointer);
  transition: color 0.35s ease;
  white-space: nowrap;
}

.sm-epoch::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(246, 228, 198, 0.7), transparent);
  transform: translateX(-50%);
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.sm-epoch:hover,
.sm-epoch.on {
  color: #f8e8cc;
}

.sm-epoch:hover::after,
.sm-epoch.on::after {
  width: 100%;
}

.sm-epoch b {
  font-weight: 400;
  font-style: italic;
  letter-spacing: 1.2px;
  opacity: 0.75;
  margin-right: 6px;
}

/* 纪元悬停/选中时浮在纪元条下方的一行字。裸元素会继承浏览器默认黑（全站 body 未设 color），必须自己定色 */
.sm-epoch-title {
  max-width: min(72vw, 760px);
  margin-top: 9px;
  font-size: 0.72rem;
  letter-spacing: 2.2px;
  line-height: 1.5;
  color: var(--sm-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  text-shadow: 0 1px 8px rgba(4, 6, 11, 0.8);
}

.sm-epoch-title.on {
  opacity: 1;
  color: rgba(250, 236, 210, 0.82);
  transform: none;
}

/* —— 图例（左下，可点开合） —— */
.sm-legend {
  position: absolute;
  left: 46px;
  bottom: 42px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.sm-legend-item {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  padding: 0;
  background: none;
  color: var(--sm-c, var(--sm-dim));
  font-family: inherit;
  font-size: 0.68rem;
  letter-spacing: 2.4px;
  cursor: var(--pl-cursor-pointer, pointer);
  transition: color 0.3s ease, opacity 0.3s ease;
}

.sm-legend-item i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 7px 1px currentColor;
  flex-shrink: 0;
}

.sm-legend-item em {
  font-style: normal;
  font-size: 0.62rem;
  letter-spacing: 1px;
  color: var(--sm-faint);
  margin-left: 2px;
}

.sm-legend-item:hover {
  color: #f8e8cc;
}

.sm-legend-item.off {
  opacity: 0.32;
}

.sm-legend-item.off i {
  box-shadow: none;
}

/* —— 检索（右上） —— */
.sm-search {
  position: absolute;
  right: 46px;
  top: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 196px;
  padding-bottom: 5px;
  border-bottom: 1px solid transparent;
  transition: border-color 0.35s ease, width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.sm-search.on {
  border-bottom-color: rgba(246, 228, 198, 0.3);
  width: 214px;
}

.sm-search svg {
  width: 13px;
  height: 13px;
  color: var(--sm-dim);
  flex-shrink: 0;
  cursor: var(--pl-cursor-pointer, pointer);
}

.sm-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: none;
  color: var(--sm-text);
  font-family: inherit;
  font-size: 0.72rem;
  letter-spacing: 1.4px;
  padding: 0;
}

.sm-search input::placeholder {
  color: var(--sm-faint);
  letter-spacing: 2px;
}

.sm-search-count {
  font-size: 0.62rem;
  letter-spacing: 1px;
  color: var(--sm-dim);
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sm-search-count.on {
  opacity: 1;
}

/* —— 底部：回书 / 提示 —— */
.sm-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 40px;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

/* 与书里 Back to the Land 完全同款（同字族、同字号、同字距、同色、同 hover 光） */
.sm-back {
  pointer-events: auto;
  border: 0;
  padding: 6px 10px;
  background: none;
  font-family: 'Kapakana', 'Cormorant Garamond', serif;
  font-style: normal;
  font-size: 1.05rem;
  letter-spacing: 2px;
  color: var(--mb-text-soft, rgba(248, 218, 199, 0.69));
  cursor: var(--pl-cursor-pointer, pointer);
  transition: color 0.3s, text-shadow 0.3s;
}

.sm-back:hover {
  color: var(--mb-highlight, #f6e1c4);
  text-shadow: 0 0 12px rgba(227, 201, 168, 0.35);
}

.sm-hint {
  position: absolute;
  left: 50%;
  bottom: 74px;
  transform: translateX(-50%);
  font-size: 0.64rem;
  letter-spacing: 3px;
  color: var(--sm-faint);
  pointer-events: none;
  opacity: 1;
  transition: opacity 1.6s ease;
  white-space: nowrap;
}

.sm-hint.gone {
  opacity: 0;
}

/* ── 3. 星卡（右侧，点星后浮出） ── */
.sm-card {
  position: absolute;
  right: 46px;
  top: 50%;
  width: 306px;
  padding: 4px 0 4px 26px;
  transform: translateY(-50%);
  border-left: 1px solid var(--sm-gold-hair);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.sm-card.on {
  opacity: 1;
  transform: translateY(-50%);
  pointer-events: auto;
}

.sm-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sm-card-kicker {
  font-family: 'Inter', sans-serif;
  font-size: 0.56rem;
  font-weight: 380;
  letter-spacing: 2.6px;
  color: rgba(246, 228, 198, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sm-card-nav {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.sm-card-nav button {
  border: 0;
  padding: 0;
  width: 16px;
  height: 16px;
  background: none;
  color: var(--sm-faint);
  font-family: inherit;
  font-size: 0.86rem;
  line-height: 1;
  cursor: var(--pl-cursor-pointer, pointer);
  transition: color 0.25s ease;
}

.sm-card-nav button:hover {
  color: #f8e8cc;
}

.sm-card-title {
  margin-top: 12px;
  font-size: 1.06rem;
  font-weight: 500;
  line-height: 1.55;
  letter-spacing: 0.4px;
  color: #f4e4cd;
  max-height: 3.4em;
  overflow: hidden;
}

.sm-card-time {
  margin-top: 7px;
  font-size: 0.66rem;
  letter-spacing: 1.4px;
  color: var(--sm-dim);
  line-height: 1.6;
}

.sm-card-anchors {
  margin-top: 5px;
  font-size: 0.62rem;
  letter-spacing: 1.2px;
  color: var(--sm-faint);
  line-height: 1.7;
}

.sm-card-rule {
  margin: 16px 0 14px;
  height: 1px;
  background: linear-gradient(90deg, var(--sm-gold-hair), transparent);
}

.sm-card-text {
  font-size: 0.76rem;
  line-height: 1.95;
  letter-spacing: 0.3px;
  color: rgba(249, 229, 214, 0.66);
  max-height: 9.8em;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 62%, transparent 100%);
  mask-image: linear-gradient(#000 62%, transparent 100%);
}

.sm-card-meta {
  margin-top: 14px;
  font-size: 0.62rem;
  letter-spacing: 1.6px;
  color: var(--sm-faint);
}

/* 展卷：无框，落在星卡下方居中，左右各一段短镶边（书页/礼盒启封的那种花边） */
.sm-card-open {
  display: flex;
  align-items: center;
  width: fit-content;
  gap: 8px;
  margin: 22px auto 2px;
  padding: 7px 2px;
  border: 0;
  background: none;
  color: var(--sm-gold-dim);
  font-family: inherit;
  font-size: 0.72rem;
  line-height: 1;
  letter-spacing: 3px;
  cursor: var(--pl-cursor-pointer, pointer);
  transition: color 0.35s ease, gap 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

/* 末字后多出的 3px 字距要扣掉，否则字偏左、右边花边离得更远 */
.sm-card-open-text {
  margin-right: -3px;
}

/* 镶边：外侧渐隐的一段细线 + 内侧一颗小菱形 */
.sm-flourish {
  position: relative;
  flex: 0 0 auto;
  width: 26px;
  height: 9px;
}

.sm-flourish-r {
  transform: scaleX(-1);
}

.sm-flourish::before {
  content: '';
  position: absolute;
  left: 0;
  right: 6px;
  top: 50%;
  height: 1px;
  margin-top: -0.5px;
  background: linear-gradient(90deg, rgba(246, 228, 198, 0) 0%, rgba(246, 228, 198, 0.26) 55%, rgba(246, 228, 198, 0.46) 100%);
  transition: background 0.35s ease;
}

.sm-flourish::after {
  content: '';
  position: absolute;
  right: 1px;
  top: 50%;
  width: 3.2px;
  height: 3.2px;
  margin-top: -1.6px;
  background: rgba(246, 228, 198, 0.52);
  transform: rotate(45deg);
  box-shadow: 0 0 7px rgba(246, 228, 198, 0.3);
  transition: background 0.35s ease, box-shadow 0.35s ease, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.sm-card-open:hover {
  color: #fdf0dc;
  gap: 11px;
}

.sm-card-open:hover .sm-flourish::before {
  background: linear-gradient(90deg, rgba(246, 228, 198, 0) 0%, rgba(246, 228, 198, 0.42) 55%, rgba(246, 228, 198, 0.68) 100%);
}

.sm-card-open:hover .sm-flourish::after {
  background: #f8e8cc;
  box-shadow: 0 0 10px rgba(246, 228, 198, 0.55);
  transform: rotate(45deg) scale(1.18);
}

/* ── 4. 空态 ── */
.sm-empty {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.8rem;
  letter-spacing: 4px;
  color: var(--sm-faint);
}

/* ── 5. 移动端不做：星图与悬浮球整块不出现 ── */
@media (max-width: 800px) {

  .sm-orb-root,
  .sm-overlay {
    display: none !important;
  }
}
