/* 鏡 Mirror — Settings & Onboarding Styles */

/* ======== Settings Gear Button ======== */
.settings-gear {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 80;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border-warm);
  border-radius: 50%;
  color: var(--text-hint);
  font-size: calc(16px * var(--user-font-scale));
  cursor: pointer;
  transition: all .4s;
  opacity: 0;
  animation: fadeIn 1.5s ease-out 2s forwards;
}
.settings-gear:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  transform: rotate(30deg);
}

/* ======== Settings Panel ======== */
.settings-panel {
  position: fixed;
  top: 0;
  right: -360px;
  width: 340px;
  max-width: 85vw;
  height: 100vh;
  /* 底部導覽列是 z-index:900。面板原本只有 150，等於整片被導覽列壓在下面，
     面板捲到底時最後一兩個項目（常見問題那幾顆）永遠按不到。
     面板本來就該蓋在導覽列之上，所以拉到 950；遮罩 940 跟著上去。 */
  z-index: 950;
  background: var(--bg-warm);
  border-left: 1px solid var(--border-warm);
  overflow-y: auto;
  transition: right .4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  padding: calc(28px + env(safe-area-inset-top)) calc(24px + env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) 24px;
}
.settings-panel.open {
  right: 0;
  box-shadow: -8px 0 40px rgba(120,100,70,.1);
}

.settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 940;
  background: rgba(0,0,0,.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s;
}
.settings-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}
.settings-title {
  font-size: calc(14px * var(--user-font-scale));
  letter-spacing: .2em;
  color: var(--accent-gold);
  opacity: .8;
}
.settings-close {
  background: none;
  border: none;
  font-size: calc(20px * var(--user-font-scale));
  color: var(--text-hint);
  cursor: pointer;
  padding: 4px 8px;
  transition: color .3s;
}
.settings-close:hover { color: var(--accent-gold); }

.settings-section {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-warm);
}
.settings-section:last-child { border-bottom: none; }

.settings-label {
  font-size: calc(10px * var(--user-font-scale));
  letter-spacing: .2em;
  color: var(--text-hint);
  text-transform: uppercase;
  margin-bottom: 14px;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  font-size: calc(13px * var(--user-font-scale));
  color: var(--text-primary);
  letter-spacing: .04em;
}

/* Theme toggle */
.theme-toggle { cursor: pointer; }
.theme-toggle-track {
  position: relative;
  width: 52px;
  height: 26px;
  border-radius: 13px;
  background: rgba(200,168,124,0.15);
  border: 1px solid var(--border-warm);
  transition: all .3s;
  display: flex;
  align-items: center;
}
.theme-toggle-track.dark {
  background: rgba(200,168,124,0.25);
}
.theme-toggle-thumb {
  position: absolute;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-gold);
  transition: left .3s;
}
.theme-toggle-track.dark .theme-toggle-thumb {
  left: 28px;
}
.theme-toggle-label {
  font-size: calc(9px * var(--user-font-scale));
  letter-spacing: .05em;
  color: var(--text-hint);
  margin-left: 62px;
}

/* Font size buttons */
.font-size-btns { display: flex; gap: 6px; }
.fs-btn {
  width: 32px;
  height: 28px;
  border: 1px solid var(--border-warm);
  background: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: calc(12px * var(--user-font-scale));
  cursor: pointer;
  border-radius: 4px;
  transition: all .3s;
}
.fs-btn:hover { border-color: var(--accent-gold); color: var(--accent-gold); }
.fs-btn.active {
  background: rgba(200,168,124,0.12);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

/* Volume slider */
.volume-slider {
  width: 120px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border-warm);
  border-radius: 2px;
  outline: none;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-gold);
  cursor: pointer;
}

/* Settings action buttons */
.settings-action {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 10px 0;
  font-family: inherit;
  font-size: calc(13px * var(--user-font-scale));
  color: var(--text-secondary);
  cursor: pointer;
  letter-spacing: .04em;
  transition: color .3s;
  border-bottom: 1px solid rgba(160,130,90,0.06);
}
.settings-action:hover { color: var(--accent-gold); }
.settings-action:last-child { border-bottom: none; }
.settings-danger { color: rgba(180,80,80,0.6); }
.settings-danger:hover { color: rgba(200,80,80,0.8); }

.settings-info {
  font-size: calc(12px * var(--user-font-scale));
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 8px;
  letter-spacing: .03em;
}

.settings-about {
  font-size: calc(12px * var(--user-font-scale));
  color: var(--text-secondary);
  line-height: 2;
  letter-spacing: .04em;
  opacity: .7;
}
.settings-version {
  font-size: calc(10px * var(--user-font-scale));
  color: var(--text-hint);
  margin-top: 8px;
  opacity: .4;
}

/* ======== Account Card ======== */
.settings-account-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(200,168,124,0.06);
  border: 1px solid var(--border-warm);
  border-radius: 10px;
  margin-bottom: 12px;
}
.settings-account-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(200,168,124,0.15);
  color: var(--accent-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(14px * var(--user-font-scale));
  font-family: 'Noto Serif TC', serif;
  flex-shrink: 0;
}
.settings-account-info { min-width: 0; }
.settings-account-email {
  font-size: calc(12px * var(--user-font-scale));
  color: var(--text-primary);
  letter-spacing: .02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.settings-account-status {
  font-size: calc(10px * var(--user-font-scale));
  color: var(--text-hint);
  opacity: .6;
  margin-top: 2px;
}

/* ======== Subscription Tier Badge ======== */
.settings-tier-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 16px;
  font-size: calc(12px * var(--user-font-scale));
  letter-spacing: .1em;
  margin-bottom: 10px;
}
.settings-tier-badge.free {
  background: rgba(200,168,124,0.08);
  border: 1px solid var(--border-warm);
  color: var(--text-secondary);
}
.settings-tier-badge.paid {
  background: rgba(200,168,124,0.15);
  border: 1px solid var(--accent-gold);
  color: var(--accent-gold);
}
.settings-tier-badge.premium {
  background: linear-gradient(135deg, rgba(200,168,124,0.2), rgba(180,150,100,0.1));
  border: 1.5px solid var(--accent-gold);
  color: var(--accent-gold);
  font-weight: 600;
}

/* Upgrade button highlight */
.settings-upgrade {
  color: var(--accent-gold) !important;
  border-bottom-color: rgba(200,168,124,0.15) !important;
}

/* ======== Push Status ======== */
.push-status {
  font-size: calc(11px * var(--user-font-scale));
  padding: 4px 12px;
  border-radius: 10px;
  letter-spacing: .06em;
}
.push-status.on {
  background: rgba(120,180,120,0.12);
  color: #7ab87a;
}

/* Inline action button (for push enable etc.) */
.settings-action-inline {
  background: none;
  border: 1px solid var(--border-warm);
  padding: 4px 14px;
  border-radius: 12px;
  font-family: inherit;
  font-size: calc(11px * var(--user-font-scale));
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .3s;
  letter-spacing: .06em;
}
.settings-action-inline:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

/* ======== FAQ ======== */
.settings-faq {
  margin-top: 16px;
  border-top: 1px solid var(--border-warm);
  padding-top: 14px;
}
.faq-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-size: calc(12px * var(--user-font-scale));
  color: var(--text-secondary);
  letter-spacing: .06em;
  padding: 4px 0;
  transition: color .3s;
}
.faq-toggle:hover { color: var(--accent-gold); }
.faq-arrow {
  font-size: calc(10px * var(--user-font-scale));
  color: var(--text-hint);
  transition: transform .3s;
}
.faq-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height .4s ease;
}
.faq-content.open {
  /* 摺疊動畫是靠 max-height 做的，這個上限等於「內容最多能有多高」。
     原本寫死 600px：字級選「大」時整份 FAQ 全展開實測要 591px（390px 寬），
     只剩 9px 餘裕；螢幕再窄一點（360px）換行變多就會被切掉，
     最後一兩題看得到卻按不到。上限跟著字級一起放大，並留足餘裕。 */
  max-height: calc(1200px * var(--user-font-scale));
}
.faq-item {
  border-bottom: 1px solid rgba(160,130,90,0.06);
  padding: 0;
}
.faq-item:last-child { border-bottom: none; }
.faq-q {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  font-size: calc(12px * var(--user-font-scale));
  color: var(--text-primary);
  cursor: pointer;
  letter-spacing: .03em;
  transition: color .3s;
}
.faq-q:hover { color: var(--accent-gold); }
.faq-item-arrow {
  font-size: calc(9px * var(--user-font-scale));
  color: var(--text-hint);
  transition: transform .3s;
  flex-shrink: 0;
  margin-left: 8px;
}
.faq-item.open .faq-item-arrow {
  transform: rotate(90deg);
}
.faq-a {
  max-height: 0;
  overflow: hidden;
  font-size: calc(11px * var(--user-font-scale));
  color: var(--text-secondary);
  line-height: 1.9;
  letter-spacing: .02em;
  opacity: .7;
  transition: max-height .3s ease, padding .3s ease;
  padding: 0;
}
.faq-item.open .faq-a {
  /* 同上：單題答案的高度上限也要跟著字級走，否則長答案在「大」字級會被截斷。 */
  max-height: calc(400px * var(--user-font-scale));
  padding: 0 0 10px 0;
}

/* ======== Font Size Scaling ========
   舊做法是在這裡針對四個選擇器各寫死一組 px（S/M/L），問題有三個：
     1. 只有對話泡泡跟測驗四個地方會變，手帳／書館／設定／每日一鏡全都不動。
     2. 「大」的 .quiz-question 寫成 18px，跟基準值一模一樣 → 選「大」等於沒選。
     3. --user-font-scale 設了卻沒有任何 CSS 在用，等於死變數。
   現在改成：全站的 font-size 都寫成 calc(原值 * var(--user-font-scale))，
   由 applySettings() 設定 --user-font-scale 一個變數統一縮放，這裡不再需要特例。
   （data-font-size 屬性保留，之後若某個元件需要「只在大字級時換版型」還用得到。） */

/* ======== Onboarding ======== */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(245,240,230,0.85);
  opacity: 0;
  transition: opacity .5s;
}
.onboarding-overlay.active { opacity: 1; }

.onboarding-card {
  max-width: 400px;
  width: 90%;
  padding: 40px 32px;
  background: var(--bg-cream);
  border: 1px solid var(--border-warm);
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,.06);
  text-align: center;
}

.ob-icon {
  font-size: calc(36px * var(--user-font-scale));
  color: var(--accent-gold);
  opacity: .5;
  margin-bottom: 20px;
  font-family: 'Noto Serif TC', serif;
  font-weight: 200;
  letter-spacing: 4px;
}
.ob-title {
  font-size: calc(16px * var(--user-font-scale));
  color: var(--text-primary);
  letter-spacing: .15em;
  margin-bottom: 16px;
}
.ob-body {
  font-size: calc(13px * var(--user-font-scale));
  color: var(--text-secondary);
  line-height: 2.2;
  letter-spacing: .04em;
  margin-bottom: 24px;
}

.ob-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}
.ob-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-warm);
  transition: all .3s;
}
.ob-dot.active {
  background: var(--accent-gold);
  transform: scale(1.3);
}

.ob-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.ob-btn { padding: 14px 40px; font-size: calc(14px * var(--user-font-scale)); }
.ob-skip {
  background: none;
  border: none;
  font-family: inherit;
  font-size: calc(11px * var(--user-font-scale));
  color: var(--text-hint);
  cursor: pointer;
  letter-spacing: .1em;
  opacity: .5;
  transition: opacity .3s;
  min-height: 20px;
}
.ob-skip:hover { opacity: .8; }

/* Onboarding card animations */
.ob-enter {
  animation: obFadeIn .4s ease-out forwards;
}
.ob-leave {
  animation: obFadeOut .3s ease-in forwards;
}
@keyframes obFadeIn {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes obFadeOut {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-10px); }
}

/* ======== Mobile adjustments ======== */
@media (max-width: 480px) {
  .settings-panel { width: 300px; }
  .settings-gear { top: 14px; right: 14px; width: 32px; height: 32px; font-size: calc(14px * var(--user-font-scale)); }
  .onboarding-card { padding: 32px 24px; }
}
