/* ==========================================================================
   RWD 與版面修正（前端）
   - 載入順序在 styles.css 之後，只做覆寫，不改原型樣式檔
   - 斷點沿用 styles.css：1100 / 820 / 760 / 560
   ========================================================================== */

/* ---------- 共用 ---------- */

img,
video,
iframe {
  max-width: 100%;
}

/* 內容區的表格在窄螢幕可左右捲動，不被卡片裁切 */
.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* 鍵盤操作時看得到焦點 */
a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--gold, #b99552);
  outline-offset: 2px;
}

/* 減少動態：只關平滑捲動與轉場；輪播用 keyframes 控制透明度，不能直接停掉，否則圖片會消失 */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: .01ms !important;
  }
}

/* ---------- 主選單：桌機 ---------- */

.nav-toggle {
  display: none;
}

/* 觸控裝置點擊展開（桌機寬度的平板沒有 hover） */
.nav-item.is-open .dropdown {
  visibility: visible;
  opacity: 1;
  transform: translate(-50%, 0);
}

.nav-trigger {
  cursor: pointer;
}

/* ---------- 主選單：手機／平板 ----------
   桌機選單全部展開約需 1220px，1240 以下改用漢堡選單（同步修改 site.js 的 mobileQuery） */

@media (max-width: 1240px) {
  .site-header {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    min-height: 64px;
    padding: 10px clamp(14px, 4vw, 32px);
  }

  .brand {
    order: 0;
    min-width: 0;
    gap: 10px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .brand strong {
    font-size: 17px;
  }

  .brand small {
    font-size: 12px;
  }

  .header-social {
    order: 1;
    margin-right: 0;
    margin-left: auto;
  }

  .site-header .header-social a {
    width: 40px;
    height: 40px;
  }

  .nav-toggle {
    position: relative;
    order: 2;
    display: inline-block;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    padding: 0;
    color: var(--heritage-green-deep, #294b3d);
    background: transparent;
    border: 1px solid rgba(41, 75, 61, .28);
    border-radius: 999px;
    cursor: pointer;
  }

  .nav-toggle-bar {
    position: absolute;
    top: calc(50% - 1px);
    left: calc(50% - 10px);
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform .2s ease, opacity .2s ease;
  }

  .nav-toggle-bar:nth-child(1) {
    transform: translateY(-7px);
  }

  .nav-toggle-bar:nth-child(3) {
    transform: translateY(7px);
  }

  .is-menu-open .nav-toggle-bar:nth-child(1) {
    transform: rotate(45deg);
  }

  .is-menu-open .nav-toggle-bar:nth-child(2) {
    opacity: 0;
  }

  .is-menu-open .nav-toggle-bar:nth-child(3) {
    transform: rotate(-45deg);
  }

  .main-nav {
    order: 3;
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0;
    max-height: calc(100vh - 64px);
    max-height: calc(100dvh - 64px);
    margin: 0 calc(clamp(14px, 4vw, 32px) * -1);
    padding: 4px clamp(14px, 4vw, 32px) 24px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-top: 1px solid rgba(41, 75, 61, .14);
  }

  .site-header.is-menu-open .main-nav {
    display: flex;
  }

  .site-header .main-nav {
    align-items: stretch;
    justify-content: flex-start;
  }

  .site-header .main-nav .nav-item {
    display: block;
    width: 100%;
    border-bottom: 1px solid rgba(41, 75, 61, .12);
  }

  .site-header .main-nav .nav-trigger,
  .site-header .main-nav .nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: auto;
    min-height: 54px;
    padding: 14px 4px;
    font-size: 18px;
    line-height: 1.4;
    text-align: left;
  }

  /* 手機不吃 hover 色塊，避免點過後一直反白 */
  .nav-item:hover > .nav-trigger,
  .nav-item:focus-within > .nav-trigger,
  .nav-item:hover > a,
  .nav-item:focus-within > a {
    color: inherit;
    background: transparent;
  }

  button.nav-trigger::after {
    width: 9px;
    height: 9px;
    margin-left: 12px;
    content: "";
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translate(-2px, -2px);
    transition: transform .2s ease;
  }

  .nav-item.is-open > button.nav-trigger::after {
    transform: rotate(-135deg) translate(-2px, -2px);
  }

  .site-header .dropdown,
  .site-header .nav-item:hover .dropdown,
  .site-header .nav-item:focus-within .dropdown,
  .site-header .nav-item.is-open .dropdown {
    position: static;
    display: none;
    width: auto;
    min-width: 0;
    padding: 0 0 10px 12px;
    visibility: visible;
    opacity: 1;
    background: transparent;
    border: 0;
    box-shadow: none;
    transform: none;
    transition: none;
  }

  .site-header .nav-item.is-open .dropdown {
    display: grid;
  }

  .dropdown::before {
    display: none;
  }

  .dropdown a {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 46px;
    padding: 10px 12px;
    font-size: 16px;
  }

  html.is-menu-locked,
  html.is-menu-locked body {
    overflow: hidden;
  }
}

@media (max-width: 560px) {
  /* 小手機：社群按鈕收進選單底部，標頭只留品牌與選單鈕 */
  .header-social {
    order: 4;
    display: none;
    flex-basis: 100%;
    justify-content: flex-start;
    margin-left: 0;
    padding: 4px 0 8px;
  }

  .is-menu-open .header-social {
    display: inline-flex;
  }

  .nav-toggle {
    margin-left: auto;
  }

  .brand small {
    font-size: 11px;
  }
}

/* ---------- 首頁：主視覺與快速資訊 ---------- */

@media (max-width: 820px) {
  .hero {
    padding-top: 80px;
  }
}

@media (max-width: 560px) {
  .hero {
    padding-top: 40px;
  }

  .hero-content {
    padding: 48px 4px 32px;
  }

  .hero .quick-info {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero .weather-card {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: auto auto minmax(0, 1fr);
    align-items: center;
    gap: 12px 14px;
  }

  .hero .weather-card .weather-text {
    width: auto;
    min-width: 0;
    writing-mode: horizontal-tb;
  }

  .hero .weather-card .today-hours {
    grid-column: 1 / -1;
    justify-self: stretch;
    width: auto;
    margin: 0;
    padding-top: 10px;
    padding-left: 0;
    text-align: left;
    border-top: 1px solid rgba(255, 255, 255, .22);
    border-left: 0;
  }

  .hero .quick-info > a {
    min-height: 0;
    padding: 18px 10px;
  }
}

/* ---------- 首頁：活動消息清單 ---------- */

@media (max-width: 1400px) {
  /* styles.css 後段的 translateX(90px) 蓋掉了 1100 斷點的重設；
     且 1400 以下右移 90px 會讓箭頭超出畫面被裁掉，一併取消 */
  .latest-news .news-rows {
    transform: none;
  }
}

@media (max-width: 820px) {
  .news-rows > a {
    grid-template-columns: auto 72px minmax(0, 1fr) 20px;
  }

  .news-rows time {
    min-width: 52px;
  }
}

@media (max-width: 560px) {
  .news-rows > a {
    grid-template-columns: auto minmax(0, 1fr) 18px;
    gap: 14px;
    min-height: 0;
  }

  .news-rows time {
    min-width: 48px;
    font-size: 22px;
  }

  .news-rows strong {
    font-size: 16px;
    line-height: 1.5;
  }
}

/* ---------- 首頁：沉浸式影片 ---------- */

/* 「點擊觀看沉浸式影片預告」原本貼齊右下角，壓到下方的展區說明文字；
   改放在播放鈕正下方置中 */
.immersive-carousel .video-caption {
  top: calc(50% + 60px);
  right: auto;
  bottom: auto;
  left: 50%;
  max-width: calc(100% - 32px);
  white-space: nowrap;
  transform: translateX(-50%);
}

.experience-visual figcaption {
  z-index: 3;
  pointer-events: none;
}

@media (max-width: 560px) {
  .experience-visual {
    min-height: 360px;
  }

  .immersive-carousel .video-play {
    width: 64px;
    height: 64px;
    font-size: 24px;
  }

  .immersive-carousel .video-caption {
    top: calc(50% + 44px);
    padding: 8px 14px;
    font-size: 14px;
  }

  .experience-visual figcaption {
    right: 20px;
    bottom: 18px;
    left: 20px;
    gap: 2px;
  }

  .experience-content h2 {
    font-size: 34px;
    line-height: 1.25;
    text-wrap: balance;
  }
}

/* ---------- 歷史沿革：發展軌跡 ---------- */

@media (max-width: 760px) {
  .history-track-board {
    padding: 28px 18px;
  }

  .history-track-board h2 {
    margin-bottom: 22px;
    font-size: 28px;
  }

  /* 橫向色帶在手機改為：時期標籤一列 + 直式節點清單 */
  .history-track-line {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 0;
  }

  .history-track-line::before {
    display: none;
  }

  .track-era {
    position: static;
    width: auto !important;
    height: auto;
    padding: 6px 14px;
    background: #b77842;
    border-radius: 999px;
    font-size: 15px;
    transform: none;
  }

  .track-era:nth-of-type(1) {
    background: #c58c58;
  }

  .track-era:nth-of-type(n + 3) {
    background: #884323;
  }

  .track-point,
  .point-top,
  .point-bottom {
    position: static;
    flex-basis: 100%;
    width: 100%;
    margin-top: 6px;
    padding: 4px 0 4px 14px;
  }

  .track-era + .track-point,
  .track-era ~ .track-point:first-of-type {
    margin-top: 18px;
  }

  .track-point strong {
    margin-top: 2px;
    font-size: 15px;
  }

  /* 下方年份段落 */
  .history-story-timeline {
    padding-left: 26px;
  }

  .history-story-timeline::before {
    left: 6px;
  }

  .history-story-item {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .history-story-content h2 {
    font-size: 24px;
  }

  .history-image-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-image-row img {
    width: 100%;
    height: 120px;
    object-fit: cover;
  }
}

/* ---------- 媒體報導卡片 ---------- */

/* 原本為 1fr（= minmax(auto, 1fr)），單行省略的摘要會把卡片撐到 900px 寬；
   改為 minmax(0, 1fr)，欄數不變 */
.park-intro-layout .park-spot-list {
  grid-template-columns: minmax(0, 1fr);
}

@media (max-width: 720px) {
  .media-report-card h3 {
    font-size: 24px;
    line-height: 1.3;
  }
}

/* ---------- 地圖：點圖開原圖 ---------- */

.map-zoom-link {
  position: relative;
  display: block;
  cursor: zoom-in;
}

.map-zoom-hint {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: none;
  padding: 6px 12px;
  color: #fff;
  background: rgba(30, 37, 33, .72);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  pointer-events: none;
}

@media (max-width: 820px) {
  .map-zoom-hint {
    display: inline-block;
  }
}

/* ---------- 景點／設施卡片圖片：手機限制高度，直式照片不佔滿整個螢幕 ---------- */

@media (max-width: 560px) {
  .park-spot-card .park-spot-body img {
    width: 100%;
    max-height: 260px;
    object-fit: cover;
  }
}

/* ---------- 展覽頁：預告圖覆蓋文字 ---------- */

@media (max-width: 560px) {
  /* 手機上圖片太矮，播放鈕、標題、說明文字會互相壓到 */
  .video-preview-frame img {
    min-height: 260px;
  }

  .video-preview-overlay {
    padding: 16px;
    gap: 8px;
  }

  .video-preview-overlay span {
    width: 60px;
    height: 60px;
    font-size: 24px;
  }

  .video-preview-overlay strong {
    font-size: 22px;
    line-height: 1.3;
  }

  .video-preview-overlay small {
    font-size: 14px;
    line-height: 1.5;
  }
}

/* ---------- 聯絡資訊：長 email 在小螢幕換行 ---------- */

.info-tile {
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 420px) {
  .media-report-card h3 {
    font-size: 20px;
  }
}

/* ---------- 內頁卡片 ---------- */

@media (max-width: 560px) {
  .subpage-card {
    padding: 22px 18px;
  }
}

/* ---------- 票價表：手機改為卡片 ---------- */

@media (max-width: 760px) {
  .ticket-price-table-wrap {
    overflow: visible;
  }

  .ticket-price-table-wrap .ticket-price-table,
  .ticket-price-table tbody,
  .ticket-price-table tr,
  .ticket-price-table td {
    display: block;
    width: 100%;
    min-width: 0;
    white-space: normal;
  }

  .ticket-price-table thead {
    display: none;
  }

  .ticket-price-table tr {
    margin-bottom: 14px;
    padding: 14px 16px;
    background: rgba(255, 253, 247, .9);
    border: 1px solid rgba(80, 105, 90, .18);
    border-radius: 14px;
  }

  .ticket-price-table td {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 10px;
    padding: 6px 0;
    text-indent: 0;
    border: 0;
    text-align: left;
  }

  .ticket-price-table td::before {
    color: var(--muted, #697068);
    content: attr(data-label);
    font-size: 14px;
    font-weight: 700;
  }

  .ticket-price-table td:first-child {
    font-size: 18px;
    font-weight: 800;
  }

  .ticket-price-table td:empty {
    display: none;
  }
}

/* ---------- 頁尾 ---------- */

.site-footer > * {
  min-width: 0;
}

.footer-address,
.site-footer a[href^="mailto:"] {
  overflow-wrap: anywhere;
}

@media (max-width: 820px) {
  .site-footer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 36px 28px;
  }

  .footer-hours,
  .footer-social,
  .footer-contact {
    transform: none;
  }
}

@media (max-width: 560px) {
  .site-footer {
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
    padding: 56px 20px 24px;
  }

  .footer-brand strong {
    white-space: nowrap;
  }

  .footer-kicker {
    letter-spacing: .12em;
  }

  .footer-phone {
    font-size: 28px;
  }

  .footer-hours p {
    grid-template-columns: 6em minmax(0, 1fr);
  }

  .footer-social {
    justify-content: flex-start;
  }
}

/* sticky 元素的 top 值配合手機版較矮的標頭 */
@media (max-width: 1240px) {
  .history-year {
    top: 80px;
  }
}
