/* ═══════════════════════════════════════════════════
   ATELIER ŒIL — 冷淡极简搭配界面
   ═══════════════════════════════════════════════════ */

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal; font-weight: 300; font-display: swap;
  src: url('public/fonts/CormorantGaramond-normal-300.woff2') format('woff2');
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic; font-weight: 300; font-display: swap;
  src: url('public/fonts/CormorantGaramond-italic-300.woff2') format('woff2');
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic; font-weight: 400; font-display: swap;
  src: url('public/fonts/CormorantGaramond-italic-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter Tight';
  font-style: normal; font-weight: 300; font-display: swap;
  src: url('public/fonts/InterTight-normal-300.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter Tight';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('public/fonts/InterTight-normal-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter Tight';
  font-style: normal; font-weight: 500; font-display: swap;
  src: url('public/fonts/InterTight-normal-500.woff2') format('woff2');
}

:root {
  --bg: #f2f2ef;
  --bg-fog: #e9eae6;
  --bg-tile: #ececea;
  --ink: #161616;
  --ink-2: #4c4c48;
  --gray: #8b8b85;
  --silver: #c6c7c3;
  --hairline: rgba(22, 22, 22, 0.14);
  --hairline-soft: rgba(22, 22, 22, 0.07);
  --serif: 'Cormorant Garamond', 'Songti SC', serif;
  --sans: 'Inter Tight', 'PingFang SC', sans-serif;

  /* 非线性缓动 */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-inout-quart: cubic-bezier(0.76, 0, 0.24, 1);
  --ease-back-soft: cubic-bezier(0.34, 1.4, 0.64, 1);
  --ease-in-quart: cubic-bezier(0.55, 0, 0.1, 1);

  --panel-w: 400px;
  --topbar-h: 72px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  cursor: default;
}
.svg-defs { position: fixed; width: 0; height: 0; overflow: hidden; pointer-events: none; }

img { display: block; }
button {
  font-family: inherit; background: none; border: none;
  color: inherit; cursor: pointer; text-align: left;
}

::selection { background: var(--ink); color: var(--bg); }

/* ══════════ 顶栏 ══════════ */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--hairline);
  position: relative; z-index: 40;
  background: var(--bg);
}
.brand { display: flex; align-items: baseline; gap: 14px; will-change: transform; }
.brand-mark {
  font-family: var(--serif);
  font-size: 22px; font-weight: 300; letter-spacing: 0.22em;
}
.brand-sub {
  font-size: 10px; letter-spacing: 0.32em; color: var(--gray);
}
.top-meta {
  display: flex; align-items: center; gap: 16px;
  font-size: 10px; letter-spacing: 0.28em; color: var(--ink-2);
}
.top-meta .dot { width: 4px; height: 4px; background: var(--ink); border-radius: 50%; }
.language-switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  border: 1px solid var(--hairline);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--gray);
}
.lang-btn {
  color: var(--gray);
  font-size: inherit;
  letter-spacing: inherit;
  line-height: 1;
  transition: color 0.35s var(--ease-out-expo);
}
.lang-btn.is-active {
  color: var(--ink);
  font-weight: 500;
}
.lang-btn:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 3px;
}

/* ══════════ 布局 ══════════ */
.layout {
  display: flex;
  height: calc(100vh - var(--topbar-h));
}

/* ══════════ 预览舞台 ══════════ */
.stage {
  flex: 1;
  position: relative;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  overflow: hidden;
  background:
    linear-gradient(var(--hairline-soft) 1px, transparent 1px) 0 0 / 100% 25%,
    var(--bg);
}

.stage-frame {
  position: relative;
  aspect-ratio: 3 / 4;
  height: min(66vh, 100%);
  max-width: 78%;
  background: var(--bg-fog);
  overflow: hidden;
  transition: height 0.8s var(--ease-out-expo);
}

/* 巨号索引 */
.stage-index {
  position: absolute;
  right: -0.08em; bottom: -0.28em;
  font-family: var(--serif); font-style: italic;
  font-size: clamp(160px, 34vh, 340px);
  font-weight: 300;
  color: transparent;
  -webkit-text-stroke: 1px rgba(22, 22, 22, 0.16);
  line-height: 1;
  pointer-events: none;
  z-index: 1;
  will-change: transform;
}

/* 视角层 */
.view {
  position: absolute; inset: 0;
  opacity: 0; visibility: hidden;
  z-index: 2;
  will-change: transform, opacity;
}
.view.is-active { opacity: 1; visibility: visible; }

/* 正面：模特 + 叠加 */
.model-box { position: absolute; inset: 0; will-change: transform; }
.model-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}

.glasses-wrap {
  position: absolute;
  aspect-ratio: 2.3;
  transform-origin: 52% 50%;
  transform-style: preserve-3d;
  mix-blend-mode: normal;
  will-change: transform;
  /* left / top / width 由 JS 按模特锚点写入 */
}
.glasses-img {
  width: 100%; height: 100%;
  object-fit: contain;
  will-change: transform, opacity;
}
.glasses-img.face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: translateZ(0);
  transform-origin: center;
}

/* 45 度与侧面：Image2 多视角画布 */
.view-side {
  background: var(--bg-fog);
}
.side-figure {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  will-change: transform;
}
.multiview-model-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.glasses-wrap.side {
  position: relative;
  aspect-ratio: 8 / 5;
  mix-blend-mode: normal;
  width: 92%;
  margin-top: -8%;
  filter: drop-shadow(0 34px 34px rgba(22, 22, 22, 0.16));
}
.model-box.has-cached-tryon .glasses-wrap,
.side-figure.has-cached-tryon .glasses-wrap.side {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100%;
  aspect-ratio: auto;
  margin: 0;
  transform: none !important;
  filter: none;
  z-index: 3;
}
.model-box.has-cached-tryon .glasses-img,
.side-figure.has-cached-tryon .glasses-img {
  display: none;
}
.side-figure.is-pending .glasses-wrap.side,
.side-figure.is-pending .side-baseline {
  display: none;
}
.side-baseline {
  position: absolute; left: 8%; right: 8%; bottom: 18%;
  height: 1px; background: var(--hairline);
}
.side-caption-v {
  position: absolute; left: 22px; top: 50%;
  transform: translateY(-50%) rotate(180deg);
  writing-mode: vertical-rl;
  font-size: 10px; letter-spacing: 0.5em; color: var(--gray);
  z-index: 3;
}
.generation-status {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 20px;
  z-index: 5;
  padding: 14px 16px;
  border: 1px solid rgba(22, 22, 22, 0.18);
  background: rgba(242, 242, 239, 0.9);
  backdrop-filter: blur(12px);
}
.generation-status[hidden] { display: none; }
.generation-status span,
.generation-status small {
  display: block;
  font-size: 8px;
  letter-spacing: 0.22em;
  color: var(--gray);
}
.generation-status strong {
  display: block;
  margin: 6px 0;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 400;
}

/* 饰品层 */
.charm-layer { position: absolute; inset: 0; pointer-events: none; }
.front-ear-layer { z-index: 4; }
.charm-item {
  position: absolute;
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
}
.charm-item img { display: block; width: 100%; height: auto; }
.charm-item.face-charm img {
  filter: brightness(1.22) saturate(1.18) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.28));
}
.earring-item {
  z-index: 2;
  transform-origin: top center;
}
.earring-item img.is-mirrored { transform: scaleX(-1); }
.earring-item.is-drop img {
  filter: brightness(1.2) saturate(1.14) drop-shadow(0 3px 3px rgba(0, 0, 0, 0.26));
}

/* 接口吸附提示环 */
.socket-ring {
  position: absolute;
  width: 9%; aspect-ratio: 1;
  border: 1px solid rgba(22, 22, 22, 0.55);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.4);
  opacity: 0;
  pointer-events: none;
}
.socket-ring::after {
  content: ''; position: absolute; inset: 36%;
  background: var(--ink); border-radius: 50%;
}
.ear-socket-ring { width: 6%; z-index: 5; }

/* 遮罩转场块 */
.wipe {
  position: absolute; inset: -2% -12%;
  transform: translateX(-115%) skewX(-9deg);
  z-index: 8; pointer-events: none;
  will-change: transform;
}
.wipe-a { background: #161616; }
.wipe-b { background: var(--silver); }

/* 角标 */
.corner {
  position: absolute; z-index: 6;
  font-size: 9px; letter-spacing: 0.3em; color: var(--ink-2);
  pointer-events: none;
}
.corner.tl { top: 18px; left: 20px; }
.corner.tr { top: 18px; right: 20px; }
.corner.br { bottom: 18px; right: 20px; text-align: right; }

/* 空状态 */
.stage-empty {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  font-family: var(--serif); font-size: 22px; font-weight: 300;
  color: var(--gray);
  opacity: 0; visibility: hidden;
  transition: opacity 0.7s var(--ease-out-expo);
  pointer-events: none;
}
.stage-empty em { font-size: 13px; letter-spacing: 0.14em; }
.stage-empty.is-visible { opacity: 1; visibility: visible; }

/* ══════════ 视角切换 ══════════ */
.view-toggle {
  position: relative;
  display: flex; gap: 34px;
  margin-top: 26px;
  padding: 10px 4px 14px;
}
.vt-btn {
  display: flex; align-items: baseline; gap: 10px;
  padding: 4px 6px;
  color: var(--gray);
  transition: color 0.6s var(--ease-out-expo);
  will-change: transform;
}
.vt-no { font-size: 9px; letter-spacing: 0.2em; }
.vt-label { font-size: 15px; font-weight: 400; letter-spacing: 0.12em; }
.vt-en { font-size: 9px; letter-spacing: 0.3em; }
.vt-btn.is-active { color: var(--ink); }
.vt-slider {
  position: absolute; bottom: 0; left: 0;
  height: 1px; width: 40px;
  background: var(--ink);
  will-change: transform, width;
}

/* ══════════ 搭配摘要 ══════════ */
.stage-caption {
  margin-top: 20px;
  text-align: center;
  min-height: 56px;
}
.caption-look {
  font-family: var(--serif); font-style: italic;
  font-size: 21px; font-weight: 300;
  letter-spacing: 0.04em;
  transition: opacity 0.5s var(--ease-out-expo), transform 0.5s var(--ease-out-expo);
}
.caption-spec {
  margin-top: 6px;
  font-size: 9px; letter-spacing: 0.32em; color: var(--gray);
}

/* ══════════ 选择面板 ══════════ */
.panel {
  width: var(--panel-w);
  flex-shrink: 0;
  border-left: 1px solid var(--hairline);
  display: flex; flex-direction: column;
  background: var(--bg);
  position: relative; z-index: 30;
}

.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--hairline);
}
.pt-btn {
  flex: 1;
  padding: 18px 4px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  color: var(--gray);
  position: relative;
  transition: color 0.55s var(--ease-out-expo);
  will-change: transform;
}
.pt-no { font-size: 8px; letter-spacing: 0.24em; }
.pt-label { font-size: 12.5px; font-weight: 400; letter-spacing: 0.14em; }
.pt-btn::after {
  content: ''; position: absolute; bottom: -1px; left: 50%;
  width: 0; height: 1px; background: var(--ink);
  transition: width 0.7s var(--ease-out-expo), left 0.7s var(--ease-out-expo);
}
.pt-btn.is-active { color: var(--ink); }
.pt-btn.is-active::after { width: 100%; left: 0; }

.panel-hint {
  padding: 14px 24px;
  font-size: 9.5px; letter-spacing: 0.22em; line-height: 1.9;
  color: var(--gray);
  border-bottom: 1px solid var(--hairline-soft);
}

.panel-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--silver) transparent;
  padding: 8px 0 24px;
}
.panel-list::-webkit-scrollbar { width: 3px; }
.panel-list::-webkit-scrollbar-thumb { background: var(--silver); }

/* —— 通用条目 —— */
.item {
  width: 100%;
  display: flex; align-items: center; gap: 16px;
  padding: 13px 24px;
  position: relative;
  border-bottom: 1px solid var(--hairline-soft);
  will-change: transform;
}
.item-idx {
  font-size: 8.5px; letter-spacing: 0.2em; color: var(--silver);
  width: 20px; flex-shrink: 0;
  transition: color 0.5s;
}
.item-thumb {
  width: 58px; height: 58px;
  flex-shrink: 0;
  background: var(--bg-tile);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.7s var(--ease-out-expo);
}
.item-thumb img { width: 88%; height: 88%; object-fit: contain; }
.item-thumb.tall img { width: 100%; height: 100%; object-fit: cover; }
.item-body { flex: 1; min-width: 0; }
.item-name {
  font-family: var(--serif);
  font-size: 17px; font-weight: 400; letter-spacing: 0.05em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item-sub {
  margin-top: 4px;
  font-size: 9px; letter-spacing: 0.24em; color: var(--gray);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item-state {
  width: 7px; height: 7px; flex-shrink: 0;
  border: 1px solid var(--silver);
  transform: rotate(45deg);
  transition: background 0.5s, border-color 0.5s, transform 0.6s var(--ease-back-soft);
}
.item:hover .item-thumb { transform: scale(1.06); }
.item.is-selected .item-idx { color: var(--ink); }
.item.is-selected .item-state {
  background: var(--ink); border-color: var(--ink);
  transform: rotate(225deg);
}
.item.is-selected::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 2px; background: var(--ink);
}

/* 配色条目 */
.item-swatch {
  width: 64px; height: 40px; flex-shrink: 0;
  background: var(--bg-tile);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.7s var(--ease-out-expo);
}
.item-swatch img { width: 90%; height: 90%; object-fit: contain; }
.item:hover .item-swatch { transform: scale(1.06); }

/* 正面耳饰佩戴方向 */
.ear-placement {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--hairline-soft);
  background: var(--bg);
}
.ear-placement-copy {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ear-placement-copy strong {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
}
.ear-placement-copy span {
  color: var(--gray);
  font-size: 8px;
  letter-spacing: 0.2em;
}
.ear-side-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(52px, 1fr));
  min-width: 186px;
  border: 1px solid var(--hairline);
}
.ear-side-btn {
  min-height: 44px;
  padding: 0 10px;
  color: var(--gray);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-align: center;
  border-right: 1px solid var(--hairline);
  transition:
    color 220ms var(--ease-out-expo),
    background 220ms var(--ease-out-expo);
}
.ear-side-btn:last-child { border-right: none; }
.ear-side-btn:hover { color: var(--ink); }
.ear-side-btn.is-active {
  color: var(--bg);
  background: var(--ink);
}
.ear-side-btn:focus-visible,
.charm-cell:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -3px;
}

/* 饰品网格 */
.charm-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--hairline-soft);
  border-bottom: 1px solid var(--hairline-soft);
}
.charm-cell {
  background: var(--bg);
  padding: 18px 16px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  position: relative;
  will-change: transform;
}
.charm-cell-thumb {
  width: 84px; height: 84px;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.8s var(--ease-out-expo);
}
.charm-cell-thumb img { width: 100%; height: 100%; object-fit: contain; }
.charm-cell:hover .charm-cell-thumb { transform: translateY(-4px) scale(1.07); }
.charm-cell-name {
  font-size: 10px; letter-spacing: 0.12em; text-align: center;
  font-weight: 400;
}
.charm-cell-zh { font-size: 10px; color: var(--gray); letter-spacing: 0.2em; }
.charm-cell-no {
  position: absolute; top: 10px; left: 12px;
  font-size: 8px; letter-spacing: 0.18em; color: var(--silver);
}
.charm-cell-check {
  position: absolute; top: 10px; right: 12px;
  width: 7px; height: 7px;
  border: 1px solid var(--silver);
  transform: rotate(45deg);
  transition: background 0.5s, border-color 0.5s, transform 0.6s var(--ease-back-soft);
}
.charm-cell.is-selected .charm-cell-check {
  background: var(--ink); border-color: var(--ink);
  transform: rotate(225deg);
}
.charm-cell.is-selected { box-shadow: inset 0 0 0 1px var(--ink); }

/* 面板底部 */
.panel-foot {
  border-top: 1px solid var(--hairline);
  padding: 18px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--bg);
}
.foot-summary { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fs-line {
  font-size: 10px; letter-spacing: 0.2em; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fs-line:first-child { font-family: var(--serif); font-size: 15px; letter-spacing: 0.06em; }
.reset-btn {
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 16px;
  border: 1px solid var(--hairline);
  font-size: 11px; letter-spacing: 0.2em;
  transition: background 0.6s var(--ease-out-expo), color 0.6s var(--ease-out-expo);
  will-change: transform;
}
.reset-btn > span:first-child { font-size: 11px; letter-spacing: 0.2em; color: currentColor; }
.reset-btn > span:last-child { font-size: 8px; letter-spacing: 0.3em; color: var(--gray); transition: color 0.6s; }
.reset-btn:hover { background: var(--ink); color: var(--bg); }
.reset-btn:hover > span:last-child { color: var(--silver); }

/* ══════════ 飞行饰品（吸附动画载体） ══════════ */
.fly-charm {
  position: fixed; z-index: 90;
  pointer-events: none;
  will-change: transform, opacity;
  filter: drop-shadow(0 10px 18px rgba(22, 22, 22, 0.22));
}

/* ══════════ 启动遮罩 ══════════ */
.boot {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.9s var(--ease-inout-quart), visibility 0.9s;
}
.boot.is-done { opacity: 0; visibility: hidden; }
.boot-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.boot-mark {
  font-family: var(--serif); font-style: italic;
  font-size: 64px; font-weight: 300;
  animation: bootPulse 2.2s var(--ease-inout-quart) infinite;
}
.boot-text { font-size: 9px; letter-spacing: 0.42em; color: var(--gray); }
.boot-err { max-width: 420px; text-align: center; font-size: 12px; line-height: 2; color: var(--ink-2); letter-spacing: 0.08em; }
@keyframes bootPulse {
  0%, 100% { opacity: 0.25; transform: scale(0.96); }
  50% { opacity: 1; transform: scale(1); }
}

/* ══════════ 响应式 ══════════ */
@media (max-width: 900px) {
  :root { --topbar-h: 60px; }
  body { overflow: auto; }
  .topbar { height: var(--topbar-h); padding: 0 16px; gap: 12px; overflow: hidden; }
  .brand { min-width: 0; flex: 1; }
  .brand-mark { white-space: nowrap; font-size: 17px; letter-spacing: 0.14em; }
  .brand-sub, .top-meta .dot, #topCounter, #topConfigurator { display: none; }
  .top-meta { flex: 0 0 auto; white-space: nowrap; font-size: 8px; letter-spacing: 0.18em; }
  .language-switch { display: inline-flex; }
  .layout { flex-direction: column; height: auto; }
  .stage { min-height: 72vh; padding: 24px 0 12px; }
  .stage-frame { height: 56vh; max-width: 92%; }
  .view-toggle {
    width: min(92%, 390px);
    justify-content: space-between;
    gap: 4px;
  }
  .vt-btn { gap: 6px; padding-inline: 4px; }
  .vt-en { display: none; }
  .panel { width: 100%; border-left: none; border-top: 1px solid var(--hairline); }
  .panel-list { max-height: 60vh; }
  .ear-placement { align-items: stretch; flex-direction: column; gap: 12px; }
  .ear-side-options { width: 100%; min-width: 0; }
}

/* ══════════ 减少动效 ══════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
