/**
 * 朴子召會統一設計系統
 * Puzih Church Design System v2.0
 *
 * 設計理念：溫暖、莊重、現代、易用
 * 配色：金色主調 + 象牙白背景
 */

/* ===== Chapter 24 RWD 全域防護 ===== */
/* iOS Safari 100vh 高度錯誤 fallback：使用 100dvh 動態視口高度 */
:root {
  --viewport-h: 100vh;
  --tap-target-min: 44px;
  --tap-target-elder: 52px;
}
@supports (height: 100dvh) {
  :root { --viewport-h: 100dvh; }
}
/* 320px 寬度 overflow 全域兜底 */
html, body { overflow-x: hidden; max-width: 100%; }
iframe, embed, object, video, img { max-width: 100%; }
img { height: auto; }
table { max-width: 100%; }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
/* iOS 安全區整合（fixed 底部元素） */
.safe-bottom { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.safe-top { padding-top: max(16px, env(safe-area-inset-top)); }

/* ===== 公開頁桌機 top-nav（chapter 24 第 24.16 節）===== */
/* 手機（<768px）隱藏 desktop nav；桌機（≥768px）隱藏 mobile back link */
.public-top-nav { display: none; }
.public-mobile-back { display: flex; }
@media (min-width: 768px) {
  .public-top-nav {
    display: flex;
    background: white;
    border-bottom: 1px solid var(--gold-200, #E8D5A3);
    padding: 12px 24px;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    position: sticky;
    top: 0;
    z-index: 100;
  }
  .public-mobile-back { display: none; }
  .public-top-nav .brand {
    font-family: 'Noto Serif TC', 'Noto Sans TC', serif;
    font-size: 18px;
    color: #1a1a1a;
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
  }
  .public-top-nav .brand:hover { color: var(--gold-400, #B8960B); }
  .public-top-nav .nav-links {
    display: flex;
    gap: 16px;
    flex: 1;
    justify-content: center;
    flex-wrap: wrap;
  }
  .public-top-nav .nav-links a {
    color: #555;
    text-decoration: none;
    font-size: 15px;
    padding: 8px 14px;
    border-radius: 6px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    transition: all 0.15s;
  }
  .public-top-nav .nav-links a:hover {
    color: var(--gold-400, #B8960B);
    background: var(--gold-50, #FDFBF7);
  }
  .public-top-nav .nav-links a[aria-current="page"] {
    color: var(--gold-400, #B8960B);
    font-weight: 600;
    background: var(--gold-50, #FDFBF7);
  }
  .public-top-nav .nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }
}

/* ===== CSS 變數 ===== */
:root {
  /* 主色調 - 溫暖金色系 */
  --gold-50: #FDFBF7;
  --gold-100: #F9F3E3;
  --gold-200: #E8D5A3;
  --gold-300: #C9A962;
  --gold-400: #B8960B;
  --gold-500: #9A7B0A;
  --gold-600: #7D6408;
  
  /* 背景色 - 象牙白 */
  --ivory-50: #FEFEFE;
  --ivory-100: #FAFAF8;
  --ivory-200: #F5F5F2;
  
  /* 文字色 */
  --text-primary: #1F2937;
  --text-secondary: #4B5563;
  --text-muted: #9CA3AF;
  --text-light: #D1D5DB;
  
  /* 功能色 */
  --success: #10B981;
  --success-light: #D1FAE5;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --danger: #EF4444;
  --danger-light: #FEE2E2;
  --info: #3B82F6;
  --info-light: #DBEAFE;
  
  /* 陰影（Claude Design v1：雙層柔陰影） */
  --shadow-sm: 0 1px 2px rgba(31,41,55,0.04);
  --shadow-md: 0 6px 16px -4px rgba(31,41,55,0.08), 0 2px 6px -2px rgba(31,41,55,0.05);
  --shadow-lg: 0 12px 32px -8px rgba(201,169,98,0.18), 0 4px 12px -4px rgba(31,41,55,0.06);
  --shadow-xl: 0 24px 48px -12px rgba(201,169,98,0.22), 0 8px 20px -8px rgba(31,41,55,0.08);

  /* 圓角（Claude Design v1：現代卡片節奏） */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* 動畫 */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s ease;

  /* 字體 */
  --font-sans: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Noto Sans TC', sans-serif;
  --font-display: 'Noto Sans TC', sans-serif;

  /* === Claude Design v1：精緻刷新（追加 tokens，不影響舊值） === */
  /* 高度系統 - 統一 z 軸層級 */
  --shadow-elevation-1: 0 1px 2px rgba(31,41,55,0.04), 0 1px 1px rgba(31,41,55,0.03);
  --shadow-elevation-2: 0 4px 12px -2px rgba(31,41,55,0.06), 0 2px 6px -2px rgba(31,41,55,0.04);
  --shadow-elevation-3: 0 12px 32px -8px rgba(201,169,98,0.18), 0 4px 12px -4px rgba(31,41,55,0.06);
  --shadow-elevation-4: 0 24px 48px -12px rgba(201,169,98,0.22), 0 8px 20px -8px rgba(31,41,55,0.08);
  --shadow-focus-gold: 0 0 0 4px rgba(201,169,98,0.18);

  /* 8pt 間距系統 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* 字級 scale */
  --font-size-xs: 12px;
  --font-size-sm: 13px;
  --font-size-base: 14px;
  --font-size-md: 15px;
  --font-size-lg: 16px;
  --font-size-xl: 18px;
  --font-size-2xl: 22px;
  --font-size-3xl: 28px;
  --font-size-4xl: 36px;
  --line-height-tight: 1.25;
  --line-height-snug: 1.4;
  --line-height-normal: 1.6;

  /* 邊框 */
  --border-subtle: 1px solid rgba(232,213,163,0.5);
  --border-default: 1px solid var(--gold-200);
  --border-strong: 1.5px solid var(--gold-300);

  /* surfaces - 背景分層 */
  --surface-base: var(--ivory-50);
  --surface-raised: #FFFFFF;
  --surface-sunken: var(--ivory-200);
  --surface-overlay: rgba(255,255,255,0.96);

  /* 漸層 - 召會金色精緻調色 */
  --gradient-gold-soft: linear-gradient(135deg, #FDFBF7 0%, #F9F3E3 100%);
  --gradient-gold-warm: linear-gradient(135deg, var(--gold-100) 0%, var(--gold-200) 100%);
  --gradient-overlay: linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.7) 100%);

  /* 微互動緩動曲線 */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Claude Design v1：精緻動畫 keyframes === */
@keyframes claude-fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes claude-pulse-border {
  0%, 100% { border-color: #F87171; }
  50% { border-color: #DC2626; }
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--ivory-50);
}

::selection {
  background: var(--gold-300);
  color: white;
}

/* ===== 字體類 ===== */
.font-sans { font-family: var(--font-sans); }
.font-serif { font-family: var(--font-serif); }
.font-display { font-family: var(--font-display); }

/* ===== 容器 ===== */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.container-sm { max-width: 640px; }
.container-md { max-width: 768px; }
.container-lg { max-width: 1024px; }

/* ===== 卡片 ===== */
.card {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gold-100);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-normal);
}

.card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--gold-200);
}

.card-body {
  padding: 24px;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gold-100);
}

.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gold-100);
  background: var(--ivory-100);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ===== 按鈕 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-normal);
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-300), var(--gold-400));
  color: white;
  box-shadow: 0 4px 12px rgba(201,169,98,0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(201,169,98,0.4);
}

.btn-secondary {
  background: white;
  color: var(--gold-500);
  border: 1.5px solid var(--gold-200);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--gold-50);
  border-color: var(--gold-300);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--ivory-200);
  color: var(--text-primary);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

.btn-lg {
  padding: 16px 32px;
  font-size: 17px;
}

.btn-block {
  width: 100%;
}

/* ===== 表單 ===== */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  border: 1.5px solid var(--gold-100);
  border-radius: var(--radius-md);
  background: var(--ivory-50);
  color: var(--text-primary);
  transition: var(--transition-fast);
  -webkit-appearance: none;
}

.form-input:focus {
  outline: none;
  border-color: var(--gold-300);
  background: white;
  box-shadow: 0 0 0 4px rgba(201,169,98,0.1);
}

.form-input::placeholder {
  color: var(--text-muted);
}

/* ===== 導航 ===== */
.nav-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--gold-100);
  padding: 16px 0;
}

.nav-brand {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 15px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.nav-link:hover {
  color: var(--gold-500);
  background: var(--gold-50);
}

.nav-link.active {
  color: var(--gold-500);
  font-weight: 500;
}

/* ===== 底部導航（手機） ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--gold-100);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 8px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 100;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  color: var(--text-muted);
  font-size: 11px;
  text-decoration: none;
  transition: var(--transition-fast);
}

.bottom-nav-item .icon {
  font-size: 22px;
}

.bottom-nav-item.active {
  color: var(--gold-500);
}

/* 5 欄底部導航 */
.bottom-nav.bottom-nav-5 {
  grid-template-columns: repeat(5, 1fr);
}

.bottom-nav.bottom-nav-5 .bottom-nav-item {
  font-size: 10px;
  padding: 6px 4px;
}

.bottom-nav.bottom-nav-5 .bottom-nav-item .icon {
  font-size: 20px;
}

/* ===== 標題 ===== */
.section-title {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.section-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
}

.page-header {
  text-align: center;
  padding: 48px 20px;
}

/* ===== 分隔線 ===== */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-200), transparent);
  margin: 32px 0;
}

.divider-text {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gold-200);
}

/* ===== Badge ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 20px;
}

.badge-gold {
  background: var(--gold-100);
  color: var(--gold-600);
}

.badge-success {
  background: var(--success-light);
  color: #065F46;
}

.badge-warning {
  background: var(--warning-light);
  color: #92400E;
}

.badge-danger {
  background: var(--danger-light);
  color: #991B1B;
}

/* ===== 動畫 ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-fade {
  animation: fadeIn 0.5s ease-out forwards;
}

.animate-slide {
  animation: slideUp 0.6s ease-out forwards;
}

/* ===== Loading ===== */
.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--gold-100);
  border-top-color: var(--gold-400);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.skeleton {
  background: linear-gradient(90deg, var(--ivory-200) 25%, var(--ivory-100) 50%, var(--ivory-200) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 40px);
  max-width: 400px;
  pointer-events: none;
}

.toast {
  background: white;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideDown 0.3s ease-out;
  pointer-events: auto;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 網格 ===== */
.grid {
  display: grid;
  gap: 20px;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
}

/* ===== 響應式工具 ===== */
.hide-mobile { display: block; }
.show-mobile { display: none; }

@media (max-width: 768px) {
  .hide-mobile { display: none; }
  .show-mobile { display: block; }
  
  .container { padding: 0 16px; }
  .card-body { padding: 20px; }
  .section-title { font-size: 1.5rem; }
  .page-header { padding: 32px 16px; }
}

/* ===== 安全區域 ===== */
@supports (padding: env(safe-area-inset-bottom)) {
  .safe-bottom {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ===== 滾動條 ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--ivory-100);
}

::-webkit-scrollbar-thumb {
  background: var(--gold-300);
  border-radius: 3px;
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* ===== 空狀態 ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state h3 {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
