/* School Banners Styles (KB1.0) */

.sb-container {
    --sb-width: 250px;
    --sb-height: 150px;
    position: relative;
    width: auto; /* Changed from 100% to prevent overflow with margins */
    max-width: 100%;
    overflow: hidden;
    margin: 20px 0;
    box-sizing: border-box;
}

.sb-wrapper {
    display: flex;
    gap: 20px;
    width: 100%;
}

/* Carousel Mode */
.sb-mode-carousel .sb-wrapper {
    overflow-x: auto;
    /* scroll-behavior: smooth; - Disabled in JS for custom animation */
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
    padding-bottom: 10px; /* Space for scrollbar if visible */
}

.sb-mode-carousel .sb-wrapper::-webkit-scrollbar {
    display: none;
}

/* Grid Mode */
.sb-mode-grid .sb-wrapper {
    flex-wrap: wrap;
}

.sb-item {
    flex: 0 0 auto;
    width: var(--sb-width);
    max-width: 100%;
    box-sizing: border-box;
}

.sb-content {
    display: block;
    height: var(--sb-height);
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s;
}

.sb-content:hover {
    transform: translateY(-3px);
}

.sb-content img {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.sb-no-image {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eee;
}

/* Navigation Buttons */
.sb-container .sb-nav {
    position: absolute;
    /* Центр по высоте самого баннера (а не всего блока с отступами) */
    top: calc(var(--sb-height) / 2);
    bottom: auto;
    margin: 0;
    padding: 0;
    line-height: 1;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.8);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s;
}

.sb-container:hover .sb-nav,
.sb-container .sb-nav:focus {
    opacity: 1;
}

.sb-container .sb-prev { left: 10px; }
.sb-container .sb-next { right: 10px; }

/* Random Mode */
.sb-mode-random .sb-wrapper {
    display: block;
}
.sb-mode-random .sb-item {
    width: 100%;
    margin: 0 auto;
    text-align: center;
}
.sb-mode-random .sb-item img {
    max-width: 300px; /* Limit width for single random banner */
    margin: 0 auto;
}
.sb-container.sb-mode-random .sb-nav {
    display: none;
}

/* Responsive */
@media (max-width: 600px) {
    .sb-mode-carousel .sb-item {
        width: min(var(--sb-width), 80%); /* Show part of next slide on mobile */
    }
    /* На touch-устройствах кнопок при наведении нет — показываем всегда */
    .sb-container .sb-nav {
        opacity: 1;
    }
}
