/* ========================================================
   Issue #458 全站頂部公告列（Announcement Bar）
   --------------------------------------------------------
   模組化結構共用 layout 層（common.layout）——全站頂部元件，
   每頁載入；顏色由 data-driven 的 .color-* 控制，各主題無差異，
   故僅放 common、不需主題覆寫。原樣遷移自舊單檔 default.css
   （#518 模組化後舊單檔已凍結不載入），詳見 docs/front/css-theme-system.md。
   ======================================================== */
.web-announcement-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 44px;
  background: #212529;
  color: #fff;
  overflow: hidden;
  z-index: 3100;
  transition: background-color 0.4s ease, transform 0.3s ease;
}

.web-announcement-bar.is-hidden {
  transform: translateY(-100%);
}

/* 公告列可見時，Header 下移 44px */
#header {
  transition: top 0.3s ease;
}

.has-announcement-bar #header {
  top: 44px;
}

/* 色盤 key（對齊後台 bar_color：red/yellow/blue/green/purple/black/white；空＝無套用上方 base 深色） */
.web-announcement-bar.color-red    { background-color: #e74c3c; }
.web-announcement-bar.color-yellow { background-color: #f39c12; color: #212529; }
.web-announcement-bar.color-blue   { background-color: #2980b9; }
.web-announcement-bar.color-green  { background-color: #27ae60; }
.web-announcement-bar.color-purple { background-color: #8e44ad; }
.web-announcement-bar.color-black  { background-color: #212529; }
.web-announcement-bar.color-white  { background-color: #ffffff; color: #212529; }

.web-announcement-bar-inner {
  display: flex;
  align-items: center;
  height: 44px;
  max-width: none;
  margin: 0 auto;
  /* 內容寬度對齊各主題 header 容器：沿用 .plr-185（由 partial 加在同一元素上） */
}

.web-announcement-bar-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  margin-right: 4px;
}

.web-announcement-nav-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  padding: 1px 6px;
  cursor: pointer;
  font-size: 10px;
  line-height: 1.2;
  transition: color 0.15s;
}

.web-announcement-nav-btn:hover {
  color: #fff;
}

.web-announcement-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  height: 44px;
}

.web-announcement-item {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.web-announcement-item.enter-from-above { transform: translateY(-100%); }
.web-announcement-item.is-active        { transform: translateY(0); }
.web-announcement-item.exit-to-up       { transform: translateY(-100%); }
.web-announcement-item.exit-to-down     { transform: translateY(100%); }

.web-announcement-item-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  min-width: 0;
}

.web-announcement-text {
  color: #fff;
  font-size: 14px;
  text-align: center;
  text-decoration: none;
  /* 單行置中、寬度隨字數擴展（最寬至 header 容器）。超過寬度時改為跑馬燈左捲（issue #458） */
  overflow: hidden;
  min-width: 0;
  max-width: 100%;
}

.web-announcement-text-scroll {
  display: inline-block;
  white-space: nowrap;
}

/* 文字超出容器寬度：左對齊並啟用跑馬燈左捲（is-scrolling 由 JS 量測後加上） */
.web-announcement-text.is-scrolling {
  text-align: left;
}

.web-announcement-text.is-scrolling .web-announcement-text-scroll {
  animation: web-announcement-marquee var(--scroll-duration, 12s) linear infinite;
}

@keyframes web-announcement-marquee {
  0%, 12%   { transform: translateX(0); }
  88%, 100% { transform: translateX(calc(-1 * var(--scroll-distance, 0px))); }
}

a.web-announcement-text:hover {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: underline;
}

.web-announcement-countdown {
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 2px 10px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

.web-announcement-bar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 8px;
}

.web-announcement-indicator {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
  white-space: nowrap;
  min-width: 32px;
  text-align: center;
}

.web-announcement-close-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  padding: 4px 6px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  transition: color 0.15s;
}

.web-announcement-close-btn:hover {
  color: #fff;
}

@media (max-width: 576px) {
  /* 手機版加高至 60px：容兩行（文字＋倒數）並上下各留約 10px padding */
  .web-announcement-bar,
  .web-announcement-bar-inner,
  .web-announcement-viewport {
    height: 60px;
  }

  .has-announcement-bar #header {
    top: 60px;
  }

  .web-announcement-bar-inner {
    padding: 0 16px;
  }

  /* 手機版：公告文字（上）與倒數（下）改上下兩行、置中 */
  .web-announcement-item-inner {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    width: 100%;
  }

  .web-announcement-text {
    font-size: 13px;
    align-self: stretch;   /* 撐滿寬度，供置中／跑馬燈量測 */
  }

  /* 倒數放第二行、置中（取消桌機外的隱藏）*/
  .web-announcement-countdown {
    display: inline-block;
    font-size: 11px;
    padding: 1px 8px;
  }
}

/* 淡入淡出動畫覆寫（版本 B 專用） */
.web-announcement-bar--fade .web-announcement-item {
  transform: translateY(0);
  opacity: 0;
  transition: opacity 0.5s ease;
}

.web-announcement-bar--fade .web-announcement-item.is-active {
  opacity: 1;
}

.web-announcement-bar--fade .web-announcement-item.is-fading-out {
  opacity: 0;
}

/* 原型比較頁：兩條公告列同時顯示時的定位 */
.has-two-announcement-bars .web-announcement-bar--fade {
  top: 44px;
}

.has-two-announcement-bars #header {
  top: 88px;
}

/* body padding-top 由 JS syncHeaderOffset() 動態設為「公告列高度」即可：頁面內容本身
   已透過 .page-wrapper margin-top / .breadcrumbs-section padding-top 等為 fixed #header
   讓位，公告列開啟時 #header 僅再下移 barHeight，故 body 只補 barHeight、不重複加 header 高度 */

/* 模糊淡入動畫覆寫（版本 C 專用）*/
.web-announcement-bar--blur .web-announcement-item {
  transform: translateY(0);
  opacity: 0;
  filter: blur(6px);
  transition: opacity 0.5s ease, filter 0.5s ease;
}

.web-announcement-bar--blur .web-announcement-item.is-active {
  opacity: 1;
  filter: blur(0);
}

.web-announcement-bar--blur .web-announcement-item.is-fading-out {
  opacity: 0;
  filter: blur(6px);
}

/* 原型比較頁：三條公告列同時顯示時的定位 */
.has-three-announcement-bars .web-announcement-bar--blur {
  top: 88px;
}

.has-three-announcement-bars #header {
  top: 132px;
}
