/* ============================================================
   訓練關卡頁
   ============================================================ */

.trainer {
  padding: 3rem 0 4.5rem;
  background: var(--paper);
}

.trainer__head {
  max-width: 46em;
  margin-bottom: 2.2rem;
  padding-bottom: 1.6rem;
  border-bottom: 1px solid var(--line);
}
.trainer__lead {
  margin-top: 1rem;
  color: var(--ink-2);
  font-size: 0.98rem;
}
.trainer__lead strong { color: var(--ink); }

/* ============================================================
   關卡選擇
   ============================================================ */

.modes {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem;
  margin-bottom: 1.6rem;
}
.mode {
  display: flex; align-items: flex-start; gap: 0.9rem;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 1rem 1.1rem;
  cursor: pointer;
  font: inherit; color: inherit;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.mode:hover { border-color: var(--ink-3); }
.mode[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--surface);
  box-shadow: inset 3px 0 0 var(--ink);
}

/* 縮圖：以漸層代表各模組的色調 */
.mode__thumb {
  flex: none;
  width: 40px; height: 40px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
}
.mode[data-mode="garden"] .mode__thumb {
  background: linear-gradient(165deg, #bcdcea 0%, #f3e0cd 45%, #5c9169 100%);
}
.mode[data-mode="rainbow"] .mode__thumb {
  background: linear-gradient(165deg, #1e2a52 0%, #79486a 50%, #e9a06a 100%);
}
.mode[data-mode="voyage"] .mode__thumb {
  background: linear-gradient(165deg, #2f6d95 0%, #cfe6ee 52%, #1d7791 100%);
}

.mode__body { display: block; }
.mode__time {
  display: block;
  font-family: var(--serif);
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.12em;
  color: var(--ink-3);
}
.mode__name {
  display: block; font-family: var(--serif);
  font-weight: 700; font-size: 1.02rem; margin: 0.2rem 0 0.3rem;
}
.mode__desc { display: block; font-size: 0.85rem; color: var(--ink-2); line-height: 1.7; }

/* ============================================================
   舞台
   ============================================================ */

.stage {
  position: relative;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: #0d1a22;
  aspect-ratio: 5 / 3;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
  border: 1px solid var(--ink);
}

.scene { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
.scene--active { display: block; }

/* 場景飽和度與亮度由 --p（0~1）驅動：越放鬆，畫面越鮮活 */
.scene__world {
  /* 完成時回到自然的 1.0，不過度加彩，避免卡通感 */
  filter:
    saturate(calc(0.04 + var(--p) * 0.96))
    brightness(calc(0.62 + var(--p) * 0.38));
  transition: filter 0.45s linear;
}

/* ============================================================
   HUD
   ============================================================ */

.hud {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 1.25rem 1.4rem;
  pointer-events: none;
}
.hud__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }

.hud__badge {
  background: rgba(13, 26, 34, 0.5);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e8eef1;
  border-radius: var(--r-sm);
  padding: 0.4rem 0.85rem;
  font-family: var(--serif);
  font-size: 0.82rem; font-weight: 600;
  letter-spacing: 0.08em;
}

.hud__score { text-align: right; line-height: 1; }
.hud__score b {
  display: block;
  font-family: var(--serif);
  font-size: 2.6rem; font-weight: 600;
  color: #fff;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
  font-variant-numeric: tabular-nums;
}
.hud__score span {
  display: block; margin-top: 0.3rem;
  font-size: 0.72rem; letter-spacing: 0.16em;
  color: rgba(255, 255, 255, 0.82);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}

.hud__bottom { display: flex; align-items: flex-end; gap: 1.4rem; }

/* ---- 呼吸節拍器 ---- */
.trainer__pacer {
  position: relative;
  width: 138px; height: 138px;
  display: grid; place-items: center;
  flex: none;
}
.trainer__pacer .ring {
  position: absolute; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.trainer__pacer .ring--1 { inset: 0; }
.trainer__pacer .ring--2 { inset: 14%; border-style: dashed; border-color: rgba(255, 255, 255, 0.22); }
.trainer__pacer .orb {
  position: absolute;
  width: 60%; height: 60%;
  border-radius: 50%;
  background: #d8e2e7;
  border: 1px solid rgba(255, 255, 255, 0.7);
  will-change: transform;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}
/* 按住（吸氣）時改以實心深色標示，不用光暈 */
.trainer__pacer .orb--held {
  background: #e8d9b8;
  border-color: #fff;
}
.trainer__pacer .cue {
  position: relative; z-index: 2;
  color: #16202a; font-weight: 700; font-size: 0.86rem;
  letter-spacing: 0.16em; text-indent: 0.16em;
}

/* ---- 協調度計 ---- */
.hud__meterwrap { flex: 1; min-width: 0; }
.hud__meterhead {
  display: flex; justify-content: space-between; gap: 1rem;
  font-size: 0.74rem; font-weight: 600; letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.86);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.55);
  margin-bottom: 0.5rem;
}
.meter {
  position: relative;
  height: 8px; border-radius: 1px;
  background: rgba(13, 26, 34, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.28);
  overflow: hidden;
}
.meter__fill {
  height: 100%; width: 0%;
  background: #e8eef1;
  transition: width 0.3s linear;
}
/* 刻度：25 / 50 / 75 三條，加上放鬆門檻 60 的標記 */
.meter__ticks {
  position: relative; height: 5px; margin-top: 3px;
}
.meter__ticks i {
  position: absolute; top: 0;
  width: 1px; height: 4px;
  background: rgba(255, 255, 255, 0.3);
}
.meter__ticks i:nth-child(1) { left: 25%; }
.meter__ticks i:nth-child(2) { left: 50%; }
.meter__ticks i:nth-child(3) { left: 75%; }
.meter__ticks i:nth-child(4) {
  left: 60%; height: 6px; width: 1.5px;
  background: rgba(232, 217, 184, 0.9);
}

/* ============================================================
   覆蓋層
   ============================================================ */

.overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(13, 26, 34, 0.66);
  backdrop-filter: blur(8px);
  text-align: center;
  padding: 2rem;
  pointer-events: auto;
  animation: fade 0.3s var(--ease);
}
.overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.overlay__card {
  max-width: 34em;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: var(--r-sm);
  padding: 2rem 1.9rem;
}
.overlay h2 { font-size: 1.32rem; color: #fff; margin-bottom: 0.7rem; }
.overlay p {
  color: #cfe1e5; font-size: 0.95rem;
  margin: 0 auto 1.5rem; max-width: 30em;
}
.overlay strong { color: #fff; }

.results {
  display: flex; gap: 2.2rem; justify-content: center; flex-wrap: wrap;
  margin: 1.6rem 0 1.4rem;
}
.results div span {
  display: block;
  font-size: 0.74rem; letter-spacing: 0.1em; color: #9fbcc2;
  margin-bottom: 0.3rem;
}
.results div b {
  font-family: var(--serif);
  font-size: 2rem; font-weight: 600; color: #fff;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   控制列與說明
   ============================================================ */

.trainer__controls {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  margin-top: 1.5rem;
}
.hint {
  flex: 1; min-width: 270px;
  color: var(--ink-2); font-size: 0.88rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 0.8rem 1.1rem;
}
.hint strong { color: var(--ink); }
.hint kbd {
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: 2px; padding: 0.1em 0.45em;
  font-size: 0.88em; font-family: inherit; font-weight: 600;
}

/* 計分方式說明 */
.trainer__method {
  margin-top: 2.4rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  max-width: 52em;
}
.trainer__method h2 {
  font-size: 1.06rem;
  margin-bottom: 0.6rem;
}
.trainer__method p { color: var(--ink-2); font-size: 0.92rem; }

.trainer__note {
  margin-top: 1.6rem;
  font-size: 0.86rem; color: var(--gold);
  background: var(--gold-100);
  border-left: 2px solid var(--gold-300);
  padding: 0.9rem 1.1rem;
  max-width: 62em;
}
.trainer__note strong { color: var(--gold); font-weight: 700; }

/* ============================================================
   響應式
   ============================================================ */

@media (max-width: 860px) {
  .modes { grid-template-columns: 1fr; }
  .mode { align-items: center; }
  .stage { aspect-ratio: 3 / 4; }
  .hud { padding: 1rem; }
  .hud__bottom { flex-direction: column; align-items: stretch; gap: 1rem; }
  .trainer__pacer { width: 112px; height: 112px; margin-inline: auto; }
  .hud__score b { font-size: 2rem; }
  .overlay__card { padding: 1.6rem 1.3rem; }
  .results { gap: 1.4rem; }
  .results div b { font-size: 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  .scene__world, .meter__fill { transition: none; }
  .overlay { animation: none; }
}
