/* ============================================================
   V4 Classic 共用視覺層（任務 29）
   - 載入於各頁 CSS 之後；只選取共用元件 class，不選取各頁專屬 class。
   - 與 components.css 相同 specificity，靠載入順序覆寫，不使用 !important。
   - 數值來源：homepage-v4-classic.css（預覽參考，不作為正式站依賴）。
   - 規劃與職責分工見 Docs/frontend/v4-theme-plan.md。
   ============================================================ */

/* 共用元件預設值：以繼承的自訂變數提供，各頁 CSS 在元件上自行設定時仍優先。 */
:root {
  --site-card-radius: var(--radius-block);
  --site-card-shadow: var(--shadow-flat);
}

/* base.css 的 font-family: inherit 讓 body 回到瀏覽器預設字型；此處重新宣告，與首頁一致。 */
body {
  font-family: "Noto Sans TC", "Microsoft JhengHei", Arial, sans-serif;
}

/* ---------- Header ---------- */

.site-header {
  background: var(--color-brand);
  border-bottom: 0;
  box-shadow: none;
}

.header-inner {
  width: 100%;
  max-width: none;
  min-height: var(--header-height);
  padding-inline: 0;
  align-items: center;
  gap: 0;
}

.brand {
  align-self: stretch;
  flex: 0 0 auto;
  min-width: 0;
  min-height: var(--header-height);
  padding: 6px 24px 6px 16px;
  background: var(--color-accent);
}

.brand-logo {
  width: 52px;
  height: 52px;
  padding: 0;
  background: transparent;
  border: 0;
}

.brand-copy {
  flex: 0 0 auto;
  width: auto;
}

.brand-title {
  color: #fff;
  font-size: 15px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* V4 Header 不顯示英文副標。12 個內頁已移除 HTML；首頁 Header 於 Phase 4 處理後再刪除此規則。 */
.brand-subtitle {
  display: none;
}

.desktop-nav {
  flex: 0 1 auto;
  justify-content: flex-start;
}

.desktop-nav-list {
  align-items: center;
  padding: 0;
  background: transparent;
  border-radius: var(--radius-block);
}

.desktop-nav-list > li {
  flex: 0 0 92px;
  border-left: 1px solid rgba(255, 255, 255, 0.07);
}

.desktop-nav-list > li:last-child {
  border-right: 1px solid rgba(255, 255, 255, 0.07);
}

.desktop-nav-link {
  width: 100%;
  min-height: var(--header-height);
  justify-content: center;
  padding: 20px 8px 15px;
  color: #fff;
  border-bottom-width: var(--accent-bar-md);
  font-size: 12px;
  letter-spacing: 0.08em;
  transition: color 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.desktop-nav-link:hover,
.desktop-nav-link:focus,
.desktop-nav-link.is-active,
.nav-dropdown.show > .desktop-nav-link {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
}

.desktop-nav .dropdown-menu {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-block);
  box-shadow: 0 16px 36px rgba(23, 26, 29, 0.24);
}

.nav-toggle {
  color: var(--color-accent);
  background: var(--color-brand);
  border-color: var(--color-brand);
  border-radius: var(--radius-block);
}

/* ---------- Newsletter（任務 29 只做 UI；任務 30 串接 API 前表單停用） ---------- */

.site-newsletter-button {
  display: none;
  flex: 0 0 auto;
  min-height: 42px;
  padding: 9px 18px;
  margin-right: 22px;
  margin-left: auto;
  color: #fff;
  background: var(--color-accent);
  border: 0;
  border-bottom: var(--accent-bar-md) solid var(--color-accent-dark);
  border-radius: var(--radius-block);
  box-shadow: -1px 0 0 rgba(255, 255, 255, 0.12);
  font-size: 13px;
  font-weight: var(--font-weight-heading);
  transition: background-color 0.18s ease;
}

.site-newsletter-button:hover,
.site-newsletter-button:focus-visible {
  background: var(--color-accent-dark);
}

.mobile-newsletter-button {
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  padding-inline: 16px;
  color: #fff;
  background: var(--color-accent);
  border: 0;
  border-left: 5px solid var(--color-accent-dark);
  border-radius: var(--radius-block);
  font-weight: var(--font-weight-heading);
  text-align: left;
}

.mobile-newsletter-button:hover,
.mobile-newsletter-button:focus-visible {
  background: var(--color-accent-dark);
}

.newsletter-dialog {
  width: min(92vw, 500px);
  padding: 38px;
  color: var(--color-text);
  background: var(--color-surface);
  border: 2px solid var(--color-brand);
  border-top: var(--accent-bar-xl) solid var(--color-accent);
  border-radius: var(--radius-block);
  box-shadow: var(--shadow-dialog);
}

.newsletter-dialog::backdrop {
  background: rgba(23, 26, 29, 0.74);
  backdrop-filter: blur(3px);
}

.newsletter-dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  color: #fff;
  background: var(--color-brand);
  border: 0;
  border-radius: var(--radius-block);
  font-size: 22px;
  line-height: 1;
  place-items: center;
}

.newsletter-dialog-kicker {
  margin: 0 0 8px;
  color: var(--color-accent);
  font-size: var(--kicker-size);
  font-weight: var(--font-weight-heading);
  letter-spacing: var(--kicker-tracking);
}

.newsletter-dialog-title {
  max-width: 360px;
  margin: 0;
  color: var(--color-brand);
  font-size: 30px;
  font-weight: var(--font-weight-heading);
  letter-spacing: -0.04em;
}

.newsletter-dialog-lead {
  margin: 12px 0 24px;
  color: var(--color-text-muted);
  font-size: 14px;
}

.newsletter-dialog-form fieldset {
  display: grid;
  gap: 10px;
}

.newsletter-dialog-form label {
  color: var(--color-brand);
  font-size: var(--kicker-size);
  font-weight: var(--font-weight-heading);
  letter-spacing: 0.14em;
}

.newsletter-dialog-form input {
  min-height: 52px;
  padding: 12px 14px;
  color: var(--color-text);
  background: #fff;
  border: 1px solid var(--color-text-muted);
  border-radius: var(--radius-block);
}

.newsletter-dialog-form button {
  min-height: 50px;
  margin-top: 6px;
  color: #fff;
  background: var(--color-accent);
  border: 0;
  border-bottom: 5px solid var(--color-accent-dark);
  border-radius: var(--radius-block);
  font-weight: var(--font-weight-heading);
}

/* 停用狀態：明確呈現「尚不能送出」，避免使用者誤以為已訂閱。 */
.newsletter-dialog-form input:disabled {
  background: #f1f5f9;
  border-color: var(--color-border);
  cursor: not-allowed;
}

.newsletter-dialog-form button:disabled {
  color: var(--color-text-muted);
  background: var(--color-border);
  border-bottom-color: #c3cedb;
  cursor: not-allowed;
}

.newsletter-dialog-notice {
  margin: 16px 0 0;
  padding: 10px 14px;
  color: var(--color-text);
  background: var(--color-accent-soft);
  border-left: var(--accent-bar-md) solid var(--color-accent);
  font-size: 14px;
}

@media (min-width: 1225px) {
  .site-newsletter-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .newsletter-dialog {
    padding: 32px 20px 22px;
    box-shadow: 8px 8px 0 rgba(23, 26, 29, 0.2);
  }
}

/* ---------- Section Title ---------- */

/* 保留 components.css 的漸層背景，避免與同為深藍的 Header 融在一起。 */
.page-banner {
  border-bottom: var(--accent-bar-lg) solid var(--color-accent);
}

.page-banner-kicker {
  color: var(--color-accent);
  letter-spacing: var(--kicker-tracking);
}

.page-banner-title {
  font-weight: var(--font-weight-heading);
  letter-spacing: -0.04em;
}

.page-title h1 {
  color: var(--color-brand);
  font-weight: var(--font-weight-heading);
  letter-spacing: -0.04em;
}

.page-title h1::after {
  border-radius: var(--radius-block);
}

/* 列表結果標題比照 V4 panel 標題：整列深藍粗底線，取代標題下方的短橘線。 */
.site-result-heading {
  padding-bottom: 16px;
  border-bottom: var(--accent-bar-md) solid var(--color-brand);
}

.site-result-heading h1::after {
  display: none;
}

/* ---------- Button ---------- */

.site-button {
  background: var(--color-brand-secondary);
  border-color: var(--color-brand-secondary);
  border-radius: var(--radius-block);
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.site-button:hover,
.site-button:focus {
  background: var(--color-accent-dark);
  border-color: var(--color-accent-dark);
}

.site-button-secondary {
  color: var(--color-brand-secondary);
  background: var(--color-surface);
}

.site-button-secondary:hover,
.site-button-secondary:focus {
  color: var(--color-brand-secondary);
  background: var(--color-brand-soft);
  border-color: var(--color-brand-secondary);
}

/* 黃色系按鈕（課程「查看課程來源」、職缺「查看原始職缺」），配色同 Header「訂閱電子報」 */
.site-button-accent {
  color: #fff;
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.site-button-accent:hover,
.site-button-accent:focus {
  color: #fff;
  background: var(--color-accent-dark);
  border-color: var(--color-accent-dark);
}

.site-more::before {
  background: var(--color-accent-soft);
  border-radius: var(--radius-block);
}

/* hover 色塊左右各多 10px（對齊 left: -10px），取代原本 130% 寬度造成的右側外溢。 */
.site-more:hover::before,
.site-more:focus-visible::before {
  width: calc(100% + 20px);
  background: var(--color-accent);
}

.site-more span,
.site-more svg {
  color: var(--color-accent-dark);
  stroke: var(--color-accent-dark);
  transition: color 0.2s ease, stroke 0.2s ease;
}

.site-more:hover span,
.site-more:focus-visible span,
.site-more:hover svg,
.site-more:focus-visible svg {
  color: #fff;
  stroke: #fff;
}

.back-to-top {
  background: var(--color-brand-secondary);
  border-radius: var(--radius-block);
}

/* ---------- Form ---------- */

.site-search-input,
.site-filter-control {
  border-color: var(--color-text-muted);
  border-radius: var(--radius-block);
}

.site-search-input:focus,
.site-filter-control:focus {
  border-color: var(--color-brand-secondary);
  outline: 3px solid rgba(243, 152, 0, 0.14);
}

.site-filter-link {
  border-radius: var(--radius-block);
}

/* ---------- Card ---------- */

.empty-state {
  border-radius: var(--radius-block);
  box-shadow: var(--shadow-flat);
}

/* news.css 列表與詳細頁元件：selector 與 news.css 同 specificity。
   載入 news.css 的 6 頁（update、training、各 detail 頁）皆已載入本檔。 */
.news-panel,
.news-article,
.detail-article,
.attachment-panel,
.region-results,
.region-results-metrics > div {
  border-radius: var(--radius-block);
  box-shadow: var(--shadow-flat);
}

.update-item-cover,
.update-item-extra .badge-secondary,
.region-results-period,
.region-results-note,
.region-results-metrics > div::before,
.article-cover,
.attachment-type,
.detail-summary-grid,
.detail-callout,
.disabled-action-tooltip,
.gallery-card img {
  border-radius: var(--radius-block);
}

/* 上一篇／下一篇（news-detail 的 article-pager、insight-detail 的 insight-pager）：
   hover 時橘框＋淡橘陰影（同 V4 卡片 hover），雙箭號往外移。
   箭號以 CSS 產生，替代文字設為空字串，螢幕閱讀器只念「上一篇／下一篇」。 */
.article-pager-link,
.insight-pager-link {
  border-radius: var(--radius-block);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.article-pager-link:hover,
.article-pager-link:focus-visible,
.insight-pager-link:hover,
.insight-pager-link:focus-visible {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-hover);
}

.article-pager-title,
.insight-pager-title {
  transition: color 0.2s ease;
}

.article-pager-link:hover .article-pager-title,
.article-pager-link:focus-visible .article-pager-title,
.insight-pager-link:hover .insight-pager-title,
.insight-pager-link:focus-visible .insight-pager-title {
  color: var(--color-accent-dark);
}

.article-pager-link:first-child .article-pager-label::before,
.article-pager-link:last-child .article-pager-label::after,
.insight-pager-link[data-insight-previous] .insight-pager-label::before,
.insight-pager-link[data-insight-next] .insight-pager-label::after {
  display: inline-block;
  color: var(--color-accent);
  font-weight: var(--font-weight-heading);
  transition: transform 0.2s ease;
}

.article-pager-link:first-child .article-pager-label::before,
.insight-pager-link[data-insight-previous] .insight-pager-label::before {
  margin-right: 6px;
  content: "«";
  content: "«" / "";
}

.article-pager-link:last-child .article-pager-label::after,
.insight-pager-link[data-insight-next] .insight-pager-label::after {
  margin-left: 6px;
  content: "»";
  content: "»" / "";
}

.article-pager-link:first-child:hover .article-pager-label::before,
.article-pager-link:first-child:focus-visible .article-pager-label::before,
.insight-pager-link[data-insight-previous]:hover .insight-pager-label::before,
.insight-pager-link[data-insight-previous]:focus-visible .insight-pager-label::before {
  transform: translateX(-4px);
}

.article-pager-link:last-child:hover .article-pager-label::after,
.article-pager-link:last-child:focus-visible .article-pager-label::after,
.insight-pager-link[data-insight-next]:hover .insight-pager-label::after,
.insight-pager-link[data-insight-next]:focus-visible .insight-pager-label::after {
  transform: translateX(4px);
}

@media (prefers-reduced-motion: reduce) {
  .article-pager-link,
  .article-pager-title,
  .article-pager-link .article-pager-label::before,
  .article-pager-link .article-pager-label::after,
  .insight-pager-link,
  .insight-pager-title,
  .insight-pager-link .insight-pager-label::before,
  .insight-pager-link .insight-pager-label::after {
    transition: none;
  }
}

/* ---------- Badge ---------- */

.site-badge,
.training-status-badge {
  border-radius: var(--radius-block);
}

/* ---------- Pagination ---------- */

.site-page-link {
  border-radius: var(--radius-block);
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 0;
  background: var(--color-brand);
  border-top: var(--accent-bar-lg) solid var(--color-accent);
}

.footer-brand-title {
  color: #fff;
}

.footer-side {
  gap: 8px;
}

.footer-side h2,
.footer-counter {
  margin-top: 0;
  margin-bottom: 0;
}

.footer-counter span {
  color: #fff;
  background: #0e1114;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.22);
}

@media (min-width: 1025px) {
  .footer-main {
    grid-template-columns: minmax(360px, 1.45fr) minmax(420px, 2.2fr) minmax(170px, 0.9fr);
  }

  .footer-logo {
    width: 124px;
    height: 124px;
  }

  .footer-brand {
    padding-right: 28px;
    border-right: 1px solid rgba(255, 255, 255, 0.18);
  }

  .footer-navigation {
    padding-left: 0;
  }
}

/* ---------- RWD ---------- */

@media (max-width: 1224px) {
  .header-inner {
    justify-content: space-between;
  }

  .brand {
    flex: 1 1 auto;
    min-width: 0;
    padding-inline: 16px;
  }

  .nav-toggle {
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    margin: 0;
    padding: 0;
  }

  .nav-toggle svg {
    display: block;
    margin: 0;
  }
}

@media (max-width: 767px) {
  .header-inner {
    min-height: var(--header-height);
  }

  .brand-copy {
    display: none;
  }

  .footer-brand > div {
    min-width: 0;
  }

  .footer-brand-title {
    font-size: clamp(14px, 4.5vw, 17px);
  }
}

/* ---------- 任務30（#12）：電子報訂閱送出結果（Header 彈窗、首頁訂閱區塊共用） ---------- */
.newsletter-dialog-notice.is-success,
.page-home .home-newsletter-notice.is-success {
  color: #14532d;
  background: #dcfce7;
  border-left-color: #16a34a;
}

.newsletter-dialog-notice.is-error,
.page-home .home-newsletter-notice.is-error {
  color: #7f1d1d;
  background: #fee2e2;
  border-left-color: #dc2626;
}

/* 防機器人隱藏欄位：移出畫面且不可聚焦 */
.newsletter-trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
