/* Related Mic Public Styles */

.related-mic-related-recipes {
    margin: 2rem 0;
    font-family: inherit;
}

.related-mic-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: #333;
    font-weight: 600;
}

/* Grid Layout */
.related-mic-layout-grid .related-mic-recipes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.related-mic-layout-grid .related-mic-recipe {
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.related-mic-layout-grid .related-mic-recipe:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.related-mic-layout-grid .related-mic-recipe-image {
    position: relative;
    height: 200px;
    overflow: hidden;
}

.related-mic-layout-grid .related-mic-recipe-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.related-mic-layout-grid .related-mic-recipe:hover .related-mic-recipe-image img {
    transform: scale(1.05);
}

.related-mic-layout-grid .related-mic-recipe-content {
    padding: 1rem;
}

.related-mic-layout-grid .related-mic-recipe-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    line-height: 1.3;
}

.related-mic-layout-grid .related-mic-recipe-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.2s ease;
}

.related-mic-layout-grid .related-mic-recipe-title a:hover {
    color: #0073aa;
}

.related-mic-layout-grid .related-mic-recipe-excerpt {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 1rem;
}

/* List Layout */
.related-mic-layout-list .related-mic-recipes {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.related-mic-layout-list .related-mic-recipe {
    display: flex;
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.related-mic-layout-list .related-mic-recipe:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.related-mic-layout-list .related-mic-recipe-image {
    flex: 0 0 214px;
    height: 214px;
    overflow: hidden;
}

.related-mic-layout-list .related-mic-recipe-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.related-mic-layout-list .related-mic-recipe-content {
    flex: 1;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.related-mic-layout-list .related-mic-recipe-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
}

.related-mic-layout-list .related-mic-recipe-excerpt {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.related-mic-layout-list .related-mic-recipe-excerpt p {
    margin-top: 0;
    margin-bottom: 0;
}

/* Compact Layout */
.related-mic-layout-compact .related-mic-recipes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.related-mic-layout-compact .related-mic-recipe {
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.related-mic-layout-compact .related-mic-recipe:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.related-mic-layout-compact .related-mic-recipe-image {
    position: relative;
    height: 120px;
    overflow: hidden;
}

.related-mic-layout-compact .related-mic-recipe-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.related-mic-layout-compact .related-mic-recipe:hover .related-mic-recipe-image img {
    transform: scale(1.03);
}

.related-mic-layout-compact .related-mic-recipe-content {
    padding: 0.75rem;
}

.related-mic-layout-compact .related-mic-recipe-title {
    margin: 0 0 0.5rem 0;
    font-size: 0.95rem;
    line-height: 1.3;
}

.related-mic-layout-compact .related-mic-recipe-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.2s ease;
}

.related-mic-layout-compact .related-mic-recipe-title a:hover {
    color: #0073aa;
}

.related-mic-layout-compact .related-mic-recipe-excerpt {
    color: #666;
    font-size: 0.8rem;
    line-height: 1.4;
    margin-bottom: 0.75rem;
}

.related-mic-layout-compact .related-mic-recipe-meta {
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
}

.related-mic-layout-compact .related-mic-recipe-tags {
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.related-mic-layout-compact .related-mic-tag {
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
}

/* Slider Layout */
.related-mic-layout-slider .related-mic-recipes {
    position: relative;
    overflow: hidden;
    width: 100%;
}

.related-mic-layout-slider .related-mic-recipes-container {
    display: flex;
    transition: transform 0.3s ease;
    width: 100%;
}

.related-mic-layout-slider .related-mic-recipe {
    flex: 0 0 calc(50% - 1.43rem);
    margin-left: 0;
    margin-right: 1.5rem;
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.related-mic-layout-slider .related-mic-recipe:last-child {
    margin-right: 0;
}

.related-mic-layout-slider .related-mic-recipe-image {
    height: 180px;
    overflow: hidden;
}

.related-mic-layout-slider .related-mic-recipe-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.related-mic-layout-slider .related-mic-recipe-content {
    padding: 1rem;
}

.related-mic-layout-slider .related-mic-recipe-title {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
}

.related-mic-layout-slider .related-mic-recipe-excerpt {
    color: #666;
    font-size: 0.85rem;
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.related-mic-slider-nav {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
    gap: 0.5rem;
}

.related-mic-slider-nav button {
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.related-mic-slider-nav button:hover {
    background: #005a87;
}

.related-mic-slider-nav button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Recipe Meta Information */
.related-mic-recipe-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    color: #666;
}

.related-mic-recipe-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.related-mic-recipe-meta svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.related-mic-recipe-time,
.related-mic-recipe-rating,
.related-mic-recipe-difficulty {
    background: #f8f9fa;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

/* Star Rating System */
.related-mic-recipe-rating {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.related-mic-stars-container {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.related-mic-stars-empty {
    display: flex;
    align-items: center;
    color: #ddd; /* Light gray for empty stars */
}

.related-mic-stars-filled {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    color: #ff9500; /* Orange color for filled stars */
    overflow: hidden;
    white-space: nowrap;
}

.related-mic-star {
    flex-shrink: 0;
    margin-right: 1px;
}

.related-mic-star:last-child {
    margin-right: 0;
}

.related-mic-rating-text {
    font-weight: 500;
    color: #666;
}

/* Recipe Tags */
.related-mic-recipe-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0;
}

.related-mic-tag {
    background: #e9ecef;
    color: #495057;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

/*.related-mic-tag:hover {
    background: #dee2e6;
    color: #495057;
    text-decoration: none;
}*/

.related-mic-tag-course {
    background: #d4edda;
    color: #155724;
}

.related-mic-tag-cuisine {
    background: #d1ecf1;
    color: #0c5460;
}

.related-mic-tag-diet {
    background: #fff3cd;
    color: #856404;
}

.related-mic-recipe-servings {
    background: #f8f9fa;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .related-mic-layout-grid .related-mic-recipes {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 1rem;
    }
    
    .related-mic-layout-compact .related-mic-recipes {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 0.75rem;
    }
    
    .related-mic-layout-compact .related-mic-recipe-image {
        height: 100px;
    }
    
    .related-mic-layout-list .related-mic-recipe {
        flex-direction: column;
    }
    
    .related-mic-layout-list .related-mic-recipe-image {
        flex: none;
        height: 150px;
    }
    
    .related-mic-layout-slider .related-mic-recipe {
        flex: 0 0 calc(100% - 0.75rem);
    }
    
    .related-mic-layout-slider .related-mic-recipe:last-child {
        margin-right: 0;
    }
    
    .related-mic-recipe-meta {
        gap: 0.5rem;
    }
    
    .related-mic-recipe-meta span {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .related-mic-layout-grid .related-mic-recipes {
        grid-template-columns: 1fr;
    }
    
    .related-mic-layout-slider .related-mic-recipe {
        flex: 0 0 100%;
        margin-right: 0;
    }
    
    .related-mic-title {
        font-size: 1.25rem;
    }
}

/* Loading States */
.related-mic-loading {
    opacity: 0.6;
    pointer-events: none;
}

.related-mic-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: related-mic-spin 1s linear infinite;
}

@keyframes related-mic-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty State */
.related-mic-empty {
    text-align: center;
    padding: 2rem;
    color: #666;
}

.related-mic-empty::before {
    content: '🍽️';
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

/* Accessibility */
.related-mic-recipe-title a:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/*.related-mic-tag:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}*/

/* Print Styles */
@media print {
    .related-mic-related-recipes {
        break-inside: avoid;
        margin: 1rem 0;
    }
    
    .related-mic-recipe {
        break-inside: avoid;
        border: 1px solid #ccc;
        margin-bottom: 1rem;
    }
    
    .related-mic-recipe-image {
        max-width: 150px;
        float: left;
        margin-right: 1rem;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .related-mic-recipe {
        border: 2px solid #000;
    }
    
    .related-mic-recipe-title a {
        color: #000;
        text-decoration: underline;
    }
    
    .related-mic-tag {
        border: 1px solid #000;
    }
}

/* Reduced Motion */
/* Ingredient filter buttons */
.related-mic-ingredient-filter {
    background: #e3f2fd !important;
    color: #1565c0 !important;
    border: 1px solid #bbdefb !important;
    cursor: auto;
    transition: all 0.2s ease;
}

/*.related-mic-ingredient-filter:hover {
    background: #bbdefb !important;
    color: #0d47a1 !important;
}*/

.related-mic-ingredient-filter.active {
    background: #1976d2 !important;
    color: white !important;
    border-color: #1976d2 !important;
}

/* Screen reader only text */
.related-mic-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Dark mode additions */
@media (prefers-color-scheme: dark) {
    .related-mic-ingredient-filter {
        background: #1e3a5f !important;
        color: #64b5f6 !important;
        border-color: #2e4a6f !important;
    }

    /*.related-mic-ingredient-filter:hover {
        background: #2e4a6f !important;
        color: #90caf9 !important;
    }*/
}

@media (prefers-reduced-motion: reduce) {
    .related-mic-recipe,
    .related-mic-recipe-image img,
    .related-mic-layout-slider .related-mic-recipes-container {
        transition: none;
    }
    
    .related-mic-loading::after {
        animation: none;
    }
    
}
/* ---------------------------------------------------------------------------
 * Single accessible card link (stretched-link pattern)
 *
 * Cards are a plain <div> with exactly ONE anchor (the title). That anchor's
 * ::after box is stretched over the whole card so the entire card — image,
 * metadata, whitespace — is one tap target, with no nested interactive
 * descendants. Interactive ingredient chips are siblings raised above the
 * stretched box with z-index so they stay independently operable.
 * ------------------------------------------------------------------------- */

.related-mic-recipe {
    max-width: 100%;
    box-sizing: border-box;
}

.related-mic-recipe--linked {
    position: relative;
}

.related-mic-recipe--linked .related-mic-recipe-title a {
    text-decoration: none;
    /* Real anchor geometry >= 44px: the stretched ::after covers the card
     * for pointer input, but target-size audits (and some AT) measure the
     * anchor's own border box — give it a compliant box of its own. */
    display: inline-flex;
    align-items: center;
    min-height: 44px;
}

.related-mic-recipe--linked .related-mic-recipe-title a::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    inset: 0;
    z-index: 0;
}

/* Focus ring is drawn around the WHOLE card via the stretched ::after box. */
.related-mic-recipe--linked .related-mic-recipe-title a:focus-visible {
    outline: none;
}

.related-mic-recipe--linked .related-mic-recipe-title a:focus-visible::after {
    outline: 3px solid currentColor;
    outline-offset: 2px;
}

/* Progressive enhancement for engines that support :has(). */
@supports selector(:has(*)) {
    .related-mic-recipe--linked:has(.related-mic-recipe-title a:focus-visible) {
        outline: 3px solid currentColor;
        outline-offset: 2px;
    }

    .related-mic-recipe--linked:has(.related-mic-recipe-title a:focus-visible) .related-mic-recipe-title a:focus-visible::after {
        outline: none;
    }
}

/* ---------------------------------------------------------------------------
 * Interactive chips: >= 44x44 target, above the stretched link, visible focus
 * ------------------------------------------------------------------------- */

.related-mic-ingredient-filter {
    position: relative;
    z-index: 1;
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.related-mic-ingredient-filter:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* ---------------------------------------------------------------------------
 * 320px / 200% zoom: nothing may overflow the viewport horizontally
 * ------------------------------------------------------------------------- */

.related-mic-recipe-content,
.related-mic-recipe-image,
.related-mic-recipe-meta,
.related-mic-recipe-excerpt,
.related-mic-recipe-tags {
    min-width: 0;
    max-width: 100%;
}

.related-mic-recipe-title,
.related-mic-recipe-title a,
.related-mic-recipe-excerpt,
.related-mic-recipe-excerpt p {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.related-mic-recipe-image img {
    max-width: 100%;
    height: auto;
}

/* ---------------------------------------------------------------------------
 * View-script states (loading / empty / error)
 * ------------------------------------------------------------------------- */

.related-mic-recipes[aria-busy="true"] {
    opacity: 0.6;
}

.related-mic-recipes:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.related-mic-no-results {
    margin: 0;
    padding: 1rem 0;
}

/* ---------------------------------------------------------------------------
 * Persistent selected-filter / clear control
 *
 * Lives inside .related-mic-related-recipes but OUTSIDE .related-mic-recipes, so it is
 * never touched by a results-region innerHTML replacement and stays
 * reachable even when the applied ingredient has no chip anywhere in the
 * replacement markup.
 * ------------------------------------------------------------------------- */

.related-mic-active-filter {
    margin: 0 0 1rem;
}

.related-mic-active-filter-clear {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    min-width: 44px;
    padding: 0.4rem 0.9rem;
    background: #1976d2;
    color: #fff;
    border: 1px solid #1976d2;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.3;
    cursor: pointer;
}

.related-mic-active-filter-clear:hover {
    background: #1565c0;
    border-color: #1565c0;
}

.related-mic-active-filter-clear:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

@media (prefers-color-scheme: dark) {
    .related-mic-active-filter-clear {
        background: #1e3a5f;
        color: #64b5f6;
        border-color: #2e4a6f;
    }

    .related-mic-active-filter-clear:hover {
        background: #2e4a6f;
    }
}
