/*
 * Announcement banner: views/announcement-banner/announcement-banner.twig
 *
 * Plain CSS (not SCSS) on purpose: it is enqueued directly by
 * inc/announcement-banner.php so it ships without re-running the legacy
 * Laravel Mix build. It is outside the views/**\/*.scss glob, so it is not
 * compiled into static/css/style.css. If the build is modernised, this can
 * move to an .scss file next to the template.
 *
 * Brand pieces reused from the theme: the Hanley fonts (@font-face in
 * assets/scss/base/_fonts.scss), the coast-lines texture and drift animation
 * used on the drink tiles (.bg-repeat in _custom.scss), and pill buttons.
 */

:root {
  /* Phones: script lead-in on one line, message on the next, pill on the right. */
  --announcement-banner-height: 3.5rem;
  /* Distance from the top of the viewport. Shared by the banner and the header below it. */
  --announcement-banner-top: 0px;
  /* Wave texture strength. Kept faint so it never competes with the text. */
  --announcement-banner-lines-opacity: 0.3;
}

@media (min-width: 768px) {
  :root {
    /* Everything on one line. */
    --announcement-banner-height: 3rem;
  }
}

/* Logged-in users: sit below the WP admin bar. Matches the theme's body.admin-bar margin (assets/scss/base/_global.scss). */
.admin-bar {
  --announcement-banner-top: 46px;
}

@media (min-width: 783px) {
  .admin-bar {
    --announcement-banner-top: 32px;
  }
}

/*
 * Colour choices (Site Options → Announcement Banner → Colour). Hex values from
 * theme-config.json. Each option only sets the background; text and the CTA
 * pill are the same for all of them (set on .announcement-banner below).
 */
.announcement-banner--cranberry  { --announcement-banner-bg: #931a1e; } /* cranberry-500 */
.announcement-banner--light-blue { --announcement-banner-bg: #49b9e6; } /* primary-500, the site's signature blue */
.announcement-banner--ocean      { --announcement-banner-bg: #0e4b63; } /* primary-800 */
.announcement-banner--charcoal   { --announcement-banner-bg: #1e2128; } /* black */

.announcement-banner {
  /* White text and a white pill with light blue (primary-500) lettering, on every background. */
  --announcement-banner-fg: #fff;
  --announcement-banner-cta-bg: #fff;
  --announcement-banner-cta-fg: #49b9e6;

  position: fixed;
  top: var(--announcement-banner-top);
  left: 0;
  right: 0;
  /* Under the header and mobile menu (z-50) and the age gate; over page content. */
  z-index: 49;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  height: var(--announcement-banner-height);
  padding: 0 1rem;
  overflow: hidden;
  background-color: var(--announcement-banner-bg);
  color: var(--announcement-banner-fg);
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/*
 * Brand wave lines, drifting slowly like the drink tiles' texture. One oversized,
 * non-repeating layer that slides sideways, so no tile seam ever shows.
 */
.announcement-banner::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: calc(100% + 300px); /* extra width = drift distance */
  min-width: 1400px;         /* keeps the curves gentle on phones */
  z-index: 0;
  background-image: url(../../static/svg/coast-lines-light.svg);
  background-repeat: no-repeat;
  background-size: 100% auto;
  background-position: center 45%;
  opacity: var(--announcement-banner-lines-opacity);
  pointer-events: none;
  animation: announcement-banner-drift 24s ease-in-out infinite;
}

@keyframes announcement-banner-drift {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(-300px); }
}

@media (prefers-reduced-motion: reduce) {
  .announcement-banner::before { animation: none; }
}

.announcement-banner__copy,
.announcement-banner__cta {
  position: relative; /* above the texture */
  z-index: 1;
}

.announcement-banner__copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.1;
}

.announcement-banner__lead {
  font-family: 'Hanley Script', cursive;
  font-size: 1.15rem;
  line-height: 1.05;
  letter-spacing: 0;
  white-space: nowrap;
}

/* Phones: may wrap to a second line rather than cut off the dates; clamped so it can't outgrow the bar. */
.announcement-banner__text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-family: 'Hanley Block Display', sans-serif;
  font-size: 0.6875rem;
  line-height: 1.15;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.announcement-banner__cta {
  /*
   * Hanley Block Display's capitals sit high in their line box, so equal
   * top/bottom padding looks top-heavy. Move padding from bottom to top by
   * --cta-optical-shift (in em so it scales with the font size) to centre the
   * letters visually. The pill's total height is unchanged.
   */
  --cta-pad-y: 0.425rem;
  --cta-pad-x: 0.75rem;
  --cta-optical-shift: 0.14em;

  flex-shrink: 0;
  padding:
    calc(var(--cta-pad-y) + var(--cta-optical-shift))
    var(--cta-pad-x)
    calc(var(--cta-pad-y) - var(--cta-optical-shift));
  border-radius: 9999px;
  background-color: var(--announcement-banner-cta-bg);
  color: var(--announcement-banner-cta-fg);
  font-family: 'Hanley Block Display', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
}

a.announcement-banner:hover .announcement-banner__cta,
a.announcement-banner:focus-visible .announcement-banner__cta {
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}

a.announcement-banner:focus-visible {
  outline: 2px solid var(--announcement-banner-fg);
  outline-offset: -4px;
}

/* Wider screens: one centred line. Script lead-in · block message · pill. */
@media (min-width: 768px) {
  .announcement-banner {
    justify-content: center;
    gap: 1.25rem;
  }

  .announcement-banner__copy {
    flex-direction: row;
    align-items: baseline;
    gap: 0.75rem;
  }

  .announcement-banner__lead {
    font-size: 1.6rem;
  }

  .announcement-banner__text {
    -webkit-line-clamp: 1;
    font-size: 0.9375rem;
    letter-spacing: 0.08em;
  }

  .announcement-banner__cta {
    --cta-pad-x: 1.1rem;
    --cta-optical-shift: 0.2em; /* measured: at this size 0.14em still left the text ~1px high */
    font-size: 0.8125rem;
  }
}

/*
 * Push the fixed header down below the banner. The header sets top:2rem inline
 * (views/header/header-between.twig), so !important is needed to override it.
 * This only applies while the banner is rendered, so the site looks exactly as
 * before when the banner is off.
 */
.announcement-banner ~ .header-between {
  top: calc(var(--announcement-banner-top) + var(--announcement-banner-height)) !important;
}
