.bw-post {
    width: 100%;
}

.bw-post-archive {
    width: min(calc(100% - 2rem), var(--bw-layout-max-width, 80rem));
    margin-inline: auto;
    padding-block: clamp(1.5rem, 4vw, 4rem);
}

/*
 * Shared horizontal layout contract (boxweaver-content-ux-ui-consistency-01, scope E):
 * `.bw-post__after-hero` used to notch its own fixed 1rem margin on top of the width
 * restriction, independently of `--bw-page-inline-gutter`. That produced a gutter value
 * that never matched the Page-side gutter (which steps 1rem -> 1.5rem -> 2rem) and, once
 * combined with each Section's own `--bw-space-section-x` padding, drifted further from
 * the Breadcrumb at wider breakpoints. `.bw-post__after-hero` now only caps/centers the
 * post column (no inset of its own) and exposes the same responsive `--bw-page-inline-gutter`
 * used by the Page layout (packages/lbenneth/boxweaver-pages/resources/css/page-shell.css)
 * so the Breadcrumb (boxweaver-core resources/views/components/navigation/breadcrumbs.blade.php)
 * and `.bw-post__layout` inherit one identical value at every breakpoint.
 */
.bw-post__after-hero {
    --bw-page-inline-gutter: 1rem;
    width: 100%;
    max-width: var(--bw-layout-max-width, 80rem);
    margin-inline: auto;
    padding-block-start: calc(var(--bw-space-section-y-bottom, var(--bw-space-section-y, 0)) * .5);
    --bw-link-color: var(--bw-link-light-color, var(--bw-token-primary, currentColor));
    --bw-link-underline-color: var(--bw-link-light-underline-color, currentColor);
}

/*
 * Breadcrumb vertical spacing must be owned SOLELY by the Breadcrumb NORMAL/WEIT setting
 * (boxweaver-content-ux-ui-consistency-01, scope BC-01) - mirrors the equivalent Page-side
 * fix in packages/lbenneth/boxweaver-pages/resources/css/page-shell.css. Only suppresses the
 * top padding for the Hero -> Breadcrumb transition; unrelated uses of this wrapper (e.g. a
 * Post with only a topbar TOC and no Breadcrumb) are unaffected since `.bw-breadcrumbs` is
 * simply absent from the DOM in that case.
 */
.bw-post__after-hero:has(.bw-breadcrumbs) {
    padding-block-start: 0;
}

@media (min-width: 640px) {
    .bw-post__after-hero {
        --bw-page-inline-gutter: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .bw-post__after-hero {
        --bw-page-inline-gutter: 2rem;
    }
}

.bw-post-hero {
    width: 100%;
    margin: 0;
    background: var(--bw-token-surface_alt, var(--bw-color-surface_alt-100, #f8fafc));
}

.bw-post-hero__media {
    position: relative;
    min-height: var(--bw-post-hero-min-height-desktop, 60vh);
    overflow: hidden;
}

.bw-post-hero__media .bw-image,
.bw-post-hero__media .bw-image__item,
.bw-post-hero__media picture,
.bw-post-hero__media img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bw-post-hero__caption {
    width: min(calc(100% - 2rem), var(--bw-layout-max-width, 80rem));
    margin-inline: auto;
    padding-block: .5rem;
    background: var(--bw-post-hero-caption-bg, transparent);
    color: var(--bw-post-hero-caption-fg, var(--bw-token-text_muted, currentColor));
    font-size: .875rem;
}

.bw-post-hero__caption.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/*
 * The `.bw-post__layout` grid-template-columns/column-gap/aside-modifier formulas now live in
 * the SHARED Page/Post content-layout-shell contract (boxweaver-core
 * resources/css/content-shell.css, scope SHELL-01), which this asset bucket loads before this
 * file (see config/boxweaver-assets.php, `posts.frontend`). `.bw-post__content` and the shared Core aside
 * columns resolve through the SAME named grid lines (`content-start`/`content-end`,
 * `sidebar-left-*`, `sidebar-right-*`) Pages use, instead of Post's own numeric column indices -
 * so a Breadcrumb, a normal Section, a Tabs section and the Post main column all share one
 * `content-start / content-end` main-column area for the same aside configuration.
 */
.bw-post__layout {
    padding-block-end: clamp(1.5rem, 4vw, 4rem);
}

.bw-post .bw-content-role--subline {
    color: var(--bw-token-text_muted, currentColor);
    font-size: clamp(1.125rem, 1rem + .45vw, 1.45rem);
    font-weight: 500;
    line-height: 1.45;
    letter-spacing: .01em;
}

.bw-post .bw-content-role--subline > :first-child {
    margin-block-start: 0;
}

.bw-post__content {
    grid-column: content-start / content-end;
    grid-row: 2;
    min-width: 0;
}

.bw-post__mobile-date {
    display: none;
}

.bw-post__date {
    display: block;
    text-align: right;
    font-size: smaller;
}

.bw-post__lead {
    margin-block: clamp(1.25rem, 3vw, 2.5rem);
    font-size: var(--bw-font-size-lg, 1.125rem);
}

.bw-post__featured-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bw-post__featured-media picture {
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

/*
 * Shared Post footer Section (boxweaver-content-ux-ui-consistency-01, correction pass 2, scope
 * FOOT-01; staging UX correction 01: X-only padding): `.bw-post__footer` supplies the
 * Section-style X-only inset (`.bw-pad-section-x`, applied in the blade partial — no outer
 * Section Y padding here) and the gap between Quellen/Referenzen and the Author when both are
 * present, reusing the exact same 1.5x derived gap token the main/aside grid gap uses (see
 * content-shell.css `--bw-page-col-gap`) instead of an unrelated margin value. `gap` naturally
 * adds no space when only one child (or neither) is present, so no artificial empty Y-gap.
 */
.bw-post__footer {
    display: grid;
    gap: var(--bw-page-col-gap);
}

.bw-post__references {
    margin-block-start: 0;
}

.bw-post__author {
    margin-block-start: 0;
    padding: 0;
}

.bw-post__author > h2 {
    margin-block-start: 0;
}

.bw-post-search {
    --bw-post-search-control-height: 3rem;

    margin-block: 1.5rem 2rem;
    padding: clamp(1rem, 2vw, 1.5rem);
    border: var(--bw-module-search-border-width, 1px) solid var(--bw-module-search-border-color, var(--bw-token-border, rgba(15, 23, 42, .14)));
    border-radius: var(--bw-module-search-radius, var(--bw-radius-global, .5rem));
    background: var(--bw-module-search-background, var(--bw-token-surface, var(--bw-color-surface-50, #fff)));
    color: var(--bw-module-search-text-color, var(--bw-token-text, currentColor));
    box-shadow: var(--bw-card-shadow-base, none);
}

.bw-post-search__disclosure {
    display: block;
}

.bw-post-search__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-block-end: 1rem;
    list-style: none;
}

.bw-post-search__summary::-webkit-details-marker {
    display: none;
}

.bw-post-search__summary--empty {
    display: none;
}

.bw-post-search__content {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) max-content;
    gap: 1rem;
    align-items: end;
}

.bw-post-search__heading {
    margin: 0;
    color: inherit;
    font-family: var(--bw-headline-h4-font-family, var(--bw-copy-font-family, ui-sans-serif));
    font-size: var(--bw-headline-h4-font-size, 1.5rem);
    font-weight: var(--bw-headline-h4-font-weight, 700);
    line-height: var(--bw-headline-h4-line-height, 1.3);
}

.bw-post-search__chevron {
    display: none;
    flex: 0 0 auto;
    transition: transform var(--bw-motion-duration-fast, 180ms) var(--bw-motion-easing-standard, ease);
}

.bw-post-search__field {
    display: grid;
    gap: .25rem;
    min-width: 0;
    font-size: .875rem;
    font-weight: 600;
}

.bw-post-search__field select,
.bw-post-search__field input {
    box-sizing: border-box;
    width: 100%;
    min-height: var(--bw-post-search-control-height);
    block-size: var(--bw-post-search-control-height);
    padding: .7rem .85rem;
    border: var(--bw-module-search-border-width, 1px) solid var(--bw-module-search-border-color, var(--bw-token-border, rgba(15, 23, 42, .14)));
    border-radius: var(--bw-module-search-radius, var(--bw-radius-global, .5rem));
    outline: 0;
    background: var(--bw-module-search-input-background, var(--bw-token-background, #fff));
    color: var(--bw-module-search-input-text-color, var(--bw-token-text, currentColor));
    font: inherit;
    transition: border-color var(--bw-motion-duration-fast, 180ms) var(--bw-motion-easing-standard, ease), box-shadow var(--bw-motion-duration-fast, 180ms) var(--bw-motion-easing-standard, ease);
}

.bw-post-search__field select option {
    background-color: var(--bw-module-search-input-background, var(--bw-token-background, #fff));
    color: var(--bw-module-search-input-text-color, var(--bw-token-text, currentColor));
}

.bw-post-search__field select:focus-visible,
.bw-post-search__field input:focus-visible {
    border-color: var(--bw-button-primary-bg, var(--bw-token-primary, currentColor));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--bw-button-primary-bg, var(--bw-token-primary, currentColor)) 22%, transparent);
}

.bw-post-search__actions {
    display: flex;
    flex-wrap: nowrap;
    gap: .75rem;
    align-items: center;
}

.bw-post-search__actions .bw-button {
    box-sizing: border-box;
    flex: 0 0 auto;
    min-height: var(--bw-post-search-control-height);
    block-size: var(--bw-post-search-control-height);
    margin-block: 0;
    white-space: nowrap;
}

.bw-post-archive__items {
    display: grid;
    gap: 1.5rem;
}

.bw-post-archive__items--grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.bw-post-archive__items--list {
    grid-template-columns: minmax(0, 1fr);
}

.bw-post-pagination {
    margin-block-start: clamp(2rem, 4vw, 3.5rem);
}

.bw-post-card,
.bw-post-card__event-time {
    --bw-post-card-overlay-bg: var(--bw-token-primary, var(--bw-color-primary-500, #2563eb));
    --bw-post-card-overlay-auto-fg: var(--bw-token-primary-contrast, var(--bw-token-white, #fff));
    --bw-post-card-overlay-fg: var(--bw-post-card-overlay-auto-fg);
}

.bw-post-card {
    min-width: 0;
    height: 100%;
}

:is(.bw-post-card, .bw-post-card__event-time)[data-bw-post-card-overlay-tone="secondary"] {
    --bw-post-card-overlay-bg: var(--bw-token-secondary, var(--bw-color-secondary-500, #475569));
    --bw-post-card-overlay-auto-fg: var(--bw-token-secondary-contrast, var(--bw-token-white, #fff));
}

:is(.bw-post-card, .bw-post-card__event-time)[data-bw-post-card-overlay-tone="tertiary"] {
    --bw-post-card-overlay-bg: var(--bw-token-tertiary, var(--bw-color-tertiary-500, #7c3aed));
    --bw-post-card-overlay-auto-fg: var(--bw-token-tertiary-contrast, var(--bw-token-white, #fff));
}

:is(.bw-post-card, .bw-post-card__event-time)[data-bw-post-card-overlay-tone="surface"] {
    --bw-post-card-overlay-bg: var(--bw-card-bg-color, var(--bw-token-surface, #fff));
    --bw-post-card-overlay-auto-fg: var(--bw-token-surface-contrast, var(--bw-token-black, #000));
}

:is(.bw-post-card, .bw-post-card__event-time)[data-bw-post-card-overlay-tone="black"] {
    --bw-post-card-overlay-bg: var(--bw-token-black, #000);
    --bw-post-card-overlay-auto-fg: var(--bw-token-white, #fff);
}

:is(.bw-post-card, .bw-post-card__event-time)[data-bw-post-card-overlay-tone="white"] {
    --bw-post-card-overlay-bg: var(--bw-token-white, #fff);
    --bw-post-card-overlay-auto-fg: var(--bw-token-black, #000);
}

:is(.bw-post-card, .bw-post-card__event-time)[data-bw-post-card-overlay-text-color="white"] {
    --bw-post-card-overlay-fg: var(--bw-token-white, #fff);
}

:is(.bw-post-card, .bw-post-card__event-time)[data-bw-post-card-overlay-text-color="black"] {
    --bw-post-card-overlay-fg: var(--bw-token-black, #000);
}

.bw-post-card > .bw-card__body {
    display: flex;
    min-width: 0;
    height: 100%;
    flex-direction: column;
    overflow: hidden;
    border-radius: inherit;
}

.bw-post-card__content {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--bw-space-element-y, .85rem);
    padding: var(--bw-space-card-y, 1rem) var(--bw-space-card-x, 1rem);
}

.bw-post-card__content > * {
    margin-block: 0;
}

.bw-post-card__content > .bw-button {
    margin-block-start: auto;
    cursor: pointer;
}

.bw-post-card__media-shell {
    position: relative;
    width: 100%;
}

.bw-post-card__image-overlays {
    position: absolute;
    inset-inline: 0;
    inset-block-end: 0;
    display: grid;
}

.bw-post-card__event-time {
    display: inline-flex;
    flex-wrap: wrap;
    gap: .25em;
}

.bw-post-card__event-time--banner {
    justify-self: start;
    max-width: calc(100% - var(--bw-space-card-x, 1rem));
    margin: calc(var(--bw-space-card-y, 1rem) * .5) calc(var(--bw-space-card-x, 1rem) * .5);
    padding: .25em .5em;
    background: var(--bw-post-card-overlay-bg);
    color: var(--bw-post-card-overlay-fg);
    font-size: .875rem;
}

.bw-post-card__image-title {
    --bw-link-color: var(--bw-post-card-overlay-fg);
    --bw-link-underline-color: currentColor;
    display: grid;
    gap: .35rem;
    padding-block: calc(var(--bw-space-card-y, 1rem) * .5);
    padding-inline: calc(var(--bw-space-card-x, 1rem) * .5);
    background: var(--bw-post-card-overlay-bg);
    color: var(--bw-post-card-overlay-fg);
}

.bw-post-card__image-title .bw-post-card__title {
    color: inherit;
    font-size: calc(var(--bw-headline-h4-font-size, 1.25rem) * .82);
}

.bw-post-card__title a {
    color: inherit;
}

.bw-post-card__image-title .bw-post-card__category {
    color: inherit;
    opacity: .82;
}

.bw-post-card__category a {
    display: inline-block;
    color: inherit;
    font-weight: 600;
    transition: transform var(--bw-motion-duration-fast, 180ms) var(--bw-motion-easing-standard, ease);
}

.bw-post-card__category a:hover,
.bw-post-card__category a:focus-visible {
    transform: translateY(var(--bw-button-hover-translate-y, -2px));
}

.bw-post-card__category,
.bw-post-card__meta {
    color: var(--bw-token-text_muted, color-mix(in srgb, currentColor 68%, transparent));
    font-size: .875rem;
}

.bw-post-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1rem;
}

.bw-post__featured-media {
    width: 100%;
    margin: 0;
}

.bw-post-card .bw-post__featured-media picture {
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

.bw-post-card .bw-post__featured-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bw-post-card .bw-post__featured-media figcaption {
    display: none;
}

.bw-post__content > .bw-post__featured-media {
    margin-block: clamp(1rem, 2vw, 1.75rem);
}

.bw-post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.bw-post-tags a {
    display: inline-flex;
    align-items: center;
    min-height: 2rem;
    padding: .25rem .65rem;
    border: var(--bw-button-primary-border-width, 2px) solid var(--bw-chip-border, var(--bw-chip-bg, transparent));
    border-radius: var(--bw-button-primary-radius, var(--bw-radius-global, 0));
    background: var(--bw-chip-bg, var(--bw-button-primary-bg, var(--bw-token-primary, transparent)));
    color: var(--bw-chip-fg, var(--bw-button-primary-fg, currentColor));
    box-shadow: var(--bw-button-primary-shadow, none);
    font-size: var(--bw-chip-font-size, .875rem);
    font-weight: var(--bw-chip-font-weight, 700);
    line-height: 1.2;
    text-decoration: none;
    transition: background-color var(--bw-motion-duration-fast, 180ms) var(--bw-motion-easing-standard, ease), border-color var(--bw-motion-duration-fast, 180ms) var(--bw-motion-easing-standard, ease), color var(--bw-motion-duration-fast, 180ms) var(--bw-motion-easing-standard, ease), transform var(--bw-motion-duration-fast, 180ms) var(--bw-motion-easing-standard, ease), box-shadow var(--bw-motion-duration-fast, 180ms) var(--bw-motion-easing-standard, ease);
}

.bw-post-tags a:hover,
.bw-post-tags a:focus-visible {
    border-color: var(--bw-chip-border-hover, var(--bw-chip-bg-hover, var(--bw-chip-border, transparent)));
    background: var(--bw-chip-bg-hover, var(--bw-chip-bg, var(--bw-button-primary-bg-hover, var(--bw-token-primary, transparent))));
    color: var(--bw-chip-fg-hover, var(--bw-chip-fg, var(--bw-button-primary-fg-hover, currentColor)));
}

@media (max-width: 64rem) {
    .bw-post-search__summary {
        cursor: pointer;
        margin-block-end: 0;
    }

    .bw-post-search__disclosure[open] > .bw-post-search__summary {
        margin-block-end: 1rem;
    }

    .bw-post-search__chevron {
        display: block;
    }

    .bw-post-search__disclosure[open] > .bw-post-search__summary .bw-post-search__chevron {
        transform: rotate(180deg);
    }

    .bw-post-search__content {
        grid-template-columns: minmax(0, 1fr);
    }

    .bw-post-search__actions {
        grid-column: 1 / -1;
    }

    .bw-post-archive__items--grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 64.0625rem) {
    .bw-post-search__summary {
        pointer-events: none;
    }

    .bw-post-search__disclosure > .bw-post-search__content {
        display: grid !important;
    }
}

@media (max-width: 42rem) {
    .bw-post-hero__media {
        min-height: var(--bw-post-hero-min-height-mobile, 43.2svh);
    }

    .bw-post-archive__items--grid {
        grid-template-columns: minmax(0, 1fr);
    }

}

/* Posts retain Breadcrumbs -> LEFT -> MAIN -> RIGHT stacking at the shared breakpoint.
 * Core detail-layout owns rail spacing, gutters and desktop placement; only Posts' mobile
 * flex ordering belongs here. Scope Core rail selectors to this Post layout. */
@media (max-width: 1279px) {
    /*
     * Switches to flexbox (column direction) instead of re-asserting `display: grid` with a
     * single track. The desktop grid places children via named lines
     * (main-start/main-end, sidebar-left-* / sidebar-right-*) that do not exist in a one-track
     * grid, which forced the browser to synthesize extra implicit columns to satisfy those
     * out-of-range references - defeating the single-column collapse. Flexbox has no
     * grid-column concept to conflict with, so `order` alone reliably reflows Breadcrumbs -> LEFT
     * aside -> MAIN -> RIGHT aside into a single visual column, matching the addendum's DOM/visual
     * reading order.
     */
    .bw-post__layout.bw-content-shell {
        display: flex;
        flex-direction: column;
        /*
         * UX/UI regression triage 01, BUG 04: `.bw-content-shell`'s unconditional (desktop-grid)
         * rule sets `align-items: start`, meant to top-align grid ROWS. `align-items` is
         * reinterpreted for a `flex-direction: column` container as the CROSS axis, which here is
         * HORIZONTAL - so that same `start` value, never reset for this flex fallback, shrink-wrapped
         * every flex child (breadcrumbs, both asides, main content) to its own content width and
         * pinned it to the container's inline-start edge instead of stretching it full width. That is
         * exactly the reported "jumps to the viewport edge" symptom for the stacked aside. `stretch`
         * is the flexbox default and restores normal full-width children.
         */
        align-items: stretch;
    }

    /* Addendum: Breadcrumbs (order 0, default) -> LEFT aside -> MAIN -> RIGHT aside. */
    .bw-post__layout > .bw-content-detail__aside--left {
        order: 1;
    }

    .bw-post__content {
        order: 2;
    }

    .bw-post__layout > .bw-content-detail__aside--right {
        order: 3;
    }

    .bw-post__mobile-date {
        display: block;
    }
}
