/* Berry Loyalty — every customer-facing berry style lives in this file.

   Self-contained on purpose: no theme variables, no theme fonts, no theme
   font sizes in any calculation. Colours are defined below as --berry-*
   custom properties; type inherits the surrounding page's font. The only
   outside markup it styles is WooCommerce's own product-loop structure
   (`ul.products li.product .price`), which exists under any theme. */

:root {
  --berry-bg:            linear-gradient(135deg, #F6F0FF 0%, #FDEFF5 100%);
  --berry-border:        rgba(124, 58, 237, 0.18);
  --berry-border-strong: rgba(124, 58, 237, 0.35);
  --berry-shadow:        0 1px 2px rgba(109, 40, 217, 0.08);
  --berry-num:           #6D28D9;
  --berry-word:          #8B5CF6;
  --berry-text:          #4C1D95;
  --berry-icon-bg:       #FFFFFF;
  --berry-tooltip-bg:    #2E1065;
  --berry-tooltip-text:  #FFFFFF;
}

/* ── The icon ────────────────────────────────────────────────────────────
   Themes commonly style every <img> in a product card as a full-width photo
   and every <img> as display:block. These selectors out-specify such rules
   regardless of stylesheet order, and !important holds the size against any
   theme !important. Contextual sizes further down use even more specific
   selectors. */
img.berry-loyalty-icon,
.woocommerce ul.products li.product img.berry-loyalty-icon,
.woocommerce div.product img.berry-loyalty-icon {
  display: inline-block !important;
  width: 16px !important;
  height: 16px !important;
  max-width: none !important;
  aspect-ratio: auto !important;
  object-fit: contain !important;
  border-radius: 0 !important;
  margin: 0 !important;
  flex: 0 0 auto;
  vertical-align: middle;
}

/* ==========================================================================
   BERRY CHIP — used on product cards and in the cart drawer

     .berry-chip-wrap           role=note + aria-label (+ data-tooltip on cards)
       .berry-chip              the visible chip (aria-hidden)
         .berry-chip__head
           .berry-chip__icon    white circle holding the berry icon
           .berry-chip__verb    "Спечелете" (cards only)
         .berry-chip__body
           .berry-chip__num     "+25"
           .berry-chip__word    "berry"
   ========================================================================== */

.berry-chip-wrap {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  vertical-align: middle;
}

.berry-chip {
  position: relative;
  overflow: hidden; /* clips the shimmer */
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 10px 0 4px;
  box-sizing: border-box;
  border-radius: 999px;
  background: var(--berry-bg);
  border: 1px solid var(--berry-border);
  box-shadow: var(--berry-shadow);
  font-family: inherit;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  transition: border-color 0.2s ease;
}

.berry-chip__head,
.berry-chip__body {
  display: inline-flex;
  align-items: center;
  gap: inherit;
}

.berry-chip__verb {
  font-weight: 500;
  color: var(--berry-text);
}

.berry-chip__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--berry-icon-bg);
  box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.06);
}

.berry-chip__icon img.berry-loyalty-icon,
.woocommerce ul.products li.product .berry-chip__icon img.berry-loyalty-icon {
  width: 13px !important;
  height: 13px !important;
}

.berry-chip__num {
  font-weight: 700;
  color: var(--berry-num);
}

.berry-chip__word {
  font-weight: 700;
  color: var(--berry-word);
}

/* Shimmer: one diagonal pass, attached only while hovered, so it runs once
   per hover. */
.berry-chip::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 60%;
  background: linear-gradient(105deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.85) 50%, rgba(255, 255, 255, 0) 100%);
  transform: translateX(-120%);
  pointer-events: none;
}

.woocommerce ul.products li.product:hover .berry-chip,
.berry-chip-wrap:hover .berry-chip {
  border-color: var(--berry-border-strong);
}

.woocommerce ul.products li.product:hover .berry-chip::after,
.berry-chip-wrap:hover .berry-chip::after {
  animation: berry-chip-shimmer 700ms ease-out 1 both;
}

@keyframes berry-chip-shimmer {
  from { transform: translateX(-120%); }
  to   { transform: translateX(220%); }
}

/* Tooltip (cards only — the attribute is only emitted there). Anchored to
   the chip's right edge: the chip is the right-hand item of the price row,
   so the tooltip opens leftwards over the card, never past its edge. */
.berry-chip-wrap[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 5;
  width: max-content;
  max-width: 180px;
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--berry-tooltip-bg);
  color: var(--berry-tooltip-text);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  box-shadow: 0 6px 18px rgba(46, 16, 101, 0.18);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  pointer-events: none;
}

/* Pointer devices only — on touch a tooltip would stick after a tap. */
@media (hover: hover) {
  .berry-chip-wrap[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
}

/* Keyboard: the card itself is the focusable link, so the tooltip follows
   that link's focus instead of making the chip focusable. */
.woocommerce ul.products li.product a:focus-visible .berry-chip-wrap[data-tooltip]::after {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .berry-chip,
  .berry-chip-wrap[data-tooltip]::after {
    transition: none;
  }

  .berry-chip::after {
    content: none;
    animation: none;
  }
}

/* ==========================================================================
   PRODUCT CARDS — chip directly beside the price

     .price
       .berry-price-row        price block + chip, side by side
         .berry-price-block    old price (del) above, current price below
         .berry-chip-wrap      (omitted when the product earns nothing)

   COMPACT (default — phones, tablets, most desktop grids)
       12,99 €  ╭─────────────╮
                │ ● Спечелете │
                │ +25 berry   │
                ╰─────────────╯
   WIDE (card content ≥ 260px)
       12,99 €  (● Спечелете +25 berry)

   The two lines are a fixed layout (head row / body row), not wrapping
   text: each line is nowrap. Chosen by the CARD's own width (container
   query), so a grid row always shares one layout.

   Widths, measured from Inter's advance widths over the whole catalogue
   (widest pair: "739,99 €" with "+1 479"):
     compact, phone sizes  ≤ 131px   — a 360px phone's 2-column homepage
                                        card has ~132px of content
     compact, desktop      ≤ 158px
     wide                  ≤ 252px

   Should a card still be too narrow (very small screens, zoom), the chip
   drops under the price rather than overflowing (flex-wrap).

   .price reserves a fixed height with the row pinned to its bottom, so cards
   with or without an old price, and with or without a chip, measure the
   same and their buttons line up. Every line height is a fixed pixel value,
   so the reserved heights hold whatever font sizes the theme gives the
   price. The current-price line is exactly the chip's height, so the price
   sits centred beside the chip; the old-price line takes no width
   (width:0; overflow visible), so a long "ПЦД: 899,99 €" cannot push the
   chip.
   ========================================================================== */

.woocommerce ul.products li.product {
  container-type: inline-size;

  --berry-card-old-line:  16px;
  --berry-card-chip-h:    32px;
}

/* A hovered card sits above its neighbours so its tooltip is never painted
   under the next card. */
.woocommerce ul.products li.product:hover {
  z-index: 2;
}

/* `span.price` lifts specificity above a theme's own `.price` rule. */
.woocommerce ul.products li.product span.price {
  display: flex;
  align-items: flex-end;
  align-content: flex-end;
  /* old-price line + gap + current-price line (= chip height) */
  min-height: calc(var(--berry-card-old-line) + 2px + var(--berry-card-chip-h));
}

.berry-price-row {
  display: flex;
  flex: 1 1 100%;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: flex-end;
  gap: 4px 8px;
  min-width: 0;
}

.berry-price-block {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  white-space: nowrap;
}

.berry-price-block > del {
  flex: none;
  width: 0;
  overflow: visible;
  line-height: var(--berry-card-old-line);
}

.berry-price-block > :not(del) {
  flex: none;
  line-height: var(--berry-card-chip-h);
}

/* Compact chip: two fixed lines. */
.woocommerce ul.products li.product .berry-chip-wrap--card .berry-chip {
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  height: var(--berry-card-chip-h);
  padding: 0 7px;
  border-radius: 10px;
  font-size: 11px;
}

.woocommerce ul.products li.product .berry-chip-wrap--card .berry-chip__head,
.woocommerce ul.products li.product .berry-chip-wrap--card .berry-chip__body {
  gap: 3px;
}

.woocommerce ul.products li.product .berry-chip-wrap--card .berry-chip__verb {
  font-size: 10px;
}

/* Beside a single line of text the white circle is too heavy; the bare
   icon leads the "Спечелете" line instead. */
.woocommerce ul.products li.product .berry-chip-wrap--card .berry-chip__icon {
  flex-basis: auto;
  width: auto;
  height: auto;
  background: none;
  box-shadow: none;
}

.woocommerce ul.products li.product .berry-chip-wrap--card .berry-chip__icon img.berry-loyalty-icon {
  width: 11px !important;
  height: 11px !important;
}

/* Wide cards: one line, the full chip. */
@container (min-width: 260px) {
  .woocommerce ul.products li.product .berry-chip-wrap--card .berry-chip {
    flex-direction: row;
    align-items: center;
    gap: 4px;
    height: 26px;
    padding: 0 10px 0 4px;
    border-radius: 999px;
    font-size: 12px;
  }

  .woocommerce ul.products li.product .berry-chip-wrap--card .berry-chip__head,
  .woocommerce ul.products li.product .berry-chip-wrap--card .berry-chip__body {
    gap: 4px;
  }

  .woocommerce ul.products li.product .berry-chip-wrap--card .berry-chip__verb {
    font-size: 12px;
  }

  .woocommerce ul.products li.product .berry-chip-wrap--card .berry-chip__icon {
    flex-basis: 18px;
    width: 18px;
    height: 18px;
    background: var(--berry-icon-bg);
    box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.06);
  }

  .woocommerce ul.products li.product .berry-chip-wrap--card .berry-chip__icon img.berry-loyalty-icon {
    width: 13px !important;
    height: 13px !important;
  }

  .berry-price-block > :not(del) {
    line-height: 26px;
  }

  .woocommerce ul.products li.product span.price {
    min-height: calc(var(--berry-card-old-line) + 2px + 26px);
  }
}

/* Phones: the theme's price type is smaller, and the cards are narrow, so
   the compact chip tightens to fit a 360px screen. */
@media (max-width: 768px) {
  .woocommerce ul.products li.product {
    --berry-card-old-line: 14px;
    --berry-card-chip-h:   30px;
  }

  .berry-price-row {
    column-gap: 4px;
  }

  .woocommerce ul.products li.product .berry-chip-wrap--card .berry-chip {
    padding: 0 5px;
    border-radius: 9px;
    font-size: 10px;
  }

  .woocommerce ul.products li.product .berry-chip-wrap--card .berry-chip__verb {
    font-size: 9px;
  }
}

/* ==========================================================================
   CART DRAWER — compact chip under each item's name, and a summary line
   under the drawer total. Rendered through the berry_cart_drawer_* actions.
   ========================================================================== */

.berry-drawer-item {
  margin: 0 0 6px;
  line-height: 0;
}

.berry-chip-wrap--drawer .berry-chip {
  height: 22px;
  padding: 0 8px 0 3px;
  gap: 3px;
  font-size: 11.5px;
}

.berry-chip-wrap--drawer .berry-chip__icon {
  flex-basis: 16px;
  width: 16px;
  height: 16px;
}

.berry-chip-wrap--drawer .berry-chip__icon img.berry-loyalty-icon {
  width: 11px !important;
  height: 11px !important;
}

.berry-drawer-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: -6px 0 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--berry-text);
}

.berry-drawer-total__label {
  opacity: 0.8;
}

/* ==========================================================================
   PRODUCT PAGE — pill under the price
   ========================================================================== */

.berry-earn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 10px 4px 7px;
  border-radius: 999px;
  background: var(--berry-bg);
  border: 1px solid var(--berry-border);
  color: var(--berry-text);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  box-sizing: border-box;
}

.berry-earn__text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.berry-earn__text strong {
  font-weight: 700;
  color: var(--berry-num);
}

.berry-earn--single {
  margin: 4px 0 14px;
  padding: 6px 14px 6px 10px;
  gap: 8px;
  font-size: 14px;
}

.berry-earn--single img.berry-loyalty-icon {
  width: 20px !important;
  height: 20px !important;
}

@media (max-width: 768px) {
  .berry-earn--single {
    font-size: 13px;
  }
}

/* ==========================================================================
   OTHER SURFACES
   ========================================================================== */

.berry-thankyou {
  display: flex;
  align-items: center;
  gap: 8px;
}

.berry-account__balance {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
}

.berry-account__balance img.berry-loyalty-icon {
  width: 28px !important;
  height: 28px !important;
}

.berry-account__pending,
.berry-account__expiring,
.berry-account__paused {
  margin: 4px 0;
  opacity: 0.8;
}

.berry-account__history {
  margin-top: 16px;
  width: 100%;
}

.berry-account__history th,
.berry-account__history td {
  text-align: left;
  padding: 6px 8px;
}

/* Icon inside the theme's dashboard summary card, if that card is present. */
.berry-rewards-card__icon img.berry-loyalty-icon {
  width: 54px !important;
  height: 54px !important;
}
