/* School Publications KB — витрина выпусков */

.sn-grid {
    --sn-c: 4;
    --sn-gap: 30px;
    --sn-just: center;
    --sn-ratio: 210 / 297;
    --sn-maxw: 250px;
    --sn-border: #e5e5e5;
    --sn-hover: #0073aa;
    --sn-bg: #fff;
    --sn-title: #1d2327;
    --sn-desc: #555;
    --sn-date: #444;
    --sn-badge: #e63946;
    --sn-tsize: 20px;
    --sn-dsize: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: var(--sn-gap);
    justify-content: var(--sn-just);
    margin: 20px 0;
    box-sizing: border-box;
}

.sn-c1 { --sn-c: 1; }
.sn-c2 { --sn-c: 2; }
.sn-c3 { --sn-c: 3; }
.sn-c4 { --sn-c: 4; }
.sn-c5 { --sn-c: 5; }
.sn-c6 { --sn-c: 6; }

.sn-grid *,
.sn-grid *::before,
.sn-grid *::after { box-sizing: border-box; }

.sn-item {
    display: flex;
    flex-direction: column;
    position: relative;
    width: min(calc((100% - (var(--sn-c) - 1) * var(--sn-gap)) / var(--sn-c)), var(--sn-maxw));
    max-width: 100%;
    background: var(--sn-bg);
    border: 1px solid var(--sn-border);
    border-radius: 12px;
    overflow: hidden;
    color: inherit;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s, border-color 0.3s;
}

.sn-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
    border-color: var(--sn-hover);
    z-index: 2;
}

.sn-link-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    cursor: pointer;
}

.sn-link-overlay:focus-visible {
    outline: 3px solid var(--sn-hover);
    outline-offset: -3px;
    border-radius: 12px;
}

.sn-cover-wrap {
    width: 100%;
    aspect-ratio: var(--sn-ratio);
    background: #f9f9f9;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid #f0f0f0;
}

.sn-grid .sn-cover {
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

.sn-item:hover .sn-cover {
    transform: scale(1.06);
}

.sn-no-cover {
    color: #ccc;
    display: flex;
}

.sn-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    max-width: calc(100% - 24px);
    background: var(--sn-badge);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    line-height: 1.3;
    padding: 4px 8px;
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 6;
    pointer-events: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sn-content {
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-grow: 1;
    text-align: center;
}

.sn-grid .sn-title {
    margin: 0 !important;
    padding: 0;
    font-size: var(--sn-tsize) !important;
    font-weight: 700;
    line-height: 1.3;
    color: var(--sn-title) !important;
    overflow-wrap: anywhere;
}

.sn-grid .sn-desc {
    font-size: var(--sn-dsize) !important;
    color: var(--sn-desc) !important;
    line-height: 1.5;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

.sn-grid .sn-date {
    display: block;
    font-size: 12px;
    color: var(--sn-date) !important;
    margin-top: auto;
    width: 100%;
    text-align: center;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
}

/* Режим «список»: обложка слева, текст справа */
.sn-list { flex-direction: column; flex-wrap: nowrap; gap: 16px; align-items: stretch; }
.sn-list .sn-item { width: 100%; max-width: 760px; margin-left: auto; margin-right: auto; flex-direction: row; }
.sn-list .sn-cover-wrap { width: 130px; flex: 0 0 130px; border-bottom: 0; border-right: 1px solid #f0f0f0; }
.sn-list .sn-content { text-align: left; justify-content: center; }
.sn-list .sn-desc { -webkit-line-clamp: 6; }
.sn-list .sn-date { text-align: left; margin-top: 0; border-top: 0; padding-top: 0; }
.sn-list .sn-badge { top: 8px; right: auto; left: 8px; }

/* Планшет и телефон */
@media (max-width: 900px) {
    .sn-c4, .sn-c5, .sn-c6 { --sn-c: 3; }
}

@media (max-width: 600px) {
    .sn-grid { --sn-gap: 14px; }
    .sn-c3, .sn-c4, .sn-c5, .sn-c6 { --sn-c: 2; }
    .sn-content { padding: 12px 10px; }
    .sn-grid .sn-title { font-size: min(var(--sn-tsize), 16px) !important; }
    .sn-grid .sn-desc { font-size: min(var(--sn-dsize), 14px) !important; -webkit-line-clamp: 3; }
    .sn-list .sn-item { width: 100%; }
    .sn-list .sn-cover-wrap { width: 96px; flex-basis: 96px; }
}

@media (max-width: 340px) {
    .sn-c2, .sn-c3, .sn-c4, .sn-c5, .sn-c6 { --sn-c: 1; }
    .sn-item { max-width: 280px; }
}

@media (prefers-reduced-motion: reduce) {
    .sn-item, .sn-cover { transition: none; }
    .sn-item:hover, .sn-item:hover .sn-cover { transform: none; }
}
