/* =========================================================
   Brand Card
   1:1 card, flips on the vertical axis (rotateY) on hover /
   focus to reveal a custom snapshot. Per-card colours arrive as
   --brand-bg / --brand-fg inline variables.
   ========================================================= */

.brandcard-wrap {
  display: block;
}

.brandcard {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  perspective: 1200px;
  text-decoration: none;
  color: var(--brand-fg, #fff);
  outline: none;
  container-type: inline-size; /* lets the flag text scale with the card */
}

.brandcard__inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
  will-change: transform;
}

/* flip on hover, keyboard focus, or when JS toggles .is-flipped (touch) */
.brandcard:hover .brandcard__inner,
.brandcard:focus-visible .brandcard__inner,
.brandcard:focus-within .brandcard__inner,
.brandcard.is-flipped .brandcard__inner {
  transform: rotateY(180deg);
}

.brandcard__face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 16px;
  overflow: hidden;
  background: var(--brand-bg, #111);
}

.brandcard__front {
  padding: 16%;
}
.brandcard__back {
  transform: rotateY(180deg);
  align-items: stretch;
  justify-content: flex-start;
  padding: 9%;
  text-align: left;
}

/* logo */
.brandcard__logo {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}
.brandcard__logotext {
  font-weight: 800;
  font-size: clamp(1.4rem, 6vw, 2.4rem);
  line-height: 1.1;
  text-align: center;
  color: var(--brand-fg, #fff);
}

/* snapshot (back) */
.brandcard__snap {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  width: 100%;
  color: var(--brand-fg, #fff);
}
.brandcard__name {
  margin: 0;
  font-size: clamp(1rem, 2.4vw, 1.25rem);
  font-weight: 800;
  line-height: 1.1;
  color: #ffffff !important;
}
.brandcard__desc {
  margin: 0;
  font-size: clamp(0.8rem, 1.7vw, 0.9rem);
  line-height: 1.45;
  opacity: 0.92;
}
.brandcard__facts {
  list-style: none;
  margin: 0.15em 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3em;
}
.brandcard__facts li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: clamp(0.75rem, 1.6vw, 0.85rem);
  padding-top: 0.3em;
  border-top: 1px solid currentColor;
  /* keep the divider subtle regardless of fg colour */
  border-top-color: color-mix(in srgb, currentColor 30%, transparent);
}
.brandcard__facts .k {
  opacity: 0.75;
}
.brandcard__facts .v {
  font-weight: 700;
  text-align: right;
}
.brandcard__more {
  margin-top: auto;
  padding-top: 0.4em;
  font-weight: 700;
  font-size: clamp(0.75rem, 1.6vw, 0.85rem);
}

/* corner flag — fills the whole corner; text wraps along the diagonal */
.brandcard__flag {
  position: absolute;
  top: 0;
  right: 0;
  width: 48%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}
.brandcard__flag::before {
  /* the triangle */
  content: "";
  position: absolute;
  inset: 0;
  background: var(--flag-bg, #ffd400);
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}
.brandcard__flag span {
  /* text, centred on the triangle, parallel to its edge */
  position: absolute;
  top: 33.3%;
  left: 66.7%;
  width: 82%;
  transform: translate(-50%, -50%) rotate(45deg);
  text-align: center;
  line-height: 1.15;
  color: var(--flag-fg, #151515);
  font-size: 11px; /* fallback if cqw unsupported */
  font-size: clamp(8px, 4.4cqw, 14px);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: normal; /* allow wrapping */
  overflow-wrap: anywhere;
}
.brandcard__flag span strong {
  font-weight: 800;
}

/* fallback for browsers without color-mix */
@supports not (color: color-mix(in srgb, white 50%, transparent)) {
  .brandcard__facts li {
    border-top-color: rgba(127, 127, 127, 0.4);
  }
}

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

/* =========================================================
   Related stories card
   The standard flip card with a custom title beneath it.
   ========================================================= */

.brandcard-related {
  display: flex;
  flex-direction: column;
  gap: 1em;
}

.brandcard-related__caption {
  text-align: left;
}

.brandcard-related__title {
  display: inline-block;
  font-weight: 700;
  font-size: clamp(0.95rem, 1.9vw, 1.15rem);
  line-height: 1.25;
  color: inherit;
  text-decoration: none;
}

a.brandcard-related__title:hover,
a.brandcard-related__title:focus-visible {
  text-decoration: underline;
}
