/* bi_herobanner - mobile-first editorial hero banner */

/*
 * Every visual aspect is driven by custom properties so the banner can be
 * re-skinned from the theme's own CSS without touching this file: declare the
 * public `--bi-hero-*` ones you need on `.bi-hero` (or higher up the tree).
 *
 * This file never declares a public token itself, it only reads them with a
 * fallback into a private `--_bi-hero-*` copy. That way a theme wins even from
 * inside a CSS cascade layer, which unlayered declarations of the same
 * property on the same element would otherwise always beat.
 *
 * On a light background (see .bi-hero--light) the colour tokens are read from
 * their `--bi-hero-light-*` twins instead.
 */
.bi-hero {
  --_bi-hero-bg: var(--bi-hero-bg, #101010);
  --_bi-hero-color: var(--bi-hero-color, #fff);
  --_bi-hero-muted: var(--bi-hero-muted, rgba(255, 255, 255, 0.72));
  --_bi-hero-radius: var(--bi-hero-radius, 0);
  --_bi-hero-content-width: var(--bi-hero-content-width, 47%);
  --_bi-hero-min-height: var(--bi-hero-min-height, 32rem);
  --_bi-hero-media-ratio: var(--bi-hero-media-ratio, 4 / 3);
  --_bi-hero-padding-inline: var(--bi-hero-padding-inline, clamp(1.25rem, 4vw, 4rem));
  --_bi-hero-padding-block: var(--bi-hero-padding-block, clamp(1.5rem, 4vw, 4rem));
  --_bi-hero-title-font: var(--bi-hero-title-font, Georgia, "Times New Roman", serif);
  --_bi-hero-title-size: var(--bi-hero-title-size, clamp(1.875rem, 4vw, 3.5rem));
  --_bi-hero-price-size: var(--bi-hero-price-size, clamp(1.75rem, 3.2vw, 3rem));
  --_bi-hero-badge-bg: var(--bi-hero-badge-bg, #fff);
  --_bi-hero-badge-color: var(--bi-hero-badge-color, #101010);
  --_bi-hero-btn-radius: var(--bi-hero-btn-radius, 0);
  --_bi-hero-btn-primary-bg: var(--bi-hero-btn-primary-bg, #fff);
  --_bi-hero-btn-primary-color: var(--bi-hero-btn-primary-color, #101010);
  --_bi-hero-btn-secondary-bg: var(--bi-hero-btn-secondary-bg, rgba(255, 255, 255, 0.06));
  --_bi-hero-btn-secondary-bg-hover: var(--bi-hero-btn-secondary-bg-hover, rgba(255, 255, 255, 0.16));
  --_bi-hero-btn-secondary-color: var(--bi-hero-btn-secondary-color, #fff);
  --_bi-hero-btn-secondary-border: var(--bi-hero-btn-secondary-border, rgba(255, 255, 255, 0.35));
  --_bi-hero-chip-bg: var(--bi-hero-chip-bg, rgba(255, 255, 255, 0.12));
  --_bi-hero-title-weight: var(--bi-hero-title-weight, 400);
  --_bi-hero-title-line-height: var(--bi-hero-title-line-height, 1.08);
  --_bi-hero-text-size: var(--bi-hero-text-size, 1rem);
  --_bi-hero-text-width: var(--bi-hero-text-width, 34rem);
  --_bi-hero-badge-padding: var(--bi-hero-badge-padding, 0.4375rem 1rem);
  --_bi-hero-badge-radius: var(--bi-hero-badge-radius, 999px);
  --_bi-hero-badge-size: var(--bi-hero-badge-size, 0.75rem);
  --_bi-hero-badge-letter-spacing: var(--bi-hero-badge-letter-spacing, 0.08em);
  --_bi-hero-badge-weight: var(--bi-hero-badge-weight, 600);
  --_bi-hero-btn-padding: var(--bi-hero-btn-padding, 0.9375rem 1.75rem);
  --_bi-hero-btn-size: var(--bi-hero-btn-size, 0.9375rem);
  --_bi-hero-btn-weight: var(--bi-hero-btn-weight, 600);
  --_bi-hero-btn-primary-border: var(--bi-hero-btn-primary-border, transparent);

  /* Overlay layout only (media position "overlay"). */
  --_bi-hero-overlay: var(--bi-hero-overlay, linear-gradient(90deg, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.45) 45%, rgba(0, 0, 0, 0.05) 100%));
  --_bi-hero-overlay-mobile: var(--bi-hero-overlay-mobile, linear-gradient(0deg, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.5) 55%, rgba(0, 0, 0, 0.2) 100%));
  --_bi-hero-overlay-content-width: var(--bi-hero-overlay-content-width, 36rem);
  --_bi-hero-overlay-min-height: var(--bi-hero-overlay-min-height, var(--_bi-hero-min-height));
  --_bi-hero-overlay-min-height-mobile: var(--bi-hero-overlay-min-height-mobile, 28rem);

  position: relative;
  overflow: hidden;
  border-radius: var(--_bi-hero-radius);
  background-color: var(--_bi-hero-bg);
  color: var(--_bi-hero-color);
}

/*
 * Light background: the defaults above are white text on white buttons, which
 * disappears on anything pale. The back office picks this modifier on its own
 * from the luminance of the chosen colour, so a merchant never has to think
 * about contrast. Only the colours change; the layout tokens stay as they are.
 */
.bi-hero--light {
  --_bi-hero-color: var(--bi-hero-light-color, #101010);
  --_bi-hero-muted: var(--bi-hero-light-muted, rgba(16, 16, 16, 0.68));
  --_bi-hero-badge-bg: var(--bi-hero-light-badge-bg, #101010);
  --_bi-hero-badge-color: var(--bi-hero-light-badge-color, #fff);
  --_bi-hero-btn-primary-bg: var(--bi-hero-light-btn-primary-bg, #101010);
  --_bi-hero-btn-primary-color: var(--bi-hero-light-btn-primary-color, #fff);
  --_bi-hero-btn-secondary-bg: var(--bi-hero-light-btn-secondary-bg, rgba(16, 16, 16, 0.04));
  --_bi-hero-btn-secondary-bg-hover: var(--bi-hero-light-btn-secondary-bg-hover, rgba(16, 16, 16, 0.1));
  --_bi-hero-btn-secondary-color: var(--bi-hero-light-btn-secondary-color, #101010);
  --_bi-hero-btn-secondary-border: var(--bi-hero-light-btn-secondary-border, rgba(16, 16, 16, 0.3));
  --_bi-hero-chip-bg: var(--bi-hero-light-chip-bg, rgba(16, 16, 16, 0.1));
}

.bi-hero__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.bi-hero__content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: var(--_bi-hero-padding-block) var(--_bi-hero-padding-inline);
}

.bi-hero__badge {
  display: inline-block;
  max-width: 100%;
  margin: 0 0 1.25rem;
  padding: var(--_bi-hero-badge-padding);
  border-radius: var(--_bi-hero-badge-radius);
  background-color: var(--_bi-hero-badge-bg);
  color: var(--_bi-hero-badge-color);
  font-size: var(--_bi-hero-badge-size);
  font-weight: var(--_bi-hero-badge-weight);
  letter-spacing: var(--_bi-hero-badge-letter-spacing);
  line-height: 1.2;
  text-transform: uppercase;
}

.bi-hero__title {
  margin: 0 0 1rem;
  font-family: var(--_bi-hero-title-font);
  font-size: var(--_bi-hero-title-size);
  font-weight: var(--_bi-hero-title-weight);
  line-height: var(--_bi-hero-title-line-height);
  color: inherit;
}

.bi-hero__text {
  max-width: var(--_bi-hero-text-width);
  margin: 0 0 1.75rem;
  color: var(--_bi-hero-muted);
  font-size: var(--_bi-hero-text-size);
  line-height: 1.55;
}

.bi-hero__price {
  margin: 0 0 1.75rem;
}

.bi-hero__price-prefix {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--_bi-hero-muted);
  font-size: 0.875rem;
}

.bi-hero__price-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.75rem;
}

.bi-hero__price-current {
  font-family: var(--_bi-hero-title-font);
  font-size: var(--_bi-hero-price-size);
  font-weight: 400;
  line-height: 1.1;
}

/*
 * Screen-reader-only label, defined here so the banner never depends on the
 * host theme shipping a `.visually-hidden` helper.
 */
.bi-hero__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.bi-hero__price-old {
  color: var(--_bi-hero-muted);
  font-size: 1.125rem;
}

.bi-hero__discount {
  padding: 0.25rem 0.625rem;
  border-radius: 0.25rem;
  background-color: var(--_bi-hero-chip-bg);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
}

.bi-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  width: 100%;
}

.bi-hero__btn {
  flex: 1 1 12rem;
  padding: var(--_bi-hero-btn-padding);
  border: 1px solid transparent;
  border-radius: var(--_bi-hero-btn-radius);
  font-size: var(--_bi-hero-btn-size);
  font-weight: var(--_bi-hero-btn-weight);
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: opacity 0.2s ease, background-color 0.2s ease;
}

.bi-hero__btn:hover,
.bi-hero__btn:focus {
  text-decoration: none;
}

.bi-hero__btn--primary {
  border-color: var(--_bi-hero-btn-primary-border);
  background-color: var(--_bi-hero-btn-primary-bg);
  color: var(--_bi-hero-btn-primary-color);
}

.bi-hero__btn--primary:hover,
.bi-hero__btn--primary:focus {
  color: var(--_bi-hero-btn-primary-color);
  opacity: 0.85;
}

.bi-hero__btn--secondary {
  border-color: var(--_bi-hero-btn-secondary-border);
  background-color: var(--_bi-hero-btn-secondary-bg);
  color: var(--_bi-hero-btn-secondary-color);
}

.bi-hero__btn--secondary:hover,
.bi-hero__btn--secondary:focus {
  background-color: var(--_bi-hero-btn-secondary-bg-hover);
  color: var(--_bi-hero-btn-secondary-color);
}

.bi-hero__media {
  position: relative;
  min-width: 0;
}

.bi-hero__media picture {
  display: block;
  height: 100%;
}

/*
 * The upload is always cropped to the box it is given, never the other way
 * round: `height: 100%` wins over the ratio as soon as the box has a height of
 * its own, so two banners whose images have different formats stay exactly the
 * same height. The ratio only kicks in when nothing else sets one — a lone
 * stacked banner.
 */
.bi-hero__image {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: var(--_bi-hero-media-ratio);
  object-fit: cover;
  /* Merchant-tunable framing, e.g. `--bi-hero-media-position: 50% 20%`. */
  object-position: var(--bi-hero-media-position, 50% 50%);
}

/*
 * Mobile-only trimming: keep the banner short above the fold by dropping the
 * secondary information. Everything stays in the DOM for wider viewports.
 */
@media (max-width: 767.98px) {
  /*
   * Stacked, the media is the row that absorbs any extra height the carousel
   * gives a shorter banner — otherwise that surplus is left as a strip of
   * background under the image.
   */
  .bi-hero__inner {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .bi-hero--compact-mobile .bi-hero__text,
  .bi-hero--compact-mobile .bi-hero__price-prefix,
  .bi-hero--compact-mobile .bi-hero__discount,
  .bi-hero--compact-mobile .bi-hero__btn--secondary {
    display: none;
  }

  .bi-hero--compact-mobile .bi-hero__title {
    margin-bottom: 0.75rem;
  }

  .bi-hero--compact-mobile .bi-hero__price {
    margin-bottom: 1.25rem;
  }
}

@media (min-width: 768px) {
  .bi-hero__inner {
    grid-template-columns: minmax(0, var(--_bi-hero-content-width)) minmax(0, 1fr);
    align-items: stretch;
    min-height: var(--_bi-hero-min-height);
  }

  /* No image uploaded: the editorial panel spans the whole banner. */
  .bi-hero__content:only-child {
    grid-column: 1 / -1;
  }

  .bi-hero--media-left .bi-hero__inner {
    grid-template-columns: minmax(0, 1fr) minmax(0, var(--_bi-hero-content-width));
  }

  .bi-hero--media-left .bi-hero__content {
    grid-row: 1;
    grid-column: 2;
  }

  .bi-hero--media-left .bi-hero__media {
    grid-row: 1;
    grid-column: 1;
  }

  .bi-hero__btn {
    flex: 0 0 auto;
  }

  /*
   * Side by side, the banner is --bi-hero-min-height tall (more only if the
   * editorial panel needs it) and the media fills that row. The picture is
   * taken out of the flow so that a tall upload cannot push the row open and
   * make this banner taller than the next one in the carousel.
   */
  .bi-hero__media picture {
    position: absolute;
    inset: 0;
  }

  .bi-hero__image {
    aspect-ratio: auto;
  }
}

/* ==========================================================================
   Overlay layout (media position "overlay"): the visual fills the whole
   banner and the editorial panel sits on top of it, over a gradient that keeps
   the text readable. Bottom-anchored on mobile, vertically centred on desktop.
   ========================================================================== */

.bi-hero--media-overlay .bi-hero__inner {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  min-height: var(--_bi-hero-overlay-min-height-mobile);
}

.bi-hero--media-overlay .bi-hero__content,
.bi-hero--media-overlay .bi-hero__media {
  grid-row: 1;
  grid-column: 1;
}

.bi-hero--media-overlay .bi-hero__content {
  position: relative;
  z-index: 1;
  justify-content: flex-end;
}

.bi-hero--media-overlay .bi-hero__title,
.bi-hero--media-overlay .bi-hero__actions {
  max-width: var(--_bi-hero-overlay-content-width);
}

/* The banner sizes itself on the text, never on the upload. */
.bi-hero--media-overlay .bi-hero__media picture {
  position: absolute;
  inset: 0;
}

.bi-hero--media-overlay .bi-hero__image {
  aspect-ratio: auto;
}

.bi-hero--media-overlay .bi-hero__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--_bi-hero-overlay-mobile);
  pointer-events: none;
}

/* Keep the bottom-anchored text clear of the carousel control bar. */
.bi-hero-carousel .bi-hero--media-overlay .bi-hero__content {
  padding-bottom: calc(var(--_bi-hero-padding-block) + 3rem);
}

@media (min-width: 768px) {
  .bi-hero--media-overlay .bi-hero__inner {
    grid-template-columns: minmax(0, 1fr);
    min-height: var(--_bi-hero-overlay-min-height);
  }

  .bi-hero--media-overlay .bi-hero__content {
    justify-content: center;
  }

  .bi-hero--media-overlay .bi-hero__media::after {
    background: var(--_bi-hero-overlay);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bi-hero__btn {
    transition: none;
  }
}

/* ==========================================================================
   Carousel — only rendered when the shop has more than one active banner.
   The track is a scroll-snap slider, so it swipes on touch and stays usable
   without JavaScript; bi-herobanner.js adds auto-rotation and the controls.
   ========================================================================== */

.bi-hero-carousel {
  --_bi-hero-carousel-bar-bg: var(--bi-hero-carousel-bar-bg, rgba(16, 16, 16, 0.7));
  --_bi-hero-carousel-bar-border: var(--bi-hero-carousel-bar-border, rgba(255, 255, 255, 0.18));
  --_bi-hero-carousel-control-color: var(--bi-hero-carousel-control-color, #fff);
  --_bi-hero-carousel-control-bg-hover: var(--bi-hero-carousel-control-bg-hover, rgba(255, 255, 255, 0.16));
  --_bi-hero-carousel-dot-size: var(--bi-hero-carousel-dot-size, 0.5rem);
  --_bi-hero-carousel-dot-bg: var(--bi-hero-carousel-dot-bg, rgba(255, 255, 255, 0.45));
  --_bi-hero-carousel-dot-bg-current: var(--bi-hero-carousel-dot-bg-current, #fff);
  --_bi-hero-carousel-inset: var(--bi-hero-carousel-inset, clamp(0.75rem, 2vw, 1.5rem));

  position: relative;
}

.bi-hero-carousel__track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  /* The dots are the scroll indicator; a native bar would sit on the banner. */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.bi-hero-carousel__track::-webkit-scrollbar {
  display: none;
}

.bi-hero-carousel__slide {
  display: flex;
  flex: 0 0 100%;
  min-width: 0;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

/*
 * Every slide is as tall as the tallest one, so rotating never shifts the page.
 * The banner and its grid have to take that whole height, otherwise a shorter
 * banner is painted on a taller slide and shows its background underneath.
 */
.bi-hero-carousel__slide > .bi-hero {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
}

.bi-hero-carousel__slide > .bi-hero > .bi-hero__inner {
  flex: 1 1 auto;
  min-width: 0;
}

.bi-hero-carousel__controls {
  position: absolute;
  right: 0;
  bottom: var(--_bi-hero-carousel-inset);
  left: 0;
  z-index: 2;
  display: flex;
  justify-content: center;
  padding: 0 var(--_bi-hero-carousel-inset);
  pointer-events: none;
}

/*
 * The controls are useless until the script wires them up: keep them out of
 * the layout, and out of the tab order, while JavaScript has not run.
 */
.bi-hero-carousel:not(.bi-hero-carousel--ready) .bi-hero-carousel__controls {
  display: none;
}

.bi-hero-carousel__bar {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3125rem;
  border: 1px solid var(--_bi-hero-carousel-bar-border);
  border-radius: 999px;
  background-color: var(--_bi-hero-carousel-bar-bg);
  pointer-events: auto;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.bi-hero-carousel__arrow,
.bi-hero-carousel__play,
.bi-hero-carousel__dot {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background-color: transparent;
  color: var(--_bi-hero-carousel-control-color);
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.bi-hero-carousel__arrow,
.bi-hero-carousel__play {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
}

.bi-hero-carousel__arrow:hover,
.bi-hero-carousel__arrow:focus-visible,
.bi-hero-carousel__play:hover,
.bi-hero-carousel__play:focus-visible {
  background-color: var(--_bi-hero-carousel-control-bg-hover);
}

.bi-hero-carousel__icon {
  display: block;
  pointer-events: none;
}

/* One icon at a time: pause while rotating, play once stopped. */
.bi-hero-carousel__icon--play,
.bi-hero-carousel--paused .bi-hero-carousel__icon--pause {
  display: none;
}

.bi-hero-carousel--paused .bi-hero-carousel__icon--play {
  display: block;
}

.bi-hero-carousel__separator {
  align-self: stretch;
  width: 1px;
  margin: 0.25rem 0.125rem;
  background-color: var(--_bi-hero-carousel-bar-border);
}

.bi-hero-carousel__dots {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.5rem;
}

.bi-hero-carousel__dot {
  width: var(--_bi-hero-carousel-dot-size);
  height: var(--_bi-hero-carousel-dot-size);
  border-radius: 999px;
  background-color: var(--_bi-hero-carousel-dot-bg);
}

.bi-hero-carousel__dot:hover {
  background-color: var(--_bi-hero-carousel-dot-bg-current);
}

.bi-hero-carousel__dot--current {
  background-color: var(--_bi-hero-carousel-dot-bg-current);
  transform: scale(1.35);
}

.bi-hero-carousel__arrow:focus-visible,
.bi-hero-carousel__play:focus-visible,
.bi-hero-carousel__dot:focus-visible {
  outline: 2px solid var(--_bi-hero-carousel-dot-bg-current);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .bi-hero-carousel__arrow,
  .bi-hero-carousel__play,
  .bi-hero-carousel__dot {
    transition: none;
  }
}
