/* ============================================
   台灣特殊兒童收養互動新聞 - 手繪繪本風
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+TC:wght@400;700&family=Noto+Sans+TC:wght@400;500;600;700&family=Permanent+Marker&display=swap');

:root {
  /* 畫布與紙張顏色 */
  --color-bg-primary: #ffffff; /* 白色背景 */
  --color-bg-card: #fcfcfc; /* 剪紙白底 */

  /* 墨水顏色 */
  --color-text-primary: #222222;
  --color-text-secondary: #333333;
  --color-text-muted: #555555;

  /* 畫作中的彩色筆顏色 */
  --color-accent-pink: #f472b6; /* 媽媽的粉紅衣 */
  --color-accent-purple: #a855f7; /* 媽媽的紫衣 */
  --color-accent-yellow: #fcd34d; /* 黃色磁鐵與文字 */
  --color-accent-orange: #fb923c; /* 蝴蝶結橘色 */
  --color-accent-red: #ef4444; /* 紅色愛心 */

  /* 字體 */
  --font-display: 'Noto Serif TC', 'Comic Sans MS', 'Klee One', serif;
  --font-body: 'Noto Sans TC', 'Comic Sans MS', 'Klee One', sans-serif;
  --font-marker: 'Permanent Marker', 'Noto Sans TC', cursive;

  /* 間距與其他 */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  
  /* 轉場 */
  --transition-fast: 0.2s ease;
}

/* --- 基礎設定 --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

/* 背景圖層（透過 .bg-ambience 控制透明度） */
.bg-ambience {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('bg.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.5;
  z-index: -1;
  pointer-events: none;
}

.page-wrapper {
  padding: var(--space-xl) 1rem;
  display: flex;
  justify-content: center;
}

.container {
  width: 100%;
  max-width: 640px;
}

/* --- 動畫 --- */
.page-enter {
  animation: floatIn 0.8s ease-out forwards;
}

.stagger-children > * {
  opacity: 0;
  animation: floatIn 0.6s ease-out forwards;
}
.stagger-children > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.5s; }

@keyframes floatIn {
  0% { opacity: 0; transform: translateY(20px) rotate(-1deg); }
  100% { opacity: 1; transform: translateY(0) rotate(0); }
}

/* --- 標籤 (Tag) --- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--color-accent-yellow);
  border: 2px solid var(--color-text-primary);
  border-radius: 255px 15px 225px 15px/15px 225px 15px 255px; /* 手繪不規則邊框 */
  box-shadow: 2px 2px 0px var(--color-text-primary);
  font-weight: 600;
  font-size: 0.9rem;
  font-family: var(--font-body);
}

/* --- 標題與文字 --- */
.headline {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--color-text-primary);
  text-shadow: 2px 2px 0px #fff;
  line-height: 1.3;
}

.headline .highlight {
  color: var(--color-accent-pink);
  background: none;
  -webkit-text-fill-color: var(--color-accent-pink);
  position: relative;
  display: inline-block;
}

/* 手繪底線效果 */
.headline .highlight::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: -2px;
  right: -2px;
  height: 8px;
  background: var(--color-accent-yellow);
  z-index: -1;
  border-radius: 10px;
  transform: rotate(-1deg);
}

.body-text {
  font-size: 1.1rem;
  font-weight: 500;
  font-family: var(--font-body);
}

.divider {
  border: none;
  border-top: 3px dashed var(--color-text-muted);
  margin: 10px 0;
}

/* --- 剪紙卡片風格共用 --- */
.slider-section, .result-card, .comparison-section, .avg-insight, .stat-card {
  background: var(--color-bg-card);
  border: 3px solid var(--color-text-primary);
  /* 讓邊框看起來像隨意剪裁的紙張 */
  border-radius: 2px 15px 3px 12px / 10px 3px 15px 5px; 
  box-shadow: 6px 6px 0px var(--color-text-primary);
  padding: 1.5rem;
}

/* --- 滑桿區塊 --- */
.slider-label {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  font-family: var(--font-body);
}

.slider-hint {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--color-text-muted);
  display: block;
  font-family: var(--font-body);
}

.slider-value-display {
  text-align: center;
  margin-bottom: 1.5rem;
}

.slider-value-number {
  font-family: var(--font-marker);
  font-size: 4.5rem;
  color: var(--color-accent-purple);
  text-shadow: 3px 3px 0px var(--color-text-primary);
  line-height: 1;
}

.slider-value-unit {
  font-family: var(--font-marker);
  font-size: 2rem;
  color: var(--color-text-primary);
}

/* 自訂滑桿 */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 12px;
  background: #e5e5e5;
  border: 2px solid var(--color-text-primary);
  border-radius: 10px;
  outline: none;
  margin: 15px 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-accent-orange);
  border: 3px solid var(--color-text-primary);
  box-shadow: 2px 2px 0px var(--color-text-primary);
  cursor: pointer;
  transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1) rotate(5deg);
  background: var(--color-accent-yellow);
}

.slider-scale {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-marker);
  font-size: 0.9rem;
}

/* --- 按鈕 --- */
.btn-submit, .btn-cta-primary, .btn-cta-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 24px;
  font-family: var(--font-body);
  font-size: 1.2rem;
  font-weight: 600;
  color: #fff;
  background: var(--color-accent-pink);
  border: 3px solid var(--color-text-primary);
  border-radius: 5px 12px 4px 8px; /* 手繪不規則 */
  box-shadow: 4px 4px 0px var(--color-text-primary);
  cursor: pointer;
  transition: all 0.1s ease;
  text-decoration: none;
  text-shadow: 1px 1px 0px rgba(0,0,0,0.3);
}

.btn-submit:hover, .btn-cta-primary:hover {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0px var(--color-text-primary);
  background: var(--color-accent-purple);
}

.btn-cta-secondary {
  background: var(--color-bg-card);
  color: var(--color-text-primary);
  text-shadow: none;
}

.btn-cta-secondary:hover {
  background: var(--color-accent-yellow);
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0px var(--color-text-primary);
}

/* --- 結果頁 --- */
.result-card {
  text-align: center;
  background: #fff;
}

.result-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 15px;
  border-radius: 50%;
  background: var(--color-accent-yellow);
  border: 3px solid var(--color-text-primary);
  box-shadow: 4px 4px 0px var(--color-text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

.result-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 10px;
  text-shadow: 1px 1px 0px #fff;
}

.result-description {
  font-size: 1.1rem;
  font-family: var(--font-body);
  font-weight: 500;
}

/* --- 比較長條圖 --- */
.comparison-bar-track {
  height: 24px;
  background: #eee;
  border: 3px solid var(--color-text-primary);
  border-radius: 12px;
  position: relative;
  box-shadow: inset 2px 2px 0px rgba(0,0,0,0.1);
  margin-top: 70px;
  margin-bottom: 70px;
  overflow: visible;
}

/* 標記定位基礎 — 讓 JS 的 left 定位生效 */
.bar-marker {
  position: absolute;
  top: 0;
  height: 100%;
  z-index: 2;
}

/* 圓點標記（用於「你的猜測」） */
.bar-marker-dot {
  width: 20px;
  height: 20px;
  border: 3px solid var(--color-text-primary);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
  background: #fff;
  z-index: 2;
}

.marker-user .bar-marker-dot { background: var(--color-accent-yellow); }
.marker-actual .bar-marker-dot { background: var(--color-accent-pink); }
.marker-avg .bar-marker-dot { background: var(--color-accent-purple); }

/* 虛線標記（用於「實際數據」和「讀者平均」） */
.bar-marker-line {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
  width: 0;
  height: 70px;
  border-left: 3px dashed var(--color-text-primary);
  z-index: 2;
}

.marker-actual .bar-marker-line {
  border-left-color: var(--color-accent-pink);
}

.marker-avg .bar-marker-line {
  border-left-color: var(--color-accent-purple);
}

/* 標記標籤 — 共用 */
.bar-marker-label {
  position: absolute;
  left: 0;
  transform: translateX(-50%);
  font-weight: 600;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  font-size: 0.85rem;
  line-height: 1.4;
  font-family: var(--font-body);
}

/* 「實際數據」標籤：放在長條圖下方 */
.marker-actual .bar-marker-label {
  top: calc(100% + 28px);
}

/* 「你的猜測」標籤：放在長條圖上方 */
.marker-user .bar-marker-label {
  bottom: calc(100% + 8px);
  top: auto;
}

/* 「讀者平均」標籤：放在長條圖下方 */
.marker-avg .bar-marker-label {
  top: calc(100% + 28px);
}

.bar-marker-value {
  font-family: var(--font-marker);
  font-size: 1.2rem;
  display: block;
}

.comparison-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 60px;
  font-weight: 600;
  align-items: center;
  font-family: var(--font-body);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2.5px solid var(--color-text-primary);
  flex-shrink: 0;
}
.legend-dot.user {
  background: var(--color-accent-yellow);
}
.legend-dot.actual {
  background: var(--color-accent-pink);
}
.legend-dot.avg {
  background: var(--color-accent-purple);
}

/* 圖例中的虛線樣式 */
.legend-line {
  width: 20px;
  height: 0;
  border-top: 3px dashed var(--color-text-primary);
}
.legend-line.actual { border-top-color: var(--color-accent-pink); }
.legend-line.avg { border-top-color: var(--color-accent-purple); }

/* --- 統計方塊 --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
}

.stat-card {
  padding: 1rem;
  text-align: center;
}

.stat-card-value {
  font-family: var(--font-marker);
  font-size: 1.8rem;
  color: var(--color-text-primary);
}

.stat-card-label {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* --- 頁尾 --- */
.footer-note {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text-muted);
  font-family: var(--font-body);
}

.comparison-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1rem;
  font-family: var(--font-body);
}

.avg-insight-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1rem;
  font-family: var(--font-body);
}

.avg-insight-text {
  font-size: 1rem;
  font-weight: 500;
  font-family: var(--font-body);
  line-height: 1.6;
}

/* ============================================
   RWD 響應式設計
   ============================================ */

/* --- 平板 (768px 以上) --- */
@media (min-width: 768px) {
  .container {
    max-width: 680px;
  }

  .headline {
    font-size: 2.6rem;
  }

  .body-text,
  .slider-label,
  .result-description {
    font-size: 1.2rem;
  }

  .slider-value-number {
    font-size: 5rem;
  }

  .result-title {
    font-size: 1.8rem;
  }

  .page-wrapper {
    padding: var(--space-xl) 2rem;
  }
}

/* --- 桌面 (1024px 以上) --- */
@media (min-width: 1024px) {
  .container {
    max-width: 720px;
  }

  .headline {
    font-size: 2.8rem;
  }

  .page-wrapper {
    padding: 3rem 2rem;
  }

  .btn-submit,
  .btn-cta-primary,
  .btn-cta-secondary {
    font-size: 1.3rem;
    padding: 16px 28px;
  }

  .stat-card-value {
    font-size: 2rem;
  }

  .slider-value-number {
    font-size: 5.5rem;
  }
}

/* --- 大螢幕 (1440px 以上) --- */
@media (min-width: 1440px) {
  .container {
    max-width: 760px;
  }

  .page-wrapper {
    padding: 4rem 2rem;
  }
}

/* --- 小手機 (375px 以下) --- */
@media (max-width: 375px) {
  .headline {
    font-size: 1.8rem;
  }

  .slider-value-number {
    font-size: 3.5rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .comparison-legend {
    flex-direction: column;
    gap: 10px;
    align-items: center;
  }

  .btn-submit,
  .btn-cta-primary {
    font-size: 1rem;
    padding: 12px 20px;
  }
}
