/* ===== CSS 변수 (라이트 모드 기본) ===== */
:root {
  --bg-color: #f0ede8;
  --container-bg: #ffffff;
  --header-bg: rgba(255, 255, 255, 0.97);
  --text-primary: #1a1a1a;
  --text-secondary: #5a5a5a;
  --accent-color: #8A1538;
  --btn-hover: #6c102c;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.07);
  --border-color: #ddd8d0;
  --card-bg: #ffffff;
  --p-gold: #b38b4d;

  /* 다크/라이트 전용 변수 */
  --tarot-card-bg: linear-gradient(135deg, #5c3472, #3b1a5a);
  --tarot-card-border: rgba(155, 108, 194, 0.6);
  --tarot-card-hover-border: #b38b4d;

  --toggle-bg: #ece8e3;
  --toggle-hover-bg: #ddd8d0;
  --toggle-border: #c8c2ba;

  --btn-secondary-bg: transparent;
  --btn-secondary-border: #c8c2ba;
  --btn-secondary-color: #5a5a5a;
  --btn-secondary-hover-bg: #f5f2ee;

  --input-bg: #faf9f7;
  --icon-accent: #8A1538;
}

/* ===== 다크 모드 변수 ===== */
body.dark-mode {
  --bg-color: #0f0f12;
  --container-bg: #1a1a1e;
  --header-bg: rgba(15, 15, 18, 0.97);
  --text-primary: #e4e4e7;
  --text-secondary: #a1a1aa;
  --accent-color: #be123c;
  --btn-hover: #9f1239;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  --border-color: #2e2e34;
  --card-bg: #242429;
  --p-gold: #c9a85c;

  --tarot-card-bg: linear-gradient(135deg, #1a1a2e, #0a0a14);
  --tarot-card-border: rgba(255, 255, 255, 0.12);
  --tarot-card-hover-border: #c9a85c;

  --toggle-bg: #242429;
  --toggle-hover-bg: #2e2e35;
  --toggle-border: #3f3f46;

  --btn-secondary-bg: transparent;
  --btn-secondary-border: #3f3f46;
  --btn-secondary-color: #a1a1aa;
  --btn-secondary-hover-bg: #242429;

  --input-bg: #1a1a1e;
  --icon-accent: #be123c;
}

/* ===== 리셋 & 기본 스타일 ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
html { scroll-behavior: smooth; }
body {
  font-family: 'Pretendard', 'Noto Sans KR', 'Apple SD Gothic Neo', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.8;
  font-size: 16px;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}
.wrapper { display: flex; flex-direction: column; min-height: 100vh; }

/* 숨김 처리 - 가장 중요한 유틸리티 클래스 */
.hidden { display: none !important; }

/* ===== 헤더 & 내비게이션 ===== */
.main-header {
  position: sticky;
  top: 0;
  background-color: var(--header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 1000;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}
.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.logo {
  font-size: 1.35rem;
  font-weight: 900;
  text-decoration: none;
  color: var(--accent-color);
  letter-spacing: -0.5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.main-nav ul { display: flex; list-style: none; gap: 1.5rem; }
.main-nav a {
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.9rem;
  opacity: 0.65;
  transition: color 0.2s ease, opacity 0.2s ease;
}
.main-nav a:hover,
.main-nav a.active {
  opacity: 1;
  color: var(--accent-color);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

/* 테마 토글 버튼 - 다크/라이트 모드에 따라 색상 변경 */
#theme-toggle {
  background: var(--toggle-bg);
  border: 1.5px solid var(--toggle-border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: background 0.3s ease, border-color 0.3s ease, transform 0.25s ease;
  flex-shrink: 0;
}
#theme-toggle:hover {
  background: var(--toggle-hover-bg);
  border-color: var(--accent-color);
  transform: rotate(20deg) scale(1.08);
}

/* ===== 레이아웃 ===== */
.container {
  max-width: 960px;
  margin: 3.5rem auto;
  padding: 0 1.5rem;
  flex: 1;
  width: 100%;
}
.landing-container { max-width: 900px; }
.content-section {
  background-color: var(--container-bg);
  padding: 3.5rem 3rem;
  border-radius: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 3rem;
  animation: slideUp 0.5s ease-out;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* ===== 타이포그래피 ===== */
h1 {
  font-size: 2.1rem;
  margin-bottom: 0.75rem;
  text-align: center;
  font-weight: 800;
  color: var(--text-primary);
}
h2 {
  font-size: 1.5rem;
  color: var(--text-primary);
  font-weight: 800;
  margin: 2rem 0 1.5rem;
}
.subtitle {
  color: var(--text-secondary);
  margin-bottom: 2.5rem;
  text-align: center;
  font-size: 1rem;
  line-height: 1.75;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* ===== 랜딩 페이지 ===== */
.hero-section { padding: 1.5rem 0 2rem; }
.choice-container {
  display: flex;
  gap: 1.8rem;
  margin-top: 2rem;
}
.choice-card {
  flex: 1;
  background-color: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: 22px;
  padding: 3rem 1.8rem;
  text-decoration: none;
  color: inherit;
  display: block;
  text-align: center;
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              border-color 0.3s ease,
              box-shadow 0.3s ease,
              background-color 0.3s ease;
}
.choice-card:hover {
  transform: translateY(-10px);
  border-color: var(--accent-color);
  box-shadow: 0 18px 40px rgba(138, 21, 56, 0.12);
}
.choice-icon {
  font-size: 3.8rem;
  margin-bottom: 1.4rem;
  display: block;
}
.choice-card h2 {
  margin: 0 0 0.9rem;
  font-size: 1.5rem;
  color: var(--text-primary);
}
.choice-card p {
  color: var(--text-secondary);
  font-size: 0.93rem;
  line-height: 1.7;
  margin-bottom: 1.8rem;
}
.choice-card .btn-primary {
  display: inline-block;
  width: auto;
  padding: 0.8rem 1.8rem;
  font-size: 0.95rem;
  border-radius: 50px;
}

/* ===== 폼 스타일 ===== */
.input-form { max-width: 520px; margin: 0 auto; }
.form-group { margin-bottom: 1.6rem; }
.row-group { display: flex; gap: 1.2rem; }
.half-width { flex: 1; min-width: 0; }
.form-group label {
  display: block;
  margin-bottom: 0.55rem;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
}
input, select, textarea {
  width: 100%;
  padding: 0.95rem 1.15rem;
  border-radius: 13px;
  border: 2px solid var(--border-color);
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.25s ease, background 0.3s ease, color 0.3s ease;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent-color);
  background: var(--container-bg);
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

/* ===== 버튼 ===== */
.btn-primary {
  background: var(--accent-color);
  color: #fff;
  border: none;
  padding: 1.15rem;
  border-radius: 14px;
  font-weight: 800;
  cursor: pointer;
  font-size: 1rem;
  font-family: inherit;
  width: 100%;
  display: block;
  text-align: center;
  text-decoration: none;
  transition: background 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
  box-shadow: 0 5px 16px rgba(138, 21, 56, 0.22);
}
.btn-primary:hover {
  background: var(--btn-hover);
  transform: translateY(-2px);
  box-shadow: 0 9px 22px rgba(138, 21, 56, 0.32);
}
.btn-primary:disabled {
  background: var(--text-secondary);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  opacity: 0.65;
}
.full-width { width: 100%; }

/* 보조 버튼 - 다크/라이트 모드 모두 대응 */
.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-color);
  border: 2px solid var(--btn-secondary-border);
  padding: 1rem 2rem;
  border-radius: 13px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.93rem;
  font-family: inherit;
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease;
  margin-top: 2rem;
  display: block;
  width: 100%;
  text-align: center;
}
.btn-secondary:hover {
  background: var(--btn-secondary-hover-bg);
  border-color: var(--accent-color);
  color: var(--accent-color);
}

/* ===== 로딩 스피너 ===== */
.loader-wrapper { text-align: center; padding: 4rem 0; }
.loader {
  width: 46px;
  height: 46px;
  border: 4px solid var(--border-color);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
  margin: 0 auto 1.4rem;
}
.loader-text {
  font-weight: 700;
  color: var(--accent-color);
  letter-spacing: 0.5px;
  font-size: 0.93rem;
}

/* ===== 결과 패널 (사주/타로 공통) ===== */
.result-panel { margin-top: 2.5rem; }
.result-panel hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin-bottom: 2rem;
}
.result-panel h2 {
  text-align: center;
  font-size: 1.4rem;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
}

/* ===== 사주 만세력 테이블 ===== */
.manse-table {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin: 2.5rem 0;
  padding: 1.5rem;
  background: var(--bg-color);
  border-radius: 18px;
  border: 1px solid var(--border-color);
  transition: background-color 0.3s ease;
}
.column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
}
.column > span {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}
.pillar {
  width: 100%;
  height: 88px;
  background: var(--container-bg);
  border: 2px solid var(--border-color);
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--text-primary);
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
.pillar.highlight {
  border-color: var(--accent-color);
  color: var(--accent-color);
  background: rgba(138, 21, 56, 0.04);
}
body.dark-mode .pillar.highlight {
  background: rgba(190, 18, 60, 0.08);
}

/* ===== 결과 박스 ===== */
.result-box {
  background: var(--card-bg);
  padding: 2rem 2.2rem;
  border-radius: 18px;
  margin-bottom: 1.3rem;
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}
.result-box::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: var(--accent-color);
  border-radius: 4px 0 0 4px;
}
.result-box h3 {
  font-size: 1.1rem;
  margin-bottom: 0.9rem;
  color: var(--text-primary);
  font-weight: 800;
}
.result-box p {
  font-size: 0.98rem;
  color: var(--text-secondary);
  line-height: 1.9;
  word-break: keep-all;
}
.detail-text {
  font-size: 0.98rem;
  color: var(--text-secondary);
  line-height: 1.9;
  word-break: keep-all;
}
.pos-desc {
  font-size: 0.82rem !important;
  color: var(--accent-color) !important;
  font-weight: 700;
  margin-bottom: 0.7rem;
  line-height: 1.5;
  opacity: 0.9;
}
.result-box.special {
  border-color: var(--p-gold);
}
.result-box.special::before {
  background: var(--p-gold);
}

/* ===== 타로 카드 - 카테고리 선택 ===== */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}
/* 카테고리 버튼 - 다크/라이트 모드 색상 변경 */
.cat-btn {
  padding: 1.6rem 1rem;
  border-radius: 16px;
  border: 2px solid var(--border-color);
  background: var(--card-bg);
  cursor: pointer;
  font-size: 0.98rem;
  font-weight: 800;
  font-family: inherit;
  transition: border-color 0.25s ease,
              transform 0.25s ease,
              background 0.25s ease,
              color 0.25s ease,
              box-shadow 0.25s ease;
  color: var(--text-primary);
  line-height: 1.4;
}
.cat-btn:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(138, 21, 56, 0.12);
}
body.dark-mode .cat-btn:hover {
  box-shadow: 0 8px 20px rgba(190, 18, 60, 0.18);
}
.cat-btn.selected {
  background: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
}

/* ===== 타로 카드 덱 - 다크/라이트 모드 색상 변경 ===== */
.tarot-deck {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 2.5rem 0;
}
/* 카드 뒷면 - 테마에 따라 색상 변경 */
.tarot-card {
  width: 56px;
  height: 90px;
  background: var(--tarot-card-bg);
  border-radius: 9px;
  border: 2px solid var(--tarot-card-border);
  cursor: pointer;
  transition: transform 0.28s ease, border-color 0.28s ease, opacity 0.28s ease;
}
.tarot-card::after {
  content: '✦';
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 1.1rem;
  opacity: 0.35;
  color: #fff;
}
.tarot-card:hover {
  transform: translateY(-13px) rotate(2deg);
  z-index: 10;
  border-color: var(--tarot-card-hover-border);
}
.tarot-card.selected {
  opacity: 0.18;
  transform: translateY(-18px);
  pointer-events: none;
}

/* 선택된 카드 미리보기 */
.picked-cards-preview {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.7rem;
  min-height: 52px;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
/* 카드 아이콘 - 다크/라이트 모드 배경 색상 변경 */
.card-icon-sm {
  font-size: 1.8rem;
  background: var(--card-bg);
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease, border-color 0.3s ease;
}

/* ===== 타로 스프레드 (결과 배치) ===== */
.tarot-spread {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin: 2.5rem 0;
}
.spread-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.spread-item > span {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}
/* 스프레드 카드 - 다크/라이트 모드 색상 변경 */
.card-sm {
  width: 100%;
  height: 125px;
  background: var(--bg-color);
  border: 2px solid var(--border-color);
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  box-shadow: var(--shadow);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.reading-text { margin-top: 0.5rem; }

/* ===== 푸터 ===== */
.main-footer {
  padding: 3.5rem 1.5rem;
  text-align: center;
  border-top: 1px solid var(--border-color);
  background: var(--container-bg);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}
.footer-content { max-width: 960px; margin: 0 auto; }
.footer-links { margin-bottom: 1.2rem; }
.footer-links a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin: 0 0.7rem;
  font-weight: 700;
  opacity: 0.75;
  transition: color 0.2s ease, opacity 0.2s ease;
}
.footer-links a:hover {
  opacity: 1;
  color: var(--accent-color);
}
.footer-content p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-bottom: 0.4rem;
}
.disclaimer {
  font-size: 0.78rem !important;
  opacity: 0.65;
  line-height: 1.6;
  max-width: 500px;
  margin: 0.5rem auto 0 !important;
}

/* ===== 애니메이션 ===== */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
  100% { transform: rotate(360deg); }
}

/* ===== 구글 번역 ===== */
#google_translate_element .goog-te-gadget-simple {
  border-radius: 8px;
  border: 1.5px solid var(--border-color) !important;
  background: var(--toggle-bg) !important;
  padding: 4px 8px !important;
  font-size: 0.8rem !important;
  transition: border-color 0.3s ease, background 0.3s ease;
}

/* ===== 모바일 반응형 ===== */
@media (max-width: 768px) {
  .header-content { padding: 0.75rem 1rem; }
  .logo { font-size: 1.2rem; }
  .main-nav ul { gap: 0.9rem; }
  .main-nav a { font-size: 0.82rem; }
  #theme-toggle { width: 36px; height: 36px; font-size: 1rem; }

  .container { margin: 1.5rem auto; }
  .content-section { padding: 2rem 1.3rem; border-radius: 20px; }
  h1 { font-size: 1.65rem; }

  .choice-container { flex-direction: column; gap: 1.2rem; }
  .choice-card { padding: 2.5rem 1.5rem; }

  .row-group { flex-direction: column; gap: 1rem; }

  .manse-table { flex-wrap: wrap; gap: 0.7rem; padding: 1rem; }
  .column { flex: 1 1 42%; }
  .pillar { height: 75px; font-size: 1.35rem; }

  .category-grid { grid-template-columns: repeat(2, 1fr); gap: 0.8rem; }
  .cat-btn { padding: 1.3rem 0.8rem; font-size: 0.9rem; }

  .tarot-spread { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
  .spread-item:last-child { grid-column: 1 / -1; max-width: 50%; margin: 0 auto; }
  .card-sm { height: 108px; font-size: 2.6rem; }

  .result-box { padding: 1.5rem 1.2rem; }
  .result-box p, .detail-text { font-size: 0.93rem; }
}

@media (max-width: 480px) {
  .main-nav { display: none; }
  .header-content { justify-content: space-between; }
  .logo { font-size: 1.15rem; }
}
