/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cream: #f5f0e8;
  --cream-dark: #ede6d8;
  --brown-dark: #2c1a0e;
  --brown-mid: #5c3d2e;
  --brown-light: #8b6650;
  --brown-muted: #b89b8a;
  --accent: #c8813a;
  --accent-light: #e8a864;
  --text-main: #2c1a0e;
  --text-sub: #6b5040;
  --text-muted: #9e8070;
  --border: #d8cfc3;
  --white: #ffffff;
  --radius: 12px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(44,26,14,0.08);
  --shadow-hover: 0 6px 24px rgba(44,26,14,0.14);
  --font: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 0.2s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--cream);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; background: none; font-family: var(--font); }
ul { list-style: none; }

/* ===== Typography ===== */
h1 { font-size: clamp(1.8rem, 5vw, 3rem); font-weight: 700; line-height: 1.2; }
h2 { font-size: clamp(1.3rem, 3vw, 1.8rem); font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 600; }

/* ===== Layout ===== */
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.section { padding: 48px 24px; }

/* ===== Nav ===== */
.nav {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}
.nav-logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--brown-dark);
  letter-spacing: 0.02em;
}
.nav-logo span { color: var(--accent); }
.nav-links { display: flex; gap: 24px; align-items: center; }
.nav-links a {
  font-size: 0.9rem;
  color: var(--text-sub);
  font-weight: 500;
  transition: color var(--transition);
}
.nav-links a:hover, .nav-links a.active { color: var(--accent); }

/* ===== Hero ===== */
.hero {
  padding: 56px 24px 40px;
  text-align: center;
}
.hero-title { color: var(--brown-dark); margin-bottom: 12px; }
.hero-sub { color: var(--text-sub); font-size: 1rem; margin-bottom: 36px; }

/* ===== Search ===== */
.search-wrap { position: relative; max-width: 560px; margin: 0 auto 32px; }
.search-input {
  width: 100%;
  padding: 14px 48px 14px 20px;
  border: 2px solid var(--border);
  border-radius: 999px;
  font-size: 1rem;
  font-family: var(--font);
  background: var(--white);
  color: var(--text-main);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(200,129,58,0.15); }
.search-input::placeholder { color: var(--text-muted); }
.search-icon {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
  pointer-events: none;
}

/* ===== City Filters ===== */
.city-filters { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 20px; }
.city-btn {
  padding: 8px 20px;
  border: 2px solid var(--border);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-sub);
  background: var(--white);
  transition: all var(--transition);
}
.city-btn:hover { border-color: var(--brown-light); color: var(--brown-mid); }
.city-btn.active {
  background: var(--brown-dark);
  border-color: var(--brown-dark);
  color: var(--white);
}

/* ===== Tag Filters ===== */
.tag-filters { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 12px; }
.tag-btn {
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--white);
  transition: all var(--transition);
}
.tag-btn:hover { border-color: var(--accent-light); color: var(--accent); }
.tag-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white);
}

/* ===== Mobile Filters ===== */
.mobile-filters { display: none; gap: 10px; margin-top: 16px; }
.filter-select {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text-main);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 500;
  appearance: none;
  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='%235c3d2e' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
  transition: border-color var(--transition);
}
.filter-select:focus { outline: none; border-color: var(--accent); }

/* ===== Mood Picker ===== */
.mood-section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin: 0 auto 48px;
  max-width: 700px;
  box-shadow: var(--shadow);
}
.mood-section h2 { text-align: center; margin-bottom: 24px; color: var(--brown-dark); font-size: 1.1rem; }
.mood-grid { display: flex; flex-direction: column; gap: 16px; margin-bottom: 20px; }
.mood-label { font-size: 0.85rem; font-weight: 600; color: var(--text-sub); margin-bottom: 8px; letter-spacing: 0.04em; }
.mood-options { display: flex; flex-wrap: wrap; gap: 8px; }
.mood-opt {
  padding: 8px 16px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  font-size: 0.88rem;
  color: var(--text-sub);
  background: var(--cream);
  transition: all var(--transition);
}
.mood-opt:hover { border-color: var(--accent); color: var(--accent); }
.mood-opt.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white);
  font-weight: 600;
}
.mood-btn {
  display: block;
  width: 100%;
  padding: 12px;
  background: var(--brown-dark);
  color: var(--white);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  transition: background var(--transition);
}
.mood-btn:hover { background: var(--brown-mid); }

/* ===== Mood Results ===== */
.mood-results {
  display: none;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.mood-results.show { display: block; }
.mood-results-label { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 12px; text-align: center; }
.mood-cards { display: flex; flex-direction: column; gap: 10px; }
.mood-card-mini {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.mood-card-mini:hover { border-color: var(--accent); background: #fff8f2; }
.mood-card-mini img { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.mood-card-mini-info h4 { font-size: 0.9rem; font-weight: 600; }
.mood-card-mini-info p { font-size: 0.78rem; color: var(--text-muted); }

/* ===== Cards Grid ===== */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.section-header h2 { color: var(--brown-dark); }
.see-all { font-size: 0.85rem; color: var(--accent); font-weight: 500; }
.see-all:hover { text-decoration: underline; }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.cafe-card {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
  cursor: pointer;
  border: 1px solid var(--border);
}
.cafe-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }

.card-img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: var(--cream-dark);
  border-radius: var(--radius) var(--radius) 0 0;
}
.card-img-placeholder {
  width: 100%;
  height: 180px;
  background: linear-gradient(135deg, var(--cream-dark), var(--brown-muted));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 2rem;
}

.card-body { padding: 16px; }
.card-location {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.card-name { font-size: 1rem; font-weight: 700; color: var(--brown-dark); margin-bottom: 8px; }
.card-review { font-size: 0.82rem; color: var(--text-sub); line-height: 1.5; margin-bottom: 12px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag-chip {
  font-size: 0.72rem;
  padding: 3px 8px;
  background: var(--cream-dark);
  color: var(--brown-mid);
  border-radius: 999px;
  font-weight: 500;
}

/* ===== No results ===== */
.no-results {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  display: none;
}
.no-results.show { display: block; }
.no-results-icon { font-size: 2.5rem; margin-bottom: 12px; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--cream-dark);
  color: var(--brown-mid);
}
.badge-city { background: var(--brown-dark); color: var(--white); }

/* ===== Back Button ===== */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  margin-bottom: 16px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-sub);
  cursor: pointer;
  transition: all var(--transition);
}
.back-btn:hover { border-color: var(--accent); color: var(--accent); background: #fff8f2; }

/* ===== Detail Page ===== */
.detail-hero { padding: 48px 24px 0; }
.detail-breadcrumb { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 16px; }
.detail-breadcrumb a:hover { color: var(--accent); }
.detail-header { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; margin-bottom: 24px; }
.detail-title { font-size: clamp(1.5rem, 4vw, 2.2rem); font-weight: 700; color: var(--brown-dark); }
.detail-badges { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }

/* ===== Photo Slider ===== */
.photo-slider {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  margin-bottom: 32px;
  background: #1a1008;
}
.photo-track { display: flex; transition: transform 0.35s ease; }

.photo-slide {
  min-width: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 420px;
  overflow: hidden;
}

/* 模糊背景層：同一張圖放大模糊填滿 */
.photo-blur-bg {
  position: absolute;
  inset: -20px;
  background-size: cover;
  background-position: center;
  filter: blur(18px) brightness(0.6) saturate(1.2);
  transform: scale(1.05);
  z-index: 0;
}

/* 前景照片：保持原比例置中 */
.photo-slide img {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: 420px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
.slider-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(44,26,14,0.6);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: background var(--transition);
  z-index: 2;
}
.slider-btn:hover { background: var(--brown-dark); }
.slider-btn.prev { left: 12px; }
.slider-btn.next { right: 12px; }
.slider-dots { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; }
.slider-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.5); transition: background var(--transition); }
.slider-dot.active { background: white; }

/* ===== Detail Layout ===== */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 32px;
  align-items: start;
}

.review-section { margin-bottom: 32px; }
.review-section h3 { color: var(--brown-dark); margin-bottom: 12px; font-size: 1rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.review-text { color: var(--text-sub); line-height: 1.8; font-size: 0.95rem; }

/* ===== Score Bars ===== */
.scores-section { margin-bottom: 32px; }
.score-item { margin-bottom: 14px; }
.score-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.score-name { font-size: 0.85rem; color: var(--text-sub); font-weight: 500; }
.score-num { font-size: 0.85rem; font-weight: 700; color: var(--brown-mid); }
.score-bar { height: 6px; background: var(--cream-dark); border-radius: 999px; overflow: hidden; }
.score-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-light)); border-radius: 999px; transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1); }

/* ===== Info Card ===== */
.info-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.info-row {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.info-row:last-child { border-bottom: none; }
.info-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; color: var(--accent); }
.info-label { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 2px; }
.info-value { font-size: 0.9rem; color: var(--text-main); font-weight: 500; }
.info-value a { color: var(--accent); }
.info-value a:hover { text-decoration: underline; }

.features-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.feature-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
}
.feature-chip.has { background: #e8f5e9; color: #2e7d32; }
.feature-chip.no { background: var(--cream-dark); color: var(--text-muted); }

.ig-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  margin-top: 16px;
  background: linear-gradient(135deg, #833ab4, #fd1d1d, #fcb045);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  transition: opacity var(--transition);
}
.ig-btn:hover { opacity: 0.9; }

/* ===== Map Page ===== */
.map-toggle { display: none; } /* 桌面隱藏 */

.map-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: calc(100vh - 60px);
}
.map-sidebar {
  overflow-y: auto;
  background: var(--white);
  border-right: 1px solid var(--border);
  padding: 16px;
}
.map-sidebar h2 { font-size: 1rem; margin-bottom: 12px; color: var(--brown-dark); }
.sidebar-search { width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 0.9rem; font-family: var(--font);
  background: var(--cream); outline: none; margin-bottom: 12px; }
.sidebar-search:focus { border-color: var(--accent); }
.sidebar-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.sidebar-tag {
  padding: 4px 10px; border: 1.5px solid var(--border); border-radius: 999px;
  font-size: 0.75rem; font-weight: 500; color: var(--text-muted); background: var(--cream); cursor: pointer;
  transition: all var(--transition);
}
.sidebar-tag.active { background: var(--accent); border-color: var(--accent); color: white; }

.sidebar-list { display: flex; flex-direction: column; gap: 8px; }
.sidebar-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  background: var(--cream);
}
.sidebar-item:hover, .sidebar-item.active { border-color: var(--accent); background: #fff8f2; }
.sidebar-item h4 { font-size: 0.88rem; font-weight: 600; margin-bottom: 3px; }
.sidebar-item p { font-size: 0.75rem; color: var(--text-muted); }

#map { height: 100%; }

/* ===== Footer ===== */
.footer {
  background: var(--brown-dark);
  color: var(--brown-muted);
  text-align: center;
  padding: 28px 20px;
  font-size: 0.85rem;
  margin-top: 48px;
}
.footer a { color: var(--accent-light); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  /* Layout */
  .detail-layout { grid-template-columns: 1fr; }
  .info-card { margin-top: 0; }

  /* Map — 手機版切換模式 */
  .map-toggle {
    display: flex;
    background: var(--white);
    border-bottom: 1px solid var(--border);
  }
  .map-toggle-btn {
    flex: 1;
    padding: 12px;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    font-family: var(--font);
  }
  .map-toggle-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
  }

  .map-layout {
    grid-template-columns: 1fr;
    height: calc(100vh - 108px); /* nav ~60px + toggle ~48px */
  }

  /* 地圖模式（預設）*/
  .map-layout .map-sidebar { display: none; }
  #map { display: block; height: 100%; order: 1; }

  /* 列表模式 */
  .map-layout.show-list .map-sidebar {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
    order: 1;
  }
  .map-layout.show-list #map { display: none; }

  /* Photos */
  .photo-slide { height: 300px; }
  .photo-slide img { max-height: 300px; }

  /* Nav */
  .nav-links { gap: 16px; }
  .nav-logo span { display: none; }

  /* Detail */
  .back-btn { font-size: 0.85rem; padding: 9px 14px; }
  .detail-title { font-size: 1.5rem; }

  /* Touch targets */
  .mood-opt { padding: 10px 18px; min-height: 44px; }
  .slider-btn { width: 44px; height: 44px; font-size: 1.4rem; }
  .sidebar-item { padding: 14px; }

  /* 手機版 filter 改下拉選單 */
  .city-filters { display: none; }
  .tag-filters  { display: none; }
  .mobile-filters {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 10px;
    margin-top: 16px;
  }
}

@media (max-width: 480px) {
  .container { padding: 0 20px; }
  .section { padding: 28px 20px; }

  /* Hero */
  .hero { padding: 40px 20px 24px; }
  .hero-title { font-size: 1.7rem; }
  .hero-sub { font-size: 0.9rem; margin-bottom: 20px; }

  /* Search — 不貼邊 */
  .search-wrap {
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 16px;
  }

  /* 下拉選單不貼邊 */
  .mobile-filters { margin-top: 12px; }
  .filter-select { font-size: 0.83rem; padding: 9px 28px 9px 10px; }

  /* Cards */
  .cards-grid { grid-template-columns: 1fr; gap: 16px; }
  .card-img { height: 200px; border-radius: var(--radius) var(--radius) 0 0; }
  .card-body { padding: 14px 16px; }

  /* Section header */
  .section-header { margin-bottom: 16px; }

  /* Mood */
  .mood-section { padding: 20px; margin-bottom: 28px; }

  /* Detail */
  .photo-slide { height: 260px; }
  .photo-slide img { max-height: 260px; }
  .info-card { padding: 16px; }

  /* Review / scores 留白 */
  .review-section { padding: 0; }
  .scores-section { padding: 0; }

  /* Footer */
  .footer { padding: 20px; font-size: 0.8rem; }
}

/* ===== Animations ===== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.4s ease both; }
