/* ══════════════════════════════════════════════════════════════════════════
   SITE-WIDE ANNOUNCEMENT BANNER
   Renders directly beneath the fixed page topbar and pushes every offset-based
   layout down by --dc-banner-height, which js/site-banner.js measures and sets
   on :root. Nothing here is loaded conditionally: the strip is absent from the
   DOM entirely until the runtime has a live banner to draw.
   ══════════════════════════════════════════════════════════════════════════ */

.site-banner {
  position: fixed;
  /* Both coordinates are measured from the chrome that is actually on screen
     and written by js/site-banner.js — the site runs pages with a topbar and a
     rail, with a rail only, and with neither. */
  top: var(--dc-banner-top, 0px);
  right: 0;
  left: var(--dc-banner-left, 0px);
  /* Above the map page's floating chrome (900/950) and the topbar's own 1200
     is deliberately *not* cleared — the topbar stays on top when a drawer or
     dropdown overlaps. Below the nav rail (1400) and enforcement (2147482000). */
  z-index: 1150;
  display: flex;
  align-items: center;
  gap: clamp(10px, 2vw, 18px);
  min-height: 48px;
  padding: 9px clamp(14px, 2.4vw, 26px);
  color: var(--dc-text, #f2f2f2);
  background: var(--site-banner-bg, rgba(65, 105, 225, 0.16));
  border-bottom: 1px solid var(--dc-border, rgba(255, 255, 255, 0.1));
  box-shadow: inset 3px 0 0 0 var(--site-banner-accent, #4169e1);
  font-family: var(--dc-font-body, "Barlow", "Segoe UI", system-ui, sans-serif);
  /* The strip is chrome layered over a solid page background on the map page;
     keep it opaque enough that map tiles never bleed through the copy. */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.site-banner[hidden] {
  display: none;
}

/* ── Severity ──────────────────────────────────────────────────────────────
   Colour never carries the meaning on its own: each severity also swaps the
   icon glyph and the visually-hidden prefix read out by screen readers. */

.site-banner.is-info {
  --site-banner-accent: var(--dc-blue-bright, #8eacff);
  --site-banner-bg: rgba(65, 105, 225, 0.17);
}

.site-banner.is-success {
  --site-banner-accent: var(--dc-green, #4ad17e);
  --site-banner-bg: rgba(74, 209, 126, 0.15);
}

.site-banner.is-warning {
  --site-banner-accent: var(--dc-amber, #e5ca7e);
  --site-banner-bg: rgba(229, 202, 126, 0.15);
}

.site-banner.is-error {
  --site-banner-accent: var(--dc-red, #ff3b4d);
  --site-banner-bg: rgba(255, 59, 77, 0.16);
}

/* ── Icon ───────────────────────────────────────────────────────────────── */

.site-banner-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--site-banner-accent, #8eacff);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--site-banner-accent, #8eacff);
  border-radius: 50%;
}

.site-banner-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Copy ───────────────────────────────────────────────────────────────── */

.site-banner-copy {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 3px 10px;
  min-width: 0;
  /* Takes the slack so the action and dismiss controls stay pinned right. */
  flex: 1 1 auto;
}

.site-banner-title {
  margin: 0;
  color: var(--dc-text, #f2f2f2);
  font-family: var(--dc-font-display, "Barlow Condensed", "Segoe UI", system-ui, sans-serif);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.25;
}

.site-banner-message {
  margin: 0;
  min-width: 0;
  /* #c4c4ca on the darkest severity tint clears 4.5:1; --dc-muted does not. */
  color: var(--dc-muted-strong, #c4c4ca);
  font-size: 14px;
  line-height: 1.4;
}

.site-banner-message:empty {
  display: none;
}

/* ── Controls ───────────────────────────────────────────────────────────── */

.site-banner-controls {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.site-banner-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 14px;
  color: #111318;
  background: var(--site-banner-accent, #8eacff);
  border: 1px solid var(--site-banner-accent, #8eacff);
  border-radius: var(--dc-radius-sm, 6px);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
  transition: filter 160ms ease-out, transform 160ms ease-out;
}

.site-banner-action:hover {
  filter: brightness(1.1);
}

.site-banner-action:active {
  transform: translateY(1px);
}

.site-banner-action svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.site-banner-dismiss {
  position: relative;
  display: grid;
  place-items: center;
  /* 44×44 hit area on a 48px strip: the padding does the work, not the box. */
  width: 34px;
  height: 34px;
  margin: -5px -6px -5px 0;
  padding: 0;
  color: var(--dc-muted-strong, #c4c4ca);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--dc-radius-sm, 6px);
  cursor: pointer;
  transition: color 160ms ease-out, background 160ms ease-out;
}

.site-banner-dismiss::before {
  /* Extends the pointer target to 44×44 without growing the strip. */
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
}

.site-banner-dismiss:hover {
  color: var(--dc-text, #f2f2f2);
  background: rgba(255, 255, 255, 0.08);
}

.site-banner-dismiss svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
}

.site-banner-action:focus-visible,
.site-banner-dismiss:focus-visible {
  outline: 3px solid var(--dc-blue-bright, #8eacff);
  outline-offset: 2px;
}

/* ── Entry ──────────────────────────────────────────────────────────────── */

.site-banner.is-entering {
  /* Deliberately no fill-mode. `both` would hold the -100% `from` frame
     whenever the animation does not actually run — a background tab, a
     throttled renderer — parking the strip on top of the topbar instead of
     below it. With no fill, not animating just means appearing in place. */
  animation: site-banner-in 190ms ease-out;
}

@keyframes site-banner-in {
  from { opacity: 0; transform: translateY(-100%); }
  to { opacity: 1; transform: translateY(0); }
}

/* Pages with no fixed topbar (the commerce shells) have no --dc-topbar-height
   offset for the strip to fold into, so they take the height on the body. */
body.needs-site-banner-offset {
  padding-top: var(--dc-banner-height, 0px);
}

/* ── Narrow viewports ───────────────────────────────────────────────────── */

@media (max-width: 760px) {
  .site-banner {
    gap: 10px;
    padding: 8px 14px;
  }

  .site-banner-icon {
    width: 24px;
    height: 24px;
  }

  .site-banner-icon svg {
    width: 14px;
    height: 14px;
  }

  .site-banner-title {
    font-size: 15px;
  }

  .site-banner-message {
    font-size: 13px;
    /* Two lines is the budget before the strip starts eating the fold. */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
  }

  .site-banner-action {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 12px;
  }

  .site-banner-action svg {
    display: none;
  }
}

@media (max-width: 460px) {
  .site-banner-copy {
    /* Below this the title and message can no longer share a line without one
       of them collapsing to a couple of words per row. */
    flex-direction: column;
    gap: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-banner.is-entering {
    animation: none;
  }

  .site-banner-action {
    transition: none;
  }

  .site-banner-dismiss {
    transition: none;
  }
}
