/* 玩沐國際設計 WANMU DESIGN — preview3d.css
   「3D預覽」頁專用；顏色、字體、按鈕沿用 style.css 的設定。
   版面：電腦上左邊是 3D 畫面、右邊是區塊設定；手機上 3D 畫面固定在上方，設定往下捲。 */

.p3d-page { --nav-h: 68px; --side-w: 392px; overflow: hidden; }
.p3d-page .nav-links a.active { color: var(--ink); }

.p3d {
  display: grid; grid-template-columns: minmax(0, 1fr) var(--side-w);
  height: 100vh; height: 100dvh; padding-top: var(--nav-h);
}

/* ---------- 3D 畫面 ---------- */
.p3d-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #07070d; }
.p3d-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; outline: none; }
.p3d-stage canvas:active { cursor: grabbing; }
.p3d-stage.is-hover canvas { cursor: pointer; }

.p3d-title { position: absolute; left: clamp(14px, 2.4vw, 28px); top: clamp(14px, 2.2vw, 24px); pointer-events: none; }
.p3d-title .kicker { margin-bottom: 8px; font-size: 11px; }
.p3d-title h1 { font-size: clamp(22px, 2.6vw, 34px); line-height: 1.2; font-weight: 900; text-shadow: 0 2px 18px rgba(0, 0, 0, .8); }
.p3d-sub { margin: 6px 0 0; font-size: 13px; color: var(--muted); text-shadow: 0 1px 10px rgba(0, 0, 0, .9); }

.p3d-all {
  display: inline-block; margin-top: 10px; padding: 5px 13px; border-radius: 999px; pointer-events: auto;
  font-size: 12px; color: var(--body); border: 1px solid var(--line); background: rgba(5, 5, 10, .72);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: border-color .2s, color .2s;
}
.p3d-all:hover { color: var(--ink); border-color: rgba(255, 255, 255, .45); }
.p3d-all[hidden] { display: none; }

/* ---------- 專案清單 ---------- */
.p3d-gallery-mode { overflow: auto; }
.p3d-gallery { min-height: 100vh; min-height: 100dvh; padding: calc(var(--nav-h) + clamp(36px, 6vw, 72px)) 0 clamp(60px, 8vw, 110px); }
.p3d-gallery h1 { font-size: clamp(32px, 4.6vw, 58px); line-height: 1.18; font-weight: 900; }
.p3d-cats { display: grid; gap: clamp(36px, 5vw, 60px); margin-top: clamp(36px, 5vw, 60px); }
.p3d-cat h2 { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; font-size: 14px; font-weight: 500; letter-spacing: .22em; color: var(--muted); }
.p3d-cat h2::before { content: ""; width: 28px; height: 1px; background: var(--grad); }
.p3d-projs { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.p3d-proj { display: block; overflow: hidden; transition: transform .3s var(--ease), border-color .3s; }
.p3d-proj:hover { transform: translateY(-4px); border-color: rgba(255, 255, 255, .28); }
.p3d-proj img { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; background: #0b0b14; border-radius: var(--radius) var(--radius) 0 0; }
.p3d-proj div { padding: 16px 18px 18px; }
.p3d-proj h3 { font-size: 20px; line-height: 1.35; }
.p3d-proj p { margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.p3d-proj small { display: block; margin-top: 10px; font-family: var(--f-display); font-size: 12px; color: var(--dim); }
.p3d-gallery .p3d-warn { margin: 0; }
.p3d-gallery .p3d-none { color: var(--muted); }

/* 工具列：選取／顏料桶／文字 */
.p3d-toolbar {
  position: absolute; left: clamp(12px, 2vw, 22px); top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 4px; padding: 6px; border-radius: 18px; border: 1px solid var(--line);
  background: rgba(5, 5, 10, .74); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.p3d-toolbar button {
  display: grid; justify-items: center; gap: 3px; width: 58px; padding: 9px 0 7px; border: 0; border-radius: 13px; cursor: pointer;
  font-size: 11px; color: var(--muted); background: transparent; transition: background .2s, color .2s;
}
.p3d-toolbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.p3d-toolbar button:hover { color: var(--ink); background: rgba(255, 255, 255, .07); }
.p3d-toolbar button[aria-pressed="true"] { color: #0b0610; background: var(--grad); font-weight: 700; }
.p3d-stage.tool-paint canvas { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 24 24' fill='%23fff' stroke='%23111' stroke-width='1.5' stroke-linejoin='round'%3E%3Cpath d='m19 11-8-8-8.6 8.6a2 2 0 0 0 0 2.8l5.2 5.2a2 2 0 0 0 2.8 0L19 11Z'/%3E%3Cpath d='M22 20a2 2 0 1 1-4 0c0-1.6 2-3.5 2-3.5s2 1.9 2 3.5Z'/%3E%3C/svg%3E") 3 16, crosshair; }
.p3d-stage.tool-text canvas { cursor: text; }
.p3d-stage.tool-text.is-hover canvas { cursor: pointer; }
.p3d-stage.is-drag canvas { cursor: move; }

.p3d-views {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  flex-wrap: nowrap; max-width: calc(100% - 28px); overflow-x: auto; scrollbar-width: none;
  padding: 6px; border-radius: 999px; border: 1px solid var(--line);
  background: rgba(5, 5, 10, .72); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.p3d-views::-webkit-scrollbar { display: none; }
.p3d-views button { flex: none; padding: 7px 15px; font-size: 13px; white-space: nowrap; border-color: transparent; background: transparent; }

.p3d-tools { position: absolute; right: clamp(12px, 2vw, 22px); top: clamp(14px, 2.2vw, 24px); display: flex; gap: 8px; }
.p3d-tool {
  padding: 8px 15px; border-radius: 999px; cursor: pointer; font-size: 13px; white-space: nowrap;
  border: 1px solid var(--line); background: rgba(5, 5, 10, .72); color: var(--body);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transition: border-color .2s, color .2s, background .2s;
}
.p3d-tool:hover { border-color: rgba(255, 255, 255, .45); color: var(--ink); }
.p3d-tool[aria-pressed="true"] { border-color: rgba(255, 154, 82, .6); color: var(--amber); }

.p3d-hint {
  position: absolute; left: clamp(14px, 2.4vw, 28px); bottom: 74px; margin: 0; max-width: min(520px, 70%);
  font-size: 12px; color: rgba(255, 255, 255, .5); pointer-events: none; text-shadow: 0 1px 8px rgba(0, 0, 0, .9);
}

.p3d-drop {
  position: absolute; inset: 10px; display: grid; place-items: end center; padding-bottom: 96px;
  border: 2px dashed rgba(255, 154, 82, .7); border-radius: 22px; pointer-events: none;
  opacity: 0; transition: opacity .2s;
}
.p3d-drop span { padding: 10px 20px; border-radius: 999px; font-weight: 700; color: #0b0610; background: var(--grad); }
.p3d-stage.is-drop .p3d-drop { opacity: 1; }

.p3d-loading {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 16px;
  color: var(--muted); font-size: 14px; background: #07070d; transition: opacity .5s; text-align: center; padding: 24px;
}
.p3d-loading.is-done { opacity: 0; pointer-events: none; }
.p3d-loading.is-error .p3d-spinner { display: none; }
.p3d-loading.is-error { color: #ff8fa3; }
.p3d-spinner { width: 38px; height: 38px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .12); border-top-color: var(--rose); animation: p3d-spin .9s linear infinite; }
@keyframes p3d-spin { to { transform: rotate(360deg); } }

.p3d-toast {
  position: absolute; left: 50%; top: 18px; transform: translate(-50%, -12px); margin: 0; max-width: calc(100% - 32px);
  padding: 9px 18px; border-radius: 999px; font-size: 13px; text-align: center;
  color: var(--ink); background: rgba(5, 5, 10, .9); border: 1px solid rgba(255, 154, 82, .5);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s var(--ease);
}
.p3d-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 區塊設定 ---------- */
.p3d-side {
  display: flex; flex-direction: column; gap: 18px; min-height: 0; overflow-y: auto;
  padding: 20px 18px 26px; border-left: 1px solid var(--line); background: var(--bg-2); outline: none;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .18) transparent;
}
.p3d-side h2 { font-size: 19px; line-height: 1.35; font-weight: 900; letter-spacing: 0; }

.p3d-card { padding: 18px; border-radius: 18px; border: 1px solid var(--line); background: linear-gradient(180deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .015)); }
.p3d-card.is-active { border-color: rgba(255, 154, 82, .5); }
.p3d-card-empty p { margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.p3d-card-empty b { color: var(--ink); }
.p3d-card-head { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.p3d-chip { display: inline-flex; align-items: center; gap: 7px; padding: 3px 11px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); color: var(--body); }
.p3d-chip::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c, #888); }
.p3d-spec { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 16px; }
.p3d-spec div { padding: 10px 12px; border-radius: 12px; background: rgba(0, 0, 0, .3); }
.p3d-spec dt { font-size: 11px; letter-spacing: .12em; color: var(--muted); }
.p3d-spec dd { margin: 2px 0 0; font-family: var(--f-display); font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.p3d-actions { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; }
.p3d-actions .btn { height: 46px; padding: 0 18px; font-size: 15px; }
.p3d-color {
  position: relative; display: inline-flex; align-items: center; gap: 8px; height: 46px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  font-size: 14px; font-weight: 700; white-space: nowrap; border: 1px solid rgba(255, 255, 255, .24); background: rgba(255, 255, 255, .04);
}
.p3d-color:hover { border-color: rgba(255, 255, 255, .55); }
.p3d-color input { width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; }
.p3d-color input::-webkit-color-swatch-wrapper { padding: 0; }
.p3d-color input::-webkit-color-swatch { border: 1px solid rgba(255, 255, 255, .5); border-radius: 50%; }
.p3d-color input::-moz-color-swatch { border: 1px solid rgba(255, 255, 255, .5); border-radius: 50%; }
.p3d-color:focus-within { outline: 2px solid var(--cyan); outline-offset: 3px; }
.p3d-formats { margin: 10px 0 0; font-size: 12px; color: var(--dim); }
.p3d-media { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.p3d-file { margin: 0 0 10px; font-size: 13px; color: var(--body); overflow-wrap: anywhere; }
.p3d-fit button { padding: 7px 8px; font-size: 13px; text-align: center; }
.p3d-fit.seg-full { grid-template-columns: repeat(3, 1fr); }
.p3d-warn { margin: 10px 0 0; padding: 9px 12px; border-radius: 10px; font-size: 13px; color: #ffd9a8; background: rgba(255, 154, 82, .1); border: 1px solid rgba(255, 154, 82, .3); }
.p3d-warn.is-ok { color: #9dffcf; background: rgba(61, 255, 154, .07); border-color: rgba(61, 255, 154, .25); }

/* 顏料桶與文字的設定 */
.p3d-lead { margin: 8px 0 14px; font-size: 14px; color: var(--muted); }
.p3d-lead b { color: var(--ink); }
.p3d-swatches { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-bottom: 12px; }
.p3d-swatches button {
  aspect-ratio: 1; padding: 0; border-radius: 10px; cursor: pointer; background: var(--c);
  border: 1px solid rgba(255, 255, 255, .22); outline-offset: 2px; transition: transform .15s;
}
.p3d-swatches button:hover { transform: scale(1.1); }
.p3d-swatches button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 4px var(--amber); }
.p3d-color-wide { width: 100%; margin-bottom: 12px; }
.p3d-color-wide output { margin-left: auto; font-family: var(--f-mono); font-size: 12px; font-weight: 400; color: var(--muted); }
.p3d-card-paint .seg button, .p3d-pair .btn { font-size: 13px; }
.p3d-card-paint .seg button { padding: 8px 6px; text-align: center; }
.p3d-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.p3d-pair .btn { height: 42px; padding: 0 10px; }
.p3d-field { display: grid; gap: 6px; margin: 14px 0 12px; font-size: 12px; letter-spacing: .1em; color: var(--muted); }
.p3d-field textarea {
  width: 100%; min-height: 64px; padding: 10px 12px; resize: vertical; font: inherit; font-size: 16px; letter-spacing: 0; color: var(--ink);
  background: rgba(0, 0, 0, .35); border: 1px solid rgba(255, 255, 255, .15); border-radius: 12px;
}
.p3d-field textarea:focus { outline: none; border-color: var(--rose); box-shadow: 0 0 0 3px rgba(255, 79, 114, .25); }
.p3d-range { display: grid; grid-template-columns: 5em 1fr 4.5em; gap: 10px; margin-bottom: 10px; font-size: 13px; }
.p3d-range input { width: 100%; }
.p3d-range output { text-align: right; font-family: var(--f-display); font-variant-numeric: tabular-nums; color: var(--ink); }
.p3d-danger { height: 44px; margin-top: 12px; font-size: 14px; color: #ff9db0; border-color: rgba(255, 92, 122, .4); }
.p3d-danger:hover { color: #fff; background: rgba(255, 92, 122, .18); border-color: #ff5c7a; }

.p3d-texts { list-style: none; margin: -6px 0 0; padding: 0; display: grid; gap: 6px; }
.p3d-texts button {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; width: 100%; padding: 8px 12px 8px 8px;
  border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, .025); cursor: pointer; text-align: left;
  transition: border-color .2s, background .2s;
}
.p3d-texts button:hover { border-color: rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .05); }
.p3d-texts button[aria-current="true"] { border-color: var(--amber); background: rgba(255, 154, 82, .08); }
.p3d-texts i { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; font-style: normal; font-weight: 900; font-size: 17px; color: var(--c, #fff); background: rgba(255, 255, 255, .9); }
.p3d-texts b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p3d-texts small { font-family: var(--f-display); font-size: 11px; color: var(--dim); white-space: nowrap; }
.p3d-texts .p3d-none { padding: 4px 2px; font-size: 13px; color: var(--dim); }

.p3d-list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 4px; }
.p3d-list-head small { margin-left: 6px; font-family: var(--f-display); font-size: 13px; font-weight: 500; color: var(--muted); }
.p3d-link { padding: 4px 0; border: 0; background: none; cursor: pointer; font-size: 13px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.p3d-link:hover { color: var(--ink); }

.p3d-list { display: grid; gap: 16px; }
.p3d-zone h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 12px; font-weight: 500; letter-spacing: .18em; color: var(--muted); }
.p3d-zone h3::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--c, #888); box-shadow: 0 0 10px var(--c, transparent); }
.p3d-zone ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.p3d-row {
  display: grid; grid-template-columns: 58px 1fr auto; align-items: center; gap: 12px; width: 100%; padding: 8px 12px 8px 8px;
  border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, .025); cursor: pointer; text-align: left;
  transition: border-color .2s, background .2s;
}
.p3d-row:hover, .p3d-row.is-hover { border-color: rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .05); }
.p3d-row[aria-current="true"] { border-color: var(--amber); background: rgba(255, 154, 82, .08); }
.p3d-thumb { width: 58px; height: 38px; border-radius: 8px; background: var(--c, #666) center / cover no-repeat; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14); }
.p3d-row b { display: block; font-size: 15px; line-height: 1.3; }
.p3d-row small { display: block; font-family: var(--f-display); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.p3d-state { font-size: 11px; color: var(--dim); white-space: nowrap; }
.p3d-row.has-media .p3d-state { color: var(--amber); }

.p3d-note { margin: 4px 0 0; font-size: 12px; line-height: 1.7; color: var(--dim); }
.p3d-note b { color: var(--muted); font-weight: 500; }
.p3d-side > .btn { flex: none; height: auto; min-height: 52px; padding: 12px 20px; white-space: normal; text-align: center; line-height: 1.4; font-size: 15px; }
.p3d-noscript { position: fixed; inset: auto 16px 16px; padding: 14px 18px; border-radius: 12px; background: #2a1020; color: #ffd0d8; }

/* ---------- 手機：3D 畫面固定在上方，設定在下面捲動 ---------- */
@media (max-width: 900px) {
  .p3d-page { overflow: auto; }
  .p3d { display: block; height: auto; }
  .p3d-stage { position: sticky; top: var(--nav-h); z-index: 5; height: 52vh; height: 52dvh; min-height: 300px; border-bottom: 1px solid var(--line); }
  .p3d-side { overflow: visible; border-left: 0; padding: 18px 16px 96px; }
  .p3d-card { scroll-margin-top: calc(var(--nav-h) + 52vh + 14px); scroll-margin-top: calc(var(--nav-h) + 52dvh + 14px); }
  .p3d-title h1 { font-size: 20px; }
  .p3d-title .kicker { display: none; }
  .p3d-sub { font-size: 12px; }
  .p3d-tools { top: auto; bottom: 62px; right: 10px; }
  .p3d-tool { padding: 6px 12px; font-size: 12px; }
  .p3d-hint { display: none; }
  .p3d-toolbar { left: 8px; top: auto; bottom: 62px; transform: none; flex-direction: row; padding: 4px; border-radius: 14px; }
  .p3d-toolbar button { width: 46px; padding: 6px 0 5px; font-size: 10px; border-radius: 10px; }
  .p3d-toolbar svg { width: 19px; height: 19px; }
  .p3d-views { bottom: 10px; }
  .p3d-views button { padding: 6px 12px; font-size: 12px; }
  .p3d-drop { display: none; }
}
@media (max-width: 380px) { .p3d-actions { grid-template-columns: 1fr 1fr; } .p3d-actions .btn-glow { grid-column: 1 / -1; } }
