/*
 * Consent banner and preferences panel.
 *
 * Colours come from the theme tokens, so the banner follows the palette chosen
 * in the panel. Radius 18px at most, light first with automatic dark mode.
 */

/* ------ scroll lock ------ */
/* Scroll held still while a choice is pending, the same way base.css does it
   for the lightbox: overflow only, NOT height:100%. The body is a flex column
   with main{flex:1}, and a fixed height would clip the article away. */
html.pls-consent-locked,
html.pls-consent-locked body {
    overflow: hidden !important;
}

/* ------ the page-wide overlay, under the banner and the panel ------ */
#pls-consent-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 99998;
    display: none;
    animation: pls-consent-fade-in 280ms ease-out;
}
html.pls-consent-locked #pls-consent-overlay {
    display: block;
}

/* ============================================================
 * FAÇADE BANNER (card bottom-right desktop, bottom-sheet mobile)
 * ============================================================ */
.pls-consent-banner {
    position: fixed;
    inset: 0;
    z-index: 99999;
    font-family: var(--pls-font, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    pointer-events: none;
}
.pls-consent-banner[hidden] {
    display: none !important;
}
.pls-consent-banner__card {
    position: absolute;
    bottom: 20px;
    right: 20px;
    left: auto;
    max-width: 480px;
    width: calc(100vw - 40px);
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: calc(18px * var(--pls-r));
    box-shadow: 0 10px 40px rgba(30, 99, 212, 0.25);
    padding: 22px 22px 30px 22px;
    color: #374151;
    pointer-events: auto;
    animation: pls-consent-fade-in 280ms ease-out;
}
.pls-consent-banner__title {
    font-size: 22px;
    font-weight: 700;
    color: #111827;
    line-height: 1.25;
    margin: 0 0 12px 0;
    letter-spacing: -0.01em;
}
.pls-consent-banner__rationale {
    font-size: 14px;
    line-height: 1.55;
    color: #374151;
    margin: 0 0 16px 0;
}
.pls-consent-banner__rationale strong {
    font-weight: 700;
    color: inherit;
}
.pls-consent-banner__rationale a {
    color: var(--pls-brand,#1e63d4);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.pls-consent-banner__rationale a:hover {
    color: var(--pls-brand-dark,#1751b8);
}
.pls-consent-banner__buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
}
.pls-consent-banner__btn {
    border-radius: calc(10px * var(--pls-r));
    padding: 0 18px;
    height: 40px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    line-height: 1;
    cursor: pointer;
    transition: all .18s ease;
    border: 1.5px solid #d1d5db;
    background: #ffffff;
    color: #374151;
    box-shadow: none;
    white-space: nowrap;
}
.pls-consent-banner__btn:hover {
    background: #ffffff;
    border-color: var(--pls-brand,#1e63d4);
    color: var(--pls-brand,#1e63d4);
}
.pls-consent-banner__btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

@media (max-width: 640px) {
    .pls-consent-banner__card {
        bottom: 12px;
        right: 12px;
        left: 12px;
        width: auto;
        max-width: none;
        padding: 18px;
        border-radius: calc(16px * var(--pls-r));
    }
    .pls-consent-banner__buttons {
        gap: 8px;
    }
    .pls-consent-banner__btn {
        flex: 1 1 30%;
        padding: 0 10px;
        font-size: 13px;
    }
}

/* ============================================================
 * THE PREFERENCES PANEL
 * On a desktop it is a dialog in the middle of the screen, 640px at most,
 * scrolling inside itself. On a phone it rises from the bottom edge and takes
 * nearly the whole screen.
 * ============================================================ */
.pls-consent-panel {
    position: fixed;
    inset: 0;
    z-index: 100000;
    font-family: var(--pls-font, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    display: flex;
    align-items: center;
    justify-content: center;
}
.pls-consent-panel[hidden] {
    display: none !important;
}
.pls-consent-panel__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: pls-consent-fade-in 200ms ease-out;
}
.pls-consent-panel__card {
    position: relative;
    background: #ffffff;
    border-radius: calc(18px * var(--pls-r));
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    width: calc(100vw - 32px);
    max-width: 640px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: pls-consent-pop-in 280ms cubic-bezier(.18,.89,.32,1.28);
}
.pls-consent-panel__close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease, color .15s ease;
    z-index: 2;
}
.pls-consent-panel__close:hover {
    background: #f3f4f6;
    color: #111827;
}
.pls-consent-panel__header {
    padding: 28px 28px 16px 28px;
}
.pls-consent-panel__title {
    margin: 0 0 10px 0;
    font-size: 22px;
    line-height: 1.25;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.01em;
    padding-right: 40px;
}
.pls-consent-panel__intro {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.55;
    color: #4b5563;
}
.pls-consent-panel__quick-actions {
    display: flex;
    gap: 10px;
    padding: 0 28px 16px 28px;
    border-bottom: 1px solid #f3f4f6;
}
.pls-consent-panel__quick-actions .pls-consent-panel__btn {
    flex: 1;
}
.pls-consent-panel__section {
    padding: 18px 28px 8px 28px;
    overflow-y: auto;
    flex: 1 1 auto;
    -webkit-overflow-scrolling: touch;
}
.pls-consent-panel__section-title {
    margin: 0 0 6px 0;
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    line-height: 1.35;
}
.pls-consent-panel__section-text {
    margin: 0 0 16px 0;
    font-size: 12.5px;
    line-height: 1.55;
    color: #6b7280;
}
.pls-consent-panel__items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.pls-consent-panel__item {
    padding: 14px 0;
    border-top: 1px solid #f3f4f6;
}
.pls-consent-panel__item:first-child {
    border-top: 0;
}
.pls-consent-panel__item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.pls-consent-panel__item-label {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    cursor: pointer;
    flex: 1;
}
.pls-consent-panel__item-desc {
    margin: 8px 0 0 0;
    font-size: 13px;
    line-height: 1.5;
    color: #6b7280;
}

/* ------ toggle switch ------ */
.pls-consent-toggle {
    position: relative;
    display: inline-flex;
    width: 44px;
    height: 24px;
    flex: 0 0 44px;
}
.pls-consent-toggle input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
}
.pls-consent-toggle__track {
    position: absolute;
    inset: 0;
    background: #d1d5db;
    border-radius: calc(999px * var(--pls-r));
    transition: background .2s ease;
    pointer-events: none;
}
.pls-consent-toggle__thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform .2s ease;
}
.pls-consent-toggle input:checked ~ .pls-consent-toggle__track {
    background: var(--pls-brand,#1e63d4);
}
.pls-consent-toggle input:checked ~ .pls-consent-toggle__track .pls-consent-toggle__thumb {
    transform: translateX(20px);
}
.pls-consent-toggle input:focus-visible ~ .pls-consent-toggle__track {
    outline: 2px solid var(--pls-brand,#1e63d4);
    outline-offset: 2px;
}
.pls-consent-toggle--locked input {
    cursor: not-allowed;
}
.pls-consent-toggle--locked .pls-consent-toggle__track {
    background: var(--pls-brand,#1e63d4);
    opacity: 0.55;
}
.pls-consent-toggle--locked .pls-consent-toggle__thumb {
    transform: translateX(20px);
}

/* ------ footer panel ------ */
.pls-consent-panel__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 28px 22px 28px;
    border-top: 1px solid #f3f4f6;
    background: #fafbfc;
}
.pls-consent-panel__footer-links {
    font-size: 12.5px;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.pls-consent-panel__footer-links a {
    color: var(--pls-brand,#1e63d4);
    text-decoration: none;
    font-weight: 500;
}
.pls-consent-panel__footer-links a:hover {
    text-decoration: underline;
}

/* ------ the buttons at the foot of the panel ------ */
.pls-consent-panel__btn {
    border-radius: calc(10px * var(--pls-r));
    padding: 0 18px;
    height: 40px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    line-height: 1;
    cursor: pointer;
    transition: all .18s ease;
    border: 1.5px solid #d1d5db;
    background: #ffffff;
    color: #374151;
    white-space: nowrap;
}
.pls-consent-panel__btn:hover {
    border-color: var(--pls-brand,#1e63d4);
    color: var(--pls-brand,#1e63d4);
    background: #ffffff;
}
.pls-consent-panel__btn--primary {
    background: var(--pls-brand,#1e63d4);
    color: #ffffff;
    border-color: var(--pls-brand,#1e63d4);
}
.pls-consent-panel__btn--primary:hover {
    background: #ffffff;
    color: var(--pls-brand,#1e63d4);
    border-color: var(--pls-brand,#1e63d4);
}
.pls-consent-panel__btn--ghost {
    background: transparent;
}

@media (max-width: 640px) {
    .pls-consent-panel {
        align-items: flex-end;
    }
    .pls-consent-panel__card {
        width: 100%;
        max-width: none;
        max-height: 92vh;
        border-radius: calc(18px * var(--pls-r)) calc(18px * var(--pls-r)) 0 0;
        animation: pls-consent-slide-up 320ms cubic-bezier(.18,.89,.32,1.28);
    }
    .pls-consent-panel__header,
    .pls-consent-panel__quick-actions,
    .pls-consent-panel__section,
    .pls-consent-panel__footer {
        padding-left: 18px;
        padding-right: 18px;
    }
    .pls-consent-panel__footer {
        flex-direction: column-reverse;
        align-items: stretch;
    }
    .pls-consent-panel__footer-links {
        justify-content: center;
    }
    .pls-consent-panel__btn {
        font-size: 13px;
    }
}

/* ------ keyframes ------ */
@keyframes pls-consent-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes pls-consent-pop-in {
    from { opacity: 0; transform: scale(.92) translateY(8px); }
    to   { opacity: 1; transform: scale(1)   translateY(0); }
}
@keyframes pls-consent-slide-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

/* ============================================================
 * DARK MODE
 * ============================================================ */
@media (prefers-color-scheme: dark) {
    .pls-consent-banner__card,
    .pls-consent-panel__card {
        background: #1f2937;
        border-color: rgba(255, 255, 255, 0.08);
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    }
    .pls-consent-banner__title,
    .pls-consent-panel__title,
    .pls-consent-panel__section-title,
    .pls-consent-panel__item-label {
        color: #f3f4f6;
    }
    .pls-consent-banner__rationale,
    .pls-consent-panel__intro {
        color: #d1d5db;
    }
    .pls-consent-panel__section-text,
    .pls-consent-panel__item-desc,
    .pls-consent-panel__footer-links {
        color: #9ca3af;
    }
    .pls-consent-banner__rationale a,
    .pls-consent-panel__footer-links a {
        color: #60a5fa;
    }
    .pls-consent-banner__btn,
    .pls-consent-panel__btn:not(.pls-consent-panel__btn--primary) {
        background: #374151;
        color: #e5e7eb;
        border-color: #4b5563;
    }
    .pls-consent-banner__btn:hover,
    .pls-consent-panel__btn:not(.pls-consent-panel__btn--primary):hover {
        background: #1f2937;
        border-color: #60a5fa;
        color: #60a5fa;
    }
    .pls-consent-panel__close {
        color: #9ca3af;
    }
    .pls-consent-panel__close:hover {
        background: #374151;
        color: #f3f4f6;
    }
    .pls-consent-panel__quick-actions,
    .pls-consent-panel__item,
    .pls-consent-panel__footer {
        border-color: rgba(255, 255, 255, 0.08);
    }
    .pls-consent-panel__footer {
        background: #18212f;
    }
    .pls-consent-toggle__track {
        background: #4b5563;
    }
}
