/* 知序 · 拍照搜题页 (#photo)。完全复用 ui.css token 与组件。 */

.photo {
  display: grid;
  gap: 18px;
}

.photo .page-head {
  margin-bottom: 4px;
}

/* 三步流程条 */
.photo-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}

.photo-step {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-3);
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}

.photo-step-dot {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--sunken);
  color: var(--ink-3);
  font-size: 12.5px;
  font-weight: 700;
}

.photo-step.is-active {
  background: var(--brand-soft);
  color: var(--brand-ink);
}
.photo-step.is-active .photo-step-dot {
  background: var(--brand);
  color: #fff;
}

.photo-step.is-done {
  color: var(--ink-2);
}
.photo-step.is-done .photo-step-dot {
  background: var(--ok-soft);
  color: var(--ok);
}

/* 上传 + 核对两步工作区 */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.photo-card {
  padding: clamp(18px, 2.2vw, 24px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.photo-step-title {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.photo-step-badge {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  margin-top: 1px;
  border-radius: 7px;
  background: var(--sunken);
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  font-weight: 700;
  transition: background-color 0.16s var(--ease), color 0.16s var(--ease);
}
.photo-card.is-active .photo-step-badge {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 1px 2px rgba(25, 49, 120, 0.24);
}
.photo-card.is-done .photo-step-badge {
  background: var(--ok-soft);
  color: var(--ok);
}
.photo-card.is-active {
  border-color: var(--brand-line);
  box-shadow: var(--shadow-md);
}
.photo-step-title h2 {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
}
.photo-step-title p {
  margin-top: 3px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-2);
}

/* 大触控上传区（含 3D 光学镜头与扫描光束微动效） */
.photo-upload {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  flex: 1;
  min-height: 210px;
  padding: 24px 18px;
  border: 1.5px dashed var(--brand-line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.16s var(--ease), background-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.photo-upload > *:not(.photo-scan-beam) { position: relative; z-index: 1; }
.photo-scan-beam {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 0;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent 0%, rgba(37, 84, 199, 0.72) 50%, transparent 100%);
  box-shadow: 0 0 14px 2px rgba(59, 130, 246, 0.28);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}
.photo-upload-art-wrap {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin-bottom: 2px;
}
.photo-lens-art {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(15, 23, 42, 0.16));
  transition: transform 0.36s cubic-bezier(0.22, 1.15, 0.36, 1), filter 0.24s ease-out;
  transition-timing-function: linear(0, 0.42 16%, 1.06 42%, 0.99 70%, 1), ease-out;
}
@media (prefers-reduced-motion: no-preference) {
  .photo-upload:hover .photo-lens-art,
  .photo-upload.is-dragover .photo-lens-art {
    transform: translateY(-2px) scale(1.08);
    filter: drop-shadow(0 12px 18px rgba(37, 84, 199, 0.22));
  }
  .photo-upload:hover .photo-scan-beam,
  .photo-upload.is-dragover .photo-scan-beam,
  .photo-upload.is-loading .photo-scan-beam {
    opacity: 1;
    animation: photo-beam-sweep 2.1s ease-in-out infinite;
  }
  @keyframes photo-beam-sweep {
    0% { transform: translateY(12px); opacity: 0; }
    14% { opacity: 0.9; }
    86% { opacity: 0.9; }
    100% { transform: translateY(196px); opacity: 0; }
  }
}
.photo-upload:hover,
.photo-upload.is-dragover {
  border-color: var(--brand);
  background: var(--brand-soft);
}
#photo-file-input:focus-visible + .photo-upload {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.photo-upload-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  color: var(--brand-ink);
  margin-bottom: 4px;
}
.photo-upload strong {
  font-size: var(--t-md);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.photo-upload small {
  font-size: var(--t-xs);
  color: var(--ink-3);
  line-height: 1.55;
  text-wrap: balance;
  max-width: 40ch;
}

/* 图片预览与识别遮罩 */
.photo-preview-wrap {
  position: relative;
  min-height: 160px;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--sunken);
}
.photo-preview {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: contain;
}
.photo-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(243, 244, 246, 0.86);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: var(--brand-ink);
  font-size: 14px;
  font-weight: 600;
}
.photo-preview-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.photo-preview-bar label.is-disabled {
  pointer-events: none;
  opacity: 0.5;
}

/* 状态提示条 */
.photo-status {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-2);
  margin-top: auto;
}
.photo-status svg {
  flex: none;
  margin-top: 2px;
}
.photo-status.is-loading {
  background: var(--brand-soft);
  border-color: var(--brand-line);
  color: var(--brand-ink);
}
.photo-status.is-ok {
  background: var(--ok-soft);
  border-color: var(--ok-line);
  color: var(--ok);
}
.photo-status.is-warn {
  background: var(--warn-soft);
  border-color: var(--warn-line);
  color: var(--warn);
}
.photo-status.is-bad {
  background: var(--bad-soft);
  border-color: var(--bad-line);
  color: var(--bad);
}

/* 识别加载与文本区 */
.photo-loading-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
  color: var(--brand-ink);
  font-size: 13.5px;
  font-weight: 600;
}

.photo-card textarea {
  width: 100%;
  flex: 1;
  min-height: 180px;
  padding: 12px 14px;
  background: var(--surface-2);
}
.photo-card textarea:focus {
  background: var(--surface);
}
.photo-card textarea:disabled {
  opacity: 0.65;
  cursor: wait;
}

.photo-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.photo-note {
  margin-top: -4px;
}

.photo-spin {
  display: inline-flex;
  animation: photo-rotate 0.9s linear infinite;
}
@keyframes photo-rotate {
  to {
    transform: rotate(360deg);
  }
}

/* 第 3 步结果列表（与题库卡片风格一致） */
.photo-results {
  display: grid;
  gap: 14px;
  margin-top: 4px;
  scroll-margin-top: 16px;
}
.photo-results-head {
  padding: 2px 0;
}

.photo-result-list {
  display: grid;
  gap: 14px;
}
.photo-result-card {
  padding: clamp(18px, 2.2vw, 24px);
  display: grid;
  gap: 14px;
}
.photo-result-head {
  display: grid;
  gap: 8px;
}
.photo-result-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.photo-badge-source {
  max-width: 28ch;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  line-height: 22px;
}
.photo-result-card h3 {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink);
}

.photo-stem {
  font-size: 15.5px;
  line-height: 1.78;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.photo-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}
.photo-options.is-stacked {
  grid-template-columns: minmax(0, 1fr);
}
.photo-option {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
}
.photo-opt-key {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--sunken);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 700;
}
.photo-opt-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.photo-result-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

@media (max-width: 820px) {
  .photo-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 700px) {
  .photo {
    gap: 14px;
  }
  .photo-steps {
    gap: 4px;
    padding: 4px;
  }
  .photo-step {
    padding: 6px 8px;
    gap: 6px;
    font-size: 12.5px;
    justify-content: center;
  }
  .photo-step-dot {
    width: 20px;
    height: 20px;
    font-size: 11.5px;
  }
  .photo-upload {
    min-height: 170px;
    padding: 20px 14px;
  }
  .photo-card textarea {
    min-height: 140px;
  }
  .photo-actions > button {
    flex: 1 1 auto;
  }
  .photo-actions > [data-action="clear-text"] {
    flex: 0 0 auto;
  }
  .photo-options {
    grid-template-columns: minmax(0, 1fr);
  }
  .photo-result-actions > button {
    flex: 1 1 auto;
  }
}

/* 相机触发按钮组与网页实时取景器 */
.photo-upload {
  cursor: default;
}
.photo-trigger-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
  width: 100%;
}
.photo-trigger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--r-sm);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.photo-trigger-btn.is-disabled {
  pointer-events: none;
  opacity: 0.55;
}
.photo-live-fallback {
  margin-top: 2px;
  font-size: 13px;
}
.photo-camera-stage {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0f172a;
  aspect-ratio: 4 / 3;
  min-height: 220px;
}
.photo-camera-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-camera-guide {
  position: absolute;
  inset: 14% 8%;
  border: 2px dashed rgba(255, 255, 255, 0.72);
  border-radius: 10px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.28);
}
.photo-camera-guide span {
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.68);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}
.photo-camera-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.photo-camera-bar > .primary {
  flex: 1 1 160px;
}
.photo-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  flex-wrap: wrap;
}
.photo-scope-seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 9px;
  background: var(--surface-2, #f4f4f3);
  border: 1px solid var(--line, rgba(17, 19, 24, 0.085));
}
.photo-scope-seg button {
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-3, #52565e);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.photo-scope-seg button[aria-pressed="true"] {
  background: #ffffff;
  color: var(--ink, #111318);
  box-shadow: 0 1px 2px rgba(17, 19, 24, 0.08);
}
.photo-result-card.is-mistake {
  border-left: 3px solid #c94a38;
}
.photo-badge-mistake {
  background: rgba(201, 74, 56, 0.1);
  color: #a93828;
  border: 1px solid rgba(201, 74, 56, 0.24);
  font-weight: 700;
}
.photo-sol {
  border-top: 1px solid var(--line, rgba(17, 19, 24, 0.08));
  padding-top: 8px;
}
.photo-sol > summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--brand-ink, #2b44ad);
  user-select: none;
}
.photo-sol-body {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--surface-2, #f4f4f3);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--ink-2, #343840);
}
.photo-sol-ans {
  margin: 0 0 6px;
}
.photo-sol-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
@media (max-width: 700px) {
  .photo-trigger-row {
    flex-direction: column;
    align-items: stretch;
  }
  .photo-trigger-btn {
    width: 100%;
  }
}
