/* ~/shared/css/announcement-bar.css
   peek bar (1 行 sticky bottom) + drawer overlay + dark mode 対応 */

/* ---- Category color tokens ---- */
.cat-outage      { --ann-color: #dc3545; --ann-bg: #fbeaec; }  /* 障害 = 赤 */
.cat-maintenance { --ann-color: #fd7e14; --ann-bg: #fff1e6; }  /* メンテ = オレンジ */
.cat-feature     { --ann-color: #28a745; --ann-bg: #e8f5ea; }  /* 新機能 = 緑 */
.cat-improvement { --ann-color: #007bff; --ann-bg: #e6f1fc; }  /* 改善 = 青 */

#dlc-announcement-bar { font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif; }

/* ---- Peek bar ---- */
#dlc-announcement-bar .ann-peek {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #fff;
  border: none;
  border-top: 1px solid #d1d1d6;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.92rem;
  z-index: 1040;
  box-shadow: 0 -2px 6px rgba(0,0,0,0.04);
  width: 100%;
  text-align: left;
}
#dlc-announcement-bar .ann-peek:focus { outline: 2px solid var(--ann-color); outline-offset: -4px; }
#dlc-announcement-bar .ann-peek .ann-pin { width: 18px; text-align:center; color:#888; }
#dlc-announcement-bar .ann-peek .ann-cat-badge {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 9px; border-radius: 10px;
  background: var(--ann-color, #888); color: #fff;
  font-size: 0.75rem; font-weight: 600;
  white-space: nowrap;
}
#dlc-announcement-bar .ann-peek .ann-title {
  flex: 1 1 auto; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  color: #1d1d1f; font-weight: 500;
}
#dlc-announcement-bar .ann-peek .ann-badge {
  background: #ff3b30; color: #fff;
  font-size: 0.72rem; font-weight: 600;
  padding: 1px 7px; border-radius: 10px;
  min-width: 18px; text-align: center;
}
#dlc-announcement-bar .ann-peek .ann-chev { color: #888; font-size: 0.95rem; }
#dlc-announcement-bar .ann-peek .ann-dismiss {
  width: 22px; height: 22px;
  border: none; background: transparent;
  color: #aaa; cursor: pointer; font-size: 1rem;
}
#dlc-announcement-bar .ann-peek .ann-dismiss:hover { color: #555; }

/* ---- Drawer overlay ---- */
#dlc-announcement-bar .ann-drawer {
  position: fixed; inset: 0;
  z-index: 1050;
}
#dlc-announcement-bar .ann-drawer-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.4);  /* drawer を前景として識別しやすくする暗転 */
}
#dlc-announcement-bar .ann-drawer-body {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: #fff;
  color: #1d1d1f;            /* 明示色で親アプリの白系継承を断ち切る (タイトル不可視防止) */
  max-height: 80vh; overflow-y: auto;
  border-radius: 12px 12px 0 0;
  padding: 12px 16px 18px;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.18);
  animation: ann-slide-up 0.22s ease-out;
  touch-action: pan-y;       /* 下スワイプ検知用、縦スクロールは引き続き許可 */
}
@keyframes ann-slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
#dlc-announcement-bar .ann-drawer-handle {
  width: 48px; height: 5px; background: #9a9a9e;  /* darker handle so swipe affordance is obvious */
  border-radius: 3px; margin: 4px auto 12px;
}
#dlc-announcement-bar .ann-drawer-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
#dlc-announcement-bar .ann-drawer-head h4 { font-size: 1.05rem; font-weight: 600; margin: 0; color: inherit; }
#dlc-announcement-bar .ann-close-x { background: none; border: none; font-size: 1.3rem; color: #888; cursor: pointer; }

/* announcement card layout (drawer + history shared shape):
   line 1: header-line (pin + badge + title + dismiss)
   line 2: meta (period)
   line 3+: thumb (optional) → body → CTA */
#dlc-announcement-bar .ann-item {
  padding: 11px 0; border-bottom: 1px solid #d1d1d6;
}
#dlc-announcement-bar .ann-item:last-child { border-bottom: none; }
#dlc-announcement-bar .ann-item .ann-header-line {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 4px;
}
#dlc-announcement-bar .ann-item .pin-mark { color: #c97a00; flex: 0 0 auto; }
#dlc-announcement-bar .ann-item .badge-cat {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 3px 10px; border-radius: 10px;
  color: #fff; background: var(--ann-color, #888);
  font-size: 0.78rem; font-weight: 600;
  white-space: nowrap;
}
#dlc-announcement-bar .ann-item .ann-title {
  flex: 1 1 auto; min-width: 0;
  font-weight: 600; color: inherit;
  overflow-wrap: anywhere;
}
#dlc-announcement-bar .ann-item.is-unread .ann-title::after {
  content: ''; width: 7px; height: 7px;
  border-radius: 50%; background: #ff3b30;
  display: inline-block; margin-left: 6px;
}
#dlc-announcement-bar .ann-item.is-read { opacity: 0.7; }
#dlc-announcement-bar .ann-item .ann-meta {
  color: #5a5a5e; font-size: 0.78rem;
  margin-bottom: 6px;
}
#dlc-announcement-bar .ann-item .ann-thumb {
  display: block; max-width: 100%; max-height: 200px;
  border-radius: 6px; object-fit: cover;
  margin-bottom: 8px;
}
#dlc-announcement-bar .ann-item .ann-body { color: #2c2c2e; font-size: 0.9rem; }
#dlc-announcement-bar .ann-item .ann-cta-row {
  margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap;
}
#dlc-announcement-bar .ann-item .ann-cta-btn {
  display: inline-flex; padding: 4px 11px;
  border-radius: 14px; font-size: 0.85rem;
  text-decoration: none; font-weight: 500;
  color: #fff; background: var(--ann-color, #007bff);
}
#dlc-announcement-bar .ann-item .ann-cta-btn.secondary {
  background: transparent; color: #2c2c2e; border: 1px solid #999;
}
#dlc-announcement-bar .ann-item .item-dismiss {
  flex: 0 0 auto;
  width: 28px; height: 28px; border: none;
  background: transparent; color: #6b6b6f;
  cursor: pointer; font-size: 1.2rem;
  border-radius: 50%; margin-left: auto;
}
#dlc-announcement-bar .ann-item .item-dismiss:hover { background: #ececef; color: #1d1d1f; }
#dlc-announcement-bar .ann-item.is-pinned .item-dismiss { display: none; }

#dlc-announcement-bar .ann-drawer-foot {
  margin-top: 12px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding-top: 10px;
  border-top: 1px solid #d1d1d6;
}
#dlc-announcement-bar .ann-history-link { font-size: 0.88rem; color: #0056d2; text-decoration: underline; }
#dlc-announcement-bar .ann-dismiss-all {
  background: transparent; border: 1px solid #999;
  color: #2c2c2e; border-radius: 14px;
  padding: 4px 11px; font-size: 0.82rem; cursor: pointer;
}

/* ---- Dark mode ---- */
@media (prefers-color-scheme: dark) {
  #dlc-announcement-bar .ann-peek { background: #2d2d2f; border-top-color: #424245; }
  #dlc-announcement-bar .ann-peek .ann-title { color: #f5f5f7; }
  #dlc-announcement-bar .ann-drawer-body { background: #2d2d2f; color: #f5f5f7; }
  #dlc-announcement-bar .ann-drawer-handle { background: #6e6e72; }
  #dlc-announcement-bar .ann-item { border-bottom-color: #555; }
  #dlc-announcement-bar .ann-item .ann-body { color: #e5e5e7; }
  #dlc-announcement-bar .ann-item .ann-meta { color: #a8a8ac; }
  #dlc-announcement-bar .ann-item .pin-mark { color: #f8b94d; }
  #dlc-announcement-bar .ann-item .ann-cta-btn.secondary { color: #f5f5f7; border-color: #888; }
  #dlc-announcement-bar .ann-item .item-dismiss { color: #c5c5c7; }
  #dlc-announcement-bar .ann-item .item-dismiss:hover { background: #424245; color: #f5f5f7; }
  #dlc-announcement-bar .ann-drawer-foot { border-top-color: #555; }
  #dlc-announcement-bar .ann-dismiss-all { color: #f5f5f7; border-color: #888; }
  #dlc-announcement-bar .ann-history-link { color: #5ea0ff; }
}

/* ---- Push #page-top above peek bar when present ---- */
body.dlc-ann-bar-shown #page-top { bottom: 64px !important; }
body.dlc-ann-bar-shown { padding-bottom: 56px; }

/* sticky footer (`body > .footer { position: sticky; top: 100vh }`)'s containment
   block is body's content-box (100vh tall, since `html, body { height: 100% }`),
   so body's `padding-bottom: 56px` doesn't push it up. Instead, give the footer
   its own bottom padding so the visible text ends 56px above the bar even when
   the footer wraps to multiple lines on mobile. */
body.dlc-ann-bar-shown > .footer { padding-bottom: 56px; }
