/*
 * Cult Tournament badges — one card block, two surfaces.
 *
 * `.cc-tbadge*` is the badge card itself, shared by the product landing page
 * (built in the browser by js/badges/tournamentBadgeCard_09222026.js) and the
 * cultivator landing page (server-rendered into the markup for crawlers). It
 * replaces the `.product-tournament-badge*` rules that used to live in
 * styles.css: one card, one set of rules, so the two surfaces cannot drift.
 *
 * `.cc-badge-panel*` is the sortable/filterable panel the cultivator page wraps
 * those cards in. `.cc-tbadges*` is the product page's lighter wrapper.
 *
 * Everything is expressed in the site's `--cc-*` tokens and sized in `rem`, so
 * the cards inherit the page's palette and the reader's text size. The grid is
 * intrinsic (`auto-fill` + `minmax(min(100%, …))`), which is what makes one
 * stylesheet fit a 320px phone and a 1440px desktop without a breakpoint per
 * column count.
 */

/* ---------------------------------------------------------------------------
 * Card
 * ------------------------------------------------------------------------ */

.cc-tbadge {
  /* The card sets its own width and carries padding and a border, so it states
     its box model rather than inheriting whatever reset the host page has.
     Every page here loads MDB, which sets border-box globally; this only makes
     the component correct on its own terms. */
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  margin: 0;
  padding: 0.75rem;
  border: 1px solid var(--cc-border);
  border-radius: 0.65rem;
  background: var(--cc-surface-2);
  color: var(--cc-bone);
  text-align: left;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

/* The product page's card is one big disclosure button; the cultivator page's
   is a list item holding its own controls. Only the former is clickable, and
   only the latter -- taller, with its own meta row -- wants top alignment. */
button.cc-tbadge {
  cursor: pointer;
}

.cc-badge-panel .cc-tbadge {
  align-items: start;
  /* Cards in a row stretch to the tallest one. Collect that spare height below
     the content instead of letting the grid share it out between the rows,
     which would open a gap above every short card's description. */
  align-content: start;
}

/* A card whose own link or button has focus. Scoped to the panel: the product
   card has no focusable children, so on that page this would only ever fire
   for the card itself and would latch a highlight after a plain mouse click. */
.cc-badge-panel .cc-tbadge:focus-within,
button.cc-tbadge:hover,
button.cc-tbadge:focus-visible,
.cc-tbadge[aria-expanded='true'] {
  border-color: var(--cc-pink);
  box-shadow: 0 0.25rem 0.75rem rgba(var(--cc-black-rgb), 0.45);
}

button.cc-tbadge:focus-visible {
  outline: 2px solid var(--cc-pink);
  outline-offset: 2px;
}

button.cc-tbadge:hover {
  transform: translateY(-2px);
}

.cc-tbadge__artwork {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  border: 1px solid rgba(var(--cc-pink-rgb), 0.35);
  background: rgba(var(--cc-pink-rgb), 0.14);
  color: var(--cc-pink);
  font-size: 1.75rem;
}

.cc-tbadge__artwork img {
  width: 2.75rem;
  height: 2.75rem;
  object-fit: contain;
}

.cc-tbadge__copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Only the panel's card stacks a meta row under the tournament line. */
.cc-badge-panel .cc-tbadge__copy {
  gap: 0.15rem;
}

/* Brand and strain names are user data and can be one long token. A
   description is prose, so it wraps normally -- as it always has. */
.cc-tbadge__copy > * {
  overflow-wrap: anywhere;
}

.cc-badge-panel .cc-tbadge__details {
  overflow-wrap: anywhere;
}

.cc-tbadge__name {
  color: var(--cc-bone);
  font-weight: 700;
}

.cc-tbadge__tournament {
  color: var(--cc-muted);
  font-size: 0.8rem;
}

.cc-tbadge__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.15rem;
  color: var(--cc-muted);
  font-size: 0.75rem;
}

.cc-tbadge__type {
  padding: 0.05rem 0.45rem;
  border: 1px solid rgba(var(--cc-green-rgb), 0.45);
  border-radius: 999px;
  background-color: rgba(var(--cc-green-rgb), 0.16);
  color: var(--cc-green);
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.cc-tbadge__date {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The strain that won a product award: a real link to that product's page, so
   the panel gives crawlers (and readers) somewhere to go. */
.cc-tbadge__subject-link {
  color: var(--cc-bone);
  text-decoration: underline;
  text-decoration-color: rgba(var(--cc-green-rgb), 0.5);
  text-underline-offset: 2px;
}

.cc-tbadge__subject-link:hover,
.cc-tbadge__subject-link:focus-visible {
  color: var(--cc-green);
  text-decoration-color: currentColor;
}

.cc-tbadge__details {
  grid-column: 1 / -1;
  padding-top: 0.5rem;
  margin-bottom: 0;
  border-top: 1px solid rgba(var(--cc-bone-rgb), 0.12);
  color: var(--cc-muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

/* Long descriptions are clamped rather than hidden: the text stays in the
   markup for search engines and screen readers, and only its box is short. */
.cc-tbadge__details.is-clamped {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}

.cc-tbadge__more {
  grid-column: 1 / -1;
  justify-self: start;
  min-height: 44px;
  padding: 0 0.25rem;
  border: 0;
  background: none;
  color: var(--cc-green);
  font-size: 0.8rem;
}

.cc-tbadge__more:hover {
  color: var(--cc-green-hover);
  text-decoration: underline;
}

/* ---------------------------------------------------------------------------
 * Product landing wrapper (client-rendered)
 * ------------------------------------------------------------------------ */

.cc-tbadges {
  margin-top: 1.5rem;
  padding: 1rem;
  border: 1px solid var(--cc-border);
  border-radius: 0.75rem;
  background: var(--cc-charcoal);
  color: var(--cc-bone);
  text-align: left;
}

.cc-tbadges__subtitle,
.cc-badge-panel__subtitle {
  color: var(--cc-muted);
}

.cc-tbadges__count,
.cc-badge-panel__count {
  border: 1px solid rgba(var(--cc-green-rgb), 0.45);
  background-color: rgba(var(--cc-green-rgb), 0.16);
  color: var(--cc-green);
}

.cc-tbadges__grid,
.cc-badge-panel__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* `auto-fill` keeps a filtered-down result card the size of its neighbours
   instead of stretching the last survivor across the whole panel. */
.cc-badge-panel__grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
}

/* ---------------------------------------------------------------------------
 * Cultivator landing panel (server-rendered, sorted and filtered in place)
 * ------------------------------------------------------------------------ */

.cc-badge-panel__controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.cc-badge-panel__field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.cc-badge-panel__label {
  color: var(--cc-muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* 44px targets and 1rem text: a select under 16px makes iOS Safari zoom the
   whole page on focus, which on this grid looks like a layout bug. */
.cc-badge-panel .form-control,
.cc-badge-panel .form-select {
  min-height: 44px;
  color: var(--cc-bone);
  background-color: var(--cc-surface-1);
  border-color: var(--cc-border);
  font-size: 1rem;
}

.cc-badge-panel .form-control::placeholder {
  color: var(--cc-muted);
  opacity: 1;
}

.cc-badge-panel__search {
  position: relative;
}

.cc-badge-panel__search .form-control {
  padding-left: 2.4rem;
}

.cc-badge-panel__search-icon {
  position: absolute;
  top: 50%;
  left: 0.9rem;
  transform: translateY(-50%);
  color: var(--cc-muted);
  pointer-events: none;
}

.cc-badge-panel__status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  color: var(--cc-muted);
  font-size: 0.8rem;
}

.cc-badge-panel__reset {
  min-height: 44px;
}

.cc-badge-panel__empty {
  padding: 2rem 1rem;
  color: var(--cc-muted);
  text-align: center;
}

.cc-badge-panel__grid > [hidden] {
  display: none !important;
}

/* The panel packs more into each card, so on a phone it buys width back from
   the artwork. The product page's single row of cards keeps its 3.5rem disc. */
@media (max-width: 575.98px) {
  .cc-badge-panel .cc-tbadge {
    grid-template-columns: 3rem minmax(0, 1fr);
    padding: 0.65rem;
  }

  .cc-badge-panel .cc-tbadge__artwork {
    width: 3rem;
    height: 3rem;
    font-size: 1.5rem;
  }

  .cc-badge-panel .cc-tbadge__artwork img {
    width: 2.25rem;
    height: 2.25rem;
  }
}

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

  button.cc-tbadge:hover {
    transform: none;
  }
}
