/**
 * Atvise PageBuilder — frontend baseline styles
 *
 * Loaded on every storefront via layout (no theme required).
 *
 * Cascade strategy is INTENTIONALLY ASYMMETRIC between colors and sizes:
 *
 * - COLOR classes (.pagebuilder-button-primary/secondary/tertiary/
 *   transparent) must ALWAYS show the Figma reference colors, regardless of
 *   theme — they are the module's own visual identity, not tied to any one
 *   child-theme's brand palette. These rules stay UNLAYERED (no @layer). Any
 *   Hyvä theme (incl. plain Hyvä/default) ships its own generic
 *   page-builder.css that maps `.pagebuilder-button-primary` etc. to
 *   Tailwind's `.btn`/`.btn-primary` utilities (meant for Magento core's
 *   "Buttons" content type, but colliding with our classnames). CSS Cascade
 *   Layers give ANY layered rule strictly lower priority than unlayered
 *   rules regardless of specificity/order, so if this file were layered it
 *   would always lose to that theme rule. Staying unlayered + scoping every
 *   selector on `[data-content-type="button-icon"]` (higher specificity)
 *   makes our colors win instead.
 *
 * - SIZE classes (.btn-size-sm/md/lg/xl/2xl) intentionally use the SAME
 *   classnames that child-themes already define for their own `.btn-size-*`
 *   utilities (e.g. Atvise's own child-theme in
 *   web/tailwind/components/button.css + tailwind.browser-jit.css). A
 *   child-theme is allowed to override our default sizing, so those rules
 *   are wrapped in `@layer atvise-pagebuilder-size-default` further below —
 *   guaranteeing any unlayered theme CSS targeting the same `.btn-size-*`
 *   classnames wins, no matter the source order.
 *
 * Reference: vendor/hyva-themes/magento2-default-theme/web/tailwind/theme/page-builder.css
 *
 * Everything that does NOT collide with a Hyvä theme's own unlayered
 * page-builder.css (Headline, and the button-icon/buttons-icon layout
 * rules below) stays wrapped in `@layer atvise-pagebuilder-default` like
 * any normal module CSS, so a child-theme can still cleanly override it
 * from inside its own layered CSS if it ever needs to.
 */

:root {
    /* Headline */
    --atvise-pb-headline-gap: 4px;
    --atvise-pb-headline-line-1-size: 1.25rem;
    --atvise-pb-headline-line-1-line-height: 1.25;
    --atvise-pb-headline-line-2-size: 2.25rem;
    --atvise-pb-headline-line-2-line-height: 1.125;
    --atvise-pb-headline-font-weight: 700;
    --atvise-pb-headline-color: inherit;

    /* Button base + maten/kleuren 1-op-1 uit de Figma-referentie "Hyvä UI
     * V2.7" Button-component (node 1286:12715, Size M/Default+Hover),
     * geverifieerd via get_design_context. Dit is de THEME-AGNOSTISCHE
     * default van de module — bewust NIET gebaseerd op de merk-kleuren van
     * één specifiek child-theme (die kunnen per klant verschillen), zodat
     * dezelfde look consistent is op Luma en op elk Hyvä child-theme dat
     * deze niet zelf overschrijft. */
    --atvise-pb-btn-radius: 6px;
    --atvise-pb-btn-border-width: 1px;
    --atvise-pb-btn-font-weight: 500;
    --atvise-pb-btn-gap: 0.5rem;
    --atvise-pb-btn-padding-y: 0.625rem;
    --atvise-pb-btn-padding-x: 1.25rem;
    --atvise-pb-btn-font-size: 0.875rem;
    --atvise-pb-btn-line-height: 1.25rem;
    --atvise-pb-btn-icon-size: 0.875em;
    --atvise-pb-btn-hover-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Primary — Figma: bg blue-600, tekst wit, hover bg blue-700 */
    --atvise-pb-btn-primary-bg: #2563eb;
    --atvise-pb-btn-primary-color: #ffffff;
    --atvise-pb-btn-primary-border: transparent;
    --atvise-pb-btn-primary-hover-bg: #1d4ed8;

    /* Secondary — Figma: bg blue-100, tekst blue-800, geen border, hover bg blue-200 */
    --atvise-pb-btn-secondary-bg: #dbeafe;
    --atvise-pb-btn-secondary-color: #1e40af;
    --atvise-pb-btn-secondary-border: transparent;
    --atvise-pb-btn-secondary-hover-bg: #bfdbfe;

    /* Tertiary — Figma: bg wit, border blue-400, tekst blue-700; hover
     * verandert geen kleur, alleen de shadow wordt toegevoegd */
    --atvise-pb-btn-tertiary-bg: #ffffff;
    --atvise-pb-btn-tertiary-color: #1d4ed8;
    --atvise-pb-btn-tertiary-border: #60a5fa;

    /* Transparent — Figma: transparant/blue-700, hover krijgt een blue-100
     * border en tekst wordt blue-800 (geen achtergrond-wissel) */
    --atvise-pb-btn-transparent-bg: transparent;
    --atvise-pb-btn-transparent-color: #1d4ed8;
    --atvise-pb-btn-transparent-border: transparent;
    --atvise-pb-btn-transparent-hover-border: #dbeafe;
    --atvise-pb-btn-transparent-hover-color: #1e40af;

    /* Outline en Link zijn geen Figma-varianten van dit component; afgeleid
     * in dezelfde kleurtaal zodat ze niet uit de toon vallen. */
    --atvise-pb-btn-outline-bg: #ffffff;
    --atvise-pb-btn-outline-color: #1f2937;
    --atvise-pb-btn-outline-border: #d1d5db;
    --atvise-pb-btn-outline-hover-bg: #f9fafb;

    --atvise-pb-btn-link-bg: transparent;
    --atvise-pb-btn-link-color: #2563eb;
    --atvise-pb-btn-link-border: #2563eb;
    --atvise-pb-btn-link-hover-color: #1d4ed8;
}

@layer atvise-pagebuilder-default {
    /* ---------------------------------------------------------------------
     * Headline
     * --------------------------------------------------------------------- */
    [data-content-type="headline"] .headline {
        /* stretch (default) laat de regels de volledige breedte van .headline
         * vullen, zodat de geërfde text-align (center/right) op de tekst
         * zelf werkt. Met align-items: flex-start krimpen de regels naar
         * content-breedte en heeft text-align: center dan geen zichtbaar
         * effect. */
        align-items: stretch;
        color: var(--atvise-pb-headline-color);
        display: flex;
        flex-direction: column;
        gap: var(--atvise-pb-headline-gap);
    }

    [data-content-type="headline"] .headline > * {
        font-weight: var(--atvise-pb-headline-font-weight);
        margin: 0;
        overflow-wrap: break-word;
        text-wrap: balance;
    }

    /* Visuele baseline-rollen via DOM-volgorde, los van de semantische
     * tag (h1–h6). Custom look gaat via CSS Classes (Line 1/2). */
    [data-content-type="headline"] .headline > :first-child {
        font-size: var(--atvise-pb-headline-line-1-size);
        line-height: var(--atvise-pb-headline-line-1-line-height);
    }

    [data-content-type="headline"] .headline > :last-child {
        font-size: var(--atvise-pb-headline-line-2-size);
        line-height: var(--atvise-pb-headline-line-2-line-height);
    }

    [data-content-type="headline"] .headline.headline--reverse > :last-child {
        order: 1;
    }

    [data-content-type="headline"] .headline.headline--reverse > :first-child {
        order: 2;
    }

    /* -----------------------------------------------------------------------
     * Button with Icon — layout
     * ----------------------------------------------------------------------- */
    [data-content-type="button-icon"] {
        max-width: 100%;
    }

    [data-content-type="button-icon"] [data-element="link"],
    [data-content-type="button-icon"] [data-element="empty_link"] {
        max-width: 100%;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    [data-content-type="button-icon"] [data-element="empty_link"] {
        cursor: default;
    }

    /* -----------------------------------------------------------------------
     * Buttons with Icon — container for multiple buttons on one line/stacked
     * Only the direct [data-content-type="button-icon"] children of a
     * [data-content-type="buttons-icon"] container get the inline/stacked
     * layout below — a standalone button-icon (existing content created
     * before this container existed) keeps its normal block-level layout.
     * ----------------------------------------------------------------------- */
    [data-content-type="buttons-icon"] {
        max-width: 100%;
    }

    [data-content-type="buttons-icon"] > [data-content-type="button-icon"] {
        display: inline-block;
        margin: 0 0.625rem 0.625rem 0;
        max-width: 100%;
        vertical-align: top;
    }

    [data-content-type="buttons-icon"][data-appearance="stacked"] > [data-content-type="button-icon"] {
        display: block;
        margin-right: 0;
        width: 100%;
    }
}

/* -------------------------------------------------------------------------
 * Page Builder button classes — baseline (no Hyvä .btn utilities required)
 *
 * Alle selectors zijn gescoped op [data-content-type="button-icon"]. De
 * classnamen (pagebuilder-button-primary, ...) komen 1-op-1 overeen met
 * Magento core's "Buttons"-content type, en Hyvä-thema's (ook het
 * onaangepaste Hyvä/default) leveren daarvoor hun eigen page-builder.css met
 * dezelfde classnamen (`.pagebuilder-button-primary` → `@apply btn
 * btn-primary`) maar zonder [data-content-type]-scoping. Die Hyvä-regel
 * staat bovendien UNLAYERED (buiten @layer), dus alleen hogere specificiteit
 * is niet genoeg als onze eigen CSS in een @layer zou staan — vandaar dat
 * dit hele bestand ook bewust unlayered is (zie comment boven in dit
 * bestand). De extra attribute-selector hier geeft onze regels daarnaast
 * ook nog voorrang op specificiteit, voor extra robuustheid.
 * ------------------------------------------------------------------------- */
[data-content-type="button-icon"] :is(a, button, div)[class*="pagebuilder-button-"] {
    align-items: center;
    border-radius: var(--atvise-pb-btn-radius);
    border-style: solid;
    border-width: var(--atvise-pb-btn-border-width);
    display: inline-flex;
    font-weight: var(--atvise-pb-btn-font-weight);
    gap: var(--atvise-pb-btn-gap);
    justify-content: center;
    line-height: var(--atvise-pb-btn-line-height);
    max-width: 100%;
    padding: var(--atvise-pb-btn-padding-y) var(--atvise-pb-btn-padding-x);
    text-decoration: none;
    transition: background-color 200ms ease-in-out, box-shadow 200ms ease-in-out, border-color 200ms ease-in-out, color 200ms ease-in-out;
    vertical-align: middle;
}

/* Maten 1-op-1 uit de Figma-referentie "Hyvä UI V2.7" Button-component
 * (node 1286:12715). "md" is hier de default (basis-CSS-vars hierboven),
 * dus geen apart .btn-size-md-blok nodig.
 *
 * Classnamen zijn bewust dezelfde als de `.btn-size-*`-utilities die
 * child-themes al zelf definiëren (zie bestandskop-comment) — en daarom in
 * een eigen @layer, zodat een child-theme's eigen (onlayered) `.btn-size-*`
 * deze default altijd mag overschrijven. */
@layer atvise-pagebuilder-size-default {
    [data-content-type="button-icon"] :is(a, button, div).btn-size-sm {
        --atvise-pb-btn-font-size: 0.875rem;
        --atvise-pb-btn-line-height: 1.25rem;
        --atvise-pb-btn-padding-y: 0.5rem;
        --atvise-pb-btn-padding-x: 1rem;
        font-size: var(--atvise-pb-btn-font-size);
    }

    [data-content-type="button-icon"] :is(a, button, div).btn-size-md {
        font-size: var(--atvise-pb-btn-font-size);
    }

    [data-content-type="button-icon"] :is(a, button, div).btn-size-lg {
        --atvise-pb-btn-font-size: 1rem;
        --atvise-pb-btn-line-height: 1.5rem;
        --atvise-pb-btn-padding-y: 0.625rem;
        --atvise-pb-btn-padding-x: 1.25rem;
        font-size: var(--atvise-pb-btn-font-size);
    }

    [data-content-type="button-icon"] :is(a, button, div).btn-size-xl {
        --atvise-pb-btn-font-size: 1rem;
        --atvise-pb-btn-line-height: 1.5rem;
        --atvise-pb-btn-padding-y: 0.75rem;
        --atvise-pb-btn-padding-x: 1.5rem;
        font-size: var(--atvise-pb-btn-font-size);
    }

    [data-content-type="button-icon"] :is(a, button, div).btn-size-2xl {
        --atvise-pb-btn-font-size: 1.125rem;
        --atvise-pb-btn-line-height: 1.75rem;
        --atvise-pb-btn-padding-y: 1rem;
        --atvise-pb-btn-padding-x: 2rem;
        font-size: var(--atvise-pb-btn-font-size);
    }
}

[data-content-type="button-icon"] :is(a, button, div).pagebuilder-button-primary {
    background-color: var(--atvise-pb-btn-primary-bg);
    border-color: var(--atvise-pb-btn-primary-border);
    color: var(--atvise-pb-btn-primary-color);
}

[data-content-type="button-icon"] :is(a, button, div).pagebuilder-button-primary:hover {
    background-color: var(--atvise-pb-btn-primary-hover-bg);
    box-shadow: var(--atvise-pb-btn-hover-shadow);
    text-decoration: none;
}

[data-content-type="button-icon"] :is(a, button, div).pagebuilder-button-secondary {
    background-color: var(--atvise-pb-btn-secondary-bg);
    border-color: var(--atvise-pb-btn-secondary-border);
    color: var(--atvise-pb-btn-secondary-color);
}

[data-content-type="button-icon"] :is(a, button, div).pagebuilder-button-secondary:hover {
    background-color: var(--atvise-pb-btn-secondary-hover-bg);
    box-shadow: var(--atvise-pb-btn-hover-shadow);
    text-decoration: none;
}

[data-content-type="button-icon"] :is(a, button, div).pagebuilder-button-tertiary {
    background-color: var(--atvise-pb-btn-tertiary-bg);
    border-color: var(--atvise-pb-btn-tertiary-border);
    color: var(--atvise-pb-btn-tertiary-color);
}

[data-content-type="button-icon"] :is(a, button, div).pagebuilder-button-tertiary:hover {
    box-shadow: var(--atvise-pb-btn-hover-shadow);
    text-decoration: none;
}

[data-content-type="button-icon"] :is(a, button, div).pagebuilder-button-transparent {
    background-color: var(--atvise-pb-btn-transparent-bg);
    border-color: var(--atvise-pb-btn-transparent-border);
    color: var(--atvise-pb-btn-transparent-color);
}

[data-content-type="button-icon"] :is(a, button, div).pagebuilder-button-transparent:hover {
    border-color: var(--atvise-pb-btn-transparent-hover-border);
    color: var(--atvise-pb-btn-transparent-hover-color);
    text-decoration: none;
}

[data-content-type="button-icon"] :is(a, button, div).pagebuilder-button-outline {
    background-color: var(--atvise-pb-btn-outline-bg);
    border-color: var(--atvise-pb-btn-outline-border);
    color: var(--atvise-pb-btn-outline-color);
}

[data-content-type="button-icon"] :is(a, button, div).pagebuilder-button-outline:hover {
    background-color: var(--atvise-pb-btn-outline-hover-bg);
    text-decoration: none;
}

[data-content-type="button-icon"] :is(a, button, div).pagebuilder-button-link {
    background-color: var(--atvise-pb-btn-link-bg);
    border-color: transparent;
    border-radius: 0;
    border-width: 0;
    border-bottom: var(--atvise-pb-btn-border-width) solid var(--atvise-pb-btn-link-border);
    color: var(--atvise-pb-btn-link-color);
    padding-inline: 0;
    padding-block: 0;
}

[data-content-type="button-icon"] :is(a, button, div).pagebuilder-button-link:hover {
    color: var(--atvise-pb-btn-link-hover-color);
    text-decoration: none;
}

[data-content-type="button-icon"] :is(a, button, div)[class*="pagebuilder-button-"] > i[class*="fa-"] {
    color: currentColor;
    flex-shrink: 0;
    font-size: var(--atvise-pb-btn-icon-size);
    line-height: 1;
}

[data-content-type="button-icon"] :is(a, button, div)[class*="pagebuilder-button-"] > i[class*="fa-"].atvise-pb-icon--unknown {
    display: inline-block;
    flex-shrink: 0;
    font-size: 0;
    height: var(--atvise-pb-btn-icon-size);
    line-height: 0;
    overflow: hidden;
    position: relative;
    vertical-align: middle;
    width: var(--atvise-pb-btn-icon-size);
}

[data-content-type="button-icon"] :is(a, button, div)[class*="pagebuilder-button-"] > i[class*="fa-"].atvise-pb-icon--unknown::before {
    content: none !important;
    display: none !important;
}

[data-content-type="button-icon"] :is(a, button, div)[class*="pagebuilder-button-"] > i[class*="fa-"].atvise-pb-icon--unknown::after {
    background-color: currentColor;
    content: '';
    display: block;
    height: 100%;
    -webkit-mask: url('../images/icon-fallback-unknown.svg') no-repeat center / contain;
    mask: url('../images/icon-fallback-unknown.svg') no-repeat center / contain;
    width: 100%;
}
