/* Cookie Policy v3.0.0 - banner + preferences panel
   Hardened against theme/Elementor cascade. Square (hard) edges, full-width bar
   with symmetric padding, and the HTML [hidden] attribute is forced to win so the
   panel only shows when opened.
   NOTE: the color values below are NEUTRAL FALLBACKS only. The live banner colors
   are set per-site from Settings -> Cookie Policy and injected as inline custom
   properties (see Cookie_Policy_Banner::color_css()).
   DOM prefix "cpc" = cookie-policy-consent. */

/* ---- theme-able tokens (also set on the reopen button, outside #cpc) ---- */
#cpc,
button.cpc-reopen {
    --cpc-bar-bg: #1f1f1f;
    --cpc-bar-fg: #ffffff;
    --cpc-accent: #2271b1;       /* neutral default; overridden from settings */
    --cpc-accent-hover: #1b5a8a;
    --cpc-accent-fg: #ffffff;
    --cpc-panel-bg: #ffffff;
    --cpc-panel-fg: #1f1f1f;
    --cpc-muted: #5b6066;
    --cpc-border: #d9dde3;
    --cpc-radius: 0;             /* hard edges */
}

/* ---- baseline reset so the host theme can't bleed in ---- */
#cpc,
#cpc *,
button.cpc-reopen {
    box-sizing: border-box;
}

/* force the hidden attribute to win over author display rules (fixes the panel
   showing on load and the X not closing it) */
#cpc[hidden],
#cpc [hidden],
button.cpc-reopen[hidden] {
    display: none !important;
}

#cpc,
button.cpc-reopen {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    text-transform: none;
    letter-spacing: normal;
    font-style: normal;
    font-weight: 400;
}

/* neutralise theme element rules inside the widget */
#cpc p,
#cpc h2,
#cpc h3,
#cpc label,
#cpc span {
    margin: 0;
    padding: 0;
    color: inherit;
    text-transform: none;
    letter-spacing: normal;
    font-family: inherit;
}

#cpc a {
    text-decoration: underline;
    box-shadow: none;
    background: none;
}

#cpc button,
button.cpc-reopen {
    margin: 0;
    font-family: inherit;
    text-transform: none !important;
    letter-spacing: normal;
    text-shadow: none;
    box-shadow: none;
    cursor: pointer;
    min-height: 0;
    width: auto;
}

/* ---------- bottom bar ---------- */
#cpc .cpc-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2147483600;
    background: var(--cpc-bar-bg);
    color: var(--cpc-bar-fg);
    box-shadow: 0 -2px 14px rgba(0, 0, 0, 0.28);
    width: 100%;
}

#cpc.cpc-open-panel .cpc-bar {
    display: none;
}

/* full width, symmetric light padding (no fixed max-width) */
#cpc .cpc-bar-inner {
    width: 100%;
    padding: 14px clamp(16px, 3vw, 48px);
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

#cpc .cpc-msg {
    flex: 1 1 340px;
    margin: 0;
    font-size: 13.5px !important;
    line-height: 1.5;
    color: var(--cpc-bar-fg);
}

#cpc .cpc-msg a,
#cpc .cpc-policy-link {
    color: var(--cpc-bar-fg) !important;
    text-decoration: underline !important;
}

#cpc .cpc-bar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

/* desktop: X is an inline flex item at the far right (no overlap, symmetric padding) */
#cpc .cpc-close {
    align-self: center;
    background: transparent !important;
    border: 0 !important;
    color: var(--cpc-bar-fg) !important;
    font-size: 22px;
    line-height: 1;
    padding: 4px 6px;
    opacity: 0.75;
    border-radius: 0;
    flex-shrink: 0;
}

#cpc .cpc-close:hover {
    opacity: 1;
}

/* ---------- buttons (square) ---------- */
#cpc .cpc-btn {
    display: inline-block;
    background: var(--cpc-accent) !important;
    color: var(--cpc-accent-fg) !important;
    border: 2px solid var(--cpc-accent) !important;
    padding: 9px 24px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    border-radius: 0 !important;
    text-decoration: none !important;
}

#cpc .cpc-btn:hover {
    background: var(--cpc-accent-hover) !important;
    border-color: var(--cpc-accent-hover) !important;
}

#cpc .cpc-btn--ghost {
    background: transparent !important;
    color: var(--cpc-panel-fg) !important;
    border: 2px solid var(--cpc-border) !important;
}

#cpc .cpc-btn--ghost:hover {
    background: transparent !important;
    border-color: var(--cpc-muted) !important;
}

#cpc .cpc-textlink {
    background: none !important;
    border: 0 !important;
    color: var(--cpc-bar-fg) !important;
    text-decoration: underline !important;
    font-size: 14px !important;
    padding: 4px 0 !important;
    border-radius: 0;
}

/* ---------- preferences panel ---------- */
#cpc .cpc-panel-wrap {
    position: fixed;
    inset: 0;
    z-index: 2147483601;
    background: rgba(15, 18, 22, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

#cpc .cpc-panel {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--cpc-panel-bg);
    color: var(--cpc-panel-fg);
    border-radius: var(--cpc-radius);
    padding: 30px 28px 24px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

#cpc .cpc-panel-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none !important;
    border: 0 !important;
    font-size: 24px;
    line-height: 1;
    color: var(--cpc-muted) !important;
    padding: 4px;
    border-radius: 0;
}

#cpc .cpc-panel-title {
    margin: 0 0 10px !important;
    font-size: 20px !important;
    font-weight: 700 !important;
    color: var(--cpc-panel-fg) !important;
}

#cpc .cpc-panel-intro {
    margin: 0 0 18px !important;
    font-size: 14px !important;
    line-height: 1.55;
    color: var(--cpc-panel-fg) !important;
}

#cpc .cpc-rowset {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 22px;
}

#cpc .cpc-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border: 1px solid var(--cpc-border);
    border-radius: var(--cpc-radius);
    padding: 14px 16px;
    background: #ffffff;
}

#cpc .cpc-row--locked {
    background: #f6f7f9;
}

#cpc .cpc-row-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    cursor: pointer;
}

#cpc .cpc-row--locked .cpc-row-label {
    cursor: default;
}

#cpc .cpc-row-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--cpc-panel-fg);
}

#cpc .cpc-row-state {
    font-size: 13px;
    color: var(--cpc-muted);
}

#cpc .cpc-lock {
    color: var(--cpc-accent);
    font-size: 18px;
    flex-shrink: 0;
}

/* toggle switch (kept rounded - a square toggle reads as a checkbox) */
#cpc .cpc-switch {
    position: relative;
    width: 52px;
    height: 30px;
    flex-shrink: 0;
}

#cpc .cpc-switch-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

#cpc .cpc-switch-track {
    position: absolute;
    inset: 0;
    background: #c6cad2;
    border-radius: 999px;
    transition: background 0.15s ease;
}

#cpc .cpc-switch-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease;
}

#cpc .cpc-switch-input:checked ~ .cpc-switch-track {
    background: var(--cpc-accent);
}

#cpc .cpc-switch-input:checked ~ .cpc-switch-track .cpc-switch-thumb {
    transform: translateX(22px);
}

#cpc .cpc-switch-input:focus-visible ~ .cpc-switch-track {
    outline: 2px solid var(--cpc-accent);
    outline-offset: 2px;
}

/* privacy rights */
#cpc .cpc-rights-title {
    margin: 0 0 8px !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    color: var(--cpc-panel-fg) !important;
}

#cpc .cpc-rights {
    margin: 0 0 12px !important;
    font-size: 13px !important;
    line-height: 1.55;
    color: var(--cpc-panel-fg) !important;
}

#cpc .cpc-rights a {
    color: var(--cpc-accent) !important;
}

#cpc .cpc-panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 18px;
}

/* reopen pill -> square */
button.cpc-reopen {
    position: fixed;
    left: 16px;
    bottom: 16px;
    z-index: 2147483599;
    background: var(--cpc-bar-bg) !important;
    color: #ffffff !important;
    border: 0 !important;
    border-radius: 0 !important;
    padding: 8px 16px !important;
    font-size: 13px !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
    opacity: 0.85;
}

button.cpc-reopen:hover {
    opacity: 1;
}

/* focus states */
#cpc .cpc-btn:focus-visible,
#cpc .cpc-textlink:focus-visible,
#cpc .cpc-close:focus-visible,
#cpc .cpc-panel-close:focus-visible,
button.cpc-reopen:focus-visible {
    outline: 2px solid var(--cpc-accent);
    outline-offset: 2px;
}

/* ---------- responsive ---------- */
@media (max-width: 782px) {
    #cpc .cpc-bar-inner {
        position: relative;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 16px clamp(16px, 4vw, 28px);
        padding-right: 44px;
    }

    #cpc .cpc-msg {
        flex: 1 1 auto;
    }

    #cpc .cpc-bar-actions {
        justify-content: flex-start;
        gap: 14px;
        flex-wrap: wrap;
    }

    #cpc .cpc-btn {
        flex: 0 1 auto;
    }

    /* on mobile the X moves back to the top-right corner */
    #cpc .cpc-close {
        position: absolute;
        top: 10px;
        right: 12px;
        align-self: auto;
    }
}

@media (max-width: 480px) {
    #cpc .cpc-bar-actions {
        flex-direction: column;
        align-items: stretch;
    }

    #cpc .cpc-btn,
    #cpc .cpc-textlink {
        width: 100%;
        text-align: center;
    }

    #cpc .cpc-panel {
        padding: 24px 18px 18px;
    }

    #cpc .cpc-panel-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    #cpc .cpc-panel-actions .cpc-btn {
        width: 100%;
        text-align: center;
    }
}

/* ---------- v2.1.0 additions ---------- */

/* Decline button sits on the dark bar -> needs light ghost styling */
#cpc .cpc-decline {
    color: var(--cpc-bar-fg) !important;
    border-color: rgba(255, 255, 255, 0.55) !important;
    background: transparent !important;
}

#cpc .cpc-decline:hover {
    border-color: #ffffff !important;
    background: rgba(255, 255, 255, 0.08) !important;
}

/* GPC note inside the preferences panel */
#cpc .cpc-gpc-note {
    margin: 0 0 16px !important;
    padding: 10px 12px;
    font-size: 13px !important;
    line-height: 1.5;
    color: var(--cpc-panel-fg) !important;
    background: #f3f6fb;
    border-left: 3px solid var(--cpc-accent);
}

/* confirmation toast (outside #cpc; toggled by class, not the hidden attribute) */
.cpc-confirm {
    box-sizing: border-box;
    display: none;
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    z-index: 2147483602;
    background: #1f1f1f;
    color: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 13.5px;
    line-height: 1.4;
    padding: 12px 18px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
    max-width: 90vw;
}

.cpc-confirm.is-visible {
    display: block;
}

@media (max-width: 480px) {
    .cpc-confirm {
        left: 12px;
        right: 12px;
        bottom: 12px;
        transform: none;
        text-align: center;
    }
}
/* ---------- v2.1.1 responsive hardening ---------- */

/* never let the widget force a horizontal scrollbar */
#cpc .cpc-bar,
#cpc .cpc-bar-inner {
    max-width: 100vw;
}

/* let the message shrink and wrap long links instead of pushing the row wider
   (a flex item defaults to min-width:auto, which can overflow with a long URL) */
#cpc .cpc-msg {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* on short viewports a stacked bottom bar can grow taller than the screen;
   anchored at bottom:0 it would push its own top out of reach with no way to
   scroll to it. Cap the height and let the bar scroll internally instead. */
#cpc .cpc-bar-inner {
    max-height: 85vh;
    max-height: 85dvh;
    overflow-y: auto;
}

/* preferences modal: align to the top with auto margins so a panel taller than
   the viewport scrolls from the top. (align-items:center clips the top of a tall
   panel and the close button becomes unreachable on short windows.) */
#cpc .cpc-panel-wrap {
    align-items: flex-start;
}

#cpc .cpc-panel {
    margin: auto;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
}
