/**
 * Elle Gourmet Blocks — Product card
 * Shared front-end + editor styles.
 */

/* ==========================================================================
   Base — shared across both layouts
   ========================================================================== */
.elg-product {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    border: 1px solid #e8e8e8;
    border-radius: 4px;
    padding: 1.25rem;
    margin: 1.5rem 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    background: #fff;
    --elg-product-image-scale: 100;
}

/* ==========================================================================
   Editor wrapper (editor-only class). No width here on purpose — see the
   matching note in recipe-roundup/style.css: --wp--style--global--content-size
   is undefined on a classic theme, so this fell back to 100% and outranked the
   theme's `html :where(.wp-block)` cap on specificity.
   ========================================================================== */
.elg-product-block {
    box-sizing: border-box;
}

.elg-product-block > .elg-product {
    margin-left: 0;
    margin-right: 0;
}

/* ==========================================================================
   Layout: image LEFT (landscape / square)
   ========================================================================== */
.elg-product--left {
    flex-direction: row;
}

.elg-product--left .elg-product__image-wrap {
    flex: 0 0 auto;
    width: calc( 160px * var(--elg-product-image-scale, 100) / 100 );
}

/* ==========================================================================
   Layout: image TOP (portrait)
   ========================================================================== */
.elg-product--top {
    flex-direction: column;
}

.elg-product--top .elg-product__image-wrap {
    width: 100%;
}

.elg-product--top .elg-product__image {
    max-height: 420px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

/* ==========================================================================
   Image
   ========================================================================== */
.elg-product__image-wrap a {
    display: block;
    line-height: 0;
}

.elg-product__image {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 3px;
    object-fit: cover;
}

/* ==========================================================================
   Content
   ========================================================================== */
.elg-product__content {
    flex: 1 1 auto;
    min-width: 0;
}

.elg-product__name {
    font-family: var(--font-heading, inherit);
    font-size: 1.1em;
    font-weight: 700;
    line-height: 1.25;
    margin: 0 0 0.4rem;
}

.elg-product__name a {
    text-decoration: none;
    color: inherit;
}

.elg-product__name a:hover {
    color: var(--accent-color, #cd202e);
}

/* Description: hard-clamp to 3 lines, balanced so the last line doesn't rag.
   Apple News sees the full text — line-clamp is visual only. */
.elg-product__brand {
    font-family: var(--font-heading, inherit);
    font-size: 0.8em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #888;
    margin: 0 0 0.5rem;
}

.elg-product__description {
    font-size: 16px;
    font-weight: normal;
    line-height: 1.5;
    margin: 0;
    color: #555;

    /* Prevents the last visible line from being a single word */
    text-wrap: pretty;
}

/* Space only appears when the CTA row is actually rendered */
.elg-product__description + .elg-product__cta {
    margin-top: 0.85rem;
}

/* ==========================================================================
   CTA row — button + price side by side
   ========================================================================== */
.elg-product__cta {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.elg-product__price {
    font-family: var(--font-heading, inherit);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.elg-product__description strong,
.elg-product__description b {
    font-weight: 600;
}

/* ==========================================================================
   CTA button — matches recipe-roundup button style
   ========================================================================== */
.elg-product__button {
    display: inline-block;
    font-family: var(--font-heading, inherit);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-decoration: none;
    color: #fff !important;
    background: #000;
    padding: 9px 20px;
    border-radius: 3px;
    transition: opacity 0.2s;
    line-height: 1;
}

.elg-product__button:hover {
    opacity: 0.75;
    color: #fff !important;
}

/* ==========================================================================
   Multiple blocks stacking — collapse gap between consecutive cards
   ========================================================================== */
.elg-product + .elg-product {
    margin-top: 0;
    border-top: none;
    border-radius: 0 0 4px 4px;
}

.elg-product:has(+ .elg-product) {
    border-radius: 4px 4px 0 0;
    margin-bottom: 0;
}

/* ==========================================================================
   Editor: placeholder state
   ========================================================================== */
.elg-product--placeholder {
    border: 2px dashed #ccc;
    background: #fafafa;
    align-items: center;
}

.elg-product__image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 160px;
    min-height: 120px;
    background: #f0f0f0;
    border-radius: 3px;
    flex-shrink: 0;
    gap: 0.5rem;
    color: #999;
    font-size: 13px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 480px) {
    .elg-product--left {
        flex-direction: column;
    }

    .elg-product--left .elg-product__image-wrap {
        width: 100%;
    }
}
