/* ===== "Все записи" journal (/posts/) ===== */

/* .feed-wrap's -16px margin-top exists to compensate for the homepage's
   hero banner sitting right above it — this page has no hero, so left as-is
   it just pulls the header up flush against the fixed topbar. */
.pj-page-wrap {
    margin-top: 0;
}

.pj-subtitle {
    font-size: 13px;
    color: #9ca3af;
    margin: 0 0 16px;
}

.pj-section-title {
    font-size: 15px;
    font-weight: 700;
    color: #1f2933;
    margin: 0 0 12px;
}

.pj-section {
    margin-top: 26px;
}

/* Match the gap above "Сейчас читают" to the gap below the featured card —
   .cat-tabs already has its own margin-bottom (shared with /map/points/),
   which would otherwise stack on top of .pj-section's margin-top here. */
#pj-cat-tabs {
    margin-bottom: 0;
}

/* ===== Category badge over a photo ===== */
.pj-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 5px 11px;
    border-radius: 999px;
    background: rgba(11, 42, 72, 0.82);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    backdrop-filter: blur(2px);
}
.pj-badge--sm { top: 8px; left: 8px; padding: 4px 9px; font-size: 11px; }

/* ===== Photo placeholder (no photo) — same look as /map/points/ cards, ===== */
/* ===== but with the post's own category icon instead of a map pin.    ===== */
.pj-hero__img.pj-hero__img--placeholder,
.pj-fresh-card__img.pj-fresh-card__img--placeholder {
    background: #f6f7f8;
    border-bottom: 1px solid #f0f2f4;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pj-hero__img--placeholder svg,
.pj-fresh-card__img--placeholder svg { filter: brightness(0.45); }

/* ===== Featured post ("Сейчас читают") ===== */
.pj-hero {
    display: flex;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 14px;
    overflow: hidden;
    transition: background 0.15s;
}
.pj-hero:hover { background: var(--card-hover-bg); }

.pj-hero__media {
    position: relative;
    flex: 0 0 44%;
    max-width: 440px;
    aspect-ratio: 16 / 9;
    display: block;
    overflow: hidden;
}
/* position:absolute (rather than width/height:100%) keeps the photo locked to
   the 16:9 box regardless of its own intrinsic ratio — a plain height:100%
   on an <img> can lose to the image's natural aspect ratio in some browsers
   when the parent's height only comes from `aspect-ratio`. */
.pj-hero__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.pj-hero__img--placeholder svg { width: 34px; height: 34px; }

.pj-hero__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 16px 20px;
    gap: 8px;
}
.pj-hero__title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
    color: #0B1F33;
}
.pj-hero__title a { color: inherit; text-decoration: none; }
.pj-hero__title a:hover { color: #0b4f7a; }

.pj-hero__excerpt {
    margin: 0;
    font-size: 14px;
    color: #6b7280;
    line-height: 1.55;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.pj-hero__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 14px;
    margin-top: auto;
    padding-top: 4px;
}
.pj-hero__cta {
    margin-left: auto;
    font-size: 13.5px;
    font-weight: 600;
    color: #0b4f7a;
    text-decoration: none;
    white-space: nowrap;
}
.pj-hero__cta:hover { color: #0d6199; }

/* ===== Fresh posts grid ===== */
.pj-fresh-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    align-items: stretch;
}
.pj-fresh-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 14px;
    overflow: hidden;
    transition: background 0.15s;
    cursor: pointer;
}
.pj-fresh-card:hover { background: var(--card-hover-bg); }

.pj-fresh-card__media {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    flex-shrink: 0;
    overflow: hidden;
}
.pj-fresh-card__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.pj-fresh-card__img--placeholder svg { width: 28px; height: 28px; }

.pj-fresh-card__body {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 12px 14px 14px;
    gap: 6px;
}
.pj-fresh-card__title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
    height: 2.7em;
    color: #0B1F33;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.pj-fresh-card__title a { color: inherit; text-decoration: none; }
.pj-fresh-card__title a:hover { color: #0b4f7a; }

.pj-fresh-card__excerpt {
    margin: 0;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.5;
    height: 3em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.pj-fresh-card__body .feed-card__stats { margin-top: auto; }

.pj-empty { color: #9ca3af; font-size: 14px; }

/* ===== Sidebar cards: Популярные категории / Популярные записи ===== */
.pj-sidebar-card {
    background: #fff;
    border: 1px solid #eef0f2;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03), 0 1px 3px rgba(16, 24, 40, 0.04);
    height: auto;
    overflow: visible;
    padding: 18px 18px 16px;
}
.pj-sidebar-card .feed-sidebar__block-title { font-size: 16px; }

.pj-cat-list {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.pj-cat-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 4px;
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.15s;
}
.pj-cat-item a:hover { background: #f9fafb; }
.pj-cat-item svg { width: 19px; height: 19px; color: #64748b; flex-shrink: 0; }
.pj-cat-item__label {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pj-cat-item__count { flex-shrink: 0; font-size: 13px; font-weight: 600; color: #9ca3af; }
.pj-cat-item--active .pj-cat-item__label { color: #0b4f7a; font-weight: 700; }
.pj-cat-item--active svg { color: #0b4f7a; }

.pj-popular-list {
    list-style: none;
    margin: 14px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.pj-popular-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.pj-popular-item__num {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    background: #f8f9fa;
    color: #6b7280;
    font-size: 12px;
    font-weight: 700;
}
.pj-popular-item a {
    padding-top: 2px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.pj-popular-item a:hover { color: #0B1F33; }

.pj-sidebar-more { display: none; }
.pj-sidebar-more--shown { display: flex; }

.pj-reveal-btn {
    display: inline-block;
    margin-top: 12px;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    color: #0b4f7a;
    text-decoration: none;
    cursor: pointer;
    flex-shrink: 0;
}
.pj-reveal-btn:hover { color: #0d6199; }

.feed-sidebar__block--pj-expanded {
    height: auto;
    overflow: visible;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .pj-hero { flex-direction: column; }
    .pj-hero__media { flex: none; max-width: none; width: 100%; }
    .pj-hero__body { padding: 12px 4px 4px; }
    .pj-hero__title { font-size: 18px; }
    .pj-fresh-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
    .pj-fresh-card__body { padding: 10px 10px 12px; }
    .pj-fresh-card__title { font-size: 14px; }

    /* Sidebar blocks get interleaved into the fresh-posts grid by JS —
       make them span the full grid row instead of a single card cell. */
    .index-layout { flex-direction: column; }
    .feed-layout { max-width: 100%; }
    .pj-fresh-grid .feed-sidebar__block {
        grid-column: 1 / -1;
        margin: 4px 0;
    }
    /* Match the homepage's mobile sidebar-block look: plain gray card, ──
       no border/shadow (those are the desktop white-card treatment). ── */
    .pj-fresh-grid .pj-sidebar-card {
        padding: 16px;
        background: rgb(248, 248, 249);
        border: none;
        box-shadow: none;
    }
}

@media (max-width: 480px) {
    .pj-fresh-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}
