/* ========== 基礎與變數 ========== */
:root {
  --bg: #020617;
  --surface: rgba(15, 23, 42, 0.4);
  --border: rgba(255, 255, 255, 0.1);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #f59e0b;
  --accent-glow: rgba(245, 158, 11, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Microsoft JhengHei", sans-serif;
}

.hidden {
  display: none !important;
}

/* ========== 背景光暈 ========== */
.bg-glow {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.bg-glow::before,
.bg-glow::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.5;
}

.bg-glow::before {
  top: -10%;
  left: -10%;
  width: 40vw;
  height: 40vw;
  background: rgba(30, 58, 138, 0.15);
  animation: pulse-bg 5s ease-in-out infinite;
}

.bg-glow::after {
  bottom: -10%;
  right: -10%;
  width: 30vw;
  height: 30vw;
  background: rgba(120, 53, 15, 0.15);
}

@keyframes pulse-bg {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.8; }
}

.app {
  position: relative;
  z-index: 10;
}

/* ========== 步驟切換 ========== */
.step {
  min-height: 100vh;
  padding-top: 5rem;
  padding-bottom: 3rem;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

/* ========== 步驟一：上傳 ========== */
.upload-wrap {
  max-width: 56rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.upload-header {
  text-align: center;
  margin-bottom: 3rem;
}

.upload-header h1 {
  font-size: 2rem;
  font-weight: 400;
  margin: 0 0 1rem;
  letter-spacing: 0.05em;
}

.upload-header .accent {
  color: var(--accent);
}

.upload-header p {
  color: var(--text-muted);
  font-size: 1.125rem;
  max-width: 36rem;
  margin: 0 auto;
}

.cards {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.5rem;
  width: 100%;
  margin-bottom: 3rem;
}

@media (max-width: 768px) {
  .cards {
    grid-template-columns: 1fr;
  }
}

/* 玻璃卡 */
.glass-card,
.card {
  background: var(--surface);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: border-color 0.3s, background 0.3s;
}

.card.has-image {
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(120, 53, 15, 0.1);
}

.card-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.card-preview .preview-img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-preview.has-image .preview-img {
  display: block;
}

.card-preview.has-image .placeholder {
  display: none;
}

.placeholder {
  color: #64748b;
  font-size: 0.875rem;
}

.card-preview .overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
}

.card-preview:hover .overlay {
  opacity: 1;
}

.btn-overlay {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background 0.2s, color 0.2s;
}

.btn-overlay:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.badge-ok {
  display: none;
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: #22c55e;
  color: white;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  font-size: 0.75rem;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.card-preview.has-image .badge-ok {
  display: flex;
}

.card h3 {
  font-size: 1.25rem;
  font-weight: 400;
  margin: 0 0 0.25rem;
}

.card > p {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0 0 1.5rem;
}

.card-actions {
  display: flex;
  gap: 0.75rem;
  width: 100%;
}

.card-actions .btn {
  flex: 1;
  font-size: 0.75rem;
  padding: 0.5rem 0.25rem;
}

.card.has-image .card-actions {
  display: none;
}

/* 按鈕 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 9999px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.3s;
  font-size: 1rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #0f172a;
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
  background: #fbbf24;
  box-shadow: 0 0 30px rgba(245, 158, 11, 0.5);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.sticky-bottom {
  position: sticky;
  bottom: 2rem;
  z-index: 20;
}

.sticky-bottom .btn-primary {
  width: 16rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: scale(1.1);
}

/* ========== 步驟二：分析中 ========== */
.analyzing-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.analyzing-rings {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.2;
}

.analyzing-rings::before,
.analyzing-rings::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 50%;
  animation: ping-ring 3s ease-out infinite;
}

.analyzing-rings::before {
  width: 500px;
  height: 500px;
}

.analyzing-rings::after {
  width: 300px;
  height: 300px;
  animation-delay: 0.7s;
}

@keyframes ping-ring {
  0% { transform: scale(0.8); opacity: 0.2; }
  100% { transform: scale(1.2); opacity: 0; }
}

.analyzing-content {
  position: relative;
  z-index: 10;
  text-align: center;
}

.analyzing-icon {
  width: 8rem;
  height: 8rem;
  margin: 0 auto 2rem;
  color: var(--accent);
  font-size: 5rem;
  line-height: 1;
  animation: spin 3s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.analyzing-content h2 {
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  margin: 0 0 0.5rem;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.typewriter {
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
  font-size: 0.875rem;
  min-height: 1.5rem;
}

/* ========== 步驟三：報告 ========== */
.report-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  padding: 1.5rem 1.5rem;
  transition: background 0.5s, border 0.5s;
}

.report-nav.scrolled {
  background: rgba(2, 6, 23, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding: 1rem 1.5rem;
}

.nav-inner {
  max-width: 80rem;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-logo {
  font-size: 1.25rem;
  letter-spacing: 0.1em;
  color: #f1f5f9;
}

.report-hero {
  padding-top: 8rem;
  padding-bottom: 3rem;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.hero-inner {
  max-width: 65rem;
  margin: 0 auto;
  text-align: center;
  margin-bottom: 4rem;
}

.hero-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 9999px;
  background: rgba(245, 158, 11, 0.05);
  color: #fde68a;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}

.hero-inner h1 {
  font-size: 2.25rem;
  font-weight: 400;
  margin: 0 0 2rem;
  line-height: 1.2;
}

.hero-thumbs {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.hero-thumbs img {
  width: 5rem;
  height: 6rem;
  object-fit: cover;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

.report-summary {
  padding: 1.5rem;
}

.report-summary .glass-card {
  max-width: 56rem;
  margin: 0 auto;
}

.summary-inner {
  padding: 2rem 1rem 2rem;
  text-align: center;
}

.summary-inner h2 {
  font-size: 1.5rem;
  font-weight: 400;
  margin: 0 0 1.5rem;
}

.divider {
  width: 4rem;
  height: 2px;
  background: rgba(245, 158, 11, 0.5);
  margin: 0 auto 1.5rem;
}

.summary-p {
  color: #cbd5e1;
  line-height: 1.8;
  font-size: 1.125rem;
  text-align: justify;
  max-width: 36rem;
  margin: 0 auto;
}

.report-detail {
  padding: 3rem 1.5rem;
}

.detail-inner {
  max-width: 72rem;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2rem;
}

@media (max-width: 1024px) {
  .detail-inner {
    grid-template-columns: 1fr;
  }
}

.detail-menu {
  position: sticky;
  top: 8rem;
  height: fit-content;
}

.menu-title {
  font-size: 0.75rem;
  font-family: ui-monospace, monospace;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 1rem 0.5rem;
}

.detail-menu button {
  width: 100%;
  text-align: left;
  padding: 1rem;
  border-radius: 0.75rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all 0.3s;
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.detail-menu button:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.detail-menu button.active {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  box-shadow: 0 10px 15px -3px rgba(120, 53, 15, 0.1);
  color: #fde68a;
}

.detail-menu .menu-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: #1e293b;
  color: var(--text-muted);
}

.detail-menu button.active .menu-icon {
  background: var(--accent);
  color: #0f172a;
}

.detail-menu .menu-text {
  flex: 1;
}

.detail-menu .menu-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
}

.detail-content-wrap {
  min-height: 600px;
  position: relative;
}

.detail-panel {
  position: absolute;
  inset: 0;
  transition: opacity 0.5s, transform 0.5s;
  opacity: 0;
  transform: translateX(2rem);
  pointer-events: none;
  z-index: 0;
}

.detail-panel.active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
  z-index: 10;
}

.detail-panel .glass-card {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.panel-header h3 {
  font-size: 1.875rem;
  font-weight: 400;
  margin: 0 0 0.5rem;
}

.panel-highlight {
  color: rgba(251, 191, 36, 0.8);
  font-weight: 500;
}

.panel-score {
  text-align: right;
}

.panel-score .num {
  font-size: 2.25rem;
  color: rgba(255, 255, 255, 0.9);
}

.panel-score .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.panel-body {
  flex: 1;
}

.panel-body p {
  color: #cbd5e1;
  line-height: 2;
  font-size: 1.125rem;
  margin-bottom: 1.5rem;
}

.advice-box {
  margin-top: 2.5rem;
  padding: 1.5rem;
  background: linear-gradient(to right, rgba(120, 53, 15, 0.2), transparent);
  border-radius: 0.75rem;
  border-left: 2px solid var(--accent);
}

.advice-box h4 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #fde68a;
  font-weight: 400;
  margin: 0 0 0.5rem;
}

.advice-box p {
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.6;
  margin: 0;
}

.report-final {
  padding: 6rem 1.5rem;
  text-align: center;
}

.report-final h2 {
  font-size: 2.25rem;
  font-weight: 400;
  margin: 0 0 2rem;
}

.final-p {
  color: #cbd5e1;
  line-height: 1.8;
  font-size: 1.125rem;
  max-width: 42rem;
  margin: 0 auto 3rem;
}

.report-footer {
  padding: 2.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  text-align: center;
}

.report-footer p {
  font-size: 0.875rem;
  font-family: ui-monospace, monospace;
  color: #475569;
  margin: 0;
}

/* ========== 相機彈窗 ========== */
.camera-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  display: flex;
  flex-direction: column;
}

.camera-header {
  height: 4rem;
  padding: 0 1rem;
  background: #000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 20;
}

.camera-header span {
  color: white;
}

.camera-header strong {
  color: var(--accent);
}

.camera-close {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  cursor: pointer;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.camera-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.camera-view {
  flex: 1;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#camera-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

#camera-canvas {
  position: absolute;
  left: -9999px;
}

.camera-guide {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.guide-frame {
  width: 70vw;
  max-width: 400px;
  height: 70vw;
  max-height: 500px;
  border: 2px dashed rgba(245, 158, 11, 0.5);
  border-radius: 40%;
  opacity: 0.6;
  animation: pulse 2s ease-in-out infinite;
}

.camera-guide span {
  position: absolute;
  top: 2.5rem;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.875rem;
}

.camera-flash {
  position: absolute;
  inset: 0;
  background: white;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

.camera-flash.show {
  opacity: 1;
}

.camera-error {
  text-align: center;
  padding: 2rem;
  max-width: 24rem;
}

.camera-error .hidden {
  display: none !important;
}

.camera-error p {
  color: white;
  margin-bottom: 1.5rem;
}

.camera-footer {
  height: 8rem;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.shutter-btn {
  position: relative;
  width: 5rem;
  height: 5rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.shutter-outer {
  position: absolute;
  inset: 0;
  border: 6px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  transition: transform 0.1s;
}

.shutter-btn:active .shutter-outer {
  transform: scale(0.95);
}

.shutter-inner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 66px;
  height: 66px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
  transition: transform 0.1s;
}

.shutter-btn:active .shutter-inner {
  transform: translate(-50%, -50%) scale(0.9);
}

/* 列印時隱藏不需要的區塊 */
@media print {
  .report-nav,
  .btn,
  .detail-menu,
  #btn-print,
  .sticky-bottom {
    display: none !important;
  }

  .step {
    padding-top: 1rem;
  }

  .detail-inner {
    display: block;
  }

  .detail-panel {
    position: static !important;
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto !important;
    page-break-inside: avoid;
  }
}
