/* 选车 /garage.php —— 3D 车型配置器。沿用 site.css 的浅色 teal 主题变量。 */

.garage-layout {
  display: grid;
  grid-template-columns: 1.6fr 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-sm);
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 62% 18%, #ffffff 0%, #eef7f6 46%, #dfeef0 100%);
}
.garage-canvas {
  display: block;
  width: 100%;
  height: 460px;
  touch-action: none;      /* 拖拽轨道时不滚动页面 */
  cursor: grab;
}
.garage-canvas:active { cursor: grabbing; }
/* ★ 同 .garage-fallback：作者的 display:block 会盖过 UA 的 [hidden]{display:none}。 */
.garage-canvas[hidden] { display: none; }

.garage-presets {
  position: absolute;
  top: 12px; left: 12px;
  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; }

.garage-hud {
  position: absolute;
  top: 12px; right: 12px;
  font: 11.5px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--teal-d); background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(8px);
  padding: 7px 11px; border-radius: var(--r-md); box-shadow: var(--shadow-sm);
  min-width: 108px;
}
.garage-hud .row { display: flex; justify-content: space-between; gap: 12px; }
.garage-hud .row b { font-weight: 700; }

/* ── CAD 热点（投影到屏幕的 ping）─────────────────────── */
.garage-hotspots { position: absolute; inset: 0; 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; left: 12px; bottom: 12px;
  width: min(310px, calc(100% - 24px));
  padding: 12px 14px;
  background: rgba(255, 255, 255, .93);
  backdrop-filter: blur(10px);
  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;
  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; }

/* ── 配置抽屉 ────────────────────────────────────────── */
.garage-drawer {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 14px;
}
.garage-drawer .tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.garage-drawer .tab {
  border: 0; cursor: pointer; font: inherit; font-size: 12.5px;
  padding: 6px 14px; border-radius: var(--r-pill);
  background: var(--teal-050); color: var(--teal-d);
}
.garage-drawer .tab.on { background: var(--teal-d); color: #fff; font-weight: 700; }
.garage-drawer .tabpanel h3 { font-size: 12px; color: var(--muted); font-weight: 600; margin: 0 0 8px; letter-spacing: .04em; }
.garage-drawer .tabpanel h3 + .swatches { margin-bottom: 16px; }
.garage-drawer .drawer-foot { margin: 12px 0 0; font-size: 11.5px; }

.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); }

/* 推荐尺码行 */
.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);
  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); }

/* ── 动态控制（滑块 / 开关）──────────────────────────── */
.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%; accent-color: var(--teal-d); margin: 0; }
.ctrl .ctrl-v {
  text-align: right; font: 11.5px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--teal-d);
}
.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);
}
.toggle.on { background: var(--teal-d); border-color: var(--teal-d); color: #fff; font-weight: 700; }

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