/**
 * Alphatrad Contact Bar.
 * Mobile (< 782px): fixed bar at the bottom, hidden while a text field has focus
 * (virtual keyboard open) and while the mobile menu is open.
 * Desktop: fixed column on the right.
 */

.acb-bar {
  position: fixed;
  z-index: 1000; /* Below the sticky header (1100), so the open mobile menu covers it. */
  display: flex;
  margin: 0;
  padding: 0;
}

.acb-button {
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  background-color: var(--acb-bg);
  color: var(--acb-fg);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

.acb-button:hover,
.acb-button:focus {
  color: var(--acb-fg);
  text-decoration: none;
  filter: brightness(0.95);
}

.acb-button:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: -4px;
}

.acb-button svg {
  flex: none;
  width: 22px;
  height: 22px;
}

.acb-label--desktop {
  display: none;
}

@media (max-width: 781.98px) {
  .acb-bar {
    left: 0;
    right: 0;
    bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.12);
  }

  .acb-button {
    flex: 1 1 0;
    min-width: 0;
    min-height: 60px;
  }

  /* Space so the bar does not cover the end of the footer. */
  body:has(.acb-bar) {
    padding-bottom: calc(60px + env(safe-area-inset-bottom));
  }

  /* Hidden while typing (a text field has focus) and while the mobile menu is open. */
  body:has(:is(input:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"], [type="file"], [type="range"], [type="hidden"]), textarea, [contenteditable="true"]):focus) .acb-bar,
  body:has(.wp-block-navigation__responsive-container.is-menu-open) .acb-bar {
    display: none;
  }

  body:has(:is(input:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"], [type="file"], [type="range"], [type="hidden"]), textarea, [contenteditable="true"]):focus) {
    padding-bottom: 0;
  }

  /* AppConsent "Privacy center" widget above the bar. */
  body:has(.acb-bar) #appconsent-widget > div {
    bottom: calc(68px + env(safe-area-inset-bottom)) !important;
  }
}

@media (min-width: 782px) {
  .acb-bar {
    top: 50%;
    right: 0;
    flex-direction: column;
    width: 76px;
    transform: translateY(-50%);
    border-radius: 8px 0 0 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  }

  .acb-button {
    min-height: 68px;
  }

  .acb-label--mobile {
    display: none;
  }

  .acb-label--desktop {
    display: inline;
  }

  /* Home page: keep the hero quote form clear of the fixed column (76px + 16px gap). */
  body.home:has(.acb-bar) .wp-block-post-content > .wp-block-cover.alignfull:first-child {
    padding-right: max(var(--wp--preset--spacing--24, 24px), 92px) !important;
  }
}
