/**
 * Buy at Amazon Button — left-edge tab.
 * The label is shown by default, expanded to the right of the cart icon. On
 * hover or keyboard focus the tab nudges outward from the screen edge and
 * darkens slightly. Below the breakpoint it pins to the bottom edge and
 * collapses to the icon alone. The top/bottom offset and the breakpoint are
 * injected inline from the plugin settings.
 */

.bab-button {
  --bab-nudge: 3px;

  position: fixed;
  top: var(--bab-top, 100px);
  left: calc(
    -1 * var(--bab-nudge)
  ); /* overhangs the edge so the nudge can't open a gap */
  z-index: 99990;

  display: inline-flex;
  align-items: center;
  gap: 0;

  margin: 0;
  padding: 0.7em 1em 0.7em calc(0.7em + var(--bab-nudge));

  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;

  color: #d7dac8;
  background: #4c9900;
  border: 1px solid #4c9900;
  border-left: none; /* sits flush against the screen edge */
  border-radius: 0 20px 20px 0; /* tab: round the outer (right) side only */
  box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.12);
  cursor: pointer;

  transform: translateX(0);
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease;
}

.bab-icon {
  width: 1.15em;
  height: 1.15em;
  flex: 0 0 auto;
}

/* Visible by default. The max-width/opacity machinery is retained so the label
   can collapse below the breakpoint while staying in the DOM for screen
   readers, which always announce the full "Buy at Amazon" text. */
.bab-label {
  display: inline-block;
  max-width: 14em;
  margin-left: 0.5em;
  overflow: hidden;
  white-space: nowrap;
  opacity: 1;
  transition:
    max-width 0.28s ease,
    margin-left 0.28s ease,
    opacity 0.2s ease;
}

/* :focus-visible only — bare :focus would stick the nudge on after a click. */
.bab-button:hover,
.bab-button:focus-visible {
  color: #d7dac8;
  background: #438600;
  border-color: #438600;
  transform: translateX(var(--bab-nudge));
  box-shadow: 3px 3px 14px rgba(0, 0, 0, 0.22);
}

.bab-button:focus-visible {
  outline: 3px solid #007185;
  outline-offset: 2px;
}

@media screen and (max-width: 1685px) {
  .bab-button {
    top: auto;
    bottom: var(--bab-top, 100px);
    padding-right: calc(
      0.7em + var(--bab-nudge)
    ); /* even up around the lone icon */
  }

  /* Icon-only at this size. The hover/focus overrides matter: touch devices
     leave :hover stuck after a tap, which would otherwise expand the label
     and leave it expanded. */
  .bab-label,
  .bab-button:hover .bab-label,
  .bab-button:focus-visible .bab-label {
  }
}

@media (prefers-reduced-motion: reduce) {
  .bab-button,
  .bab-label {
    transition: none;
  }

  .bab-button:hover,
  .bab-button:focus-visible {
    transform: none; /* colour still changes — that's the part carrying meaning */
  }
}
