/* v2 地圖模式 — 獨立 CSS（跟 style2.css 分離）
 * 只 retty.liu@gmail.com 看得到入口；其他用戶這 file 雖載但 .v2-view-toggle 不顯示
 * 載入順序：index2.html 內 style2.css 之後（覆寫 default 樣式 + 提供地圖專用 class）
 */

/* ── 「近 N 天內」新進物件 filter (地圖左上角 Leaflet control) ─────────── */
.v2-map-recency-filter {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.v2-map-recency-filter__label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  background: #fff;
  padding: 5px 9px;
  border: 1px solid rgba(0,0,0,0.18);
  border-radius: 4px;
  font-size: 12px;
  color: #333;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  user-select: none;
}
.v2-map-recency-filter__label input { cursor: pointer; margin: 0; }

/* ── 列表 / 地圖 切換 link (toolbar 右側) ── */
.v2-view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 12px;
  font-size: 13px;
}
.v2-view-toggle__link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--c-text-muted);
  text-decoration: none;
  padding: 2px 4px;
  cursor: pointer;
}
.v2-view-toggle__link:hover { color: #c78a00; }
.v2-view-toggle__link.is-active {
  color: #c78a00;
  font-weight: 700;
  text-decoration: underline;
}
.v2-view-toggle__sep { color: #d8d2be; }
.v2-view-toggle__icon { display: none; }   /* PC 預設 hide icon, show text */

/* mobile (≤640px)：改顯示 icon（text 隱藏，sep 隱藏，icon 點擊區放大） */
@media (max-width: 640px) {
  .v2-view-toggle { gap: 2px; margin-right: 8px; }
  .v2-view-toggle__txt { display: none; }
  .v2-view-toggle__icon { display: inline-block; width: 18px; height: 18px; }
  .v2-view-toggle__sep { display: none; }
  .v2-view-toggle__link {
    padding: 6px 8px;
    border-radius: var(--r-sm);
    text-decoration: none !important;     /* 蓋過 .is-active underline */
  }
  .v2-view-toggle__link.is-active {
    background: #fff5d6;
    color: #c78a00;
  }
}

/* ── 地圖容器 ── */
.v2-map-wrap {
  display: flex;
  flex-direction: column;
}
.v2-map-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 7px 12px;
  background: #f5f0e3;
  border: 1px solid var(--c-border);
  border-bottom: none;
  border-radius: var(--r-md) var(--r-md) 0 0;
  font-size: 13px;
  flex-wrap: wrap;
}
.v2-map-toolbar__label { color: #555; font-weight: 600; }
.v2-map-toolbar__radio {
  cursor: pointer;
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.v2-map-toolbar__radio input { vertical-align: middle; cursor: pointer; }
.v2-map-toolbar__hint { color: #888; font-size: 12px; margin-left: auto; }
.v2-zoom-indicator {
  background: rgba(255, 255, 255, 0.85);
  padding: 2px 6px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 3px;
  font: 11px/1.4 monospace;
  color: #555;
  user-select: none;
  pointer-events: none;
}
.v2-map {
  width: 100%;
  height: calc(100vh - 260px);
  min-height: 460px;
  border: 1px solid var(--c-border);
  border-radius: 0 0 var(--r-md) var(--r-md);
  overflow: hidden;
  z-index: 0;            /* drawer / sidebar 蓋過去 */
  background: #e8e2cc;   /* loading tile 之前不至於白板 */
}
@media (max-width: 1024px) {
  .v2-map { height: calc(100vh - 240px); min-height: 380px; }
}

/* ── 學區圖層學校名稱 label：純文字 + 描邊，無邊框 / 無背景 ──
 * 結構：leaflet 用 iconSize:[0,0] 把 wrapper div 收成 0×0、anchor 落在 polygon center。
 *      inner .v2-school-label-inner 用 absolute + translate(-50%,-50%) 把整文字方塊
 *      中心對齊 wrapper(0,0) → polygon center。
 *      （直接對 wrapper 加 transform 會被 leaflet 自己的 translate3d 蓋掉，
 *       所以必須用 inner 結構） */
.v2-school-label-inner {
  position: absolute;
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);
  font-size: 10px;
  font-weight: 700;
  color: #1f2937;
  white-space: nowrap;
  text-align: center;
  line-height: 1.25;
  pointer-events: none;
  /* 8 方向白色描邊讓字在花花地圖上仍清楚 */
  text-shadow:
    -1px -1px 0 #fff, 1px -1px 0 #fff,
    -1px  1px 0 #fff, 1px  1px 0 #fff,
     0   -1px 0 #fff, 0    1px 0 #fff,
    -1px  0   0 #fff, 1px  0   0 #fff;
}

/* 學區 polygon 不可選取 — disable browser focus outline、不可 hover/click 改 cursor */
.leaflet-overlay-pane svg path.leaflet-interactive {
  outline: none !important;
}

/* ── Marker 倍數 chip 樣式 ── */
.v2-map-marker {
  color: #fff;
  border-radius: 14px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
  line-height: 1.4;
}

/* 從 detail page「在地圖上查看」帶來的目標 marker：放大 + 光暈 pulse 動畫
 * 容器層 transform:scale 透過 transform-origin:center 讓放大不偏移 anchor
 * box-shadow 用 rgba(252, 165, 36, 0.7) 金黃色光暈 (跟 detail page 主色協調) */
.v2-map-marker--focused {
  transform: scale(1.5);
  transform-origin: center center;
  font-size: 13px;
  padding: 3px 10px;
  border-color: #fef3c7;
  z-index: 1000;
  position: relative;
  animation: v2-marker-pulse 1.4s ease-out infinite;
}

@keyframes v2-marker-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(252, 165, 36, 0.85),
                0 1px 3px rgba(0, 0, 0, 0.4);
  }
  70% {
    box-shadow: 0 0 0 18px rgba(252, 165, 36, 0),
                0 1px 3px rgba(0, 0, 0, 0.4);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(252, 165, 36, 0),
                0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

/* ── Leaflet tooltip 客製 (default 太醜) ── */
.leaflet-tooltip {
  background: rgba(31, 41, 55, 0.95) !important;
  color: #fff !important;
  border: none !important;
  font-size: 12px !important;
  padding: 6px 10px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}
.leaflet-tooltip-top:before {
  border-top-color: rgba(31, 41, 55, 0.95) !important;
}
