/* Market card: Bricks component smca26, same anatomy as the vendor card. ACSS tokens only.
   ACSS gives every Bricks block gap: var(--content-gap); card blocks set their own gap. */

.market-card-shell {
  gap: 0;
  block-size: 100%;
}

.market-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
  block-size: 100%;
  min-inline-size: 0;
  overflow: hidden;
  border: 1px solid var(--neutral-light);
  border-radius: var(--card-radius);
  background: var(--white);
  color: var(--text-dark-muted);
}
/* Selected from the map or "Show on map" (class set by market-map.js). */
.market-card-shell.is-map-selected .market-card {
  border-color: var(--primary-dark);
  box-shadow: 0 0 0 1px var(--primary-dark);
}

/* Media: fixed ratio, first photo or the market's initial. */
.market-card__media {
  position: relative;
  flex: none;
  gap: 0;
  inline-size: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-block-end: 1px solid var(--neutral-light);
}
/* "Featured" badge, top left (paid placement: admin "Featured Market" + "Featured until"; element smcflag). */
.market-card__flag {
  position: absolute;
  z-index: 2;
  inset-block-start: var(--space-xs);
  inset-inline-start: var(--space-xs);
  margin: 0;
  padding: 0 5px; /* owner's values, 11 Oct 2026 */
  border-radius: var(--radius-s);
  background: var(--bg-dark, var(--neutral-ultra-dark));
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.market-card__media--initial {
  display: grid;
  place-items: center;
  background: var(--secondary-ultra-light);
}
.market-card__image,
.market-card__image img {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  border-radius: 0;
}
.market-card__initial {
  display: grid;
  place-items: center;
  inline-size: var(--space-xl);
  block-size: var(--space-xl);
  border-radius: var(--radius-50);
  background: var(--sv-initial-bg, var(--primary)); /* owner's avatar colour (inc/owner-colors.php) */
  color: var(--sv-initial-fg, var(--white));
  font-size: var(--text-xl);
}

/* Body */
.market-card__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  min-inline-size: 0;
  padding: var(--space-xs) var(--space-xs) 0;
}
.market-card__title {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--primary-dark);
  font-size: var(--text-m);
  font-weight: 600;
  line-height: var(--heading-line-height);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.market-card__title a {
  color: inherit;
  text-decoration: none;
}
.market-card__title a:hover {
  color: var(--primary-ultra-dark);
}
/* One primary link per card: the title link covers the card; secondary actions sit above it. */
.market-card__title a::after {
  content: "";
  position: absolute;
  inset: 0;
}
.market-card__city {
  margin-block-start: calc(var(--space-xs) / 4);
  overflow: hidden;
  color: var(--text-dark-muted);
  font-size: var(--text-xs);
  line-height: var(--heading-line-height);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Date band: full-bleed strip at the bottom; red when the market is on now. */
.market-card__band {
  position: relative;
  z-index: 1;
  display: flex;
  flex-flow: row nowrap; /* Bricks blocks default to column + wrap */
  align-items: center;
  gap: var(--space-xs);
  inline-size: auto;
  max-inline-size: none;
  margin: auto calc(var(--space-xs) * -1) 0;
  padding: calc(var(--space-xs) * .75) var(--space-xs);
  background: var(--primary-ultra-light);
  font-size: var(--text-xs);
  line-height: var(--heading-line-height);
}
.market-card[data-on-now="true"] .market-card__band {
  background: var(--danger-ultra-light);
}
.market-card__date {
  display: flex;
  align-items: center;
  gap: calc(var(--space-xs) / 2);
  color: var(--primary-dark);
  font-weight: 600;
  white-space: nowrap;
}
.market-card[data-on-now="true"] .market-card__date {
  color: var(--danger-semi-dark);
  font-weight: 700;
  text-transform: uppercase;
}
.market-card[data-on-now="true"] .market-card__date::before {
  content: "";
  inline-size: .5em;
  block-size: .5em;
  border-radius: var(--radius-50);
  background: currentColor;
}
/* Show on map: secondary action at the card bottom, above the stretched title link; 44px hit area. */
.market-card__map {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: calc(var(--space-xs) / 4);
  min-block-size: calc(var(--space-xs) * 3.5);
  margin: auto 0 calc(var(--space-xs) / 4) calc(var(--space-xs) / -2); /* pinned above the date band so rows line up */
  padding: 0 calc(var(--space-xs) / 2);
  border: 0;
  background: transparent;
  color: var(--primary-dark);
  font-family: inherit;
  font-size: var(--text-xs);
  line-height: var(--heading-line-height);
  white-space: nowrap;
  cursor: pointer;
}
.market-card__map + .market-card__band {
  margin-block-start: 0;
}
/* "Map it" link to the listings map. Output only where the component property "Hide Map it link" is off
   (Related Markets); it then sits at the right of the date band. */
.market-card__map-link {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: calc(var(--space-xs) / 4);
  margin: calc(var(--space-xs) / -2) calc(var(--space-xs) / -2) calc(var(--space-xs) / -2) auto;
  padding: calc(var(--space-xs) / 2);
  color: var(--primary-dark);
  white-space: nowrap;
  text-decoration: none;
}
.market-card__map-link:hover {
  color: var(--primary-ultra-dark);
  text-decoration: none; /* outranks the site-wide a:hover underline */
}
.market-card__map-link svg {
  flex: none;
  inline-size: 1.25em;
  block-size: 1.25em;
}
.market-card__map:hover {
  color: var(--primary-ultra-dark);
}
.market-card__map svg {
  flex: none;
  inline-size: 1.25em;
  block-size: 1.25em;
}

/* Quick view (+): 34px visual circle, 44px hit area; drawn with two bars so it's centred. */
.market-card__quick-view {
  position: absolute;
  z-index: 2;
  inset-block-start: var(--space-xs);
  inset-inline-end: var(--space-xs);
  display: grid;
  place-items: center;
  inline-size: calc(var(--space-xs) * 2.5);
  block-size: calc(var(--space-xs) * 2.5);
  padding: 0;
  border: 0;
  border-radius: var(--radius-circle);
  background: var(--white);
  box-shadow: 0 1px 3px var(--neutral-trans-10);
  color: var(--primary-dark);
  cursor: pointer;
}
.market-card__quick-view::before {
  content: "";
  position: absolute;
  inset: calc(var(--space-xs) * -.4);
}
.market-card__quick-view:hover {
  background: var(--primary-ultra-light);
}
.market-card__plus {
  position: relative;
  inline-size: 40%;
  block-size: 40%;
  font-size: 0;
}
.market-card__plus::before,
.market-card__plus::after {
  content: "";
  position: absolute;
  inset: 50% 0 auto;
  border-block-start: 2px solid currentColor;
  border-radius: var(--radius-circle);
  translate: 0 -50%;
}
.market-card__plus::after {
  rotate: 90deg;
}

/* Focus */
.market-card :is(a, button):focus-visible {
  outline: var(--focus-width) solid var(--focus-color);
  outline-offset: var(--focus-offset);
}

/* Media zoom while the card's primary link is hovered. */
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .market-card__media img,
  .market-card__initial {
    transition: transform 180ms ease;
  }
  .market-card:has(.market-card__title a:hover) :is(.market-card__media img, .market-card__initial) {
    transform: scale(1.04);
  }
}

/* Grid loading state while Gridbuilder refreshes (is-loading set by market-map.js), same as the vendor grid. */
.is-loading .market-card {
  pointer-events: none;
  opacity: .7;
}
@media (prefers-reduced-motion: no-preference) {
  .is-loading .market-card::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
    background: linear-gradient(100deg, transparent 20%, var(--white-trans-60) 50%, transparent 80%);
    background-size: 200% 100%;
    animation: market-card-shimmer 1.2s linear infinite;
  }
}
@keyframes market-card-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* Phones (Bricks S breakpoint): list rows like the vendor cards. */
@media (max-width: 480px) {
  .market-card {
    --market-card-thumb: calc(var(--space-xl) * 2);
    display: grid;
    grid-template-columns: var(--market-card-thumb) minmax(0, 1fr);
    grid-template-rows: auto auto 1fr auto;
    align-content: start;
    column-gap: var(--space-xs);
    padding: var(--space-xs) var(--space-xs) 0;
  }
  .market-card__body {
    display: contents;
  }
  .market-card__media {
    grid-column: 1;
    grid-row: 1 / 4;
    align-self: start;
    aspect-ratio: 1;
    border: 0;
    border-radius: var(--radius-s);
  }
  .market-card__initial {
    inline-size: calc(var(--market-card-thumb) / 2);
    block-size: calc(var(--market-card-thumb) / 2);
  }
  .market-card__title {
    grid-column: 2;
    grid-row: 1;
    padding-inline-end: calc(var(--space-xs) * 3); /* clears the + button */
  }
  .market-card__city {
    grid-column: 2;
    grid-row: 2;
  }
  .market-card__map {
    grid-column: 2;
    grid-row: 3;
    margin-block-end: 0;
  }
  .market-card__map + .market-card__band {
    margin-block-start: var(--space-xs);
  }
  .market-card__band {
    grid-column: 1 / -1;
    grid-row: 4;
    margin: var(--space-xs) calc(var(--space-xs) * -1) 0;
  }
}
