/* ==========================================================================
   Brand buttons (WB Games Support) - replaces Custom blocks
   Six diagonal panels in a single row; stacks into a grid on small screens.
   Hover/focus accent uses the theme's Primary color (Customize design > Colors).
   ========================================================================== */
.wb-brands {
  --wb-panel-height: 13rem;
  --wb-angle-ratio: 0.145;     /* horizontal lean per unit of height (~8.3deg from vertical) */
  --wb-slant: calc(var(--wb-panel-height) * var(--wb-angle-ratio)); /* how far each diagonal leans */
  --wb-gap: 0.4rem;            /* space between panels */
}
.wb-brands__heading { margin-bottom: 1.5rem; }

.wb-brands__grid {
  display: flex;
  height: var(--wb-panel-height);
  margin: 0;
  padding: 0;
  list-style: none;
}
.wb-brands__item {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  margin-inline-start: calc(var(--wb-gap) - var(--wb-slant)); /* overlap so diagonals interlock */
  transition: flex-grow 0.45s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.wb-brands__item:first-child { margin-inline-start: 0; }
.wb-brands__item:hover,
.wb-brands__item:focus-within { flex-grow: 1.4; }

.wb-brands__link {
  position: relative;
  display: flex;
  align-items: flex-end;
  height: 100%;
  overflow: hidden;
  padding: 0; /* the name band below carries the padding */
  /* Panel background: Customize design > Page background image overlay color
     Text: Customize design > Primary text color */
  background-color: var(--page-bg-mask, #0b0f1a);
  color: var(--color-text-primary, #fff);
  text-decoration: none;
  /* Leans left ("\"): top edge pulled in on the right, bottom edge pulled in on the left */
  clip-path: polygon(0 0, calc(100% - var(--wb-slant)) 0, 100% 100%, var(--wb-slant) 100%);
}
.wb-brands__item:first-child .wb-brands__link {
  clip-path: polygon(0 0, calc(100% - var(--wb-slant)) 0, 100% 100%, 0 100%);
  border-top-left-radius: var(--border-radius-lg, 12px);
  border-bottom-left-radius: var(--border-radius-lg, 12px);
}
.wb-brands__item:last-child .wb-brands__link {
  clip-path: polygon(0 0, 100% 0, 100% 100%, var(--wb-slant) 100%);
  border-top-right-radius: var(--border-radius-lg, 12px);
  border-bottom-right-radius: var(--border-radius-lg, 12px);
}

.wb-brands__art {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: saturate(0.85) brightness(0.8);
  transition: transform 0.6s ease, filter 0.4s ease;
}
.wb-brands__link::after {
  /* Primary-color accent bar along the bottom, shown on hover/focus */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0.3rem;
  background-color: var(--color-brand-primary);
  transform: scaleX(0);
  z-index: 2; /* sits above the name band */
  transform-origin: left;
  transition: transform 0.35s ease, height 0.2s ease;
}
.wb-brands__name {
  /* Semi-opaque band across the lower third of each panel, behind the brand name.
     It grows taller if a long name needs more room. The diagonal clip-path on the
     link trims the band to the panel shape. Adjust the rgba alpha (0.65) to taste. */
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 33.333%;
  padding: 0.6rem 1rem 0.7rem;
  padding-inline-start: calc(var(--wb-slant) + 0.5rem);
  background-color: rgba(5, 8, 16, 0.65);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  font-size: clamp(0.85rem, 1.05vw, 1.05rem);
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: break-word;
  hyphens: auto;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  transition: background-color 0.3s ease;
}
/* First panel has a straight left edge, so it needs no extra slant padding */
.wb-brands__item:first-child .wb-brands__name { padding-inline-start: 1rem; }
.wb-brands__link:hover .wb-brands__name,
.wb-brands__link:focus-visible .wb-brands__name { background-color: rgba(5, 8, 16, 0.75); }
.wb-brands__arrow { display: none; }

.wb-brands__link:hover,
.wb-brands__link:focus-visible { color: var(--color-text-primary, #fff); text-decoration: none; }
.wb-brands__link:hover .wb-brands__art,
.wb-brands__link:focus-visible .wb-brands__art {
  transform: scale(1.08);
  filter: saturate(1) brightness(1);
}
.wb-brands__link:hover::after { transform: scaleX(1); }
.wb-brands__link:active::after { background-color: var(--color-brand-primary-pressed); }

/* Keyboard focus: outlines are clipped by the diagonal shape, so use a
   thicker accent bar plus an underlined name instead */
.wb-brands__link:focus { outline: none; }
.wb-brands__link:focus-visible::after { transform: scaleX(1); height: 0.5rem; }
.wb-brands__link:focus-visible .wb-brands__name {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

/* Right-to-left languages (e.g. Arabic): the row runs right to left, so the
   panel shapes are mirrored. The first panel (rightmost) gets the straight,
   rounded right edge and the last panel (leftmost) the straight, rounded left edge. */
[dir="rtl"] .wb-brands__link {
  clip-path: polygon(var(--wb-slant) 0, 100% 0, calc(100% - var(--wb-slant)) 100%, 0 100%);
}
[dir="rtl"] .wb-brands__item:first-child .wb-brands__link {
  clip-path: polygon(var(--wb-slant) 0, 100% 0, 100% 100%, 0 100%);
  border-radius: 0 var(--border-radius-lg, 12px) var(--border-radius-lg, 12px) 0;
}
[dir="rtl"] .wb-brands__item:last-child .wb-brands__link {
  clip-path: polygon(0 0, 100% 0, calc(100% - var(--wb-slant)) 100%, 0 100%);
  border-radius: var(--border-radius-lg, 12px) 0 0 var(--border-radius-lg, 12px);
}
[dir="rtl"] .wb-brands__link::after { transform-origin: right; }

/* Tablets: 3 x 2 grid of straight tiles */
@media (max-width: 991px) {
  .wb-brands__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    height: auto;
  }
  .wb-brands__item,
  .wb-brands__item:first-child { margin: 0; }
  .wb-brands__link,
  .wb-brands__item:first-child .wb-brands__link,
  .wb-brands__item:last-child .wb-brands__link,
  [dir="rtl"] .wb-brands__link,
  [dir="rtl"] .wb-brands__item:first-child .wb-brands__link,
  [dir="rtl"] .wb-brands__item:last-child .wb-brands__link {
    clip-path: none;
    height: auto;
    aspect-ratio: 4 / 3;
    padding: 0;
    border-radius: var(--border-radius-lg, 12px);
  }
  .wb-brands__name,
  .wb-brands__item:first-child .wb-brands__name { padding: 0.6rem 1rem 0.7rem; }
}
/* Phones: 2 x 3 grid */
@media (max-width: 575px) {
  .wb-brands__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .wb-brands__item,
  .wb-brands__art,
  .wb-brands__name,
  .wb-brands__link::after { transition: none !important; }
  .wb-brands__item:hover,
  .wb-brands__item:focus-within { flex-grow: 1; }
  .wb-brands__link:hover .wb-brands__art,
  .wb-brands__link:focus-visible .wb-brands__art { transform: none; }
}
