/*
 * Compare button and toasts. Colours come from `--pcfw-button-*` tokens
 * (Design settings); fallbacks match the storefront prototype.
 */
.pcfw-button {
  --_text: var(--pcfw-button-text, #14161b);
  --_bg: var(--pcfw-button-bg, #fff);
  --_border: var(--pcfw-button-border, #d5d8de);
  --_hover-text: var(--pcfw-button-hover-text, var(--_text));
  --_hover-bg: var(--pcfw-button-hover-bg, #f3f4f6);
  --_hover-border: var(--pcfw-button-hover-border, #c9cdd4);
  --_icon: var(--pcfw-button-icon, currentColor);
  --_icon-added: var(--pcfw-button-icon-added, #1d44b8);
  --_added-text: var(--pcfw-button-added-text, #1d44b8);
  --_added-bg: var(--pcfw-button-added-bg, #eaf0fd);
  --_added-border: var(--pcfw-button-added-border, #2b59e0);
  --_remove: var(--pcfw-button-remove, #b42318);
  --_remove-bg: var(--pcfw-button-remove-bg, #fef3f2);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.pcfw-button[aria-busy="true"] {
  cursor: progress;
  opacity: 0.7;
}

/* Only one of the three states is visible at a time. */
.pcfw-button__state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pcfw-button--icon-right .pcfw-button__state {
  flex-direction: row-reverse;
}

.pcfw-button__state--added,
.pcfw-button__state--remove,
.pcfw-button.is-added .pcfw-button__state--add {
  display: none;
}

.pcfw-button.is-added .pcfw-button__state--added {
  display: inline-flex;
}

@media (hover: hover) {
  .pcfw-button.is-added:hover .pcfw-button__state--added {
    display: none;
  }

  .pcfw-button.is-added:hover .pcfw-button__state--remove {
    display: inline-flex;
  }
}

.pcfw-icon {
  flex: none;
}

/* Own style (Design › Button › "Use my theme's button style" off). */
.pcfw-button.pcfw-button--custom {
  min-height: 44px;
  margin: 0;
  padding: 0 14px;
  border: 1px solid var(--_border);
  border-radius: var(--pcfw-button-radius, 24px);
  background: var(--_bg);
  color: var(--_text);
  font: inherit;
  font-family: var(--pcfw-button-font, inherit);
  font-size: var(--pcfw-button-font-size, 14px);
  font-weight: var(--pcfw-button-font-weight, 500);
  line-height: 1.2;
  text-decoration: none;
}

.pcfw-button.pcfw-button--custom:hover {
  border-color: var(--_hover-border);
  background: var(--_hover-bg);
  color: var(--_hover-text);
}

.pcfw-button--custom .pcfw-icon {
  color: var(--_icon);
}

.pcfw-button--custom.is-added .pcfw-button__state--added .pcfw-icon {
  color: var(--_icon-added);
}

.pcfw-button.pcfw-button--custom.is-added {
  border-color: var(--_added-border);
  background: var(--_added-bg);
  color: var(--_added-text);
}

@media (hover: hover) {
  .pcfw-button.pcfw-button--custom.is-added:hover {
    border-color: var(--_remove);
    background: var(--_remove-bg);
    color: var(--_remove);
  }
}

/*
 * Theme style: the theme's button as is; the check icon and label show the
 * state. Classic themes style `.button`, block themes `.wp-element-button`
 * (both classes are on it). These zero-specificity defaults only stop the
 * browser's own button look where a theme styles neither.
 */
:where(.pcfw-button--theme) {
  margin: 0;
  padding: 0.6em 1.2em;
  border: 1px solid currentColor;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1.2;
  text-decoration: none;
}

/* Next to a WooCommerce block (block themes): follow its alignment. */
.pcfw-button-block {
  display: flex;
  margin-bottom: 1rem;
}

.pcfw-button-block.is-align-center {
  justify-content: center;
}

.pcfw-button-block.is-align-right {
  justify-content: flex-end;
}

.pcfw-button-block .pcfw-button {
  margin-top: 0;
}
/* Checkbox style: a box that ticks when the product is in the list. */
.pcfw-button.pcfw-button--checkbox {
  gap: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: none;
}

.pcfw-button__box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--_border);
  border-radius: 4px;
  background: var(--_bg);
  color: transparent;
}

.pcfw-button--checkbox.is-added .pcfw-button__box {
  border-color: var(--_added-border);
  background: var(--_added-border);
  color: #fff;
}

/*
 * Link style: text with an underline in the page's colour; added turns the
 * "added" colour, and "remove on hover" turns red, like the button.
 */
.pcfw-button.pcfw-button--link {
  min-height: 24px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.pcfw-button.pcfw-button--link:hover {
  text-decoration-thickness: 2px;
}

.pcfw-button.pcfw-button--link.is-added {
  color: var(--_added-text);
}

@media (hover: hover) {
  .pcfw-button.pcfw-button--link.is-added:hover {
    color: var(--_remove);
  }
}

/* Icon only: a 44px square (circle with the own style), theme or own look. */
.pcfw-button.pcfw-button--icon {
  box-sizing: border-box;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
}

.pcfw-button--icon .pcfw-button__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.pcfw-button:focus-visible {
  outline: 2px solid var(--_added-border);
  outline-offset: 2px;
}

/* Loop spacing: sit next to or below Add to cart. */
.products .product .pcfw-button {
  margin-top: 8px;
}

/* Toasts. */
.pcfw-toasts {
  position: fixed;
  top: 24px;
  inset-inline-end: 24px;
  z-index: 100001;
  display: grid;
  gap: 8px;
  width: min(340px, calc(100% - 32px));
}

.pcfw-toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid #e4e6ea;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 12px 32px rgb(16 24 40 / 14%);
  color: #14161b;
  font-size: 14px;
  animation: pcfw-toast-in 0.18s ease-out;
}

.pcfw-toast.is-error {
  border-color: #fecdca;
}

.pcfw-toast__text {
  display: grid;
  flex: 1;
  gap: 2px;
  min-width: 0;
}

.pcfw-toast__text span {
  color: #5f6675;
  font-size: 13px;
}

.pcfw-toasts .pcfw-toast__action {
  padding: 0;
  border: 0;
  background: none;
  color: #1d44b8;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

@keyframes pcfw-toast-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pcfw-toast {
    animation: none;
  }
}

@media (max-width: 600px) {
  .pcfw-toasts {
    top: auto;
    bottom: 16px;
    inset-inline: 16px;
    width: auto;
  }
}

/* Sticky compare bar. Colours from `--pcfw-bar-*` (Design, Pro). */
.pcfw-bar {
  --_bar-bg: var(--pcfw-bar-bg, #14161b);
  --_bar-text: var(--pcfw-bar-text, #fff);
  --_bar-muted: color-mix(in srgb, var(--_bar-text) 70%, transparent);
  --_bar-btn-bg: var(--pcfw-bar-button-bg, #fff);
  --_bar-btn-text: var(--pcfw-bar-button-text, #14161b);
  --_accent: var(--pcfw-button-added-border, #2b59e0);

  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 99990;
  width: min(820px, calc(100% - 32px));
  transform: translateX(-50%);
  color: #14161b;
  font-size: 14px;
  line-height: 1.3;
}

.pcfw-bar[hidden] {
  display: none;
}

.pcfw-bar--top {
  top: 24px;
  bottom: auto;
}

/* Keep a top bar below the WordPress admin bar (32px, 46px on phones). */
.admin-bar .pcfw-bar--top {
  top: 56px;
}

@media (max-width: 782px) {
  .admin-bar .pcfw-bar--top {
    top: 58px;
  }
}

.pcfw-bar--align-left {
  inset-inline-start: 16px;
  transform: none;
}

.pcfw-bar--align-right {
  inset-inline: auto 16px;
  transform: none;
}

.pcfw-bar__panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 12px 12px 12px 16px;
  border-radius: 16px;
  background: var(--_bar-bg);
  box-shadow: 0 16px 40px rgb(16 24 40 / 30%);
  color: var(--_bar-text);
}

.pcfw-bar__slots {
  display: flex;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pcfw-bar__slots > li {
  margin: 0;
}

.pcfw-bar .pcfw-bar__slot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 10px;
  background: #fff;
}

.pcfw-bar__slot img {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  object-fit: cover;
}

.pcfw-bar .pcfw-bar__remove {
  position: absolute;
  top: -6px;
  inset-inline-end: -6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 2px solid var(--_bar-bg);
  border-radius: 50%;
  background: #fff;
  color: #14161b;
  cursor: pointer;
}

.pcfw-bar .pcfw-bar__slot--add {
  border: 1.5px dashed var(--_accent);
  background: color-mix(in srgb, var(--_bar-text) 8%, var(--_bar-bg));
  color: var(--_bar-text);
  cursor: pointer;
}

.pcfw-bar .pcfw-bar__slot--empty {
  border: 1.5px dashed color-mix(in srgb, var(--_bar-text) 28%, transparent);
  background: transparent;
}

.pcfw-bar__text {
  display: grid;
  flex: 1 1 140px;
  gap: 2px;
}

.pcfw-bar__text strong {
  font-size: 15px;
}

.pcfw-bar__text span {
  color: var(--_bar-muted);
  font-size: 13px;
}

.pcfw-bar .pcfw-bar__clear,
.pcfw-bar .pcfw-bar__toggle {
  height: 44px;
  margin: 0;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--_bar-muted);
  font: inherit;
  cursor: pointer;
}

.pcfw-bar .pcfw-bar__toggle {
  width: 44px;
  padding: 0;
}

.pcfw-bar .pcfw-bar__compare {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  margin: 0;
  padding: 0 20px;
  border: 0;
  border-radius: 10px;
  background: var(--_bar-btn-bg);
  color: var(--_bar-btn-text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.pcfw-bar .pcfw-bar__compare:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.pcfw-bar button:focus-visible {
  outline: 2px solid var(--_accent);
  outline-offset: 2px;
}

/* Minimised: only the pill shows. */
.pcfw-bar .pcfw-bar__pill {
  display: none;
  align-items: center;
  gap: 8px;
  height: 48px;
  margin: 0 auto;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--_bar-bg);
  box-shadow: 0 12px 32px rgb(16 24 40 / 30%);
  color: var(--_bar-text);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.pcfw-bar.is-collapsed {
  width: auto;
}

.pcfw-bar.is-collapsed .pcfw-bar__panel,
.pcfw-bar.is-collapsed .pcfw-bar__search {
  box-sizing: border-box;
  display: none;
}

.pcfw-bar.is-collapsed .pcfw-bar__pill {
  display: inline-flex;
}

/* "+ Add more" search popover. */
.pcfw-bar__search {
  width: 340px;
  max-width: 100%;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid #e4e6ea;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 12px 32px rgb(16 24 40 / 16%);
}

.pcfw-bar__search[hidden] {
  display: none;
}

.pcfw-bar--top .pcfw-bar__search {
  position: absolute;
  top: calc(100% + 10px);
}

.pcfw-bar__field {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 10px;
  border: 1.5px solid var(--_accent);
  border-radius: 8px;
  color: #5f6675;
}

.pcfw-bar .pcfw-bar__field input {
  flex: 1;
  min-width: 0;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  box-shadow: none;
  color: #14161b;
  font: inherit;
}

.pcfw-bar__status {
  margin: 6px 4px 0;
  color: #5f6675;
  font-size: 13px;
}

.pcfw-bar__status:empty {
  display: none;
}

.pcfw-bar__results {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.pcfw-bar__result {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}

.pcfw-bar__result:hover,
.pcfw-bar__result.is-active {
  background: #f3f4f6;
}

.pcfw-bar__result img {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: cover;
}

.pcfw-bar__result-name {
  flex: 1;
  min-width: 0;
}

.pcfw-bar__result-price {
  color: #5f6675;
}

.pcfw-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 600px) {
  .pcfw-bar {
    bottom: 12px;
  }

  .pcfw-bar__panel {
    gap: 10px;
  }

  .pcfw-bar__slots {
    gap: 8px;
    order: -1;
    width: 100%;
  }

  .pcfw-bar .pcfw-bar__slot {
    width: 48px;
    height: 48px;
  }

  .pcfw-bar .pcfw-bar__compare {
    flex: 1;
    justify-content: center;
  }

  .pcfw-bar__search {
    width: 100%;
  }
}

@media (max-width: 600px) {
  .pcfw-toasts {
    bottom: 96px;
  }
}

/* Header counter: round icon button with a count badge (label optional). */
.pcfw-counter {
  --_badge: var(--pcfw-button-added-border, #2b59e0);

  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 44px;
  height: 44px;
  margin: 0;
  padding: 0 6px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

/* (0,2,2): beats theme link rules such as `.ast-single-post .entry-content a`. */
html a.pcfw-counter[class],
html a.pcfw-counter[class]:hover,
html a.pcfw-counter[class]:focus {
  color: inherit;
  text-decoration: none;
}

.pcfw-counter.has-label {
  padding: 0 12px 0 8px;
}

.pcfw-counter:focus-visible {
  outline: 2px solid var(--_badge);
  outline-offset: 2px;
}

.pcfw-counter__label {
  font-weight: 500;
}

.pcfw-counter__badge {
  position: absolute;
  top: 3px;
  inset-inline-end: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--_badge);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.pcfw-counter.has-label .pcfw-counter__badge {
  position: static;
}

.pcfw-counter__badge[hidden] {
  display: none;
}

/* Print: no bar, toasts or Compare buttons on paper. */
@media print {
  body .pcfw-bar,
  body .pcfw-toasts,
  body .pcfw-button,
  body .pcfw-counter {
    display: none;
  }
}

/* Right-to-left: point the "Compare now" arrow the reading way. */
[dir="rtl"] .pcfw-bar__compare .pcfw-icon {
  transform: scaleX(-1);
}
