/* ==========================================================================
   数字长城 Digital Great Wall — 砖墙主题
   色值与尺寸严格锁定于 IMPLEMENTATION_PLAN.md 第 7A 节，不得自行调色。
   ========================================================================== */

:root {
  --bg: #14161c;
  --text: #e8e6e1;
  --text-dim: #9a9aa0;
  --gold: #c9a227;
  --panel: #1e2129;
  --border: #3a3f4a;
  --input-bg: #14161c;

  --radius-panel: 12px;
  --radius-btn: 8px;
  --shadow-panel: 0 8px 32px rgba(0, 0, 0, .5);
  --btn-height: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   顶部栏
   -------------------------------------------------------------------------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}

.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }

.brand-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* 进度 */
.progress { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.progress-text { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.progress-num { color: var(--gold); font-weight: 600; }

.progress-bar {
  width: 140px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--gold);
  border-radius: 2px;
  transition: width .4s ease;
}

/* 语言切换 */
.lang-btn {
  height: 32px;
  min-width: 44px;
  padding: 0 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.lang-btn:hover { border-color: var(--gold); color: var(--gold); }

/* --------------------------------------------------------------------------
   Canvas
   -------------------------------------------------------------------------- */
#wall {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: calc(100% - 56px);
  display: block;
  cursor: grab;
  touch-action: none;
}

#wall:active { cursor: grabbing; }

/* --------------------------------------------------------------------------
   工具栏
   -------------------------------------------------------------------------- */
.toolbar {
  position: fixed;
  left: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 15;
}

.tool-group {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  overflow: hidden;
}

.tool-btn {
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
}

.tool-btn:hover { background: var(--input-bg); color: var(--gold); }
.tool-btn + .tool-btn { border-top: 1px solid var(--border); }

.search-box {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  overflow: hidden;
}

.search-box input {
  width: 130px;
  height: 40px;
  padding: 0 10px;
  background: var(--input-bg);
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

.search-box input:focus { background: var(--input-bg); }

.search-box button {
  padding: 0 12px;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.search-box button:hover { color: var(--gold); }

/* 悬停信息条（编号 / tier / 价格 / 状态） */
.hover-tip {
  position: fixed;
  left: 76px;
  bottom: 68px;
  max-width: min(400px, calc(100vw - 100px));
  padding: 7px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  color: var(--text-dim);
  font-size: 12px;
  pointer-events: none;
  z-index: 16;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
}

.hover-tip strong { color: var(--text); font-weight: 600; }

/* --------------------------------------------------------------------------
   弹窗
   -------------------------------------------------------------------------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-mask.open { display: flex; }

.modal {
  width: 100%;
  max-width: 480px;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--panel);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-panel);
  padding: 20px;
}

.modal-title {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.modal-sub {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-dim);
}

/* 步骤指示 */
.steps {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
}

.step-dot {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
}

.step-dot.active { background: var(--gold); }

/* 详情行 */
.detail-rows { margin-bottom: 16px; }

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.detail-row:last-child { border-bottom: none; }
.detail-row .k { color: var(--text-dim); }
.detail-row .v { color: var(--text); text-align: right; word-break: break-all; }
.detail-row .v.price { color: var(--gold); font-weight: 600; }

/* 状态标签 */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  border: 1px solid var(--border);
}

.badge.available { color: var(--gold); border-color: var(--gold); }
.badge.reserved { color: var(--text-dim); }
.badge.sold { color: var(--text); }

/* 刻字内容（VISUAL_FIX.md P2：16px 字号，配图圆角 8px） */
.inscription-box {
  margin: 12px 0;
  padding: 14px 16px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.inscription-box a { color: var(--gold); }

/* 成功态里的刻字回显，字号小一号避免抢占「上墙成功」主信息 */
.success-brick-no + .inscription-box {
  font-size: 14px;
  padding: 10px 12px;
  text-align: left;
}

.inscription-img {
  display: block;
  max-width: 100%;
  border-radius: 8px;
  margin-top: 10px;
  border: 1px solid var(--border);
}

/* 注：.brick-swatch-lg 的唯一定义在下方「详情页展示砖块颜色」小节 */

/* --------------------------------------------------------------------------
   表单
   -------------------------------------------------------------------------- */
.field { margin-bottom: 14px; }

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-dim);
}

.field input[type="text"],
.field input[type="email"],
.field textarea {
  width: 100%;
  padding: 10px 12px;
  min-height: var(--btn-height);
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

.field textarea { min-height: 88px; resize: vertical; }

.field input:focus, .field textarea:focus { border-color: var(--gold); }

.field-hint { margin-top: 4px; font-size: 12px; color: var(--text-dim); }
.field-count { text-align: right; font-size: 12px; color: var(--text-dim); }
.field-count.over { color: #a63a3a; }

/* 文件上传 */
.file-input { display: none; }

.file-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--btn-height);
  padding: 0 12px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius-btn);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
}

.file-label:hover { border-color: var(--gold); color: var(--gold); }

.img-preview {
  position: relative;
  margin-top: 10px;
  max-width: 220px;
}

.img-preview img {
  display: block;
  width: 100%;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border);
}

.img-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}

.img-remove:hover { color: var(--gold); border-color: var(--gold); }

/* 注：原 .color-grid / .color-opt 固定色块样式已被调色板的
   .preset-grid / .preset-opt 取代，见文件下方「调色板」小节。 */

/* 详情页展示砖块颜色 */
.detail-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-size: 13px;
}

.detail-color-label { color: var(--text-dim); }
.detail-color-hex {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  letter-spacing: .5px;
}

.brick-swatch-lg {
  display: inline-block;
  width: 18px;
  height: 14px;
  border-radius: 3px;
  vertical-align: -2px;
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2),
              inset 0 -1px 0 rgba(0, 0, 0, .2);
}

/* --------------------------------------------------------------------------
   调色板（用户可自选任意颜色）
   -------------------------------------------------------------------------- */

/* 预览行：色块 + hex 输入 */
.color-preview-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.color-preview {
  width: 56px;
  height: 44px;
  flex: 0 0 56px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border);
  /* 内阴影模拟砖块质感，所见即墙上效果 */
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .18),
              inset 0 -2px 0 rgba(0, 0, 0, .22);
}

.color-preview-meta { flex: 1; min-width: 0; }

.hex-input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  letter-spacing: .5px;
  text-transform: uppercase;
  outline: none;
}

.hex-input:focus { border-color: var(--gold); }

.field-hint.warn { color: #a63a3a; }

/* 分组标签 */
.preset-label {
  margin: 12px 0 8px;
  font-size: 12px;
  color: var(--text-dim);
}

/* 精选预设色 */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.preset-opt {
  height: 38px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 0;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .18),
              inset 0 -2px 0 rgba(0, 0, 0, .22);
  transition: transform .1s ease;
}

.preset-opt:hover { transform: translateY(-1px); }

.preset-opt.selected {
  border-color: var(--gold);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .18),
              inset 0 -2px 0 rgba(0, 0, 0, .22),
              0 0 0 1px var(--gold);
}

/* 色相环 */
.hue-ring {
  display: block;
  width: 168px;
  height: 168px;
  margin: 4px auto 14px;
  cursor: pointer;
  touch-action: none;
  border-radius: 50%;
}

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

/* 饱和度 / 明度滑条 */
.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.slider-label {
  font-size: 12px;
  color: var(--text-dim);
  flex: 0 0 52px;
}

.slider {
  flex: 1;
  height: 6px;
  appearance: none;
  background: transparent;
  cursor: pointer;
  outline: none;
}

.slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--input-bg);
}

.slider::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--text);
  border: 1px solid var(--border);
}

.slider::-webkit-slider-thumb:hover { background: var(--gold); }

.slider::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--input-bg);
}

.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  border: 1px solid var(--border);
}

.slider-val {
  font-size: 12px;
  color: var(--text-dim);
  flex: 0 0 38px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 420px) {
  .preset-grid { grid-template-columns: repeat(6, 1fr); gap: 6px; }
  .preset-opt { height: 34px; }
}

/* --------------------------------------------------------------------------
   按钮
   -------------------------------------------------------------------------- */
.btn {
  height: var(--btn-height);
  padding: 0 18px;
  border-radius: var(--radius-btn);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-primary {
  width: 100%;
  background: var(--gold);
  color: var(--bg);
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) { background: #b18f1f; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.btn-row .btn { flex: 1; }

/* --------------------------------------------------------------------------
   支付步骤
   -------------------------------------------------------------------------- */
.pay-amount {
  margin: 16px 0;
  padding: 16px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  text-align: center;
}

.pay-amount .num {
  display: block;
  font-size: 28px;
  font-weight: 600;
  color: var(--gold);
}

.pay-amount .cur { font-size: 13px; color: var(--text-dim); }

.countdown {
  margin: 12px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
}

.countdown .time {
  color: var(--gold);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.pay-hint { text-align: center; font-size: 12px; color: var(--text-dim); }

/* 支付中 loading */
.spinner {
  width: 22px;
  height: 22px;
  margin: 0 auto 12px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* 成功态 */
.success-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border: 2px solid var(--gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-size: 26px;
}

/* 撒花：z-index 高于弹窗但不覆盖顶部栏，避免遮挡品牌与进度 */
.confetti {
  position: fixed;
  top: 56px;
  width: 8px;
  height: 14px;
  z-index: 45;
  pointer-events: none;
  animation: fall linear forwards;
}

@keyframes fall {
  to { transform: translateY(calc(100dvh - 56px)) rotate(720deg); opacity: 0; }
}

.success-brick-no {
  margin: 14px 0;
  padding: 12px;
  background: var(--input-bg);
  border: 1px solid var(--gold);
  border-radius: var(--radius-btn);
  text-align: center;
  color: var(--gold);
  font-weight: 600;
}

/* 错误提示 */
.err-box {
  margin: 12px 0;
  padding: 10px 12px;
  background: var(--input-bg);
  border: 1px solid #a63a3a;
  border-radius: var(--radius-btn);
  color: #a63a3a;
  font-size: 13px;
}

/* Toast */
.toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: var(--radius-btn);
  color: var(--text);
  font-size: 13px;
  z-index: 80;
  display: none;
  max-width: calc(100% - 32px);
}

.toast.show { display: block; }

/* 加载遮罩 */
.loading-mask {
  position: fixed;
  inset: 56px 0 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text-dim);
  font-size: 14px;
  z-index: 10;
}

.loading-mask.hidden { display: none; }

/* --------------------------------------------------------------------------
   响应式
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .brand-sub { display: none; }
  .progress-bar { width: 80px; }
  .search-box input { width: 100px; }
  .modal { padding: 16px; }
  .hover-tip { display: none; }
}

@media (max-width: 400px) {
  .progress-text { display: none; }
}
