/* ==========================================================================
   《耐人尋味：老夫子的前世今生》魅力工學問卷風格系統
   以經典書報紙質、雅緻深墨藍、琥珀金與復古朱紅為視覺基底
   完全響應式（RWD）：電腦版左圖右題，手機版上下無縫排列
   ========================================================================== */

:root {
  --font-sans: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Noto Serif TC', Georgia, serif;
  
  /* 色彩系統 */
  --bg-main: #F4EFE6;         /* 溫潤懷舊米紙底色 */
  --bg-card: #FFFFFF;         /* 純白卡片底 */
  --bg-subtle: #F9F6F0;       /* 柔和淺底 */
  --border-color: #E2D9CC;    /* 典雅邊框灰褐 */
  --border-hover: #CBD5E0;
  
  --primary: #1A365D;         /* 經典墨藍 */
  --primary-light: #2B6CB0;   /* 亮藍 */
  --primary-soft: #EBF8FF;    /* 淡藍底 */
  --accent-gold: #D69E2E;     /* 琥珀金 */
  --accent-red: #C53030;      /* 復古朱紅 */
  --accent-green: #2F855A;    /* 墨綠 */
  --accent-purple: #6B46C1;   /* 雅紫 */
  
  --text-main: #2D3748;       /* 炭黑正文 */
  --text-muted: #718096;      /* 次級灰字 */
  --text-light: #A0AEC0;
  
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* 頂部固定導航列 */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 12px 20px;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand .badge {
  background: var(--accent-gold);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.brand h1 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--primary);
  letter-spacing: 0.5px;
}

/* 步驟指示器 */
.stepper-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.step-dot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.step-dot .num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #E2E8F0;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
}

.step-dot.active {
  color: var(--primary);
  font-weight: 700;
}

.step-dot.active .num {
  background: var(--primary);
  color: #fff;
}

.step-dot.completed .num {
  background: var(--accent-green);
  color: #fff;
}

.step-line {
  width: 20px;
  height: 2px;
  background: #E2E8F0;
}

/* 主容器 */
.main-container {
  max-width: 1100px;
  margin: 28px auto 60px;
  padding: 0 16px;
}

/* 頁面切換控制 */
.survey-page {
  display: none;
  animation: fadeIn 0.3s ease forwards;
}

.survey-page.active {
  display: block;
}

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

/* 卡片共用樣式 */
.hero-card, .egm-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: 24px;
}

.hero-banner {
  background: linear-gradient(135deg, #1A365D 0%, #2B6CB0 100%);
  color: #fff;
  padding: 36px 32px;
  text-align: center;
}

.hero-banner h2 {
  font-family: var(--font-serif);
  font-size: 1.85rem;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.hero-sub {
  font-size: 1.05rem;
  opacity: 0.9;
}

.card-body {
  padding: 32px;
}

/* 研究基本資訊四格表 */
.academic-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 24px;
}

.meta-item {
  display: flex;
  flex-direction: column;
}

.meta-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.meta-val {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
}

/* 說明文字區塊 */
.notice-box {
  background: #FFFDF7;
  border-left: 4px solid var(--accent-gold);
  border-radius: 4px;
  padding: 16px 20px;
  margin-bottom: 28px;
}

.notice-box h3 {
  font-size: 1.05rem;
  color: #744210;
  margin-bottom: 8px;
}

.notice-box p {
  font-size: 0.92rem;
  color: #4A5568;
  margin-bottom: 8px;
  line-height: 1.65;
}

.notice-box p:last-child {
  margin-bottom: 0;
}

/* 同意書勾選 */
.consent-group {
  background: #FEFCBF;
  border: 1px solid #ECC94B;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 28px;
}

.consent-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.consent-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--accent-red);
}

.consent-text {
  font-weight: 700;
  font-size: 1rem;
  color: #744210;
}

/* 標題與必填標記 */
.field-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.q-tag {
  background: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  padding: 2px 7px;
  border-radius: 4px;
}

.req {
  color: var(--accent-red);
}

/* 單選卡片網格 (老夫子閱讀經驗) */
.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.radio-card {
  position: relative;
  display: block;
  cursor: pointer;
}

.radio-card input {
  position: absolute;
  opacity: 0;
}

.radio-card .card-content {
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--bg-card);
  transition: all 0.2s ease;
  height: 100%;
}

.radio-card .card-content strong {
  display: block;
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: 4px;
}

.radio-card .card-content p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.radio-card input:checked + .card-content {
  border-color: var(--primary-light);
  background: var(--primary-soft);
  box-shadow: 0 0 0 1px var(--primary-light);
}

/* 按鈕樣式 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-weight: 700;
  border-radius: var(--radius-md);
  padding: 12px 24px;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
  font-size: 0.95rem;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 10px rgba(26, 54, 93, 0.25);
}

.btn-primary:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #EDF2F7;
  color: var(--text-main);
}

.btn-secondary:hover {
  background: #E2E8F0;
}

.btn-large {
  padding: 14px 32px;
  font-size: 1.05rem;
}

.action-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

/* 浮動底列 */
.sticky-footer {
  position: sticky;
  bottom: 0;
  z-index: 90;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
  padding: 16px 24px;
  margin-top: 40px;
  border-radius: var(--radius-md);
}

/* ==========================================================================
   PAGE 1: 20幅漫畫快速評分 (精緻左圖右題/手機上下並排)
   ========================================================================== */

.section-intro-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--bg-card);
  padding: 20px 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.section-intro-bar h2 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  color: var(--primary);
}

.section-intro-bar .sub {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.progress-indicator {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.95rem;
}

.progress-indicator strong {
  font-size: 1.15rem;
  color: var(--accent-red);
}

/* 20 幅卡片容器 */
.comic-rate-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.comic-card-unit {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: grid;
  grid-template-columns: 55% 45%; /* 電腦版左圖右題 */
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.comic-card-unit:hover {
  box-shadow: var(--shadow-lg);
}

/* 左側圖片區 */
.comic-view-col {
  background: #111827;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 460px;
  padding: 16px;
}

.comic-view-col img {
  max-width: 100%;
  max-height: 480px;
  object-fit: contain;
  cursor: zoom-in;
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: transform 0.25s ease;
}

.comic-view-col img:hover {
  transform: scale(1.02);
}

.zoom-hint {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 14px;
  pointer-events: none;
}

/* 右側問卷評分區 */
.comic-action-col {
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #FFFDF9;
}

.comic-header-info {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--border-color);
}

.comic-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
  margin-bottom: 8px;
}

.tag-early { background: #EDF2F7; color: #4A5568; }
.tag-mid { background: #EBF8FF; color: #2B6CB0; }
.tag-recent { background: #FAF5FF; color: #6B46C1; }

.comic-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  color: var(--primary);
  margin-bottom: 4px;
}

.comic-no {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

/* 評分按鈕群組 (1~5 星級/數字) */
.rating-section {
  margin-top: 10px;
}

.rating-prompt {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-main);
  margin-bottom: 12px;
}

.score-btn-group {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.score-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 6px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.score-btn input {
  position: absolute;
  opacity: 0;
}

.score-btn .num-label {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--text-main);
  line-height: 1;
  margin-bottom: 4px;
}

.score-btn .text-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
}

.score-btn:hover {
  border-color: var(--primary-light);
  background: var(--primary-soft);
}

.score-btn input:checked + .btn-inner {
  color: #fff;
}

.score-btn.active {
  background: var(--primary);
  border-color: var(--primary);
}

.score-btn.active .num-label {
  color: #fff;
}

.score-btn.active .text-label {
  color: #E2E8F0;
}

.score-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}


/* ==========================================================================
   PAGE 2: 第二階段 跨時期與正反對照深入感受 (EGM 選擇題)
   ========================================================================== */

.egm-card {
  margin-bottom: 32px;
}

.card-header-badge {
  padding: 20px 24px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 16px;
}

.card-header-badge.blue { background: linear-gradient(135deg, #1A365D 0%, #2B6CB0 100%); }
.card-header-badge.green { background: linear-gradient(135deg, #1C4532 0%, #2F855A 100%); }
.card-header-badge.purple { background: linear-gradient(135deg, #44337A 0%, #6B46C1 100%); }
.card-header-badge.red { background: linear-gradient(135deg, #742A2A 0%, #C53030 100%); }

.badge-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 900;
  flex-shrink: 0;
}

.card-header-badge h3 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  margin-bottom: 2px;
}

.card-header-badge p {
  font-size: 0.88rem;
  opacity: 0.9;
}

/* 挑選作品縮圖輪播/選單 */
.select-comic-selector {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.thumb-choice-card {
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  position: relative;
}

.thumb-choice-card img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  background: #f0f0f0;
}

.thumb-choice-card .caption {
  padding: 6px 4px;
  font-size: 0.75rem;
  text-align: center;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thumb-choice-card:hover {
  border-color: var(--primary-light);
  transform: translateY(-2px);
}

.thumb-choice-card.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 2px var(--primary);
}

.thumb-choice-card.selected::after {
  content: '✓';
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--primary);
  color: #fff;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 標籤複選方塊 (Tag Checkbox) */
.tag-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.tag-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.tag-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.tag-item span {
  font-size: 0.9rem;
  color: var(--text-main);
}

.tag-item:hover {
  background: var(--bg-subtle);
  border-color: var(--border-hover);
}

.tag-item.checked {
  background: var(--primary-soft);
  border-color: var(--primary-light);
  font-weight: 500;
}

/* 負向對照卡專用色彩 */
.contrast-card .tag-item.checked {
  background: #FFF5F5;
  border-color: var(--accent-red);
}

.contrast-card .tag-item input[type="checkbox"] {
  accent-color: var(--accent-red);
}

/* ==========================================================================
   PAGE 3: 基本資料與送出
   ========================================================================== */

.card-header-simple {
  padding: 28px 32px 12px;
}

.card-header-simple h2 {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  color: var(--primary);
  margin-bottom: 4px;
}

.card-header-simple p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.pill-btn {
  position: relative;
  cursor: pointer;
}

.pill-btn input {
  position: absolute;
  opacity: 0;
}

.pill-btn span {
  display: inline-block;
  padding: 10px 20px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: #fff;
  font-size: 0.92rem;
  color: var(--text-main);
  transition: all 0.2s ease;
}

.pill-btn:hover span {
  border-color: var(--primary-light);
  background: var(--bg-subtle);
}

.pill-btn input:checked + span {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 700;
}

.submit-box {
  margin-top: 36px;
  background: #FFFDF7;
  border: 1px dashed var(--accent-gold);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
}

.submit-note {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.btn-submit-now {
  background: linear-gradient(135deg, #1A365D 0%, #2B6CB0 100%);
  font-size: 1.15rem;
  padding: 16px 40px;
  box-shadow: 0 6px 18px rgba(26, 54, 93, 0.3);
}

.btn-submit-now:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(26, 54, 93, 0.4);
}

/* ==========================================================================
   PAGE 4: 感謝與結果收據
   ========================================================================== */

.success-card {
  text-align: center;
  padding: 60px 32px;
}

.success-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  animation: bounce 1s infinite alternate;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

.success-card h2 {
  font-family: var(--font-serif);
  font-size: 2rem;
  color: var(--primary);
  margin-bottom: 8px;
}

.success-desc {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto 32px;
}

.result-receipt {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  max-width: 480px;
  margin: 0 auto 32px;
  padding: 24px;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.95rem;
}

.receipt-row:last-child {
  border-bottom: none;
}

.id-tag {
  font-size: 1.35rem;
  color: var(--accent-red);
  font-family: monospace;
}

.status-badge {
  background: #C6F6D5;
  color: #22543D;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 700;
}

.final-wish {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--primary);
  font-weight: 700;
}

/* ==========================================================================
   Lightbox 放大燈箱
   ========================================================================== */

.lightbox-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-modal.active {
  display: flex;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}

.lightbox-caption {
  color: #fff;
  margin-top: 10px;
  font-size: 1rem;
  font-family: var(--font-serif);
}

.lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 2.2rem;
  cursor: pointer;
}

/* ==========================================================================
   RWD 手機與平板專用適應
   ========================================================================== */

@media (max-width: 768px) {
  .app-header {
    padding: 10px 14px;
  }
  
  .brand h1 {
    font-size: 1.05rem;
  }
  
  .stepper-nav .step-dot .label {
    display: none; /* 手機版隱藏文字標籤，僅保留數字圓圈 */
  }
  
  .hero-banner {
    padding: 24px 16px;
  }
  
  .hero-banner h2 {
    font-size: 1.4rem;
  }
  
  .card-body {
    padding: 20px 16px;
  }
  
  /* 電腦雙欄改為手機上下並排 */
  .comic-card-unit {
    grid-template-columns: 1fr;
  }
  
  .comic-view-col {
    min-height: 320px;
    padding: 12px;
  }
  
  .comic-view-col img {
    max-height: 360px;
  }
  
  .comic-action-col {
    padding: 20px 16px;
  }
  
  .score-btn-group {
    gap: 4px;
  }
  
  .score-btn {
    padding: 10px 2px;
  }
  
  .score-btn .num-label {
    font-size: 1.15rem;
  }
  
  .score-btn .text-label {
    font-size: 0.65rem;
  }
  
  .tag-checkbox-grid {
    grid-template-columns: 1fr;
  }
  
  .action-footer {
    flex-direction: column-reverse;
  }
  
  .action-footer .btn {
    width: 100%;
  }
}
