.plathix-gallery {
    --plathix-item-height: 220px;
    display: grid;
    gap: 12px;
}

.plathix-gallery--cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.plathix-gallery--cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.plathix-gallery--cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.plathix-gallery--cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.plathix-gallery--cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.plathix-gallery--cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.plathix-gallery--masonry {
    column-gap: 12px;
    display: block;
}

/* Masonry — кладка через CSS multi-column. Число колонок берётся из того же класса
   --cols-N, что и grid (PHP ставит оба класса на враппер). Без column-count masonry
   схлопывался в одну колонку (grid-template-columns при display:block игнорируется). */
.plathix-gallery--masonry.plathix-gallery--cols-1 { column-count: 1; }
.plathix-gallery--masonry.plathix-gallery--cols-2 { column-count: 2; }
.plathix-gallery--masonry.plathix-gallery--cols-3 { column-count: 3; }
.plathix-gallery--masonry.plathix-gallery--cols-4 { column-count: 4; }
.plathix-gallery--masonry.plathix-gallery--cols-5 { column-count: 5; }
.plathix-gallery--masonry.plathix-gallery--cols-6 { column-count: 6; }

.plathix-gallery--masonry .plathix-gallery__item {
    break-inside: avoid;
    margin-bottom: 12px;
}

.plathix-gallery--justified {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.plathix-gallery--justified .plathix-gallery__item {
    flex: 1 1 240px;
}

.plathix-gallery__item {
    margin: 0;
}

.plathix-gallery__item img,
.plathix-gallery__item video,
.plathix-gallery__item iframe {
    display: block;
    width: 100%;
}

.plathix-gallery__item iframe {
    aspect-ratio: 16 / 9;
    border: 0;
}

.plathix-gallery:not(.plathix-gallery--no-crop) .plathix-gallery__item img {
    height: var(--plathix-item-height);
    object-fit: cover;
}

.plathix-gallery__caption {
    color: #50575e;
    font-size: 12px;
    line-height: 1.5;
    margin-top: 6px;
}

/* Документы — grid, число колонок из --cols-N (эталон: контрол «Колонки» на Docs,
   PLX-SCB5-fix). Базовый .plathix-gallery уже display:grid; тут только gap. Без
   --cols-N (columns не задан) вырождается в 1 колонку через grid-auto-flow. */
.plathix-gallery--documents {
    gap: 12px;
}

.plathix-gallery--documents:not([class*="--cols-"]) {
    grid-template-columns: 1fr;
}

.plathix-document-item {
    align-items: center;
    border-radius: 12px;
    display: flex;
    gap: 16px;
    padding: 4px;
}

.plathix-document-item__icon {
    align-items: center;
    display: inline-flex;
    flex: 0 0 auto;
    justify-content: center;
    text-decoration: none;
}

.plathix-document-item__thumb {
    border-radius: 8px;
    height: 60px;
    object-fit: cover;
    width: 60px;
}

/* Иконка типа файла (режим Документы, PLX-GAL-documents-icons). SVG фикс. размера —
   опрятный список. Заменяет превью (__thumb) и текстовый бейдж (__badge). */
.plathix-document-item__icon-img {
    height: 48px;
    width: 48px;
    display: block;
}

/* Размер иконки типа файла (PLX-SCB5-103, A3). Модификатор на ссылке-иконке
   (__icon--{size}) задаёт размер вложенного SVG. medium (48px) = базовый дефолт. */
.plathix-document-item__icon--small .plathix-document-item__icon-img {
    height: 32px;
    width: 32px;
}
.plathix-document-item__icon--medium .plathix-document-item__icon-img {
    height: 48px;
    width: 48px;
}
.plathix-document-item__icon--large .plathix-document-item__icon-img {
    height: 64px;
    width: 64px;
}
.plathix-document-item__icon--xlarge .plathix-document-item__icon-img {
    height: 96px;
    width: 96px;
}

.plathix-document-item__badge {
    align-items: center;
    background: #2271b1;
    border-radius: 10px;
    color: #fff;
    display: inline-flex;
    font-size: 13px;
    font-weight: 700;
    height: 60px;
    justify-content: center;
    letter-spacing: 0.04em;
    min-width: 60px;
    padding: 0 10px;
    text-transform: uppercase;
}

.plathix-document-item--pdf .plathix-document-item__badge { background: #d63638; }
.plathix-document-item--doc .plathix-document-item__badge { background: #3858a6; }
.plathix-document-item--xls .plathix-document-item__badge { background: #217346; }
.plathix-document-item--ppt .plathix-document-item__badge { background: #c05a00; }
.plathix-document-item--archive .plathix-document-item__badge { background: #6b7280; }
.plathix-document-item--text .plathix-document-item__badge { background: #7c3aed; }
.plathix-document-item--file .plathix-document-item__badge { background: #4b5563; }

.plathix-document-item__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.plathix-document-item__title {
    align-self: flex-start;
    color: #0856c8;
    font-size: 18px;
    line-height: 1.35;
    text-decoration: none;
    word-break: break-word;
}

.plathix-document-item__title:hover,
.plathix-document-item__title:focus-visible,
.plathix-document-item__icon:hover + .plathix-document-item__body .plathix-document-item__title {
    text-decoration: underline;
}

.plathix-document-item__meta {
    color: #50575e;
    font-size: 13px;
    line-height: 1.4;
}

/* Кнопка «Скачать» карточки документа (PLX-SCB5-103, A5). Отдельный download-
   аффорданс в __body, независимый от ссылки-заголовка (link_to). */
.plathix-document-item__download {
    align-items: center;
    align-self: flex-start;
    background: #f0f0f1;
    border-radius: 6px;
    color: #1e1e1e;
    display: inline-flex;
    font-size: 13px;
    font-weight: 500;
    gap: 6px;
    margin-top: 4px;
    padding: 5px 12px;
    text-decoration: none;
    transition: background 0.12s;
}

.plathix-document-item__download:hover,
.plathix-document-item__download:focus-visible {
    background: #e0e0e1;
}

@media (max-width: 782px) {
    .plathix-gallery--cols-4,
    .plathix-gallery--cols-5,
    .plathix-gallery--cols-6 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Masonry на узких экранах — тоже 2 колонки (аналог grid-сужения выше). */
    .plathix-gallery--masonry.plathix-gallery--cols-4,
    .plathix-gallery--masonry.plathix-gallery--cols-5,
    .plathix-gallery--masonry.plathix-gallery--cols-6 {
        column-count: 2;
    }

    .plathix-document-item {
        align-items: flex-start;
        gap: 14px;
    }

    .plathix-document-item__title {
        font-size: 16px;
    }
}
