/* =========================================================
   风格转绘照相机 · Dark Gallery Edition
   深炭背景 + 金箔强调 + 衬线标题
   ========================================================= */

/* ---------- Design Tokens ---------- */
:root {
  --bg: #14110f;
  --bg-elev: #1c1815;
  --surface: #221e1b;
  --surface-hi: #2a2522;
  --border: rgba(255, 255, 255, 0.08);

  --text: #f5f0e8;
  --text-dim: #9a9088;
  --text-mute: #6b6259;

  --accent: #c9a96a;
  --accent-hi: #e0c285;
  --lock: #4ade80;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-soft: 0 20px 60px rgba(0, 0, 0, 0.5);

  --font-display: "Cormorant Garamond", "Noto Serif SC", serif;
  --font-body: "Manrope", "Noto Sans SC", -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(1200px 620px at 50% -8%, rgba(201, 169, 106, 0.10), transparent 60%),
    radial-gradient(900px 520px at 50% 108%, rgba(201, 169, 106, 0.05), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* 画廊氛围：细密噪点纹理 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

/* ---------- Header ---------- */
.app-header {
  text-align: center;
  margin-bottom: 16px;
  padding-top: 4px;
}

.eyebrow {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0;
  animation: fadeUp 600ms ease 80ms both;
}

.app-header h1 {
  margin: 6px 0 4px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.05;
  letter-spacing: 0.01em;
  color: var(--text);
  opacity: 0;
  animation: fadeUp 800ms ease 160ms both;
}

.subtitle {
  margin: 0;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  opacity: 0;
  animation: fadeUp 800ms ease 240ms both;
}

.rule {
  width: 64px;
  height: 1px;
  margin: 22px auto 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  animation: fadeIn 800ms ease 360ms both;
}

/* ---------- Stage ---------- */
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.camera-container {
  position: relative;
  width: 100%;
  max-width: 540px;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: #0c0a09;
  border: 1px solid var(--border);
  box-shadow:
    var(--shadow-soft),
    inset 0 0 0 1px rgba(201, 169, 106, 0.14);
}

#webcam,
#preview-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#webcam {
  transform: scaleX(-1);
  z-index: 1;
}

#preview-canvas {
  z-index: 2;
}

/* 画面框上方控制区：状态文字 + hint提示 + 摄像头选择器，纵向排列 */
.camera-controls-top {
  width: 100%;
  max-width: 540px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* 状态文字：居中显示在画面框上方 */
.status-bar {
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-align: center;
}

/* 画面框上方的hint提示（复用.hint样式，居中） */
.hint-top {
  margin: 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-mute);
  letter-spacing: 0.06em;
}

/* 摄像头选择器靠右对齐 */
.camera-controls-top #camera-select {
  align-self: flex-end;
}

/* 摄像头选择：玻璃拟态胶囊 */
#camera-select {
  padding: 8px 26px 8px 12px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(20, 17, 15, 0.55);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23c9a96a' stroke-width='1.2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 180ms ease, background-color 180ms ease;
}

#camera-select:hover {
  border-color: rgba(201, 169, 106, 0.4);
  background-color: rgba(20, 17, 15, 0.7);
}

#camera-select option {
  background: var(--surface);
  color: var(--text);
}

/* ---------- Controls ---------- */
.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  width: 100%;
  max-width: 540px;
}

.picker-label {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  color: var(--text-mute);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 16px;
  letter-spacing: 0.08em;
}

.picker-label::before,
.picker-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

/* 风格选择：3列网格（移动端2列） */
.style-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
}

.style-btn {
  display: flex;
  flex-direction: column;
  padding: 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  cursor: pointer;
  overflow: hidden;
  transition: background 180ms ease, border-color 180ms ease,
    box-shadow 180ms ease, transform 180ms ease;
  opacity: 0;
  animation: reveal 560ms ease both;
}

.style-btn:nth-child(1) { animation-delay: 0.42s; }
.style-btn:nth-child(2) { animation-delay: 0.47s; }
.style-btn:nth-child(3) { animation-delay: 0.52s; }
.style-btn:nth-child(4) { animation-delay: 0.57s; }
.style-btn:nth-child(5) { animation-delay: 0.62s; }
.style-btn:nth-child(6) { animation-delay: 0.67s; }
.style-btn:nth-child(7) { animation-delay: 0.72s; }
.style-btn:nth-child(8) { animation-delay: 0.77s; }
.style-btn:nth-child(9) { animation-delay: 0.82s; }

.style-swatch {
  display: block;
  height: 56px;
  width: 100%;
}

.style-name {
  display: block;
  text-align: center;
  padding: 10px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  transition: color 180ms ease;
}

.style-btn:hover {
  background: var(--surface-hi);
  border-color: rgba(255, 255, 255, 0.16);
}

.style-btn:hover .style-name {
  color: var(--text);
}

.style-btn.active {
  border-color: var(--accent);
  border-width: 1.5px;
  background: var(--surface-hi);
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 24px rgba(201, 169, 106, 0.25), 0 0 0 1px rgba(201, 169, 106, 0.20);
}

.style-btn.active .style-name {
  color: var(--accent-hi);
  font-weight: 600;
}

/* 拍照按钮：金色环形 76px */
.capture-btn {
  position: relative;
  width: 76px;
  height: 76px;
  margin-top: 4px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: transparent;
  cursor: pointer;
  box-shadow:
    0 0 0 4px rgba(201, 169, 106, 0.10),
    0 10px 28px rgba(0, 0, 0, 0.45);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.capture-btn::after {
  content: "";
  position: absolute;
  inset: 13px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--accent-hi), var(--accent) 70%);
  box-shadow: 0 0 16px rgba(201, 169, 106, 0.55);
  transition: background 120ms ease, box-shadow 120ms ease;
}

.capture-btn:hover {
  box-shadow:
    0 0 0 5px rgba(201, 169, 106, 0.16),
    0 12px 30px rgba(0, 0, 0, 0.5);
}

.capture-btn:active {
  transform: scale(0.92);
}

.capture-btn:active::after {
  background: var(--accent);
  box-shadow: 0 0 10px rgba(201, 169, 106, 0.4);
}

.hint {
  margin: 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-mute);
  letter-spacing: 0.06em;
}

/* ---------- Gallery ---------- */
/* 画廊悬浮在画面框右侧，不影响画面框居中 */
.gallery {
  position: absolute;
  top: 100px;
  right: 0;
  width: 260px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding: 0 4px 4px 0;
}

.gallery-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.gallery h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: 0.01em;
}

.gallery-tag {
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.85;
}

.gallery-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gallery-grid img {
  width: 100%;
  display: block;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: transform 220ms ease, box-shadow 220ms ease;
}

.gallery-grid img:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(201, 169, 106, 0.25);
}

/* ---------- Footer ---------- */
.app-footer {
  margin-top: 56px;
  padding-top: 20px;
  text-align: center;
  border-top: 1px solid var(--border);
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--text-mute);
}

/* ---------- Keyframes ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .app {
    padding: 16px;
  }
  .app-header {
    margin-bottom: 24px;
  }
  .app-header h1 {
    font-size: 34px;
  }
  .stage {
    gap: 20px;
  }
  .style-picker {
    grid-template-columns: repeat(2, 1fr);
  }
  .camera-container {
    border-radius: var(--radius-lg);
  }
  .gallery {
    position: static;
    width: 100%;
    max-height: none;
    margin-top: 40px;
  }
  .gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
  .gallery-head {
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
  }
  .gallery h2 {
    font-size: 24px;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- Onboarding 新手引导弹窗 ---------- */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 400ms ease both;
}

.onboarding-overlay.hidden {
  display: none;
}

.onboarding-card {
  width: 90%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 40px;
  background: var(--bg-elev);
  border: 1px solid rgba(201, 169, 106, 0.2);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
  animation: fadeUp 600ms ease both;
}

.onboarding-header {
  text-align: center;
  margin-bottom: 8px;
}

.onboarding-eyebrow {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--accent);
}

.onboarding-card h2 {
  margin: 10px 0 6px;
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text);
}

.onboarding-sub {
  margin: 0;
  font-size: 14px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.onboarding-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin: 32px 0;
}

.onboarding-item {
  text-align: center;
}

.gesture-svg {
  width: 80px;
  height: 80px;
  margin: 0 auto 12px;
  color: var(--accent);
}

.gesture-svg svg {
  width: 100%;
  height: 100%;
  display: block;
}

.onboarding-item h3 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}

.onboarding-item p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
}

.onboarding-start {
  display: block;
  margin: 0 auto;
  padding: 12px 40px;
  border: 1px solid var(--accent);
  border-radius: 100px;
  background: transparent;
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background 180ms ease, box-shadow 180ms ease, color 180ms ease;
}

.onboarding-start:hover {
  background: rgba(201, 169, 106, 0.1);
  box-shadow: 0 0 0 4px rgba(201, 169, 106, 0.1);
  color: var(--accent-hi);
}

/* Onboarding 移动端：单列 */
@media (max-width: 640px) {
  .onboarding-card {
    padding: 28px 20px;
  }
  .onboarding-card h2 {
    font-size: 26px;
  }
  .onboarding-grid {
    grid-template-columns: 1fr;
    gap: 20px;
    margin: 24px 0;
  }
}
