/* The CookieYes banner and preference centre, dressed in the boutique's tokens. CookieYes's own
   Custom CSS needs a paid plan, so the overrides live here. Its stylesheet is injected after this
   one and wins ties, so every selector starts with body to outrank the rule it overrides; the
   colours it sets as inline styles (from its dashboard) need !important.

   Accept and Reject look the same on purpose: refusing must be as easy as accepting (Law 25). */

/* The notice. */
body .cky-consent-container {
    font-family: var(--font-functional);
    animation: cky-reveal var(--reveal-duration) var(--ease) both;

    & .cky-consent-bar {
        background-color: var(--bg) !important;
        border-color: var(--hairline) !important;
        border-radius: 0;
        box-shadow: 0 18px 50px rgb(44 37 34 / .14);
    }

    & .cky-notice .cky-title {
        margin-bottom: var(--space-1);
        font-family: var(--font-editorial);
        font-weight: 300;
        font-size: 1.6rem;
        line-height: 1.15;
        letter-spacing: .02em;
        color: var(--ink) !important;
    }

    & .cky-notice-des,
    & .cky-notice-des * {
        font-weight: 300;
        font-size: .875rem;
        line-height: 1.7;
        color: var(--ink) !important;
    }

    /* CookieYes caps the text's height on phones with a scrollbar that always shows. */
    & .cky-notice-des {
        overflow-y: auto;
    }

    & .cky-notice-des a.cky-policy,
    & .cky-notice-des button.cky-policy {
        border: 0;
        text-decoration-color: var(--hairline);
        text-underline-offset: .3em;
    }

    /* Reject and Accept side by side and the same width at every size and in either layout
       (CookieYes stacks them on phones, Accept first), Customise below as a quiet link. Two equal
       grid columns; in the full-width banner the group sits in a flex row beside the text and
       mustn't shrink, or each column narrows to its own label. */
    & .cky-notice-btn-wrapper {
        display: grid;
        grid-template-columns: 1fr 1fr;
        flex-shrink: 0;
        gap: var(--space-1);
        margin-top: var(--space-3);

        /* The gap spaces them; CookieYes's phone rules give each button a different top margin,
           which sets Reject and Accept out of line. */
        & .cky-btn {
            width: auto;
            margin: 0;
        }

        & .cky-btn-reject { order: 1; }
        & .cky-btn-accept { order: 2; }

        & .cky-btn-customize {
            order: 3;
            grid-column: 1 / -1;
            padding: var(--space-1) 0 0;
            border-color: transparent !important;
            text-decoration: underline;
            text-decoration-color: var(--hairline);
            text-underline-offset: .3em;

            &:hover,
            &:focus-visible {
                background-color: transparent !important;
                color: var(--ink) !important;
                text-decoration-color: currentColor;
            }
        }
    }
}

/* Buttons, in the notice and in the preference centre: the site's uppercase label style. */
body .cky-consent-container .cky-btn,
body .cky-modal .cky-btn {
    padding: .85rem 1rem;
    border: 1px solid var(--ink) !important;
    border-radius: 0;
    background-color: transparent !important;
    color: var(--ink) !important;
    font-family: var(--font-functional);
    font-weight: 400;
    font-size: .68rem;
    line-height: 1.4;
    letter-spacing: .22em;
    text-transform: uppercase;
    transition: background-color .3s ease, color .3s ease;

    &:hover {
        filter: none;
        background-color: var(--bg-deep) !important;
        color: var(--ink-on-deep) !important;
    }
}

body .cky-consent-container .cky-btn:focus-visible,
body .cky-modal .cky-btn:focus-visible,
body .cky-modal .cky-accordion-btn:focus-visible,
body .cky-modal .cky-show-desc-btn:focus-visible,
body .cky-modal .cky-btn-close:focus-visible,
body .cky-modal .cky-switch input:focus-visible {
    outline: 2px solid var(--ink-soft);
    outline-offset: 3px;
}

/* The preference centre: a modal that fades in (the site's motion rules: no slide-ins). Centred
   with inset and auto margins rather than CookieYes's translate(-50%, -50%), which lands on half
   pixels for odd sizes and blurs every 1px line. */
body .cky-modal {
    inset: 0;
    width: fit-content;
    height: fit-content;
    margin: auto;
    border-radius: 0;
    background: var(--bg);
    box-shadow: 0 30px 80px rgb(44 37 34 / .25);
    opacity: 0;
    transform: none;
    transition: opacity .6s var(--ease), visibility .6s;

    &.cky-modal-open {
        top: 0;
        left: 0;
        opacity: 1;
        transform: none;
        transition: opacity .6s var(--ease), visibility .6s;
    }

    & .cky-preference-center {
        border-radius: 0;
        background-color: var(--bg) !important;
        border-color: var(--hairline) !important;
        color: var(--ink) !important;
        font-family: var(--font-functional);
        font-weight: 300;
    }

    & .cky-preference-header .cky-preference-title {
        font-family: var(--font-editorial);
        font-weight: 300;
        font-size: 1.6rem;
        line-height: 1.15;
        letter-spacing: .02em;
        color: var(--ink) !important;
    }

    & .cky-preference-content-wrapper,
    & .cky-preference-content-wrapper *,
    & .cky-accordion-header-des,
    & .cky-accordion-header-des * {
        font-weight: 300;
        font-size: .875rem;
        line-height: 1.7;
        color: var(--ink) !important;
    }

    & .cky-preference-content-wrapper .cky-show-desc-btn {
        font-weight: 400;
        text-decoration-color: var(--hairline);
        text-underline-offset: .3em;
    }

    & .cky-horizontal-separator {
        background: var(--hairline);
    }

    & .cky-accordion-header .cky-accordion-btn {
        font-weight: 400;
        font-size: .72rem;
        letter-spacing: .22em;
        text-transform: uppercase;
        color: var(--ink) !important;
    }

    & .cky-accordion-header .cky-always-active {
        font-weight: 400;
        font-size: .68rem;
        letter-spacing: .18em;
        text-transform: uppercase;
        color: var(--accent) !important;
    }

    & .cky-audit-table {
        border-radius: 0;
        background-color: color-mix(in srgb, var(--hairline) 22%, var(--bg)) !important;
        border-color: var(--hairline) !important;
        color: var(--ink) !important;
    }

    & .cky-switch input[type="checkbox"] {
        background-color: var(--hairline) !important;

        &:checked {
            background-color: var(--accent) !important;
        }
    }

    & .cky-footer-shadow {
        background: linear-gradient(180deg, transparent 0%, var(--bg) 100%) !important;
    }

    & .cky-prefrence-btn-wrapper {
        flex-direction: row;
        flex-wrap: wrap;

        & .cky-btn {
            flex: 1 1 0;
            width: auto;
        }

        & .cky-btn-reject { order: 1; }
        & .cky-btn-preferences { order: 2; }
        & .cky-btn-accept { order: 3; }
    }
}

/* On phones: Reject and Accept side by side, Save my preferences below at full width. */
@media (max-width: 576px) {
    body .cky-modal .cky-prefrence-btn-wrapper {
        & .cky-btn-accept { order: 2; }

        & .cky-btn-preferences {
            order: 3;
            flex-basis: 100%;
        }
    }
}

body .cky-overlay {
    background: var(--ink);
}

/* The button that reopens the choices once they're made. */
body .cky-btn-revisit-wrapper {
    width: 40px;
    height: 40px;
    background-color: var(--bg-deep) !important;
}

@keyframes cky-reveal {
    from {
        opacity: 0;
        filter: blur(2px);
    }
}

@media (prefers-reduced-motion: reduce) {
    body .cky-consent-container {
        animation: none;
    }

    body .cky-modal,
    body .cky-modal.cky-modal-open {
        transition: none;
    }
}
