/* ============================================================
   晶礦人生 — 金工鑲嵌委託單
   共用樣式（index.html / guide.html）
   配色：提亮版
   ============================================================ */

:root {
  --bg:      #22282A;
  --panel:   #2C3336;
  --panel-2: #333B3E;
  --border:  #414A4D;
  --gold:    #D4AF6A;
  --gold-hi: #E9D3A2;
  --silver:  #C2BCB2;
  --text:    #F4F1EB;
  --muted:   #A6ADAD;

  --danger:  #D98878;

  --radius:  5px;
  --radius-lg: 6px;
  --ease:    cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans TC', sans-serif;
  padding: 0 0 90px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

.wrap { max-width: 640px; margin: 0 auto; padding: 32px 20px 0; }

/* ---------- 頁首 ---------- */

header.page-head {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
}

.eyebrow-row {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 12px; gap: 12px;
}

.brand {
  font-family: 'Noto Serif TC', serif;
  font-size: 12px; letter-spacing: .34em;
  color: var(--gold); font-weight: 600;
}

.eyebrow-r {
  font-family: 'Cormorant Garamond', serif;
  font-size: 11px; letter-spacing: .2em; color: var(--silver);
  white-space: nowrap;
}

h1 {
  font-family: 'Noto Serif TC', serif;
  font-size: 26px; font-weight: 700; letter-spacing: .04em;
  margin-bottom: 10px; line-height: 1.4;
}

.lede { font-size: 13px; color: var(--muted); line-height: 1.9; font-weight: 300; }

/* ---------- 區塊 ---------- */

section { margin-bottom: 46px; }

.sec-head { position: relative; padding-left: 26px; margin-bottom: 22px; }

.sec-head::before {
  content: ''; position: absolute; left: 0; top: 15px;
  height: 1px; width: 18px;
  background: linear-gradient(90deg, var(--gold) 0%, rgba(212, 175, 106, .15) 100%);
}

.sec-en {
  display: block; font-family: 'Cormorant Garamond', serif; font-size: 11px;
  letter-spacing: .26em; text-transform: uppercase; color: var(--gold);
  margin-bottom: 2px;
}

.sec-head h2 {
  font-family: 'Noto Serif TC', serif;
  font-size: 18px; font-weight: 600; letter-spacing: .03em;
}

/* ---------- 欄位 ---------- */

.field { margin-bottom: 26px; }
.field:last-child { margin-bottom: 0; }

.lbl {
  display: block; font-size: 12px; color: var(--silver);
  letter-spacing: .06em; margin-bottom: 9px; font-weight: 500;
}

.req { color: var(--gold); }
.opt { color: var(--muted); font-weight: 400; }

.hint {
  font-size: 12px; color: var(--muted); line-height: 1.8;
  margin-top: 8px; font-weight: 300;
}

input[type=text],
input[type=number],
textarea {
  width: 100%; background: transparent; border: none;
  border-bottom: 1px solid var(--border); color: var(--text);
  padding: 10px 0; font-size: 15px; font-family: inherit;
  border-radius: 0;
  transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease);
}

textarea {
  resize: vertical; min-height: 72px; line-height: 1.7;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; background: rgba(44, 51, 54, .5);
}

input[type=text]:focus,
input[type=number]:focus {
  outline: none; border-bottom-color: var(--gold);
  box-shadow: 0 1px 0 0 var(--gold);
}

textarea:focus {
  outline: none; border-color: var(--gold); box-shadow: none;
}

input::placeholder, textarea::placeholder {
  color: rgba(166, 173, 173, .55); font-weight: 300;
}

.field.invalid input[type=text],
.field.invalid input[type=number] { border-bottom-color: var(--danger); }
.field.invalid textarea { border-color: var(--danger); }

.err {
  display: none; font-size: 12px; color: var(--danger);
  margin-top: 8px; line-height: 1.6;
}
.field.invalid .err { display: block; }

/* ---------- 選項（膠囊） ---------- */

.pills { display: grid; gap: 9px; }
.pills.c3 { grid-template-columns: repeat(3, 1fr); }
.pills.c2 { grid-template-columns: repeat(2, 1fr); }
.pills.c1 { grid-template-columns: 1fr; }

.pill {
  border: 1px solid var(--border);
  background: rgba(44, 51, 54, .7);
  color: var(--text); border-radius: var(--radius);
  padding: 13px 10px; min-height: 46px;
  font-size: 14px; font-family: inherit; cursor: pointer;
  transition: border-color 180ms var(--ease), background-color 180ms var(--ease), color 180ms var(--ease);
  text-align: center; line-height: 1.5;
}

.pill:hover { border-color: var(--silver); }

.pill.on {
  border-color: var(--gold); color: var(--gold);
  background: rgba(212, 175, 106, .12);
  font-weight: 500;
}

/* 左對齊的寬選項（含副標） */
.pill.wide {
  text-align: left; display: flex; flex-direction: column;
  gap: 3px; padding: 14px 16px;
}
.pill.wide small {
  font-size: 11.5px; color: var(--muted); font-weight: 300; line-height: 1.6;
}
.pill.wide.on small { color: rgba(212, 175, 106, .8); }

/* ---------- 鑲法卡片 ---------- */

.craft-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.craft {
  border: 1px solid var(--border); background: var(--panel);
  border-radius: var(--radius-lg); padding: 16px 12px 0;
  text-align: center;
  transition: border-color 200ms var(--ease), background-color 200ms var(--ease);
  display: flex; flex-direction: column;
}

.craft:hover { border-color: rgba(212, 175, 106, .55); }

.craft.on {
  border-color: var(--gold);
  background: rgba(212, 175, 106, .08);
}

.craft-pick {
  background: none; border: none; padding: 0 0 4px; cursor: pointer;
  font-family: inherit; color: inherit; width: 100%;
}

.craft svg { width: 84px; height: 84px; display: block; margin: 0 auto 12px; }

.craft .metal {
  fill: none; stroke: var(--muted); stroke-width: 2.4;
  transition: stroke 200ms var(--ease);
}

.craft .stone {
  fill: rgba(194, 188, 178, .14); stroke: var(--border); stroke-width: 1;
  transition: fill 200ms var(--ease), stroke 200ms var(--ease);
}

.craft.on .metal { stroke: var(--gold); }
.craft.on .stone { fill: rgba(212, 175, 106, .14); stroke: rgba(212, 175, 106, .35); }

.craft-name {
  font-family: 'Noto Serif TC', serif; font-size: 14px;
  font-weight: 600; margin-bottom: 2px;
  transition: color 200ms var(--ease);
}
.craft.on .craft-name { color: var(--gold); }

.craft-en {
  font-family: 'Cormorant Garamond', serif; font-size: 10px;
  letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
}

.craft-link {
  display: block; margin-top: 10px; padding: 11px 4px;
  border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--silver);
  background: none; border-left: none; border-right: none; border-bottom: none;
  width: 100%; cursor: pointer; font-family: inherit;
  transition: color 180ms var(--ease);
}
.craft-link:hover { color: var(--gold); }

/* 卡片以外的「看範例」入口 */
.ex-link {
  display: block; width: 100%; margin-top: 10px; padding: 11px 4px;
  background: none; border: 1px solid var(--border); border-radius: var(--radius);
  font-family: inherit; font-size: 12px; color: var(--silver); cursor: pointer;
  transition: border-color 180ms var(--ease), color 180ms var(--ease);
}
.ex-link:hover { border-color: var(--gold); color: var(--gold); }

/* ---------- 提示框 ---------- */

.notice {
  border: 1px solid rgba(212, 175, 106, .38);
  background: var(--panel-2); border-radius: var(--radius);
  padding: 15px 16px; display: flex; gap: 12px; margin-top: 16px;
}

.notice svg {
  flex-shrink: 0; width: 17px; height: 17px;
  stroke: var(--gold); fill: none; margin-top: 3px;
}

.notice p {
  font-size: 12.5px; line-height: 1.9;
  color: rgba(244, 241, 235, .88); font-weight: 300;
}

.notice.plain { border-color: var(--border); }
.notice.plain svg { stroke: var(--silver); }

/* ---------- 照片上傳 ---------- */

.up-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.up-btn {
  border: 1px dashed var(--border); background: rgba(44, 51, 54, .45);
  border-radius: var(--radius); aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; cursor: pointer; color: var(--muted);
  transition: border-color 180ms var(--ease), color 180ms var(--ease);
  font-family: inherit; font-size: 11px;
}
.up-btn:hover { border-color: var(--gold); color: var(--text); }
.up-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; }
.up-btn input { display: none; }

.thumb {
  position: relative; aspect-ratio: 1; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--border); background: var(--panel);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.thumb-del {
  position: absolute; top: 5px; right: 5px;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(20, 24, 26, .8); border: none; cursor: pointer;
  color: var(--text); display: flex; align-items: center; justify-content: center;
  transition: color 160ms var(--ease);
}
.thumb-del:hover { color: var(--gold); }
.thumb-del svg { width: 12px; height: 12px; stroke: currentColor; fill: none; }

/* ---------- 勾選框 ---------- */

.check-row { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }

.check-row input[type=checkbox] {
  appearance: none; -webkit-appearance: none;
  width: 20px; height: 20px; flex-shrink: 0; margin-top: 2px;
  border: 1px solid var(--border); border-radius: 4px;
  background: transparent; cursor: pointer; position: relative;
  transition: border-color 180ms var(--ease), background-color 180ms var(--ease);
}
.check-row input[type=checkbox]:checked {
  border-color: var(--gold); background: rgba(212, 175, 106, .2);
}
.check-row input[type=checkbox]:checked::after {
  content: ''; position: absolute; left: 6px; top: 2px;
  width: 6px; height: 11px;
  border: solid var(--gold); border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.check-row .ct { font-size: 13px; line-height: 1.8; color: var(--text); }
.check-row .cs { display: block; font-size: 11.5px; color: var(--muted); font-weight: 300; margin-top: 3px; line-height: 1.7; }

.check-box {
  border: 1px solid var(--border); background: var(--panel);
  border-radius: var(--radius); padding: 16px;
}
.check-box.invalid { border-color: var(--danger); }

/* ---------- 條件展開 ---------- */

.cond { display: none; }
.cond.open { display: block; animation: slideIn 320ms var(--ease); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.sub-panel {
  margin-top: 14px; padding: 16px;
  background: rgba(44, 51, 54, .5);
  border: 1px solid var(--border); border-radius: var(--radius);
}

.sub-panel .lbl:first-child { margin-top: 0; }

/* ---------- 按鈕 ---------- */

.btn-ghost {
  width: 100%; padding: 15px; border: 1px dashed var(--border);
  background: transparent; color: var(--silver);
  border-radius: var(--radius); font-family: inherit; font-size: 13.5px;
  cursor: pointer; letter-spacing: .04em;
  transition: border-color 180ms var(--ease), color 180ms var(--ease);
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }

.submit {
  width: 100%; padding: 18px; border: none; border-radius: var(--radius);
  background: var(--gold); color: var(--bg);
  font-family: inherit; font-size: 15px; font-weight: 700; letter-spacing: .08em;
  cursor: pointer; transition: background-color 200ms var(--ease), opacity 200ms var(--ease);
}
.submit:hover:not(:disabled) { background: var(--gold-hi); }
.submit:disabled { opacity: .35; cursor: not-allowed; }

/* ---------- 燈箱 ---------- */

.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(14, 17, 18, .88);
  display: none; align-items: flex-end; justify-content: center;
  padding: 0;
}
.modal.open { display: flex; }

.modal-box {
  background: var(--panel); border-top: 1px solid var(--border);
  width: 100%; max-width: 640px; max-height: 88vh;
  border-radius: 12px 12px 0 0; overflow-y: auto;
  animation: sheetUp 340ms var(--ease);
  padding: 22px 20px 32px;
}

@keyframes sheetUp { from { transform: translateY(24px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }

.modal-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 6px;
}
.modal-head h3 { font-family: 'Noto Serif TC', serif; font-size: 19px; font-weight: 600; }
.modal-en {
  font-family: 'Cormorant Garamond', serif; font-size: 10px;
  letter-spacing: .2em; text-transform: uppercase; color: var(--gold);
  display: block; margin-bottom: 3px;
}

.modal-close {
  background: none; border: none; cursor: pointer; color: var(--muted);
  padding: 4px; flex-shrink: 0; transition: color 160ms var(--ease);
}
.modal-close:hover { color: var(--text); }
.modal-close svg { width: 20px; height: 20px; stroke: currentColor; fill: none; }

.modal-desc { font-size: 13px; line-height: 1.95; color: var(--muted); font-weight: 300; margin: 12px 0 18px; }

.modal-foot { margin-top: 20px; display: grid; gap: 10px; }

/* ---------- 照片藝廊 ---------- */

.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.gallery.g3 { grid-template-columns: repeat(3, 1fr); }

/* 佔位框是「預設」狀態，照片載入成功才蓋上去。
   邏輯刻意反過來：檔案不存在、lazy 沒觸發、網路斷掉——任何情況
   都只會停在佔位框，不會出現破圖。素材未到不擋上線。 */
.shot {
  aspect-ratio: 1; border-radius: var(--radius); overflow: hidden;
  border: 1px dashed var(--border); background: var(--panel-2);
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.shot::after {
  content: '照片準備中';
  font-size: 11px; color: var(--muted); letter-spacing: .08em; font-weight: 300;
}
/* 用 display 切換而不是 opacity 淡入：淡入需要瀏覽器產生繪製影格才會
   推進，萬一沒推進，照片就永遠是透明的。顯示與否不拿來賭動畫。 */
.shot img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover; display: none;
}

.shot.ok { border-style: solid; }
.shot.ok::after { content: none; }
.shot.ok img { display: block; }

/* ---------- 上傳中／錯誤 ---------- */

.status {
  margin-top: 16px; padding: 14px 16px; border-radius: var(--radius);
  font-size: 13px; line-height: 1.8; display: none;
}
.status.show { display: block; }
.status.working { border: 1px solid var(--border); background: var(--panel); color: var(--muted); }
.status.bad { border: 1px solid var(--danger); background: rgba(217, 136, 120, .1); color: var(--danger); }

.bar { height: 2px; background: var(--border); border-radius: 2px; margin-top: 10px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--gold); transition: width 300ms var(--ease); }

/* ---------- 草稿還原提示 ---------- */

.draft-note {
  border: 1px solid rgba(212, 175, 106, .38); background: var(--panel-2);
  border-radius: var(--radius); padding: 13px 15px; margin-bottom: 28px;
  display: none; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 12.5px; color: var(--muted); line-height: 1.7;
}
.draft-note.show { display: flex; }
.draft-note button {
  background: none; border: none; color: var(--gold); cursor: pointer;
  font-family: inherit; font-size: 12.5px; text-decoration: underline;
  text-underline-offset: 3px; flex-shrink: 0; padding: 4px;
}

/* ---------- 完成畫面 ---------- */

.done { display: none; }
.done.show { display: block; animation: slideIn 420ms var(--ease); }

.done-mark {
  width: 54px; height: 54px; border-radius: 50%; margin: 0 auto 18px;
  border: 1px solid rgba(212, 175, 106, .45); background: rgba(212, 175, 106, .1);
  display: flex; align-items: center; justify-content: center;
}
.done-mark svg { width: 26px; height: 26px; stroke: var(--gold); fill: none; }

.done-top { text-align: center; padding: 20px 0 28px; border-bottom: 1px solid var(--border); margin-bottom: 26px; }
.done-top h2 { font-family: 'Noto Serif TC', serif; font-size: 22px; font-weight: 700; margin-bottom: 10px; }
.done-top p { font-size: 13px; color: var(--muted); line-height: 1.9; font-weight: 300; }

.code-box {
  border: 1px solid rgba(212, 175, 106, .5); background: var(--panel);
  border-radius: var(--radius-lg); padding: 24px 20px; text-align: center;
  margin-bottom: 26px;
}
.code-cap {
  font-family: 'Cormorant Garamond', serif; font-size: 10px;
  letter-spacing: .26em; text-transform: uppercase; color: var(--silver);
  display: block; margin-bottom: 8px;
}
.code-val {
  font-family: 'Cormorant Garamond', serif; font-size: 40px; font-weight: 600;
  letter-spacing: .1em; color: var(--gold); line-height: 1.2;
}

.summary { border: 1px solid var(--border); border-radius: var(--radius); background: rgba(44, 51, 54, .5); padding: 4px 16px; }
.sum-row { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid rgba(65, 74, 77, .55); font-size: 13px; }
.sum-row:last-child { border-bottom: none; }
.sum-k { color: var(--muted); flex-shrink: 0; font-weight: 300; }
.sum-v { color: var(--text); text-align: right; line-height: 1.7; }

.sum-head {
  font-family: 'Noto Serif TC', serif; font-size: 13px; color: var(--gold);
  padding: 14px 0 4px; border-bottom: 1px solid rgba(65, 74, 77, .55); letter-spacing: .06em;
}

/* ---------- guide.html ---------- */

.guide-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 44px; }
.guide-nav a {
  font-size: 12.5px; color: var(--silver); text-decoration: none;
  border: 1px solid var(--border); border-radius: 100px;
  padding: 8px 14px; transition: border-color 180ms var(--ease), color 180ms var(--ease);
}
.guide-nav a:hover { border-color: var(--gold); color: var(--gold); }

.guide-body { font-size: 14px; line-height: 2; color: var(--text); font-weight: 300; }
.guide-body p { margin-bottom: 14px; }
.guide-body p:last-child { margin-bottom: 0; }
.guide-body strong { color: var(--gold); font-weight: 500; }

.spec-list { margin: 18px 0 0; padding: 0; list-style: none; }
.spec-list li {
  display: flex; gap: 12px; padding: 11px 0;
  border-bottom: 1px solid rgba(65, 74, 77, .5); font-size: 13.5px; line-height: 1.8;
}
.spec-list li:last-child { border-bottom: none; }
.spec-list .k { color: var(--gold); flex-shrink: 0; width: 5.5em; font-weight: 500; }
.spec-list .v { color: var(--muted); font-weight: 300; }

.back-link {
  display: inline-block; margin-top: 8px; font-size: 13px;
  color: var(--silver); text-decoration: none;
  border-bottom: 1px solid var(--border); padding-bottom: 3px;
  transition: color 180ms var(--ease), border-color 180ms var(--ease);
}
.back-link:hover { color: var(--gold); border-color: var(--gold); }

/* ---------- 無障礙 ---------- */

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media (max-width: 380px) {
  .pills.c3 { grid-template-columns: repeat(2, 1fr); }
  h1 { font-size: 23px; }
  .code-val { font-size: 34px; }
}
