/* components.css — 跨頁共用元件：Header（單一 nav 漢堡選單）/ 按鈕 / Footer */

/* ---- Header ---- */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--color-header);
}
.site-header__inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 2;
}
.site-logo img {
  width: var(--logo-w);
}

.global-nav__list a {
  display: block;
  transition: color 0.25s;
}
.global-nav__list a:hover {
  color: var(--color-orange);
}
.sub-toggle {
  display: none;
}

/* 漢堡按鈕（桌機隱藏） */
.menu-button {
  display: none;
  position: relative;
  width: 2.5rem;
  height: 2.5rem;
}
.menu-button span {
  position: absolute;
  left: 50%;
  width: 1.5rem;
  height: 1px;
  background: var(--color-note);
  transform: translateX(-50%);
  transition:
    transform 0.3s,
    opacity 0.3s;
}
.menu-button span:nth-child(1) {
  top: 30%;
}
.menu-button span:nth-child(2) {
  top: 50%;
}
.menu-button span:nth-child(3) {
  top: 70%;
}
.is-menu-open .menu-button span:nth-child(1) {
  top: 50%;
  transform: translateX(-50%) rotate(45deg);
}
.is-menu-open .menu-button span:nth-child(2) {
  opacity: 0;
}
.is-menu-open .menu-button span:nth-child(3) {
  top: 50%;
  transform: translateX(-50%) rotate(-45deg);
}

/* ---- 按鈕 ---- */
.btn-outline {
  display: inline-block;
  min-width: 9em;
  padding: 0.4em 1.5em;
  text-align: center;
  border: 1px solid var(--color-orange);
  border-radius: 999px;
  transition: all 0.25s;
}
.btn-outline:hover {
  background: var(--color-orange);
  color: var(--color-white);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgb(244, 122, 90, 0.18);
}

/* ---- Footer ---- */
.site-footer {
  background: var(--color-footer);
}
.site-footer__inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-md);
}
.site-footer__brand {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: var(--space-sm);
}
.site-footer__logo {
  width: var(--logo-w);
}
.site-footer__brand-name {
  font-size: var(--fs-text-lg);
}
.site-footer__right {
  text-align: right;
}

.site-footer__inner .text-caption p {
  font-size: var(--fs-caption);
}

/* ==========================================
   Media Queries (媒體查詢樣式)
   ========================================== */

/* ---- 桌機（768px 以上）：hover 效果 ----
   橘字 #EE7959／橘線 1pt（寬度依各選單文字）／灰線 180px × 1pt #D1CFCD */
@media (min-width: 768px) {
  .global-nav {
    height: 100%;
  }
  .global-nav__list {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    height: 100%;
  }
  .global-nav__item {
    position: relative;
    display: flex;
    align-items: center;
  }

  /* 主選單：hover / focus / 子選單開啟時，文字轉橘並由左向右展開橘線 */
  .global-nav__item > a {
    position: relative;
  }
  .global-nav__item > a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: calc(
      100% - 0.06em
    ); /* 與各選單文字等長（扣掉 letter-spacing 尾端空白） */
    border-bottom: 1pt solid var(--color-orange);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
  }
  .global-nav__item > a:hover::after,
  .global-nav__item > a:focus-visible::after,
  .global-nav__item:focus-within > a::after,
  .global-nav__item:hover > a::after {
    transform: scaleX(1);
  }
  .global-nav__item:hover > a,
  .global-nav__item:focus-within > a {
    color: var(--color-orange);
  }

  /* 下拉面板：白底，貼齊 Header 下緣，以父層選單為中心 */
  .global-nav__sub {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    /* 上緣 = 選單文字底部再往下一小段，使面板疊進 Header 但不蓋到文字 */
    top: calc(
      50% + var(--fs-nav) * var(--lh-body) / 2 + var(--space-2xs) +
        var(--space-xs)
    );
    width: max-content;
    min-width: calc(180px + var(--space-sm) * 2); /* 至少容納 180px 灰線 */
    padding: var(--space-2xs) var(--space-sm);
    background: var(--color-header);
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition:
      opacity 0.25s,
      visibility 0.25s;
  }
  .global-nav__item:hover > .global-nav__sub,
  .global-nav__item:focus-within > .global-nav__sub {
    opacity: 1;
    visibility: visible;
  }
  .global-nav__sub a {
    padding-block: var(--space-xs);
  }

  /* 項目之間的灰線：180px × 1pt */
  .global-nav__sub li + li::before {
    content: "";
    display: block;
    width: 180px;
    margin-inline: auto;
    border-top: 1pt solid var(--color-line);
  }

  /* footer 項目之間的間距 */
  .site-footer__inner .text-caption {
    display: flex;
    flex-direction: column;
    gap: var(--space-2xs);
  }
}

/* ---- 768px 以下：同一個 nav 變成全版抽屜 / Footer 樣式 ---- */
@media (max-width: 768px) {
  .menu-button {
    display: block;
  }
  .global-nav {
    position: fixed;
    inset: var(--header-h) 0 0 0;
    z-index: 1;
    background: var(--color-bg);
    border-top: 1px solid var(--color-line);
    padding: 0 var(--space-md);
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transition:
      opacity 0.3s,
      visibility 0.3s;
  }
  .is-menu-open .global-nav {
    opacity: 1;
    visibility: visible;
  }
  .global-nav__list {
    display: block;
  }
  .global-nav__item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    border-bottom: 1px solid var(--color-line);
  }
  .global-nav__list > li > a {
    flex: 1;
    padding-block: var(--space-md);
    font-size: var(--fs-text-md);
  }
  .sub-toggle {
    display: block;
    width: 2.5rem;
    height: 2.5rem;
    position: relative;
  }
  .sub-toggle::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 40%;
    width: 0.7rem;
    height: 0.7rem;
    border: solid var(--color-note);
    border-width: 0 1px 1px 0;
    transform: translateX(-50%) rotate(45deg);
    transition: transform 0.3s;
  }
  .sub-toggle[aria-expanded="true"]::before {
    top: 55%;
    transform: translateX(-50%) rotate(-135deg);
  }
  .global-nav__sub {
    position: static;
    transform: none;
    opacity: 1;
    visibility: visible;
    width: 100%;
    display: none;
    text-align: left;
    padding: 0 0 var(--space-sm) var(--space-sm);
    background: none;
    border-top: 0;
  }
  .global-nav__sub.is-open {
    display: block;
  }
  .global-nav__sub a {
    padding-block: var(--space-xs);
    color: var(--color-note);
    font-size: var(--fs-text-sm);
  }

  /* Footer 響應式 */
  .site-footer__inner {
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
  }
  .separatorLine {
    position: absolute;
    top: 26px;
    bottom: 0;
    left: 0;
    right: 0;
    width: 85%;
    height: 2px;
    background-color: #adadad;
    margin: auto;
  } 
  .site-footer__brand {
    justify-content: center;
  }
  .site-footer__right {
    text-align: center;
  }
}