/* 地球物种地图 · 全局样式
   维护：会话 A（地球引擎）
   依赖：无（第 1 步只保证纯黑底、全屏画布、可拖拽不选字） */

:root {
  --bg: #05070d;
  --accent: #4fd1c5;
  --font: -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: #e8eef6;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

#globe-canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

/* 页脚署名（CC BY 4.0 要求署名；纯文本、pointer-events:none —— 不挡拖动地球，也不挡时间轴横滑） */
.site-credit {
  position: fixed;
  left: 14px;
  bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 10px);
  z-index: 15;
  max-width: min(58vw, 560px);
  margin: 0;
  color: rgba(232, 238, 246, 0.36);
  font-family: var(--font);
  font-size: 11px;
  line-height: 1.55;
  letter-spacing: 0.01em;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
  transition: color 0.2s ease;
}

.site-credit p {
  margin: 0;
}

.site-credit p + p {
  margin-top: 2px;
}

@media (hover: hover) {
  /* 鼠标移到画面上时才稍微亮一点，平时不抢地球的注意力 */
  body:hover .site-credit {
    color: rgba(232, 238, 246, 0.5);
  }
}

/* 第 6 步：自转倍速控件（右下角，让开底部时间轴 64px / 手机 56px + 安全区） */
.speed-control {
  position: fixed;
  right: 14px;
  bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 12px);
  z-index: 25;
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(10, 16, 24, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.speed-control__btn {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  border: 0;
  background: transparent;
  color: rgba(232, 238, 246, 0.62);
  font-family: var(--font);
  font-size: 12px;
  line-height: 1;
  padding: 7px 10px;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.speed-control__btn:hover {
  color: #e8eef6;
  background: rgba(255, 255, 255, 0.08);
}

.speed-control__btn[aria-pressed="true"] {
  color: #06231f;
  background: var(--accent);
  font-weight: 600;
}

.speed-control__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 768px) {
  .speed-control {
    right: 10px;
    bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 10px);
  }

  .speed-control__btn {
    font-size: 11px;
    padding: 6px 8px;
  }

  .site-credit {
    left: 10px;
    bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 8px);
    max-width: min(74vw, 360px);
    font-size: 10px;
    line-height: 1.45;
  }
}

/* 首屏加载层（main.js 首帧后加 .is-hidden 淡出；pointer-events:none 保证不挡任何交互）
   只在地球还没出来时出现，正常情况下很短，别在这里堆花哨动效 */
#loading {
  position: fixed;
  inset: 0;
  z-index: 60; /* 盖住画布 / 时间轴 / 卡片 / 右下角控件 */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--bg);
  opacity: 1;
  pointer-events: none;
  transition: opacity 0.45s ease;
}

#loading.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.loading__text {
  color: rgba(232, 238, 246, 0.62);
  font-family: var(--font);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.loading__bar {
  width: 132px;
  height: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.loading__bar i {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  animation: loading-slide 1.1s ease-in-out infinite;
}

@keyframes loading-slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(360%); }
}

@media (prefers-reduced-motion: reduce) {
  .loading__bar i { animation-duration: 2.8s; }
}

/* ?debug=1 专用：屏上计时条（手机看不到控制台时直接读数字；正常访问不出现）
   位置在时间轴上方居中，别和左下署名 / 右下倍速抢地方 */
.debug-timings {
  position: fixed;
  left: 50%;
  bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 10px);
  transform: translateX(-50%);
  z-index: 50;
  max-width: 92vw;
  margin: 0;
  padding: 7px 11px;
  border-radius: 8px;
  background: rgba(8, 12, 18, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(232, 238, 246, 0.82);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.55;
  white-space: pre;
  pointer-events: none;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

@media (max-width: 768px) {
  .debug-timings {
    bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 8px);
    font-size: 10px;
    padding: 6px 9px;
  }
}

/* 右上角「看数据」按钮：点一下显示/收起加载计时面板（不依赖网址参数） */
.debug-toggle {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: 10px;
  z-index: 46;
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(10, 16, 24, 0.55);
  color: rgba(232, 238, 246, 0.78);
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.3;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.debug-toggle:active {
  background: rgba(79, 209, 197, 0.22);
  color: #e8eef6;
}

/* 画质档位按钮：排在「看数据」下面一行 */
.debug-toggle--quality {
  top: calc(env(safe-area-inset-top, 0px) + 50px);
}

.debug-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* v1.1.0 手测修正（2026-11-11 用户要求）：「看数据」「画质」不再浮在右上角压住卡片图，
   改挂到左侧搜索面板下面，排成一行小按钮（位置由 main.js 挂进 .explore 后自然流式排列） */
.ui-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  pointer-events: auto;
}

.debug-toggle--inline {
  position: static;
  top: auto;
  right: auto;
  margin: 0;
  padding: 6px 10px;
  font-size: 11.5px;
  z-index: auto;
}

.debug-toggle--quality.debug-toggle--inline {
  top: auto;
}
