/**
 * WPO Promo Bar — block layout (editor + front) and the site-wide region.
 *
 * The bar's colours come from the block's own colour/spacing supports; this
 * file only handles layout and the region's positioning + dismiss control.
 *
 * @package WPO_Promo_Bar
 */

/* Block — editor preview and front end */
.wpo-promo-bar-block {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 16px;
  padding: 8px 16px;
  text-align: center;
}
.wpo-promo-bar-block > * {
  margin-top: 0;
  margin-bottom: 0;
}
.wpo-promo-bar-block p {
  margin: 0;
}

/* Region wrapper — printed once at wp_body_open */
.wpo-promo-bar-region {
  position: relative;
  width: 100%;
  box-sizing: border-box;
  z-index: 1000;
}
.wpo-promo-bar-region--top {
  position: sticky;
  top: 0;
}
/* Sticky site header (.site-header.sticky.visible) re-appears below a visible top bar; JS sets the height + class. */
:root {
  --wpo-promo-h: 0px;
}
html.has-wpo-promo-top .site-header.sticky.visible {
  top: var(--wpo-promo-h) !important;
}
/* WP admin bar is fixed from 601px up (unless Better Admin Bar auto-hides it): stack bar + header below it. */
@media (min-width: 601px) {
  html:not(.auto-hide-admin-bar) body.admin-bar .wpo-promo-bar-region--top {
    top: var(--wp-admin--admin-bar--height, 32px);
  }
  html.has-wpo-promo-top:not(.auto-hide-admin-bar) body.admin-bar .site-header.sticky.visible {
    top: calc(var(--wp-admin--admin-bar--height, 32px) + var(--wpo-promo-h)) !important;
  }
}
.wpo-promo-bar-region--bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
}
.wpo-promo-bar-region__inner {
  width: 100%;
}
.wpo-promo-bar-region .wpo-promo-bar-block {
  width: 100%;
}

/* Tighter column gutter on small screens. */
@media (max-width: 781px) {
  .wpo-promo-bar-region div.wp-block-columns {
    gap: 12px;
  }
}

/* Dismiss control — WPO Modal-style corner tab: top-right on a top bar, bottom-right on a bottom bar; square in the bar's corner. */
.wpo-promo-bar-region__close {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  display: block;
  width: auto;
  min-width: 0;
  height: auto;
  min-height: 0;
  margin: 0;
  padding: 5px 6px 5px 7px;
  border: 1px solid rgba(189, 228, 243, 0.4);
  border-width: 0 0 1px 1px;
  border-radius: 0 0 0 50%;
  background: rgba(255, 255, 255, 0.5);
  color: #333;
  line-height: 0;
  cursor: pointer;
  opacity: 0.75;
  box-shadow: rgb(100 100 111 / 50%) 0 1px 3px 0;
  transition: opacity 0.15s ease, box-shadow 0.15s ease;
}
.wpo-promo-bar-region--bottom .wpo-promo-bar-region__close {
  top: auto;
  bottom: 0;
  border-width: 1px 0 0 1px;
  border-radius: 50% 0 0 0;
}
.wpo-promo-bar-region__close:hover,
.wpo-promo-bar-region__close:focus-visible {
  opacity: 1;
  box-shadow: rgb(100 100 111 / 80%) 0 1px 3px 0;
}
.wpo-promo-bar-region__close svg {
  display: block;
  transition: transform 0.2s ease-out;
}
.wpo-promo-bar-region__close:hover svg {
  transform: rotate(180deg);
}
/* Dark promo style: translucent grey tab, light cross. */
.wpo-promo-bar-region.is-dark .wpo-promo-bar-region__close {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(128, 128, 128, 0.25);
  color: #f2f2f2;
}
.wpo-promo-bar-region.is-dismissed {
  display: none !important;
}

/* Reveal triggers: armed bars stay hidden until JS adds is-revealed. */
.wpo-promo-bar-region.is-armed {
  display: none;
}
.wpo-promo-bar-region.is-armed.is-revealed {
  display: block;
}
.wpo-promo-bar-region--top.is-armed.is-revealed {
  animation: wpo-promo-bar-in-top 0.3s ease-out;
}
.wpo-promo-bar-region--bottom.is-armed.is-revealed {
  animation: wpo-promo-bar-in-bottom 0.3s ease-out;
}
@keyframes wpo-promo-bar-in-top {
  from { opacity: 0; transform: translateY(-100%); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes wpo-promo-bar-in-bottom {
  from { opacity: 0; transform: translateY(100%); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .wpo-promo-bar-region.is-armed.is-revealed {
    animation: none;
  }
}
