/* ============================================================
 * 公网图谱页（gallery.html）的增量样式
 * 视觉按 02-ecology 走：暗青底、点云、细蓝轴、等宽字笔记。
 * 数据层（catalog.json / gallery.js / space.js）一行未改。
 * ============================================================ */

:root {
  --fp-bg:     #101515;
  --fp-bg-2:   #1a2320;
  --fp-ink:    #a9bbb0;
  --fp-title:  #d7dfce;
  --fp-head:   #e8eddf;
  --fp-accent: #c25572;
  --fp-axis:   rgba(61, 66, 139, 0.32);
  --fp-line:   rgba(169, 187, 176, 0.16);
  --fp-mono:   "SFMono-Regular", Menlo, "PingFang SC", ui-monospace, monospace;
}

body.gallery {
  background: var(--fp-bg);
  color: var(--fp-ink);
  font-family: var(--fp-mono);
}

body.gallery #app {
  background: radial-gradient(ellipse at center, var(--fp-bg-2), var(--fp-bg) 68%);
}

/* 参考页没有 HUD、没有网格辉光 */
body.gallery .hud,
body.gallery .bg-glow,
body.gallery .bg-grid,
body.gallery .bg-vignette { display: none; }

/* cqw 的基准容器 */
body.gallery #stage { container-type: inline-size; }

body.gallery [data-screen="garden"] { background: transparent; }
/* 这张底图已经由 EcologyBackground 画在 garden-bg 画布里了（同一张 jpg 铺成纹理 + 撒粒子），
   这里再铺一遍静态照片只会重复，横屏 cover 还会裁出上下两条毛边，所以只垫一层暗底 */
body.gallery [data-screen="garden"] .garden-fallback {
  background: radial-gradient(ellipse at center, #1a2320 0%, #101515 70%);
  animation: none;
}
body.gallery [data-screen="garden"] .garden-fallback::before { display: none; }
body.gallery [data-screen="garden"] .garden-fallback::after {
  content: "";
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(2, 7, 6, 0.55) 0%, transparent 22%, transparent 74%, rgba(2, 7, 6, 0.62) 100%),
    radial-gradient(72% 58% at 50% 46%, transparent 42%, rgba(2, 7, 6, 0.45) 100%);
}

/* 动态背景画布：垫在静态底图之上、标本点云之下 */
body.gallery [data-screen="garden"] .garden-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

/* 横屏不再旋转整块画布：cover 裁切由画布内部按底图比例算（ecology-bg.js 的 _view），
   一旋转反而会和容器尺寸对不上，左右露出两条边 */
@media (orientation: landscape) {
  /* 暗角改成各向同性的径向渐变，转过来也看不出方向 */
  body.gallery [data-screen="garden"] .garden-fallback::after {
    background: radial-gradient(66% 58% at 50% 50%, transparent 40%, rgba(2, 7, 6, 0.55) 100%);
  }
}

/* 细蓝轴：竖线 36%，横线 23%，和参考页一致 */
body.gallery [data-screen="garden"]::before,
body.gallery [data-screen="garden"]::after {
  content: "";
  position: absolute;
  z-index: 3;
  pointer-events: none;
  background: #3d428b;
  opacity: 0.32;
}
body.gallery [data-screen="garden"]::before { top: 10%; bottom: 9%; left: 36%; width: 0.5px; }
body.gallery [data-screen="garden"]::after  { top: 23%; left: 7%; right: 7%; height: 0.5px; }

/* ------------------------------------------------------------ 标题块 */
body.gallery .overlay-top {
  inset: 0;
  position: absolute;
  padding: 12.2cqw 0 0 10.8cqw;
  pointer-events: none;
}
body.gallery .overlay-top .pad { max-width: none; width: auto; margin: 0; padding: 0; }

/* 左上角野外观测标题：照搬 02-ecology 原稿的 .field-title */
body.gallery [data-screen="garden"] .field-title {
  font-family: "SFMono-Regular", Menlo, "PingFang SC", monospace;
  font-size: 2cqw;
  letter-spacing: 0.26em;
  color: #d7dfce;
}
body.gallery [data-screen="garden"] .field-title span {
  display: block;
  margin-top: 1.3cqw;
  font-size: clamp(6.5px, 1.15cqw, 9px);
  letter-spacing: 0.1em;
  opacity: 0.66;
}
body.gallery .garden-head { display: none; }
body.gallery .me-me { display: none; }

/* ------------------------------------------------------------ 底部读数 */
body.gallery .overlay-bottom { padding: 0 7cqw 7.5cqw; }

body.gallery .garden-bar {
  gap: 6cqw;
  align-items: flex-end;
  padding: 2cqw 0 0;
  border: 0;
  border-top: 0.5px solid var(--fp-axis);
  border-radius: 0;
  background: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  font-family: var(--fp-mono);
}
body.gallery .garden-bar i {
  display: block;
  font-style: normal;
  font-size: 1cqw;
  letter-spacing: 0.22em;
  color: rgba(229, 238, 217, 0.5);
}
body.gallery .garden-bar b {
  font-weight: 300;
  font-size: 3.2cqw;
  line-height: 1.25;
  color: var(--fp-head);
  font-variant-numeric: tabular-nums;
}

body.gallery .garden-bar .btn-mini {
  margin-left: auto;
  width: auto;
  padding: 1.4cqw 2.6cqw;
  border: 0.5px solid var(--fp-axis);
  border-radius: 0;
  background: none;
  color: var(--fp-ink);
  font-family: var(--fp-mono);
  font-size: 1.15cqw;
  letter-spacing: 0.16em;
}
body.gallery .garden-bar .btn-mini:not(:disabled):hover {
  border-color: rgba(194, 85, 114, 0.6);
  color: var(--fp-head);
  background: rgba(194, 85, 114, 0.07);
}

body.gallery .hint-line {
  margin: 2cqw 0 0;
  font-family: var(--fp-mono);
  font-size: 1.05cqw;
  letter-spacing: 0.06em;
  line-height: 1.6;
  color: rgba(229, 238, 217, 0.42);
}

/* ------------------------------------------------------------ 光点标签 */
body.gallery .label-text {
  font-family: var(--fp-mono);
  font-size: 1.1cqw;
  letter-spacing: 0.1em;
  color: rgba(232, 237, 223, 0.78);
  border-color: var(--fp-line);
  background: rgba(16, 21, 21, 0.72);
  border-radius: 0;
}
body.gallery .label-dot {
  background: rgba(232, 237, 223, 0.75);
  box-shadow: 0 0 10px 1px rgba(232, 237, 223, 0.35);
}
body.gallery .label-node.mine .label-dot {
  background: var(--fp-accent);
  box-shadow: 0 0 14px 2px rgba(194, 85, 114, 0.45);
}
body.gallery .label-node.mine .label-text { color: #e7c3cc; border-color: rgba(194, 85, 114, 0.36); }

/* ------------------------------------------------------------ 档案卡 */
body.gallery .sheet {
  max-width: none;
  padding: 1.6cqw 7cqw calc(env(safe-area-inset-bottom, 0px) + 5cqw);
  border-top: 0.5px solid var(--fp-axis);
  border-radius: 0;
  background: rgba(8, 12, 11, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
body.gallery .sheet-grip { width: 6cqw; height: 1px; background: var(--fp-axis); margin: 0 auto 3cqw; }
body.gallery .sheet-body h3 {
  position: relative;
  margin: 0 0 3cqw;
  padding-left: 3cqw;
  font-family: var(--fp-mono);
  font-size: 4.2cqw;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fp-head);
}
body.gallery .sheet-body h3::before {
  content: "+";
  position: absolute;
  left: 0;
  top: -0.5cqw;
  font-weight: 300;
  font-size: 5cqw;
  color: var(--fp-accent);
}
body.gallery .sheet-meta { gap: 2cqw; }
body.gallery .sheet-meta i {
  display: block;
  font-style: normal;
  font-family: var(--fp-mono);
  font-size: 1.05cqw;
  letter-spacing: 0.2em;
  color: rgba(229, 238, 217, 0.45);
}
body.gallery .sheet-meta b {
  display: block;
  margin-top: 0.6cqw;
  font-family: var(--fp-mono);
  font-size: 1.35cqw;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: rgba(232, 240, 232, 0.9);
}
body.gallery .sheet-cta {
  margin-top: 4cqw;
  width: 100%;
  padding: 2.4cqw;
  border: 0.5px solid var(--fp-axis);
  border-radius: 0;
  background: none;
  color: var(--fp-head);
  font-family: var(--fp-mono);
  font-size: 1.4cqw;
  letter-spacing: 0.28em;
}
/* 卡片里只剩一个按钮：别留着原来标题和字段的空档 */
body.gallery .sheet-body > .sheet-cta:first-child { margin-top: 0; }
body.gallery .sheet-cta:not(:disabled):hover {
  border-color: rgba(194, 85, 114, 0.6);
  background: rgba(194, 85, 114, 0.07);
}

/* ------------------------------------------------------------ 标本详情层 */
body.gallery .detail-layer {
  display: block;
  padding: 0;
  font-family: var(--sans);
  color: var(--text);
}
body.gallery .detail-layer[hidden] { display: none; }
body.gallery .detail-loading {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 0.9em;
  font-family: var(--fp-mono);
  font-size: 1.1cqw;
  letter-spacing: 0.24em;
  color: rgba(229, 238, 217, 0.5);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
body.gallery .detail-loading.on { opacity: 1; }
/* 模型要等 three.js 模块 + GLB 下载解析，光一行字看着像卡死：给个转圈 */
body.gallery .detail-loading::before {
  content: "";
  width: 1.5em;
  height: 1.5em;
  flex: none;
  border: 2px solid rgba(229, 238, 217, 0.18);
  border-top-color: rgba(229, 238, 217, 0.85);
  border-radius: 50%;
  animation: lp-detail-spin 0.85s linear infinite;
}
body.gallery .detail-loading:empty::before { display: none; }
@keyframes lp-detail-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  body.gallery .detail-loading::before { animation-duration: 2.4s; }
}


/* ------------------------------------------------------------ 空态 */
body.gallery .gallery-empty {
  position: absolute;
  inset: 0;
  justify-content: center;
  text-align: center;
  gap: 2cqw;
  padding: 0 10cqw;
  pointer-events: none;
  font-family: var(--fp-mono);
}
body.gallery .gallery-empty[hidden] { display: none; }
body.gallery .gallery-empty .hint-line { margin: 0 auto; }
body.gallery .gallery-empty .headline.sm {
  font-size: 6cqw;
  font-weight: 300;
  letter-spacing: 0.02em;
  color: var(--fp-head);
}

/* 画面层与标签层跟着一起转 90°，标签文字再转回来保持正向 */
@media (orientation: landscape) and (min-width: 900px) {
  /* 背景/飞行层：宽高要按旋转后的画布算，覆盖上面 100%/inset 的声明 */
  body.gallery [data-screen="garden"] .garden-bg,
  body.gallery [data-screen="garden"] .garden-video-slot {
    top: 0; left: 0; right: auto; bottom: auto;
    width: 100vh;
    height: 100vw;
    transform-origin: 0 0;
    transform: translateX(100vw) rotate(90deg);
  }
  body.gallery #garden-labels {
    top: 0; left: 0; right: auto; bottom: auto;
    width: 100vh;
    height: 100vw;
    transform-origin: 0 0;
    transform: translateX(100vw) rotate(90deg);
  }
  body.gallery #garden-labels .label-node {
    transform: translate(-50%, -50%) rotate(-90deg);
  }
}

/* ------------------------------------------------------------ 现场笔记
   文字与版式照搬 02-ecology 原稿（.field-notes / .note）：等宽小字、
   标题前一枚洋红「+」、位置用同一套百分比。字体尺寸加了上下限，
   免得 393px 窄屏上只有 6px 看不清 */
body.gallery [data-screen="garden"] .field-notes {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  color: rgba(229, 238, 217, 0.9);
  font-family: var(--fp-mono);
  transition: opacity 0.35s ease;
}
body.gallery [data-screen="garden"] .note {
  position: absolute;
  max-width: 55%;
  font-size: clamp(7.5px, 1.5cqw, 9.5px);
  line-height: 1.7;
  letter-spacing: 0.015em;
  opacity: 0.95;
  /* 底下是亮粒子林，纯靠字色读不出来，垫一层很近的暗影（参考稿用的是更暗的底） */
  text-shadow: 0 1px 6px rgba(2, 7, 6, 0.95), 0 0 16px rgba(2, 7, 6, 0.7);
  transform: rotate(var(--tilt, 0deg));
}
body.gallery [data-screen="garden"] .note h2 {
  position: relative;
  margin: 0 0 0.8cqw;
  font-family: var(--fp-mono);
  font-size: clamp(7px, 1.65cqw, 10px);
  font-weight: 600;
  line-height: 1.6;
  color: var(--fp-head);
}
body.gallery [data-screen="garden"] .note h2::before {
  content: "+";
  position: absolute;
  left: -2.1cqw;
  top: -0.9cqw;
  font-family: var(--fp-mono);
  font-size: clamp(9px, 3.2cqw, 14px);
  font-weight: 300;
  color: var(--fp-accent);
  opacity: 0.9;
}
body.gallery [data-screen="garden"] .note p { margin: 0; }
body.gallery [data-screen="garden"] .note small {
  display: block;
  margin-top: 2cqw;
  font-size: clamp(6.5px, 1.05cqw, 8px);
  opacity: 0.5;
}
/* 取景位置与参考稿一致 */
body.gallery [data-screen="garden"] .note.uv         { left: 54%; top: 44.8%;  --tilt: 0.5deg; font-size: clamp(6px, 1.4cqw, 8.5px); }
body.gallery [data-screen="garden"] .note.atmosphere { left: 13%; top: 59%;    --tilt: -0.6deg; }
body.gallery [data-screen="garden"] .note.habitat    { left: 15%; top: 84%;    max-width: 72%; }
/* 档案卡 / 详情层打开时让位 */
body.gallery.sheet-open [data-screen="garden"] .field-notes,
body.gallery.detail-open [data-screen="garden"] .field-notes { opacity: 0; }

/* ------------------------------------------------------------ 选中高亮环
   键盘（WASD/方向键）和点击共用：选中那只外面套一圈细环 + 柔光，
   环跟着标本的透视缩放，不挡点击 */
body.gallery .select-ring {
  position: absolute;
  left: 0;
  top: 0;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 2px solid rgba(243, 240, 220, 0.9);
  box-shadow:
    /* 贴着环的一圈硬边，边缘不发虚 */
    0 0 0 2px rgba(243, 240, 220, 0.42),
    /* 近处光晕 */
    0 0 12px 4px rgba(243, 240, 220, 0.32),
    /* 远处弥散 */
    0 0 56px 12px rgba(243, 240, 220, 0.16),
    inset 0 0 20px rgba(243, 240, 220, 0.22);
  transform: translate3d(var(--ring-x, -9999px), var(--ring-y, -9999px), 0)
    translate(-50%, -50%) scale(var(--ring-scale, 1));
  opacity: 0;
  transition: opacity 0.28s ease;
  pointer-events: none;
  will-change: transform, opacity;
}
body.gallery .select-ring.on { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  body.gallery .select-ring.on { animation: ringBreathe 3.2s ease-in-out infinite; }
  @keyframes ringBreathe {
    0%, 100% { box-shadow: 0 0 0 2px rgba(243, 240, 220, 0.36), 0 0 11px 3px rgba(243, 240, 220, 0.28), 0 0 50px 10px rgba(243, 240, 220, 0.13), inset 0 0 18px rgba(243, 240, 220, 0.2); }
    50%      { box-shadow: 0 0 0 2px rgba(243, 240, 220, 0.52), 0 0 16px 6px rgba(243, 240, 220, 0.42), 0 0 66px 16px rgba(243, 240, 220, 0.2), inset 0 0 24px rgba(243, 240, 220, 0.28); }
  }
}

/* 选中标本时压暗背景：夹在飞行层与标本画布之间，只压背景不压标本 */
body.gallery [data-screen="garden"] .garden-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s ease;
  background:
    radial-gradient(60% 44% at 50% 46%, rgba(2, 7, 6, 0.18) 0%, rgba(2, 7, 6, 0.6) 74%, rgba(2, 7, 6, 0.82) 100%);
}
body.gallery.sheet-open [data-screen="garden"] .garden-scrim { opacity: 1; }

/* ------------------------------------------------------------ 标本铭牌
   每只标本头顶一块小牌：命名 / 发现时间 / 尺寸。位置由投影坐标驱动，
   选中那只描边更实，其余收着一点，别把画面压满 */
body.gallery .specimen-tag {
  position: absolute;
  left: 0;
  top: 0;
  padding: 2cqw 2.8cqw;
  border: 1px solid rgba(236, 241, 228, 0.68);
  border-radius: 2.2cqw;
  background: rgba(7, 11, 10, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-family: var(--fp-mono);
  font-size: clamp(10px, 1.9cqw, 15px);
  line-height: 1.7;
  letter-spacing: 0.05em;
  color: rgba(229, 238, 217, 0.8);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease, border-color 0.24s ease, background 0.24s ease;
  will-change: transform, opacity;
  /* 位置由 --tag-x/--tag-y 进 transform：每帧只更新合成器，不触发布局 */
  transform: translate3d(var(--tag-x, -9999px), var(--tag-y, -9999px), 0)
    translate(-50%, -100%) translateY(calc(-1 * var(--tag-lift, 46px)));
}
body.gallery .specimen-tag.on { opacity: 0.8; }
body.gallery .specimen-tag.cur {
  opacity: 1;
  border-color: rgba(236, 241, 228, 0.95);
  background: rgba(7, 11, 10, 0.78);
  color: rgba(236, 241, 228, 0.9);
}
body.gallery .specimen-tag b {
  display: block;
  margin-bottom: 0.7cqw;
  font-size: clamp(15px, 2.7cqw, 23px);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fp-head);
}
body.gallery .specimen-tag span { display: block; }
/* 选中那只：牌底一枚奶白三角，箭头尖正好落在选中环的上沿 */
body.gallery .specimen-tag.cur::after {
  content: "";
  position: absolute;
  left: 50%; top: 100%;
  margin-top: 2px;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 1.9cqw solid transparent;
  border-right: 1.9cqw solid transparent;
  border-top: 2.4cqw solid rgba(243, 240, 220, 0.95);
  filter: drop-shadow(0 0 6px rgba(243, 240, 220, 0.5));
}
@media (orientation: landscape) and (min-width: 900px) {
  body.gallery #garden-labels .specimen-tag {
    transform-origin: 50% 100%;
    transform: translate3d(var(--tag-x, -9999px), var(--tag-y, -9999px), 0)
      translate(-50%, -100%) translateY(calc(-1 * var(--tag-lift, 46px))) rotate(-90deg);
  }
}

/* ------------------------------------------------------------ 详情层改名
   公网图谱是只读静态站：改的名字只进本机 localStorage，不进 catalog.json。
   按钮用固定的 px 尺寸，别跟着 cqw 一起缩——窄屏上缩到 6px 就没人看得见了 */
body.gallery .name-row {
  display: flex;
  flex-direction: column;    /* 竖排：按钮单独一行，别压到右侧「观察记录」上 */
  align-items: flex-start;
  gap: 6px;
  pointer-events: auto;      /* .model-head 整体是 pointer-events:none */
}
/* 标题在列容器里：只留上边距，下边距交给 gap */
body.gallery .name-row .model-title { margin: 14px 0 0; }
/* 铅笔 + 「改名」：细线小胶囊，任何屏宽都看得见、点得到 */
body.gallery #btn-rename {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 9px 0 7px;
  border: 1px solid rgba(232, 240, 232, 0.28);
  background: rgba(7, 11, 10, 0.5);
  color: rgba(232, 240, 232, 0.72);
  border-radius: 999px;
  cursor: pointer;
  pointer-events: auto;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
body.gallery #btn-rename svg {
  display: block;
  width: 13px;
  height: 13px;
}
body.gallery #btn-rename span {
  font: 11px/1 Menlo, "PingFang SC", monospace;
  letter-spacing: 0.14em;
}
body.gallery #btn-rename:hover {
  color: var(--fp-head);
  border-color: rgba(194, 85, 114, 0.6);
  background: rgba(194, 85, 114, 0.08);
}
body.gallery #name-edit {
  pointer-events: auto;
  width: min(34vw, 190px);
  padding: 4px 6px 3px;
  border: 0.5px solid rgba(61, 66, 139, 0.55);
  border-radius: 2px;
  background: rgba(8, 12, 11, 0.92);
  color: var(--fp-head);
  font: inherit;
  letter-spacing: 0.04em;
}
body.gallery #name-edit:focus,
body.gallery #name-edit:focus-visible {
  outline: none;
  border-color: rgba(194, 85, 114, 0.75);
}
body.gallery .model-title[hidden] { display: none; }
