/* ============================================================
   最新消息公告列 .swa —— 心斎ノ翼官網（2026-09-24）
   搭配 /announce.js。資料來源 GET /api/announcements。

   兩種版型（announce.js 依頁面自動判斷）：
   ① 浮動膠囊（overlay）：首頁這種「最上面是大圖 hero」的頁面。膠囊浮在 hero 上方，
      不推擠任何版面 ⇒ CLS＝0；桌機置中、避開左側選單與右上角查空房圓鈕；手機貼在頂部列下方。
   ② 細長橫條（inline）：一般內頁（例如長住區，頁首 sticky:top:0＋.notice-bar）。
      插在 body 最前面、sticky 頁首之前 ⇒ 捲動後頁首照樣貼頂，錨點補償變數不受影響，
      也不會蓋到 .notice-bar。展開時會推擠一次（約 40px）。

   三種樣式：info（一般，墨黑＋金線）／promo（優惠，香檳金）／important（重要，朱紅）。
   🔴 公告文字一律由 JS 用 textContent 放進來，本檔不含任何內容。
   ============================================================ */

.swa {
  --swa-h: 44px;
  --swa-radius: 999px;
  --swa-bg: rgba(14, 14, 14, .86);
  --swa-fg: #F3EEE6;
  --swa-border: rgba(197, 168, 128, .55);
  --swa-tag-bg: rgba(197, 168, 128, .16);
  --swa-tag-fg: #E3C9A0;
  --swa-tag-border: rgba(197, 168, 128, .5);
  --swa-btn-fg: rgba(243, 238, 230, .78);
  --swa-btn-hover: rgba(255, 255, 255, .12);
  --swa-dot: #E3C9A0;
  --swa-shadow: 0 10px 30px rgba(0, 0, 0, .38), 0 1px 0 rgba(255, 255, 255, .04) inset;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.35;
  letter-spacing: .02em;
  color: var(--swa-fg);
  -webkit-font-smoothing: antialiased;
}
.swa *, .swa *::before, .swa *::after { box-sizing: border-box; }

/* ── 樣式：優惠（香檳金，最搶眼）── */
.swa--promo {
  --swa-bg: linear-gradient(100deg, #B8925F 0%, #E6CC9C 48%, #C9A56F 100%);
  --swa-fg: #1B150C;
  --swa-border: rgba(255, 236, 200, .7);
  --swa-tag-bg: #1B150C;
  --swa-tag-fg: #F0D9AE;
  --swa-tag-border: #1B150C;
  --swa-btn-fg: rgba(27, 21, 12, .75);
  --swa-btn-hover: rgba(27, 21, 12, .12);
  --swa-dot: #1B150C;
}
/* ── 樣式：重要（朱紅）── */
.swa--important {
  --swa-bg: linear-gradient(100deg, #8E2320 0%, #B8322B 55%, #9C2723 100%);
  --swa-fg: #FFFFFF;
  --swa-border: rgba(255, 190, 180, .45);
  --swa-tag-bg: #FFFFFF;
  --swa-tag-fg: #8E2320;
  --swa-tag-border: #FFFFFF;
  --swa-btn-fg: rgba(255, 255, 255, .85);
  --swa-btn-hover: rgba(255, 255, 255, .16);
  --swa-dot: #FFFFFF;
}

.swa__bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--swa-h);
  padding: 0 4px 0 6px;
  background: var(--swa-bg);
  border: 1px solid var(--swa-border);
  border-radius: var(--swa-radius);
  box-shadow: var(--swa-shadow);
  overflow: hidden;
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  backdrop-filter: blur(10px) saturate(1.2);
  transition: background .4s ease, border-color .4s ease, color .4s ease;
}
/* 優惠款的流光：只在允許動態時跑，一次 1.2 秒、間隔 5 秒，吸睛但不吵 */
.swa--promo .swa__bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .45) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: swa-shine 6s ease-in-out 1.2s infinite;
  pointer-events: none;
}
@keyframes swa-shine {
  0% { transform: translateX(-100%); }
  20%, 100% { transform: translateX(100%); }
}

/* 左側標籤：「優惠」「最新消息」「重要」 */
.swa__tag {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px 0 9px;
  border-radius: 999px;
  background: var(--swa-tag-bg);
  color: var(--swa-tag-fg);
  border: 1px solid var(--swa-tag-border);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  white-space: nowrap;
}
.swa__tagtext { display: grid; justify-items: center; }
.swa__tagtext > span { grid-area: 1 / 1; visibility: hidden; }
.swa__tagtext > span.is-on { visibility: visible; }
.swa__dot {
  width: 6px; height: 6px; border-radius: 50%;
  /* 圓點用標籤前景色：窄手機只剩圓點時，才不會與標籤底色同色而看不見 */
  background: var(--swa-tag-fg);
  box-shadow: 0 0 0 0 currentColor;
  animation: swa-pulse 2.4s ease-out infinite;
}
@keyframes swa-pulse {
  0% { box-shadow: 0 0 0 0 rgba(227, 201, 160, .7); }
  70%, 100% { box-shadow: 0 0 0 7px rgba(227, 201, 160, 0); }
}

/* 中間訊息：超出寬度就走馬燈；左右邊緣淡出 */
.swa__viewport {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: center;
  overflow: hidden;
  transition: opacity .22s ease;
}
.swa.is-overflow .swa__viewport {
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 10px, #000 calc(100% - 22px), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 10px, #000 calc(100% - 22px), transparent 100%);
}
.swa.is-swapping .swa__viewport { opacity: 0; }
.swa__track {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  will-change: transform;
}
.swa.is-marquee .swa__track {
  animation: swa-marquee var(--swa-dur, 12s) linear var(--swa-iter, 1) both;
}
.swa.is-paused .swa__track,
.swa.is-paused .swa__bar::after { animation-play-state: paused; }
@keyframes swa-marquee {
  0%, 14% { transform: translateX(0); }
  86%, 100% { transform: translateX(var(--swa-dist, 0px)); }
}

.swa__msg {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 4px;
  color: inherit;
  font-weight: 600;
  text-decoration: none;
  border-radius: 6px;
}
a.swa__msg:hover .swa__text { text-decoration: underline; text-underline-offset: 3px; }
a.swa__msg:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }
.swa__go {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 700;
  opacity: .85;
  white-space: nowrap;
}
.swa__go svg { width: 14px; height: 14px; transition: transform .2s ease; }
a.swa__msg:hover .swa__go svg { transform: translateX(3px); }

/* 右側控制：‹ 1/3 › ✕ */
.swa__ctrl {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0;
}
.swa__btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--swa-btn-fg);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .1s ease;
}
.swa__btn:hover { background: var(--swa-btn-hover); color: var(--swa-fg); }
.swa__btn:active { transform: scale(.92); }
.swa__btn:focus-visible { outline: 2px solid currentColor; outline-offset: -3px; }
.swa__btn svg { width: 16px; height: 16px; }
.swa__count {
  min-width: 34px;
  text-align: center;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  opacity: .72;
}
.swa__close { margin-left: 2px; }
.swa.is-single .swa__prev,
.swa.is-single .swa__next,
.swa.is-single .swa__count { display: none; }

/* ═══ 版型①：浮動膠囊（overlay）═══ */
.swa--overlay {
  position: absolute;
  z-index: 90; /* 低於首頁手機頂部列（100）、側欄（1600）與所有浮動鈕（1498+）⇒ 捲動時滑到頂部列底下 */
  display: block; /* 不用 flex 置中：子層會被長文字撐到 max-content 寬、整條溢出畫面 */
  pointer-events: none;
  opacity: 0;
  transform: translateY(-10px) scale(.98);
  transition: opacity .38s cubic-bezier(.2, .8, .2, 1), transform .38s cubic-bezier(.2, .8, .2, 1);
}
.swa--overlay > .swa__clip { width: 100%; min-width: 0; }
.swa--overlay .swa__bar { width: 100%; max-width: 760px; margin: 0 auto; pointer-events: auto; }
.swa--overlay.is-in { opacity: 1; transform: none; }

/* ═══ 版型②：細長橫條（inline）═══ */
.swa--inline {
  --swa-h: 42px;
  --swa-radius: 0;
  position: relative;
  z-index: 60;
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .32s cubic-bezier(.2, .8, .2, 1);
}
.swa--inline > .swa__clip { overflow: hidden; min-height: 0; }
.swa--inline.is-in { grid-template-rows: 1fr; }
.swa--inline .swa__bar {
  border-width: 0 0 1px;
  box-shadow: none;
  padding: 0 max(8px, calc((100% - 1120px) / 2)) 0 max(10px, calc((100% - 1120px) / 2));
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.swa--inline.swa--info .swa__bar { --swa-bg: #141312; }

/* 收起（按 ✕）：膠囊淡出、橫條收合 */
.swa.is-out.swa--overlay { opacity: 0; transform: translateY(-8px) scale(.98); }
.swa.is-out.swa--inline { grid-template-rows: 0fr; }

/* ── 手機 ── */
@media (max-width: 640px) {
  .swa { font-size: 13.5px; }
  .swa__bar { gap: 6px; padding: 0 2px 0 5px; }
  .swa__tag { height: 26px; padding: 0 9px 0 8px; font-size: 11.5px; letter-spacing: .04em; }
  .swa__prev, .swa__count { display: none; }
  .swa__btn { width: 40px; height: 40px; }
  .swa__go-label { display: none; }
  /* 手機上把寬度留給公告文字：下一則鈕縮一點、內頁橫條左右留白收窄 */
  .swa__next { width: 36px; }
  .swa__close { margin-left: 0; }
  .swa--inline .swa__bar { padding: 0 2px 0 6px; }
}
/* 窄手機（≤ 480px）：標籤只留圓點（樣式顏色仍在），文字標籤改成只給讀屏器
   ⇒ 375px 寬時，首頁膠囊與內頁橫條的公告文字區都 ≥ 220px。 */
@media (max-width: 480px) {
  .swa__tag { width: 24px; height: 24px; padding: 0; gap: 0; justify-content: center; }
  .swa__tagtext {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  .swa__dot { width: 8px; height: 8px; }
}

/* ── 減少動態：不捲動、不流光、不脈動；長字最多兩行，換則改淡入 ── */
@media (prefers-reduced-motion: reduce) {
  .swa--overlay, .swa--inline, .swa__viewport, .swa__bar { transition-duration: .01ms !important; }
  .swa--overlay { transform: none !important; transition: opacity .3s ease !important; }
  .swa__viewport { transition: opacity .45s ease !important; }
  .swa--promo .swa__bar::after, .swa__dot { animation: none !important; }
  .swa.is-marquee .swa__track { animation: none !important; }
  .swa__track { white-space: normal; will-change: auto; }
  .swa__text {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    line-height: 1.3;
  }
  /* 固定高度（容得下兩行）：換到一行／兩行的公告時高度不變 ⇒ 不產生版面位移 */
  .swa__bar { height: 52px; padding-top: 3px; padding-bottom: 3px; }
  .swa--overlay .swa__bar { border-radius: 22px; }
}

@media print { .swa { display: none !important; } }
