/* ==========================================================================
   Gridbox RSS News Feed - Custom Styles
   Orange accents, Montserrat fonts, Gridbox variables + Video Gallery Support
 ========================================================================== */

/* ==========================================================================
   ОСНОВНОЙ КОНТЕЙНЕР
 ========================================================================== */
.com-newsfeeds-newsfeed {
    max-width: 100%;
    margin: 0 auto 2rem;
    padding: 0 15px;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* ЗАГОЛОВОК ЛЕНТЫ */
.com-newsfeeds-newsfeed h2 {
    font-family: 'Montserrat', 'Roboto', sans-serif;
    font-weight: 350;
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    color: var(--title, #1a1a1a);
    margin: 0 0 2rem 0;
    padding-bottom: 1rem;
    position: relative;
    line-height: 1.3;
}

.com-newsfeeds-newsfeed h2 a {
    color: var(--title, #1a1a1a) !important;
    text-decoration: none;
    transition: opacity 0.3s ease;
}

.com-newsfeeds-newsfeed h2 a:hover {
    opacity: 0.8;
}

/* КАРТОЧКИ НОВОСТЕЙ */
.com-newsfeeds-newsfeed__items {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.com-newsfeeds-newsfeed__items > li {
    background: var(--bg-white, #fff);
    border: 1px solid #000 !important;
    border-radius: 12px;
    padding: 1.75rem;
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.com-newsfeeds-newsfeed__items > li::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary, #ff6200), var(--hover, #e55a00));
}

.com-newsfeeds-newsfeed__items > li:hover {
    box-shadow: 0 25px 60px rgba(0,0,0,0.18) !important;
    transform: translateY(-6px) !important;
    border-color: var(--primary, #ff6200) !important;
}

/* ЗАГОЛОВКИ НОВОСТЕЙ */
.feed-link,
.feed-link h3,
.feed-link a {
    text-decoration: none !important;
    color: var(--title, #1a1a1a) !important;
}

.feed-link h3,
.feed-link a {
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    line-height: 1.4;
    display: block;
    word-break: break-word;
    margin: 0 0 1rem 0 !important;
}

/* ТЕКСТ НОВОСТЕЙ */
.feed-item-description {
    color: var(--text, #555);
    font-size: 1rem;
    line-height: 1.65;
    font-weight: 400;
    margin: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.feed-item-description p,
.com-newsfeeds-newsfeed__items p {
    margin: 0 0 1rem 0 !important;
}

/* Unified text section (after galleries) */
.rss-unified-text {
    margin-top: 1.5rem;
    color: var(--text, #555);
    font-size: 1rem;
    line-height: 1.65;
}

.rss-unified-text p {
    margin: 0 0 1rem 0;
}

.rss-unified-text p:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   ГОРИЗОНТАЛЬНАЯ ГАЛЕРЕЯ ФОТО
 ========================================================================== */
.rss-photo-gallery {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 1rem 0;
    margin: 1.5rem 0;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--primary, #ff6200) transparent;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.rss-photo-gallery::-webkit-scrollbar {
    height: 6px;
}

.rss-photo-gallery::-webkit-scrollbar-track {
    background: var(--border, #f0f0f0);
}

.rss-photo-gallery::-webkit-scrollbar-thumb {
    background: var(--primary, #ff6200);
    border-radius: 3px;
}

.rss-photo-gallery.center-gallery {
    justify-content: center;
    overflow-x: visible;
}

/* ==========================================================================
   ГОРИЗОНТАЛЬНАЯ ГАЛЕРЕЯ ВИДЕО
 ========================================================================== */
.rss-video-gallery {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 1rem 0;
    margin: 1.5rem 0;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--primary, #ff6200) transparent;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.rss-video-gallery::-webkit-scrollbar {
    height: 6px;
}

.rss-video-gallery::-webkit-scrollbar-track {
    background: var(--border, #f0f0f0);
}

.rss-video-gallery::-webkit-scrollbar-thumb {
    background: var(--primary, #ff6200);
    border-radius: 3px;
}

/* ==========================================================================
   ИЗОБРАЖЕНИЯ В ГАЛЕРЕЕ
 ========================================================================== */
.rss-media-wrapper {
    position: relative;
    flex-shrink: 0;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: all 0.3s ease;
    box-sizing: border-box;
    max-width: 100%;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.rss-media-wrapper.rss-video-thumbnail {
    flex-shrink: 0;
    width: 100% !important;
}

.rss-media-wrapper:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    z-index: 10;
}

.rss-image-frame {
    position: relative;
    width: 220px;
    height: 165px;
    flex-shrink: 0;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-secondary, #f8f9fa);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

@media (min-width: 768px) {
    .rss-image-frame {
        width: 240px;
        height: 180px;
    }
}

@media (min-width: 1024px) {
    .rss-image-frame {
        width: 280px;
        height: 200px;
    }
}

@media (max-width: 480px) {
    .rss-image-frame {
        width: 180px;
        height: 135px;
    }
}

.rss-image-frame::after {
    content: '🔍';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    font-size: 1.8rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.rss-image-frame:hover::after {
    opacity: 1;
}

.rss-image-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.rss-image-frame:hover img {
    transform: scale(1.08);
}

.rss-image-frame.single-image {
    width: 100%;
    padding-bottom: 56.25%;
    height: auto;
}

.rss-image-frame.single-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ==========================================================================
   ВИДЕО В ГАЛЕРЕЕ
 ========================================================================== */
.rss-video-frame {
    position: relative;
    width: 440px;
    height: 330px;
    flex-shrink: 0;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

@media (min-width: 768px) {
    .rss-video-frame {
        width: 480px;
        height: 360px;
    }
}

@media (min-width: 1024px) {
    .rss-video-frame {
        width: 560px;
        height: 400px;
    }
}

@media (max-width: 480px) {
    .rss-video-frame {
        width: 360px;
        height: 270px;
    }
}

.rss-video-gallery:has(.rss-video-frame:only-child) {
    justify-content: center;
}

.rss-video-gallery.single-video-item {
    justify-content: center;
}

.rss-video-frame::after {
    content: '▶';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.9);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}

.rss-video-frame:hover::after {
    opacity: 1;
}

.rss-video-frame video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain;
    border-radius: 0;
    margin: 0;
    box-shadow: none;
    min-width: 0 !important;
    min-height: 0 !important;
}

/* ==========================================================================
   ВИДЕО ТУМБНЕЙЛЫ
 ========================================================================== */
.rss-media-wrapper.rss-video-thumbnail,
.rss-video-thumbnail {
    position: relative !important;
    width: 100% !important;
    max-width: 50% !important;
    margin: 1.5rem auto !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    background: #000 !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08) !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    aspect-ratio: 16 / 9 !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
}

@media (min-width: 1024px) {
    .rss-media-wrapper.rss-video-thumbnail,
    .rss-video-thumbnail {
        max-width: min(50%, 800px) !important;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .rss-media-wrapper.rss-video-thumbnail,
    .rss-video-thumbnail {
        max-width: min(70%, 600px) !important;
    }
}

@media (max-width: 767px) {
    .rss-media-wrapper.rss-video-thumbnail,
    .rss-video-thumbnail {
        max-width: 100% !important;
        margin: 1rem auto !important;
    }
}

@supports not (aspect-ratio: 16 / 9) {
    .rss-media-wrapper.rss-video-thumbnail,
    .rss-video-thumbnail {
        padding-bottom: 56.25% !important;
        height: 0 !important;
    }
}

.rss-video-thumbnail:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.rss-video-thumbnail::after {
    content: '▶';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.9);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}

.rss-video-thumbnail:hover::after {
    opacity: 1;
}

.rss-video-thumbnail img,
.rss-media-wrapper.rss-video-thumbnail img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
    max-height: 100% !important;
    box-sizing: border-box !important;
}

/* ==========================================================================
   ССЫЛКИ И ЦИТАТЫ
 ========================================================================== */
.feed-item-description a {
    color: var(--primary, #ff6200);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.3s ease;
}

.feed-item-description a:hover {
    opacity: 0.85;
    text-decoration: underline;
}

.feed-item-description blockquote {
    border-left: 4px solid var(--primary, #ff6200);
    padding: 1.25rem;
    margin: 1.5rem 0;
    background: var(--bg-secondary, rgba(255,98,0,0.05));
    border-radius: 8px;
    font-style: italic;
    color: var(--text, #555);
}

/* ==========================================================================
   LIGHTBOX
 ========================================================================== */
.rss-lightbox-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(0,0,0,0.92) !important;
    z-index: 99999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
}

.rss-lightbox-overlay.active {
    opacity: 1 !important;
    visibility: visible !important;
}

.rss-lightbox-content {
    position: relative !important;
    max-width: 95vw !important;
    max-height: 95vh !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

.rss-lightbox-content img,
.rss-lightbox-content video {
    max-width: 100% !important;
    max-height: 90vh !important;
    border-radius: 12px !important;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6) !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

.rss-lightbox-close {
    position: absolute !important;
    top: 20px !important;
    right: 20px !important;
    width: 50px !important;
    height: 50px !important;
    background: rgba(255,255,255,0.98) !important;
    border: 2px solid rgba(255,255,255,0.3) !important;
    border-radius: 50% !important;
    font-size: 22px !important;
    font-weight: bold !important;
    color: #333 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 100000 !important;
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1) !important;
    line-height: 1 !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3) !important;
}

.rss-lightbox-close:hover {
    background: #fff !important;
    transform: rotate(90deg) scale(1.1) !important;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4) !important;
    color: var(--primary, #ff6200) !important;
}

.rss-lightbox-nav {
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 56px !important;
    height: 56px !important;
    background: rgba(255,255,255,0.95) !important;
    border: 2px solid rgba(255,255,255,0.4) !important;
    border-radius: 50% !important;
    font-size: 24px !important;
    font-weight: bold !important;
    color: #333 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 100000 !important;
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1) !important;
    line-height: 1 !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3) !important;
    user-select: none !important;
}

.rss-lightbox-nav:hover {
    background: #fff !important;
    transform: translateY(-50%) scale(1.15) !important;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4) !important;
    color: var(--primary, #ff6200) !important;
}

.rss-lightbox-nav.prev {
    left: 25px !important;
}

.rss-lightbox-nav.next {
    right: 25px !important;
}

.rss-lightbox-counter {
    position: absolute !important;
    bottom: 25px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    background: rgba(0,0,0,0.8) !important;
    color: #fff !important;
    padding: 10px 20px !important;
    border-radius: 25px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    z-index: 100000 !important;
}

/* ==========================================================================
   АДАПТИВНОСТЬ
 ========================================================================== */
@media (max-width: 1024px) {
    .com-newsfeeds-newsfeed__items > li {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    .com-newsfeeds-newsfeed {
        padding: 0 10px;
    }
    
    .com-newsfeeds-newsfeed h2 {
        font-size: 1.75rem;
    }
    
    .com-newsfeeds-newsfeed__items > li {
        padding: 1.25rem;
    }
    
    .rss-lightbox-close {
        top: 15px !important;
        right: 15px !important;
        width: 44px !important;
        height: 44px !important;
        font-size: 20px !important;
    }
    
    .rss-lightbox-nav {
        width: 48px !important;
        height: 48px !important;
        font-size: 20px !important;
    }
    
    .rss-lightbox-nav.prev {
        left: 15px !important;
    }
    
    .rss-lightbox-nav.next {
        right: 15px !important;
    }
    
    .rss-video-thumbnail {
        max-height: 300px;
    }
}

@media (max-width: 480px) {
    .rss-photo-gallery,
    .rss-video-gallery {
        gap: 0.75rem;
    }
}

/* ==========================================================================
   ПРЕДОТВРАЩЕНИЕ ПЕРЕПОЛНЕНИЯ
 ========================================================================== */
.com-newsfeeds-newsfeed__items * {
    max-width: 100% !important;
    box-sizing: border-box;
    word-break: break-word;
}

.com-newsfeeds-newsfeed__items table {
    width: 100% !important;
    overflow-x: auto;
    display: block;
}

.com-newsfeeds-newsfeed__items > li p,
.com-newsfeeds-newsfeed__items > li div,
.com-newsfeeds-newsfeed__items > li span {
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.com-newsfeeds-newsfeed__items > li pre,
.com-newsfeeds-newsfeed__items > li code {
    max-width: 100%;
    overflow-x: auto;
    word-wrap: break-word;
    white-space: pre-wrap;
}

/* ==========================================================================
   ДОПОЛНИТЕЛЬНЫЕ ПРАВИЛА ДЛЯ ВИДЕО
 ========================================================================== */
.feed-item-description video:not(.rss-video-frame video),
.com-newsfeeds-newsfeed__items video:not(.rss-video-frame video),
.com-newsfeeds-newsfeed video:not(.rss-video-frame video) {
    width: 100% !important;
    max-width: 50% !important;
    height: auto !important;
    max-height: 400px !important;
    aspect-ratio: 16 / 9 !important;
    margin: 1.5rem auto !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15) !important;
    object-fit: contain !important;
    border: none !important;
    outline: none !important;
    box-sizing: border-box !important;
}

@media (min-width: 1024px) {
    .feed-item-description video:not(.rss-video-frame video),
    .com-newsfeeds-newsfeed__items video:not(.rss-video-frame video),
    .com-newsfeeds-newsfeed video:not(.rss-video-frame video) {
        max-width: min(50%, 800px) !important;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .feed-item-description video:not(.rss-video-frame video),
    .com-newsfeeds-newsfeed__items video:not(.rss-video-frame video),
    .com-newsfeeds-newsfeed video:not(.rss-video-frame video) {
        max-width: min(70%, 600px) !important;
    }
}

@media (max-width: 767px) {
    .feed-item-description video:not(.rss-video-frame video),
    .com-newsfeeds-newsfeed__items video:not(.rss-video-frame video),
    .com-newsfeeds-newsfeed video:not(.rss-video-frame video) {
        max-width: 100% !important;
        margin: 1rem auto !important;
    }
}

@supports not (aspect-ratio: 16 / 9) {
    .feed-item-description video:not(.rss-video-frame video),
    .com-newsfeeds-newsfeed__items video:not(.rss-video-frame video),
    .com-newsfeeds-newsfeed video:not(.rss-video-frame video) {
        padding-bottom: 56.25% !important;
        height: 0 !important;
        position: relative !important;
    }
}

.feed-item-description iframe {
    max-width: 100% !important;
    width: 100% !important;
    height: 56.25vw !important;
    max-height: 450px !important;
    aspect-ratio: 16 / 9 !important;
    border: none !important;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15) !important;
    outline: none !important;
    margin: 1.5rem auto !important;
    border-radius: 12px !important;
}

@media (max-width: 768px) {
    .feed-item-description video:not(.rss-video-frame video),
    .com-newsfeeds-newsfeed__items video:not(.rss-video-frame video) {
        max-height: 300px !important;
    }
    
    .feed-item-description iframe {
        max-height: 350px !important;
    }
    
    .rss-video-thumbnail {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .feed-item-description video:not(.rss-video-frame video),
    .com-newsfeeds-newsfeed__items video:not(.rss-video-frame video) {
        max-height: 250px !important;
    }
}
