/* ==========================================================================
   前台共用樣式 — 頁首、頁尾、按鈕、表單
   尺寸皆為設計稿量得的數值 × --u（見 tokens.css）

   與雛形的差異：
   1. 頁首改為固定式（沿用本站既有的 syncContentOffset 推開 #content 機制）
   2. 補上手機抽屜選單與會員下拉的外觀（雛形只畫了漢堡鍵）
   3. .btn / .field / .select 收斂在 .s2 內，避免與 Bootstrap 4 同名元件互相覆蓋
   ========================================================================== */

/* --------------------------------------------------------------- 頁首 */

/* 用 ID 提高權重，蓋掉 frontref/css/all.css 的 navbar 樣式 */
#header_apply {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1030;
  padding: 0;
  border: 0;
  background: var(--white);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.gov-header {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  min-height: calc(90 * var(--u));
  background: var(--white);
}

.gov-header__brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: calc(24 * var(--u));
  padding: 0 calc(40 * var(--u)) 0 calc(56 * var(--u));
  background: var(--blue);
  color: #fff;
  text-decoration: none;
  /* 避免 hover 時 underline / 色票跳動造成整塊 logo 區變形 */
  transition: none;
}

.gov-header__brand:hover,
.gov-header__brand:focus,
.gov-header__brand:active {
  color: #fff;
  background: var(--blue);
  text-decoration: none;
  transform: none;
}

#header_apply .gov-header__brand,
#header_apply .gov-header__brand:hover,
#header_apply .gov-header__brand:focus,
#header_apply .gov-header__brand:active,
#header_apply .gov-header__brand span {
  color: #fff !important;
  text-decoration: none !important;
}

#header_apply .gov-header__brand:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85) !important;
  outline-offset: -4px;
  box-shadow: none !important;
}

/* 市徽字標：寬字距的黑體 + 全大寫英文，重現機關識別 */
.crest__zh {
  display: block;
  color: #fff;
  font-size: calc(30 * var(--u));
  font-weight: 700;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  line-height: 1.2;
  white-space: nowrap;
}

.crest__en {
  display: block;
  font-family: var(--font-num);
  font-size: calc(10 * var(--u));
  font-weight: 500;
  letter-spacing: 0.135em;
  line-height: 1.4;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.9);
}

.gov-header__divider {
  flex-shrink: 0;
  width: 1px;
  height: calc(52 * var(--u));
  background: rgba(255, 255, 255, 0.6);
}

.gov-header__platform {
  color: #fff;
  font-size: calc(20 * var(--u));
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.gov-header__nav {
  display: flex;
  align-items: center;
  gap: calc(36 * var(--u));
  padding: 0 calc(24 * var(--u)) 0 calc(40 * var(--u));
  margin: 0;
  list-style: none;
}

.gov-header__nav .nav-item {
  display: flex;
  align-items: center;
  list-style: none;
}

/* nav-link 是 oss2025-auth.js 與 Oss2025HeaderNavHighlighter 標記 active 的鉤子，
   類名必須保留，這裡只覆蓋 Bootstrap 的外觀 */
.gov-header__nav .nav-link,
.gov-nav__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: calc(7 * var(--u));
  padding: calc(6 * var(--u)) 2px;
  font-size: calc(19 * var(--u));
  font-weight: 500;
  white-space: nowrap;
  color: var(--text);
  text-decoration: none;
  transition: color var(--dur) var(--ease);
}

.gov-header__nav .nav-link::after,
.gov-nav__link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--purple);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur) var(--ease);
}

.gov-header__nav .nav-link:hover,
.gov-nav__link:hover {
  color: var(--purple);
  text-decoration: none;
}

.gov-header__nav .nav-link:hover::after,
.gov-nav__link:hover::after {
  transform: scaleX(1);
}

/* 目前所在頁：底線常駐 */
.gov-header__nav .nav-link.active,
.gov-nav__link.on {
  color: var(--purple);
  font-weight: 700;
}

.gov-header__nav .nav-link.active::after,
.gov-nav__link.on::after {
  transform: scaleX(1);
}

/* 會員鍵：未登入為紫色實心膠囊 */
.gov-header__login {
  display: inline-flex;
  align-items: center;
  gap: calc(7 * var(--u));
  padding: calc(11 * var(--u)) calc(24 * var(--u));
  font-size: calc(19 * var(--u));
  font-weight: 500;
  white-space: nowrap;
  color: #fff !important;
  background: var(--purple);
  border: 1px solid var(--purple);
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.gov-header__login::after {
  display: none;
}

.gov-header__login:hover {
  color: #fff !important;
  background: var(--purple-dark);
  border-color: var(--purple-dark);
  text-decoration: none;
}

/* 登入後：改為淺紫底的姓名鍵 */
.gov-header__nav .oss-auth-user .nav-link {
  padding: calc(9 * var(--u)) calc(20 * var(--u));
  color: var(--purple-dark);
  background: var(--purple-light);
  border: 1px solid #d9cdee;
  border-radius: 999px;
}

.gov-header__nav .oss-auth-user .nav-link::after {
  display: none;
}

.gov-header__nav .oss-auth-user .nav-link:hover {
  background: #e4dbf3;
}

.gov-header__nav .oss-auth-user {
  position: relative;
}

.gov-header__nav .oss-auth-user .dropdown-menu {
  right: 0;
  left: auto;
  padding: calc(8 * var(--u)) 0;
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
}

.gov-header__nav .oss-auth-user .dropdown-item {
  padding: calc(9 * var(--u)) calc(20 * var(--u));
  font-size: calc(16 * var(--u));
  color: var(--text);
}

.gov-header__nav .oss-auth-user .dropdown-item:hover {
  background: var(--purple-xlight);
  color: var(--purple-dark);
}

/* 字級調整：無障礙規範要求的小／中／大三段 */
.gov-header__fonts {
  display: flex;
  gap: calc(4 * var(--u));
}

.gov-header__font-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(30 * var(--u));
  height: calc(30 * var(--u));
  font-size: calc(15 * var(--u));
  color: var(--blue-dark);
  background: var(--white);
  border: 1px solid var(--blue);
  border-radius: 4px;
  text-decoration: none;
}

.gov-header__font-btn:hover {
  color: var(--white);
  background: var(--blue);
  text-decoration: none;
}

.gov-header__font-btn.active {
  color: var(--white);
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.gov-header__burger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  margin-right: 14px;
  align-self: center;
  color: var(--text);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

/* --------------------------------------------------------------- 手機抽屜選單 */

.gov-drawer {
  position: fixed;
  inset: 0;
  z-index: 1040;
  display: none;
}

.gov-drawer.is-open {
  display: block;
}

.gov-drawer__mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.gov-drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(84vw, 320px);
  padding: 18px;
  overflow-y: auto;
  background: var(--white);
  box-shadow: -6px 0 24px rgba(0, 0, 0, 0.18);
}

.gov-drawer__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-left: auto;
  color: var(--text-2);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.gov-drawer__list {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.gov-drawer__list a {
  display: block;
  padding: 14px 6px;
  font-size: 17px;
  color: var(--text);
  border-bottom: 1px solid var(--border-card);
  text-decoration: none;
}

.gov-drawer__list a.active {
  color: var(--purple);
  font-weight: 700;
}

/* --------------------------------------------------------------- 按鈕 */

.s2 .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: calc(8 * var(--u));
  padding: calc(11 * var(--u)) calc(22 * var(--u));
  font-size: calc(17 * var(--u));
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
    color var(--dur) var(--ease);
}

.s2 .btn--primary {
  background: var(--purple);
  border-color: var(--purple);
  color: var(--white);
}

.s2 .btn--primary:hover {
  background: var(--purple-dark);
  border-color: var(--purple-dark);
  color: var(--white);
}

.s2 .btn--success {
  background: var(--green);
  border-color: var(--green);
  color: var(--white);
}

.s2 .btn--success:hover {
  background: var(--green-dark);
  border-color: var(--green-dark);
  color: var(--white);
}

.s2 .btn--harbor {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
  color: var(--white);
}

.s2 .btn--harbor:hover {
  background: #275d8e;
  border-color: #275d8e;
  color: var(--white);
}

.s2 .btn--outline-blue {
  background: var(--white);
  border-color: var(--blue-outline);
  color: var(--blue-outline);
}

.s2 .btn--outline-blue:hover {
  background: var(--blue-light);
  color: var(--blue-outline);
}

.s2 .btn--outline-green {
  background: var(--white);
  border-color: var(--green);
  color: var(--green-dark);
}

.s2 .btn--outline-green:hover {
  background: var(--green-light);
  color: var(--green-dark);
}

.s2 .btn--outline-grey {
  background: var(--white);
  border-color: var(--border);
  color: var(--text-2);
}

.s2 .btn--outline-grey:hover {
  background: var(--bg);
  color: var(--text);
}

.s2 .btn--outline-danger {
  background: var(--white);
  border-color: var(--danger);
  color: var(--danger);
}

.s2 .btn--outline-danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.s2 .btn--sm {
  padding: calc(7 * var(--u)) calc(16 * var(--u));
  font-size: calc(15 * var(--u));
  border-radius: 6px;
}

.s2 .btn--lg {
  padding: calc(14 * var(--u)) calc(28 * var(--u));
  font-size: calc(19 * var(--u));
}

.s2 .btn--block {
  width: 100%;
}

.s2 .btn--pill {
  border-radius: 999px;
}

.s2 .btn:disabled,
.s2 .btn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.s2 .btn__caret {
  font-family: var(--font-num);
  font-size: 0.78em;
  opacity: 0.85;
}

/* --------------------------------------------------------------- 表單 */

.s2 .field {
  margin-bottom: calc(20 * var(--u));
}

.s2 .field__label {
  display: block;
  margin-bottom: calc(9 * var(--u));
  font-size: calc(19 * var(--u));
  font-weight: 500;
  color: var(--text);
}

.s2 .field__label .req {
  margin-left: 3px;
  color: var(--danger);
}

.s2 .input,
.s2 .textarea {
  width: 100%;
  padding: calc(10 * var(--u)) calc(17 * var(--u));
  font-size: calc(18 * var(--u));
  color: var(--text);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.s2 .input:focus,
.s2 .textarea:focus,
.s2 .select select:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(104, 70, 165, 0.15);
  outline: none;
}

.s2 .input::placeholder,
.s2 .textarea::placeholder {
  color: var(--text-muted);
}

.s2 .select {
  position: relative;
}

.s2 .select select {
  width: 100%;
  padding: calc(10 * var(--u)) calc(44 * var(--u)) calc(10 * var(--u)) calc(17 * var(--u));
  font-size: calc(18 * var(--u));
  color: var(--text);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  appearance: none;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.s2 .select__caret {
  position: absolute;
  top: 50%;
  right: calc(16 * var(--u));
  width: calc(17 * var(--u));
  height: calc(17 * var(--u));
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-2);
}

.s2 .hint,
.s2 .field__hint {
  display: block;
  margin-top: calc(5 * var(--u));
  font-size: calc(14 * var(--u));
  line-height: 1.6;
  color: var(--text-2);
}

.s2 .field__error {
  display: block;
  margin-top: calc(5 * var(--u));
  font-size: calc(14 * var(--u));
  line-height: 1.6;
  color: var(--danger);
}

/* 內容短的頁面（身分驗證、送件完成等）原本會在頁尾下方露出 #wrapper 的
   裝飾底圖，改用 flex 讓頁尾自然貼到視窗底部。 */
#wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#content {
  flex: 1 0 auto;
}

/* --------------------------------------------------------------- 頁尾 */

/* frontref/css/sticky-footer-navbar.css 用 body margin-bottom 為絕對定位的舊頁尾
   預留 212~476px。S2 頁尾改為正常流式，這段預留空間必須歸零，
   否則頁尾下方會多出一大塊空白（原規則帶 !important，這裡也需要）。 */
body {
  margin-bottom: 0 !important;
}

#footer,
.site-footer {
  padding: calc(60 * var(--u)) 0 calc(54 * var(--u));
  background: var(--footer);
  color: var(--white);
}

.footer__grid {
  display: grid;
  grid-template-columns: calc(240 * var(--u)) 1fr auto;
  gap: calc(36 * var(--u));
  align-items: start;
  width: min(100% - var(--gutter) * 2, var(--wrap));
  margin: 0 auto;
}

.footer__crest {
  padding-top: calc(28 * var(--u));
  text-align: center;
}

.footer__crest a {
  color: var(--white);
  text-decoration: none;
}

.footer__crest .crest__zh {
  font-size: calc(26 * var(--u));
}

.footer__crest .crest__en {
  font-size: calc(9 * var(--u));
}

.footer__info {
  font-size: calc(16 * var(--u));
  line-height: 2;
  color: var(--footer-text-2);
}

.footer__info strong {
  font-weight: 400;
  color: var(--white);
}

.footer__info-block + .footer__info-block {
  margin-top: calc(24 * var(--u));
}

.footer__gap {
  display: inline-block;
  width: calc(22 * var(--u));
}

.footer__info a {
  color: var(--footer-text-2);
  text-decoration: none;
}

.footer__info a:hover {
  color: var(--white);
  text-decoration: underline;
}

.footer__map {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(24 * var(--u));
  height: calc(24 * var(--u));
  margin-left: calc(8 * var(--u));
  color: var(--white);
  background: rgba(255, 255, 255, 0.16);
  border-radius: 4px;
  vertical-align: middle;
}

.footer__map:hover {
  color: var(--white);
  background: rgba(255, 255, 255, 0.3);
}

.footer__right {
  text-align: right;
}

.footer__policies {
  display: flex;
  gap: calc(12 * var(--u));
  justify-content: flex-end;
  font-size: calc(16 * var(--u));
}

.footer__policies a {
  color: var(--white);
  white-space: nowrap;
  text-decoration: none;
  transition: color var(--dur) var(--ease);
}

.footer__policies a:hover {
  color: var(--footer-link-hover);
  text-decoration: underline;
}

.footer__policies span {
  color: rgba(255, 255, 255, 0.4);
}

.footer__badges {
  display: flex;
  gap: calc(12 * var(--u));
  justify-content: flex-end;
  margin-top: calc(22 * var(--u));
}

.badge-a11y,
.badge-open {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: calc(42 * var(--u));
  padding: 0 calc(11 * var(--u));
  font-family: var(--font-num);
  font-size: calc(10 * var(--u));
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border-radius: 3px;
}

.badge-a11y {
  color: #1b1b1b;
  background: #cddc39;
  border: 1px solid #9aa62b;
}

.badge-a11y b {
  color: #c1272d;
  font-size: calc(12 * var(--u));
}

.badge-open {
  align-items: center;
  color: var(--white);
  background: #1a5fb4;
  border: 1px solid #12468a;
}

/* --------------------------------------------------------------- LINE 浮動鍵 */

.line-fab {
  position: fixed;
  right: calc(26 * var(--u));
  bottom: calc(26 * var(--u));
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(60 * var(--u));
  height: calc(60 * var(--u));
  color: var(--white);
  background: var(--line-green);
  border-radius: 50%;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.24);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.line-fab svg {
  width: 62%;
  height: 62%;
}

.line-fab:hover {
  color: var(--white);
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
}

/* --------------------------------------------------------------- 內頁通用外框 */

.s2-page {
  min-height: 60vh;
  padding: calc(26 * var(--u)) 0 calc(48 * var(--u));
  background: var(--bg);
}

.s2 .wrap {
  width: min(100% - var(--gutter) * 2, var(--wrap));
  margin-inline: auto;
}

.s2 .page-hd {
  margin-bottom: calc(16 * var(--u));
}

.s2 .page-hd h1 {
  font-size: calc(31 * var(--u));
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--blue-dark);
}

.s2 .page-hd p {
  margin-top: calc(4 * var(--u));
  font-size: calc(18 * var(--u));
  color: var(--text-2);
}

.s2 .crumb {
  margin-bottom: calc(10 * var(--u));
  font-size: calc(15 * var(--u));
  color: var(--text-2);
}

.s2 .crumb a {
  color: var(--text-2);
}

.s2 .crumb a:hover {
  color: var(--purple);
  text-decoration: underline;
}

.s2 .crumb span {
  color: var(--blue-dark);
}

/* --------------------------------------------------------------- 捲動揭露 */

/* 只在 JS 可用時才先隱藏，避免關閉 JS 的使用者看到空白頁 */
.js .s2 [data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 520ms var(--ease), transform 520ms var(--ease);
}

.js .s2 [data-reveal].is-revealed {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .js .s2 [data-reveal] {
    opacity: 1;
    transform: none;
  }
}

/* --------------------------------------------------------------- 響應式 */

@media (max-width: 1024px) {
  :root {
    --u: calc(0.86px * var(--font-scale, 1));
    --wrap: 100%;
  }

  .gov-header {
    min-height: 66px;
  }

  .gov-header__brand {
    width: auto;
    gap: 16px;
    padding: 10px 18px;
  }

  .gov-header__nav {
    display: none;
  }

  .gov-header__burger {
    display: flex;
  }

  .footer__grid {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .footer__crest {
    padding-top: 0;
    text-align: left;
  }

  .footer__right {
    text-align: left;
  }

  .footer__policies,
  .footer__badges {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  :root {
    --u: calc(0.82px * var(--font-scale, 1));
  }

  .crest__zh {
    font-size: 19px;
    letter-spacing: 0.1em;
    text-indent: 0.1em;
  }

  .crest__en {
    font-size: 7.5px;
  }

  .gov-header__platform {
    font-size: 14px;
  }

  .gov-header__divider {
    height: 34px;
  }
}

/* --------------------------------------------------------------- 焦點樣式 */

/* all.css 用 !important 對所有元素套橘色焦點光暈（#fd7e14），與本設計不搭。
   在 S2 範圍內改成設計色的外框。 */

.s2 :focus {
  box-shadow: none !important;
}

.s2 :focus-visible {
  outline: 3px solid var(--blue-outline) !important;
  outline-offset: 2px;
  box-shadow: none !important;
}

/* 程式化聚焦的標題不該顯示焦點框，讀螢幕軟體仍會正確朗讀 */
.s2 h1:focus,
.s2 h2:focus,
.s2 [tabindex="-1"]:focus {
  outline: none !important;
}

.s2 .input:focus,
.s2 .textarea:focus,
.s2 .select select:focus {
  border-color: var(--purple) !important;
  box-shadow: 0 0 0 3px rgba(104, 70, 165, 0.15) !important;
}
