/*
 * Cookie consent banner + preferences.
 *
 * Colours follow the storefront theme (#337ed7 primary, 4px radii, Roboto).
 * Sizes use rem to match the rest of the Keyclamp modules.
 *
 * Everything starts hidden: the markup ships on every cached page and JS
 * reveals it only when there is no stored decision.
 */

.kc-consent {
    --kc-consent-accent: #337ed7;
    --kc-consent-accent-dark: #2a6bb8;
    --kc-consent-text: #282828;
    --kc-consent-muted: #666;
    --kc-consent-border: #ddd;
}

.kc-consent[hidden],
.kc-consent [hidden] {
    display: none !important;
}

/* ---------- backdrop (preferences only) ---------- */

.kc-consent__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 9998;
}

/*
 * Banner state: dim the page but keep it fully usable — pointer-events: none
 * lets every click, scroll and tap pass straight through. Blocking the site
 * until someone accepts would be a cookie wall and would invalidate consent;
 * this is a visual nudge only.
 */
.kc-consent--dimmed .kc-consent__backdrop {
    background: rgba(0, 0, 0, .3);
    pointer-events: none;
}

/* ---------- shared shell ---------- */

.kc-consent__banner,
.kc-consent__prefs {
    position: fixed;
    z-index: 9999;
    background: #fff;
    color: var(--kc-consent-text);
    font-size: 1.4rem;
    line-height: 1.5;
    box-shadow: 0 -2px 16px rgba(0, 0, 0, .18);
}

.kc-consent__inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px;
}

.kc-consent__title {
    margin: 0 0 8px;
    font-size: 1.8rem;
    font-weight: 700;
}

.kc-consent__message {
    margin: 0 0 12px;
    color: var(--kc-consent-muted);
}

.kc-consent__links {
    margin: 0 0 16px;
}

.kc-consent__links a {
    color: var(--kc-consent-accent);
    text-decoration: underline;
    margin-right: 16px;
}

/* ---------- banner ---------- */

.kc-consent__banner {
    left: 0;
    right: 0;
    bottom: 0;
    border-top: 3px solid var(--kc-consent-accent);
}

/* ---------- buttons ---------- */

.kc-consent__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.kc-consent__btn {
    display: inline-block;
    padding: 10px 22px;
    border: 1px solid var(--kc-consent-border);
    border-radius: 4px;
    background: #f7f7f7;
    color: var(--kc-consent-text);
    font-size: 1.4rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
}

.kc-consent__btn:hover {
    background: #ededed;
}

/*
 * Accept and Reject share one style on purpose. Making refusal visually weaker
 * than acceptance is the classic dark pattern the ICO calls out.
 */
.kc-consent__btn--primary {
    background: var(--kc-consent-accent);
    border-color: var(--kc-consent-accent);
    color: #fff;
}

.kc-consent__btn--primary:hover {
    background: var(--kc-consent-accent-dark);
    border-color: var(--kc-consent-accent-dark);
    color: #fff;
}

.kc-consent__btn--link {
    background: none;
    border-color: transparent;
    color: var(--kc-consent-accent);
    text-decoration: underline;
    padding-left: 8px;
    padding-right: 8px;
}

.kc-consent__btn--link:hover {
    background: none;
    color: var(--kc-consent-accent-dark);
}

.kc-consent__btn:focus-visible,
.kc-consent__cat-label input:focus-visible {
    outline: 2px solid var(--kc-consent-accent);
    outline-offset: 2px;
}

/*
 * Attention pulse when someone tries to use the page before choosing.
 * Applied to Accept AND Reject together — singling out Accept would make it
 * more salient than Reject, which is the nudging pattern the ICO warns about.
 *
 * Two cycles at 0.55s is roughly 1.8 flashes/second, comfortably under the
 * WCAG 2.3.1 three-per-second threshold for photosensitivity.
 */
@keyframes kc-consent-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(51, 126, 215, 0);
    }
    50% {
        transform: scale(1.06);
        box-shadow: 0 0 0 6px rgba(51, 126, 215, .3);
    }
}

.kc-consent__btn--pulse {
    animation: kc-consent-pulse .55s ease-in-out 2;
}

@media (prefers-reduced-motion: reduce) {
    /* Same signal without motion, for anyone who has asked to avoid it. */
    .kc-consent__btn--pulse {
        animation: none;
        outline: 3px solid var(--kc-consent-accent);
        outline-offset: 3px;
    }
}

/* ---------- preferences panel ---------- */

.kc-consent__prefs {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 32px);
    max-width: 640px;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    border-radius: 4px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .3);
}

.kc-consent__prefs-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.kc-consent__close {
    background: none;
    border: 0;
    font-size: 2.6rem;
    line-height: 1;
    color: var(--kc-consent-muted);
    cursor: pointer;
    padding: 0 4px;
}

.kc-consent__close:hover {
    color: var(--kc-consent-text);
}

.kc-consent__cats {
    list-style: none;
    margin: 16px 0;
    padding: 0;
}

.kc-consent__cat {
    padding: 14px 0;
    border-top: 1px solid var(--kc-consent-border);
}

.kc-consent__cat-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    cursor: pointer;
}

.kc-consent__cat-label input[disabled] {
    cursor: not-allowed;
}

.kc-consent__cat-always {
    margin-left: auto;
    font-size: 1.2rem;
    font-weight: 400;
    color: var(--kc-consent-muted);
}

.kc-consent__cat-desc {
    margin: 6px 0 0 28px;
    font-size: 1.3rem;
    color: var(--kc-consent-muted);
}

/* ---------- small screens ---------- */

@media (max-width: 600px) {
    .kc-consent__inner {
        padding: 16px;
    }

    .kc-consent__banner {
        max-height: 80vh;
        overflow-y: auto;
    }

    .kc-consent__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .kc-consent__btn {
        width: 100%;
        text-align: center;
    }
}
