/*
 * Eenvoud Consent: the layer over the core's consent.css for themes outside
 * eenvoud-core.
 *
 * 1. Values for every --ee-consent-* property the core's stylesheet would
 *    otherwise take from the core theme's presets. Background and text come
 *    as a pair from the inline style the plugin prints after this file
 *    (Palette::css()); muted text and borders are mixed from that pair, so
 *    they can never lose contrast against it. Everything sits in
 *    :where(:root), the lowest specificity there is: a theme that sets a
 *    property on :root, on .ee-consent or anywhere closer wins.
 *    Sizes are in px, not rem: older themes set the root font size to 10px
 *    (62.5%), which shrinks every rem to two thirds.
 * 2. The look: radius, shadow and spacing per layout (bar, card, modal).
 * 3. A reset against themes that style bare elements (h2, label, button,
 *    checkbox) globally. Only properties the core's stylesheet leaves alone.
 * 4. The floating reopen button.
 */

:where(:root) {
    --ee-consent-muted: color-mix(in srgb, var(--ee-consent-fg) 78%, var(--ee-consent-bg));
    --ee-consent-border: color-mix(in srgb, var(--ee-consent-fg) 18%, var(--ee-consent-bg));
    --ee-consent-backdrop: rgb(0 0 0 / 55%);
    --ee-consent-size: 15px;
    --ee-consent-size-title: 19px;
    --ee-consent-space: 24px;
    --ee-consent-gap: 12px;
    --ee-consent-max-width: 1120px;
    --ee-consent-z: 100000;
    --ee-consent-radius: 12px;
    --ee-consent-button-radius: 6px;
    --ee-consent-shadow: 0 18px 50px rgb(0 0 0 / 28%), 0 2px 8px rgb(0 0 0 / 12%);
}

@media (max-width: 600px) {
    :where(:root) {
        --ee-consent-space: 18px;
        --ee-consent-size-title: 17px;
    }
}

/* --- 2. The look per layout ------------------------------------------------ */

.ee-consent {
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.ee-consent .ee-consent-title {
    font-size: var(--ee-consent-size-title);
}

/* Bar: full width at the foot; on a wide screen the text left and the
   buttons right, until the visitor opens the purposes. */
.ee-consent.ee-consent-bar {
    border-width: 1px 0 0;
    box-shadow: 0 -10px 40px rgb(0 0 0 / 18%);
}

@media (min-width: 900px) {
    .ee-consent.ee-consent-bar:not(.is-expanded) .ee-consent-panel {
        flex-direction: row;
        align-items: center;
        gap: calc(var(--ee-consent-space) * 1.5);
    }

    .ee-consent.ee-consent-bar:not(.is-expanded) .ee-consent-actions {
        flex: 0 0 auto;
        flex-wrap: nowrap;
    }
}

/* Card: a panel in a bottom corner, non-modal; the page stays usable. */
.ee-consent.ee-consent-card {
    position: fixed;
    z-index: var(--ee-consent-z);
    top: auto;
    bottom: 16px;
    left: 16px;
    right: auto;
    width: min(calc(100vw - 32px), 440px);
    max-width: none;
    max-height: calc(100dvh - 32px);
    margin: 0;
    border-radius: var(--ee-consent-radius);
    box-shadow: var(--ee-consent-shadow);
    overflow: hidden;
}

.ee-consent.ee-consent-card.ee-consent-right {
    left: auto;
    right: 16px;
}

.ee-consent.ee-consent-card.is-expanded {
    width: min(calc(100vw - 32px), 540px);
}

/* Modal: centred in front of the inert page. The core's sheet sets margin 0,
   which also takes away the automatic margin that centres a modal dialog,
   and sizes it in rem. */
.ee-consent.ee-consent-modal {
    width: min(calc(100% - 32px), 600px);
    margin: auto;
    border-radius: var(--ee-consent-radius);
    box-shadow: var(--ee-consent-shadow);
    overflow: hidden;
}

.ee-consent.ee-consent-modal::backdrop {
    background: var(--ee-consent-backdrop);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

/* Buttons: accept and refuse filled and equal, "Choose" outlined. In the
   card and the modal the two choices share a row, "Choose" spans below. */
.ee-consent .ee-consent-actions {
    gap: 10px;
}

.ee-consent-card .ee-consent-actions > .ee-consent-button,
.ee-consent-modal .ee-consent-actions > .ee-consent-button {
    flex: 1 1 calc(50% - 10px);
}

.ee-consent-card .ee-consent-actions > .ee-consent-toggle,
.ee-consent-card .ee-consent-actions > .ee-consent-save,
.ee-consent-modal .ee-consent-actions > .ee-consent-toggle,
.ee-consent-modal .ee-consent-actions > .ee-consent-save {
    flex-basis: 100%;
}

/* Layer two: each purpose a soft tile. */
.ee-consent .ee-consent-category {
    padding: 12px 14px;
    border-radius: calc(var(--ee-consent-radius) * 0.6);
    background: color-mix(in srgb, var(--ee-consent-fg) 4%, var(--ee-consent-bg));
}

.ee-consent .ee-consent-category-head {
    gap: 10px;
}

.ee-consent .ee-consent-always {
    padding: 2px 8px;
    border: 1px solid var(--ee-consent-border);
    border-radius: 999px;
    font-size: 0.85em;
}

.ee-consent .ee-consent-services {
    display: block;
    margin-top: 2px;
    font-size: 0.9em;
}

/* Links under the intro, side by side. */
.ee-consent .ee-consent-more {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 18px;
    font-size: 0.93em;
}

/* --- 3. Reset against global theme styles -------------------------------- */

.ee-consent .ee-consent-title,
.ee-consent .ee-consent-settings-title {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font-family: inherit;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: normal;
    text-transform: none;
    text-shadow: none;
}

.ee-consent .ee-consent-title::before,
.ee-consent .ee-consent-title::after,
.ee-consent .ee-consent-settings-title::before,
.ee-consent .ee-consent-settings-title::after,
.ee-consent .ee-consent-category::before,
.ee-consent .ee-consent-category::after {
    content: none;
    display: none;
}

.ee-consent .ee-consent-intro,
.ee-consent .ee-consent-more,
.ee-consent .ee-consent-category-description {
    line-height: 1.5;
    letter-spacing: normal;
    color: inherit;
}

.ee-consent .ee-consent-intro {
    font-size: inherit;
}

.ee-consent .ee-consent-category-description {
    font-size: 0.93em;
    color: var(--ee-consent-muted);
}

.ee-consent .ee-consent-category {
    margin: 0;
    list-style: none;
}

.ee-consent .ee-consent-category-title {
    display: inline;
    margin: 0;
    padding: 0;
    color: inherit;
    font: inherit;
    font-weight: 600;
    letter-spacing: normal;
    text-transform: none;
    cursor: pointer;
}

/* Themes often hide checkboxes to draw their own: this one must stay real. */
.ee-consent .ee-consent-switch {
    position: static;
    display: inline-block;
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    clip: auto;
    clip-path: none;
    opacity: 1;
    -webkit-appearance: auto;
    appearance: auto;
    visibility: visible;
    cursor: pointer;
}

.ee-consent .ee-consent-button {
    min-height: 44px;
    margin: 0;
    padding: 11px 20px;
    border-radius: var(--ee-consent-button-radius);
    box-shadow: none;
    font-size: inherit;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: normal;
    text-align: center;
    text-decoration: none;
    text-transform: none;
    white-space: nowrap;
    width: auto;
    transition: filter 0.15s ease, background-color 0.15s ease;
}

.ee-consent .ee-consent-button:hover {
    filter: brightness(1.15);
}

.ee-consent .ee-consent-toggle {
    color: inherit;
    border-color: var(--ee-consent-border);
}

.ee-consent .ee-consent-toggle:hover {
    filter: none;
    background: color-mix(in srgb, var(--ee-consent-fg) 7%, var(--ee-consent-bg));
}

.ee-consent .ee-consent-more a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Narrow screens: two buttons a row, so accept and refuse sit side by side
   at the same size and the banner stays short. */
@media (max-width: 600px) {
    .ee-consent .ee-consent-actions > .ee-consent-button {
        flex: 1 1 calc(50% - 10px);
        padding-inline: 10px;
        white-space: normal;
    }

    .ee-consent .ee-consent-actions > .ee-consent-toggle,
    .ee-consent .ee-consent-actions > .ee-consent-save {
        flex-basis: 100%;
    }
}

/* --- 4. Floating reopen button -------------------------------------------- */

.ee-consent-reopen {
    position: fixed;
    bottom: 16px;
    z-index: calc(var(--ee-consent-z) - 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--ee-consent-border);
    border-radius: 50%;
    background: var(--ee-consent-bg);
    color: var(--ee-consent-fg);
    box-shadow: 0 6px 20px rgb(0 0 0 / 25%);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.ee-consent-reopen:hover {
    transform: scale(1.06);
}

.ee-consent-reopen:focus-visible {
    outline: 2px solid var(--ee-consent-fg);
    outline-offset: 3px;
}

.ee-consent-reopen svg {
    width: 24px;
    height: 24px;
}

.ee-consent-reopen-left {
    left: 16px;
}

.ee-consent-reopen-right {
    right: 16px;
}

.has-ee-consent-open .ee-consent-reopen {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .ee-consent .ee-consent-button,
    .ee-consent-reopen {
        transition: none;
    }
}

@media print {
    .ee-consent,
    .ee-consent-reopen {
        display: none !important;
    }
}
