/**
 * Recipe Allergen Info - Front-end styles.
 *
 * Visual chrome (background, border, radius, padding, text colour, alignment)
 * is applied via inline styles generated from the plugin settings, so this
 * stylesheet intentionally avoids hard-coding those properties on the module
 * wrapper. It only provides structural layout, spacing and typography.
 */

/* Module wrapper — chrome comes from inline styles (see build_wrapper_style). */
.rai-allergen-module {
        margin: 1.2em 0;
        font-size: 15px;
        line-height: 1.45;
        box-sizing: border-box;
}

.rai-allergen-module *,
.rai-allergen-module *::before,
.rai-allergen-module *::after {
        box-sizing: border-box;
}

.rai-allergen-module .rai-allergen-heading {
        margin: 0 0 10px;
        font-size: 0.95rem;
        font-weight: 700;
        letter-spacing: 0.02em;
        text-transform: uppercase;
        color: inherit;
}

/* Groups container: heading + Free From / Contains side by side. */
.rai-groups {
        display: flex;
        flex-wrap: wrap;
        gap: 22px;
}

.rai-align-center .rai-groups {
        justify-content: center;
}

.rai-group {
        flex: 1 1 auto;
        min-width: 0;
}

.rai-group-title {
        margin: 0 0 8px;
        padding-bottom: 5px;
        font-size: 0.8rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.02em;
        color: inherit;
        border-bottom: 2px solid currentColor;
        opacity: 1;
}

/* ---------------------------------------------------------------------------
 * Matrix layout (default): icon above label, wrapped in rows.
 * ------------------------------------------------------------------------- */
.rai-matrix-items {
        display: flex;
        flex-wrap: wrap;
        gap: 10px 12px;
        margin: 0;
        padding: 0;
        list-style: none;
}

.rai-align-center .rai-matrix-items {
        justify-content: center;
}

.rai-matrix-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        width: 58px;
        text-align: center;
        font-size: 0.72rem;
        font-weight: 500;
        line-height: 1.2;
        color: inherit;
}

.rai-matrix-item .rai-badge-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
}

.rai-matrix-item svg,
.rai-matrix-item img {
        width: 34px;
        height: 34px;
        flex-shrink: 0;
}

/* ---------------------------------------------------------------------------
 * Pill / chip layout.
 * ------------------------------------------------------------------------- */
.rai-badges-pill {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 0;
        list-style: none;
        margin: 0;
}

.rai-align-center .rai-badges-pill {
        justify-content: center;
}

.rai-badge-pill {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        border: 1.5px solid currentColor;
        border-radius: 50px;
        padding: 5px 14px 5px 10px;
        font-size: 0.875rem;
        font-weight: 500;
        line-height: 1.4;
        color: inherit;
}

.rai-badge-pill .rai-badge-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
}

.rai-badge-pill svg,
.rai-badge-pill img {
        width: 18px;
        height: 18px;
        flex-shrink: 0;
}

/* ---------------------------------------------------------------------------
 * Compact card grid layout.
 * ------------------------------------------------------------------------- */
.rai-badges-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 10px;
        margin: 0;
        padding: 0;
        list-style: none;
}

.rai-badge-card {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        border: 1.5px solid currentColor;
        border-radius: 8px;
        padding: 12px 8px;
        text-align: center;
        font-size: 0.75rem;
        font-weight: 500;
        color: inherit;
}

.rai-badge-card .rai-badge-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
}

.rai-badge-card svg,
.rai-badge-card img {
        width: 32px;
        height: 32px;
}

.rai-badge-card .rai-badge-label {
        line-height: 1.25;
}

/* ---------------------------------------------------------------------------
 * Optional colour coding (green Free From / red Contains). Off by default.
 * ------------------------------------------------------------------------- */
.rai-colorcode .rai-group-free .rai-group-title,
.rai-colorcode .rai-item-free {
        color: #2d6a2d; /* green, ~6:1 on white */
}

.rai-colorcode .rai-group-contains .rai-group-title,
.rai-colorcode .rai-item-contains {
        color: #b3261e; /* red, ~5.9:1 on white */
}

.rai-colorcode .rai-item-none {
        color: #2d6a2d;
}

/* Front-end support link */
.rai-support-front {
        margin: 14px 0 0;
        font-size: 0.8rem;
}

.rai-support-front a {
        color: inherit;
        text-decoration: underline;
}

/* Attribution */
.rai-attribution {
        font-size: 0.7rem;
        opacity: 0.75;
        margin-top: 10px;
        margin-bottom: 0;
}

.rai-attribution a {
        color: inherit;
}

/* ---------------------------------------------------------------------------
 * Responsive: stack groups on narrow screens.
 * ------------------------------------------------------------------------- */
@media (max-width: 600px) {
        .rai-groups {
                flex-direction: column;
                gap: 18px;
        }

        .rai-badges-grid {
                grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
        }

        .rai-matrix-item {
                width: 54px;
                font-size: 0.7rem;
        }

        .rai-matrix-item svg,
        .rai-matrix-item img {
                width: 32px;
                height: 32px;
        }
}
