/* ==========================================================================
   Dashboard Overlay Styles (Phase 1 Visual Redesign)
   ========================================================================== */

/* 所有頁面統一使用 html 原生捲軸（全高），dashboard 隱藏自身捲軸 */

.homepage-dashboard {
  position: fixed;
  top: var(--header-height, 64px);
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #E2EAEF;
  background-image:
    linear-gradient(rgba(255,255,255,0.35), rgba(255,255,255,0.35)),
    url('../assets/illustrations/hero-taiwan-map.png?v=20260417c');
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
  background-attachment: fixed;
  z-index: calc(var(--z-header, 500) - 1);
  overflow-y: auto;
  overscroll-behavior: contain;
  transition: opacity 0.3s, visibility 0.3s;
  display: flex;
  flex-direction: column;
  /* 防止 sticky tabs 遮蔽 focus outline (WCAG 2.4.7) */
  scroll-padding-top: calc(56px + 8px);
  /* 隱藏 dashboard 自身捲軸，統一由 html 原生捲軸呈現 */
  scrollbar-width: none;           /* Firefox */
  -ms-overflow-style: none;        /* IE / legacy Edge */
}
.homepage-dashboard::-webkit-scrollbar {
  display: none;                   /* Chrome / Safari / Edge */
}

.homepage-dashboard.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Dashboard Footer (inside scrollable dashboard overlay) */
.dashboard-footer {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-lg) var(--space-md);
  background: var(--color-primary-dark, #0A7B77);
  color: #fff;
  font-size: var(--font-size-sm);
  margin-top: auto;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .dashboard-footer {
    flex-direction: row;
    justify-content: space-between;
    padding: var(--space-lg) 60px var(--space-lg) var(--space-xl, 2rem);
  }
}

.dashboard-footer a {
  color: rgba(255, 255, 255, 0.85);
}

.dashboard-footer a:hover,
.dashboard-footer a:focus {
  color: #fff;
  text-decoration: underline;
}

.dashboard-footer .footer-copyright {
  font-size: var(--font-size-xs, 0.75rem);
  opacity: 0.7;
}

@media (min-width: 768px) {
  .dashboard-footer .footer-copyright {
    position: absolute;
    bottom: var(--space-xs, 0.25rem);
    left: 50%;
    transform: translateX(-50%);
  }
}

/* ========================================================================
   Hero Section
   ======================================================================== */
.dashboard-hero {
  background: var(--color-primary-gradient);
  color: var(--color-text-inverse);
  padding: var(--space-lg) var(--space-lg) var(--space-md);
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: padding 0.3s ease;
  flex-shrink: 0;
}

/* ---- 台灣地圖浮水印底圖 ---- */
.dashboard-hero__watermark {
  position: absolute;
  top: 50%;
  right: 5%;
  width: 300px;
  height: 544px;
  transform: translateY(-50%);
  opacity: 0.07;
  pointer-events: none;
  z-index: 0;
}

/* ---- 方案 A: Hero 收合模式（切換非總覽 Tab 時啟用） ---- */
.dashboard-hero.is-compact {
  padding: var(--space-sm) var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  text-align: left;
}

.dashboard-hero.is-compact .dashboard-hero__title {
  font-size: var(--font-size-lg);
  margin-bottom: 0;
  animation: none;
}

/* sr-only: 視覺隱藏但螢幕報讀器仍可讀取 (WCAG 1.3.1) */
.dashboard-hero.is-compact .dashboard-hero__subtitle {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.dashboard-hero.is-compact .dashboard-hero__search {
  margin: 0;
  max-width: 20rem;
  animation: none;
}

.dashboard-hero.is-compact .dashboard-hero__stats { display: none; }
.dashboard-hero.is-compact .dashboard-hero__float-1,
.dashboard-hero.is-compact .dashboard-hero__float-2 { display: none; }
.dashboard-hero.is-compact::after { display: none; }
.dashboard-hero.is-compact .dashboard-hero__watermark { display: none; }

/* prefers-reduced-motion: 取消過渡動畫 (WCAG) */
@media (prefers-reduced-motion: reduce) {
  .dashboard-hero { transition: none; }
}

/* Decorative wave at the bottom */
.dashboard-hero::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 30px;
  background: var(--color-bg);
  clip-path: ellipse(55% 100% at 50% 100%);
}

.dashboard-hero__title,
.dashboard-hero__subtitle,
.dashboard-hero__search,
.dashboard-hero__stats {
  position: relative;
  z-index: 1;
}

.dashboard-hero__title {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  margin-bottom: var(--space-xs);
  letter-spacing: -0.01em;
  animation: fadeInUp 0.6s ease-out;
}

.dashboard-hero__subtitle {
  font-size: var(--font-size-sm);
  opacity: 0.9;
  margin-bottom: var(--space-md);
  font-weight: 400;
  animation: fadeInUp 0.6s ease-out 0.1s both;
}

/* Hero search bar */
.dashboard-hero__search {
  display: flex;
  gap: var(--space-sm);
  max-width: 35rem;
  margin: 0 auto var(--space-md);
  animation: fadeInUp 0.6s ease-out 0.2s both;
}

.dashboard-hero__search .form-input {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-base);
  border: none;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  background: var(--color-bg-white);
  color: var(--color-text);
}

.dashboard-hero__search .form-input:focus {
  outline: var(--focus-outline-width) solid var(--focus-outline-color);
  box-shadow: var(--shadow-xl);
  background: #FFF8DC;
}

.dashboard-hero__search .btn {
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--font-size-base);
  border-radius: var(--border-radius-lg);
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-text);
  box-shadow: 0 2px 8px rgba(245, 166, 35, 0.4);
}

.dashboard-hero__search .btn:hover {
  background: #E09520;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(245, 166, 35, 0.5);
}

/* Hero quick stats strip */
.dashboard-hero__stats {
  display: flex;
  justify-content: center;
  gap: var(--space-xl);
  font-size: var(--font-size-sm);
  opacity: 0.9;
  animation: fadeInUp 0.6s ease-out 0.3s both;
  position: relative;
  z-index: 1;
  padding-bottom: var(--space-sm);
}

.dashboard-hero__stat {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.dashboard-hero__stat strong {
  font-size: var(--font-size-xl);
  font-weight: 800;
}

/* ========================================================================
   Dashboard Tabs
   ======================================================================== */
/* Tab navigation moved to header split-button dropdown */
.dashboard-tabs {
  display: none;
}

.dashboard-tab {
  padding: var(--space-sm) var(--space-lg);
  border: none;
  background: none;
  font-size: var(--font-size-base);
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  color: var(--color-text-light);
  white-space: nowrap;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  border-radius: var(--border-radius-md) var(--border-radius-md) 0 0;
}

.dashboard-tab:hover {
  color: var(--color-primary-dark);
  background: var(--color-primary-light);
}

.dashboard-tab.is-active {
  color: var(--color-primary-dark);
  border-bottom-color: var(--color-primary);
}

/* Tab panels */
.dashboard-tab-panel {
  max-width: 62.5rem;
  margin: 0 auto;
  padding: var(--space-sm) var(--space-lg) var(--space-lg);
  width: 100%;
  box-sizing: border-box;
  position: relative;
}

/* Semi-transparent overlay so background map doesn't reduce readability */
.dashboard-tab-panel:not([hidden])::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.75);
  z-index: 0;
  pointer-events: none;
}

.dashboard-tab-panel:not([hidden]) > * {
  position: relative;
  z-index: 1;
}

/* 讓可見的 tab panel 撐滿剩餘空間，把 footer 推到底部 */
.dashboard-tab-panel:not([hidden]) {
  flex: 1 0 auto;
}

/* ========================================================================
   Grade Statistics Cards (Redesigned)
   ======================================================================== */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

/* Needs mode: 3 certification cards fill full width */
.dashboard-stats--three {
  grid-template-columns: repeat(3, 1fr);
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-md) var(--space-sm);
  border-radius: var(--border-radius-lg);
  text-align: center;
  border: 2px solid transparent;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  animation: fadeInUp 0.5s ease-out both;
}

.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  background: var(--focus-bg-color, #FFDD00) !important;
  color: var(--focus-text-color, #1a1a1a);
}

/* Color-coded card decorative bottom bar */
.stat-card::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
}

.stat-card--A { background: var(--color-level-A-bg); border-color: var(--color-level-A); }
.stat-card--B { background: var(--color-level-B-bg); border-color: var(--color-level-B); }
.stat-card--C { background: var(--color-level-C-bg); border-color: var(--color-level-C); }
.stat-card--D { background: var(--color-level-D-bg); border-color: var(--color-level-D); }

.stat-card--A::before { background: linear-gradient(90deg, var(--color-level-A), #5CB85C); }
.stat-card--B::before { background: linear-gradient(90deg, var(--color-level-B), #6CB4EE); }
.stat-card--C::before { background: linear-gradient(90deg, var(--color-level-C), #F0AD4E); }
.stat-card--D::before { background: linear-gradient(90deg, var(--color-level-D), #E8738A); }

.stat-card__grade {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1;
}

.stat-card--A .stat-card__grade { color: #0E6E3E; }
.stat-card--B .stat-card__grade { color: #1A5FB4; }
.stat-card--C .stat-card__grade { color: #B35C00; }
.stat-card--D .stat-card__grade { color: #A31545; }

.stat-card__label {
  font-size: var(--font-size-sm);
  color: var(--color-text-light);
  margin: var(--space-xs) 0;
}

.stat-card__count {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-text);
  animation: countUp 0.4s ease-out 0.6s both;
}

/* Stat card click hint */
.stat-card::after {
  content: '點擊查看 →';
  font-size: var(--font-size-xs);
  color: var(--color-text-light);
  margin-top: var(--space-xs);
  opacity: 0;
  transition: opacity 0.2s;
}

.stat-card:hover::after {
  opacity: 1;
}

/* Highlight active stat card */
.stat-card.is-selected {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.stat-card--A.is-selected { border-color: #0E6E3E; background: #C6F0D5; }
.stat-card--B.is-selected { border-color: #1A5FB4; background: #C9DFFB; }
.stat-card--C.is-selected { border-color: #B35C00; background: #FFE8CC; }
.stat-card--D.is-selected { border-color: #A31545; background: #F9CDD9; }

/* ========================================================================
   Dashboard Search (legacy, now used in tab-search only)
   ======================================================================== */
.dashboard-search {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  max-width: 37.5rem;
  margin-left: auto;
  margin-right: auto;
}

.dashboard-search .form-input--lg {
  flex: 1;
  padding: var(--space-md);
  font-size: var(--font-size-md);
  border-radius: var(--border-radius-lg);
}

.btn--lg {
  padding: var(--space-md) var(--space-xl);
  font-size: var(--font-size-md);
}

/* 進入地圖瀏覽 hover/focus：黃底 + 單層框，消除 .btn-primary 邊框疊加 */
#enter-map-btn:hover,
#enter-map-btn:focus-visible {
  background: var(--focus-bg-color, #FFDD00) !important;
  color: var(--focus-text-color, #1a1a1a) !important;
  border: 2px solid transparent !important;
  outline: 3px solid var(--color-primary, #0EA5A0) !important;
  outline-offset: -3px;
  box-shadow: 0 4px 0 0 var(--color-primary, #0EA5A0) !important;
}

/* ========================================================================
   Section Title
   ======================================================================== */
.dashboard-section-title {
  font-size: var(--font-size-md);
  font-weight: 700;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-xs);
  border-bottom: 2px solid var(--color-border);
  color: var(--color-text);
}

/* ========================================================================
   Featured Facility Cards (Redesigned)
   ======================================================================== */
.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.facility-card {
  position: relative;
  background: var(--color-bg-white);
  border: 2px solid var(--color-border);
  border-radius: var(--border-radius-lg);
  padding: var(--space-sm);
  transition: all var(--transition-fast);
  width: 100%;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  animation: fadeInUp 0.4s ease-out both;
  overflow: visible;
}

.facility-card:hover,
.facility-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 0 0 3px var(--_card-border-color, var(--color-border)), var(--shadow-md);
  background: var(--focus-bg-color, #FFDD00) !important;
  color: var(--focus-text-color, #1a1a1a);
}

.facility-card:focus-visible {
  outline: 3px solid var(--focus-outline-color);
  outline-offset: 2px;
}

.facility-card__grade-corner {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  z-index: 1;
}

.facility-card__header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}

.facility-card__name {
  font-weight: 700;
  font-size: var(--font-size-base);
  flex: 1;
  color: var(--color-text);
}

.facility-card__type {
  font-size: var(--font-size-xs);
  padding: 2px 10px;
  border-radius: var(--border-radius-pill);
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-weight: 600;
  border: 1px solid var(--_card-border-color, var(--color-primary, #0A7B77));
}

.facility-card__location {
  font-size: var(--font-size-sm);
  color: var(--color-text-light);
}

.facility-card__score {
  font-size: var(--font-size-sm);
  color: var(--color-text-light);
}

.facility-card__features {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: var(--space-xs);
}

.a11y-icon-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--border-radius-md);
  font-size: 0.875rem;
  background: var(--color-level-A-bg);
  border: 1px solid var(--color-level-A);
  cursor: default;
  position: relative;
}

/* CSS custom tooltip for accessibility icons */
.a11y-icon-sm[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a202c;
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}

.a11y-icon-sm[data-tooltip]:hover::after,
.a11y-icon-sm[data-tooltip]:focus::after {
  opacity: 1;
}

/* JS fixed tooltip (400% mobile, avoids overflow clipping) */
.fhm-fixed-tooltip {
  display: none;
  position: fixed;
  background: #1a202c;
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: normal;
  max-width: 45vw;
  text-align: center;
  pointer-events: none;
  z-index: 99999;
}

/* ========================================================================
   Grade Results (back button + title)
   ======================================================================== */
.grade-results__header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.grade-results__header .dashboard-section-title {
  flex: 1;
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.grade-results__header .btn--sm {
  padding: var(--space-xs) var(--space-md);
  font-size: var(--font-size-sm);
  flex-shrink: 0;
}

/* ========================================================================
   Dashboard Action Button (Enter Map)
   ======================================================================== */
.dashboard-action {
  text-align: center;
  padding: var(--space-xl) 0;
}

.dashboard-action .btn {
  background: var(--color-primary-gradient);
  border: none;
  color: var(--color-text-inverse);
  padding: var(--space-md) var(--space-2xl);
  font-size: var(--font-size-md);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 4px 15px rgba(14, 165, 160, 0.35);
  transition: all var(--transition-fast);
}

.dashboard-action .btn:hover {
  box-shadow: 0 6px 20px rgba(14, 165, 160, 0.5);
  transform: translateY(-2px);
}

/* ========================================================================
   Condition Search
   ======================================================================== */
.condition-search {
  margin-bottom: var(--space-lg);
}

.condition-search .form-input,
.condition-search .form-select {
  border-color: #767676;
}

.condition-search__row {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.condition-search__row .form-group {
  flex: 1;
}

.condition-search__results {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

/* ========================================================================
   Needs-Based Cards (Redesigned)
   ======================================================================== */
.needs-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.needs-card {
  background: var(--color-bg-white);
  border: 2px solid var(--color-border);
  border-radius: var(--border-radius-lg);
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  animation: fadeInUp 0.4s ease-out both;
}

.needs-card:nth-child(1) { animation-delay: 0.05s; }
.needs-card:nth-child(2) { animation-delay: 0.1s; }
.needs-card:nth-child(3) { animation-delay: 0.15s; }
.needs-card:nth-child(4) { animation-delay: 0.2s; }

.needs-card:hover,
.needs-card:focus-visible {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-primary);
}

.needs-card:focus-visible {
  outline: 3px solid var(--focus-outline-color);
  outline-offset: 2px;
}

.needs-card.is-selected {
  border-color: var(--color-primary-dark);
  background: #E6F9EE;
  position: relative;
}

.needs-card.is-selected::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary-dark, #065450);
}

.needs-card__icon {
  font-size: 3rem;
  margin-bottom: var(--space-sm);
  display: block;
}

.needs-card__title {
  font-size: var(--font-size-md);
  font-weight: 700;
  margin-bottom: var(--space-xs);
  color: var(--color-text);
}

.needs-card__count {
  font-size: var(--font-size-sm);
  color: var(--color-primary-dark);
  font-weight: 600;
}

.needs-card__desc {
  font-size: var(--font-size-xs);
  color: var(--color-text-light);
  margin-top: var(--space-sm);
  line-height: var(--line-height-base);
}

/* Needs results */
.needs-results {
  margin-top: var(--space-md);
}

/* Needs location filter */
.needs-location-filter {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  flex-wrap: nowrap;
  align-items: center;
  padding: var(--space-sm) 0;
}

.needs-location-filter__label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  white-space: nowrap;
}

.needs-location-filter .form-select {
  flex: 1;
  min-width: 0;
}

/* Match percentage bar */
.match-bar {
  height: 8px;
  background: var(--color-border);
  border-radius: var(--border-radius-pill);
  overflow: hidden;
  margin-top: var(--space-xs);
}

.match-bar__fill {
  height: 100%;
  border-radius: var(--border-radius-pill);
  background: var(--color-primary-gradient);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.match-percentage {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-primary-dark);
}

/* ========================================================================
   Pagination
   ======================================================================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  margin: var(--space-lg) 0;
  flex-wrap: wrap;
}

.pagination__btn {
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-white);
  border-radius: var(--border-radius-md);
  cursor: pointer;
  font-size: var(--font-size-sm);
  transition: all var(--transition-fast);
}

.pagination__btn:hover:not(:disabled) {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.pagination__btn.is-active {
  background: var(--color-primary-dark);
  color: var(--color-text-inverse);
  border-color: var(--color-primary-dark);
}

.pagination__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination__info {
  font-size: var(--font-size-xs);
  color: var(--color-text-light);
  margin-right: var(--space-sm);
}

.pagination__ellipsis {
  padding: 0 4px;
  color: var(--color-text-light);
}

/* ========================================================================
   Needs Preferences Bar
   ======================================================================== */
.needs-preferences {
  background: var(--color-bg-white);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
}

.needs-preferences__header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.needs-preferences__label {
  font-weight: 700;
  font-size: var(--font-size-base);
  flex: 1;
}

.needs-preferences__hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-light);
  margin-top: var(--space-xs);
  margin-bottom: 0;
}

.needs-preferences__summary {
  font-size: var(--font-size-sm);
  color: var(--color-primary-dark);
  font-weight: 600;
}

/* ========================================================================
   Feature Preference Modal
   ======================================================================== */
.prefs-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

/* fadeIn keyframe is defined in animations.css */

.prefs-modal {
  background: var(--color-bg-white);
  border-radius: var(--border-radius-xl);
  max-width: 38.75rem;
  width: 92%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
}

.prefs-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.prefs-modal__title {
  font-size: var(--font-size-md);
  font-weight: 700;
  margin: 0;
}

.prefs-modal__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-light);
  padding: 4px 8px;
  line-height: 1;
  border-radius: var(--border-radius-md);
  transition: all var(--transition-fast);
}

.prefs-modal__close:hover {
  color: var(--color-text);
  background: var(--color-bg-secondary);
}

.prefs-modal__body {
  overflow-y: auto;
  padding: var(--space-md) var(--space-lg);
  flex: 1;
}

.prefs-modal__group {
  margin-bottom: var(--space-md);
}

.prefs-modal__group:last-child {
  margin-bottom: 0;
}

.prefs-modal__group-title {
  font-weight: 700;
  font-size: var(--font-size-base);
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-primary-dark);
}

.prefs-modal__items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-xs) var(--space-md);
}

.prefs-modal__item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
  cursor: pointer;
  font-size: var(--font-size-sm);
}

.prefs-modal__item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--color-primary);
}

.prefs-modal__item-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.prefs-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border);
}

/* ========================================================================
   Responsive
   ======================================================================== */
@media (max-width: 767px) {
  /* Fill gap between header and hero at 400% zoom */
  .homepage-dashboard {
    background: var(--color-primary-gradient, linear-gradient(135deg, #056A5C 0%, #145490 100%));
  }

  .dashboard-hero {
    padding: var(--space-xl) var(--space-md) var(--space-lg);
  }

  .dashboard-hero__title {
    font-size: var(--font-size-xl);
  }

  .dashboard-hero__search {
    flex-direction: column;
  }

  /* 手機版隱藏副標題破折號，並強制換行 */
  .hero-dash {
    display: block;
    font-size: 0;
    line-height: 0;
    height: 0;
  }

  /* 手機版 compact Hero: 搜尋欄隱藏，僅顯示標題 */
  .dashboard-hero.is-compact .dashboard-hero__search { display: none; }
  .dashboard-hero.is-compact { flex-wrap: wrap; gap: var(--space-sm); justify-content: center; text-align: center; }

  /* 手機版: 浮水印縮小並置中 */
  .dashboard-hero__watermark {
    width: 180px;
    height: auto;
    right: 50%;
    transform: translate(50%, -50%);
    opacity: 0.2;
  }

  .dashboard-hero__stats {
    flex-wrap: wrap;
    gap: var(--space-md);
  }

  .dashboard-stats,
  .dashboard-stats--three {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .needs-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  /* 400%: 條件搜尋/需求導向結果 2 欄（覆蓋 JS inline repeat(3,1fr)） */
  #cs-results,
  #needs-results-list,
  #wizard-results-list {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .condition-search__row {
    flex-direction: column;
  }
  .needs-location-filter {
    flex-wrap: wrap !important;
  }
  .needs-location-filter .form-select {
    width: 100% !important;
    min-width: 100% !important;
  }

  .dashboard-tabs {
    gap: 0;
    padding: var(--space-sm) var(--space-sm) 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .dashboard-tab {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    white-space: nowrap;
    flex-shrink: 0;
  }

  .dashboard-tab-panel {
    padding: var(--space-md);
  }

  /* 400%: 進入地圖瀏覽按鈕 — 白底深綠字，確保對比度 (WCAG 1.4.11) */
  #enter-map-btn {
    background: #fff;
    color: var(--color-primary-dark, #065450);
    border: 3px solid var(--color-primary-dark, #065450);
  }
  #enter-map-btn:focus,
  #enter-map-btn:focus-visible {
    background-color: var(--focus-bg-color, #FFDD00) !important;
    color: var(--focus-text-color, #1a1a1a) !important;
  }

  /* 400%: 條件搜尋按鈕加白邊框+白底，提升與 gradient 背景的對比度 (WCAG 1.4.11) */
  #cs-search-btn {
    background: #fff;
    color: var(--color-primary-dark, #065450);
    border: 3px solid #fff;
    font-weight: 700;
  }
  #cs-search-btn:focus,
  #cs-search-btn:focus-visible {
    background-color: var(--focus-bg-color, #FFDD00) !important;
    color: var(--focus-text-color, #1a1a1a) !important;
  }

  /* 400%: 分頁按鈕加白邊框底色提升對比度 */
  .pagination__btn {
    background: #fff !important;
    color: var(--color-primary-dark, #065450) !important;
    border: 2px solid var(--color-primary-dark, #065450) !important;
    min-width: 32px;
    min-height: 32px;
  }
  .pagination__btn.is-active {
    background: #fff !important;
    color: var(--color-primary-dark, #065450) !important;
    border: 1px solid var(--color-primary-dark, #065450) !important;
    font-weight: 700 !important;
  }

  /* 400% focus：分頁按鈕黃底黑框，深藍背景上可辨識 */
  .pagination__btn:focus-visible {
    background: #fff000 !important;
    color: #1a1a1a !important;
    box-shadow: inset 0 0 0 3px #1a1a1a !important;
    outline: none !important;
  }

  /* 400% CCA 對比度修復：gradient 背景上的文字改為白色 (WCAG 1.4.3 / 1.4.11) */
  .form-label,
  .condition-search__row label,
  .needs-location-filter__label,
  .wizard-panel__desc,
  .wizard-feature-group__title,
  .wizard-panel__title,
  .needs-search__title,
  .dashboard-section-title,
  .pagination__info {
    color: #fff !important;
  }

  /* gradient 背景上的副標題/描述文字改白色 */
  .dashboard-tab-panel > p,
  .dashboard-tab-panel > .dashboard-section-title + p,
  .dashboard-section-desc {
    color: rgba(255,255,255,0.85) !important;
    font-size: 0.6875rem !important;
  }

  /* gradient 背景上的 select/input 邊框需 3:1 對比 */
  .form-select,
  .form-input {
    border: 1px solid #767676 !important;
    background: #fff !important;
    color: #2D3748 !important;
  }

  /* 需求導向模式切換按鈕 — gradient 背景上 */
  .needs-mode-switcher {
    background: rgba(255,255,255,0.15) !important;
    border-color: #fff !important;
  }
  .needs-mode-btn {
    background: transparent !important;
    color: #fff !important;
    border: 2px solid transparent !important;
  }
  .needs-mode-btn.is-active {
    background: #fff !important;
    color: var(--color-primary-dark, #065450) !important;
    border: 2px solid var(--color-primary-dark, #065450) !important;
  }
  .needs-mode-btn:focus,
  .needs-mode-btn:focus-visible,
  .needs-mode-btn.is-active:focus,
  .needs-mode-btn.is-active:focus-visible {
    background-color: var(--focus-bg-color, #FFDD00) !important;
    color: var(--focus-text-color, #1a1a1a) !important;
  }

  /* 400% 精簡 facility-card：隱藏原始設施圖示列 */
  .facility-card__features {
    display: none !important;
  }

  /* 400% mobile: facility-card 整體縮小 */
  .facility-card {
    padding: var(--space-xs) !important;
    gap: 2px !important;
  }

  /* 400%: facility-card focus 全黃底 + 確保名稱可見 */
  .facility-card:focus,
  .facility-card:focus-visible,
  .facility-card:focus-within,
  .facility-card--mobile:focus,
  .facility-card--mobile:focus-visible {
    background-color: var(--focus-bg-color, #FFDD00) !important;
    color: var(--focus-text-color, #1a1a1a) !important;
    outline: none !important;
  }


  .facility-card__name {
    font-size: 0.8125rem !important;
  }

  /* 400% mobile 專用設施圖示列：顯示，圖示縮小 */
  .facility-card__features--mobile {
    display: flex !important;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 2px;
  }

  .facility-card__features--mobile .a11y-icon-sm {
    width: 22px !important;
    height: 22px !important;
    font-size: 0.7rem !important;
    border-radius: 3px !important;
  }

  /* 400% tooltip: 隱藏 CSS pseudo tooltip，改用 JS fixed tooltip */
  .facility-card__features--mobile .a11y-icon-sm[data-tooltip]::after {
    display: none !important;
  }

  /* 400% 精簡 facility-card：隱藏類型標籤與區域 */
  .facility-card__type,
  .facility-card__location {
    display: none !important;
  }

  /* 400% mobile facility-card 新增欄位 */
  .facility-card__address {
    display: block;
    font-size: 0.6875rem;
    color: var(--color-text);
    margin-bottom: 2px;
  }

  .facility-card__phone {
    display: block;
    font-size: 0.6875rem;
    margin-bottom: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .facility-card__phone a {
    color: var(--color-primary-dark, #065450);
    text-decoration: underline;
  }

  .facility-card__match {
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--color-primary, #0EA5A0);
    white-space: nowrap;
    flex-shrink: 0;
  }

}

/* ========================================================================
   Empty State
   ======================================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--space-lg);
  text-align: center;
  grid-column: 1 / -1;
}

.empty-state__img {
  width: 180px;
  height: auto;
  margin-bottom: var(--space-md);
  opacity: 0.85;
}

.empty-state__text {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

.empty-state__hint {
  font-size: var(--font-size-sm);
  color: var(--color-text-light);
}

/* ========================================================================
   Section Dividers + Geometric Backgrounds
   ======================================================================== */

/* Decorative section divider */
.section-divider {
  position: relative;
  height: 48px;
  margin: var(--space-lg) 0;
  overflow: hidden;
}

.section-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-border), transparent);
}

.section-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: 2px;
}

/* Enhanced section title with decorative left accent */
.dashboard-section-title {
  position: relative;
  padding-left: var(--space-md);
}

.dashboard-section-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--color-primary-gradient);
  border-radius: var(--border-radius-pill);
}

/* Subtle geometric dot pattern in overview tab */
.dashboard-tab-panel::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 200px;
  height: 200px;
  background-image: radial-gradient(circle, var(--color-border) 1px, transparent 1px);
  background-size: 20px 20px;
  opacity: 0.3;
  pointer-events: none;
  z-index: 0;
}

.dashboard-tab-panel {
  position: relative;
}

.dashboard-tab-panel > * {
  position: relative;
  z-index: 1;
}

/* ========================================================================
   Needs Mode Switcher (Guided vs Traditional)
   ======================================================================== */
.needs-mode-switcher {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
  background: var(--color-bg-secondary);
  padding: 4px;
  border-radius: var(--border-radius-lg);
  width: fit-content;
  border: 1px solid #767676;
}

.needs-mode-btn {
  padding: var(--space-sm) var(--space-lg);
  border: none;
  background: transparent;
  border-radius: var(--border-radius-md);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-light);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.needs-mode-btn.is-active {
  background: var(--color-bg-white);
  color: var(--color-primary-dark);
  box-shadow: var(--shadow-sm);
  border: 2px solid #065450;
}

.needs-mode-btn:hover:not(.is-active) {
  color: var(--color-text);
}

/* ========================================================================
   Guided Search Wizard
   ======================================================================== */
.wizard-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: var(--space-md);
  padding: 0 var(--space-md);
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  opacity: 0.4;
  transition: opacity var(--transition-fast);
}

.wizard-step.is-active {
  opacity: 1;
}

.wizard-step.is-done {
  opacity: 1;
}

.wizard-step__num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-border);
  color: var(--color-text-light);
  border: 1px solid #767676;
  font-weight: 700;
  font-size: var(--font-size-sm);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.wizard-step.is-active .wizard-step__num {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.wizard-step.is-done .wizard-step__num {
  background: var(--color-primary-dark);
  color: var(--color-text-inverse);
  border-color: var(--color-primary-dark);
}

.wizard-step__label {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: #1a1a1a;
  white-space: nowrap;
}

.wizard-step.is-active .wizard-step__label {
  color: var(--color-text);
}

.wizard-step__line {
  flex: 1;
  height: 2px;
  background: #767676;
  margin: 0 var(--space-sm);
  min-width: 20px;
  max-width: 60px;
}

/* Wizard panels */
.wizard-panel {
  max-width: 40rem;
  margin: 0 auto;
  animation: fadeInUp 0.3s ease-out;
  color: #1a1a1a;
  font-weight: 600;
}

/* Step 4 results need full width for card grid */
#wizard-step-4 {
  max-width: 100%;
}

.wizard-panel__title {
  font-size: var(--font-size-xl, 1.5rem);
  font-weight: 700;
  margin-bottom: var(--space-xs);
  color: #1a1a1a;
}

.wizard-panel__desc {
  font-size: var(--font-size-base);
  color: #1a1a1a;
  margin-bottom: var(--space-md);
}

.wizard-panel__body {
  margin-bottom: var(--space-md);
}

.wizard-panel .form-select {
  border-color: #767676;
}

.wizard-panel__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding-top: var(--space-sm);
}

/* Wizard category cards (step 2) */
.wizard-category-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
}

.wizard-category-card {
  background: var(--color-bg-white);
  border: 2px solid var(--color-border);
  border-radius: var(--border-radius-lg);
  padding: var(--space-md);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.wizard-category-card:hover,
.wizard-category-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
}

.wizard-category-card.is-selected {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.wizard-category-card__icon {
  font-size: 4rem;
  margin-bottom: var(--space-sm);
  display: block;
}

.wizard-category-card__title {
  font-size: var(--font-size-md);
  font-weight: 700;
}

/* Wizard feature checkboxes (step 3) */
.wizard-feature-group {
  margin-bottom: var(--space-md);
}

.wizard-feature-group__title {
  font-weight: 700;
  font-size: var(--font-size-base);
  color: var(--color-primary-dark);
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--color-border);
}

.wizard-feature-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-xs) var(--space-md);
}

.wizard-feature-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
  cursor: pointer;
  font-size: var(--font-size-base);
  font-weight: 600;
  color: #1a1a1a;
}

.wizard-feature-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--color-primary);
}

/* Wizard responsive */
@media (max-width: 767px) {
  .wizard-steps {
    flex-wrap: wrap;
    gap: var(--space-xs);
  }

  .wizard-step__label {
    display: none;
  }

  /* 400%: 步驟圓圈提升對比度 — gradient 背景上 */
  .wizard-step {
    opacity: 1 !important;
  }
  .wizard-step__num {
    background: #fff !important;
    color: var(--color-primary-dark, #065450) !important;
    border: 3px solid #fff !important;
    font-size: 0.875rem !important;
  }
  .wizard-step.is-active .wizard-step__num {
    background: #fff !important;
    color: var(--color-primary-dark, #065450) !important;
    border: 3px solid var(--color-primary-dark, #065450) !important;
    box-shadow: 0 0 0 3px #fff;
  }
  .wizard-step.is-done .wizard-step__num {
    background: var(--color-primary-dark, #065450) !important;
    color: #fff !important;
    border: 3px solid #fff !important;
  }
  .wizard-step__line {
    background: rgba(255,255,255,0.5) !important;
    height: 3px !important;
  }

  .wizard-step__line {
    min-width: 16px;
    max-width: 32px;
  }

  .wizard-category-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  /* 400%: 選中的類別卡片加粗邊框+深色底+勾勾，明確顯示已選 */
  .wizard-category-card.is-selected {
    border: 4px solid var(--color-primary-dark, #065450) !important;
    background: var(--focus-bg-color, #FFDD00) !important;
    color: #1a1a1a !important;
    position: relative;
  }
  .wizard-category-card.is-selected::after {
    content: '✓';
    position: absolute;
    top: 4px;
    right: 8px;
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--color-primary-dark, #065450);
  }

  /* 400%: 未選的類別卡片白底 */
  .wizard-category-card:not(.is-selected) {
    background: #fff !important;
  }

  .wizard-feature-list {
    grid-template-columns: 1fr;
  }

  /* 400%: feature checkbox 項目加白底卡片，確保文字對比度 */
  .wizard-feature-item {
    background: #fff !important;
    color: #1a1a1a !important;
    padding: var(--space-xs) var(--space-sm) !important;
    border-radius: 6px;
    border: 1px solid var(--color-border);
  }

  /* 400%: checkbox focus 時整個 label 變黃底 */
  .wizard-feature-item:focus-within {
    background-color: var(--focus-bg-color, #FFDD00) !important;
    color: var(--focus-text-color, #1a1a1a) !important;
  }

  /* 400%: wizard panel 標題/描述/group-title 白色 */
  .wizard-panel__title,
  .wizard-panel__desc,
  .wizard-feature-group__title {
    color: #fff !important;
  }

  /* 400%: wizard 按鈕 (下一步/上一步) 白底深綠字 */
  .wizard-panel .btn-primary {
    background: #fff;
    color: var(--color-primary-dark, #065450);
    border: 2px solid var(--color-primary-dark, #065450);
  }
  .wizard-panel .btn-secondary,
  .wizard-panel .btn[type="button"]:not(.btn-primary) {
    background: transparent;
    color: #fff;
    border: 2px solid #fff;
  }


  /* 400%: needs-card 白底深綠文字 (在 gradient 上) */
  .needs-card {
    background: #fff !important;
    color: #1a1a1a !important;
  }
  .needs-card__count {
    color: var(--color-primary-dark, #065450) !important;
  }

  .needs-mode-switcher {
    width: 100%;
  }

  .needs-mode-btn {
    flex: 1;
    text-align: center;
  }
}
