/* ══════════════════════════════════════════════════════════════════════════
   The cookie consent banner and choices dialog (development/consent.js).
   Every selector starts at #erp-consent or .erp-consent-* so a host page's
   resets lose, on every template, the shop and the customer area. Its own
   tokens; dark when the page is dark (data-theme-tone, set by the script from
   the page's theme or background, else prefers-color-scheme).

   Contrast (WCAG 2.2 AA): body text 15.4:1 light / 13.9:1 dark; muted text
   7.0:1 / 7.4:1; buttons' text 15.4:1 and borders 15.4:1 / 13.9:1; focus ring
   #0054a6 on white 7.3:1, #8ab8ff on #151b26 8.6:1.
   ══════════════════════════════════════════════════════════════════════════ */
#erp-consent {
    --ec-bg: #ffffff;
    --ec-ink: #1d273b;
    --ec-muted: #4a5568;
    --ec-line: #c9d1dc;
    --ec-soft: #f4f6fa;
    --ec-focus: #0054a6;
    --ec-on: #1b6e3c;
    --ec-shadow: 0 12px 32px rgba(15, 23, 42, .18), 0 2px 6px rgba(15, 23, 42, .10);
    --ec-radius: 12px;
    --ec-space-1: 4px;
    --ec-space-2: 8px;
    --ec-space-3: 12px;
    --ec-space-4: 16px;
    --ec-space-5: 24px;
    --ec-duration: 200ms;
    font: 400 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--ec-ink);
}
#erp-consent[data-theme-tone="dark"] {
    --ec-bg: #151b26;
    --ec-ink: #eef2f8;
    --ec-muted: #b9c3d1;
    --ec-line: #4a5568;
    --ec-soft: #1f2735;
    --ec-focus: #8ab8ff;
    --ec-on: #7fd8a1;
    --ec-shadow: 0 12px 32px rgba(0, 0, 0, .55);
}
#erp-consent *, #erp-consent *::before, #erp-consent *::after { box-sizing: border-box; }

/* ── the banner ─────────────────────────────────────────────────────────── */
#erp-consent .erp-consent-banner {
    position: fixed;
    z-index: 2147483000;
    left: 50%;
    bottom: var(--ec-space-4);
    transform: translateX(-50%);
    width: min(960px, calc(100% - 2 * var(--ec-space-4)));
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--ec-space-4) var(--ec-space-5);
    padding: var(--ec-space-5);
    background: var(--ec-bg);
    color: var(--ec-ink);
    border: 1px solid var(--ec-line);
    border-radius: var(--ec-radius);
    box-shadow: var(--ec-shadow);
}
#erp-consent .erp-consent-banner[hidden] { display: none; }
#erp-consent .erp-consent-banner__body { flex: 1 1 420px; min-width: 0; }
#erp-consent .erp-consent-title {
    margin: 0 0 var(--ec-space-2);
    font-size: 17px; font-weight: 600; line-height: 1.35;
    font-family: inherit;
    color: var(--ec-ink);
    letter-spacing: 0;
    text-transform: none;
}
#erp-consent .erp-consent-text { margin: 0 0 var(--ec-space-2); color: var(--ec-ink); font-size: 15px; }
#erp-consent .erp-consent-links { margin: 0; display: flex; flex-wrap: wrap; gap: var(--ec-space-4); font-size: 14px; }
#erp-consent .erp-consent-links a,
#erp-consent .erp-consent-embed__link { color: var(--ec-ink); text-decoration: underline; text-underline-offset: 3px; }

/* equal prominence: the three choices share one style and one size */
#erp-consent .erp-consent-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ec-space-2);
    flex: 0 1 auto;
}
.erp-consent-btn,
#erp-consent .erp-consent-btn {
    appearance: none;
    min-height: 44px;
    min-width: 128px;
    padding: 0 var(--ec-space-4, 16px);
    border: 2px solid var(--ec-ink, #1d273b);
    border-radius: 8px;
    background: var(--ec-bg, #fff);
    color: var(--ec-ink, #1d273b);
    font-size: 15px; font-weight: 600; line-height: 1;
    font-family: inherit;
    cursor: pointer;
    transition: background-color var(--ec-duration, 200ms) ease, color var(--ec-duration, 200ms) ease;
}
@media (hover: hover) {
    #erp-consent .erp-consent-btn:hover,
    .erp-consent-embed .erp-consent-btn:hover { background: var(--ec-ink, #1d273b); color: var(--ec-bg, #fff); }
}
#erp-consent .erp-consent-btn:active { transform: translateY(1px); }
#erp-consent :focus-visible,
.erp-consent-embed :focus-visible {
    outline: 3px solid var(--ec-focus, #0054a6);
    outline-offset: 2px;
}

/* ── the choices dialog ─────────────────────────────────────────────────── */
#erp-consent .erp-consent-dialog {
    width: min(600px, calc(100% - 2 * var(--ec-space-4)));
    max-height: min(86vh, 760px);
    padding: 0;
    border: 1px solid var(--ec-line);
    border-radius: var(--ec-radius);
    background: var(--ec-bg);
    color: var(--ec-ink);
    box-shadow: var(--ec-shadow);
    overflow: hidden;
}
#erp-consent .erp-consent-dialog::backdrop { background: rgba(15, 23, 42, .55); }
#erp-consent .erp-consent-dialog__form { display: flex; flex-direction: column; max-height: inherit; margin: 0; }
#erp-consent .erp-consent-dialog__head {
    display: flex; align-items: center; justify-content: space-between; gap: var(--ec-space-3);
    padding: var(--ec-space-4) var(--ec-space-5); border-bottom: 1px solid var(--ec-line);
}
#erp-consent .erp-consent-dialog__head .erp-consent-title { margin: 0; }
#erp-consent .erp-consent-close {
    display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 8px;
    background: transparent; color: var(--ec-ink); cursor: pointer;
}
@media (hover: hover) { #erp-consent .erp-consent-close:hover { background: var(--ec-soft); } }
#erp-consent .erp-consent-dialog__body { padding: var(--ec-space-4) var(--ec-space-5); overflow-y: auto; }
#erp-consent .erp-consent-dialog .erp-consent-actions {
    justify-content: flex-end; padding: var(--ec-space-4) var(--ec-space-5); border-top: 1px solid var(--ec-line);
}
#erp-consent .erp-consent-category {
    margin: 0 0 var(--ec-space-3); padding: var(--ec-space-4); border: 1px solid var(--ec-line);
    border-radius: 10px; background: var(--ec-soft); min-width: 0;
}
#erp-consent .erp-consent-category__row { display: flex; align-items: center; justify-content: space-between; gap: var(--ec-space-3); }
#erp-consent .erp-consent-category__label { font-weight: 600; }
#erp-consent .erp-consent-category__text { margin: var(--ec-space-2) 0 0; color: var(--ec-muted); font-size: 14px; }
#erp-consent .erp-consent-always,
#erp-consent .erp-consent-state { font-size: 13px; font-weight: 600; color: var(--ec-muted); white-space: nowrap; }
#erp-consent .erp-consent-items { margin-top: var(--ec-space-2); font-size: 14px; }
#erp-consent .erp-consent-items summary { cursor: pointer; color: var(--ec-ink); text-decoration: underline; text-underline-offset: 3px; min-height: 32px; display: list-item; }
#erp-consent .erp-consent-items ul { margin: var(--ec-space-2) 0 0; padding-left: var(--ec-space-5); color: var(--ec-muted); }
#erp-consent .erp-consent-items li { margin-bottom: var(--ec-space-2); }
#erp-consent .erp-consent-party { font-size: 13px; color: var(--ec-muted); }

/* the switch: a real checkbox, drawn; on/off is said in words beside it too */
#erp-consent .erp-consent-switch { display: inline-flex; align-items: center; gap: var(--ec-space-3); cursor: pointer; min-height: 44px; }
#erp-consent .erp-consent-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
#erp-consent .erp-consent-switch__track {
    position: relative; flex: none; width: 44px; height: 26px; border-radius: 13px;
    border: 2px solid var(--ec-ink); background: var(--ec-bg);
    transition: background-color var(--ec-duration) ease;
}
#erp-consent .erp-consent-switch__thumb {
    position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
    background: var(--ec-ink); transition: transform var(--ec-duration) ease;
}
#erp-consent .erp-consent-switch input:checked + .erp-consent-switch__track { background: var(--ec-on); border-color: var(--ec-on); }
#erp-consent .erp-consent-switch input:checked + .erp-consent-switch__track .erp-consent-switch__thumb { transform: translateX(18px); background: var(--ec-bg); }
#erp-consent .erp-consent-switch input:disabled + .erp-consent-switch__track { opacity: .7; cursor: not-allowed; }
#erp-consent .erp-consent-switch input:focus-visible + .erp-consent-switch__track { outline: 3px solid var(--ec-focus); outline-offset: 2px; }

#erp-consent .erp-consent-sr,
.erp-consent-sr {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ── a third-party embed waiting for consent ─────────────────────────────── */
.erp-consent-embed {
    --ec-bg: #ffffff; --ec-ink: #1d273b; --ec-focus: #0054a6;
    display: block; width: 100%; min-height: 240px; border-radius: 10px; overflow: hidden;
}
.erp-consent-embed iframe { display: block; width: 100%; min-height: 360px; border: 0; }
.erp-consent-embed__ask {
    display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 12px;
    min-height: 240px; padding: 24px; border: 1px dashed #8a97aa; border-radius: 10px;
    background: #f4f6fa; color: #1d273b; font: 400 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
.erp-consent-embed__text { margin: 0; max-width: 60ch; }
.erp-consent-embed .erp-consent-btn { min-width: 0; }
@media (prefers-color-scheme: dark) {
    [data-bs-theme="dark"] .erp-consent-embed__ask,
    [data-theme="dark"] .erp-consent-embed__ask { background: #1f2735; color: #eef2f8; border-color: #6b7a90; }
}

/* ── narrow screens: the choices stack, full width ───────────────────────── */
@media (max-width: 640px) {
    #erp-consent .erp-consent-banner { bottom: var(--ec-space-2); padding: var(--ec-space-4); width: calc(100% - 2 * var(--ec-space-2)); }
    #erp-consent .erp-consent-actions { width: 100%; }
    #erp-consent .erp-consent-btn { flex: 1 1 100%; }
    #erp-consent .erp-consent-dialog { width: calc(100% - 2 * var(--ec-space-2)); max-height: 92vh; }
}

@media (prefers-reduced-motion: no-preference) {
    #erp-consent .erp-consent-banner { animation: erp-consent-in 240ms cubic-bezier(.2, .8, .2, 1); }
    @keyframes erp-consent-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
}
@media (prefers-reduced-motion: reduce) {
    #erp-consent *, .erp-consent-embed * { transition: none !important; animation: none !important; }
}
@media print { #erp-consent { display: none !important; } }

/* the legal links every public footer carries (_Shared/legal-links.php); this
   sheet is on every public page, the legal one only on the legal pages */
.erp-legal-footer-links { display: flex; flex-wrap: wrap; gap: 0 16px; }
.erp-legal-footer-links a { color: inherit; display: inline-block; padding: 6px 0; }

/* ── the banner never covers the page: while it is shown, the page gets room
   below its last line (body padding equal to the banner's height, set by
   consent.js as --erp-consent-space) and the fixed bottom widgets - the
   support chat's launcher and panel - sit above it ───────────────────── */
html.erp-consent-open body { padding-bottom: var(--erp-consent-space, 0px) !important; }
html.erp-consent-open #erp-support { bottom: calc(var(--erp-consent-space, 0px) + 16px); }
html.erp-consent-open #erp-support .sw-panel {
    bottom: calc(var(--erp-consent-space, 0px) + 16px);
    height: min(640px, calc(100vh - var(--erp-consent-space, 0px) - 32px));
    max-height: calc(100vh - var(--erp-consent-space, 0px) - 32px);
}
@media (max-width: 640px) {
    html.erp-consent-open #erp-support { bottom: calc(var(--erp-consent-space, 0px) + 12px); }
    /* the open chat is a full-screen sheet on a phone: it covers the banner, which is back when it closes */
    html.erp-consent-open #erp-support .sw-panel { bottom: 0; height: 100dvh; max-height: none; }
    html.erp-consent-open #erp-support.sw-open { z-index: 2147483001; }
    /* a compact bar: the title is for screen readers, the text three lines with a way to read it all */
    #erp-consent .erp-consent-banner { gap: 8px; padding: 12px; bottom: 0; width: 100%; border-radius: 12px 12px 0 0; border-bottom: 0; }
    #erp-consent .erp-consent-banner .erp-consent-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
    #erp-consent .erp-consent-banner .erp-consent-text { font-size: 14px; margin-bottom: 4px; }
    #erp-consent .erp-consent-banner:not(.is-expanded) .erp-consent-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
    #erp-consent .erp-consent-banner .erp-consent-actions { flex-wrap: nowrap; }
    #erp-consent .erp-consent-banner .erp-consent-btn { flex: 1 1 0; min-width: 0; padding: 0 6px; font-size: 14px; }
    #erp-consent .erp-consent-more { display: inline-block; }
}
#erp-consent .erp-consent-more { display: none; padding: 6px 0; border: 0; background: none; color: inherit; font: inherit; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
