/* 玄機智算 - 玄學風格CSS */

/* ========== 配色變量（玄學金木水火土） ========== */
:root {
  --玄黑: #0f0f23;        /* 星空底 */
  --金輝: #d4af37;         /* 卦畫金邊 */
  --玉霧: #f0f8f5;         /* 雲霧字 */
  --朱砂: #c8102e;         /* 警戒紅 */
  --墨綠: #1a3c34;         /* 古籍綠 */
  --星藍: #1e3a5f;         /* 夜空藍 */
  --紫氣: #6a4c93;         /* 紫氣東來 */
  --青龍: #2d8659;         /* 青龍色 */
}

/* ========== 全局重置 ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Noto Serif TC', 'Microsoft YaHei', serif;
  background: var(--玄黑);
  color: var(--玉霧);
  overflow-x: hidden;
  min-height: 100vh;
  position: relative;
}

/* ========== 星雲背景動畫容器 ========== */
#starfield {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ========== 主容器 ========== */
.mystic-container {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 20px;
}

/* ========== 頂部標題區 ========== */
.mystic-header {
  text-align: center;
  padding: 40px 20px;
  position: relative;
  animation: fadeInDown 1.5s ease-out;
}

.mystic-logo {
  font-size: 4em;
  font-weight: bold;
  background: linear-gradient(135deg, var(--金輝) 0%, #ffd700 50%, var(--金輝) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 30px rgba(212, 175, 55, 0.5);
  margin-bottom: 10px;
  animation: goldPulse 3s ease-in-out infinite;
  position: relative;
}

.mystic-logo::before {
  content: '✨';
  position: absolute;
  left: -50px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.6em;
  animation: sparkle 2s ease-in-out infinite;
}

.mystic-logo::after {
  content: '✨';
  position: absolute;
  right: -50px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.6em;
  animation: sparkle 2s ease-in-out infinite 1s;
}

.mystic-subtitle {
  font-size: 1.2em;
  color: var(--玉霧);
  opacity: 0.8;
  letter-spacing: 3px;
}

/* ========== 輸入區（霧氣框） ========== */
.mystic-input-section {
  max-width: 800px;
  margin: 40px auto;
  padding: 40px;
  background: rgba(15, 15, 35, 0.6);
  border: 2px solid var(--金輝);
  border-radius: 20px;
  box-shadow: 0 0 30px rgba(212, 175, 55, 0.3),
              inset 0 0 30px rgba(212, 175, 55, 0.1);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
  animation: fadeInUp 1.5s ease-out 0.3s both;
}

.mystic-input-section::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(212, 175, 55, 0.1), transparent);
  animation: scanLine 4s linear infinite;
}

.form-group {
  margin-bottom: 25px;
  position: relative;
}

.form-label {
  display: block;
  font-size: 1.1em;
  color: var(--金輝);
  margin-bottom: 10px;
  text-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

.mystic-input {
  width: 100%;
  padding: 15px 20px;
  background: rgba(30, 58, 95, 0.5);
  border: 2px solid var(--金輝);
  border-radius: 10px;
  color: var(--玉霧);
  font-size: 1.1em;
  font-family: 'Noto Serif TC', serif;
  transition: all 0.3s ease;
  position: relative;
}

.mystic-input select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23d4af37' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
  padding-right: 40px;
  cursor: pointer;
}

.mystic-input:focus {
  outline: none;
  border-color: #ffd700;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.5),
              inset 0 0 20px rgba(255, 215, 0, 0.1);
  background: rgba(30, 58, 95, 0.7);
}

.mystic-input::placeholder {
  color: rgba(240, 248, 245, 0.5);
}

/* ========== 開卦按鈕（金光脈動） ========== */
.mystic-button {
  width: 100%;
  padding: 20px;
  background: linear-gradient(135deg, var(--金輝) 0%, #ffd700 100%);
  border: none;
  border-radius: 15px;
  color: var(--玄黑);
  font-size: 1.5em;
  font-weight: bold;
  font-family: 'Noto Serif TC', serif;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 0 30px rgba(212, 175, 55, 0.5);
  animation: goldPulse 2s ease-in-out infinite;
}

.mystic-button:hover {
  transform: scale(1.05);
  box-shadow: 0 0 50px rgba(212, 175, 55, 0.8);
}

.mystic-button:active {
  transform: scale(0.98);
}

.mystic-button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transform: translateY(-50%);
  transition: left 0.5s;
}

.mystic-button:hover::before {
  left: 100%;
}

.mystic-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  animation: none;
}

/* ========== 三卦結果區 ========== */
.mystic-results {
  max-width: 1400px;
  margin: 60px auto;
  padding: 40px;
  display: none;
  animation: fadeIn 1s ease-out;
}

.mystic-results.show {
  display: block;
}

.mystic-results-title {
  text-align: center;
  font-size: 2.5em;
  color: var(--金輝);
  margin-bottom: 40px;
  text-shadow: 0 0 20px rgba(212, 175, 55, 0.5);
  border: 2px solid var(--金輝);
  padding: 20px;
  border-radius: 15px;
  background: rgba(15, 15, 35, 0.6);
}

/* ========== 三儀合卦容器 ========== */
.mystic-three-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
  margin-bottom: 40px;
}

.mystic-panel {
  background: rgba(15, 15, 35, 0.7);
  border: 2px solid var(--金輝);
  border-radius: 15px;
  padding: 30px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
  box-shadow: 0 0 30px rgba(212, 175, 55, 0.3);
}

.mystic-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.1), transparent);
  pointer-events: none;
}

.panel-title {
  font-size: 1.5em;
  color: var(--金輝);
  margin-bottom: 20px;
  text-align: center;
  text-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

/* ========== 奇門9宮格 ========== */
.qimen-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 20px;
}

.qimen-cell {
  aspect-ratio: 1;
  background: rgba(30, 58, 95, 0.5);
  border: 2px solid var(--金輝);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
  transition: all 0.3s ease;
  position: relative;
}

.qimen-cell:hover {
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.5);
  border-color: #ffd700;
}

.qimen-cell.center {
  background: rgba(212, 175, 55, 0.2);
  border-color: #ffd700;
}

.cell-shen {
  font-size: 0.9em;
  color: var(--金輝);
  font-weight: bold;
}

.cell-men {
  font-size: 0.8em;
  color: var(--玉霧);
  margin-top: 5px;
}

/* ========== 周易6爻柱 ========== */
.yijing-yao-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 20px;
  align-items: center;
}

.yao-line {
  width: 80px;
  height: 12px;
  background: var(--金輝);
  border-radius: 6px;
  position: relative;
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
  transition: all 0.3s ease;
}

.yao-line.yin {
  background: transparent;
  border: 2px solid var(--金輝);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

.yao-line.dong {
  animation: yaoGlow 2s ease-in-out infinite;
}

/* ========== 姓名五格圓環 ========== */
.xingming-rings {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 20px;
}

.wuge-item {
  text-align: center;
  position: relative;
}

.wuge-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--金輝);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(30, 58, 95, 0.5);
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
  transition: all 0.3s ease;
}

.wuge-circle:hover {
  transform: scale(1.1);
  box-shadow: 0 0 30px rgba(212, 175, 55, 0.6);
}

.wuge-number {
  font-size: 1.5em;
  font-weight: bold;
  color: var(--金輝);
}

.wuge-label {
  font-size: 0.8em;
  color: var(--玉霧);
  margin-top: 5px;
}

/* ========== AI總斷（雲霧散開效果） ========== */
.mystic-ai-advice {
  margin-top: 40px;
  padding: 40px;
  background: rgba(15, 15, 35, 0.8);
  border: 3px solid var(--金輝);
  border-radius: 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 50px rgba(212, 175, 55, 0.5);
}

.mystic-ai-advice::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(212, 175, 55, 0.1), transparent);
  animation: cloudDisperse 2s ease-out;
}

.advice-title {
  font-size: 2em;
  color: var(--金輝);
  margin-bottom: 20px;
  text-shadow: 0 0 20px rgba(212, 175, 55, 0.5);
}

.advice-text {
  font-size: 1.3em;
  color: var(--玉霧);
  line-height: 1.8;
  text-shadow: 0 0 10px rgba(240, 248, 245, 0.3);
}

.advice-score {
  font-size: 2.5em;
  color: var(--金輝);
  font-weight: bold;
  margin: 20px 0;
  text-shadow: 0 0 30px rgba(212, 175, 55, 0.8);
  animation: scorePulse 2s ease-in-out infinite;
}

/* ========== 加載動畫 ========== */
.mystic-loading {
  display: none;
  text-align: center;
  padding: 40px;
}

.mystic-loading.show {
  display: block;
}

.loading-text {
  font-size: 1.5em;
  color: var(--金輝);
  margin-top: 20px;
  animation: fadeInOut 1.5s ease-in-out infinite;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(212, 175, 55, 0.3);
  border-top: 4px solid var(--金輝);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

/* ========== 歷史記錄區 ========== */
.mystic-history {
  max-width: 1200px;
  margin: 60px auto;
  padding: 40px;
  background: rgba(15, 15, 35, 0.6);
  border: 2px solid var(--金輝);
  border-radius: 20px;
  display: none;
}

.mystic-history.show {
  display: block;
}

.history-title {
  font-size: 2em;
  color: var(--金輝);
  margin-bottom: 30px;
  text-align: center;
}

.history-item {
  padding: 20px;
  margin-bottom: 20px;
  background: rgba(30, 58, 95, 0.3);
  border: 1px solid var(--金輝);
  border-radius: 10px;
  transition: all 0.3s ease;
}

.history-item:hover {
  transform: translateX(10px);
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
}

/* ========== 動畫定義 ========== */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes goldPulse {
  0%, 100% {
    filter: brightness(1);
    text-shadow: 0 0 30px rgba(212, 175, 55, 0.5);
  }
  50% {
    filter: brightness(1.3);
    text-shadow: 0 0 50px rgba(212, 175, 55, 0.8);
  }
}

@keyframes sparkle {
  0%, 100% {
    opacity: 0.3;
    transform: translateY(-50%) scale(0.8);
  }
  50% {
    opacity: 1;
    transform: translateY(-50%) scale(1.2);
  }
}

@keyframes scanLine {
  0% {
    transform: translate(-100%, -100%) rotate(45deg);
  }
  100% {
    transform: translate(100%, 100%) rotate(45deg);
  }
}

@keyframes yaoGlow {
  0%, 100% {
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
  }
  50% {
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.9);
  }
}

@keyframes cloudDisperse {
  0% {
    opacity: 1;
    transform: scale(0.5);
  }
  100% {
    opacity: 0;
    transform: scale(2);
  }
}

@keyframes scorePulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

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

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

@keyframes rotateIn {
  from {
    opacity: 0;
    transform: rotate(-180deg) scale(0.5);
  }
  to {
    opacity: 1;
    transform: rotate(0deg) scale(1);
  }
}

/* ========== 玄學6宮選擇界面 ========== */
.six-palaces-container {
  margin: 20px 0;
}

.six-palaces-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

.palace-card {
  background: rgba(30, 58, 95, 0.5);
  border: 2px solid var(--金輝);
  border-radius: 15px;
  padding: 25px;
  text-align: center;
  cursor: pointer;
  transition: all 0.4s ease;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.palace-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(212, 175, 55, 0.2), transparent);
  transform: rotate(45deg);
  transition: all 0.6s ease;
  opacity: 0;
}

.palace-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 40px rgba(212, 175, 55, 0.4);
  border-color: #ffd700;
  background: rgba(30, 58, 95, 0.7);
}

.palace-card.active {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.3) 0%, rgba(255, 215, 0, 0.2) 100%);
  border-color: #ffd700;
  box-shadow: 0 0 50px rgba(255, 215, 0, 0.8),
              inset 0 0 30px rgba(255, 215, 0, 0.2);
  transform: scale(1.05);
}

.palace-card.active::before {
  animation: goldScan 1.5s ease-in-out;
  opacity: 1;
}

@keyframes goldScan {
  0% {
    transform: translate(-100%, -100%) rotate(45deg);
  }
  100% {
    transform: translate(100%, 100%) rotate(45deg);
  }
}

.palace-icon {
  font-size: 3.5em;
  margin-bottom: 15px;
  filter: drop-shadow(0 2px 8px rgba(212, 175, 55, 0.5));
  transition: all 0.3s ease;
}

.palace-card:hover .palace-icon {
  transform: scale(1.1);
}

.palace-card.active .palace-icon {
  animation: iconPulse 1s ease-in-out infinite;
  filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.8));
}

@keyframes iconPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
  }
}

.palace-name {
  font-size: 1.4em;
  font-weight: bold;
  color: var(--金輝);
  margin-bottom: 8px;
  text-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
  transition: all 0.3s ease;
}

.palace-card.active .palace-name {
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
  font-size: 1.5em;
}

.palace-desc {
  font-size: 1em;
  color: var(--玉霧);
  opacity: 0.8;
  transition: all 0.3s ease;
}

.palace-card.active .palace-desc {
  color: #ffd700;
  opacity: 1;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* ========== 響應式設計 ========== */
@media (max-width: 768px) {
  .mystic-logo {
    font-size: 2.5em;
  }
  
  .mystic-three-panels {
    grid-template-columns: 1fr;
  }
  
  .mystic-input-section {
    padding: 20px;
  }
  
  .six-palaces-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
  }
}

@media (max-width: 480px) {
  .six-palaces-grid {
    grid-template-columns: 1fr;
  }
  
  .palace-icon {
    font-size: 2.5em;
  }
  
  .palace-name {
    font-size: 1.2em;
  }
}
