/* 全局樣式 */
body {
  margin: 0;
  font-family: Arial, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: url("../img/background.jpg") no-repeat center center fixed;
  background-size: cover;
}

.navbar, footer { 
  background-color: rgba(51,51,51,0.85); 
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  color: white;
}

.navbar .logo {
  display: flex;
  align-items: center;
  font-size: 1.5em;   /* 與 h1 大小一致 */
  font-weight: bold;
}

.navbar .logo img {
  height: 40px;
  width: 40px;
  margin-right: 10px;
}

/* h1 樣式 (網站標題) */
.navbar .logo h1 {
  font-size: 24px;   /* 與 logo 文字大小一致，原本 1.5em ≈ 24px */
  font-weight: bold;
  margin: 0;
  color: white;
  display: inline;   /* inline 不換行 */
}

/* 導航用 h2 併排樣式 */
.navbar .nav-links {
  display: flex;          /* 水平排列 */
  align-items: center;    /* 垂直置中 */
  margin: 0;
  padding: 0;
}

.navbar .nav-links h2 {
  margin: 0 0 0 20px;     /* 左間距 20px，第一個可去掉 */
  font-size: 16px;        /* 跟原 li a 一樣 */
  font-weight: normal;    /* 跟原 li a 一樣 */
  display: flex;          /* 讓 a 在裡面也可置中 */
}

.navbar .nav-links h2:first-child {
  margin-left: 0;         /* 第一個不要左間距 */
}

.navbar .nav-links h2 a {
  text-decoration: none;
  color: white;
  transition: color 0.3s;
}

.navbar .nav-links h2 a:hover {
  color: #ffcc00;
}



/* 主內容與地圖 */
.content { 
  flex:1; 
  display:flex; 
  margin:20px; 
  padding:0; 
  background:none; 
  border-radius:10px; 
  overflow:hidden; 
  position:relative; 
}

#map { 
  flex:1; 
  width:100%; 
  height:100%; 
  border:none; 
}

/* 經緯度座標顯示 */
#coord { 
  position:absolute; 
  bottom:40px; 
  right:20px; 
  background: rgba(0,0,0,0.6); 
  color:white; 
  padding:5px 10px; 
  font-size:14px; 
  border-radius:5px; 
  pointer-events:none; 
  z-index:1001 
}

/* 右側面板 */
#panel {
  position:absolute;
  top:20px;
  right:10px;
  background: rgba(255,255,255,0.95);
  padding:10px;
  border-radius:8px;
  z-index:1000;
  width:250px;  /* 桌機版固定寬度 */
  box-sizing: border-box;
}


#panel select, #panel input { 
  width:100%; 
  margin-bottom:5px; 
  padding:5px; 
  box-sizing:border-box; 
}

#panel input { 
  display:none; 
  position:relative; 
  z-index:1000; 
}

/* 面板內 h3 / h4，不留空白，維持版型 */
#panel .panel-label {
  margin: 0;           /* 去掉上下 margin */
  font-size: 14px;     /* 與 select/input 文字大小一致 */
  font-weight: normal; /* 與原文字一致 */
  display: block;      /* 保持換行排列 */
  color: #333;         /* 與原文字顏色一致 */
  line-height: 1.2;    /* 調整行高避免空隙 */
}


/* 頁尾 */
footer { 
  color:#ccc; 
  text-align:center; 
  padding:15px 20px; 
  font-size:0.9em; 
  flex-shrink:0; 
}

footer a { 
  color:#ffcc00; 
  text-decoration:none; 
}

footer a:hover { 
  text-decoration:underline; 
}

/* 手機版調整面板與座標 */
@media(max-width:600px){
  #coord { display:none; }
  #panel { width:90%; max-width:150px; top:10px; right:5px; }
  #panel select, #panel input { padding:4px; font-size:0.85em; }
  #panel h2 { font-size: 13px; margin:6px 0; }
}

/* 問號圖標 */
.tooltip-icon {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  position: relative;
  top: -3px;   /* 垂直微調問號位置 */
  left: -3px;
  width: 20px;
  height: 20px;
  background: #007BFF;
  color: #fff;
  font-weight: bold;
  border-radius: 50%;
  font-size: 14px;
  margin-left: 5px;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  padding: 0;
  line-height: 1;
}

/* 圖例彈窗容器 */
.legend-wrapper {
  position: relative;
  display: inline-block;
  width: 100%; /* 跟面板寬度一致 */
  box-sizing: border-box;
}

/* 圖例彈窗 */
.tooltip-box {
  display: none;
  position: absolute;
  top: 36px;          /* 問號下方 */
  left: 0;
  width: 100%;        /* 跟父容器同寬 */
  max-width: 100%;
  max-height: 70vh;   /* 高度限制 */
  background: #fff;
  border: 1px solid #ccc;
  padding: 12px;
  overflow: auto;
  z-index: 2000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  border-radius: 10px;
  box-sizing: border-box;
}

/* 點擊問號後顯示 */
.legend-wrapper.active .tooltip-box {
  display: block;
}

/* 排版 */
.layer-select-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 圖例內容 */
.legend-container h2 {
  font-size: 15px;
  margin: 0 0 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.color-box {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border-radius: 4px;
}

.legend-item strong {
  font-size: 14px;
  display: block;
  line-height: 1.2;
}

.legend-item .description {
  font-size: 13px;
  color: #444;
  line-height: 1.35;
}

/* 手機優化圖例彈窗 */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
  #panel { width:90%; max-width:150px; }
  .legend-wrapper { width: 100%; }
  .tooltip-box { width: 100%; max-width: 100%; max-height: 55vh; padding: 10px; }
  .legend-container h2 { font-size: 14px; margin-bottom: 6px; }
  .legend-item { gap: 8px; margin-bottom: 6px; }
  .color-box { width: 16px; height: 16px; flex-basis: 16px; }
  .legend-item strong { font-size: 13px; }
  .legend-item .description { font-size: 12px; }
}

/* 隱藏但保留 SEO 層級 */
.sr-only {
  position: absolute; 
  width: 1px; 
  height: 1px; 
  padding: 0; 
  margin: -1px; 
  overflow: hidden; 
  clip: rect(0,0,0,0); 
  white-space: nowrap; 
  border: 0;
}
