.all-posts-page {
    position: relative;
    z-index: 1;
}

/* hide original archive pills only on this page */
.all-posts-hero-shell .archive-tags-outer,
.all-posts-hero-shell archive-tags,
.all-posts-hero-shell .tags-gradient {
    display: none !important;
}

.all-posts-hero-shell {
    position: relative;
}

.all-posts-hero-filter-row {
    position: absolute;
    top: max(188px, 21vh);
    right: 0;
    left: 0;
    z-index: 80;
    display: flex;
    justify-content: flex-end;
    pointer-events: none;
}

.all-posts-hero-filter-row > * {
    pointer-events: auto;
    margin-right: max(24px, 1.67vw);
}

.all-posts-filter-dropdown {
    position: relative;
}

.all-posts-filter-dropdown summary {
    list-style: none;
}

.all-posts-filter-dropdown summary::-webkit-details-marker {
    display: none;
}

.all-posts-filter-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 18px;
    border: 1px solid currentColor;
    border-radius: 999px;
    background: var(--background-color);
    cursor: pointer;
    font-weight: 500;
}

.all-posts-filter-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    min-width: 310px;
    max-height: min(420px, calc(100vh - 120px));
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 10px 14px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: var(--background-color);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.08);
    z-index: 9999;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.all-posts-filter-menu::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.all-posts-filter-item {
    display: block;
    padding: 10px 12px;
    color: currentColor;
    text-decoration: none;
    white-space: nowrap;
}

.all-posts-filter-item:hover {
    background: rgba(0, 0, 0, 0.04);
}

.all-posts-latest-wrap {
    margin-bottom: clamp(48px, 6vw, 72px);
}

.all-posts-latest {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(320px, 1.1fr);
    gap: clamp(24px, 3vw, 42px);
    align-items: center;
}

.all-posts-latest-media,
.all-posts-latest-title a,
.all-posts-latest-link {
    text-decoration: none;
    color: currentColor;
}

.all-posts-latest-media img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
}

.all-posts-latest-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border: 1px solid currentColor;
    border-radius: 999px;
    margin-bottom: 14px;
    font-weight: 600;
    font-size: 0.92rem;
}

.all-posts-latest-tagline {
    margin: 0 0 10px;
    opacity: 0.8;
}

.all-posts-latest-title {
    margin: 0 0 14px;
    line-height: 0.95;
}

.all-posts-latest-excerpt {
    margin: 0 0 14px;
    max-width: 60ch;
    opacity: 0.82;
}

.all-posts-latest-author {
    margin: 0 0 18px;
    display: inline-flex;
    align-items: center;
    gap: 0;
}

.all-posts-latest-author a {
    color: currentColor;
    text-decoration: none;
}

.all-posts-latest-link.button-arrow {
    margin-top: 0;
    margin-left: 0;
    opacity: 1;
    gap: max(5px, calc(0.35vw * var(--scale)));
    width: fit-content;
}

.all-posts-latest-link .icon-button-arrow {
    order: -1;
}

@media screen and (max-width: 1080px) {
    .all-posts-hero-filter-row {
        position: static;
        display: block;
        padding: 0 max(24px, 1.67vw);
        margin-top: 0;
        margin-bottom: 18px;
    }

    .all-posts-hero-filter-row > * {
        margin-right: 0;
    }

    .all-posts-filter-menu {
        left: 0;
        right: auto;
        max-height: min(360px, calc(100vh - 100px));
    }

    .all-posts-latest {
        grid-template-columns: 1fr;
        align-items: start;
    }
}

@media screen and (max-width: 767px) {
    .all-posts-hero-filter-row {
        padding: 0 18px;
    }
}

/* Keely 1.21.3 commentary page refinements */
.all-posts-hero-filter-row {
    opacity: 0;
    transform: translateY(10px);
    animation: keelyFilterIn 0.45s ease 0.25s forwards;
}

@keyframes keelyFilterIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.all-posts-filter-menu {
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.all-posts-filter-dropdown[open] .all-posts-filter-menu {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.all-posts-latest-pill {
    font-size: 0.82rem;
    line-height: 1;
    padding: 6px 13px 5px;
    font-weight: 500;
    transform: none;
    -webkit-font-smoothing: antialiased;
    text-rendering: geometricPrecision;
}

.all-posts-latest-author,
.all-posts-latest-link.button-arrow {
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.all-posts-latest-author:hover,
.all-posts-latest-link.button-arrow:hover {
    opacity: 1;
}


/* Keely 1.21.6: smoother commentary filter and latest link treatment */
.all-posts-filter-dropdown .all-posts-filter-menu {
    transform-origin: top right;
    transition: opacity 0.24s ease, transform 0.24s ease, visibility 0.24s ease;
    visibility: hidden;
}

.all-posts-filter-dropdown[open] .all-posts-filter-menu {
    animation: keelyFilterMenuOpen 0.24s ease both;
    visibility: visible;
}

@keyframes keelyFilterMenuOpen {
    from { opacity: 0; transform: translateY(10px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.all-posts-latest-author,
.all-posts-latest-link.button-arrow {
    color: color-mix(in srgb, var(--text-color) 62%, transparent);
    opacity: 1;
}

.all-posts-latest-author:hover,
.all-posts-latest-link.button-arrow:hover {
    color: var(--text-color);
    opacity: 1;
}

.all-posts-latest-pill {
    font-family: var(--font2);
    letter-spacing: 0;
    transform: translateZ(0);
}

/* Keely 1.21.7: commentary page always renders and filter opens smoothly */
.all-posts-hero-filter-row {
    animation-delay: 0.45s;
}

.all-posts-filter-dropdown:not([open]) .all-posts-filter-menu {
    visibility: hidden;
}

.all-posts-filter-dropdown[open] .all-posts-filter-menu {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Keely 1.27.2: stop mobile scroll anchoring jitter on the commentary latest story only. */
@media screen and (max-width: 767px) {
    .commentary-page .all-posts-latest-wrap,
    .commentary-page .all-posts-latest {
        overflow-anchor: none !important;
    }
}


/* Keely 1.32.0: lock the mobile commentary latest article against its own touch-drag movement only. */
@media screen and (max-width: 767px) {
    .commentary-page .all-posts-latest-wrap,
    .commentary-page .all-posts-latest,
    .commentary-page .all-posts-latest-copy {
        height: auto !important;
        max-height: none !important;
        overflow-y: visible !important;
        -webkit-overflow-scrolling: touch !important;
        overflow-anchor: none !important;
        touch-action: pan-y !important;
    }

    .commentary-page .all-posts-latest-media,
    .commentary-page .all-posts-latest-media *,
    .commentary-page .all-posts-latest-title a,
    .commentary-page .all-posts-latest-link {
        -webkit-user-drag: none !important;
        user-select: none !important;
    }
}
