/*
 * Cookie banner (Consent\Consent, templates/consent/banner.php, js/pb-consent.js).
 *
 * A card, not a wall: on a phone at most ~200 px, above the poster page's
 * sticky "Dodaj do koszyka" bar (--pb-consent-bottom, set by the script);
 * on a desktop 380 px in the bottom-left corner. While it shows, the page
 * gets as much bottom padding as the card is tall (--pb-consent-height), so
 * every button can still be scrolled into view.
 */

.pb-consent {
    position: fixed;
    z-index: 9990;
    left: 12px;
    right: 12px;
    bottom: calc(var(--pb-consent-bottom, 0px) + 12px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-sizing: border-box;
    padding: 16px;
    background: #fff;
    border: 1px solid #e5ded2;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(35, 35, 31, 0.12);
    font-family: var(--font-body);
    color: #3a3a34;
}

.pb-consent[hidden],
.pb-consent-sheet[hidden] {
    display: none;
}

html.pb-consent-shown body {
    padding-bottom: calc(var(--pb-consent-height, 0px) + 24px);
}

.pb-consent__title,
.pb-consent-sheet__title {
    margin: 0;
    font-family: var(--font-heading);
    font-weight: 400;
    font-size: 19px;
    line-height: 1.25;
    color: #2a2a2a;
}

.pb-consent__text {
    margin: -8px 0 0;
    font-size: 14px;
    line-height: 1.45;
}

.pb-consent__actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.pb-consent__btn {
    min-height: 48px;
    margin: 0;
    padding: 0 12px;
    border: 1.5px solid #2a2a2a;
    border-radius: 5px;
    background: #fff;
    color: #2a2a2a;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
}

.pb-consent__btn--primary {
    border-color: #5e6a46;
    background: #5e6a46;
    color: #fff;
}

/*
 * WoodMart's :is(.btn, button, [type=button]):hover (0,2,0) repaints every
 * button grey with dark text; the element in front of each class outranks it.
 */
@media (hover: hover) {
    button.pb-consent__btn--secondary:hover {
        border-color: #2a2a2a;
        background: #f6f3ed;
        color: #2a2a2a;
        box-shadow: none;
    }

    button.pb-consent__btn--primary:hover {
        border-color: #3f4830;
        background: #3f4830;
        color: #fff;
        box-shadow: none;
    }

    button.pb-consent__link:hover {
        background: none;
        color: #3f4830;
        text-decoration-thickness: 2px;
        box-shadow: none;
    }
}

.pb-consent__btn:focus-visible,
.pb-consent__link:focus-visible,
.pb-consent__policy:focus-visible,
.pb-consent-sheet__switch:focus-visible {
    outline: 2px solid #5e6a46;
    outline-offset: 3px;
}

.pb-consent__links {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    font-size: 13px;
}

.pb-consent__links--start {
    justify-content: flex-start;
}

.pb-consent__link {
    min-height: 32px;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: #5e6a46;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-transform: none;
    cursor: pointer;
}

.pb-consent__policy {
    color: #6b6a62;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Settings: a sheet from the bottom on a phone, a centred panel on a desktop. */

.pb-consent-sheet {
    position: fixed;
    z-index: 9995;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    font-family: var(--font-body);
    color: #3a3a34;
}

.pb-consent-sheet__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(35, 35, 31, 0.32);
}

.pb-consent-sheet__panel {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-sizing: border-box;
    width: 100%;
    max-height: 100%;
    overflow-y: auto;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 24px rgba(35, 35, 31, 0.12);
}

.pb-consent-sheet__panel:focus {
    outline: none;
}

.pb-consent-sheet__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.pb-consent-sheet__title {
    font-size: 22px;
}

.pb-consent-sheet__head .pb-consent__link {
    min-height: 44px;
    font-size: 14px;
}

.pb-consent-sheet__text {
    margin: 0;
    font-size: 14px;
    line-height: 1.45;
}

.pb-consent-sheet__list {
    display: flex;
    flex-direction: column;
    border: 1px solid #e8e1d5;
    border-radius: 10px;
}

.pb-consent-sheet__row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 14px;
    cursor: pointer;
}

.pb-consent-sheet__row + .pb-consent-sheet__row {
    border-top: 1px solid #e8e1d5;
}

.pb-consent-sheet__copy {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    gap: 2px;
}

.pb-consent-sheet__name {
    font-size: 15px;
    font-weight: 700;
    color: #23231f;
}

.pb-consent-sheet__desc {
    font-size: 13px;
    line-height: 1.4;
    color: #6b6a62;
}

.pb-consent-sheet__always {
    font-size: 13px;
    font-weight: 600;
    color: #6b6a62;
    white-space: nowrap;
}

/* A switch drawn from the checkbox itself. */
.pb-consent-sheet__switch {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 26px;
    margin: 0;
    border-radius: 999px;
    background: #cfc8bb;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    transition: background-color 0.16s;
}

.pb-consent-sheet__switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(35, 35, 31, 0.2);
    transition: transform 0.16s;
}

.pb-consent-sheet__switch:checked {
    background: #5e6a46;
}

.pb-consent-sheet__switch:checked::after {
    transform: translateX(18px);
}

@media (prefers-reduced-motion: reduce) {
    .pb-consent-sheet__switch,
    .pb-consent-sheet__switch::after {
        transition: none;
    }
}

@media (min-width: 768px) {
    .pb-consent {
        left: 24px;
        right: auto;
        bottom: calc(var(--pb-consent-bottom, 0px) + 24px);
        width: 380px;
        padding: 20px;
        gap: 14px;
    }

    .pb-consent__title {
        font-size: 20px;
    }

    .pb-consent__text {
        margin-top: -6px;
        line-height: 1.5;
    }

    .pb-consent__btn {
        min-height: 44px;
    }

    /* On a desktop the card sits in a corner and covers nothing. */
    html.pb-consent-shown body {
        padding-bottom: 0;
    }

    .pb-consent-sheet {
        align-items: center;
        padding: 24px;
    }

    .pb-consent-sheet__panel {
        max-width: 520px;
        padding: 24px;
        border-radius: 12px;
    }
}
