/*
 * Block styles of the theme (registered in inc/blocks.php): buttons
 * "Rot"/"Gruen" and the gallery "Briefdesigns". Loaded on every page and in
 * the block editor.
 *
 * Every rule starts with :is(#content, body): the theme styles content
 * links, lists and images with "#content a/li/img" (an id), which plain class
 * selectors cannot beat; :is() takes the specificity of its strongest
 * argument, so these rules win inside #content and still work elsewhere
 * (landing page, editor iframe).
 */

/* ===================================================================== *
 * Button styles "Rot" / "Gruen" (is-style-vega-red / is-style-vega-green)
 * Same look as the [vega_button] shortcode of the vega-configurator plugin.
 * ===================================================================== */

:is(#content, body) .wp-block-button:is(.is-style-vega-red, .is-style-vega-green) > .wp-block-button__link {
    --vch-btn: #a51715;
    --vch-btn-dark: #8a2321;

    display: inline-block;
    padding: 12px 24px;

    color: #ffffff;
    background: var(--vch-btn);
    border: 0;
    border-radius: 12px;
    box-shadow: none;

    font-family: georgia, 'times new roman', serif;
    font-size: 17px;
    font-style: normal;
    font-weight: bold;
    letter-spacing: 0.02em;
    line-height: 1.3;
    text-align: center;
    text-decoration: none;

    transition: background-color 150ms ease, transform 150ms ease;
}

:is(#content, body) .wp-block-button.is-style-vega-green > .wp-block-button__link {
    --vch-btn: #2f7a4f;
    --vch-btn-dark: #245f3e;
}

:is(#content, body) .wp-block-button:is(.is-style-vega-red, .is-style-vega-green) > .wp-block-button__link:is(:hover, :focus-visible) {
    color: #ffffff;
    background: var(--vch-btn-dark);
    text-decoration: none;
}

:is(#content, body) .wp-block-button:is(.is-style-vega-red, .is-style-vega-green) > .wp-block-button__link:active {
    transform: translateY(1px);
}

:is(#content, body) .wp-block-button:is(.is-style-vega-red, .is-style-vega-green) > .wp-block-button__link:focus-visible {
    outline: 3px solid var(--vch-btn-dark);
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    :is(#content, body) .wp-block-button__link {
        transition: none;
    }
}

/* ===================================================================== *
 * Gallery style "Briefdesigns" (is-style-vega-designs on core/gallery)
 *
 * The core gallery is a flex row with captions laid over the pictures and
 * widths set with :not(#individual-image) - the id selectors below beat it.
 * ===================================================================== */

:is(#content, body) .wp-block-gallery.is-style-vega-designs.has-nested-images {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 22px 16px;
    margin: 24px 0 30px;
}

@media (min-width: 600px) {
    :is(#content, body) .wp-block-gallery.is-style-vega-designs.has-nested-images {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

:is(#content, body) .wp-block-gallery.is-style-vega-designs.has-nested-images figure.wp-block-image:not(#individual-image) {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    width: auto;
    margin: 0;
}

:is(#content, body) .wp-block-gallery.is-style-vega-designs.has-nested-images figure.wp-block-image:not(#individual-image) :is(a, img) {
    display: block;
    flex: none;
    width: 100%;
    height: auto;
    margin: 0;
    padding: 0;
    border: 0;
}

:is(#content, body) .wp-block-gallery.is-style-vega-designs.has-nested-images figure.wp-block-image:not(#individual-image) img {
    aspect-ratio: 212 / 300;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(61, 54, 50, 0.08), 0 8px 20px rgba(61, 54, 50, 0.14);
    transition: transform 200ms ease, box-shadow 200ms ease;
}

@media (hover: hover) {
    :is(#content, body) .wp-block-gallery.is-style-vega-designs.has-nested-images figure.wp-block-image:not(#individual-image) a:hover img {
        transform: none;
        box-shadow: 0 2px 4px rgba(61, 54, 50, 0.1), 0 14px 28px rgba(61, 54, 50, 0.2);
    }
}

:is(#content, body) .wp-block-gallery.is-style-vega-designs.has-nested-images figure.wp-block-image:not(#individual-image) figcaption {
    position: static;
    flex: none;
    max-height: none;
    margin: 0;
    padding: 10px 0 0;
    overflow: visible;

    color: #3d3632;
    background: none;

    font-family: georgia, 'times new roman', serif;
    font-size: 14px;
    font-weight: bold;
    line-height: 1.35;
    text-align: center;
    text-shadow: none;
}

/* The core caption's backdrop-filter / will-change and the blurred
 * gradient it lays over the picture (figure::before) are meant for captions
 * on the picture - here the caption sits below it. */
:is(#content, body) .wp-block-gallery.is-style-vega-designs.has-nested-images figure.wp-block-image:not(#individual-image) figcaption {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    will-change: auto;
}

:is(#content, body) .wp-block-gallery.is-style-vega-designs.has-nested-images figure.wp-block-image:not(#individual-image)::before {
    display: none;
}

/* Links in the caption (name, then one link per line) become small buttons:
 * outlined red = exclusive letter, outlined green = configurator - chosen
 * by the link target, so nothing has to be marked by hand. Outlined, so
 * they stay quieter than the pictures; 36px high with 8px between them, so
 * they are easy to hit on a phone. */
:is(#content, body) .wp-block-gallery.is-style-vega-designs.has-nested-images figure.wp-block-image:not(#individual-image) figcaption br {
    display: none;
}

:is(#content, body) .wp-block-gallery.is-style-vega-designs.has-nested-images figure.wp-block-image:not(#individual-image) figcaption {
    font-size: 13px;
    font-weight: normal;
}

:is(#content, body) .wp-block-gallery.is-style-vega-designs.has-nested-images figure.wp-block-image:not(#individual-image) figcaption a,
:is(#content, body) .wp-block-gallery.is-style-vega-designs.has-nested-images figure.wp-block-image:not(#individual-image) figcaption a:visited {
    --vch-btn: #a51715;
    --vch-btn-tint: #f8ecea;

    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-height: 36px;
    margin: 8px 0 0;
    padding: 6px 4px;

    color: var(--vch-btn);
    background: #ffffff;
    border: 1.5px solid var(--vch-btn);
    border-radius: 9px;
    text-decoration: none;

    font-family: verdana, arial, helvetica, sans-serif;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: -0.01em;
    line-height: 1.25;
    text-align: center;
    text-wrap: balance;

    transition: background-color 150ms ease, color 150ms ease;
}

:is(#content, body) .wp-block-gallery.is-style-vega-designs.has-nested-images figure.wp-block-image:not(#individual-image) figcaption a:first-of-type {
    margin-top: 10px;
}

:is(#content, body) .wp-block-gallery.is-style-vega-designs.has-nested-images figure.wp-block-image:not(#individual-image) figcaption a[href*="weihnachtsbrief-bestellen"] {
    --vch-btn: #2f7a4f;
    --vch-btn-tint: #eaf3ed;
}

:is(#content, body) .wp-block-gallery.is-style-vega-designs.has-nested-images figure.wp-block-image:not(#individual-image) figcaption a:is(:hover, :focus-visible) {
    color: var(--vch-btn);
    background: var(--vch-btn-tint);
    text-decoration: none;
}

:is(#content, body) .wp-block-gallery.is-style-vega-designs.has-nested-images figure.wp-block-image:not(#individual-image) figcaption a:active {
    background: var(--vch-btn-tint);
}

:is(#content, body) .wp-block-gallery.is-style-vega-designs.has-nested-images figure.wp-block-image:not(#individual-image) figcaption a:focus-visible {
    outline: 3px solid #3d3632;
    outline-offset: 2px;
}

/* Very small phones (tiles about 110px wide): slightly smaller text. */
@media (max-width: 360px) {
    :is(#content, body) .wp-block-gallery.is-style-vega-designs.has-nested-images figure.wp-block-image:not(#individual-image) figcaption a {
        padding: 6px 4px;
        font-size: 11px;
    }
}

@media (prefers-reduced-motion: reduce) {
    :is(#content, body) .wp-block-gallery.is-style-vega-designs img {
        transition: none;
    }
}
