/* 導入字體 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@300;400;500;700&family=Outfit:wght@300;400;500;700&display=swap');

/* 全域變數與主題設定 */
:root {
  --primary: #C84B31;       /* 溫暖陶磚紅 */
  --primary-hover: #A03C27;
  --secondary: #2D4263;     /* 復古深藍木 */
  --accent: #5F8D4E;        /* 竹青綠/抹茶綠 */
  --accent-hover: #4A6E3D;
  
  --bg-primary: #FDFBF7;    /* 柔和奶白 */
  --bg-secondary: #F4F0EA;  /* 溫潤米黃 */
  --text-dark: #333333;     /* 深炭灰 */
  --text-muted: #666666;    /* 淺灰 */
  
  --border-color: #E2DDD5;  /* 框線色 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  
  --shadow-sm: 0 2px 8px rgba(45, 66, 99, 0.05);
  --shadow-md: 0 8px 24px rgba(45, 66, 99, 0.08);
  --shadow-lg: 0 16px 40px rgba(45, 66, 99, 0.15);
  
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --font-family: 'Outfit', 'Noto Sans TC', sans-serif;
}

/* 基礎樣式重設 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-dark);
  line-height: 1.6;
  overflow-x: hidden;
}

/* 捲軸美化 */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* 標題樣式 */
h1, h2, h3, h4 {
  font-weight: 700;
  color: var(--secondary);
}

/* --- Hero 區段 --- */
.hero-section {
  position: relative;
  height: 50vh;
  min-height: 380px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: #fff;
  padding: 2rem;
  background: linear-gradient(135deg, rgba(45, 66, 99, 0.9) 0%, rgba(200, 75, 49, 0.8) 100%), 
              url('assets/images/hero_bg.jpg') center/cover no-repeat;
  overflow: hidden;
}

.hero-title {
  font-size: clamp(2.5rem, 5vw, 4rem);
  margin-bottom: 0.5rem;
  color: #FFFFFF;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  letter-spacing: 2px;
}

.hero-subtitle {
  font-size: clamp(1rem, 2vw, 1.3rem);
  font-weight: 300;
  color: var(--bg-secondary);
  margin-bottom: 2rem;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
}

/* 搜尋框 */
.search-container {
  position: relative;
  width: 100%;
  max-width: 550px;
  margin: 0 auto;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input {
  width: 100%;
  padding: 1.1rem 1.5rem 1.1rem 3.5rem;
  border: none;
  border-radius: var(--radius-lg);
  background-color: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-family);
  font-size: 1rem;
  color: var(--text-dark);
  transition: var(--transition);
}

.search-input:focus {
  outline: none;
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(200, 75, 49, 0.4);
  transform: translateY(-2px);
}

.search-icon {
  position: absolute;
  left: 1.2rem;
  width: 20px;
  height: 20px;
  fill: var(--text-muted);
  pointer-events: none;
}

/* --- 主體容器 (Split Layout) --- */
.main-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  display: grid;
  grid-template-columns: 1.1fr 1.9fr;
  gap: 2.5rem;
}

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

/* --- 側邊欄 (Map & Filters) --- */
.sidebar-panel {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  position: sticky;
  top: 2rem;
  height: fit-content;
}

/* 篩選控制器 */
.filter-box {
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.filter-group-title {
  font-size: 0.95rem;
  color: var(--secondary);
  margin-bottom: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-group-title svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.2rem;
}

.filter-options:last-child {
  margin-bottom: 0;
}

.filter-btn {
  background-color: var(--bg-secondary);
  border: 1px solid transparent;
  color: var(--text-dark);
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-family);
  transition: var(--transition);
}

.filter-btn:hover {
  background-color: var(--border-color);
}

.filter-btn.active {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

/* --- 地圖區域 --- */
.map-box {
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.map-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
  padding: 0 0.5rem;
}

.map-title {
  font-size: 1rem;
  font-weight: 700;
}

.map-legend {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* 互動地圖容器 */
.map-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

/* SVG 地圖背景樣式 */
.map-svg-bg {
  width: 100%;
  height: 100%;
  display: block;
}

.road-line {
  fill: none;
  stroke: #ffffff;
  stroke-width: 16;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.road-line-inner {
  fill: none;
  stroke: var(--border-color);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.landmark-area {
  fill: #EAE3D2;
  stroke: var(--border-color);
  stroke-width: 2;
  opacity: 0.7;
}

.landmark-label {
  font-family: var(--font-family);
  font-size: 12px;
  font-weight: 700;
  fill: var(--secondary);
  text-anchor: middle;
}

/* 地圖 Pins 定位 */
.map-pins-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* 穿透至 Pins */
}

.map-pin {
  position: absolute;
  width: 24px;
  height: 24px;
  transform: translate(-50%, -50%);
  cursor: pointer;
  pointer-events: auto; /* 恢復指針事件 */
  z-index: 10;
  transition: var(--transition);
}

.pin-marker {
  width: 16px;
  height: 16px;
  background-color: var(--primary);
  border: 3px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  transition: var(--transition);
}

/* 呼吸效果 */
.pin-marker::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid var(--primary);
  opacity: 0;
  animation: pinPulse 2s infinite;
  pointer-events: none;
}

@keyframes pinPulse {
  0% {
    width: 100%;
    height: 100%;
    opacity: 0.8;
  }
  100% {
    width: 300%;
    height: 300%;
    opacity: 0;
  }
}

/* 地圖 Pin 懸停與選中效果 */
.map-pin:hover .pin-marker,
.map-pin.pin-highlight .pin-marker {
  transform: scale(1.3);
  background-color: var(--secondary);
  border-color: #ffffff;
}

.map-pin:hover {
  z-index: 20;
}

/* 篩選未選中 Pin 樣式 */
.map-pin.pin-inactive {
  opacity: 0.25;
  pointer-events: none;
}

/* Pin Tooltip */
.pin-tooltip {
  position: absolute;
  bottom: 140%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background-color: var(--secondary);
  color: #ffffff;
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: var(--transition);
}

.pin-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--secondary);
}

.map-pin:hover .pin-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.tooltip-title {
  font-weight: 700;
  color: #fff;
}

.tooltip-subtitle {
  font-size: 0.7rem;
  color: var(--border-color);
  margin-top: 2px;
}

/* --- 美食列表區 (Food Grid) --- */
.food-grid-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.food-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.8rem;
}

.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
}

/* 卡片樣式 */
.food-card {
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

.food-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(200, 75, 49, 0.3);
}

.card-focus {
  animation: cardPulseBorder 2s ease;
}

@keyframes cardPulseBorder {
  0%, 100% {
    border-color: var(--border-color);
    box-shadow: var(--shadow-sm);
  }
  50% {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(200, 75, 49, 0.2);
  }
}

.card-image-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background-color: var(--bg-secondary);
  overflow: hidden;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition);
}

.food-card:hover .card-image {
  transform: scale(1.05);
}

/* 卡片標籤 */
.card-category {
  position: absolute;
  top: 0.8rem;
  left: 0.8rem;
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tag-meal { background-color: var(--primary); }
.tag-snack { background-color: var(--secondary); }
.tag-cafe { background-color: var(--accent); }

.card-area-tag {
  position: absolute;
  bottom: 0.8rem;
  left: 0.8rem;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 500;
  background-color: rgba(0, 0, 0, 0.6);
  color: #ffffff;
  backdrop-filter: blur(4px);
}

/* 卡片內容 */
.card-content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.card-history {
  font-size: 0.75rem;
  background-color: var(--bg-secondary);
  color: var(--secondary);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
  white-space: nowrap;
}

.card-signature {
  font-size: 0.9rem;
  color: var(--text-dark);
  margin-bottom: 0.8rem;
  line-height: 1.4;
}

.card-description {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 1.2rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-grow: 1;
}

/* Meta 資訊 */
.card-meta {
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
  margin-bottom: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.meta-item {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.meta-icon {
  width: 14px;
  height: 14px;
  fill: var(--text-muted);
}

/* 行動按鈕 */
.card-actions {
  display: flex;
  gap: 0.8rem;
}

.map-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--secondary);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  background-color: #ffffff;
  transition: var(--transition);
}

.map-link:hover {
  background-color: var(--bg-secondary);
  border-color: var(--secondary);
}

.trail-btn {
  flex-grow: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  background-color: #ffffff;
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-family);
  transition: var(--transition);
}

.trail-btn:hover {
  background-color: rgba(200, 75, 49, 0.05);
}

.trail-btn.added {
  background-color: var(--primary);
  color: #ffffff;
}

.trail-btn.added:hover {
  background-color: var(--primary-hover);
}

/* --- 踩點計畫器側邊欄 --- */
.trail-planner-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  max-width: 100%;
  height: 100vh;
  background-color: #ffffff;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.trail-planner-panel.open {
  transform: translateX(0);
}

.panel-header {
  padding: 1.5rem;
  background-color: var(--secondary);
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.panel-title {
  color: #ffffff;
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.panel-title svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.close-btn {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 1.8rem;
  cursor: pointer;
  opacity: 0.8;
  transition: var(--transition);
}

.close-btn:hover {
  opacity: 1;
}

/* 內容滾動區 */
.panel-body {
  flex-grow: 1;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* 空白狀態 */
.trail-empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.trail-empty-state svg {
  width: 64px;
  height: 64px;
  fill: var(--border-color);
}

.trail-empty-desc {
  font-size: 0.9rem;
}

/* 列表品項 */
.trail-items-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.trail-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.trail-item.visited {
  opacity: 0.6;
  background-color: #E2DDD5;
}

.trail-item.visited .trail-item-name {
  text-decoration: line-through;
}

.trail-item-idx {
  width: 24px;
  height: 24px;
  background-color: var(--secondary);
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.trail-item.visited .trail-item-idx {
  background-color: var(--text-muted);
}

.trail-item-info {
  flex-grow: 1;
}

.trail-item-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--secondary);
}

.trail-item-area {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.trail-item-actions {
  display: flex;
  gap: 0.4rem;
}

.action-visited-btn {
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-family);
  font-weight: 500;
  transition: var(--transition);
}

.action-visited-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.trail-item.visited .action-visited-btn {
  background-color: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.action-remove-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0 0.4rem;
  line-height: 1;
}

.action-remove-btn:hover {
  transform: scale(1.2);
}

/* 規劃詳細與底欄 */
.trail-details-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.trail-stats {
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  padding-top: 0.8rem;
}

.panel-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  background-color: var(--bg-secondary);
}

.copy-trail-btn {
  background-color: var(--accent);
  color: #ffffff;
  border: none;
  padding: 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-family);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
}

.copy-trail-btn:hover {
  background-color: var(--accent-hover);
  transform: translateY(-2px);
}

.clear-trail-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  font-family: var(--font-family);
  transition: var(--transition);
}

.clear-trail-btn:hover {
  background-color: rgba(200, 75, 49, 0.05);
  color: var(--primary);
  border-color: var(--primary);
}

/* 浮動觸發按鈕 */
.floating-trail-trigger {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 64px;
  height: 64px;
  background-color: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 50%;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  transition: var(--transition);
}

.floating-trail-trigger:hover {
  transform: scale(1.1) translateY(-4px);
  background-color: var(--primary-hover);
}

.floating-icon {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

.trail-count-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background-color: var(--secondary);
  color: #ffffff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: var(--shadow-sm);
}

/* --- 文化簡介區與頁尾 --- */
.culture-section {
  background-color: var(--bg-secondary);
  padding: 4rem 1.5rem;
  border-top: 1px solid var(--border-color);
}

.culture-content {
  max-width: 1000px;
  margin: 0 auto;
  text-align: center;
}

.section-title {
  font-size: 1.8rem;
  margin-bottom: 2rem;
  position: relative;
  display: inline-block;
  padding-bottom: 0.5rem;
}

.section-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background-color: var(--primary);
}

.culture-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin-top: 1rem;
}

.culture-card {
  background-color: #ffffff;
  padding: 2rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  text-align: left;
}

.culture-card-title {
  font-size: 1.1rem;
  margin-bottom: 0.8rem;
  color: var(--primary);
}

.culture-card-text {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.footer {
  background-color: var(--secondary);
  color: rgba(255,255,255,0.7);
  text-align: center;
  padding: 2rem 1.5rem;
  font-size: 0.85rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.footer a {
  color: #ffffff;
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* --- 手機板佈局微調 --- */
@media (max-width: 600px) {
  body {
    font-size: 15px;
  }
  
  .hero-section {
    min-height: 300px;
  }

  .main-container {
    padding: 1.5rem 1rem;
    gap: 1.5rem;
  }

  .sidebar-panel {
    position: relative;
    top: 0;
    gap: 1.5rem;
  }

  .filter-box {
    padding: 1rem;
  }

  .floating-trail-trigger {
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
  }
}
