/* 首页组件 —— 令牌 / base / 顶栏 / 页脚见 site.css（本页之前加载）。
   这里只放首页私有布局与组件：滚动条、测量面板、3D 舞台、结果卡、推荐卡、保存区。 */

/* ── 顶部滚动条 ─────────────────────────────────────── */
.ticker { background: #fff; border-bottom: 1px solid var(--line); overflow: hidden; }
.ticker-row { display: flex; align-items: center; height: 34px; font-size: 13px; }
.ticker-row + .ticker-row { border-top: 1px dashed var(--line); }
.ticker-tag {
  flex: none; align-self: stretch; display: flex; align-items: center;
  padding: 0 14px; font-weight: 700; color: #fff; letter-spacing: .04em;
  background: linear-gradient(100deg, var(--teal-d), var(--teal));
  clip-path: polygon(0 0, 100% 0, calc(100% - 12px) 100%, 0 100%);
}
.ticker-row.region .ticker-tag { background: linear-gradient(100deg, var(--coral-d), var(--coral)); }
.ticker-row.model .ticker-tag { background: linear-gradient(100deg, var(--ink), #55706e); letter-spacing: .115em; }
.ticker-view { position: relative; flex: 1; overflow: hidden; height: 100%; }
/* 只钉左/上/高，不钉 right —— 让轨道按内容撑开（max-content），
   translateX(-50%) 才等于「一份文案」的宽度，滚动完整且无缝。 */
.ticker-track {
  position: absolute; top: 0; left: 0; height: 100%; display: flex; align-items: center;
  white-space: nowrap; will-change: transform;
  animation: ticker-scroll 42s linear infinite;   /* 三行统一左行 */
}
.ticker-view:hover .ticker-track { animation-play-state: paused; }
.ticker-track > span { padding: 0 26px; color: var(--body); }
.ticker-track > span b { color: var(--ink); }
.ticker-track > span i { color: var(--coral-d); font-style: normal; font-weight: 700; }
.ticker-track .ticker-link { color: var(--coral-d); font-weight: 700; }
@keyframes ticker-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .ticker-track { animation: none; } }

.region-select {
  flex: none; align-self: center; margin: 0 10px;
  height: 24px; max-width: 150px;
  padding: 0 8px; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: #fff; color: var(--body); font: 600 12px/1 inherit; cursor: pointer;
}
.region-select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(78, 205, 196, .28); }

/* ── 主体 ───────────────────────────────────────────── */
.home {
  max-width: 1240px; margin: 0 auto;
  padding: clamp(14px, 3vw, 28px);
  display: grid; gap: clamp(14px, 2.4vw, 24px);
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr) minmax(0, 1fr);
  grid-template-areas:
    "head   head   head"
    "left   stage  right"
    "expert expert expert"
    "result result result"
    "rec    rec    rec"
    "save   save   save";
  align-items: start;
}
.home-head  { grid-area: head; }
.panel-left { grid-area: left; }
.panel-right{ grid-area: right; }
.panel-expert { grid-area: expert; }
.result-card { grid-area: result; }
.rec-card   { grid-area: rec; }
.save       { grid-area: save; }

.home-head { display: flex; align-items: baseline; gap: 12px; padding: 0 4px; }
.home-head h1 { font-size: clamp(18px, 2.4vw, 22px); margin: 0; }
.home-head .req { font-size: 12.5px; color: var(--muted); margin-left: auto; }

.card {
  --pad: clamp(16px, 2.2vw, 24px);
  background: linear-gradient(180deg, #ffffff, #fbfdfd);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: var(--pad);
}

/* 卡片标题条：teal 渐变 + 白底标题药丸（带青→珊瑚强调点） */
.card-head {
  display: flex; align-items: center; gap: 10px;
  margin: calc(-1 * var(--pad)) calc(-1 * var(--pad)) 0;
  padding: 11px var(--pad);
  background: linear-gradient(100deg, var(--teal-d), var(--teal) 70%, var(--teal-l));
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, .35), 0 6px 18px rgba(30, 120, 115, .12);
}
.card-head .card-title {
  position: relative;
  background: rgba(255, 255, 255, .96); color: var(--teal-d);
  padding: 5px 16px 5px 30px; border-radius: var(--r-pill);
  font-weight: 800; font-size: 13.5px; letter-spacing: .05em;
  box-shadow: 0 4px 12px rgba(20, 80, 80, .12);
}
.card-head .card-title::before {
  content: ""; position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 8px; height: 8px; border-radius: 50%;
  background: linear-gradient(135deg, var(--teal), var(--coral));
}
.card-head .req { margin-left: auto; color: rgba(255, 255, 255, .94); font-size: 12px; }

/* ── 3D 舞台：分层光影 + 悬浮感 ─────────────────────── */
.stage-col { grid-area: stage; align-self: stretch; }
.stage {
  position: sticky; top: 60px;
  overflow: hidden;
  min-height: clamp(380px, 56vh, 620px);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg);
  background:
    radial-gradient(120% 88% at 50% 6%, #ffffff 0%, rgba(255, 255, 255, 0) 44%),
    radial-gradient(90% 70% at 50% 102%, #e3f3f1 0%, rgba(227, 243, 241, 0) 72%),
    linear-gradient(180deg, #f8fdfd, var(--teal-050));
}
/* 舞台中央柔光晕（canvas 之下） */
.stage::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(58% 48% at 50% 44%, rgba(78, 205, 196, .20), transparent 71%);
}
/* 底部承托投影：更实、更悬浮 */
.stage::after {
  content: ""; position: absolute; left: 50%; bottom: 11%;
  width: 50%; height: 30px; transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(30, 120, 115, .26), transparent 74%);
  border-radius: 50%; filter: blur(2px);
  transition: opacity .3s ease;
}
.stage.side::after { opacity: 0; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; display: block; }
/* 测量网格（对照 fitting09）：canvas 之下作技术底纹 */
.stage-grid { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.stage-grid .grid-lines { position: absolute; inset: 0; width: 100%; height: 100%; }
.cg { position: absolute; width: 26px; height: 26px; border: 0 solid rgba(53, 179, 169, .55); }
.cg-tl { top: 12px; left: 12px; border-top-width: 2px; border-left-width: 2px; border-top-left-radius: 8px; }
.cg-tr { top: 12px; right: 12px; border-top-width: 2px; border-right-width: 2px; border-top-right-radius: 8px; }
.cg-bl { bottom: 12px; left: 12px; border-bottom-width: 2px; border-left-width: 2px; border-bottom-left-radius: 8px; }
.cg-br { bottom: 12px; right: 12px; border-bottom-width: 2px; border-right-width: 2px; border-bottom-right-radius: 8px; }
.stage .hero-fallback {
  position: relative; z-index: 2;
  max-width: 92%; max-height: clamp(320px, 52vh, 560px);
  width: auto; height: auto; object-fit: contain;
  filter: drop-shadow(0 18px 30px rgba(20, 80, 80, .18));
}
.stage-hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  z-index: 3; font-size: 12px; color: var(--muted); white-space: nowrap;
}
.stage-focus {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 3; padding: 5px 16px; border-radius: var(--r-pill);
  background: linear-gradient(100deg, var(--coral), var(--coral-d)); color: #fff;
  font-size: 13px; font-weight: 700;
  box-shadow: 0 8px 20px rgba(255, 107, 107, .35);
  opacity: 0; transition: opacity .18s ease;
}
.stage-focus.on { opacity: 1; }

/* ── 测量面板 ───────────────────────────────────────── */
.panel { display: flex; flex-direction: column; }
.panel > * + * { margin-top: 12px; }

/* 专家模式 3×2 网格 */
.expert-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; }
.panel-expert .btn-calc { margin-top: 16px; }

.meas-row {
  display: grid; grid-template-columns: 40px minmax(64px, auto) 1fr;
  align-items: center; gap: 10px;
  padding: 6px 12px 6px 6px;
  border: 1px solid var(--line); border-radius: var(--r-pill);
  background: #fff;
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.meas-row:hover { border-color: var(--teal-100); }
.meas-row:focus-within, .meas-row.active {
  background: var(--teal-100); border-color: var(--teal); box-shadow: var(--shadow-sm);
}

.circle-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #fff; color: var(--teal-d);
  border: 2px solid var(--teal-100); cursor: pointer;
  font-weight: 700; font-size: 13px; font-family: inherit;
  transition: all .16s ease;
}
.circle-btn:hover { background: var(--teal-050); border-color: var(--teal-l); }
.circle-btn.active {
  background: linear-gradient(135deg, var(--coral), var(--coral-d)); color: #fff;
  border-color: var(--teal); box-shadow: 0 0 0 3px rgba(78, 205, 196, .35);
  transform: scale(1.04);
}
.meas-name { font-size: 14px; color: var(--ink); font-weight: 600; white-space: nowrap; }
.meas-name .opt { font-weight: 400; color: var(--muted); font-size: 12px; }

/* 药丸步进 */
.stepper {
  display: flex; align-items: center; justify-self: end;
  background: var(--teal-050); border-radius: var(--r-pill);
  padding: 3px; min-width: 172px;
}
.stepper button {
  width: 34px; height: 34px; flex: none; border-radius: 50%; border: 0;
  background: #fff; color: var(--teal-d); font-size: 20px; line-height: 1;
  cursor: pointer; box-shadow: var(--shadow-sm); font-family: inherit;
  transition: transform .1s ease, background .16s ease;
}
.stepper button:hover { background: var(--teal-100); }
.stepper button:active { transform: scale(.92); }
.stepper .val {
  flex: 1; width: 0; text-align: center; border: 0; background: transparent;
  font: 700 16px/1 inherit; color: var(--ink); min-width: 0; padding: 0 4px;
}
.stepper .val:focus { outline: none; }
.stepper .unit { flex: none; font-size: 12px; color: var(--muted); padding-right: 8px; }

/* 柔韧性 A/B/C */
.seg { display: flex; gap: 6px; justify-self: end; }
.seg label {
  display: flex; align-items: center; gap: 5px; cursor: pointer;
  padding: 7px 14px; border-radius: var(--r-pill);
  background: #fff; border: 1px solid var(--line);
  color: var(--body); font-weight: 600; font-size: 13px;
  transition: all .16s ease; user-select: none;
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:hover { background: var(--teal-050); border-color: var(--teal-l); }
.seg input:checked + span, .seg label:has(input:checked) {
  background: linear-gradient(135deg, var(--coral), var(--coral-d)); color: #fff;
  box-shadow: 0 0 0 3px rgba(78, 205, 196, .35);
}

/* 动作按钮 */
.btn-calc {
  margin-top: 6px; width: 100%; padding: 15px;
  border: 0; border-radius: var(--r-pill); cursor: pointer;
  background: linear-gradient(100deg, var(--coral), var(--coral-d));
  color: #fff; font: 700 16px/1 inherit; letter-spacing: .08em;
  box-shadow: 0 14px 30px rgba(255, 107, 107, .38);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn-calc:hover { transform: translateY(-2px); box-shadow: 0 18px 36px rgba(255, 107, 107, .46); }
.btn-calc:active { transform: translateY(0); }
.btn-calc:disabled { opacity: .55; cursor: default; transform: none; }

/* ── 结果：分栏玻璃面板 ─────────────────────────────── */
.result-card {
  display: grid; gap: 18px;
  grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
  align-items: start;
  background: linear-gradient(180deg, rgba(255, 255, 255, .92), rgba(250, 253, 253, .76));
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.result-card .frame { width: 100%; border-radius: var(--r-md); background: #fff; box-shadow: var(--shadow-sm); }
.result-card > div { padding-left: 18px; border-left: 1px solid var(--line); }
.result-head { color: var(--ink); font-weight: 800; margin-bottom: 10px; }
.result-head::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--coral); margin-right: 8px; vertical-align: 1px; }
table.result { width: 100%; border-collapse: collapse; font-size: 14px; }
table.result th { text-align: left; font-weight: 500; color: var(--muted); padding: 9px 8px; }
table.result td { text-align: right; font-weight: 700; color: var(--ink); padding: 9px 8px; font-variant-numeric: tabular-nums; }
table.result tr + tr th, table.result tr + tr td { border-top: 1px solid var(--line); }
table.result tr { transition: background .14s ease; }
table.result tr:hover th, table.result tr:hover td { background: var(--teal-050); }
.expert-result { margin-top: 6px; }
.notice { font-size: 12.5px; color: var(--muted); background: var(--teal-050); border-radius: var(--r-md); padding: 10px 14px; margin: 12px 0 0; }
.crank-note { font-size: 13px; line-height: 1.65; }
.crank-note p { margin: 0 0 8px; }
.crank-note p:last-child { margin-bottom: 0; }
.crank-title { font-weight: 800; color: var(--ink); margin-bottom: 6px; }
.crank-table-wrap { overflow-x: auto; margin: 8px 0; }
.crank-table { width: 100%; border-collapse: collapse; font-size: 12px; background: #fff; border-radius: var(--r-md); overflow: hidden; }
.crank-table th, .crank-table td { padding: 6px 8px; text-align: center; border: 1px solid var(--line); white-space: nowrap; }
.crank-table thead th, .crank-table tbody th { background: var(--teal-050); color: var(--teal-d); font-weight: 700; }
.crank-table tbody th { text-align: left; }
.crank-en { color: var(--muted); font-size: 12px; font-style: italic; }
.similar { margin-top: 4px; }
.similar-title { font-weight: 700; color: var(--ink); margin-bottom: 6px; font-size: 14px; }
/* 相似记录：每行做成 teal 药丸 */
.similar table.result { border-collapse: separate; border-spacing: 0 6px; }
.similar table.result tr { background: var(--teal-050); }
.similar table.result tr + tr th, .similar table.result tr + tr td { border-top: 0; }
.similar table.result th:first-child { border-radius: var(--r-pill) 0 0 var(--r-pill); padding-left: 14px; }
.similar table.result td:last-child { border-radius: 0 var(--r-pill) var(--r-pill) 0; padding-right: 14px; }

/* 性别：无圆形编号，两列布局（沿用 .meas-row 外观） */
.meas-row.gender-row { grid-template-columns: minmax(64px, auto) 1fr; }

/* 车型推荐 */
.rec-card table.result { margin-bottom: 4px; }
.rec-scroll { overflow-x: auto; margin-top: 10px; }
.rec-scroll table.result { min-width: 640px; margin-bottom: 0; }
.rec-scroll table.result thead th { padding-top: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.rec-scroll table.result thead th:first-child, .rec-scroll table.result tbody td:first-child { text-align: left; }

/* 保存区 */
.save .datatype { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.save .toggle {
  padding: 8px 18px; border-radius: var(--r-pill); border: 1px solid var(--line);
  background: #fff; color: var(--body); cursor: pointer; font-family: inherit; font-size: 14px;
  transition: all .16s ease;
}
.save .toggle:hover { border-color: var(--teal-l); background: var(--teal-050); }
.save .toggle.active { background: linear-gradient(135deg, var(--teal), var(--teal-d)); border-color: var(--teal); color: #fff; }
.save .mods { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 12px 0; }
.save .field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.save .unit { display: flex; align-items: center; gap: 6px; }
.save .unit input { flex: 1; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-md); font: inherit; }
.save .unit input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(78, 205, 196, .28); }
.btn-save { padding: 11px 26px; border: 0; border-radius: var(--r-pill); background: var(--teal); color: #fff; font: 700 15px inherit; cursor: pointer; box-shadow: var(--shadow-sm); transition: background .16s ease, transform .12s ease; }
.btn-save:hover { background: var(--teal-d); transform: translateY(-1px); }
.btn-save:disabled { opacity: .5; cursor: default; transform: none; }
.save-msg { margin-left: 10px; font-size: 13px; }
.save-msg.ok { color: var(--teal-d); }
.save-msg.err { color: var(--coral-d); }
.hint { color: var(--muted); font-size: 13px; }

/* ── 入场动效（尊重 prefers-reduced-motion） ─────────── */
@media (prefers-reduced-motion: no-preference) {
  .home > * { animation: rise .5s cubic-bezier(.2, .7, .3, 1) both; }
  .home > *:nth-child(1) { animation-delay: .02s; }
  .home > *:nth-child(2) { animation-delay: .06s; }
  .home > *:nth-child(3) { animation-delay: .10s; }
  .home > *:nth-child(4) { animation-delay: .14s; }
  .home > *:nth-child(5) { animation-delay: .18s; }
  .home > *:nth-child(6) { animation-delay: .22s; }
  .home > *:nth-child(7) { animation-delay: .26s; }
  .home > *:nth-child(8) { animation-delay: .30s; }
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ── 响应式 ─────────────────────────────────────────── */
@media (max-width: 1100px) {
  /* 两列时单元格变窄，把步进器挪到下一行，避免测量名被挤到截断 */
  .expert-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .expert-grid .meas-row { grid-template-columns: 40px 1fr; grid-template-areas: "ico name" "step step"; row-gap: 6px; border-radius: var(--r-md); padding: 8px; }
  .expert-grid .meas-row .circle-btn { grid-area: ico; }
  .expert-grid .meas-row .meas-name { grid-area: name; }
  .expert-grid .meas-row .stepper, .expert-grid .meas-row .seg { grid-area: step; justify-self: stretch; }
  .expert-grid .stepper { min-width: 0; width: 100%; }
  .expert-grid .seg { width: 100%; }
  .expert-grid .seg label { flex: 1; justify-content: center; }
}
@media (max-width: 900px) {
  /* 单列：人形置于输入之上并 sticky 常驻，滚动填写时始终可见 */
  /* align-items 覆盖基础网格的 start：flex 竖排时交叉轴是水平方向，不 stretch 会被内容挤窄 */
  .home { display: flex; flex-direction: column; align-items: stretch; max-width: 720px; }
  .stage-col { position: sticky; top: var(--header-h); z-index: 6; }
  .stage { position: relative; top: auto; min-height: 34vh; }
  .result-card { grid-template-columns: minmax(0, 1fr); }
  .result-card > div { padding-left: 0; border-left: 0; }
  .result-card .frame { max-width: 280px; }
}
@media (max-width: 560px) {
  .expert-grid { grid-template-columns: minmax(0, 1fr); }
  .expert-grid .meas-row { grid-template-columns: 36px 1fr; }
  .expert-grid .meas-row .circle-btn { width: 36px; height: 36px; }
  .ticker-row { height: 32px; font-size: 12px; }
}

/* ── 英文界面校准（只在 html[lang="en"] 生效；中文版零变化） ──
   英文字串更长：测量名允许换行以免撑宽药丸行，步进器收窄留出名称空间。 */
html[lang="en"] .meas-name { white-space: normal; }
html[lang="en"] .stepper { min-width: 158px; }
html[lang="en"] .card-head .card-title,
html[lang="en"] .btn-calc { letter-spacing: 0; }
html[lang="en"] table.result th { padding-right: 14px; }
