/*
 * CTA buttons from the WYSIWYG (quill-link-target.js).
 * Load in the frontend AND in the Pimcore admin (editor preview).
 *
 * Background and border come from the classes in the HTML
 * (sbg-primary / sborder-primary -> green inside .westerham).
 * The text colour is forced here with !important, because link colour rules
 * (".ql-snow .ql-editor a", ".wysiwyg-content a", ".westerham .wysiwyg-content a")
 * would otherwise colour the button text like a normal link.
 */

a.cta {
    --cd-cta-primary: var(--cd-color-primary, var(--color-primary, #005ca5));
    --cd-cta-green: var(--cd-color-green, var(--color-green, #0e623e));

    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;                 /* touch target size */
    margin: 0.25rem 0.5rem 0.25rem 0; /* several buttons next to each other */
    text-align: center;
    vertical-align: middle;
}

a.cta:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
}

/* Fallbacks for size/background (e.g. in the Pimcore admin, where Tailwind is not loaded).
   Specificity 0, so the Tailwind / s-classes in the HTML win. */
:where(a.cta) {
    padding: 0.75rem 1rem;
    border: 1px solid var(--cd-cta-primary);
    border-radius: 0.375rem;
    line-height: 1.25;
}

:where(a.cta--filled) {
    background: var(--cd-cta-primary);
}

:where(a.cta--outline) {
    background: #ffffff;
}

/* No underline on any CTA */
a.cta,
a.cta:hover,
a.cta:focus,
a.cta:visited,
a.cta * {
    text-decoration: none !important;
}

/* Filled: always white text */
a.cta.cta--filled,
a.cta.cta--filled:hover,
a.cta.cta--filled:focus,
a.cta.cta--filled:visited,
a.cta.cta--filled * {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff;
}

/* Outline: primary text (blue) */
a.cta.cta--outline,
a.cta.cta--outline:hover,
a.cta.cta--outline:focus,
a.cta.cta--outline:visited,
a.cta.cta--outline * {
    color: var(--cd-cta-primary) !important;
    -webkit-text-fill-color: var(--cd-cta-primary);
}

/* Outline on Westerham: green text */
.westerham a.cta.cta--outline,
.westerham a.cta.cta--outline:hover,
.westerham a.cta.cta--outline:focus,
.westerham a.cta.cta--outline:visited,
.westerham a.cta.cta--outline * {
    color: var(--cd-cta-green) !important;
    -webkit-text-fill-color: var(--cd-cta-green);
}

/* Mobile: full-width buttons like the form button (w-full lg:w-auto) */
@media (max-width: 1023px) {
    a.cta {
        display: flex;
        width: 100%;
        margin-right: 0;
    }
}
