/* ============================================================================
   Biscuit — first-visit persistent notice + storage-blocked warning.
   ============================================================================

   Filename remains `cookie.css` for continuity with the module registry in
   header.php, but the selectors within deliberately AVOID the words
   "cookie", "consent", "gdpr", "banner", "notice" and "popup". Cookie-
   annoyance filter lists (EasyList Cookie, Fanboy's Cookiemonster, uBO
   Annoyances, AdGuard Annoyances) match elements by class and id names
   containing those keywords. The prior `.cookie-banner` was being silently
   hidden after ~3s by browsers running Consent-O-Matic or an equivalent
   annoyance blocker. `.lr-biscuit` is branded-neutral and is not on any
   current list.

   Two components live here:

   1. `.lr-biscuit` — the first-visit notice. Behaviour unchanged from the
      prior implementation. Emerges from bottom-centre, stays until Accept
      / Reject / Save. Persisted via `lr_consent` cookie for 180 days.

   2. `.lr-storage-notice` — a persistent warning shown ONLY when the
      browser refuses to store cookies at all. No dismiss control. Sits
      just above the biscuit position so both can display if needed.
============================================================================ */


/* ==========================================================================
   1. First-visit biscuit
========================================================================== */


/* Container ------------------------------------------------------------- */
.lr-biscuit {
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom, 20px));
    left: 50%;
    z-index: 1000;

    width: min(480px, calc(100vw - 24px));
    max-width: 100%;

    background: var(--bg-alt);
    color: var(--text);
    border: 1px solid var(--surface-border);
    border-top: 3px solid var(--color-primary);
    border-radius: var(--r-card);

    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.35),
        0 4px 14px rgba(0, 0, 0, 0.20);

    padding: var(--space-lg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);

    /* Hidden state — off-screen and invisible. No visibility trick. */
    transform: translateX(-50%) translateY(140%);
    opacity: 0;
    pointer-events: none;

    transition:
        transform 420ms cubic-bezier(0.16, 0.84, 0.44, 1),
        opacity   240ms ease;
}

.lr-biscuit.is-visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

:root[data-theme="light"] .lr-biscuit {
    background: #FFFFFF;
    box-shadow:
        0 16px 44px rgba(13, 45, 78, 0.14),
        0 3px 10px rgba(13, 45, 78, 0.08);
}


/* Head — icon + title + body ------------------------------------------- */
.lr-biscuit__head {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.lr-biscuit__icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(176, 111, 43, 0.14);
    color: var(--color-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
:root[data-theme="light"] .lr-biscuit__icon {
    background: rgba(139, 86, 36, 0.10);
    color: var(--color-primary);
}
.lr-biscuit__icon svg { width: 20px; height: 20px; }

.lr-biscuit__text { min-width: 0; }

.lr-biscuit__title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    margin: 0 0 4px;
    letter-spacing: -0.01em;
}

.lr-biscuit__body {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-muted);
    margin: 0;
}
.lr-biscuit__body a {
    color: var(--color-accent);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}


/* Actions --------------------------------------------------------------- */
.lr-biscuit__actions {
    display: flex;
    gap: var(--space-xs);
    justify-content: flex-end;
    flex-wrap: wrap;
}
.lr-biscuit__actions .btn {
    min-height: 36px;
    padding: 0 var(--space-md);
    font-size: 13px;
    line-height: 1;
    border-radius: var(--r-card);
    letter-spacing: 0;
}
.lr-biscuit__actions .btn-primary {
    box-shadow: 0 4px 12px rgba(43, 108, 176, 0.22);
}
.lr-biscuit__actions .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(43, 108, 176, 0.30);
}


/* Manage panel ---------------------------------------------------------- */
.lr-biscuit__manage {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition:
        max-height 340ms cubic-bezier(0.16, 0.84, 0.44, 1),
        opacity    220ms ease;
}
.lr-biscuit.is-expanded .lr-biscuit__manage {
    max-height: 620px;
    opacity: 1;
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--surface-border);
}

.lr-biscuit__cat {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-sm) 0;
    border-top: 1px solid var(--surface-border);
}
.lr-biscuit__cat:first-child { border-top: 0; padding-top: 0; }

.lr-biscuit__cat-info {
    flex: 1;
    min-width: 0;
}

.lr-biscuit__cat-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 13px;
    color: var(--text);
    margin: 0 0 2px;
}

.lr-biscuit__cat-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0;
}

.lr-biscuit__manage-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--surface-border);
}


/* Toggle slider (unchanged — reused by both biscuit and any admin panel) */
.toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
    cursor: pointer;
}
.toggle input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    margin: 0;
    cursor: pointer;
}
.toggle input:disabled { cursor: not-allowed; }

.toggle .track {
    display: block;
    width: 100%;
    height: 100%;
    background: var(--surface-border);
    border-radius: 999px;
    position: relative;
    transition: background var(--transition);
}

.toggle .thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #FFFFFF;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform var(--transition);
}

.toggle input:checked ~ .track {
    background: var(--color-secondary);
}
.toggle input:checked ~ .track .thumb {
    transform: translateX(18px);
}

.toggle input:disabled ~ .track {
    opacity: 0.55;
}
.toggle input:disabled:checked ~ .track {
    background: var(--surface-border);
    opacity: 0.7;
}
.toggle input:focus-visible ~ .track {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    border-radius: 999px;
}


/* Motion respect -------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .lr-biscuit,
    .lr-biscuit__manage,
    .lr-biscuit__actions .btn-primary,
    .toggle .track,
    .toggle .thumb {
        transition: none !important;
    }
}


/* Mobile — full-width buttons for thumb-reachability ------------------- */
@media (max-width: 500px) {
    .lr-biscuit {
        bottom: max(12px, env(safe-area-inset-bottom, 12px));
        padding: var(--space-md);
    }
    .lr-biscuit__actions {
        justify-content: stretch;
    }
    .lr-biscuit__actions .btn {
        flex: 1;
    }
}


/* ==========================================================================
   2. Storage-blocked notice

   Hidden by default. cookie.js flips `.is-visible` only when a probe
   write-then-read fails, so users whose browser stores cookies normally
   never see this element in any form.

   Amber accent — signals a real problem without shouting. Sits above the
   biscuit position so both can co-exist if the biscuit is also visible
   (a browser that blocks storage will typically also show the biscuit
   because `lr_consent` never persists — the two together make the
   situation legible).
========================================================================== */

.lr-storage-notice {
    position: fixed;
    /* Sits above the biscuit slot when both are visible. */
    bottom: calc(max(20px, env(safe-area-inset-bottom, 20px)) + 240px);
    left: 50%;
    z-index: 1001;

    width: min(480px, calc(100vw - 24px));
    max-width: 100%;

    display: none;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: var(--space-md);
    align-items: start;

    background: var(--bg-alt);
    color: var(--text);
    border: 1px solid #B58524;              /* warning amber, muted */
    border-top: 3px solid #B58524;
    border-radius: var(--r-card);

    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.35),
        0 4px 14px rgba(0, 0, 0, 0.20);

    padding: var(--space-lg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);

    transform: translateX(-50%);
}

.lr-storage-notice.is-visible {
    display: grid;
}

:root[data-theme="light"] .lr-storage-notice {
    background: #FFFFFF;
    box-shadow:
        0 16px 44px rgba(13, 45, 78, 0.14),
        0 3px 10px rgba(13, 45, 78, 0.08);
}

.lr-storage-notice__icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(181, 133, 36, 0.14);
    color: #B58524;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
:root[data-theme="light"] .lr-storage-notice__icon {
    background: rgba(181, 133, 36, 0.10);
}
.lr-storage-notice__icon svg { width: 20px; height: 20px; }

.lr-storage-notice__text { min-width: 0; }

.lr-storage-notice__title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
    margin: 0 0 4px;
    letter-spacing: -0.01em;
}

.lr-storage-notice__body {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-muted);
    margin: 0;
}
.lr-storage-notice__body strong { color: var(--text); }

/* Mobile — sit closer to the bottom edge and shrink the gap above the
   biscuit slot. */
@media (max-width: 500px) {
    .lr-storage-notice {
        bottom: calc(max(12px, env(safe-area-inset-bottom, 12px)) + 220px);
        padding: var(--space-md);
    }
}
