/**
 * BK Best Sellers - Creative Elements product grid widget
 *
 * Defaults reproduce the BudsKing "Best sellers" design (Home mockup). Every
 * value reads a widget property (`--bk-bs-*`, set by the CE style controls)
 * first, then the theme token (`--bk-*`), then a hard-coded fallback, so the
 * widget renders the same outside BudsKing. Selectors are scoped and slightly
 * reinforced (`.bk-bs …`) to resist generic theme rules on h2/h3/a/button/s.
 *
 * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
 */

/* ---- Root / wrapper ---------------------------------------------------- */
.bk-bs {
  --bk-bs-min: 230px;
  --bk-bs-gap: 18px;
  --bk-bs-radius: var(--bk-radius-card, 16px);
  --bk-bs-add-size: 34px;

  box-sizing: border-box;
  color: var(--bk-ink, #191712);
}

.bk-bs *,
.bk-bs *::before,
.bk-bs *::after {
  box-sizing: border-box;
}

.bk-bs--boxed {
  max-width: 1400px;
  margin: 0 auto;
  padding: 64px clamp(16px, 4vw, 40px);
}

.bk-bs [hidden] {
  display: none !important;
}

.bk-bs-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Header ------------------------------------------------------------ */
.bk-bs .bk-bs__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 30px;
}

.bk-bs .bk-bs__eyebrow {
  margin-bottom: 8px;
  color: var(--bk-bs-eyebrow, var(--bk-gold-dark, #b8902f));
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.26em;
  line-height: normal;
  text-transform: uppercase;
}

.bk-bs .bk-bs__title {
  margin: 0;
  padding: 0;
  color: var(--bk-bs-title, var(--bk-ink, #191712));
  font-family: var(--bk-font-serif, "Marcellus", georgia, serif);
  font-size: clamp(26px, 5vw, 40px);
  font-weight: 400;
  letter-spacing: normal;
  line-height: normal;
  text-transform: none;
}

.bk-bs .bk-bs__all {
  color: var(--bk-bs-link, var(--bk-gold-dark, #b8902f));
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: normal;
  text-decoration: none;
  text-transform: uppercase;
}

.bk-bs .bk-bs__all:hover,
.bk-bs .bk-bs__all:focus-visible {
  color: var(--bk-bs-link-hover, var(--bk-gold-hover, #8f6d1e));
}

/* ---- Grid -------------------------------------------------------------- */
.bk-bs .bk-bs__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(var(--bk-bs-min), 100%), 1fr));
  gap: var(--bk-bs-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.bk-bs .bk-bs__item {
  display: flex;
  min-width: 0;
  margin: 0;
  padding: 0;
}

.bk-bs .bk-bs__item::before,
.bk-bs .bk-bs__item::marker {
  content: none;
}

.bk-bs .bk-bs__empty {
  margin: 0;
  padding: 24px;
  border: 1px dashed var(--bk-border, #eadfc3);
  border-radius: var(--bk-bs-radius);
  color: var(--bk-muted, #6f6852);
  text-align: center;
}

/* ---- Card -------------------------------------------------------------- */
.bk-bs .bk-bs-card {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--bk-bs-card-border, var(--bk-border, #eadfc3));
  border-radius: var(--bk-bs-radius);
  background: var(--bk-bs-card-bg, var(--bk-surface, #fffdf6));
}

.bk-bs .bk-bs-card:hover {
  border-color: var(--bk-bs-card-border-hover, var(--bk-gold, #cfa544));
  box-shadow: var(--bk-shadow-card-hover, 0 14px 34px rgba(25, 23, 18, 0.08));
}

.bk-bs .bk-bs-card__media {
  position: relative;
  display: block;
  text-decoration: none;
}

.bk-bs .bk-bs-card__img {
  display: block;
  width: 100%;
  max-width: none;
  height: auto;
  margin: 0;
  aspect-ratio: 1;
  object-fit: cover;
}

.bk-bs .bk-bs-card__badges {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 6px;
}

.bk-bs .bk-bs-card__badge {
  display: inline-block;
  padding: 5px 10px;
  border-radius: var(--bk-radius-pill, 99px);
  font-size: 10.5px;
  font-weight: 700;
  line-height: normal;
  white-space: nowrap;
}

.bk-bs .bk-bs-card__badge--cbd {
  background: var(--bk-bs-cbd-bg, var(--bk-gold, #cfa544));
  color: var(--bk-bs-cbd-color, #fff);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.bk-bs .bk-bs-card__badge--alt {
  background: var(--bk-bs-alt-bg, var(--bk-ink, #191712));
  color: var(--bk-bs-alt-color, var(--bk-on-ink, #f3ecd8));
}

.bk-bs .bk-bs-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 7px;
  padding: 16px 18px 18px;
}

.bk-bs .bk-bs-card__type {
  color: var(--bk-bs-type, var(--bk-teal-text, #3e8578));
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: normal;
  text-transform: uppercase;
}

.bk-bs .bk-bs-card__name {
  margin: 0;
  padding: 0;
  font-family: var(--bk-font-serif, "Marcellus", georgia, serif);
  font-size: 20px;
  font-weight: 400;
  letter-spacing: normal;
  line-height: 1.2;
  text-transform: none;
}

.bk-bs .bk-bs-card__name a {
  color: var(--bk-bs-name, var(--bk-ink, #191712));
  font: inherit;
  text-decoration: none;
}

.bk-bs .bk-bs-card__name a:hover,
.bk-bs .bk-bs-card__name a:focus-visible {
  color: var(--bk-bs-name-hover, var(--bk-gold-dark, #b8902f));
}

.bk-bs .bk-bs-card__rating {
  color: var(--bk-bs-stars, var(--bk-gold, #cfa544));
  font-size: 12px;
  line-height: normal;
}

.bk-bs .bk-bs-star--empty {
  color: var(--bk-border, #eadfc3);
}

.bk-bs .bk-bs-card__reviews {
  color: var(--bk-muted, #6f6852);
}

/* ---- Weight pills ------------------------------------------------------ */
.bk-bs .bk-bs-card__variants {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.bk-bs .bk-bs-pill {
  display: inline-block;
  min-width: 46px;
  min-height: 0;
  margin: 0;
  padding: 8px 14px;
  border: 1px solid var(--bk-bs-pill-border, var(--bk-border, #eadfc3));
  border-radius: var(--bk-radius-pill, 99px);
  background: var(--bk-bs-pill-bg, var(--bk-surface, #fffdf6));
  box-shadow: none;
  color: var(--bk-bs-pill-color, var(--bk-ink, #191712));
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: normal;
  line-height: 1.2;
  text-align: center;
  text-transform: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.bk-bs .bk-bs-pill:hover {
  border-color: var(--bk-bs-pill-active-bg, var(--bk-ink, #191712));
}

.bk-bs .bk-bs-pill.is-active {
  border-color: var(--bk-bs-pill-active-bg, var(--bk-ink, #191712));
  background: var(--bk-bs-pill-active-bg, var(--bk-ink, #191712));
  color: var(--bk-bs-pill-active-color, var(--bk-on-ink, #f3ecd8));
}

/* Out-of-stock variant: struck through, even when selected. */
.bk-bs .bk-bs-pill[data-unavailable] {
  border-style: dashed;
  color: var(--bk-subtle, #a99f85);
  text-decoration: line-through;
}

.bk-bs .bk-bs-pill[data-unavailable].is-active {
  border-color: var(--bk-subtle, #a99f85);
  background: var(--bk-subtle, #a99f85);
  color: var(--bk-on-ink, #f3ecd8);
}

/* Sold-out product: frozen pills (no hover, no click). */
.bk-bs .bk-bs-pill:disabled {
  cursor: default;
}

.bk-bs .bk-bs-pill:disabled:hover {
  border-color: var(--bk-border, #eadfc3);
}

.bk-bs .bk-bs-pill:disabled.is-active:hover {
  border-color: var(--bk-subtle, #a99f85);
}

/* ---- Footer: price + add ---------------------------------------------- */
.bk-bs .bk-bs-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 6px;
}

.bk-bs .bk-bs-card__price {
  min-width: 0;
  color: var(--bk-bs-price, var(--bk-ink, #191712));
  font-size: 15.5px;
  font-weight: 700;
  line-height: normal;
}

.bk-bs .bk-bs-card__was {
  color: var(--bk-bs-was, var(--bk-subtle, #a99f85));
  font-size: 13px;
  font-weight: 400;
  text-decoration: line-through;
}

.bk-bs .bk-bs-card__form {
  display: flex;
  flex: none;
  margin: 0;
}

.bk-bs .bk-bs-card__add {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--bk-bs-add-size);
  height: var(--bk-bs-add-size);
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: var(--bk-radius-pill, 99px);
  background: var(--bk-bs-add-bg, var(--bk-teal, #2f9d8c));
  box-shadow: none;
  color: var(--bk-bs-add-color, #fff);
  font-family: inherit;
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

/* 44px touch target around the 34px visual. */
.bk-bs .bk-bs-card__add {
  position: relative;
}

.bk-bs .bk-bs-card__add::before {
  content: "";
  position: absolute;
  inset: -5px;
}

.bk-bs .bk-bs-card__add:hover,
.bk-bs .bk-bs-card__add:focus-visible {
  background: var(--bk-bs-add-bg-hover, var(--bk-teal-hover, #257f71));
  color: var(--bk-bs-add-color, #fff);
}

.bk-bs .bk-bs-card__add[disabled],
.bk-bs .bk-bs-card__add[aria-disabled="true"] {
  background: var(--bk-border, #eadfc3);
  color: var(--bk-subtle, #a99f85);
  cursor: not-allowed;
}

/* ---- Sold out ---------------------------------------------------------- */
.bk-bs .bk-bs-card--sold-out .bk-bs-card__img {
  filter: grayscale(0.4);
  opacity: 0.55;
}

.bk-bs .bk-bs-card__badge--sold-out {
  background: var(--bk-border, #eadfc3);
  color: var(--bk-ink, #191712);
}

/* ---- Notify me when available (ps_emailalerts) ------------------------- */
.bk-bs .bk-bs-card__notify {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bk-bs .bk-bs-card__notify[hidden],
.bk-bs .bk-bs-card__notify-form[hidden] {
  display: none;
}

.bk-bs .bk-bs-card__notify-toggle {
  align-self: flex-start;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--bk-teal, #2f9d8c);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  text-decoration: underline;
  text-transform: none;
  text-underline-offset: 2px;
  cursor: pointer;
}

.bk-bs .bk-bs-card__notify-toggle:hover {
  color: var(--bk-teal-hover, #257f71);
}

.bk-bs .bk-bs-card__notify-form {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
}

.bk-bs .bk-bs-card__notify-email {
  flex: 1 1 120px;
  min-width: 0;
  height: 34px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--bk-border, #eadfc3);
  border-radius: var(--bk-radius-pill, 99px);
  background: var(--bk-surface, #fffdf6);
  color: var(--bk-ink, #191712);
  font-family: inherit;
  font-size: 13px;
}

.bk-bs .bk-bs-card__notify-email:focus {
  border-color: var(--bk-ink, #191712);
  outline: none;
}

.bk-bs .bk-bs-card__notify-submit {
  flex: none;
  height: 34px;
  min-height: 0;
  margin: 0;
  padding: 0 14px;
  border: 0;
  border-radius: var(--bk-radius-pill, 99px);
  background: var(--bk-ink, #191712);
  color: var(--bk-on-ink, #f3ecd8);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  text-transform: none;
  cursor: pointer;
}

.bk-bs .bk-bs-card__notify-submit:disabled {
  cursor: progress;
  opacity: 0.7;
}

.bk-bs .bk-bs-card__notify-note {
  flex-basis: 100%;
  margin: 0;
  color: var(--bk-muted, #6f6852);
  font-size: 11.5px;
  line-height: 1.4;
}

.bk-bs .bk-bs-card__add[aria-busy="true"] {
  cursor: progress;
  opacity: 0.7;
}

.bk-bs .bk-bs-card__add.is-added {
  background: var(--bk-bs-add-bg-hover, var(--bk-teal-hover, #257f71));
}

/* ---- Focus ------------------------------------------------------------- */
.bk-bs .bk-bs__all:focus-visible,
.bk-bs .bk-bs-card__name a:focus-visible,
.bk-bs .bk-bs-pill:focus-visible,
.bk-bs .bk-bs-card__notify-toggle:focus-visible,
.bk-bs .bk-bs-card__add:focus-visible {
  outline: 2px solid var(--bk-gold-dark, #b8902f);
  outline-offset: 2px;
}

.bk-bs .bk-bs-card:focus-within {
  border-color: var(--bk-bs-card-border-hover, var(--bk-gold, #cfa544));
}

.bk-bs .bk-bs__status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: no-preference) {
  .bk-bs .bk-bs-card {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
  }

  .bk-bs .bk-bs-pill,
  .bk-bs .bk-bs-card__add,
  .bk-bs .bk-bs-card__name a {
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  }
}
