/*
 * CONTENT ELEMENTS - BASE
 * Shared basis of all content elements, loaded by the content element layout (see Default layout).
 *
 * Conventions
 * - Wrapper (Default layout): .content-element.content-element--<CType>[.content-element--<CType>--<layout name>]
 *                             .frame--<frame_class> (default, framed, framed-<color>, accent, filled)
 * - Component (template):    .cb-<name>, .cb-<name>__<element>, .cb-<name>--<modifier>
 * - One file per component:  components/ContentElements/<Name>.css, loaded by the template via <f:asset.css />
 * - Component tokens:        --cb-<name>--<property>, defined on the component and based on variables.css
 *
 * Mobile first
 * - Styles without query apply to the smallest width, larger widths are added by min-width queries.
 * - Content elements are containers, components query the width of their element instead of the
 *   viewport, as the same element is placed in the main column, the aside or nested in a tab:
 *   @container content-element (min-width: 30rem | 45rem | 64rem)
 * - 45rem is the full layout of the elements (columns of media and lists, CTA side by side): the main column at its
 *   max width reaches it also next to the aside and in a frame (789px, framed 747px), a smaller main column not.
 *
 * Accessibility
 * - Visible focus for all interactive elements (focus-visible), not only on hover.
 * - Interactive targets are at least var(--target) high, links in running text are excluded.
 * - Links in running text are underlined, they must not be identified by color only.
 * - Borders/outlines instead of backgrounds or shadows for states, so they stay visible in forced colors mode.
 * - Animations and transitions only within prefers-reduced-motion: no-preference.
 */

.content-element {
    --content-element--gap        : var(--layout--gap--default);
    --content-element--gap--large : var(--layout--gap--large);
    --content-element--measure    : 70ch;
    --content-element--focus      : 2px solid currentColor;
    --content-element--frame-color: var(--color--dark-grey);
    --content-element--frame      : var(--border-width--default) solid var(--content-element--frame-color);
    --content-element--frame-pad  : var(--padding--default);
    /* Headline or intro -> content, in boxes title -> content (_redesign/Abstaende.md) */
    --content-element--header-gap : var(--space--m);

    container: content-element / inline-size;
}


/* SPACING: between elements and between header and content */

.content-element + .content-element {
    margin-top: var(--content-element--gap--large);
}

.content-element > .content-element__header {
    margin-bottom: var(--content-element--header-gap);
}


/*
 * FRAMES: boxes with radius and inner spacing (design F4, G2, G4, G5, G6)
 * - framed: border dark grey
 * - framed-<color>: border in a color of the palette, e.g. for the aside (yellow, light blue, purple and the
 *   Circular Culture colors, see variables.css). Only the border is colored, text and surface stay the same.
 * - accent: border orange, for notices and the funding portal (design D2, G4)
 * - filled: surface light grey without border, a transparent border keeps it visible in forced colors mode
 */

.content-element:is(
    .frame--framed,
    .frame--framed-yellow,
    .frame--framed-light-blue,
    .frame--framed-purple,
    .frame--framed-cc-green,
    .frame--framed-cc-bright-green,
    .frame--framed-cc-fuchsia,
    .frame--framed-cc-purple,
    .frame--accent,
    .frame--filled
) {
    --content-element--header-gap: var(--space--xs);

    padding: var(--content-element--frame-pad);
    border-radius: var(--border-radius--default);
}

.content-element:is(
    .frame--framed,
    .frame--framed-yellow,
    .frame--framed-light-blue,
    .frame--framed-purple,
    .frame--framed-cc-green,
    .frame--framed-cc-bright-green,
    .frame--framed-cc-fuchsia,
    .frame--framed-cc-purple
) {
    border: var(--content-element--frame);
}

.content-element.frame--framed-yellow           { --content-element--frame-color: var(--color--yellow); }
.content-element.frame--framed-light-blue       { --content-element--frame-color: var(--color--light-blue); }
.content-element.frame--framed-purple           { --content-element--frame-color: var(--color--purple); }
.content-element.frame--framed-cc-green         { --content-element--frame-color: var(--color--cc-green); }
.content-element.frame--framed-cc-bright-green  { --content-element--frame-color: var(--color--cc-bright-green); }
.content-element.frame--framed-cc-fuchsia       { --content-element--frame-color: var(--color--cc-fuchsia); }
.content-element.frame--framed-cc-purple        { --content-element--frame-color: var(--color--cc-purple); }

.content-element.frame--accent {
    border: var(--border-width--default) solid var(--color--orange);
}

.content-element.frame--filled {
    border: var(--border-width--default) solid transparent;
}


/* HEADER */

/* Size, weight and line height of the headlines are defined in base.css */

.content-element > .content-element__header :is(p, time) {
    display: block;
    line-height: var(--line-height--sub-headline);
}

/*
 * Intro of the header in lead size (see Partials/Header/SubHeader), as normal text without bold and in the line height
 * of the text, as it often has several lines. Media elements keep it bold.
 */
.content-element > .content-element__header .content-element__subheader {
    margin-top: var(--space--s);
    font-weight: var(--font-weight--regular);
    line-height: var(--line-height--text-large);
}

.content-element--cb_media > .content-element__header .content-element__subheader {
    font-weight: var(--font-weight--bold);
}

/*
 * Intro without headline, e.g. the subline of a page below the hero (text element with subheader only, like "Projekte"):
 * bold like the lead text (.text--lead)
 */
.content-element > .content-element__header:not(:has(:is(h1, h2, h3, h4, h5, h6))) .content-element__subheader {
    font-weight: var(--font-weight--bold);
}

.content-element .ce-headline-center { text-align: center; }
.content-element .ce-headline-right  { text-align: right; }


/* FOCUS */

.content-element :is(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: var(--content-element--focus);
    outline-offset: 2px;
}


/* MEDIA: defaults without specificity, so the components can size their images (e.g. height: 100%, object-fit) */

:where(.content-element) :where(img, video, iframe, svg) {
    max-width: 100%;
}

:where(.content-element) img {
    height: auto;
}
