/* Article gallery slider */
.news-gallery {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto 32px;
    padding: 0 24px 32px;
}

.gallery-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    padding-bottom: 16px;
}

.gallery-controls button {
    appearance: none;
    -webkit-appearance: none;
    box-sizing: border-box;
    flex: 0 0 48px;
    width: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
    height: 48px !important;
    min-height: 48px !important;
    padding: 0 !important;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    background: var(--bg-alt);
    color: var(--text);
    cursor: pointer;
    line-height: 1;
    transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

.gallery-controls button:hover:not(:disabled) {
    background: var(--border-soft);
    transform: translateY(-1px);
}

.gallery-controls button:disabled {
    opacity: 0.35;
    cursor: default;
}

.gallery-track-wrapper {
    position: relative;
    overflow: hidden;
    border-radius: 18px;
}

.gallery-track {
    display: flex;
    gap: 20px;
    transition: transform 0.45s ease;
    will-change: transform;
}

.gallery-card {
    position: relative;
    flex: 0 0 calc((100% - 20px) / 2);
    min-width: calc((100% - 20px) / 2);
    overflow: hidden;
    border-radius: 18px;
    background: var(--card-bg);
    box-shadow: var(--shadow);
}

.gallery-card img {
    width: 100%;
    height: 260px;
    display: block;
    object-fit: cover;
    cursor: zoom-in;
}

.gallery-card .card-footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    background: rgba(15, 23, 42, 0.96);
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.9rem;
}

/* Fullscreen viewer */
.image-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px 88px;
}

.image-modal.open {
    display: flex;
}

.image-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: rgba(0, 0, 0, 0.94);
}

.image-modal-content {
    position: relative;
    z-index: 1;
    width: min(1200px, calc(100vw - 176px));
    max-height: calc(100dvh - 48px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.image-modal-content img {
    display: block;
    width: auto !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: calc(100dvh - 100px) !important;
    object-fit: contain;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

.image-modal-caption {
    max-width: 100%;
    color: #fff;
    font-size: 0.95rem;
    line-height: 1.4;
    text-align: center;
}

.image-modal-close,
.image-modal-prev,
.image-modal-next {
    appearance: none;
    -webkit-appearance: none;
    position: fixed !important;
    z-index: 10002 !important;
    box-sizing: border-box !important;
    display: grid !important;
    place-items: center !important;
    width: 52px !important;
    min-width: 52px !important;
    max-width: 52px !important;
    height: 52px !important;
    min-height: 52px !important;
    max-height: 52px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 1px solid rgba(255, 255, 255, 0.28) !important;
    border-radius: 999px !important;
    background: rgba(15, 18, 28, 0.82) !important;
    color: #fff !important;
    cursor: pointer;
    line-height: 1 !important;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
}

.image-modal-close:hover,
.image-modal-prev:hover,
.image-modal-next:hover {
    background: rgba(42, 46, 60, 0.96) !important;
}

.image-modal-close {
    top: 18px !important;
    right: 18px !important;
    left: auto !important;
    transform: none !important;
    font-size: 30px !important;
}

.image-modal-prev,
.image-modal-next {
    top: 50% !important;
    transform: translateY(-50%) !important;
    font-size: 20px !important;
}

.image-modal-prev { left: 22px !important; right: auto !important; }
.image-modal-next { right: 22px !important; left: auto !important; }

.image-modal-prev:disabled,
.image-modal-next:disabled {
    opacity: 0.25;
    cursor: default;
}

body.image-modal-open {
    overflow: hidden;
}

/* Underlying slider controls must never shine through the modal. */
body.image-modal-open .gallery-controls {
    visibility: hidden !important;
}

.image-modal button:focus-visible,
.gallery-controls button:focus-visible {
    outline: 3px solid rgba(96, 165, 250, 0.75);
    outline-offset: 3px;
}

@media (max-width: 920px) {
    .gallery-card {
        flex-basis: 100%;
        min-width: 100%;
    }

    .image-modal {
        padding: 16px 68px;
    }

    .image-modal-content {
        width: calc(100vw - 136px);
        max-height: calc(100dvh - 32px);
    }

    .image-modal-content img {
        max-height: calc(100dvh - 88px) !important;
    }

    .image-modal-prev { left: 10px !important; }
    .image-modal-next { right: 10px !important; }
    .image-modal-close { top: 10px !important; right: 10px !important; }
}

@media (max-width: 560px) {
    .news-gallery {
        margin-bottom: 24px;
        padding: 0 14px 24px;
    }

    .gallery-track { gap: 0; }
    .gallery-track-wrapper,
    .gallery-card { border-radius: 12px; }
    .gallery-card { box-shadow: none; }
    .gallery-card img { height: clamp(210px, 58vw, 300px); }
    .gallery-card .card-footer {
        flex-direction: column;
        gap: 4px;
        font-size: 0.82rem;
    }

    .image-modal {
        padding: 64px 12px 16px;
        align-items: center;
    }

    .image-modal-content {
        width: calc(100vw - 24px);
        max-height: calc(100dvh - 80px);
    }

    .image-modal-content img {
        max-height: calc(100dvh - 130px) !important;
        border-radius: 10px;
    }

    .image-modal-prev,
    .image-modal-next,
    .image-modal-close {
        width: 44px !important;
        min-width: 44px !important;
        max-width: 44px !important;
        height: 44px !important;
        min-height: 44px !important;
        max-height: 44px !important;
    }

    .image-modal-prev { left: 8px !important; }
    .image-modal-next { right: 8px !important; }
}

@media (prefers-reduced-motion: reduce) {
    .gallery-track { transition: none; }
}
