/* ============================================================
   社交可愛生物測驗 — style.css
   糖果奶油深色主題 (Candy Cream Dark)
   ============================================================ */

/* ── 設計 Tokens ── */
:root {
  --color-bg:           #121318;
  --color-surface:      #1e2030;
  --color-surface-alt:  #272a3d;
  --color-border:       #353952;
  --color-text:         #f0eef5;
  --color-text-muted:   #9b9cb8;
  --color-accent:       #ff8fa3;
  --color-accent-hover: #ff6b88;
  --color-success:      #7ee8a0;
  --color-warning:      #ffd07a;
  --color-error:        #ff6b6b;
  --color-ad-bg:        #1a1d27;
  --color-ad-border:    #2e3347;

  --font-title: 'Outfit', 'Noto Sans TC', system-ui, sans-serif;
  --font-sans:  'Noto Sans TC', 'Inter', system-ui, sans-serif;
  --font-mono:  'Inter', monospace;

  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;

  --radius-sm: 6px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow:    0 8px 32px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 12px rgba(0,0,0,0.3);
}

/* ── 基礎重置 ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

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

/* ── 佈局 ── */
.tool-layout {
  position: relative;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--space-5);
}

.tool-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 70vh;
}

/* ── 畫面切換 ── */
.screen {
  display: none;
  width: 100%;
  max-width: 560px;
  animation: fadeSlideIn 0.4s ease-out;
}

.screen.active {
  display: block;
}

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

@keyframes bounceIn {
  0%   { opacity: 0; transform: scale(0.8); }
  60%  { transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}

/* ── 開始畫面 ── */
.start-container {
  text-align: center;
  padding: var(--space-10) 0;
}

.main-title {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 2.4rem;
  line-height: 1.3;
  margin-bottom: var(--space-4);
}

.title-line {
  display: block;
}

.title-line.accent {
  background: linear-gradient(135deg, #ff8fa3, #a78bfa, #67e8f9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--color-text-muted);
  font-size: 1rem;
  margin-bottom: var(--space-8);
}

.hero-image-wrap {
  width: 100%;
  max-width: 420px;
  margin: 0 auto var(--space-8);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow);
}

.hero-image {
  width: 100%;
  height: auto;
  display: block;
}

/* ── 按鈕 ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 14px 32px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  box-shadow: 0 4px 16px rgba(255,143,163,0.3);
}
.btn-primary:hover {
  background: var(--color-accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(255,143,163,0.4);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover {
  background: var(--color-surface);
  transform: translateY(-1px);
}

.btn-lg {
  padding: 16px 48px;
  font-size: 1.1rem;
  border-radius: var(--radius-lg);
}

.btn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ── 進度條 ── */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--color-surface-alt);
  border-radius: 3px;
  margin-bottom: var(--space-3);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff8fa3, #a78bfa, #67e8f9);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.question-counter {
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-5);
}

/* ── 題目插畫 ── */
.question-illustration-wrap {
  width: 100%;
  max-width: 480px;
  margin: 0 auto var(--space-5);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.question-illustration {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
  transition: opacity 0.3s ease;
}

.question-illustration.fade-out { opacity: 0; }

/* ── 題目文字 ── */
.question-text {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.25rem;
  text-align: center;
  margin-bottom: var(--space-6);
  line-height: 1.5;
}

/* ── 選項按鈕 ── */
.options-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}

.option-btn {
  display: block;
  width: 100%;
  padding: 16px 20px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.option-btn:hover {
  border-color: var(--color-accent);
  background: var(--color-surface-alt);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(255,143,163,0.15);
}

.option-btn:active {
  transform: translateY(0);
}

.option-btn.selected {
  border-color: var(--color-accent);
  background: rgba(255,143,163,0.12);
  box-shadow: 0 0 0 2px rgba(255,143,163,0.3);
}

/* ── 結果畫面 ── */
.result-reveal-text {
  text-align: center;
  font-family: var(--font-title);
  font-size: 1.1rem;
  color: var(--color-text-muted);
  margin: var(--space-8) 0 var(--space-5);
  animation: fadeSlideIn 0.4s ease-out;
}

.result-card {
  background: var(--color-surface);
  border: 1px solid transparent;
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  text-align: center;
  box-shadow: var(--shadow);
  animation: bounceIn 0.5s ease-out;
  background-image:
    linear-gradient(var(--color-surface), var(--color-surface)),
    linear-gradient(135deg, #ff8fa3, #a78bfa, #67e8f9);
  background-origin: border-box;
  background-clip: padding-box, border-box;
}

.result-image-wrap {
  width: 180px;
  height: 180px;
  margin: 0 auto var(--space-5);
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--color-accent);
  box-shadow: 0 0 32px rgba(255,143,163,0.25);
}

.result-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.result-name {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 2rem;
  margin-bottom: var(--space-2);
  background: linear-gradient(135deg, #ff8fa3, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-title-text {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--color-accent);
  margin-bottom: var(--space-4);
}

.result-desc {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: var(--space-6);
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.result-traits {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.trait {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-alt);
  border-radius: var(--radius);
}

.trait-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-accent);
  white-space: nowrap;
  min-width: 80px;
}

.trait-value {
  font-size: 0.9rem;
  color: var(--color-text);
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-4);
  margin: var(--space-8) 0;
  flex-wrap: wrap;
}

/* ── 廣告樣式（不可刪除）── */
.ad-slot { display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.ad-slot::before { content: attr(data-ad-slot) ' ad'; position: absolute; color: var(--color-text-muted); font-size: 0.75rem; }
.ad-slot.ad-loaded::before { display: none; }
.ad-slot--header  { width: 100%; min-height: 90px; max-width: 728px; margin: 12px auto; background: var(--color-ad-bg); border: 1px dashed var(--color-ad-border); }
.ad-slot--sidebar {
  width: 100%; min-height: auto; max-width: 200px;
  display: block; background: transparent; border: none; overflow: visible;
}
.ad-slot--footer  { width: 100%; min-height: 90px; max-width: 728px; margin: 12px auto; background: var(--color-ad-bg); border: 1px dashed var(--color-ad-border); }

.tool-sidebar {
  width: 100%; margin-top: var(--space-6);
  display: flex; justify-content: center;
}

@media (min-width: 1025px) {
  .tool-sidebar {
    position: fixed; right: 20px; top: 50%;
    transform: translateY(-50%); width: 200px; margin-top: 0; display: block; z-index: 10;
  }
}

/* 廣告卡片 */
.ad-grid { display: flex; flex-direction: column; gap: 8px; }
.ad-img  { width: 100%; height: 100px; object-fit: cover; display: block; }
.ad-card { display: block; text-decoration: none; color: inherit; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm); overflow: hidden; transition: opacity 0.4s ease; }
.ad-label { padding: 4px 8px; display: flex; flex-direction: column; justify-content: center; }
.ad-title { color: var(--color-text); font-weight: bold; font-size: 0.8rem; }
.ad-source { color: var(--color-text-muted); font-size: 0.65rem; }
.ad-sponsor-label { font-size: 0.75rem; color: var(--color-text-muted); margin-bottom: 8px; text-align: center; }

@media (max-width: 1024px) {
  .ad-slot--header, .ad-slot--footer { min-height: 50px; max-width: 320px; }
  .ad-slot--sidebar { max-width: 100%; }
  .ad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 480px; margin: 0 auto; }
  .ad-img { height: 80px; }
}

/* ── RWD ── */
@media (max-width: 768px) {
  .main-title { font-size: 1.8rem; }
  .question-illustration { height: 150px; }
  .question-text { font-size: 1.1rem; }
  .option-btn { padding: 14px 16px; font-size: 0.9rem; }
  .result-image-wrap { width: 140px; height: 140px; }
  .result-name { font-size: 1.6rem; }
  .result-card { padding: var(--space-6); }
  .result-actions { flex-direction: column; align-items: center; }
  .btn-lg { padding: 14px 36px; }
  .start-container { padding: var(--space-6) 0; }
}

@media (max-width: 480px) {
  .main-title { font-size: 1.5rem; }
  .subtitle { font-size: 0.9rem; }
  .trait { flex-direction: column; align-items: flex-start; gap: var(--space-1); }
  .trait-label { min-width: auto; }
}
