/**
 * 全站 Premium Header / Footer 樣式（site-wide，非 body.home 收斂）。
 * 由 child theme header.php / footer.php 於所有頁面輸出，故樣式需全站套用。
 * 數值與 home-premium.css 的首頁 header 一致；另含一般下拉(.has-dropdown)與頁尾樣式。
 * 變數(:root)與字體沿用 home-premium.css / Google Fonts（皆全站載入）。
 */

.noise { pointer-events: none; }

/* ① 頂部資訊條 topline */
.topline {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: center;
  padding: 9px clamp(18px, 5vw, 72px);
  color: rgba(255, 255, 255, .78);
  background: var(--deep);
  font-size: 13px;
  letter-spacing: .02em;
}
.topline span:nth-child(2) { color: #fff; font-weight: 800; }
.topline span:last-child { text-align: right; }

/* ② 主導航 header（sticky 毛玻璃 + scrolled 收縮） */
.header {
  position: sticky;
  top: 0;
  z-index: 90;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 28px;
  align-items: center;
  padding: 20px clamp(18px, 5vw, 72px);
  background: rgba(255, 250, 244, .82);
  border-bottom: 1px solid rgba(231, 221, 210, .72);
  backdrop-filter: blur(20px);
  transition: var(--ease);
  font-family: var(--sans);
}
.header.scrolled {
  padding: 11px clamp(18px, 5vw, 72px);
  background: rgba(255, 250, 244, 0.94);
  box-shadow: 0 10px 30px rgba(32, 24, 22, 0.06);
}
.header .logo { display: inline-flex; align-items: center; }
.header .logo img { width: 168px; height: auto; object-fit: contain; transition: var(--ease); }
.header.scrolled .logo img { width: 148px; }

/* ③ nav + 底線展開動畫 */
.nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(14px, 1.8vw, 26px);
  color: #5e534c;
  font-size: 15px;
  white-space: nowrap;
}
.nav a,
.nav-item > a {
  position: relative;
  padding: 9px 0;
  color: inherit;
  text-decoration: none;
  transition: var(--ease);
  display: inline-block;
}
.nav a::after,
.nav-item > a::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: var(--rose);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.nav a:hover,
.nav-item > a:hover { color: var(--deep); }
.nav a:hover::after,
.nav-item > a:hover::after { transform: scaleX(1); transform-origin: left; }

/* Mega Menu 觸發容器：static 讓 mega 鋪滿 header 寬 */
.nav-item { position: static; }

/* ④ mega-menu 純 CSS hover 下拉 */
.mega-menu {
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: rgba(255, 250, 244, 0.98);
  backdrop-filter: blur(24px);
  border-bottom: 3px solid var(--rose);
  border-top: 1px solid rgba(87, 65, 55, 0.06);
  box-shadow: 0 30px 60px rgba(32, 24, 22, 0.08);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
  z-index: 999;
  padding: 44px clamp(24px, 6vw, 80px) 56px;
}
.has-mega:hover .mega-menu { opacity: 1; visibility: visible; transform: translateY(0); }
/* 安全網：超高的 mega 不溢出視窗，改可捲動 */
.mega-menu { max-height: 78vh; overflow-y: auto; }

/* 扁平葉節點清單（如「醫學美容」18 項）：多欄流排，壓低高度 */
.mega-flat { padding: 36px clamp(24px, 6vw, 80px) 44px; }
.mega-flat-list {
  list-style: none; margin: 0 auto; padding: 0;
  max-width: 1240px; column-gap: 32px;
}
.mega-flat-list li { break-inside: avoid; margin-bottom: 4px; }
.mega-flat-list a {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--sans); font-size: 14px; color: #6e6158;
  text-decoration: none; padding: 6px 0; line-height: 1.4; transition: all 0.28s ease;
}
.mega-flat-list a::before { content: "›"; color: var(--rose); font-weight: 700; }
.mega-flat-list a:hover { color: var(--rose); transform: translateX(4px); }
.mega-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 36px 28px;
  max-width: 1240px;
  margin: 0 auto;
  text-align: left;
}
.mega-col h4,
.mega-col .mega-col-title {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 800;
  color: var(--deep);
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(87, 65, 55, .15);
  letter-spacing: .05em;
}
.mega-col h4 a,
.mega-col .mega-col-title a { color: inherit; text-decoration: none; }
.mega-links { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.mega-links a {
  font-family: var(--sans);
  font-size: 13.5px;
  color: #6e6158;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  transition: all 0.28s ease;
  white-space: normal;
  line-height: 1.4;
}
.mega-links a::before { content: "›"; color: var(--rose); font-weight: 700; font-size: 14px; transition: transform 0.28s ease; }
.mega-links a:hover { color: var(--rose); transform: translateX(4px); }
.mega-links a:hover::before { transform: translateX(2px); }

/* ④b 一般下拉 .has-dropdown（無 multicolumn 的有子項目） */
.nav-item.has-dropdown { position: relative; }
.dropdown {
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%) translateY(12px);
  min-width: 210px;
  list-style: none; margin: 0;
  padding: 16px 20px;
  background: rgba(255, 250, 244, 0.98);
  backdrop-filter: blur(24px);
  border-bottom: 3px solid var(--rose);
  border-top: 1px solid rgba(87, 65, 55, 0.06);
  box-shadow: 0 30px 60px rgba(32, 24, 22, 0.08);
  opacity: 0; visibility: hidden;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
  z-index: 999;
  display: flex; flex-direction: column; gap: 9px; text-align: left;
}
.has-dropdown:hover .dropdown { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
.dropdown a {
  font-size: 14px; color: #6e6158; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 0;
  transition: all 0.28s ease; white-space: nowrap;
}
.dropdown a::before { content: "›"; color: var(--rose); font-weight: 700; }
.dropdown a:hover { color: var(--rose); transform: translateX(4px); }

/* ⑤ actions / search / reserve */
.actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
/* 注意：選擇器須限定於 .actions 內，否則會誤中 WordPress 搜尋結果頁的 body.search */
.actions .search, .actions .reserve {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; border-radius: 999px; font-weight: 900; transition: var(--ease); text-decoration: none;
}
.actions .search { width: 44px; color: var(--deep); border: 1px solid var(--line); background: rgba(255, 255, 255, .48); cursor: pointer; }
.actions .search:hover { background: var(--deep); color: #fff; transform: scale(1.05); }
.actions .reserve { padding: 0 18px; color: #fff; background: var(--deep); cursor: pointer; box-shadow: 0 8px 20px rgba(23, 53, 47, 0.15); }
.actions .reserve:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(23, 53, 47, 0.28); }

/* ⑥ menu-toggle 漢堡鈕 */
.menu-toggle {
  display: none; width: 44px; height: 44px; place-items: center; gap: 5px;
  /* align-content 必須明確置中：grid 的 align-content 預設 normal(=stretch)，
     會把三條 auto 列撐滿 42px，線距變 15.7px（圖示發散、偏移），
     且 [aria-expanded] 的 translateY(6.5px) 收不攏成 X。置中後列高貼齊內容，線距即為 gap+1.5=6.5px。 */
  align-content: center;
  /* 父主題 reset.css 的 [type=button],button { padding:.5rem 1rem } 會吃掉 44px 內距，
     內容框僅剩 10.4px 寬 < 18px 線寬：grid 欄自 content-box 左緣起算並向右溢出＝圖示右偏。
     歸零後欄寬 42.4px，justify-items:center 才真的置中。特異度同為 (0,1,0)，靠後載入奪回。 */
  padding: 0;
  color: var(--deep); background: rgba(255, 255, 255, .48); border: 1px solid var(--line);
  border-radius: 999px; cursor: pointer; transition: var(--ease);
}
/* 三條線為 background: currentColor，故 color 必須守住。
   父主題 reset.css 有 button:hover/:focus 與 [type="button"]:focus { color:#fff }，
   特異度(0,1,1)/(0,2,0) 均壓過 .menu-toggle(0,1,0)：點擊後按鈕留在 :focus，
   線條轉白疊在近白底上＝圖示消失。此處以同特異度(0,2,0)＋後載入奪回。 */
.menu-toggle:hover,
.menu-toggle:focus { color: var(--deep); }
.menu-toggle:hover { background: rgba(255, 255, 255, 0.9); transform: scale(1.05); }
/* 鍵盤操作仍需看得見焦點框（滑鼠點擊不顯示） */
.menu-toggle:focus-visible { outline: 2px solid var(--deep); outline-offset: 2px; }
.menu-toggle span, .menu-toggle::before, .menu-toggle::after {
  content: ""; display: block; width: 18px; height: 1.5px; background: currentColor;
  transition: transform .28s ease, opacity .28s ease;
}
.menu-toggle[aria-expanded="true"] span { opacity: 0; }
.menu-toggle[aria-expanded="true"]::before { transform: translateY(6.5px) rotate(45deg); }
.menu-toggle[aria-expanded="true"]::after { transform: translateY(-6.5px) rotate(-45deg); }

/* ⑦ mobile-menu 桌面預設隱藏 */
.mobile-menu { display: none; }

/* ===================================================================
 * FOOTER（深綠四欄）
 * =================================================================== */
.site-footer-premium { background: var(--deep); color: rgba(255, 255, 255, .82); font-family: var(--sans); }
.footer-inner {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1.3fr 1fr;
  gap: 40px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 72px clamp(20px, 5vw, 72px) 48px;
}
.footer-logo img { width: 160px; height: auto; filter: brightness(0) invert(1); opacity: .92; }
.footer-tagline { color: var(--clay); font-family: var(--display); font-size: 18px; margin: 16px 0 10px; }
.footer-note { color: rgba(255, 255, 255, .58); font-size: 13.5px; line-height: 1.75; margin: 0; max-width: 320px; }
.footer-title { color: #fff; font-size: 15px; font-weight: 800; letter-spacing: .05em; margin: 0 0 16px; }
.footer-menu, .footer-clinic-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 11px; }
.footer-menu a { color: rgba(255, 255, 255, .72); font-size: 14px; text-decoration: none; transition: color .28s ease; }
.footer-menu a:hover { color: var(--clay); }
.footer-clinic-list li { display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; color: rgba(255, 255, 255, .68); }
.footer-clinic-list strong { color: #fff; font-size: 14px; }
.footer-clinic-list a { color: var(--clay); text-decoration: none; font-weight: 700; }
.footer-contact p { color: rgba(255, 255, 255, .6); font-size: 13.5px; line-height: 1.7; margin: 0 0 14px; }
.footer-cta {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 26px; border-radius: 999px; background: var(--rose); color: #fff;
  font-weight: 800; text-decoration: none; transition: var(--ease);
}
.footer-cta:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(168, 108, 101, .3); }
.footer-bottom {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  max-width: 1320px; margin: 0 auto;
  padding: 22px clamp(20px, 5vw, 72px);
  border-top: 1px solid rgba(255, 255, 255, .12);
  color: rgba(255, 255, 255, .5); font-size: 12.5px;
}

/* ===================================================================
 * RWD（header / footer）
 * =================================================================== */
@media (max-width: 1180px) {
  .nav { display: none; }
  .header { grid-template-columns: 1fr auto; } /* logo 佔滿、actions 靠右對齊邊緣 */
  .actions { justify-content: end; }
  .menu-toggle { display: grid; }
  /* 錨定於 .header（sticky＝containing block），跟著頁首高度走。
     不可用 fixed+固定 top：topline 於 ≤720px 會斷成三行，頁首實高隨之改變，
     寫死的 top 會讓選單躲進頁首底下（且 z-index 70 < .header 90 被蓋住）。
     置於 header 內後同屬其堆疊脈絡，天然疊在頁首背景之上，與 .mega-menu 作法一致。 */
  .mobile-menu {
    position: absolute;
    top: calc(100% + 8px); right: 14px; left: 14px;
    z-index: 95;
    display: grid;
    max-height: 70vh;
    padding: 12px;
    overflow: auto;
    background: rgba(255, 250, 244, .96);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(32, 24, 22, .16);
    backdrop-filter: blur(18px);
    opacity: 0; pointer-events: none;
    transform: translateY(-10px);
    transition: opacity .24s ease, transform .24s ease;
  }
  .mobile-menu.is-open { opacity: 1; pointer-events: auto; transform: translateY(0); }
  .mobile-menu a { padding: 13px 12px; color: var(--ink); text-decoration: none; border-bottom: 1px solid rgba(87, 65, 55, .12); font-weight: 800; }
  .mobile-menu a:last-child { border-bottom: 0; }
  .footer-inner { grid-template-columns: 1fr 1fr; gap: 32px; }
}

@media (max-width: 720px) {
  .topline { grid-template-columns: 1fr; gap: 2px; text-align: left; }
  .topline span:last-child { text-align: left; }
  .header { padding: 12px 18px; }
  .header .logo img { width: 132px; }
  .header.scrolled .logo img { width: 132px; }
  .reserve { display: none; }
  .footer-inner { grid-template-columns: 1fr; gap: 28px; padding: 56px 24px 40px; }
  .footer-bottom { flex-direction: column; }
}
