/* ============================
   八膳合 · 中医体质自测问卷
   主样式文件
   ============================ */

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #8B5E3C;
  --primary-lt: #C49A6C;
  --primary-dk: #5C3D20;
  --accent:     #D4A853;
  --green:      #5A7A5A;
  --green-lt:   #8AAF8A;
  --bg:         #FAF7F2;
  --card-bg:    #FFFFFF;
  --text:       #2D1F0F;
  --text-sub:   #6B5040;
  --text-mute:  #A0896E;
  --border:     #E8DDD0;
  --shadow:     rgba(139, 94, 60, 0.12);
  --radius:     16px;
  --radius-sm:  10px;
  --font:       'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

html { font-size: 16px; -webkit-tap-highlight-color: transparent; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- Page system ---- */
.page { display: none; min-height: 100vh; }
.page.active { display: block; }
.page.hidden { display: none !important; }

/* ---- COVER PAGE ---- */
#page-cover {
  position: relative;
  min-height: 100vh;
  background: linear-gradient(160deg, #3D2010 0%, #6B3D1E 40%, #8B5E3C 70%, #C49A6C 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.cover-bg {
  position: absolute; inset: 0; pointer-events: none;
}

.cover-pattern {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(212,168,83,0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(255,255,255,0.05) 0%, transparent 50%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Ccircle cx='30' cy='30' r='1' fill='rgba(255,255,255,0.06)'/%3E%3C/svg%3E");
}

.cover-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 40px 28px 60px;
  max-width: 420px;
  width: 100%;
}

.brand-badge {
  width: 72px; height: 72px;
  background: rgba(255,255,255,0.12);
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 24px;
  font-size: 32px;
  /* backdrop-filter removed: causes artifacts in headless screenshot */
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  background: rgba(255,255,255,0.18);
}

.cover-title {
  font-size: 36px;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.3;
  letter-spacing: 2px;
  margin-bottom: 10px;
  text-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.cover-sub {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  letter-spacing: 3px;
  margin-bottom: 24px;
}

.cover-desc {
  font-size: 15px;
  color: rgba(255,255,255,0.85);
  line-height: 1.8;
  margin-bottom: 32px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 16px 20px;
  border: 1px solid rgba(255,255,255,0.12);
}

.cover-tips {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 36px;
  flex-wrap: wrap;
}

.tip-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 24px;
  padding: 8px 16px;
  font-size: 13px;
  color: rgba(255,255,255,0.9);
}

.tip-icon { font-size: 16px; }

.btn-start {
  display: block;
  width: 100%;
  max-width: 280px;
  margin: 0 auto 20px;
  padding: 18px 32px;
  background: linear-gradient(135deg, var(--accent) 0%, #B8893A 100%);
  color: #FFFFFF;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 4px;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(212,168,83,0.4), 0 2px 8px rgba(0,0,0,0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-start:active {
  transform: scale(0.97);
  box-shadow: 0 4px 12px rgba(212,168,83,0.3);
}

.cover-notice {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  line-height: 1.6;
}

/* ---- SURVEY NAV ---- */
.survey-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250,247,242,0.98);
  /* backdrop-filter removed: causes artifacts in headless screenshot */
  border-bottom: 1px solid var(--border);
  padding: 12px 16px 8px;
}

.nav-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.nav-back {
  width: 36px; height: 36px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--primary);
  transition: background 0.15s;
}

.nav-back:active { background: var(--border); }

.nav-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

#nav-section-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

#nav-step-indicator {
  font-size: 11px;
  color: var(--text-mute);
}

.nav-logo {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 1px;
}

.progress-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-bar-track {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-pct {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  min-width: 32px;
  text-align: right;
}

/* ---- SECTION PAGE ---- */
.section-page {
  padding-bottom: 40px;
}

.section-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 24px 20px 20px;
  background: linear-gradient(135deg, var(--primary-dk) 0%, var(--primary) 100%);
  color: white;
  position: relative;
  overflow: hidden;
}

.section-header::before {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 120px; height: 120px;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
}

.section-number {
  font-size: 44px;
  font-weight: 800;
  color: rgba(255,255,255,0.2);
  line-height: 1;
  min-width: 56px;
  font-variant-numeric: tabular-nums;
}

.section-info { flex: 1; }

.section-title {
  font-size: 20px;
  font-weight: 700;
  color: #FFFFFF;
  margin-bottom: 4px;
  letter-spacing: 1px;
}

.section-desc {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  line-height: 1.5;
}

.section-icon {
  font-size: 28px;
  opacity: 0.8;
  position: relative;
  z-index: 1;
}

/* ---- QUESTIONS ---- */
.questions-container {
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.question-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: 0 2px 8px var(--shadow);
  transition: box-shadow 0.2s;
}

.question-card.answered {
  border-color: var(--primary-lt);
  box-shadow: 0 2px 12px rgba(139,94,60,0.15);
}

.q-text {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 14px;
  font-weight: 500;
}

.q-num {
  color: var(--primary);
  font-weight: 700;
  margin-right: 4px;
}

.options-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-item {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.option-item input[type="radio"] {
  display: none;
}

.option-btn {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-sub);
  transition: all 0.18s ease;
  line-height: 1.4;
  position: relative;
}

.option-btn::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: white;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.option-btn {
  padding-left: 38px;
}

.option-item input[type="radio"]:checked + .option-btn {
  background: linear-gradient(135deg, rgba(139,94,60,0.08) 0%, rgba(196,154,108,0.05) 100%);
  border-color: var(--primary);
  color: var(--primary-dk);
  font-weight: 600;
}

.option-item input[type="radio"]:checked + .option-btn::before {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: inset 0 0 0 3px white;
}

/* ---- FOOTER BUTTONS ---- */
.section-footer {
  padding: 20px 16px 32px;
}

.btn-next, .btn-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 16px 24px;
  border: none;
  border-radius: 50px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 2px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s;
}

.btn-next {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-lt) 100%);
  color: white;
  box-shadow: 0 6px 20px rgba(139,94,60,0.35);
  gap: 8px;
}

.btn-next:active { transform: scale(0.97); }

.btn-arrow { font-size: 18px; transition: transform 0.2s; }
.btn-next:active .btn-arrow { transform: translateX(4px); }

.btn-submit {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-lt) 100%);
  color: white;
  box-shadow: 0 6px 20px rgba(90,122,90,0.35);
  gap: 8px;
  font-size: 16px;
}

.btn-submit:active { transform: scale(0.97); }
.submit-icon { font-size: 20px; }

/* ---- LOADING PAGE ---- */
#page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.loading-content {
  text-align: center;
  padding: 40px 28px;
}

.loading-animation {
  position: relative;
  width: 100px; height: 100px;
  margin: 0 auto 32px;
}

.loading-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid transparent;
  animation: spin 1.5s linear infinite;
}

.ring1 {
  border-top-color: var(--primary);
  animation-duration: 1.2s;
}

.ring2 {
  inset: 10px;
  border-right-color: var(--accent);
  animation-duration: 1.8s;
  animation-direction: reverse;
}

.ring3 {
  inset: 20px;
  border-bottom-color: var(--green);
  animation-duration: 2.4s;
}

.loading-yin-yang {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 28px;
  animation: pulse 2s ease-in-out infinite;
}

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

@keyframes pulse {
  0%, 100% { opacity: 0.6; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
}

.loading-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.loading-sub {
  font-size: 13px;
  color: var(--text-mute);
  line-height: 1.6;
}

/* ---- Utility ---- */
.hidden { display: none !important; }

/* ---- Page entry animation ---- */
@keyframes slideInUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.section-page.active { animation: slideInUp 0.35s ease-out; }

/* ---- Scrollbar (mobile hidden) ---- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ---- PRIVACY MODAL ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  /* backdrop-filter removed: causes artifacts in headless screenshot */
  animation: fadeIn 0.25s ease;
}

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

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

.modal-card {
  background: #FFFFFF;
  border-radius: 24px;
  padding: 40px 28px 32px;
  margin: 0 20px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(40px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.privacy-modal { padding-bottom: 24px; }

.privacy-icon {
  font-size: 48px;
  margin-bottom: 16px;
  animation: pulse 2s ease-in-out infinite;
}

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

.privacy-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary-dk);
  margin-bottom: 20px;
  letter-spacing: 1px;
}

.privacy-body {
  text-align: left;
  margin-bottom: 28px;
}

.privacy-body p {
  font-size: 14px;
  color: var(--text-sub);
  line-height: 1.85;
}

.privacy-body strong {
  color: var(--primary);
}

.privacy-note {
  text-align: center !important;
  margin-top: 12px;
  font-size: 13px !important;
  color: var(--text-mute) !important;
}

.privacy-btn {
  display: block;
  width: 100%;
  padding: 16px 24px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-lt) 100%);
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(139, 94, 60, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.privacy-btn:active {
  transform: scale(0.97);
  box-shadow: 0 3px 10px rgba(139, 94, 60, 0.25);
}

/* ============================================================
   截图兼容模式（?export=1）
   修复无头浏览器生成长图时的渲染异常：
   - fixed/sticky 元素改为 relative（避免长图重复渲染）
   - 提高半透明背景不透明度（避免 alpha 采样偏差）
   - 隐藏弹窗（截图时不需要）
   ============================================================ */
body.export-mode .survey-nav {
  position: relative !important;
  background: rgba(250,247,242,1) !important;
}

body.export-mode .modal-overlay {
  display: none !important;
}

body.export-mode .brand-badge {
  background: rgba(255,255,255,0.22) !important;
}

body.export-mode .cover-desc {
  background: rgba(255,255,255,0.12) !important;
}

body.export-mode .section-header {
  background: var(--primary) !important;
}

/* 禁用所有动画（避免截图时动画帧导致画面撕裂） */
body.export-mode * {
  animation-duration: 0.001s !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001s !important;
}
