/* ==============================================================
 * 拍她 · styles.css
 * 目标：单屏、无装饰、全屏沉浸，黑底为主，所有交互色按文档 §7 视觉规范
 * ============================================================== */

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Helvetica Neue", Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* ---------- 取景层 & 画布层叠放 ---------- */

#camera,
#filter-canvas,
#overlay-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#filter-canvas,
#overlay-canvas {
  pointer-events: none;
}

/* 视频原画预览在前；滤镜画布叠加在视频之上；引导线画在最上 */
#camera {
  z-index: 1;
  background: #000;
  transform: scaleX(-1); /* 默认前置摄像头镜像显示 */
}

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

#overlay-canvas {
  z-index: 3;
}

/* 屏幕方向 / 镜像标记翻转 */
#app.mirrored #camera,
#app.mirrored #filter-canvas {
  transform: scaleX(-1);
}

#app:not(.mirrored) #camera,
#app:not(.mirrored) #filter-canvas {
  transform: scaleX(1);
}

#app.flipped #overlay-canvas {
  transform: scaleX(-1);
}

#app:not(.flipped) #overlay-canvas {
  transform: scaleX(1);
}

/* ---------- 主界面 ---------- */

#app {
  position: relative;
  width: 100%;
  height: 100%;
}

/* ---------- 顶部信息条 ---------- */

.top-bar {
  position: fixed;
  top: env(safe-area-inset-top, 0);
  left: 0;
  right: 0;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
  pointer-events: none;
}

.top-bar > * {
  pointer-events: auto;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  /* 用实底代替半透明+blur：blur 在手机 GPU 上是持续开销，多个常驻元素会拖慢预览 */
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
  white-space: nowrap;
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill.dim {
  opacity: 0.6;
}

.pill.ready {
  color: #1d9e75;
}

.pill.error {
  color: #ff6b6b;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

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

/* ---------- 提示文案 ---------- */

.hint-text {
  position: fixed;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  text-shadow:
    0 0 6px rgba(0, 0, 0, 0.85),
    0 0 12px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 5;
  transition: color 200ms ease;
}

.hint-text.ok {
  color: #1d9e75;
  animation: pulse 200ms ease;
}

@keyframes pulse {
  0% {
    transform: translateY(-50%) scale(1);
  }
  50% {
    transform: translateY(-50%) scale(1.08);
  }
  100% {
    transform: translateY(-50%) scale(1);
  }
}

/* ---------- 底部控制条 ---------- */

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: env(safe-area-inset-bottom, 0);
  padding: 12px 16px 16px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.55) 60%);
  z-index: 10;
}

.filter-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.filter-pill {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
}

.filter-pill:active {
  transform: scale(0.95);
}

.filter-pill.active {
  background: rgba(255, 255, 255, 0.85);
  color: #000;
  border-color: rgba(255, 255, 255, 0.95);
}

.control-row {
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.shutter {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 4px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 100ms ease;
  position: relative;
}

.shutter:active {
  transform: scale(0.92);
}

.shutter.capturing .shutter-inner {
  transform: scale(0.85);
}

.shutter-inner {
  display: block;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #fff;
  transition: transform 100ms ease;
}

/* ---------- 滤镜强度滑杆 ---------- */

.strength-slider {
  position: fixed;
  left: 32px;
  right: 32px;
  bottom: calc(env(safe-area-inset-bottom, 0) + 180px);
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 11;
  color: #fff;
  font-size: 13px;
}

.strength-slider input[type="range"] {
  flex: 1;
  accent-color: #1d9e75;
}

/* ---------- 连拍结果面板 ---------- */

.review-panel {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  padding-top: calc(env(safe-area-inset-top, 0) + 16px);
}

.review-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
}

.review-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
  overflow-y: auto;
}

.review-item {
  position: relative;
  aspect-ratio: 3 / 4;
  background: #222;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color 200ms ease;
}

.review-item.rank-1 {
  border-color: #1d9e75;
}

.review-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.review-item .score {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 6px;
  font-size: 11px;
  border-radius: 4px;
}

.review-item .rank-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: #1d9e75;
  color: #000;
  font-weight: 700;
  padding: 2px 6px;
  font-size: 11px;
  border-radius: 4px;
}

/* ---------- 错误/引导界面（满屏卡片） ---------- */

.overlay-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #0d0d0d;
  z-index: 100;
}

.card {
  max-width: 380px;
  background: #1a1a1a;
  border-radius: 16px;
  padding: 24px;
  text-align: left;
}

.card h1 {
  font-size: 20px;
  margin: 0 0 12px;
}

.card p {
  font-size: 14px;
  line-height: 1.6;
  color: #ccc;
  margin: 0 0 12px;
}

.card p.steps {
  background: #111;
  padding: 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.8;
  margin: 16px 0;
}

.card .hint {
  font-size: 12px;
  color: #999;
  margin-top: 12px;
}

.btn {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  background: #fff;
  color: #000;
  cursor: pointer;
}

.btn.primary {
  background: #1d9e75;
}

.btn:active {
  transform: scale(0.98);
}

/* ---------- 闪光动画（拍照瞬间） ---------- */

.flash {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  animation: flashAnim 250ms ease-out;
}

@keyframes flashAnim {
  0% {
    opacity: 0;
  }
  10% {
    opacity: 0.85;
  }
  100% {
    opacity: 0;
  }
}

/* ---------- 小屏适配 ---------- */

/* 手机竖屏：滤镜按钮排可横向滑动，避免挤爆；字号/间距收窄 */
@media (max-width: 480px) {
  .filter-row {
    gap: 8px;
    margin-bottom: 12px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
  }
  .filter-row::-webkit-scrollbar {
    display: none;
  }
  .filter-pill {
    padding: 5px 12px;
    font-size: 13px;
    flex-shrink: 0;
  }
  .hint-text {
    font-size: clamp(17px, 5vw, 22px);
  }
  .comp-btn {
    font-size: 12px;
    max-width: 34vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .advisor-card {
    width: min(92%, 340px);
    bottom: 27%;
  }
}

@media (max-height: 640px) {
  .hint-text {
    font-size: 22px;
  }
  .shutter {
    width: 64px;
    height: 64px;
  }
  .shutter-inner {
    width: 50px;
    height: 50px;
  }
}
/* ============================================================
 *  混合版新增：构图模板按钮 + AI 顾问卡片
 * ============================================================ */

.comp-btn {
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
}
.comp-btn:active {
  background: rgba(255, 255, 255, 0.2);
}

.advisor-btn {
  font-size: 18px;
}

.advisor-card {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 24%;
  width: min(86%, 340px);
  background: rgba(20, 20, 20, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 12px 14px;
  color: #fff;
  z-index: 30;
  backdrop-filter: blur(8px);
}

.advisor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 8px;
}

.advisor-body {
  font-size: 15px;
  line-height: 1.5;
}

.advisor-msg {
  font-weight: 600;
  margin: 0 0 6px;
}

.advisor-action {
  font-size: 13px;
  color: #7fd8b5;
  margin: 0;
}
