﻿/* theme.css - 八字冷暖表 最終版 (2026.03.17) */

:root {
  --bg-body: linear-gradient(145deg, #fdf5f0 0%, #f0e7db 100%);
  --bg-container: rgba(255,255,255,0.9);
  --backdrop: blur(8px);
  --shadow-container: 0 12px 30px rgba(0,0,0,0.15);
  --border-container: 1px solid rgba(255,245,235,0.6);
  --text-main: #4a3b2c;
  --text-sub: #9b7b6b;
  --text-light: #7a5d4e;
  --text-muted: #6e5440;
  --primary: #cfa189;
  --primary-hover: #b8866b;
  --primary-shadow: rgba(170,130,100,0.3);
  --bg-form: #fff8f2;
  --bg-ad: #f3ede7;
  --border-ad: 1px dashed #b9a291;
  --text-ad: #7d6657;
  --bg-privacy: #d4edda;
  --text-privacy: #155724;
  --border-privacy: 4px solid #28a745;
  --bg-charity: #e9dad1;
  --text-charity: #4e3e33;
  --border-charity: 6px solid #b3927e;
  --bg-preview: #f0e0d0;
  --border-input: #dccbbd;
  --focus-border: #b28b7a;
  --focus-ring: rgba(210,150,130,0.3);
  --required: #c44536;
  --table-header-bg: #bda79b;
  --table-header-text: white;
  --table-even: #faf3ed;
  --table-border: #ecdacf;
  --dayun-header: #cfa189;
  --positive-color: #c44536;
  --negative-color: #1e90ff;
  --footer-font: 0.95rem;
  --footer-small: 0.82rem;
  --footer-opacity: 0.85;
  --spacing: 1rem;
  --font-base: 16px;
  --ripple-color: rgba(255,255,255,0.3);
  --card-shadow: 0 4px 12px rgba(0,0,0,0.08);
  --card-shadow-hover: 0 8px 24px rgba(0,0,0,0.12);
  --btn-shadow: 0 8px 16px rgba(170,130,100,0.3);
  --btn-shadow-hover: 0 12px 24px rgba(170,130,100,0.4);
  --btn-press-scale: 0.97;
  --border-radius-card: 32px;
  --border-radius-button: 48px;
  --border-radius-item: 24px;
}


/* 新年紅主題 (完全保留) */
[data-theme="red"] {
  --bg-body: linear-gradient(145deg, #9d2a2a 0%, #c0392b 100%);
  --bg-container: rgba(220, 20, 20, 0.9);
  --text-main: #ffecb3;
  --text-sub: #ffe082;
  --text-light: #ffd54f;
  --text-muted: #ffb74d;
  --primary: #ff4d4d;
  --primary-hover: #e03a3a;
  --primary-shadow: rgba(255, 215, 0, 0.5);
  --bg-form: #b22222;
  --bg-ad: #8b1a1a;
  --border-ad: 1px dashed #ffd700;
  --text-ad: #ffecb3;
  --bg-privacy: #ffd700;
  --text-privacy: #8b0000;
  --border-privacy: 4px solid #b8860b;
  --bg-charity: #d4af37;
  --text-charity: #8b0000;
  --border-charity: 6px solid #b22222;
  --bg-preview: #b03a2e;
  --border-input: #ffd700;
  --focus-border: #ffaa00;
  --focus-ring: rgba(255, 215, 0, 0.5);
  --table-header-bg: #b22222;
  --table-header-text: #ffd700;
  --table-even: #a52a2a;
  --table-border: #ffd700;
  --dayun-header: #8b1a1a;
  --positive-color: #ffaa00;
  --negative-color: #ffe082;
  --ripple-color: rgba(255,255,255,0.3);
  --card-shadow: 0 4px 12px rgba(0,0,0,0.2);
  --card-shadow-hover: 0 8px 24px rgba(0,0,0,0.3);
  --btn-shadow: 0 8px 16px rgba(255, 215, 0, 0.5);
  --btn-shadow-hover: 0 12px 24px rgba(255, 215, 0, 0.6);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--font-base);
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-body);
  margin: 0;
  padding: calc(var(--spacing) * 0.8);
  color: var(--text-main);
  line-height: 1.6;
  transition: background 0.3s ease;
  min-height: 100vh;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  background: var(--bg-container);
  backdrop-filter: var(--backdrop);
  -webkit-backdrop-filter: var(--backdrop);
  border-radius: var(--border-radius-card);
  box-shadow: var(--shadow-container);
  padding: 1.8rem;
  border: var(--border-container);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

h1 {
  margin-top: 0;
  font-size: 2.0rem;
  font-weight: 600;
  color: var(--text-main);
  text-align: center;
  border-bottom: 2px solid var(--border-input);
  padding-bottom: 1rem;
  letter-spacing: 0.5px;
}
.sub {
  text-align: center;
  font-size: 1.2rem;
  /* footer加深文字顏色，提高對比度 */
  color: #836e5f;  /* 更深褐色，與背景明顯區分 */
  margin-bottom: 0.5rem;
  font-style: italic;
}

/* 卡片區塊 */
.charity-note {
  background: var(--bg-charity);
  color: var(--text-charity);
  padding: 1rem 2rem;
  border-radius: 60px;
  margin: 0.5rem 0;
  text-align: center;
  font-size: 1.1rem;
  border-left: var(--border-charity);
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--card-shadow);
}
.charity-note:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-shadow-hover);
}

.form-section {
  background: var(--bg-form);
  border-radius: var(--border-radius-item);
  padding: 1.8rem;
  margin-bottom: 0.5rem;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.05), var(--card-shadow);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.form-group { margin-bottom: 0.5rem; }
label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 0.4rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding-left: 0.8rem;
}
input, select {
  width: 100%;
  padding: 1rem 1.2rem;
  border: 1px solid var(--border-input);
  border-radius: var(--border-radius-button);
  font-size: 1rem;
  background: rgba(255,255,255,0.1);
  color: var(--text-main);
  transition: all 0.2s ease;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus {
  border-color: var(--focus-border);
  box-shadow: 0 0 0 4px var(--focus-ring);
}

/* 按鈕 - Apps 風格 */
.btn {
  position: relative;
  overflow: hidden;
  background: var(--primary);
  color: white;
  border: none;
  padding: 1rem 2rem;
  font-size: 1.2rem;
  font-weight: 600;
  border-radius: var(--border-radius-button);
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: var(--btn-shadow);
  min-width: 200px;
  margin: 0.5rem 0;
  letter-spacing: 0.5px;
  width: auto;
  display: inline-block;
  text-decoration: none;
}
.btn:hover {
  background: var(--primary-hover);
  transform: translateY(-4px);
  box-shadow: var(--btn-shadow-hover);
}
.btn:active {
  transform: scale(var(--btn-press-scale));
  box-shadow: 0 4px 8px var(--primary-shadow);
}
.btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  background: var(--ripple-color);
  opacity: 0;
  border-radius: 100%;
  transform: scale(1, 1) translate(-50%, -50%);
  transform-origin: 50% 50%;
}
.btn:focus:not(:active)::after {
  animation: ripple 0.6s ease-out;
}
@keyframes ripple {
  0% { transform: scale(0, 0); opacity: 0.5; }
  100% { transform: scale(20, 20); opacity: 0; }
}

/* 讓按鈕容器在電腦版置中 */
.btn-container {
  text-align: center;
}

.privacy-note {
  background: var(--bg-privacy);
  color: var(--text-privacy);
  padding: 1rem 2rem;
  border-radius: 60px;
  margin: 1rem 0 0.5rem;
  text-align: center;
  font-size: 1rem;
  border-left: var(--border-privacy);
  box-shadow: var(--card-shadow);
}
.privacy-note:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-2px);
}

.footer {
  margin-top: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--footer-font);
  border-top: 1px solid var(--border-input);
  padding-top: 1.8rem;
  line-height: 1.6;
}
.footer small {
  display: block;
  margin-top: 0.6rem;
  font-size: var(--footer-small);
  opacity: var(--footer-opacity);
}
.required-star { color: var(--required); margin-left: 2px; }
#baziPreview {
  font-size: 1.2rem;
  font-weight: bold;
  text-align: center;
  background: var(--bg-preview);
  padding: 1.2rem;
  border-radius: var(--border-radius-item);
  box-shadow: var(--card-shadow);
}

/* 電腦表格 */
.result-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-form);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow-container);
}
.result-table th {
  background: var(--table-header-bg);
  color: var(--table-header-text);
  padding: 1rem 0.8rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  font-size: 1rem;
}
.result-table td {
  padding: 1rem 0.8rem;
  border-bottom: 1px solid var(--table-border);
  text-align: center;
}
.result-table tbody tr {
  transition: background 0.2s;
}
.result-table tbody tr:hover {
  background: var(--table-even);
  cursor: default;
}
.dayun-header td {
  background: var(--dayun-header);
  color: white;
  font-weight: bold;
  padding: 0.5rem;
  text-align: left;
  font-size: 1.1rem;
}
.score { font-weight: bold; color: var(--primary); }

/* 手機版 - 所有卡片統一四邊圓角 */
@media (max-width: 768px) {
  body { 
    padding: 0.5rem; 
    font-size: 15px; 
  }
  .container { 
    padding: 1.2rem; 
    border-radius: 24px; 
    gap: 1rem;
  }
  h1 { font-size: 2rem; margin-bottom: 0.2rem; }
  
  .grid-3 { 
    grid-template-columns: repeat(3, 1fr); 
    gap: 0.8rem; 
    margin-bottom: 1rem;
  }
  .grid-2 { 
    grid-template-columns: repeat(2, 1fr); 
    gap: 0.8rem; 
    margin-bottom: 1rem;
  }
  
  input, select { 
    padding: 1rem 1.1rem;
    font-size: 1rem; 
    border-radius: 32px;
  }
  .btn {
    width: 100%;
    padding: 1rem;
    font-size: 1.2rem;
    min-height: 56px;
    margin: 0.5rem 0;
  }

  .footer { font-size: 0.9rem; padding-top: 1.2rem; }
  .footer small { font-size: 0.8rem; }

  /* 表格轉卡片列表 */
  .result-table {
    display: block;
    width: 100%;
    margin: 1rem 0;
    background: transparent;
    box-shadow: none;
  }
  .result-table thead { display: none; }
  .result-table tbody {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }
  
  /* 所有卡片統一四邊圓角 */
  .result-table tr {
    display: block;
    background: var(--bg-form);
    border-radius: var(--border-radius-item);  /* 四邊一致圓角 */
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05), var(--card-shadow);
    border: 1px solid var(--table-border);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
  }
  .result-table tr:active {
    transform: scale(0.98);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05), 0 2px 6px rgba(0,0,0,0.1);
  }
  
  /* 普通格 */
  .result-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--table-border);
    text-align: right;
    background: transparent;
    font-size: 1rem;
  }
  .result-table td:last-child { border-bottom: none; }
  .result-table td:before {
    content: attr(data-label);
    font-weight: bold;
    color: var(--text-sub);
    flex: 0 0 40%;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.95rem;
    padding-right: 0.5rem;
  }
  
  /* 大運標題行 - 獨立卡片，四邊圓角 */
  .dayun-header td {
    display: block;
    text-align: center;
    background: var(--dayun-header);
    color: var(--table-header-text);
    padding: 0.9rem 1rem;
    font-size: 1.15rem;
    font-weight: bold;
    border-radius: var(--border-radius-item);  /* 四邊圓角 */
    border-bottom: 2px solid var(--table-border);
  }
  
  /* 移除所有特殊相鄰處理，所有卡片獨立 */
  .dayun-header + tr {
    border-top-left-radius: var(--border-radius-item);
    border-top-right-radius: var(--border-radius-item);
  }
  .dayun-header + tr td {
    padding-top: 1rem;  /* 恢復正常內距 */
  }

  /* 知識網格手機版 */
  .knowledge-grid {
    gap: 0.8rem;
    justify-items: center;
  }
  .knowledge-grid .btn {
    font-size: 1rem;
    padding: 0.6rem 1rem;
    line-height: 1.2;
    border-radius: 40px;
    width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    text-decoration: none;
    min-width: 80px;
    margin: 0.2rem;
  }

  /* 移除漣漪效果 */
  .btn::after { display: none; }
}

/* 主題切換按鈕 */
#theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  padding: 0.7rem 1.5rem;
  border-radius: 50px;
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0,0,0,0.25);
  font-size: 1rem;
  font-weight: 500;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
#theme-toggle:hover {
  background: var(--primary-hover);
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}
#theme-toggle:active {
  transform: scale(0.95);
}

/* 載入動畫 */
#loading {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 2rem;
  color: var(--text-sub);
  font-size: 1.1rem;
}
#loading:after {
  content: "";
  width: 24px;
  height: 24px;
  border: 3px solid var(--primary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 免責聲明樣式 */
.disclaimer {
  font-size: 0.9em;
  color: var(--text-muted);
  font-style: italic;
  margin: 8px 0;
  text-align: center;
}

/* 知識網格 - 電腦版 */
.knowledge-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin: 2rem 0;
  justify-content: center;
}
.knowledge-grid h3 {
  grid-column: 1 / -1;
  text-align: center;
  margin-bottom: 0.5rem;
  font-size: 1.4rem;
  font-weight: 600;
}
.knowledge-grid .btn {
  margin: 0;
  width: 100%;
  text-align: center;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 1rem;
  padding: 0.8rem 0.2rem;
  box-shadow: var(--btn-shadow);
}
.knowledge-grid .btn:hover {
  transform: translateY(-3px);
  box-shadow: var(--btn-shadow-hover);
}
.btn {
  text-decoration: none;
}
.site-header {
    font-size: 2.4rem;
    font-weight: 600;
    color: var(--text-main);
    text-align: center;
    border-bottom: 2px solid var(--border-input);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    letter-spacing: 0.5px;
}
