/*
 * HubSpot cookie banner and settings panel, restyled. Why and how: includes/cookie-banner.php.
 * HubSpot's own stylesheet targets the same ids and sets colors from its Customize screen, hence the !important.
 */

:root {
    --kela-cb-red: var(--wp--preset--color--kela-hover-text, #dd0909);
    --kela-cb-ink: var(--wp--preset--color--kela-surface-dark, #121212);
    --kela-cb-text: var(--wp--preset--color--kela-secondary-text, #646376);
}

/* Banner: phones first, a bottom sheet */
html body #hs-eu-cookie-confirmation {
    position: fixed !important;
    top: auto !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 18px 18px 0 0 !important;
    background: #fff !important;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, .18) !important;
    transform: none !important;
    color: var(--kela-cb-ink) !important;
    font-family: Poppins, sans-serif !important;
}

html body #hs-eu-cookie-confirmation #hs-eu-cookie-confirmation-inner {
    width: auto !important;
    max-width: none !important;
    padding: 24px 20px calc(22px + env(safe-area-inset-bottom)) !important;
    background: transparent !important;
    text-align: left !important;
}

html body #hs-eu-cookie-confirmation #hs-eu-header-container {
    display: none !important;
}

html body #hs-eu-cookie-confirmation #hs-eu-policy-wording {
    margin: 0 0 18px !important;
    color: var(--kela-cb-ink) !important;
}

html body #hs-eu-cookie-confirmation #hs-eu-policy-wording p {
    margin: 0 !important;
    color: var(--kela-cb-text) !important;
    font-size: 15px !important;
    line-height: 1.55 !important;
}

/* A first paragraph followed by more text is the headline ("We value your privacy") */
html body #hs-eu-cookie-confirmation #hs-eu-policy-wording p:first-child:not(:only-child) {
    margin: 0 0 8px !important;
    color: var(--kela-cb-ink) !important;
    font-size: 20px !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
}

html body #hs-eu-cookie-confirmation #hs-eu-policy-wording a {
    color: var(--kela-cb-ink) !important;
    font-weight: 600 !important;
    text-decoration: underline !important;
    text-underline-offset: 3px;
}

html body #hs-eu-cookie-confirmation #hs-eu-cookie-disclaimer {
    margin: 0 0 18px !important;
    color: var(--kela-cb-text) !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
}

html body #hs-eu-cookie-confirmation #hs-eu-cookie-disclaimer:empty {
    display: none !important;
}

html body #hs-eu-cookie-confirmation #hs-eu-cookie-confirmation-buttons-area,
html body #hs-eu-cookie-confirmation #hs-eu-confirmation-button-group {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* HubSpot's separate settings button, shown as a plain link; hidden when the text carries its own link */
html body #hs-eu-cookie-confirmation #hs-eu-cookie-settings-button {
    display: inline-block !important;
    flex: none !important;
    width: auto !important;
    min-width: 0 !important;
    height: auto !important;
    margin: 0 0 14px !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: none !important;
    color: var(--kela-cb-ink) !important;
    font-family: inherit !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    text-decoration: underline !important;
    text-underline-offset: 3px;
}

html body #hs-eu-cookie-confirmation.kela-cb-inline #hs-eu-cookie-settings-button {
    display: none !important;
}

html body #hs-eu-cookie-confirmation #hs-eu-opt-in-buttons {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
    margin: 0 !important;
}

/* HubSpot gives these flex: 1 1 0, which collapses them in a column */
html body #hs-eu-cookie-confirmation #hs-eu-confirmation-button,
html body #hs-eu-cookie-confirmation #hs-eu-decline-button {
    flex: 0 0 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 52px !important;
    margin: 0 !important;
    padding: 0 16px !important;
    border: 0 !important;
    border-radius: 12px !important;
    background: var(--kela-cb-ink) !important;
    color: #fff !important;
    font-family: inherit !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    cursor: pointer;
}

html body #hs-eu-cookie-confirmation #hs-eu-confirmation-button {
    background: var(--kela-cb-red) !important;
}

html body #hs-eu-cookie-confirmation #hs-eu-confirmation-button:hover,
html body #hs-eu-cookie-confirmation #hs-eu-decline-button:hover {
    opacity: .88;
}

html body #hs-eu-cookie-confirmation button:focus-visible,
html body #hs-eu-cookie-confirmation a:focus-visible {
    outline: 2px solid var(--kela-cb-ink) !important;
    outline-offset: 3px !important;
}

/* Banner: a full-width strip from 768px up, text left and buttons right */
@media (min-width: 768px) {
    html body #hs-eu-cookie-confirmation {
        border-radius: 0 !important;
        box-shadow: 0 -6px 28px rgba(0, 0, 0, .16) !important;
    }

    /* 1188px less the 24px padding lines the text up with the header's 1140px container */
    html body #hs-eu-cookie-confirmation #hs-eu-cookie-confirmation-inner {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto !important;
        align-items: center !important;
        column-gap: 48px !important;
        max-width: 1188px !important;
        margin: 0 auto !important;
        padding: 20px 24px !important;
    }

    html body #hs-eu-cookie-confirmation #hs-eu-policy-wording,
    html body #hs-eu-cookie-confirmation #hs-eu-cookie-disclaimer {
        grid-column: 1 !important;
        margin: 0 !important;
    }

    html body #hs-eu-cookie-confirmation #hs-eu-cookie-disclaimer {
        margin-top: 6px !important;
    }

    html body #hs-eu-cookie-confirmation #hs-eu-cookie-confirmation-buttons-area {
        grid-column: 2 !important;
        grid-row: 1 / span 2 !important;
        width: auto !important;
    }

    html body #hs-eu-cookie-confirmation #hs-eu-policy-wording p:first-child:not(:only-child) {
        margin: 0 0 4px !important;
        font-size: 18px !important;
    }

    html body #hs-eu-cookie-confirmation #hs-eu-policy-wording p {
        font-size: 14px !important;
    }

    html body #hs-eu-cookie-confirmation #hs-eu-confirmation-button-group {
        display: flex !important;
        align-items: center !important;
        gap: 20px !important;
        width: auto !important;
    }

    html body #hs-eu-cookie-confirmation #hs-eu-cookie-settings-button {
        margin: 0 !important;
        white-space: nowrap;
    }

    html body #hs-eu-cookie-confirmation #hs-eu-opt-in-buttons {
        flex-direction: row !important;
        width: auto !important;
    }

    html body #hs-eu-cookie-confirmation #hs-eu-confirmation-button,
    html body #hs-eu-cookie-confirmation #hs-eu-decline-button {
        width: 160px !important;
        height: 48px !important;
    }
}

/* While the banner is open, lift HubSpot's bottom-corner pop-up CTA and chat launcher above it.
   translate (not transform or bottom) so it stacks on whatever positioning and animation HubSpot already applies. */
html.kela-cb-open body [id^="hs-overlay-cta-"],
html.kela-cb-open body #hubspot-messages-iframe-container {
    translate: 0 calc(-1 * var(--kela-cb-h, 0px)) !important;
}

/* Settings panel, matched to the banner */
html body #hs-modal #hs-modal-content {
    border-radius: 16px !important;
    background: #fff !important;
    color: var(--kela-cb-ink) !important;
    font-family: Poppins, sans-serif !important;
}

html body #hs-modal #hs-modal-content h1,
html body #hs-modal #hs-modal-content h2,
html body #hs-modal #hs-modal-content h3,
html body #hs-modal .hs-category-label,
html body #hs-modal #hs-modal-introduction {
    color: var(--kela-cb-ink) !important;
}

html body #hs-modal #hs-modal-introduction-description,
html body #hs-modal .hs-category-description,
html body #hs-modal .hs-always-active-label {
    color: var(--kela-cb-text) !important;
}

html body #hs-modal .hs-category-row {
    border-radius: 12px !important;
    background: var(--wp--preset--color--kela-light-bg, #f6f6f6) !important;
}

html body #hs-modal .hs-toggle-switch:has(input:checked) {
    border-color: var(--kela-cb-ink) !important;
    background: var(--kela-cb-ink) !important;
}

html body #hs-modal svg {
    color: var(--kela-cb-ink) !important;
}

html body #hs-modal #hs-modal-footer button {
    border: 1.5px solid var(--kela-cb-ink) !important;
    border-radius: 12px !important;
    background: #fff !important;
    color: var(--kela-cb-ink) !important;
    font-family: inherit !important;
    font-weight: 600 !important;
}

html body #hs-modal #hs-modal-footer #hs-modal-accept-all {
    border-color: var(--kela-cb-red) !important;
    background: var(--kela-cb-red) !important;
    color: #fff !important;
}
