/* ==========================================================================
   共修之徑 · 共用 Mobile-First Stylesheet
   斷點：base = mobile / sm ≥ 640 / md ≥ 768 / lg ≥ 1024
   ========================================================================== */

/* ---------- Design Tokens ---------- */
:root {
  --bg: #F5F1EA;
  --bg-alt: #EDE5D8;
  --text: #2A2420;
  --text-muted: #6B5F54;
  --accent: #C08B6B;
  --accent-2: #3D5A40;
  --line: rgba(42, 36, 32, 0.12);

  /* 字型基準：全站以 16px 為正文底線（CLAUDE.md body 16px+ 規範）*/
  --fs-body: 16px;
  --fs-small: 14px;
  --fs-eyebrow: 13px;
  --fs-caption: 12px;

  /* Tap target 最小 44px（Apple HIG） */
  --tap: 44px;

  /* Safe-area (iPhone notch / home indicator) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  /* 流體 section padding */
  --section-y: 72px;       /* mobile */
  --section-x: 20px;       /* mobile */
}

@media (min-width: 640px) {
  :root { --section-y: 96px; --section-x: 32px; }
}
@media (min-width: 768px) {
  :root { --section-y: 112px; --section-x: 48px; }
}
@media (min-width: 1024px) {
  :root { --section-y: 144px; --section-x: 64px; }
}

/* ---------- Reset / Base ---------- */
* { box-sizing: border-box; }
html {
  scroll-behavior: auto;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: "Noto Serif TC", "Cormorant Garamond", serif;
  font-size: var(--fs-body);
  line-height: 1.7;
  background: var(--bg);
  color: var(--text);
  transition: background 700ms ease, color 700ms ease;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  /* iOS 點擊時的灰框 → 改成幾乎不可見（保留一點回饋） */
  -webkit-tap-highlight-color: rgba(192, 139, 107, 0.12);
}
img { max-width: 100%; height: auto; display: block; }

/* 所有按鈕/連結：可見鍵盤 focus 輪廓（a11y） */
:where(a, button, [role="button"], input, select, textarea):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Skip-to-content（鍵盤與螢幕閱讀器用） */
.skip-link {
  position: absolute;
  top: -60px;
  left: 16px;
  z-index: 200;
  background: var(--text);
  color: var(--bg);
  padding: 12px 18px;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font-size: 14px;
  letter-spacing: 0.08em;
  border-radius: 0 0 6px 6px;
  transition: top 200ms;
}
.skip-link:focus { top: 0; }

.serif-en { font-family: "Cormorant Garamond", serif; font-style: italic; }
.hairline { height: 1px; background: var(--line); }

/* ---------- Buttons ---------- */
.btn-primary {
  background: var(--accent); color: #fff;
  padding: 14px 28px; border-radius: 2px;
  letter-spacing: 0.12em; transition: all 300ms ease;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap);
  font-size: var(--fs-small);
  border: none; font-family: inherit; cursor: pointer;
  text-decoration: none;
}
.btn-primary:hover { opacity: 0.88; transform: translateY(-1px); }

.btn-ghost {
  border: 1px solid currentColor;
  padding: 13px 27px; border-radius: 2px;
  letter-spacing: 0.12em; transition: all 300ms ease;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap);
  font-size: var(--fs-small);
  text-decoration: none;
  background: transparent;
  font-family: inherit; cursor: pointer;
}
.btn-ghost:hover { background: currentColor; color: var(--bg); }

@media (min-width: 640px) {
  .btn-primary { padding: 14px 36px; }
  .btn-ghost   { padding: 13px 35px; }
}

/* ---------- Top Bar (sticky mobile nav) ---------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 60;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  /* 跟隨派系：mystic 的 --bg 是深藏藍、--text 是暖金白，自動反黑確保對比 */
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  transition: background 300ms ease;
}
.topbar.on-dark {
  background: linear-gradient(to bottom, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.35) 100%);
  border-bottom-color: rgba(255,255,255,0.14);
}
.topbar.on-dark .topbar-brand,
.topbar.on-dark .topbar-back,
.topbar.on-dark .theme-toggle { color: #fff; }
/* 漢堡欄在深色 hero 上時改用半透黑底 + 白邊，避免白底白字看不清 */
.topbar.on-dark .theme-toggle {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.45);
}
.topbar.on-dark .topbar-brand {
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.55);
}

.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-back {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: var(--tap); min-height: var(--tap);
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.08em;
  background: transparent;
  border: none; cursor: pointer;
  font-family: inherit;
}
.topbar-brand {
  font-size: 15px;
  letter-spacing: 0.16em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (min-width: 640px) {
  .topbar { padding: calc(14px + var(--safe-top)) 24px 14px; }
  .topbar-brand { font-size: 16px; }
}

/* Theme toggle (mobile: icon; ≥640: full switcher) */
.theme-toggle {
  display: inline-flex;
  align-items: center; justify-content: center;
  min-width: var(--tap); min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  /* 跟隨派系背景，避免 mystic 深底上白按鈕看不清 */
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  color: var(--text);
  font-family: inherit;
  font-size: 13px; letter-spacing: 0.08em;
  cursor: pointer;
}
/* mobile-first：預設隱藏文字（只留漢堡 icon），≥640 才顯示 */
.theme-toggle-label {
  display: none;
  margin-left: 6px;
}
@media (min-width: 640px) {
  .theme-toggle-label { display: inline; }
}

.theme-sheet {
  position: fixed;
  top: calc(64px + var(--safe-top));
  right: 12px;
  z-index: 65;
  /* 跟隨派系背景：mystic 反黑後內文 var(--text) 暖金白也可讀 */
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  min-width: 170px;
}
.theme-sheet.open { display: flex; }

.theme-btn {
  display: flex; align-items: center;
  min-height: var(--tap);
  padding: 10px 16px;
  font-size: var(--fs-small);
  letter-spacing: 0.08em;
  /* 跟隨派系文字色，避免 mystic 深底上 #333 深灰看不見 */
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-family: "Noto Serif TC", serif;
  text-align: left;
  white-space: nowrap;
  transition: background 200ms ease, color 200ms ease;
}
/* 跟隨派系：用 currentColor 低透明，深色派系也可見 */
.theme-btn:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
.theme-btn.active { background: var(--accent); color: #fff; }

/* ≥640 直接展成橫排切換器（吸附 topbar 右側） */
@media (min-width: 640px) {
  .theme-toggle { display: none; }
  .theme-sheet {
    display: flex;
    position: static;
    flex-direction: row;
    /* 桌機橫排切換器也跟隨派系背景 */
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    border-radius: 999px;
    padding: 4px;
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.08);
    min-width: 0;
  }
  .theme-btn {
    padding: 8px 14px;
    min-height: 36px;
    font-size: 12.5px;
    border-radius: 999px;
  }
}

/* ---------- Hint bar ---------- */
.hint-bar {
  position: fixed;
  bottom: calc(16px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 12.5px;
  letter-spacing: 0.08em;
  z-index: 55;
  backdrop-filter: blur(10px);
  max-width: calc(100vw - 32px);
  text-align: center;
  animation: fadeInUp 1s ease 1.5s both, fadeOutDown 800ms ease 6s forwards;
  pointer-events: none;
}
@media (min-width: 640px) {
  .hint-bar { padding: 12px 26px; font-size: 13px; }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes fadeOutDown {
  to { opacity: 0; transform: translate(-50%, 20px); }
}
.hint-bar.hidden { opacity: 0; pointer-events: none; transition: opacity 400ms; }

/* ---------- Section padding helper ---------- */
.section {
  padding: var(--section-y) var(--section-x);
}
.container {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}
.container-narrow {
  max-width: 780px;
  margin: 0 auto;
  width: 100%;
}

/* ---------- Eyebrow ---------- */
.eyebrow-line {
  display: inline-flex;
  align-items: center;
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-size: var(--fs-eyebrow);
  letter-spacing: 0.22em;
  color: var(--accent);
}
.eyebrow-symbol { display: inline-flex; color: var(--accent); }

/* ---------- Hero full-bleed (共用基底) ---------- */
.hero-fullbleed {
  position: relative;
  min-height: 92vh;   /* 舊瀏覽器 fallback */
  min-height: 92dvh;  /* iOS Safari 地址列收合時不跳動 */
  display: flex;
  align-items: center;
  padding: calc(84px + var(--safe-top)) 20px 72px;
  background-color: var(--bg);
  background-size: cover;
  /* mobile：所有 hero/quote 圖都是「左主體 + 右文字留白」橫幅構圖，
     center crop 會把主體裁掉，改成 28% 讓左焦點顯露 */
  background-position: 28% center;
  transition: background-image 800ms ease;
  color: #fff;
}
@media (min-width: 640px) {
  .hero-fullbleed { padding: 112px 32px 80px; }
}
@media (min-width: 768px) {
  .hero-fullbleed {
    padding: 128px 48px 96px;
    min-height: 100vh;
    min-height: 100dvh;
    background-position: center;
  }
}
.hero-content { max-width: 680px; width: 100%; }
.hero-title {
  font-size: clamp(32px, 8vw, 80px);
  line-height: 1.12;
  font-weight: 300;
  letter-spacing: -0.01em;
  color: #fff;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.35);
  margin: 0 0 24px;
}
.hero-sub {
  font-size: clamp(16px, 2.4vw, 20px);
  line-height: 1.75;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 20px rgba(0, 0, 0, 0.3);
  margin: 0 0 32px;
}
.hero-eyebrow {
  font-size: var(--fs-eyebrow);
  letter-spacing: 0.22em;
  color: rgba(255, 255, 255, 0.78);
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  margin: 0 0 20px;
}
.hero-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.hero-cta-primary {
  background: #fff; color: #111;
  padding: 14px 28px;
  min-height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  letter-spacing: 0.12em;
  font-size: var(--fs-small);
  transition: all 300ms;
  text-decoration: none;
}
.hero-cta-primary:hover { background: var(--accent); color: #fff; }
.hero-cta-ghost {
  border: 1px solid rgba(255, 255, 255, 0.55);
  color: #fff;
  padding: 13px 27px;
  min-height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  letter-spacing: 0.12em;
  font-size: var(--fs-small);
  transition: all 300ms;
  text-decoration: none;
}
.hero-cta-ghost:hover { background: #fff; color: #111; }
@media (min-width: 640px) {
  .hero-cta-primary { padding: 16px 36px; }
  .hero-cta-ghost   { padding: 15px 35px; }
  .hero-cta-row     { gap: 16px; }
}

/* mobile-first：預設隱藏（手機畫面有限），≥640 才顯示 scroll 提示 */
.scroll-hint {
  display: none;
  position: absolute;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  letter-spacing: 0.3em;
  color: rgba(255, 255, 255, 0.65);
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  animation: float 2.5s ease-in-out infinite;
}
@media (min-width: 640px) {
  .scroll-hint { display: block; }
}
@keyframes float {
  0%, 100% { transform: translate(-50%, 0); opacity: 0.65; }
  50%      { transform: translate(-50%, 8px); opacity: 1; }
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg-alt);
  border: 1px solid var(--line);
  transition: all 400ms ease;
  text-decoration: none;
  color: inherit;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-4px); border-color: var(--accent); }
.card-img {
  aspect-ratio: 4 / 3;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-alt);
  transition: background-image 500ms ease;
}
/* 商品小卡：原本強制 1:1 會把生成的 4:3 圖左右裁掉。手機改回 4:3，桌機才用 1:1 */
.card-img-square { aspect-ratio: 4 / 3; }
@media (min-width: 768px) {
  .card-img-square { aspect-ratio: 1 / 1; }
}

/* ---------- Section image (about / testimonial / exp / loc / inst) ---------- */
.section-img {
  aspect-ratio: 4 / 3;
  background-size: cover;
  background-position: center;
  transition: background-image 500ms ease;
  border: 1px solid var(--line);
}
.section-img.portrait { aspect-ratio: 4 / 5; }
.section-img.wide     { aspect-ratio: 16 / 9; }

/* ---------- Forms (統一 16px 避免 iOS 縮放) ---------- */
.form-input, .form-select, .form-textarea, .inp {
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 14px 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  border-radius: 2px;
  transition: border-color 200ms;
  width: 100%;
  min-height: var(--tap);
}
.form-input:focus, .form-select:focus, .form-textarea:focus, .inp:focus {
  outline: none; border-color: var(--accent);
}
.form-textarea, textarea.inp {
  resize: vertical;
  min-height: 110px;
  line-height: 1.6;
}
.form-label, .lbl {
  font-size: var(--fs-caption);
  letter-spacing: 0.14em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

/* ---------- Footer ---------- */
.site-footer {
  padding: 48px 20px calc(48px + var(--safe-bottom));
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--line);
}
.site-footer p { margin: 0; }
.site-footer .small { font-size: 12px; opacity: 0.7; margin-top: 6px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%;
  transform: translate(-50%, 80px);
  background: var(--text);
  color: var(--bg);
  padding: 12px 24px;
  font-size: 13.5px;
  letter-spacing: 0.1em;
  border-radius: 999px;
  z-index: 80;
  opacity: 0;
  transition: all 400ms;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- Accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Utilities ---------- */
.fade-in { animation: fadeIn 800ms ease both; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Hero 影片背景（手機 only，取代 hero 圖）---------- */
/* 桌機 / 平板：影片與 overlay 完全隱藏，維持 themes.js 原本的背景圖邏輯 */
.hero-video,
.hero-overlay { display: none; }

@media (max-width: 767.98px) {
  /* 手機 only 顯示影片取代 hero 圖 */
  .hero-video {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    background: var(--bg); /* 影片尚未顯示時的底色 */
  }
  /* 覆蓋在影片之上的漸層，確保左側文字對比（與 themes 原 heroOverlay 相同方向） */
  .hero-overlay {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(
      to right,
      rgba(0, 0, 0, 0.55) 0%,
      rgba(0, 0, 0, 0.3) 55%,
      rgba(0, 0, 0, 0.05) 100%
    );
    pointer-events: none;
  }
  /* hero 內容與 scroll-hint 都要 stack 在影片+overlay 之上 */
  .hero-fullbleed .hero-content,
  .hero-fullbleed .scroll-hint { position: relative; z-index: 2; }
}

/* ---------- 派系音樂播放器（參考 ai-brain pc-bottom-bar，mobile-first）---------- */
.sw-player {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 70;
  background: rgba(26, 26, 26, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.28);
  padding: calc(10px) 0 calc(10px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 400ms cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}
.sw-player.visible {
  transform: translateY(0);
  pointer-events: auto;
}
/* 有播放器時底部 padding，避免遮內容 */
body.has-player { padding-bottom: 72px; }
@media (min-width: 640px) { body.has-player { padding-bottom: 80px; } }

.sw-player-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
@media (min-width: 640px) {
  .sw-player-inner { padding: 0 20px; gap: 16px; }
}

.sw-player-play {
  width: var(--tap);
  height: var(--tap);
  min-width: var(--tap);
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s, box-shadow 0.2s;
  font-family: inherit;
}
.sw-player-play:hover { transform: scale(1.06); }
.sw-player-play.playing {
  animation: swPulse 1.6s ease infinite;
}
@keyframes swPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192, 139, 107, 0); }
  50%      { box-shadow: 0 0 0 10px rgba(192, 139, 107, 0.25); }
}

.sw-player-info {
  flex: 1;
  min-width: 0;
}
.sw-player-title {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.78);
  letter-spacing: 0.08em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
  font-family: inherit;
}
@media (min-width: 640px) { .sw-player-title { font-size: 13px; } }

.sw-player-progress {
  height: 3px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 3px;
  cursor: pointer;
  overflow: hidden;
}
.sw-player-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.15s linear;
}
.sw-player-time {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.42);
  margin-top: 3px;
  letter-spacing: 0.04em;
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
}
@media (min-width: 640px) { .sw-player-time { font-size: 11px; } }

.sw-player-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}
.sw-player-close:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
