/* 澎湖縣社區運動資源查詢 - 共用樣式（長者易用性優先：大字體、大按鈕、高對比） */

* { box-sizing: border-box; }

body {
  font-family: "Microsoft JhengHei", "PingFang TC", "Helvetica Neue", Arial, sans-serif;
  font-size: 1.15rem;
  color: #1a1a1a;
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(160deg, #e3f4fb 0%, #fdf6ea 55%, #fbe9dd 100%);
  background-attachment: fixed;
}

html.text-large { font-size: 125%; }
html.text-xlarge { font-size: 150%; }

h1 {
  font-size: 1.8em;
  color: #0a5c78;
  padding-bottom: 0.4rem;
  border-bottom: 4px solid #f4a261;
  display: inline-block;
}

h2 { font-size: 1.4em; color: #0a5c78; }

main {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 1.5rem 2rem 2.5rem;
  background: white;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(10, 92, 120, 0.15);
}

.hint-text { font-size: 1.05em; color: #444; }

/* 鄉鎮頁：該鄉鎮的景觀照當作滿版背景（不做霧化模糊，照片清晰呈現），內容卡片維持一般頁面的實心白底，
   確保文字可讀性不受背景照片影響 */
.township-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: linear-gradient(160deg, #e3f4fb 0%, #fdf6ea 55%, #fbe9dd 100%);
}

  .township-bg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

/* 首頁入口歡迎畫面：整頁滿版風景照輪播＋置中文字，沒有導覽列（進站之後才出現），
   不用一般頁面的白色卡片版型，所以這裡沒有用 <main> */

.hero-section {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: white;
}

.hero-bg-photos { position: absolute; inset: 0; }

  .hero-bg-photos img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    animation: hero-crossfade 18s ease-in-out infinite;
  }

  .hero-bg-photos img:nth-child(1) { animation-delay: 0s; }
  .hero-bg-photos img:nth-child(2) { animation-delay: 6s; }
  .hero-bg-photos img:nth-child(3) { animation-delay: 12s; }

@keyframes hero-crossfade {
  0%, 100% { opacity: 0; }
  5%, 33% { opacity: 1; }
  38% { opacity: 0; }
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(5, 25, 35, 0.45) 0%, rgba(5, 25, 35, 0.58) 100%);
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 780px;
  padding: 2rem 1.5rem;
}

.hero-logo {
  width: 500px;
  height: 500px;
  border-radius: 50%;
  object-fit: cover;
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.4));
}

  .hero-content h1 {
    font-size: 2em;
    color: white;
    border-bottom: none;
    padding-bottom: 0;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
  }

  .hero-content p {
    font-size: 1.2rem;
    line-height: 1.8;
    margin: 1.5rem 0 2.5rem;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
  }

.hero-cta {
  display: inline-block;
  min-height: 64px;
  padding: 1rem 3.5rem;
  border-radius: 999px;
  font-size: 1.4rem;
  font-weight: bold;
  background: linear-gradient(135deg, #f4a261 0%, #e76f51 100%);
  color: white;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

  .hero-cta:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45); }

/* 點「開始」之後的離場轉場：背景放大、畫面轉暗、文字淡出，做出往前走進畫面的感覺 */
.hero-section.leaving .hero-bg-photos img {
  animation-play-state: paused;
  transition: transform 0.9s ease-in;
  transform: scale(1.4);
}

.hero-section.leaving .hero-overlay {
  transition: background 0.9s ease-in;
  background: #05131a;
}

.hero-section.leaving .hero-content {
  transition: opacity 0.35s ease-out, transform 0.35s ease-out;
  opacity: 0;
  transform: scale(0.94);
}

  @media (max-width: 640px) {
    .hero-content h1 { font-size: 1.9em; }
    .hero-content p { font-size: 1.05rem; }
    .hero-cta { padding: 0.9rem 2.5rem; font-size: 1.2rem; }
    .hero-logo { width: 280px; height: 280px; }
  }

/* 導覽列 */

.nav-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(135deg, #0a5c78 0%, #14919b 100%);
  color: white;
  padding: 1rem 1.5rem;
  box-shadow: 0 4px 15px rgba(10, 92, 120, 0.3);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: white;
  font-weight: bold;
  font-size: 1.25rem;
  text-decoration: none;
  margin-right: auto;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.25);
}

.nav-logo { height: 44px; width: auto; flex-shrink: 0; border-radius: 6px; }

.nav-toggle,
.nav-home {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.5rem 1.1rem;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.15s ease;
}

  .nav-toggle:hover,
  .nav-home:hover { background: rgba(255, 255, 255, 0.28); }

  .nav-home { text-decoration: none; white-space: nowrap; }

/* 選單按鈕跟下拉選單包在同一個 .nav-menu 裡，hover 判斷用父層而不是「按鈕:hover 才顯示」，
   這樣滑鼠從按鈕往下移到選單清單的路徑上，不會有一段「兩邊都沒 hover 到」的空隙讓選單提早收合。
   下拉選單本身用 top:100%（跟按鈕下緣完全貼齊、沒有 margin 空隙），視覺上的留白改用 padding-top，
   因為 padding 還算在可以 hover 的範圍內，margin 不算。 */
.nav-menu { position: relative; }

.nav-links {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
  background: linear-gradient(135deg, #0a5c78 0%, #14919b 100%);
  padding: 1.3rem 1.2rem 1rem;
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(10, 92, 120, 0.4);
  min-width: 240px;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 15;
}

  .nav-links.open { display: flex; }

  @media (hover: hover) {
    .nav-menu:hover .nav-links {
      display: flex;
    }
  }

  /* #nav-auth-links 這個 span 裡面塞了好幾個連結（會員資料/我的最愛/登出），
     它本身雖然是 .nav-links 的 flex item，但沒有設 display:flex 的話，
     裡面的連結彼此之間就沒有 gap，跟其他頁籤的間距會對不起來 */
  #nav-auth-links {
    display: flex;
    align-items: center;
    gap: 0.9rem;
  }

  .nav-links a {
    color: white;
    text-decoration: none;
    font-size: 1rem;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    transition: background 0.15s ease;
  }

  .nav-links a:hover {
    background: rgba(255, 255, 255, 0.2);
    text-decoration: none;
  }

  /* 未登入時的「會員登入 / 註冊」按鈕，故意跟其他導覽連結長得不一樣，讓它更顯眼 */
  .nav-links a.nav-cta {
    background: #f4a261;
    color: #5a2d0c;
    font-weight: bold;
    padding: 0.4rem 1.1rem;
    border-radius: 999px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  }

  .nav-links a.nav-cta:hover {
    background: #f7b787;
  }

  /* 登出是不可逆的動作，故意做得跟一般導覽連結不一樣，長輩比較不會誤觸 */
  .nav-links a.nav-logout-link {
    background: rgba(0, 0, 0, 0.18);
    border: 2px solid rgba(255, 255, 255, 0.6);
    font-weight: bold;
  }

  .nav-links a.nav-logout-link:hover {
    background: #c0392b;
    border-color: #c0392b;
  }

/* 字級切換 */

.font-size-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1rem 0 1.5rem;
}

.font-size-controls button {
  min-height: 44px;
  padding: 0.3rem 1.1rem;
  border: 2px solid #14919b;
  border-radius: 999px;
  background: white;
  color: #0a5c78;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.15s ease;
}

  .font-size-controls button:hover {
    background: #14919b;
    color: white;
  }

/* 首頁地圖 */

.map-container {
  position: relative;
  max-width: 900px;
  margin: 0 auto;
}

/* 地圖本島（馬公/湖西/白沙/西嶼）縮放後的 viewBox 是直式的（高比寬多），如果讓它填滿 900px
   容器寬度，換算出來的高度會超過 1000px、地名字也會被放大到不成比例；改用 max-height 夾住，
   讓瀏覽器照長寬比整張縮小到合理大小（跟 <img> 的 object-fit: contain 同一種原理） */
body.sports-map-page #map svg {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 640px;
  margin: 0 auto;
}

.map-wrap {
  padding: 1rem;
  background: linear-gradient(180deg, #cdeefb 0%, #e3f4fb 100%);
  border-radius: 16px;
  box-shadow: inset 0 2px 10px rgba(10, 92, 120, 0.15);
}

/* 望安、七美的「放大鏡」縮圖，疊在地圖左上角，不代表實際地理位置 */
.map-insets {
  position: absolute;
  top: 0.7rem;
  left: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 2;
}

.map-inset {
  width: 170px;
  height: 170px;
  background: white;
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(10, 92, 120, 0.35);
  cursor: pointer;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}

  .map-inset svg { width: 100%; height: 100%; }

  .map-inset:hover, .map-inset:focus, .map-inset.highlight {
    transform: scale(1.06);
    outline: none;
  }

  .map-inset-label {
    position: absolute;
    bottom: 8px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    pointer-events: none;
  }

.inset-note { font-size: 0.85em; margin-top: 0.6rem; }

/* 地圖上的小島不好點準時，直接點鄉鎮名稱一樣能到達，兩種方式並存 */
.township-buttons {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.6rem;
  max-width: 900px;
  margin: 1.2rem auto 0;
}

.township-button {
  --tb-color: #14919b;
  min-height: 56px;
  min-width: 0;
  padding: 0.6rem;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--tb-color), color-mix(in srgb, var(--tb-color) 70%, black));
  color: white;
  font-weight: bold;
  font-size: 1.05rem;
  text-align: center;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(10, 92, 120, 0.25);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

  .township-button:hover,
  .township-button.highlight {
    transform: translateY(-3px);
    box-shadow: 0 8px 18px rgba(10, 92, 120, 0.35);
  }

.township-shape {
  cursor: pointer;
  transition: opacity 0.15s ease, filter 0.15s ease;
}

  .township-shape:hover,
  .township-shape:focus,
  .township-shape.highlight {
    opacity: 0.8;
    filter: brightness(1.15);
    outline: none;
  }

.map-marker {
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}

.map-marker-badge {
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}

.map-marker-hit {
  cursor: pointer;
  transition: opacity 0.15s ease;
}

  .map-marker-hit:hover,
  .map-marker-hit:focus {
    opacity: 0.75;
    outline: none;
  }

.marker-tooltip {
  position: fixed;
  z-index: 50;
  background: white;
  border: 2px solid #14919b;
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  font-size: 0.95rem;
  line-height: 1.5;
  box-shadow: 0 8px 22px rgba(10, 92, 120, 0.3);
  pointer-events: none;
  max-width: 240px;
}

  .marker-tooltip[hidden] { display: none; }
  .marker-tooltip strong { color: #0a5c78; }

/* 回到頂端按鈕，全站共用，捲動一小段才出現 */
.back-to-top {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #14919b 0%, #0a5c78 100%);
  color: white;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(10, 92, 120, 0.35);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  z-index: 30;
}

  .back-to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }
  .back-to-top:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(10, 92, 120, 0.45); }

svg text {
  font-size: 20px;
  font-weight: bold;
  fill: white;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.5);
  stroke-width: 3px;
  pointer-events: none;
}

/* 運動圖示 */

.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.icon-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  min-height: 110px;
  padding: 0.75rem;
  border: 3px solid #e6e6e6;
  border-radius: 14px;
  background: white;
  cursor: pointer;
  font-size: 1rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

  .icon-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(10, 92, 120, 0.18);
  }

  .icon-button img { width: 56px; height: 56px; }
  .icon-button.selected { border-color: #14919b; background: #e3f4fb; }

/* 據點卡片 */

.venue-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.1rem;
  margin: 1rem 0;
}

.venue-card {
  border: 1px solid #eee;
  border-radius: 14px;
  padding: 1.1rem;
  background: white;
  box-shadow: 0 3px 12px rgba(10, 92, 120, 0.08);
  border-left: 5px solid #14919b;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

  .venue-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(10, 92, 120, 0.15);
  }

.venue-photo {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
  border-radius: 10px;
  margin-bottom: 0.7rem;
}

.venue-type { font-size: 0.85em; color: #666; }

.course-card { border-top: 1px dashed #ddd; margin-top: 0.6rem; padding-top: 0.6rem; }
.course-line { margin: 0 0 0.3rem; }
.course-detail-line { font-size: 0.9em; color: #555; margin: 0.15rem 0; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85em;
  font-weight: bold;
  background: color-mix(in srgb, var(--status-color) 15%, white);
  color: var(--status-color);
  border: 1.5px solid var(--status-color);
  margin-right: 0.5rem;
  vertical-align: middle;
}

/* 首頁目錄 */

.directory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.2rem;
  margin: 1.5rem 0;
}

.directory-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.4rem;
  background: white;
  border: 1px solid #eee;
  border-left: 5px solid #14919b;
  border-radius: 14px;
  box-shadow: 0 3px 12px rgba(10, 92, 120, 0.08);
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

  .directory-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(10, 92, 120, 0.18); }
  .directory-card h3 { margin: 0; color: #0a5c78; }
  .directory-card p { margin: 0; color: #444; font-size: 0.95rem; }
  .directory-icon { font-size: 2rem; line-height: 1; }
  .directory-more { margin-top: auto; padding-top: 0.4rem; font-weight: bold; color: #14919b; }

  .directory-preview-line { color: #666 !important; font-size: 0.85em !important; }

  .directory-thumbs { display: flex; gap: 0.4rem; }
    .directory-thumbs img { flex: 1 1 0; min-width: 0; height: 60px; object-fit: cover; border-radius: 8px; }

/* 公告 / 常見問題 */

.post-list { display: flex; flex-direction: column; gap: 1rem; }

.post-card {
  display: flex;
  gap: 1rem;
  align-items: center;
  border: 1px solid #eee;
  border-radius: 14px;
  padding: 1rem;
  text-decoration: none;
  color: inherit;
  background: white;
  box-shadow: 0 3px 12px rgba(10, 92, 120, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

  .post-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(10, 92, 120, 0.15);
  }

  .post-card img { width: 80px; height: 80px; object-fit: cover; border-radius: 10px; flex-shrink: 0; }

.post-date { color: #666; font-size: 0.9em; }
.post-content { white-space: pre-wrap; line-height: 1.7; }
.post-detail-image { max-width: 100%; border-radius: 14px; box-shadow: 0 4px 15px rgba(10, 92, 120, 0.15); }

/* 活動成果集 */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.gallery-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border: none;
  border-radius: 14px;
  overflow: hidden;
  padding: 0;
  cursor: pointer;
  background: #eee;
  box-shadow: 0 3px 12px rgba(10, 92, 120, 0.12);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

  .gallery-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

  .gallery-thumb:hover, .gallery-thumb:focus {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(10, 92, 120, 0.22);
    outline: none;
  }

  .gallery-caption {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 0.5rem 0.6rem;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.65), transparent);
    color: white;
    font-size: 0.9rem;
    text-align: left;
  }

.lightbox-dialog {
  background: white;
  border-radius: 18px;
  padding: 1.2rem;
  max-width: 640px;
  width: 100%;
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.3);
  text-align: center;
}

  .lightbox-dialog img { max-width: 100%; max-height: 65vh; border-radius: 12px; display: block; margin: 0 auto 0.8rem; }
  .lightbox-dialog p { margin: 0.3rem 0; }

.faq-list { display: flex; flex-direction: column; gap: 0.75rem; }

.faq-item {
  border: 1px solid #eee;
  border-left: 5px solid #f4a261;
  border-radius: 12px;
  padding: 0.85rem 1.1rem;
  background: white;
  box-shadow: 0 3px 10px rgba(10, 92, 120, 0.06);
}

  .faq-item summary { font-weight: bold; cursor: pointer; color: #0a5c78; }

/* 表單 / 按鈕 */

.member-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  width: 100%;
  max-width: 480px;
}

/* 登入頁只有一個表單，內容比 main 卡片窄很多，改成整欄置中，不要貼著卡片左邊 */
.centered-form-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

  .centered-form-page .member-form { text-align: left; }

  .member-form label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: bold; color: #333; }

  .member-form input,
  .member-form select,
  .member-form textarea {
    min-height: 44px;
    font-size: 1rem;
    padding: 0.5rem 0.7rem;
    border: 2px solid #d8d8d8;
    border-radius: 8px;
    font-family: inherit;
    transition: border-color 0.15s ease;
  }

  .member-form input:focus,
  .member-form select:focus,
  .member-form textarea:focus {
    outline: none;
    border-color: #14919b;
  }

.checkbox-line {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-weight: normal;
}

.primary-button, .secondary-button, .danger-button, .back-button {
  display: inline-block;
  min-height: 48px;
  padding: 0.6rem 1.6rem;
  border-radius: 999px;
  font-size: 1.05rem;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  font-family: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.primary-button {
  background: linear-gradient(135deg, #14919b 0%, #0a5c78 100%);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(10, 92, 120, 0.3);
}

  .primary-button:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(10, 92, 120, 0.4); }

.secondary-button { background: white; color: #0a5c78; border: 2px solid #14919b; }
  .secondary-button:hover { background: #e3f4fb; }

.danger-button {
  background: linear-gradient(135deg, #e76f51 0%, #c0392b 100%);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(192, 57, 43, 0.35);
}

  .danger-button:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(192, 57, 43, 0.45); }

/* 自訂確認視窗（取代原生 confirm()） */

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 30, 40, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.confirm-dialog {
  background: white;
  border-radius: 18px;
  padding: 1.8rem;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.3);
  text-align: center;
}

  .confirm-dialog p {
    font-size: 1.15rem;
    font-weight: bold;
    color: #1a1a1a;
    margin: 0 0 1.4rem;
  }

.confirm-buttons {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
}

  .confirm-buttons button { flex: 1; }

/* 後台新增／編輯表單的彈出視窗，跟 .confirm-dialog 共用同一層半透明背景（.confirm-overlay），
   只是內容改成表單，所以要寬一點、允許內部捲動（表單欄位一多，視窗本身不會撐爆畫面） */
.edit-modal-dialog {
  background: white;
  border-radius: 18px;
  padding: 1.8rem;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.3);
  animation: pop-in 0.25s ease-out;
}

.back-button { display: block; margin-bottom: 1rem; color: #0a5c78; font-weight: bold; border: none; padding: 0; background: none; transition: color 0.15s ease; }
  .back-button:hover { color: #14919b; text-decoration: underline; }

.error-text { color: #c0392b; font-weight: bold; }
.success-text { color: #2a9d5f; font-weight: bold; }

/* 搜尋篩選 */

.search-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.2rem;
  padding: 1rem;
  background: #f3fafc;
  border-radius: 14px;
}

  .search-filters label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: bold; color: #333; }

  .search-filters input,
  .search-filters select {
    min-height: 44px;
    padding: 0.5rem 0.7rem;
    font-size: 1rem;
    border: 2px solid #d8d8d8;
    border-radius: 8px;
  }

/* 滾動三力學運動地圖：找不到符合篩選條件的據點時，改顯示「還沒開課」呼籲區塊 */

.map-cta {
  margin-top: 1rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, #e3f4fb 0%, #fdf6ea 100%);
  border-radius: 16px;
  text-align: center;
}

  .map-cta h3 { margin-top: 0; color: #0a5c78; }

.map-cta-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  justify-content: center;
  margin-top: 1rem;
}

/* 後台管理 */

.admin-nav { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }

  .admin-nav a {
    display: block;
    padding: 1rem 1.2rem;
    border: 1px solid #eee;
    border-left: 5px solid #0a5c78;
    border-radius: 12px;
    text-decoration: none;
    font-size: 1.1rem;
    color: #0a5c78;
    font-weight: bold;
    background: white;
    box-shadow: 0 3px 10px rgba(10, 92, 120, 0.08);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
  }

  .admin-nav a:hover {
    transform: translateY(-2px) translateX(2px);
    box-shadow: 0 6px 16px rgba(10, 92, 120, 0.15);
  }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.2rem;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 3px 12px rgba(10, 92, 120, 0.08);
}

  .admin-table th {
    background: #0a5c78;
    color: white;
    padding: 0.7rem 0.6rem;
    text-align: left;
  }

  .admin-table td { border-bottom: 1px solid #eee; padding: 0.6rem; text-align: left; }
  .admin-table tr:last-child td { border-bottom: none; }
  .admin-table tr:nth-child(even) td { background: #f7fbfc; }
  .admin-table button { min-height: 36px; margin-right: 0.4rem; }

/* 表格在手機上容易被內容撐爆，讓它可以左右滑動而不會把整頁版面擠壞 */
.table-scroll {
  overflow-x: auto;
  border-radius: 12px;
  margin-bottom: 1.2rem;
}

  .table-scroll .admin-table { margin-bottom: 0; min-width: 480px; }

/* 手機版微調 */

@media (max-width: 640px) {
  main {
    margin: 0.75rem auto 2rem;
    padding: 1.1rem 1.1rem 1.8rem;
    border-radius: 14px;
  }

  .nav-bar { padding: 0.75rem 1rem; }
  .nav-brand { font-size: 1.05rem; }
  .nav-logo { height: 34px; width: auto; }
  .nav-links { gap: 0.5rem; right: 1rem; min-width: 200px; }
  .nav-links a { font-size: 0.9rem; padding: 0.25rem 0.45rem; }

  h1 { font-size: 1.5em; }

  .icon-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }

  /* venue-list 最小欄寬 280px、directory-grid 260px，比很多手機的可用寬度還寬，
     沒有這個覆寫的話欄位撐不下去會把整頁往右推出去，變成要橫向捲動才看得到內容 */
  .venue-list, .directory-grid { grid-template-columns: 1fr; }

  /* 手機地圖太小很難點準，把地圖區塊的內距縮小，讓地圖本身盡量畫大一點 */
  .map-wrap { padding: 0.5rem; }
  main:has(.map-wrap) { padding-left: 0.6rem; padding-right: 0.6rem; }

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

  /* 手機螢幕窄，本島地圖填滿整個容器寬度後，左上角剛好對齊望安/七美縮圖原本疊放的位置，
     縮圖會蓋住西嶼鄉/白沙鄉的圖形；改成不疊加、平移到地圖上方的一排，就不會再互相遮到 */
  .map-container { display: flex; flex-direction: column; }
  .map-insets {
    position: static;
    order: -1;
    flex-direction: row;
    justify-content: center;
    gap: 0.8rem;
    margin-bottom: 0.6rem;
  }
  .map-inset { width: 100px; height: 100px; }
  .map-inset-label { font-size: 0.8rem; bottom: 4px; }
}

/* 動畫效果：只在進場、互動當下播放一次，不做持續循環的晃動，
   長輩比較不會因為畫面一直在動而分心或不舒服 */

@keyframes fade-slide-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade-slide-down { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }

.nav-bar { animation: fade-slide-down 0.5s ease-out; }
main { animation: fade-slide-up 0.5s ease-out; }


/* 卡片／清單項目進場淡入，依序錯開，最多做前 8 個以免項目一多要等很久 */
:where(.venue-list, .post-list, .icon-grid, .township-buttons, .faq-list, .gallery-grid, .directory-grid) > *,
.admin-nav > li {
  animation: fade-slide-up 0.45s ease-out both;
}

:where(.venue-list, .post-list, .icon-grid, .township-buttons, .faq-list, .gallery-grid, .directory-grid) > *:nth-child(1), .admin-nav > li:nth-child(1) { animation-delay: 0.02s; }
:where(.venue-list, .post-list, .icon-grid, .township-buttons, .faq-list, .gallery-grid, .directory-grid) > *:nth-child(2), .admin-nav > li:nth-child(2) { animation-delay: 0.06s; }
:where(.venue-list, .post-list, .icon-grid, .township-buttons, .faq-list, .gallery-grid, .directory-grid) > *:nth-child(3), .admin-nav > li:nth-child(3) { animation-delay: 0.10s; }
:where(.venue-list, .post-list, .icon-grid, .township-buttons, .faq-list, .gallery-grid, .directory-grid) > *:nth-child(4), .admin-nav > li:nth-child(4) { animation-delay: 0.14s; }
:where(.venue-list, .post-list, .icon-grid, .township-buttons, .faq-list, .gallery-grid, .directory-grid) > *:nth-child(5), .admin-nav > li:nth-child(5) { animation-delay: 0.18s; }
:where(.venue-list, .post-list, .icon-grid, .township-buttons, .faq-list, .gallery-grid, .directory-grid) > *:nth-child(6), .admin-nav > li:nth-child(6) { animation-delay: 0.22s; }
:where(.venue-list, .post-list, .icon-grid, .township-buttons, .faq-list, .gallery-grid, .directory-grid) > *:nth-child(7), .admin-nav > li:nth-child(7) { animation-delay: 0.26s; }
:where(.venue-list, .post-list, .icon-grid, .township-buttons, .faq-list, .gallery-grid, .directory-grid) > *:nth-child(n+8), .admin-nav > li:nth-child(n+8) { animation-delay: 0.30s; }

/* 按鈕按下的觸覺回饋 */
.primary-button:active, .secondary-button:active, .danger-button:active,
.township-button:active, .icon-button:active, .font-size-controls button:active {
  transform: scale(0.96);
}

.icon-button.selected { animation: pop-in 0.25s ease-out; }

.confirm-overlay { animation: fade-in 0.2s ease-out; }
.confirm-dialog, .lightbox-dialog { animation: pop-in 0.25s ease-out; }

/* 尊重系統「減少動態效果」設定，開啟該選項的使用者完全關閉動畫 */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
