/* ==========================
   SHOP CARD
   Single canonical coffee shop card used everywhere (homepage Top Picks,
   Archive/Directory grid, related shops, etc). Flat surface — no glass —
   so it stays cheap to render at scale in a scrolling grid.
========================== */

.shop-card {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--color-surface);
    border: var(--border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.shop-card:hover,
.shop-card:focus-within {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: rgba(251, 146, 60, 0.3);
}

.shop-card__media {
    position: relative;
    flex-shrink: 0;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--color-muted);
}

.shop-card__media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.25s ease;
}

/* Skeleton shimmer — shown until assets/js/skeleton-loader.js adds .is-loaded.
   Only animates `transform` (compositor-only, no layout/paint per frame) so it
   stays cheap even with many cards on screen at once (Archive grid). */
.shop-card__media::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
    transform: translateX(-100%);
    animation: shop-card-shimmer 1.5s ease-in-out infinite;
    will-change: transform;
}

.shop-card__media.is-loaded::before {
    content: none;
}

.shop-card__media.is-loaded img {
    opacity: 1;
}

@keyframes shop-card-shimmer {
    100% {
        transform: translateX(100%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .shop-card__media::before {
        animation: none;
    }
}

/* Fallback for shops with no featured image — a background tone chosen to
   complement the site's black/grayscale logo mark, with the full logo
   centered rather than stretched full-bleed (the opacity/is-loaded fade-in
   above still applies, since this is a real <img>, not just a background
   color — see the fix note in shop-card.php). Sized wider than a typical
   centered icon (60%, not ~35%) since the logo itself is a wide wordmark
   (480x180, not square) — at a smaller width its text reads too small. */
.shop-card__media--placeholder {
    background: var(--color-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.shop-card__media--placeholder .shop-card__placeholder-logo {
    width: 60%;
    height: auto;
    object-fit: contain;
}

.shop-card__badges {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.shop-card__body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    gap: 0.85rem;
    padding: 1.25rem;
}

.shop-card__title {
    font-size: 1.2rem;
    color: var(--color-text-dark);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    overflow: hidden;
}

.shop-card__excerpt {
    color: var(--color-text-light);
    font-size: 0.95rem;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

/* Pins tags/payment/distance to the bottom of the card so cards in the same
   row line up flush even when title/excerpt line counts differ */
.shop-card__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: auto;
}

.shop-card__tag,
.shop-card__payment {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    width: fit-content;
    border-radius: 999px;
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.shop-card__tag {
    background: var(--color-muted);
    color: var(--color-accent);
    border: 1px solid rgba(139, 94, 60, 0.12);
}

/* Payment method tags are visually distinct from category tags */
.shop-card__payment {
    background: rgba(251, 146, 60, 0.16);
    color: var(--color-text-dark);
    border: 1px solid rgba(251, 146, 60, 0.28);
}

.shop-card__distance {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    color: var(--color-text-light);
    margin-left: auto;
}

.shop-card__distance svg {
    width: 0.85rem;
    height: 0.85rem;
    flex-shrink: 0;
}

.shop-card__link {
    display: block;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

.shop-card__link:hover,
.shop-card__link:focus-visible {
    text-decoration: none;
}

/* ==========================
   LIST VIEW
   Toggled via assets/js/view-toggle.js (adds/removes .layout-grid--list on
   the results grid) — same shop-cards, laid out as full-width horizontal
   rows instead of a 3-column grid, for scanning more results at once.
========================== */

.layout-grid--list > .span-3,
.layout-grid--list > .span-4,
.layout-grid--list > .span-6,
.layout-grid--list > .span-8,
.layout-grid--list > .span-12 {
    grid-column: span 12;
}

.layout-grid--list .shop-card {
    flex-direction: row;
}

.layout-grid--list .shop-card__media {
    flex: 0 0 240px;
    aspect-ratio: 4 / 3;
}

.layout-grid--list .shop-card__body {
    padding: 1rem 1.25rem;
}

/* Cramped as a horizontal row below ~768px — revert to the normal vertical
   card layout even while "list view" is selected. */
@media (max-width: 768px) {
    .layout-grid--list .shop-card {
        flex-direction: column;
    }

    .layout-grid--list .shop-card__media {
        flex: 0 0 auto;
        aspect-ratio: 16 / 10;
    }
}
