/* =====================================================
   THE COMMON PEOPLE — Announcement Bar (reusable component)
   =====================================================
   Loaded by BOTH the public site (index.html) and the admin
   "Announcement Bar" live preview (admin/index.html), so the
   preview is pixel-for-pixel what visitors actually see.

   Styling is driven entirely by inline CSS custom properties
   set on .announcement-bar itself (see js/announcement.js),
   NOT by editing rules here per admin setting — that keeps
   this file small and reusable rather than one-off.
   ===================================================== */

.announcement-bar {
  --announcement-anim-direction: normal;
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  box-sizing: border-box;
  padding: var(--announcement-padding-y, 0.5rem) 1.25rem;
  background: var(--announcement-bg, #0b0f0d);
  color: var(--announcement-text, #f5efe4);
  font-family: 'DM Sans', 'Jost', 'Segoe UI', sans-serif;
  font-size: var(--announcement-font-size, 0.85rem);
  font-weight: var(--announcement-font-weight, 500);
  border-bottom: var(--announcement-border, none);
  overflow: hidden;
  letter-spacing: 0.01em;
}

/* Public site only: pinned above the (also-fixed) navbar. The admin
   preview renders this same markup in normal flow instead — see
   .announcement-preview-mount in admin.css. */
.announcement-bar.is-fixed {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1031;
}

.announcement-viewport {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

.announcement-track {
  display: flex;
  align-items: center;
  gap: 3.5rem;
  white-space: nowrap;
  width: max-content;
}

/* Static: single centered copy, allowed to wrap on narrow screens.
   .announcement-copy/.announcement-text default to flex-shrink:0 +
   nowrap so the ticker's duplicated copies never wrap mid-loop — static
   mode needs the opposite, so it's explicitly un-done here. */
.announcement-bar[data-display='static'] .announcement-track {
  justify-content: center;
  white-space: normal;
  flex-wrap: wrap;
  width: 100%;
  row-gap: 0.25rem;
}
.announcement-bar[data-display='static'] .announcement-copy {
  flex-shrink: 1;
  flex-wrap: wrap;
  white-space: normal;
  min-width: 0;
  justify-content: center;
  row-gap: 0.25rem;
}
.announcement-bar[data-display='static'] .announcement-text {
  white-space: normal;
  min-width: 0;
}

/* Ticker: a single copy of the message slides across the whole bar and starts over from the edge. */
.announcement-bar[data-display='ticker'] .announcement-track {
  animation-name: announcement-scroll;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  animation-duration: var(--announcement-duration, 26s);
  animation-direction: var(--announcement-anim-direction, normal);
}

.announcement-bar[data-display='ticker'][data-pause-hover='true']:hover .announcement-track,
.announcement-bar[data-display='ticker'][data-pause-hover='true']:focus-within .announcement-track {
  animation-play-state: paused;
}

/* One message travels from just outside one edge to just outside the other (distances are measured in
   js/announcement.js: starts at the bar's width, ends at minus the message's width), then repeats. */
@keyframes announcement-scroll {
  from { transform: translateX(var(--announcement-from, 100%)); }
  to { transform: translateX(var(--announcement-to, -100%)); }
}

.announcement-copy {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-shrink: 0;
}

.announcement-text {
  display: inline-block;
}

.announcement-link {
  flex-shrink: 0;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0.95;
  transition: opacity 0.2s ease;
}
.announcement-link:hover,
.announcement-link:focus-visible {
  color: inherit;
  opacity: 1;
}
.announcement-link:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
  border-radius: 2px;
}

.announcement-close {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  opacity: 0.75;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.2s ease, background-color 0.2s ease;
}
.announcement-close:hover,
.announcement-close:focus-visible {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
}
.announcement-close:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .announcement-bar[data-display='ticker'] .announcement-track {
    animation: none;
  }
}

@media (max-width: 575.98px) {
  .announcement-bar { padding-left: 1rem; padding-right: 1rem; gap: 0.5rem; }
  .announcement-track { gap: 2rem; }
  .announcement-copy { gap: 0.6rem; }
}
