/* Shared layout for own and Contao core content on mixed article pages. */
body.b2sme-theme .b2sme-costs,
body.b2sme-theme .b2sme-faq,
body.b2sme-theme main .mod_article > :is(.content-text,.content-image,.content-gallery,.content-hyperlink,.mod_newslist,.mod_eventlist) {
    width: min(100% - 2rem, var(--b2sme-content));
    margin-inline: auto;
}

/* The configured element spacing is the single source of vertical page rhythm.
   Normal: 300px desktop / 200px tablet / 100px mobile.
   Half:   150px desktop / 100px tablet / 50px mobile.
   No component adds compensating top spacing. */
body.b2sme-theme main .mod_article > * {
    margin-bottom: 300px !important;
}
body.b2sme-theme main .mod_article > .b2sme-spacing--half {
    margin-bottom: 150px !important;
}
body.b2sme-theme main .mod_article > .b2sme-spacing--none {
    margin-bottom: 0 !important;
}

@media (max-width: 64rem) {
    body.b2sme-theme main .mod_article > * { margin-bottom: 200px !important; }
    body.b2sme-theme main .mod_article > .b2sme-spacing--half { margin-bottom: 100px !important; }
    body.b2sme-theme main .mod_article > .b2sme-spacing--none { margin-bottom: 0 !important; }
}

@media (max-width: 48rem) {
    body.b2sme-theme main .mod_article > * { margin-bottom: 100px !important; }
    body.b2sme-theme main .mod_article > .b2sme-spacing--half { margin-bottom: 50px !important; }
    body.b2sme-theme main .mod_article > .b2sme-spacing--none { margin-bottom: 0 !important; }
}

/* Normal content components must not create a second vertical spacing system. */
body.b2sme-theme :is(
    .b2sme-teaser,
    .b2sme-section,
    .b2sme-team,
    .b2sme-statement,
    .b2sme-products,
    .b2sme-costs,
    .b2sme-faq
) {
    padding-top: 0;
    padding-bottom: 0;
}

/* Contao's base content template renders the element headline before the custom
   inner component. Keep that headline on the same content axis without an
   additional left margin. */
body.b2sme-theme main .mod_article > [class*="content-b2sme-"] > :is(h1,h2,h3,h4,h5,h6) {
    width: min(100% - 2rem, var(--b2sme-content));
    max-width: var(--b2sme-content);
    margin: 0 0 1.5rem;
}

body.b2sme-theme main .mod_article > :is(.content-download,.content-downloads,.content-image,.content-gallery,.content-hyperlink) > :is(h1,h2,h3,h4,h5,h6),
body.b2sme-theme main .mod_article > .content-module > :is(h1,h2,h3,h4,h5,h6) {
    width: min(100% - 2rem, var(--b2sme-content));
    max-width: var(--b2sme-content);
    margin: 0 0 1.5rem;
}

body.b2sme-theme main .mod_article > .content-text > :is(h1,h2,h3,h4,h5,h6) {
    width: 100%;
    max-width: none;
    margin: 0 0 1.5rem;
}

body.b2sme-theme .b2sme-costs__items {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin: 2rem 0 0;
}

body.b2sme-theme .b2sme-costs__item {
    display: grid;
    gap: .65rem;
    padding: clamp(1.25rem, 3vw, 2rem);
    border: 1px solid var(--b2sme-border);
    border-radius: var(--b2sme-radius);
    background: var(--b2sme-surface-soft);
}

body.b2sme-theme .b2sme-costs__item dt {
    color: var(--b2sme-muted);
    font-weight: 700;
}

body.b2sme-theme .b2sme-costs__item dd {
    display: grid;
    gap: .35rem;
    margin: 0;
}

body.b2sme-theme .b2sme-costs__item strong {
    color: var(--b2sme-secondary);
    font-size: clamp(1.35rem, 2.5vw, 2rem);
}

body.b2sme-theme .b2sme-costs__item small {
    color: var(--b2sme-muted);
}

/* FAQ should read as a deliberate accordion, not two loose text rows. */
body.b2sme-theme .b2sme-faq__items {
    margin-top: 2rem;
    border-top: 1px solid var(--b2sme-border);
}
body.b2sme-theme .b2sme-faq__item {
    border-bottom: 1px solid var(--b2sme-border);
}
body.b2sme-theme .b2sme-faq__item summary {
    position: relative;
    padding: 1.2rem 3rem 1.2rem 0;
    font-weight: 750;
    cursor: pointer;
    list-style: none;
}
body.b2sme-theme .b2sme-faq__item summary::-webkit-details-marker { display: none; }
body.b2sme-theme .b2sme-faq__item summary::after {
    content: "+";
    position: absolute;
    right: .25rem;
    top: 50%;
    translate: 0 -50%;
    color: var(--b2sme-primary);
    font-size: 1.4rem;
    line-height: 1;
}
body.b2sme-theme .b2sme-faq__item[open] summary::after { content: "−"; }
body.b2sme-theme .b2sme-faq__item > div {
    padding: 0 0 1.25rem;
    color: var(--b2sme-muted);
}

/* Core image/gallery elements should respect the same content width. */
body.b2sme-theme .content-image figure,
body.b2sme-theme .content-gallery figure {
    margin: 0;
}

body.b2sme-theme .content-image img {
    display: block;
    width: 100%;
    max-height: 42rem;
    object-fit: cover;
    border-radius: var(--b2sme-radius);
}

/* Core news list as cards instead of full-width image/text stacks. */
body.b2sme-theme .mod_newslist {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.5rem;
}

body.b2sme-theme .mod_newslist .layout_latest {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border: 1px solid var(--b2sme-border);
    border-radius: var(--b2sme-radius);
    background: var(--b2sme-surface);
    box-shadow: var(--b2sme-card-shadow);
}

body.b2sme-theme .mod_newslist .layout_latest > :not(figure) {
    margin-inline: 1.25rem;
}

body.b2sme-theme .mod_newslist .layout_latest > :last-child {
    margin-bottom: 1.25rem;
}

body.b2sme-theme .mod_newslist .layout_latest .more {
    margin-top: auto;
    padding-top: .75rem;
}

body.b2sme-theme .mod_newslist .layout_latest figure {
    margin: 0 0 1rem;
}

body.b2sme-theme .mod_newslist .layout_latest img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

body.b2sme-theme .mod_newslist .layout_latest h2,
body.b2sme-theme .mod_newslist .layout_latest p,
body.b2sme-theme .mod_newslist .layout_latest .ce_text {
    max-width: none;
}

body.b2sme-theme .mod_newslist .layout_latest h2 {
    font-size: clamp(1.3rem, 2vw, 1.7rem);
}

body.b2sme-theme .mod_newslist .info {
    color: var(--b2sme-muted);
    font-size: .875rem;
}

/* Keep CTA buttons aligned at the bottom in card teasers as well. */
body.b2sme-theme .b2sme-teaser--card .b2sme-teaser__content {
    display: flex;
    flex-direction: column;
    height: 100%;
}
body.b2sme-theme .b2sme-teaser--card .b2sme-button {
    margin-top: auto;
    align-self: flex-start;
}

/* Event list gets the same compact card language as news. */
body.b2sme-theme .mod_eventlist .event,
body.b2sme-theme .mod_eventlist .empty {
    padding: 1.5rem;
    border: 1px solid var(--b2sme-border);
    border-radius: var(--b2sme-radius);
    background: var(--b2sme-surface-soft);
}
body.b2sme-theme .mod_eventlist .event :is(h2,h3,p) { max-width: none; }
body.b2sme-theme .mod_eventlist .event > :first-child { margin-top: 0; }
body.b2sme-theme .mod_eventlist .event > :last-child { margin-bottom: 0; }

/* Contact should remain compact and visibly structured. */
body.b2sme-theme .b2sme-contact__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(1.5rem, 4vw, 3rem);
}
body.b2sme-theme .b2sme-contact__details,
body.b2sme-theme .b2sme-contact__hours {
    padding: 1.5rem;
    border: 1px solid var(--b2sme-border);
    border-radius: var(--b2sme-radius);
    background: var(--b2sme-surface-soft);
}
body.b2sme-theme .b2sme-contact__details { display: grid; gap: .45rem; }
body.b2sme-theme .b2sme-contact__details p { margin: .25rem 0; }
body.b2sme-theme .b2sme-contact__hours h3 { margin-top: 0; }
body.b2sme-theme .b2sme-contact__hours > div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding-block: .45rem;
    border-top: 1px solid var(--b2sme-border);
}

@media (max-width: 64rem) {
    body.b2sme-theme .mod_newslist {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 48rem) {
    body.b2sme-theme .b2sme-costs__items,
    body.b2sme-theme .mod_newslist,
    body.b2sme-theme .b2sme-contact__grid {
        grid-template-columns: 1fr;
    }
}
