/* ============================================================
   鹈鹕骑行 · Pelican on a Bicycle
   视觉语言：黄昏海岛 / 暖琥珀 × 深海青 / 编辑式排版
   层级：画布 < 颗粒层 < HUD 面板
   ============================================================ */

:root {
  /* 调色板 —— 与 3D 场景的光照保持同一色系 */
  --ink:        #06131a;
  --ink-2:      #0b1f29;
  --teal:       #0e3b45;
  --teal-lift:  #17505c;
  --sand:       #f2e4cd;
  --amber:      #ffb347;
  --amber-hot:  #ff8c42;
  --coral:      #ff6b6b;
  --aqua:       #6fd8d0;

  --fg:         rgba(242, 228, 205, 0.94);
  --fg-dim:     rgba(242, 228, 205, 0.58);
  --fg-faint:   rgba(242, 228, 205, 0.28);

  --glass:      rgba(6, 22, 29, 0.42);
  --glass-line: rgba(242, 228, 205, 0.16);

  --hair: 1px;
  --r: 14px;
  --pad: 16px;

  --f-display: "Cormorant Garamond", "Noto Serif SC", serif;
  --f-body:    "Noto Serif SC", "Cormorant Garamond", serif;
  --f-mono:    "JetBrains Mono", ui-monospace, "SF Mono", monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--fg);
  font-family: var(--f-body);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- 画布 ---------- */
#stage { position: fixed; inset: 0; }
#scene { display: block; width: 100%; height: 100%; touch-action: none; }

/* 场景边缘的柔和暗角，把视线收进画面中心 */
#stage::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 45%, transparent 42%, rgba(3, 10, 14, 0.55) 100%);
  z-index: 2;
}

/* ---------- 胶片颗粒 ---------- */
.grain {
  position: fixed; inset: -50%;
  pointer-events: none;
  z-index: 3;
  opacity: 0.055;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
  animation: grainShift 6s steps(6) infinite;
}
@keyframes grainShift {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-3%, 2%); }
  40%  { transform: translate(2%, -3%); }
  60%  { transform: translate(-2%, -2%); }
  80%  { transform: translate(3%, 1%); }
  100% { transform: translate(0, 0); }
}

/* ---------- 通用玻璃面板 ---------- */
.panel {
  position: fixed;
  z-index: 10;
  background: var(--glass);
  border: var(--hair) solid var(--glass-line);
  border-radius: var(--r);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  box-shadow:
    0 18px 48px -22px rgba(0, 0, 0, 0.9),
    inset 0 1px 0 rgba(242, 228, 205, 0.07);
}

/* ---------- 标题卡 ---------- */
.titlecard {
  position: fixed;
  z-index: 10;
  top: clamp(18px, 4vh, 46px);
  left: clamp(18px, 4vw, 56px);
  max-width: min(52vw, 460px);
  pointer-events: none;
  animation: riseIn 1.1s var(--ease) 0.25s both;
}
.titlecard__rule {
  width: 46px; height: 2px;
  background: linear-gradient(90deg, var(--amber), transparent);
  margin-bottom: 14px;
}
.titlecard h1 {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: clamp(34px, 5.6vw, 74px);
  line-height: 0.98;
  letter-spacing: 0.06em;
  background: linear-gradient(178deg, #fff7e8 8%, var(--sand) 42%, var(--amber) 108%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 22px rgba(255, 140, 66, 0.22));
}
.titlecard__en {
  margin: 10px 0 0;
  font-family: var(--f-display);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(13px, 1.5vw, 19px);
  letter-spacing: 0.16em;
  color: var(--fg-dim);
}
.titlecard__sub {
  margin: 6px 0 0;
  font-family: var(--f-mono);
  font-size: 10.5px;
  font-weight: 300;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

/* ---------- 遥测面板 ---------- */
.panel--telemetry {
  top: clamp(18px, 4vh, 46px);
  right: clamp(18px, 4vw, 56px);
  width: 248px;
  padding: 13px 15px 10px;
  animation: riseIn 1.1s var(--ease) 0.45s both;
}
.panel__head {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--f-mono);
  font-size: 10px; font-weight: 500;
  letter-spacing: 0.28em;
  color: var(--fg-dim);
  padding-bottom: 9px;
  border-bottom: var(--hair) solid var(--glass-line);
}
.dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--aqua);
  box-shadow: 0 0 0 0 rgba(111, 216, 208, 0.7);
  animation: pulse 2.2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(111, 216, 208, 0.55); }
  70%  { box-shadow: 0 0 0 7px rgba(111, 216, 208, 0); }
  100% { box-shadow: 0 0 0 0 rgba(111, 216, 208, 0); }
}

.rows { padding: 9px 0 6px; }
.row {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 11.5px;
  padding: 3.5px 0;
}
.row > span {
  color: var(--fg-faint);
  letter-spacing: 0.22em;
  font-size: 10.5px;
}
.row > b {
  font-family: var(--f-mono);
  font-weight: 400;
  font-size: 12.5px;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.row > b > i { font-style: normal; }
/* 数值变化时由 JS 触发的高亮 */
.row > b.flash { color: var(--amber); }

.spark {
  margin-top: 8px;
  padding-top: 8px;
  border-top: var(--hair) solid var(--glass-line);
}
#sparkline { display: block; width: 100%; height: 34px; }

/* ---------- 操作提示 ---------- */
.hints {
  position: fixed;
  z-index: 10;
  left: clamp(18px, 4vw, 56px);
  bottom: clamp(18px, 4vh, 42px);
  animation: riseIn 1.1s var(--ease) 0.65s both;
}
.hints__head {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--fg-faint);
  margin-bottom: 9px;
}
.hints ul {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 5px;
}
.hints li {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px;
  color: var(--fg-dim);
}
.hints li span { margin-left: 5px; letter-spacing: 0.08em; }
kbd {
  font-family: var(--f-mono);
  font-size: 10px;
  min-width: 20px;
  padding: 2.5px 5px;
  text-align: center;
  color: var(--fg);
  background: rgba(242, 228, 205, 0.07);
  border: var(--hair) solid var(--glass-line);
  border-bottom-width: 2px;
  border-radius: 5px;
  line-height: 1;
}

/* ---------- 按钮组 ---------- */
.controls {
  position: fixed;
  z-index: 10;
  right: clamp(18px, 4vw, 56px);
  bottom: clamp(18px, 4vh, 42px);
  display: flex; gap: 8px;
  animation: riseIn 1.1s var(--ease) 0.8s both;
}
.controls button {
  all: unset;
  cursor: pointer;
  width: 60px;
  padding: 9px 0 7px;
  text-align: center;
  border: var(--hair) solid var(--glass-line);
  border-radius: 11px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: border-color 0.35s var(--ease), transform 0.35s var(--ease), background 0.35s var(--ease);
}
.controls button .ico {
  display: block;
  font-size: 15px;
  line-height: 1;
  color: var(--fg-dim);
  transition: color 0.35s var(--ease), transform 0.5s var(--ease);
}
.controls button em {
  display: block;
  font-style: normal;
  font-size: 9.5px;
  letter-spacing: 0.2em;
  margin-top: 5px;
  color: var(--fg-faint);
}
.controls button:hover {
  border-color: rgba(255, 179, 71, 0.5);
  background: rgba(255, 179, 71, 0.08);
  transform: translateY(-2px);
}
.controls button:hover .ico { color: var(--amber); }
.controls button:active { transform: translateY(0) scale(0.96); }
.controls button.on {
  border-color: rgba(111, 216, 208, 0.55);
  background: rgba(111, 216, 208, 0.1);
}
.controls button.on .ico { color: var(--aqua); }
.controls button:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ---------- 加载器 ---------- */
.loader {
  position: fixed; inset: 0;
  z-index: 40;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  background:
    radial-gradient(90% 70% at 50% 40%, #12313c 0%, var(--ink) 70%);
  transition: opacity 0.9s var(--ease), visibility 0.9s;
}
.loader.gone { opacity: 0; visibility: hidden; }
.loader__bird {
  font-size: 44px;
  filter: saturate(0.4) brightness(1.4);
  animation: bob 2.4s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-12px) rotate(3deg); }
}
.loader__bar {
  width: min(46vw, 320px);
  height: 2px;
  background: rgba(242, 228, 205, 0.14);
  border-radius: 2px;
  overflow: hidden;
}
.loader__bar > i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--aqua), var(--amber));
  transition: width 0.45s var(--ease);
}
.loader__text {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.26em;
  color: var(--fg-dim);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  z-index: 30;
  left: 50%; bottom: clamp(96px, 13vh, 140px);
  transform: translate(-50%, 14px);
  padding: 9px 20px;
  font-family: var(--f-mono);
  font-size: 11.5px;
  letter-spacing: 0.18em;
  color: var(--sand);
  background: rgba(6, 22, 29, 0.72);
  border: var(--hair) solid var(--glass-line);
  border-radius: 999px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 隐藏全部 UI ---------- */
body.bare .titlecard,
body.bare .panel,
body.bare .hints,
body.bare .controls,
body.bare .grain { opacity: 0; visibility: hidden; transition: opacity 0.4s var(--ease); }

/* ---------- 入场动画 ---------- */
@keyframes riseIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- lil-gui 主题覆写 ---------- */
.lil-gui {
  --background-color: rgba(6, 22, 29, 0.72);
  --widget-color: rgba(242, 228, 205, 0.09);
  --hover-color: rgba(255, 179, 71, 0.22);
  --focus-color: rgba(255, 179, 71, 0.3);
  --text-color: var(--fg);
  --title-background-color: rgba(255, 179, 71, 0.14);
  --font-family: var(--f-mono);
  --font-size: 11px;
  --width: 262px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: var(--hair) solid var(--glass-line);
  border-radius: 12px;
  overflow: hidden;
  z-index: 20 !important;
}
.lil-gui.root { top: 14px; right: 14px; }

/* ---------- 无障碍 / 降级 ---------- */
.noscript {
  position: fixed; inset: 0;
  display: grid; place-content: center;
  background: var(--ink); color: var(--fg);
  font-size: 14px; letter-spacing: 0.1em;
}

@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .loader__bird { animation: none; }
  .dot { animation: none; }
  .titlecard, .panel--telemetry, .hints, .controls { animation: none; }
}

/* 窄屏：把面板收起来，只保留按钮组 */
@media (max-width: 780px) {
  .panel--telemetry { display: none; }
  .hints { display: none; }
  .titlecard h1 { font-size: clamp(28px, 9vw, 44px); }
  .controls button { width: 52px; }
}
