/* Cookie-consent UI (first-party CMP) — Alectrofag. SEO Phase 2 / WP-19.
   Loaded (non-blocking) from template/consent_init.php on every page that
   can run GTM; markup is injected by core/cookie-consent.js.

   Two pieces:
     .fv-cc-banner   non-modal bottom sheet shown on first visit — the page
                     stays fully usable behind it (nothing is gated).
     .fv-cc-overlay  centred preferences dialog (category cards + per-cookie
                     tables), opened from "Manage" / fvConsent.open().

   Colours come from core/css/critical.css :root tokens (navy #0f2236, teal
   #0f857f / #1aa69f, ink greys, --fv-text-success #3BB77E) with literal
   fallbacks, so the UI reads as part of the shop without adding a palette.

   z-index: everything here sits BELOW Bootstrap's modal backdrop (1050) so
   the 18+ age-verification modal (inline z-index 9999999999) always wins;
   the JS also hides this UI (.fv-cc-suspended) while that modal is open. */

#fv-cc.fv-cc-suspended {
    display: none;
}

/* ── First-visit banner (bottom sheet) ──────────────────────────────── */
.fv-cc-banner {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1035;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    pointer-events: none; /* only the card itself catches clicks */
    animation: fv-cc-rise .22s ease-out;
}

.fv-cc-banner-inner {
    pointer-events: auto;
    max-width: 1140px;
    margin: 0 auto;
    background: #fff;
    color: var(--ink-900, #0f2236);
    border: 1px solid var(--ink-200, #dbe1e9);
    border-top: 4px solid var(--teal-600, #0f857f);
    border-radius: var(--radius, 12px);
    box-shadow: var(--shadow-lg, 0 16px 40px rgba(11, 18, 19, .12), 0 4px 12px rgba(11, 18, 19, .06));
    padding: 16px 20px;
    display: flex;
    gap: 18px;
    align-items: center;
    flex-wrap: wrap;
    font-family: inherit;
}

.fv-cc-banner-text {
    flex: 1 1 380px;
    min-width: 0;
}

.fv-cc-banner-text strong {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: var(--navy, #0f2236);
    margin-bottom: 4px;
}

.fv-cc-banner-text p {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--ink-600, #4a6383);
}

.fv-cc-banner a,
.fv-cc-modal a {
    color: var(--teal-600, #0f857f);
    text-decoration: underline;
}

@keyframes fv-cc-rise {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
}

/* ── Action buttons ──────────────────────────────────────────────────
   "Accept all" and "Reject non-essential" keep EQUAL prominence (ICO
   guidance) — same size and weight, different colour only. */
.fv-cc-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    flex: 0 0 auto;
}

.fv-cc-btn {
    border: 0;
    border-radius: var(--radius-sm, 6px);
    padding: 11px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    line-height: 1.2;
    font-family: inherit;
}

.fv-cc-accept-btn {
    background: var(--teal-600, #0f857f);
    color: #fff;
}

.fv-cc-reject-btn {
    background: var(--ink-100, #eef1f5);
    color: var(--ink-900, #0f2236);
}

.fv-cc-save-btn {
    background: var(--navy, #0f2236);
    color: #fff;
}

.fv-cc-btn:hover {
    filter: brightness(.94);
}

.fv-cc-btn:focus-visible,
.fv-cc-linkbtn:focus-visible,
.fv-cc-close:focus-visible,
.fv-cc-reopen:focus-visible {
    outline: 2px solid var(--teal-500, #1aa69f);
    outline-offset: 2px;
}

.fv-cc-linkbtn {
    background: none;
    border: 0;
    color: var(--teal-600, #0f857f);
    text-decoration: underline;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 2px;
    font-family: inherit;
}

/* ── Preferences dialog ──────────────────────────────────────────────── */
.fv-cc-overlay {
    position: fixed;
    inset: 0;
    z-index: 1039;
    background: rgba(10, 20, 35, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fv-cc-fade .18s ease-out;
}

@keyframes fv-cc-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fv-cc-modal {
    background: #fff;
    color: var(--ink-900, #0f2236);
    border-radius: var(--radius, 12px);
    max-width: 600px;
    width: 100%;
    max-height: 88vh;
    overflow: auto;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .30);
    font-family: inherit;
    animation: fv-cc-rise .22s ease-out;
    position: relative;
}

.fv-cc-brandbar {
    height: 5px;
    border-radius: var(--radius, 12px) var(--radius, 12px) 0 0;
    background: linear-gradient(90deg, var(--navy, #0f2236), var(--teal-500, #1aa69f));
}

.fv-cc-body {
    padding: 22px 24px 20px;
}

.fv-cc-modal h3 {
    margin: 0 0 8px;
    font-size: 19px;
    font-weight: 700;
    color: var(--navy, #0f2236);
}

.fv-cc-text {
    margin: 0 0 16px;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--ink-600, #4a6383);
}

.fv-cc-back {
    position: absolute;
    top: 14px;
    left: 18px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.fv-cc-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: 0;
    font-size: 26px;
    line-height: 1;
    color: var(--ink-500, #7089a6);
    cursor: pointer;
    padding: 4px 8px;
}

.fv-cc-close:hover {
    color: var(--ink-900, #0f2236);
}

.fv-cc-back + h3,
.fv-cc-close + h3 {
    margin-top: 14px;
}

/* Category cards */
.fv-cc-cats {
    margin-bottom: 16px;
}

.fv-cc-cat {
    border: 1px solid var(--ink-200, #dbe1e9);
    border-radius: 10px;
    padding: 13px 14px 10px;
    margin-bottom: 10px;
    background: var(--ink-50, #f6f8fb);
}

.fv-cc-cat-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
}

.fv-cc-cat-titles h4 {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 700;
    color: var(--ink-900, #0f2236);
}

.fv-cc-cat-titles p {
    margin: 0;
    font-size: 12.5px;
    color: var(--ink-600, #4a6383);
    line-height: 1.45;
}

.fv-cc-always {
    font-size: 12px;
    font-weight: 700;
    color: var(--fv-text-success, #3BB77E);
    white-space: nowrap;
    padding-top: 3px;
}

/* "Show cookies" expander + per-cookie table */
.fv-cc-showcookies {
    background: none;
    border: 0;
    padding: 6px 0 2px;
    font-size: 12px;
    font-weight: 600;
    color: var(--teal-600, #0f857f);
    cursor: pointer;
    text-decoration: underline;
    font-family: inherit;
}

.fv-cc-showcookies::after {
    content: " \25BE";
}

.fv-cc-showcookies.fv-cc-open::after {
    content: " \25B4";
}

.fv-cc-cookielist {
    overflow-x: auto;
    margin-top: 6px;
}

.fv-cc-cookielist table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.fv-cc-cookielist th {
    text-align: left;
    color: var(--ink-500, #7089a6);
    font-weight: 600;
    padding: 4px 8px 4px 0;
    border-bottom: 1px solid var(--ink-200, #dbe1e9);
    white-space: nowrap;
}

.fv-cc-cookielist td {
    padding: 5px 8px 5px 0;
    color: var(--ink-800, #1a3147);
    border-bottom: 1px solid var(--ink-100, #eef1f5);
    vertical-align: top;
}

.fv-cc-cookielist td:first-child {
    font-family: monospace;
    white-space: nowrap;
}

/* Toggle switch */
.fv-cc-switch {
    position: relative;
    flex: none;
    width: 44px;
    height: 24px;
    margin-top: 2px;
}

.fv-cc-switch input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}

.fv-cc-switch span {
    position: absolute;
    inset: 0;
    border-radius: 24px;
    background: var(--ink-300, #c3ccd9);
    transition: background .15s;
    pointer-events: none;
}

.fv-cc-switch span::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: transform .15s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}

.fv-cc-switch input:checked + span {
    background: var(--teal-500, #1aa69f);
}

.fv-cc-switch input:checked + span::after {
    transform: translateX(20px);
}

.fv-cc-switch input:focus-visible + span {
    outline: 2px solid var(--teal-500, #1aa69f);
    outline-offset: 2px;
}

/* ── Fallback "Cookie settings" pill ──────────────────────────────────
   Injected only when the page has no reopen link of its own; drop it by
   adding <a href="#cookie-settings"> (or data-fv-cc-open) to the footer. */
.fv-cc-reopen {
    position: fixed;
    left: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 1029;
    background: #fff;
    color: var(--ink-600, #4a6383);
    border: 1px solid var(--ink-200, #dbe1e9);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(11, 18, 19, .08));
    opacity: .85;
}

.fv-cc-reopen:hover {
    opacity: 1;
    color: var(--teal-600, #0f857f);
}

/* ── Mobile ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .fv-cc-banner {
        padding: 8px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }

    .fv-cc-banner-inner {
        padding: 14px 14px 12px;
        gap: 12px;
    }

    .fv-cc-banner-text p {
        font-size: 12.5px;
    }

    .fv-cc-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .fv-cc-btn {
        width: 100%;
    }

    .fv-cc-linkbtn.fv-cc-goto-prefs {
        order: 5;
        text-align: center;
    }

    .fv-cc-overlay {
        padding: 10px;
        align-items: flex-end;
    }

    .fv-cc-body {
        padding: 18px 16px 16px;
    }

    .fv-cc-reopen {
        left: 8px;
        padding: 5px 10px;
        font-size: 11px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fv-cc-banner,
    .fv-cc-overlay,
    .fv-cc-modal {
        animation: none;
    }
}
