html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

*, *::before, *::after {
    box-sizing: border-box;
}

/* Ensure fluid containers use full width properly */
.container-fluid {
    width: 100% !important;
    max-width: none !important;
    padding-left: 15px;
    padding-right: 15px;
}

/* CSS-Only Masonry Layout for Recipe Cards */
.masonry-grid {
    columns: 6;
    column-gap: 16px;
    padding: 0 15px;
    width: 100%;
    margin: 0;
}

.masonry-item {
    display: inline-block;
    margin: 0 0 16px 0;
    width: 100%;
    break-inside: avoid;
    page-break-inside: avoid;
}

/* Responsive column adjustments */
@media (max-width: 1600px) {
    .masonry-grid {
        columns: 5;
    }
}

@media (max-width: 1400px) {
    .masonry-grid {
        columns: 4;
    }
}

@media (max-width: 1200px) {
    .masonry-grid {
        columns: 3;
        column-gap: 14px;
    }
}

@media (max-width: 768px) {
    .masonry-grid {
        columns: 2;
        column-gap: 12px;
        padding: 0 10px;
    }
}

@media (max-width: 576px) {
    .masonry-grid {
        columns: 1;
        column-gap: 0;
        padding: 0 8px;
    }
    
    .masonry-item {
        margin-bottom: 12px;
    }
}

@media (max-width: 480px) {
    .masonry-grid {
        padding: 0 5px;
    }

    .masonry-item {
        margin-bottom: 10px;
    }
}

/* Search page specific masonry overrides */
.search-results .masonry-grid {
    columns: 4 !important;
    column-gap: 1.25rem !important;
    padding: 0 !important;
}

@media (max-width: 1024px) {
    .search-results .masonry-grid {
        columns: 3 !important;
    }
}

@media (max-width: 900px) {
    .search-results .masonry-grid {
        columns: 2 !important;
    }
}

@media (max-width: 768px) {
    .search-results .masonry-grid {
        columns: 2 !important;
    }
}

@media (max-width: 480px) {
    .search-results .masonry-grid {
        columns: 1 !important;
    }
}

/* Recipe Card Styles - Variable Height for Masonry Effect */
.recipe-card {
    border: none;
    border-radius: 12px;
    padding: 0;
    width: 100%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    box-sizing: border-box;
    position: relative;
    background-color: #fff;
    transition: all 0.3s ease;
    overflow: hidden;
    display: block;
}

.recipe-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.recipe-card:active {
    transform: translateY(-2px);
}

/* Variable height images for masonry effect */
.recipe-card img {
    width: 100%;
    height: auto;
    min-height: 150px;
    max-height: 300px;
    object-fit: cover;
    margin: 0;
    padding: 0;
    display: block;
    border-radius: 0;
}

.rating-overlay {
    position: absolute; 
    top: 8px; 
    right: 8px; 
    z-index: 2; 
    background: rgba(0,0,0,0.75); 
    border-radius: 8px; 
    padding: 4px 8px;
}

.recipe-card-content {
    padding: 16px;
    position: relative;
    background: #fff;
}

.recipe-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
    line-height: 1.3;
}

.recipe-source {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 4px;
    font-weight: 500;
}

.recipe-time {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 8px;
}

.recipe-description {
    font-size: 0.9rem;
    color: #555;
    line-height: 1.4;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Validation message style - with icon for accessibility (WCAG 1.4.1) */
.validation-message {
    color: #e52240;
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
}

.validation-message::before {
    content: "⚠";
    font-size: 0.9em;
    flex-shrink: 0;
}

/* Validation summary style - with icon for accessibility (WCAG 1.4.1) */
.validation-summary {
    color: #e52240;
}

.validation-summary li::before {
    content: "⚠ ";
}

/* Alert styles with icons for accessibility (WCAG 1.4.1) */
.alert-danger {
    position: relative;
    padding-left: 2.5rem !important;
}

.alert-danger::before {
    content: "⚠";
    position: absolute;
    left: 0.75rem;
    top: 0.5rem;
    font-size: 1.1em;
}

.alert-success {
    position: relative;
    padding-left: 2.5rem !important;
}

.alert-success::before {
    content: "✓";
    position: absolute;
    left: 0.75rem;
    top: 0.5rem;
    font-size: 1.1em;
    font-weight: bold;
    color: #0f5132;
}

/* Blazor error boundary styles */
.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA9NC4wODE1IDI5MSA9NC42NzgyIDI5MSA9Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDc1IDY2LjA1NDcgMjYzLjU3NiA5My41Mjk1IDI2Ni4xMTYgOTMuNTI5NSAyNjcuMzg3IDkyLjI4MzcgMjY3LjM4NyA4OS43OTIxIDI2Ny4zODcgODcuMzAwNSAyNjYuMTE2IDg2LjA1NDcgMjYzLjU3NiA4Ni4wNTQ3WiIgZmlsbD0iI0ZGRTUwMCIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9nPjwvc3ZnPg==) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

/* Overlay Styles for recipe details */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    color: white;
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 12px;
    pointer-events: none;
    padding: 0; /* Remove padding from overlay itself */
    box-sizing: border-box;
    overflow: hidden; /* Hide overflow on the overlay container */
    display: flex;
    flex-direction: column;
}

.recipe-card:hover .overlay {
    opacity: 1;
    pointer-events: auto;
}

.overlay-content {
    /* Make overlay-content the actual scrollable container */
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px; /* Move padding to the scrollable content */
    width: 100%;
    box-sizing: border-box;
    text-align: left;
    font-size: 0.85rem;
    line-height: 1.4;
    
    /* Ensure proper scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.6) rgba(0, 0, 0, 0.3);
    
    /* Enable momentum scrolling on iOS */
    -webkit-overflow-scrolling: touch;
}

/* Webkit scrollbar styling for overlay content */
.overlay-content::-webkit-scrollbar {
    width: 8px;
}

.overlay-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.overlay-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 4px;
}

.overlay-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.8);
}

.overlay-content h6 {
    color: #ffc107;
    margin-bottom: 0.75rem;
    margin-top: 0.75rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.overlay-content h6:first-child {
    margin-top: 0;
}

.overlay-content p {
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.overlay-content p:first-child {
    margin-top: 0;
}

.overlay-content ul, .overlay-content ol {
    padding-left: 1.2rem;
    margin-bottom: 0.75rem;
    margin-top: 0;
}

.overlay-content li {
    margin-bottom: 0.2rem;
    line-height: 1.3;
}

/* Ensure there's space at the bottom when scrolling */
.overlay-content::after {
    content: "";
    display: block;
    height: 16px;
    flex-shrink: 0;
}

/* Mobile-specific overlay improvements */
@media (max-width: 768px) {
    .overlay-content {
        font-size: 0.8rem;
        padding: 12px;
    }
    
    .overlay-content h6 {
        font-size: 0.85rem;
        margin-bottom: 0.5rem;
        margin-top: 0.5rem;
    }
    
    /* Larger touch targets for mobile scrolling */
    .overlay-content::-webkit-scrollbar {
        width: 12px;
    }
    
    .overlay-content::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.8);
    }
}

/* For touch devices - overlay is hidden by default, shown on long press */
@media (hover: none) and (pointer: coarse) {
    .recipe-card .overlay {
        opacity: 0;
        pointer-events: none;
    }

    /* Show overlay when long press is detected */
    .recipe-card .overlay.show-on-touch {
        opacity: 1;
        pointer-events: auto;
        z-index: 100;
    }
}
