@import url('https://fonts.googleapis.com/css2?family=Gowun+Batang:wght@400;700&family=Noto+Sans+KR:wght@300;400;500;700;900&display=swap');

/* 전통주 테마 CSS 변수 */
:root {
  --bg-color: #0f0d0b; /* 옻칠 느낌의 깊은 다크 브라운 */
  --bg-card: rgba(30, 26, 22, 0.7); /* 한지 느낌을 주는 반투명 카드 배경 */
  --border-color: rgba(212, 175, 55, 0.15); /* 은은한 황동색 테두리 */
  --primary-color: #d4af37; /* 황동색 (금색) */
  --primary-glow: rgba(212, 175, 55, 0.4);
  --accent-jade: #3e8e8e; /* 옥색 (청백) */
  --accent-dancheong: #b93232; /* 단청 홍색 */
  --text-primary: #f2ede4; /* 한지색 백색 */
  --text-secondary: #c2b6a2; /* 바래진 양반 종이색 */
  --shadow-color: rgba(0, 0, 0, 0.5);
  
  --font-main: 'Noto Sans KR', sans-serif;
  --font-accent: 'Gowun Batang', serif;
  
  --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* 기본 리셋 및 전역 스타일 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(185, 50, 50, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(62, 142, 142, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(212, 175, 55, 0.03) 0%, transparent 50%);
  color: var(--text-primary);
  font-family: var(--font-main);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* 스크롤바 디자인 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-color);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color);
}

/* 컨테이너 및 헤더 */
.app-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0 30px 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 30px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 15px;
}

.logo-symbol {
  width: 45px;
  height: 45px;
  border: 2px solid var(--primary-color);
  transform: rotate(45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px var(--primary-glow);
}

.logo-symbol span {
  transform: rotate(-45deg);
  font-family: var(--font-accent);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary-color);
}

.logo-title h1 {
  font-family: var(--font-accent);
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 2px;
  background: linear-gradient(135deg, var(--text-primary) 30%, var(--primary-color) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-title p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  letter-spacing: 1px;
}

.nav-buttons {
  display: flex;
  gap: 15px;
}

.btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: 4px;
  font-family: var(--font-main);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  box-shadow: 0 0 12px var(--primary-glow);
  transform: translateY(-2px);
}

.btn-primary {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.2) 0%, rgba(212, 175, 55, 0.05) 100%);
  border-color: var(--primary-color);
  color: var(--primary-color);
  font-weight: 700;
}

.btn-primary:hover {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.3) 0%, rgba(212, 175, 55, 0.1) 100%);
  box-shadow: 0 0 18px var(--primary-glow);
}

/* 대시보드 그리드 레이아웃 */
.main-layout {
  display: grid;
  grid-template-columns: 1.8fr 1.2fr;
  gap: 30px;
  flex: 1;
}

@media (max-width: 1100px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

/* 패널 공통 스타일 */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 25px;
  box-shadow: 0 10px 30px var(--shadow-color);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

/* 전통 무양 모서리 데코레이션 */
.panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 15px;
  height: 15px;
  border-top: 2px solid var(--primary-color);
  border-left: 2px solid var(--primary-color);
  opacity: 0.6;
}

.panel::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 15px;
  height: 15px;
  border-bottom: 2px solid var(--primary-color);
  border-right: 2px solid var(--primary-color);
  opacity: 0.6;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px dashed rgba(212,175,55,0.2);
}

.panel-title {
  font-family: var(--font-accent);
  font-size: 1.4rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-title::before {
  content: '◆';
  color: var(--primary-color);
  font-size: 0.8rem;
}

/* 계보도 시각화 영역 */
.genealogy-panel {
  display: flex;
  flex-direction: column;
  min-height: 600px;
}

.tree-container {
  flex: 1;
  width: 100%;
  background: rgba(10, 8, 7, 0.8);
  border: 1px solid rgba(212, 175, 55, 0.08);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}

#tree-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* D3 트리 노드/링크 스타일 */
.link {
  fill: none;
  stroke: rgba(62, 142, 142, 0.4);
  stroke-width: 2px;
  transition: stroke 0.3s, stroke-width 0.3s;
}

.link.highlighted {
  stroke: var(--primary-color);
  stroke-width: 4px;
  filter: drop-shadow(0 0 5px var(--primary-glow));
}

.node {
  cursor: pointer;
}

.node circle {
  fill: var(--bg-color);
  stroke-width: 2.5px;
  transition: transform 0.3s, r 0.3s, fill 0.3s, stroke 0.3s;
}

/* 노드 타입별 고유 색상 */
.node.root circle {
  stroke: var(--primary-color);
  fill: rgba(212,175,55,0.2);
}

.node.process circle {
  stroke: var(--accent-jade);
  fill: rgba(62,142,142,0.1);
}

.node.category circle {
  stroke: var(--accent-dancheong);
}

.node.drink circle {
  stroke: #888;
  fill: #1e1e1e;
}

.node:hover circle {
  r: 10;
  stroke: var(--primary-color) !important;
  fill: var(--primary-color) !important;
  filter: drop-shadow(0 0 8px var(--primary-glow));
}

.node text {
  font-family: var(--font-main);
  font-size: 11px;
  fill: var(--text-secondary);
  pointer-events: none;
  transition: var(--transition-smooth);
}

.node:hover text {
  fill: var(--text-primary);
  font-weight: 700;
  font-size: 13px;
}

.node.active circle {
  r: 10;
  stroke: var(--primary-color) !important;
  fill: var(--primary-color) !important;
  filter: drop-shadow(0 0 12px var(--primary-glow));
}

.node.active text {
  fill: var(--primary-color);
  font-weight: 700;
  font-size: 13px;
}

/* 계보도 조작 가이드 */
.tree-controls {
  position: absolute;
  bottom: 15px;
  left: 15px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

.control-btn {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  font-weight: bold;
}

.control-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: rgba(212, 175, 55, 0.1);
}

.tree-legend {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(15, 13, 11, 0.9);
  padding: 10px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
  pointer-events: none;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid;
}

.legend-color.root { border-color: var(--primary-color); background: rgba(212,175,55,0.2); }
.legend-color.process { border-color: var(--accent-jade); background: rgba(62,142,142,0.1); }
.legend-color.category { border-color: var(--accent-dancheong); }
.legend-color.drink { border-color: #888; background: #1e1e1e; }

/* 탐색 패널 */
.explore-panel {
  display: flex;
  flex-direction: column;
  max-height: 800px;
}

.search-filter-area {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-box-wrapper {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  background: rgba(20, 18, 15, 0.8);
  border: 1px solid var(--border-color);
  padding: 12px 40px 12px 15px;
  color: var(--text-primary);
  border-radius: 4px;
  font-family: var(--font-main);
  font-size: 0.95rem;
  transition: var(--transition-smooth);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 10px var(--primary-glow);
}

.search-box-wrapper::after {
  content: '🔍';
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.95rem;
  color: var(--text-secondary);
  pointer-events: none;
}

.filter-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-chip {
  background: rgba(25, 22, 19, 0.6);
  border: 1px solid rgba(212, 175, 55, 0.1);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.filter-chip:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.filter-chip.active {
  background: var(--primary-color);
  color: #0f0d0b;
  border-color: var(--primary-color);
  font-weight: 700;
  box-shadow: 0 0 8px var(--primary-glow);
}

/* 전통주 카드 목록 */
.drink-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 15px;
  overflow-y: auto;
  flex: 1;
  padding-right: 5px;
}

.drink-card {
  background: rgba(20, 18, 16, 0.5);
  border: 1px solid rgba(212, 175, 55, 0.1);
  border-radius: 6px;
  padding: 18px;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
}

.drink-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary-color);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), 0 0 10px rgba(212, 175, 55, 0.1);
  background: rgba(30, 26, 22, 0.8);
}

.drink-card.active-highlight {
  border-color: var(--accent-jade);
  box-shadow: 0 0 15px rgba(62, 142, 142, 0.3);
  background: rgba(30, 36, 36, 0.6);
}

.card-category {
  font-size: 0.75rem;
  color: var(--accent-jade);
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 6px;
  display: inline-block;
  padding: 2px 6px;
  background: rgba(62, 142, 142, 0.1);
  border-radius: 3px;
  align-self: flex-start;
}

.card-title {
  font-family: var(--font-accent);
  font-size: 1.15rem;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.card-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 12px;
  height: 2.6em;
}

.card-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  border-top: 1px dashed rgba(212, 175, 55, 0.1);
  padding-top: 10px;
  color: var(--text-secondary);
}

.card-region {
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-abv {
  color: var(--primary-color);
  font-weight: 700;
}

/* 모달 윈도우 스타일 (상세 정보 및 취향 테스트) */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 1000;
}

.modal.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #161311;
  border: 2px solid var(--primary-color);
  border-radius: 10px;
  width: 90%;
  max-width: 650px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 35px;
  box-shadow: 0 15px 40px rgba(0,0,0,0.8), 0 0 20px var(--primary-glow);
  position: relative;
  transform: translateY(-20px);
  transition: transform 0.3s ease;
}

.modal.open .modal-content {
  transform: translateY(0);
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.modal-close:hover {
  color: var(--accent-dancheong);
}

/* 상세 정보 모달 세부 요소 */
.drink-detail-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 15px;
  margin-bottom: 20px;
}

.drink-detail-header .category {
  color: var(--accent-jade);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 1px;
}

.drink-detail-header h2 {
  font-family: var(--font-accent);
  font-size: 2rem;
  color: var(--text-primary);
  margin-top: 5px;
}

.drink-detail-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  background: rgba(25, 22, 19, 0.8);
  padding: 15px;
  border-radius: 6px;
  border: 1px solid rgba(212,175,55,0.08);
  margin-bottom: 20px;
  text-align: center;
}

.meta-item {
  display: flex;
  flex-direction: column;
}

.meta-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.meta-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.meta-value.abv {
  color: var(--primary-color);
}

.detail-section {
  margin-bottom: 20px;
}

.detail-title {
  font-family: var(--font-accent);
  font-size: 1.1rem;
  color: var(--primary-color);
  margin-bottom: 8px;
  border-left: 3px solid var(--primary-color);
  padding-left: 8px;
}

.detail-body {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* 오각형/슬라이더 스타일의 맛 프로필 차트 */
.taste-profile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.taste-bar-container {
  display: flex;
  align-items: center;
  gap: 15px;
}

.taste-label {
  width: 60px;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.taste-track {
  flex: 1;
  height: 8px;
  background: rgba(25, 22, 19, 0.8);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.taste-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-jade) 0%, var(--primary-color) 100%);
  border-radius: 4px;
  width: 0;
  transition: width 0.8s ease-in-out;
}

.taste-value {
  width: 25px;
  font-size: 0.85rem;
  color: var(--primary-color);
  font-weight: 700;
  text-align: right;
}

/* 취향 추천 모달 */
.survey-intro {
  text-align: center;
  margin-bottom: 25px;
}

.survey-intro h2 {
  font-family: var(--font-accent);
  font-size: 1.7rem;
  margin-bottom: 10px;
  color: var(--primary-color);
}

.survey-step {
  display: none;
}

.survey-step.active {
  display: block;
  animation: fadeIn 0.4s ease;
}

.survey-question {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-primary);
  text-align: center;
}

.survey-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 25px;
}

.survey-option-btn {
  background: rgba(25, 22, 19, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-smooth);
  text-align: left;
  font-size: 0.95rem;
}

.survey-option-btn:hover {
  background: rgba(212, 175, 55, 0.08);
  border-color: var(--primary-color);
  padding-left: 20px;
}

.survey-option-btn.selected {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.25) 0%, rgba(212, 175, 55, 0.05) 100%);
  border-color: var(--primary-color);
  color: var(--primary-color);
  font-weight: 700;
  box-shadow: 0 0 10px rgba(212,175,55,0.1);
}

.survey-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
}

/* 취향 테스트 결과 화면 */
.recommend-results {
  text-align: center;
}

.recommend-results h3 {
  font-family: var(--font-accent);
  font-size: 1.4rem;
  color: var(--primary-color);
  margin-bottom: 15px;
}

.recommend-cards-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin: 20px 0;
}

.recommend-item {
  background: rgba(20, 18, 16, 0.8);
  border: 1px solid var(--primary-color);
  border-radius: 6px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  transition: var(--transition-smooth);
  cursor: pointer;
}

.recommend-item:hover {
  box-shadow: 0 0 15px var(--primary-glow);
  transform: translateY(-2px);
}

.recommend-item-header {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 10px;
}

.recommend-title {
  font-family: var(--font-accent);
  font-size: 1.25rem;
  color: var(--primary-color);
  font-weight: 700;
}

.recommend-match-pct {
  color: var(--accent-jade);
  font-weight: 700;
  font-size: 0.9rem;
}

.recommend-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* 애니메이션 효과 */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

footer {
  text-align: center;
  padding: 30px 0;
  color: var(--text-secondary);
  font-size: 0.8rem;
  border-top: 1px solid rgba(212, 175, 55, 0.08);
  margin-top: 40px;
  letter-spacing: 1px;
}
