/* 选车 /garage.php —— 3D 车型配置器（浅色版）。
   沿用 site.css 浅色 teal 主题：白玻璃面板 + teal 药丸按钮环绕全宽 3D 舞台。
   renderer 是 alpha 透明底 → 舞台的浅色渐变直接透过画布显示，3D 区即浅色。 */

.garage-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
  margin-top: 14px;
}

/* ── 3D 舞台 ─────────────────────────────────────────── */
.garage-stage {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  background:
    radial-gradient(120% 95% at 62% 16%, #ffffff 0%, #eaf3f3 42%, #b7ccce 72%, #96b1b4 100%);
}

.garage-canvas {
  display: block;
  position: relative;
  z-index: 0;
  width: 100%;
  height: 680px;
  touch-action: none;      /* 拖拽轨道时不滚动页面 */
  cursor: grab;
}
.garage-canvas:active { cursor: grabbing; }
/* ★ 同 .garage-fallback：作者的 display:block 会盖过 UA 的 [hidden]{display:none}。 */
.garage-canvas[hidden] { display: none; }

/* ── 相机预设（.edge-tc 顶端中央横排内流式布局）─────── */
.garage-presets {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.garage-presets .preset {
  border: 0; cursor: pointer; font: inherit; font-size: 12px;
  padding: 5px 11px; border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .82); color: var(--teal-d);
  box-shadow: var(--shadow-sm);
  transition: background .16s ease, color .16s ease;
}
.garage-presets .preset:hover { background: #fff; }
.garage-presets .preset.on { background: var(--teal-d); color: #fff; font-weight: 700; }

/* 遥测：右上角单层常驻指标卡（无标签/无折叠）——置于 .edge-right-stack 内 */
.garage-hud {
  position: relative;
  pointer-events: none;
  font: 11px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--body);
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  padding: 7px 11px 8px;
  min-width: 132px;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.garage-hud::before {
  content: "TEL";
  display: block;
  font-size: 9px;
  letter-spacing: .18em;
  color: var(--muted);
  margin-bottom: 4px;
}
.garage-hud .row {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 1px 0;
}
.garage-hud .row span { color: var(--muted); }
.garage-hud .row b {
  font-weight: 700; color: var(--teal-d);
  font-variant-numeric: tabular-nums;
}

/* ── CAD 热点（投影到屏幕的 ping）─────────────────────── */
.garage-hotspots { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.garage-hotspots .ping {
  position: absolute; display: block;
  pointer-events: auto;            /* 容器 pointer-events:none，只有 ping 可点 */
  width: 24px; height: 24px; padding: 0; border: 0; cursor: pointer;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 255, 255, .9);
  color: var(--teal-d);
  font: 700 11px/24px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  text-align: center;
  box-shadow: 0 0 0 1px rgba(78, 205, 196, .55), var(--shadow-sm);
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
/* ★ 作者样式会盖过 UA 的 [hidden]{display:none}，必须显式复位。 */
.garage-hotspots .ping[hidden] { display: none; }
.garage-hotspots .ping::after {
  content: ""; position: absolute; inset: -6px;
  border-radius: 50%; border: 1.5px solid var(--teal);
  animation: garage-ping 2.4s ease-out infinite;
}
.garage-hotspots .ping:hover, .garage-hotspots .ping.on { background: var(--teal-d); color: #fff; }
@keyframes garage-ping {
  0%   { transform: scale(.7); opacity: .85; }
  70%  { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1.5); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .garage-hotspots .ping::after { animation: none; opacity: .5; }
}

/* ── CAD 规格卡（点热点后浮出）───────────────────────── */
.garage-cad {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 5;
  width: min(310px, calc(100% - 24px));
  padding: 12px 14px;
  background: rgba(255, 255, 255, .93);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  font-size: 12px; color: var(--body);
}
.garage-cad[hidden] { display: none; }
.garage-cad .cad-code {
  display: inline-block; margin-right: 6px;
  font: 700 10.5px/1.6 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--teal-d);
}
.garage-cad .cad-cat { font-size: 10.5px; color: var(--muted); letter-spacing: .04em; }
.garage-cad h4 { margin: 3px 0 5px; font-size: 13.5px; color: var(--ink); }
.garage-cad p { margin: 0 0 9px; line-height: 1.6; color: var(--muted); }
.garage-cad dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; }
.garage-cad dt { color: var(--muted); }
.garage-cad dd { margin: 0; text-align: right; font-weight: 700; color: var(--ink); }
.garage-cad .cad-close {
  position: absolute; top: 7px; right: 8px;
  border: 0; background: none; cursor: pointer; font: inherit;
  color: var(--muted); font-size: 15px; line-height: 1; padding: 3px;
}
.garage-cad .cad-close:hover { color: var(--ink); }

.garage-fallback {
  position: absolute; inset: 0;
  z-index: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; text-align: center; color: var(--muted); font-size: 13px;
}
/* ★ 作者样式 display:flex 会盖过 UA 的 [hidden]{display:none}，必须显式复位，
   否则降级文案永远盖在 3D 上（看上去像「不支持 WebGL」，其实车就在底下）。 */
.garage-fallback[hidden] { display: none; }
/* 失败原因（技术信息，回报用）；同样必须显式复位 [hidden]。 */
.garage-fallback small {
  display: block; margin-top: 7px; font-size: 11.5px; opacity: .72;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  word-break: break-word;
}
.garage-fallback small[hidden] { display: none; }

/* ── 舞台边缘：标签药丸 + 弹出面板 ─────────────────────
   容器必须 pointer-events:none —— 否则整层浮在画布上，轨道拖拽/缩放就全废了；
   只有标签与面板自身开回 auto，吃事件。 */
.garage-edge {
  position: absolute; inset: 0;
  z-index: 3;
  pointer-events: none;
}
.edge-slot { position: absolute; pointer-events: auto; }
/* 右上叠放（TEL）：独立于 .garage-edge，始终贴画布右上 */
.edge-right-stack {
  position: absolute;
  top: 14px; right: 14px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

/* 标签：白玻璃药丸（同全站 .tab / nav 药丸语感） */
.edge-tag {
  position: relative;
  border: 1px solid rgba(255, 255, 255, .9);
  cursor: pointer; font: inherit;
  font-size: 12.5px; font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .85);
  color: var(--teal-d);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  transition: background .16s ease, color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.edge-tag:hover {
  background: #fff;
  border-color: var(--teal);
  transform: translateY(-1px);
}
.edge-tag:focus-visible {
  outline: 2px solid var(--teal-d);
  outline-offset: 2px;
}
.edge-tag.on {
  background: var(--teal-d);
  border-color: var(--teal-d);
  color: #fff;
  font-weight: 700;
}
/* 常开模块保持浅色描边态（不填实也能读出 ACTIVE） */
.edge-tag.static.on {
  background: rgba(78, 205, 196, .16);
  color: var(--teal-d);
  border-color: var(--teal);
}

.edge-pop {
  position: absolute;
  /* 半透明底：打开时能透视到车身 */
  background: linear-gradient(165deg, rgba(255, 255, 255, .72), rgba(255, 255, 255, .62));
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  padding: 14px;
  /* ★ 不能用 100%：绝对定位的 containing block 是 .edge-slot（只有标签按钮那么宽），
     calc(100% - 24px) 会缩成 ~30px，中文全竖排撑到 1100px 高。 */
  width: min(320px, calc(100vw - 48px));
  font-size: 12px;
  color: var(--body);
}
/* ★ 作者样式会盖过 UA 的 [hidden]{display:none}，必须显式复位 —— 同 .garage-fallback 的老坑。 */
.edge-pop[hidden] { display: none; }
.edge-pop h3 {
  font-size: 12px; color: var(--muted); font-weight: 600;
  margin: 0 0 8px; letter-spacing: .04em;
}
.edge-pop h3 + .swatches { margin-bottom: 16px; }
.edge-pop .hint { font-size: 11.5px; color: var(--muted); }
.drawer-foot { margin: 12px 0 0; font-size: 11.5px; color: var(--muted); }

/* 槽位锚点：面板一律朝舞台中心开，避免被 .garage-stage{overflow:hidden} 裁掉。
   顶端中央=视角 7 按钮横排（.edge-tc）；右上=TEL（.edge-right-stack）；
   左侧=涂装/轮组/尺码（弹窗朝右开，不盖下方标签）；右下=动态；左下=规格。 */
.edge-tc {
  top: 12px;
  /* 两侧让开：左=边缘标签列，右=TEL 宽度；在此盒内居中排布 */
  left: 70px; right: 170px;
  display: flex; flex-wrap: wrap;
  justify-content: center; align-items: center;
  gap: 6px;
}
.edge-lu { left: 12px; }
/* 顶端按钮带（最多两行 ~90px）下方起排 */
.edge-lu1 { top: 96px; }
.edge-lu2 { top: 140px; }
.edge-lu3 { top: 184px; }
.edge-br { right: 12px; bottom: 12px; }   /* 动态 */
.edge-bl { left: 12px; bottom: 12px; }    /* 规格 */

/* 面板相对自己的标签展开（涂装/轮组/尺码朝右 → 朝舞台中心，不盖下方标签） */
.edge-lu .edge-pop { top: 0; left: calc(100% + 8px); }
.edge-bl .edge-pop { bottom: calc(100% + 8px); left: 0; }

/* 动态：画布底缘一行、右对齐 —— 3 滑块横排，无标题（只占底部一条，压车最少） */
.edge-br {
  display: flex; align-items: center; gap: 8px;
}
.edge-br .edge-pop {
  position: static;
  width: auto; padding: 6px 10px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
  justify-content: flex-end;
}
.edge-br .ctrl {
  display: flex; align-items: center; gap: 6px;
  grid-template-columns: none;
  margin-bottom: 0;
  font-size: 11px;
}
.edge-br .ctrl input[type="range"] { width: 84px; flex: none; }
/* 数字预留最大位数（-25°/100% 4 字符）—— 位数增减不再挤动滑块 */
.edge-br .ctrl .ctrl-v { width: 38px; flex: none; }

.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(98px, 1fr));
  gap: 8px;
}
.swatch {
  position: relative;
  height: 58px;
  border: 2px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  padding: 6px 8px;
  display: flex; flex-direction: column; justify-content: flex-end;
  text-align: left; font: inherit;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.swatch.on { border-color: var(--teal-d); box-shadow: 0 0 0 2px rgba(78, 205, 196, .4); }
.swatch-name { font-size: 12px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .55); }
.swatch-sub { font-size: 10.5px; color: rgba(255, 255, 255, .92); text-shadow: 0 1px 3px rgba(0, 0, 0, .55); }
/* 轮组象形：正视轮子瓦片（框高∝rimDepthMm 由内联 SVG 表达）
   3 列并排（#swWheels 压过 auto-fill）—— 三档框高横着扫一眼即可对比 */
#swWheels { grid-template-columns: repeat(3, 1fr); }
.swatch-wheel {
  height: 104px;
  background: rgba(9, 26, 34, .06);   /* 浅灰蓝底：托住深色轮形 SVG */
  justify-content: flex-end;
  gap: 3px;
  padding: 6px 4px;
}
.swatch-wheel .wheel-ico { display: block; width: 100%; height: 56px; margin-bottom: auto; }
.swatch-wheel .swatch-name { text-shadow: none; color: var(--ink); }
.swatch-wheel .swatch-sub { white-space: nowrap; font-size: 10px; text-shadow: none; color: var(--muted); }

/* 推荐尺码行（页面下方浅色表格 —— 保持全站一致） */
.grid tr.is-match { background: var(--teal-100); font-weight: 700; }
.grid tr.is-match:hover { background: var(--teal-100); }
.grid tbody tr { cursor: pointer; }
.grid tbody tr.is-current { outline: 2px solid var(--teal-d); outline-offset: -2px; }

/* ── 尺码档位（选车）──────────────────────────────────── */
.size-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.size-chip {
  border: 1px solid var(--line); cursor: pointer; font: inherit; font-size: 12.5px;
  padding: 6px 12px; border-radius: var(--r-pill);
  background: var(--card); color: var(--body);
  letter-spacing: .04em;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.size-chip:hover { border-color: var(--teal); }
.size-chip.on {
  background: var(--teal-d); border-color: var(--teal-d); color: #fff; font-weight: 700;
}
.size-chip.match {
  border-color: var(--teal);
  box-shadow: inset 0 0 0 1px var(--teal);
}
.size-chip.on.match {
  color: #fff;
  box-shadow: none;
  border-color: var(--teal-d);
}

/* ── 动态控制（滑块 / 开关）──────────────────────────── */
.ctrl {
  display: grid; grid-template-columns: 58px 1fr 52px;
  align-items: center; gap: 9px; margin-bottom: 11px;
  font-size: 12px; color: var(--muted);
}
.ctrl input[type="range"] {
  width: 100%; margin: 0;
  height: 18px; padding: 0;          /* 压过 app.css 全局 input padding —— 行高 32→18 */
  accent-color: var(--teal-d);
  cursor: pointer;
}
.ctrl .ctrl-v {
  text-align: right; font: 11.5px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--teal-d);
  font-variant-numeric: tabular-nums;
}
.toggles { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.toggle {
  border: 1px solid var(--line); cursor: pointer; font: inherit; font-size: 12.5px;
  padding: 6px 13px; border-radius: var(--r-pill);
  background: var(--card); color: var(--body);
  letter-spacing: .04em;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.toggle:hover { border-color: var(--teal); }
.toggle.on {
  background: var(--teal-d); border-color: var(--teal-d); color: #fff; font-weight: 700;
}

/* 面板内结果表（尺码几何 / 规格）—— 浅色读法 */
.edge-pop .result th,
.edge-pop .result td { border-bottom-color: var(--line); }
.edge-pop .result th { color: var(--muted); font-weight: 500; }
.edge-pop .result td { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }

@media (max-width: 820px) {
  .garage-layout { grid-template-columns: 1fr; }
  .garage-canvas { height: 340px; }

  /* 窄屏：可折叠标签下沉到画布下方成药丸行（TEL 叠放除外），面板整宽展开 —— 绝不遮车。
     选择器写成 .garage-edge .edge-* 才压得过桌面锚点（同特异性靠源顺序）。 */
  .garage-edge {
    position: static;
    inset: auto;
    z-index: auto;
    pointer-events: auto;
    display: flex; flex-wrap: wrap; gap: 8px;
    padding: 10px 12px 12px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
  }
  .garage-edge .edge-slot {
    position: static;
    transform: none;
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  }
  /* 四个标签槽拆成独立 flex 项（display:contents）→ 涂装/轮组/尺码/规格恒排一行；
     面板靠 order 统一沉到标签行之后、整宽展开 —— 开合不再挤散标签行 */
  .garage-edge .edge-lu,
  .garage-edge .edge-bl { display: contents; }
  .garage-edge .edge-tag { order: 1; }
  .garage-edge .edge-pop {
    order: 2;
    position: static;
    transform: none;
    flex-basis: 100%;
    width: 100%;
    margin-top: 6px;
  }
  .garage-cad { width: min(310px, calc(100% - 24px)); }
  /* 右上只剩 TEL 仍贴画布；动态/规格都在药丸行里（动态面板随行展开在画布下方） */
  .edge-right-stack { top: 8px; right: 8px; }
  .garage-hud { min-width: 0; padding: 6px 9px 7px; font-size: 10.5px; }
  .garage-hud::before { letter-spacing: .14em; }
}

@media (prefers-reduced-motion: reduce) {
  .edge-tag, .edge-pop, .preset, .size-chip, .toggle, .swatch { transition: none; }
}
