/* ==========================================================================
   Masonry Gallery - Posts & Pages
   Beautiful masonry grid gallery for WordPress
   ========================================================================== */

/* ---- Grid Layout ---- */
.mg-masonry-grid {
    column-count: 3;
    column-gap: 15px;
    width: 100%;
    margin: 0 auto;
    padding: 10px 0;
}

/* ---- Gallery Item ---- */
.mg-item {
    display: inline-block;
    width: 100%;
    margin-bottom: 15px;
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none !important;
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    line-height: 0;
}

.mg-item:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.mg-item:focus {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
}

/* ---- Image ---- */
.mg-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                opacity 0.4s ease;
    object-fit: cover;
}

/* ---- Hover Effects ---- */

/* Zoom effect */
[data-effect="zoom"] .mg-item:hover img {
    transform: scale(1.08);
}

/* Fade effect */
[data-effect="fade"] .mg-item:hover img {
    opacity: 0.8;
}

/* Slide effect */
[data-effect="slide"] .mg-item:hover img {
    transform: translateY(-5px);
}

/* None */
[data-effect="none"] .mg-item:hover img {
    transform: none;
    opacity: 1;
}

/* ---- Overlay ---- */
.mg-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    top: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.35s ease;
    padding: 20px;
    text-decoration: none !important;
    line-height: normal;
}

.mg-item:hover .mg-overlay {
    opacity: 1;
}

/* ---- Overlay Content ---- */
.mg-overlay-content {
    text-align: center;
    transform: translateY(15px);
    transition: transform 0.35s ease;
    width: 100%;
    padding-bottom: 5px;
}

.mg-item:hover .mg-overlay-content {
    transform: translateY(0);
}

/* ---- Title ---- */
.mg-title {
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px 0;
    padding: 0;
    line-height: 1.3;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    word-wrap: break-word;
}

/* ---- Type Badge ---- */
.mg-type-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
    font-size: 11px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

/* ---- Date ---- */
.mg-date {
    display: block;
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    margin-top: 5px;
}

/* ---- No Results ---- */
.mg-no-results {
    text-align: center;
    padding: 40px 20px;
    color: #888;
    font-size: 16px;
    background: #f9f9f9;
    border-radius: 10px;
    border: 2px dashed #ddd;
}

/* ---- Loading Animation ---- */
.mg-item img {
    animation: mgFadeIn 0.6s ease-out;
}

@keyframes mgFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---- Stagger Animation ---- */
.mg-item:nth-child(1)  { animation-delay: 0.05s; }
.mg-item:nth-child(2)  { animation-delay: 0.10s; }
.mg-item:nth-child(3)  { animation-delay: 0.15s; }
.mg-item:nth-child(4)  { animation-delay: 0.20s; }
.mg-item:nth-child(5)  { animation-delay: 0.25s; }
.mg-item:nth-child(6)  { animation-delay: 0.30s; }
.mg-item:nth-child(7)  { animation-delay: 0.35s; }
.mg-item:nth-child(8)  { animation-delay: 0.40s; }
.mg-item:nth-child(9)  { animation-delay: 0.45s; }
.mg-item:nth-child(10) { animation-delay: 0.50s; }

.mg-item {
    animation: mgItemAppear 0.6s ease-out both;
}

@keyframes mgItemAppear {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/* Tablet */
@media (max-width: 1024px) {
    .mg-masonry-grid {
        column-count: 2;
    }
    .mg-title {
        font-size: 14px;
    }
}

/* Mobile */
@media (max-width: 640px) {
    .mg-masonry-grid {
        column-count: 1;
        column-gap: 10px;
    }
    .mg-item {
        margin-bottom: 10px;
    }
    .mg-overlay {
        padding: 15px;
    }
    .mg-title {
        font-size: 14px;
    }
    .mg-type-badge {
        font-size: 10px;
    }
}

/* Small mobile */
@media (max-width: 400px) {
    .mg-masonry-grid {
        column-count: 1;
    }
}

/* ==========================================================================
   RTL Support (Hebrew / Arabic)
   ========================================================================== */
[dir="rtl"] .mg-overlay-content,
.rtl .mg-overlay-content {
    text-align: center;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
    .mg-masonry-grid {
        column-count: 2 !important;
    }
    .mg-overlay {
        display: none !important;
    }
    .mg-item {
        box-shadow: none !important;
        border: 1px solid #ccc;
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    .mg-item,
    .mg-item img,
    .mg-overlay,
    .mg-overlay-content {
        animation: none !important;
        transition: none !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .mg-item {
        border: 2px solid #000;
    }
    .mg-title {
        text-shadow: none;
        background: rgba(0, 0, 0, 0.8);
        padding: 2px 6px;
    }
}
