/* ============================================================
   站点门户 · Kinetic Gallery（瓷白展廊 · 弹珠站点名称场）
   - 背景：瓷白 + 极低透明度光晕 + 点阵网格
   - 色彩预算全部留给弹珠名称，页面其余部分保持近单色纪律
   ============================================================ */

:root {
  --bg: #f6f7fb;
  --ink: #0f172a;
  --ink-muted: #475569;
  --line: #e2e8f0;
  --surface: rgba(255, 255, 255, 0.92);
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --success: #10b981;
  --font-display: Georgia, "Times New Roman", "Songti SC", "Noto Serif SC", "SimSun", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --field-top: 96px;
  --field-bottom: 88px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(640px 420px at 12% -8%, rgba(99, 102, 241, 0.07), transparent 60%),
    radial-gradient(560px 400px at 96% 18%, rgba(16, 185, 129, 0.07), transparent 60%),
    radial-gradient(620px 460px at 50% 112%, rgba(244, 63, 94, 0.05), transparent 60%),
    radial-gradient(rgba(15, 23, 42, 0.05) 1px, transparent 1.2px);
  background-size: auto, auto, auto, 24px 24px;
  overflow: hidden;
}

/* ---------- 页眉 ---------- */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.75rem 2rem 0;
  animation: rise 0.6s ease both;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.brand-eyebrow {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.brand-name {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.count-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink-muted);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
  white-space: nowrap;
}

.count-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2.4s ease-in-out infinite;
}

/* ---------- 弹珠场（全屏自由区） ---------- */

#field {
  position: fixed;
  inset: var(--field-top) 0 var(--field-bottom) 0;
  overflow: hidden;
  touch-action: manipulation; /* 双击缩放会让 dblclick 失效 */
}

/* 名称弹珠：颜色 / 字号由 JS 内联驱动，碰壁时平滑过渡 */
.marble {
  position: absolute;
  top: 0;
  left: 0;
  appearance: none;
  border: 0;
  background: transparent;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  white-space: nowrap;
  padding: 0.12em 0.3em;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  will-change: transform;
  transition: color 0.35s ease, font-size 0.35s ease, filter 0.25s ease;
  animation: marble-in 0.5s ease both;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.65);
}

.marble:hover,
.marble:focus-visible {
  filter: drop-shadow(0 8px 16px rgba(15, 23, 42, 0.16));
}

.marble:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
  border-radius: 8px;
}

/* 中文站名弹珠：同款衬线粗体但不倾斜（中文斜体观感差） */
.marble--cn {
  font-style: normal;
  letter-spacing: 0.04em;
}

/* ---------- 碰撞炸毁粒子（WAAPI 驱动，结束即移除） ---------- */

.shard {
  position: absolute;
  z-index: 5;
  border-radius: 1px;
  pointer-events: none;
  will-change: transform, opacity;
}

.shockwave {
  position: absolute;
  z-index: 5;
  width: 120px;
  height: 120px;
  border: 2px solid;
  border-radius: 50%;
  pointer-events: none;
  will-change: transform, opacity;
}

/* 受击小号冲击波（角色撞飞弹珠瞬间） */
.shockwave--mini {
  width: 64px;
  height: 64px;
  border-width: 1.5px;
}

/* 击飞态弹珠：高速漂移 + 超速自转的动感 */
.marble--knocked {
  filter: blur(0.6px) drop-shadow(0 10px 18px rgba(15, 23, 42, 0.28));
}

/* ---------- 跑步角色（装饰性实体，不拦截鼠标） ---------- */

.runner {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3; /* 置于弹珠与碎片之下，重叠瞬间文字始终可读 */
  height: clamp(56px, 9vh, 84px);
  width: auto;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  will-change: transform;
  filter: drop-shadow(0 6px 10px rgba(15, 23, 42, 0.18));
  transition: opacity 0.3s ease, filter 0.3s ease;
}

/* 休整态（双击触发）：轻微降饱和降不透明度示意原地休息 */
.runner--frozen {
  opacity: 0.72;
  filter: grayscale(0.45) drop-shadow(0 4px 8px rgba(15, 23, 42, 0.14));
}

/* 减少动态偏好：静态流式陈列，点击查看详情功能保留 */
#field.field--static {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: center;
  justify-content: center;
  gap: clamp(1.25rem, 4vw, 3rem) clamp(1.5rem, 5vw, 4rem);
  padding: 0 1.5rem;
}

#field.field--static .marble {
  position: static;
  will-change: auto;
}

.field-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--ink-muted);
}

.field-status[hidden] {
  display: none;
}

/* ---------- 底部提示胶囊 ---------- */

.hint-pill {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 1.75rem;
  margin-inline: auto;
  width: fit-content;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--surface);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.8125rem;
  color: var(--ink-muted);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
  pointer-events: none;
  white-space: nowrap;
  animation: rise 0.6s 0.15s ease both;
}

.hint-pill svg {
  flex: none;
  color: var(--accent);
}

/* ---------- 站点详情弹窗 ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(246, 247, 251, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
}

.modal-card {
  position: relative;
  width: min(560px, 100%);
  max-height: calc(100dvh - 2.5rem);
  overflow-y: auto;
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2.25rem 2.25rem 2rem;
  box-shadow:
    0 24px 60px -12px rgba(15, 23, 42, 0.2),
    0 4px 16px rgba(15, 23, 42, 0.06);
  animation: modal-in 0.3s ease both;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink-muted);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.modal-close:hover {
  background: #f1f5f9;
  color: var(--ink);
}

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

.modal-eyebrow {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 0.75rem;
  padding-right: 2.5rem;
}

.modal-name {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: clamp(1.6rem, 4.5vw, 2.25rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin-bottom: 0.375rem;
  overflow-wrap: anywhere;
}

.modal-cnname {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.0625rem;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
  margin-bottom: 1rem;
}

.modal-cnname[hidden] {
  display: none;
}

.modal-desc {
  font-size: 0.9375rem;
  line-height: 1.8;
  color: var(--ink-muted);
  margin-bottom: 1.5rem;
}

.modal-meta {
  margin-bottom: 1.75rem;
}

.modal-host {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 100%;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--ink-muted);
  background: #f1f5f9;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
}

.modal-host svg {
  flex: none;
}

.modal-host span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-visit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.8rem 1.25rem;
  background: var(--accent);
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 8px 20px -6px rgba(79, 70, 229, 0.45);
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.modal-visit:hover {
  background: var(--accent-hover);
  box-shadow: 0 10px 24px -6px rgba(79, 70, 229, 0.55);
}

.modal-visit:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- noscript 兜底 ---------- */

.noscript-note {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  text-align: center;
  font-size: 0.95rem;
  color: var(--ink-muted);
  background: var(--bg);
}

/* ---------- 动画 ---------- */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes marble-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- 响应式：手机 / 平板 / 桌面 ---------- */

@media (max-width: 767px) {
  :root {
    --field-top: 76px;
    --field-bottom: 72px;
  }

  .site-header {
    padding: 1.25rem 1.25rem 0;
  }

  .brand-name {
    font-size: 1.125rem;
  }

  .count-badge {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
  }

  .hint-pill {
    bottom: 1.25rem;
    padding: 0.45rem 0.85rem;
    font-size: 0.75rem;
  }

  .modal-card {
    padding: 1.75rem 1.5rem 1.5rem;
    border-radius: 16px;
  }
}

@media (max-height: 560px) {
  :root {
    --field-top: 64px;
    --field-bottom: 56px;
  }

  .hint-pill {
    display: none;
  }
}

/* ---------- 减少动态偏好 ---------- */

@media (prefers-reduced-motion: reduce) {
  .site-header,
  .hint-pill,
  .marble,
  .modal-card {
    animation: none;
  }

  .count-dot {
    animation: none;
  }

  .marble {
    transition: none;
  }
}
