/* Publication gallery compose (variant B) + feed carousel */

/* На всю ширину формы */
.publication-gallery-compose {
    max-width: none;
    width: 100%;
    margin: 0;
}

/* Меньше пустоты между заголовком «Несколько фотографий» и превью */
#publication-cover-block.is-gallery-multi {
    padding-bottom: 0.25rem !important;
}
#publication-cover-block.is-gallery-multi #publicationCoverHintImage {
    display: none !important;
}

#publicationGalleryMultiMode {
    margin-bottom: 1.5rem; /* отступ до переключателя */
}

#pubGalleryFileName.file-selected-name {
    color: #9aa0a6;
    font-size: 0.8rem;
    margin: 0.1rem 0 0.5rem;
    text-align: center;
    word-break: break-all;
}

.pub-gallery-preview-wrap {
    position: relative;
    width: min(100%, 280px);
    max-width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
    overflow: visible;
}
.pub-gallery-preview {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 5;
    border-radius: 16px;
    overflow: hidden;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: pan-y;
    user-select: none;
    cursor: grab;
}
.pub-gallery-preview img#pubGalleryPreviewImg {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    background: #f5f5f5;
    pointer-events: none;
}
.pub-gallery-preview__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 16px;
    color: #9a9a9a;
    font-size: 14px;
    line-height: 1.4;
    text-align: center;
}
.pub-gallery-preview__empty .icon {
    opacity: 0.5;
    width: 64px !important;
    height: 64px !important;
}

.pub-gallery-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 3;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: rgba(20, 20, 20, 0.45);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    letter-spacing: 0.02em;
    pointer-events: none;
}
.pub-gallery-badge[hidden] {
    display: none !important;
}

/* Абсолют снаружи — превью остаётся по центру, позицию уточним отдельно */
.pub-gallery-preview__remove {
    position: absolute;
    top: 6px;
    left: calc(100% + 8px);
    right: auto;
    z-index: 10;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
@media (hover: hover) and (pointer: fine) {
    .pub-gallery-preview__remove:hover {
        background-color: rgba(220, 53, 69, 0.1);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14);
    }
}
.pub-gallery-preview__remove:active,
.pub-gallery-preview__remove.is-pressed {
    background-color: rgba(220, 53, 69, 0.14);
    transform: scale(0.94);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}
.pub-gallery-preview__remove[hidden] {
    display: none !important;
}
.pub-gallery-preview__remove .icon,
.pub-gallery-preview__remove svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Фиксированный размер миниатюр, ряд от центра */
.pub-gallery-thumbs {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 8px 2px 8px;
    overflow: visible;
    box-sizing: border-box;
}
.pub-gallery-thumbs::-webkit-scrollbar {
    display: none;
}
.pub-gallery-thumb {
    position: relative;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    min-width: 48px;
    max-width: 48px;
    border-radius: 10px;
    border: none;
    box-sizing: border-box;
    padding: 0;
    overflow: visible;
    background: transparent;
    cursor: pointer;
}
.pub-gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
    border-radius: 10px;
    background: #e9e9e9;
}
/* Чёткая обводка выбранного — снаружи картинки, не обрезается */
.pub-gallery-thumb.is-active::after {
    content: '';
    position: absolute;
    inset: -4px;
    border: 2.5px solid #9978D0;
    border-radius: 13px;
    pointer-events: none;
    box-shadow: 0 0 0 3px rgba(153, 120, 208, 0.22);
    z-index: 2;
}
.pub-gallery-thumb--add {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #fbfbfd 0%, #f3f0f8 100%);
    border: 2px dashed #b9a8d8;
    border-radius: 12px;
    overflow: hidden;
    background-clip: padding-box;
}
.pub-gallery-thumb--add:hover,
.pub-gallery-thumb--add:active {
    border-color: #9978D0;
    background: linear-gradient(180deg, #f8f5fc 0%, #efe8f8 100%);
}
.pub-gallery-thumb--add .icon {
    opacity: 1;
}
.pub-gallery-thumb.is-uploading {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    overflow: hidden;
    border-radius: 10px;
}
.pub-gallery-thumb.is-uploading::after {
    display: none;
}
.pub-gallery-thumb__spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.pub-gallery-thumb__spinner svg {
    display: block;
    width: 22px;
    height: 22px;
}
.pub-gallery-thumb.is-error::after {
    content: '';
    position: absolute;
    inset: -4px;
    border: 2.5px solid #dc3545;
    border-radius: 13px;
    pointer-events: none;
}

/* Feed / profile carousel */
.post-media-carousel {
    position: relative;
    width: 100%;
    user-select: none;
}
.post-media-carousel__viewport {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 0;
    background: #f5f5f5;
}
.post-media-carousel__track {
    display: flex;
    align-items: stretch;
    width: 100%;
    transition: transform 0.28s ease;
}
.post-media-carousel__slide {
    flex: 0 0 100%;
    width: 100%;
    min-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
}
.post-media-carousel__slide .image-publication {
    width: 100%;
    max-height: 550px;
    display: block;
    object-fit: contain;
    object-position: center;
    margin: 0 auto;
    align-self: center;
}
.post-media-carousel__badge {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: rgba(20, 20, 20, 0.45);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    pointer-events: none;
}
.post-media-carousel__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 4;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.post-media-carousel__nav[hidden] { display: none !important; }
.post-media-carousel__nav--prev { left: 8px; }
.post-media-carousel__nav--next { right: 8px; }
.post-media-carousel__nav svg {
    width: 18px;
    height: 18px;
    stroke: #333;
    fill: none;
    stroke-width: 2;
    overflow: visible;
}
.post-media-carousel__dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 8px;
}
.post-media-carousel__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    border: 0;
    padding: 0;
    background: #d5d5d5;
}
.post-media-carousel__dot.is-active {
    background: linear-gradient(180deg, #8AB7D5 0%, #9978D0 100%);
}
