/*
 * Sapphire consent banner (Consent library, phase 1 of the ads work).
 * Colours come from the skin's own tokens when it has them and fall back to a neutral light theme otherwise; a skin
 * may override any --sapphire-consent-* property. Logical properties only, so a right-to-left page (Hebrew) mirrors
 * the layout by itself. The banner is a non-modal region: the page stays usable while it is open.
 */
/* Defaults at zero specificity (:where), so a skin's own `.sapphire-consent { --sapphire-consent-…: … }` wins whatever
   the order of the stylesheets. */
:where(.sapphire-consent) {
    --sapphire-consent-bg: var(--sapphire-bg-panel, #ffffff);
    --sapphire-consent-fg: var(--sapphire-text, #1b2330);
    --sapphire-consent-muted: var(--sapphire-text-muted, var(--sapphire-text-soft, #5b6575));
    --sapphire-consent-line: var(--sapphire-line, rgba(27, 35, 48, 0.16));
    --sapphire-consent-accent: var(--sapphire-blue, #2563eb);
    --sapphire-consent-accent-fg: var(--sapphire-on-accent, #ffffff);
    --sapphire-consent-radius: 14px;
    z-index: 99999;
}

.sapphire-consent {
    position: fixed;
    inset-inline: 16px;
    inset-block-end: 16px;
    display: flex;
    justify-content: center;
    pointer-events: none;
    font: inherit;
}

.sapphire-consent[hidden] {
    display: none;
}

.sapphire-consent__box {
    pointer-events: auto;
    box-sizing: border-box;
    inline-size: 100%;
    max-inline-size: 720px;
    max-block-size: calc(100vh - 32px);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 20px 22px;
    background: var(--sapphire-consent-bg);
    color: var(--sapphire-consent-fg);
    border: 1px solid var(--sapphire-consent-line);
    border-radius: var(--sapphire-consent-radius);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.sapphire-consent__title {
    margin: 0 0 6px;
    font-size: 1.05rem;
    font-weight: 700;
}

.sapphire-consent__text {
    margin: 0 0 14px;
    font-size: 0.93rem;
    line-height: 1.5;
    color: var(--sapphire-consent-muted);
}

.sapphire-consent__text a {
    color: var(--sapphire-consent-accent);
    text-decoration: underline;
}

.sapphire-consent__settings {
    display: grid;
    gap: 10px;
    margin: 0 0 14px;
    padding: 12px 14px;
    border: 1px solid var(--sapphire-consent-line);
    border-radius: 10px;
}

.sapphire-consent__settings[hidden] {
    display: none;
}

.sapphire-consent__option {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 10px;
    align-items: start;
    cursor: pointer;
}

.sapphire-consent__option input {
    margin: 3px 0 0;
    inline-size: 18px;
    block-size: 18px;
    accent-color: var(--sapphire-consent-accent);
}

.sapphire-consent__option-name {
    font-weight: 600;
}

.sapphire-consent__option-help {
    grid-column: 2;
    font-size: 0.85rem;
    color: var(--sapphire-consent-muted);
}

.sapphire-consent__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

/* Refusing is exactly as easy and as visible as accepting: both are full buttons of the same size. */
.sapphire-consent__button {
    flex: 0 1 auto;
    min-block-size: 40px;
    padding: 8px 16px;
    font: inherit;
    font-weight: 600;
    border-radius: 9px;
    border: 1px solid var(--sapphire-consent-accent);
    background: transparent;
    color: var(--sapphire-consent-fg);
    cursor: pointer;
}

.sapphire-consent__button--primary {
    background: var(--sapphire-consent-accent);
    color: var(--sapphire-consent-accent-fg);
}

.sapphire-consent__button[hidden] {
    display: none;
}

.sapphire-consent__button:focus-visible,
.sapphire-consent__option input:focus-visible,
.sapphire-consent__text a:focus-visible {
    outline: 2px solid var(--sapphire-consent-accent);
    outline-offset: 2px;
}

@media (max-width: 560px) {
    .sapphire-consent {
        inset-inline: 8px;
        inset-block-end: 8px;
    }

    .sapphire-consent__box {
        padding: 16px;
    }

    .sapphire-consent__actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    /* Refuse and accept side by side, equal; "Settings" (or "Save my choice") on its own row below them. */
    .sapphire-consent__button--settings,
    .sapphire-consent__button[data-consent-action="save"] {
        grid-column: 1 / -1;
        order: 1;
    }
}

/* "Cookie settings" in the footer: reopens the choice, so withdrawing is as easy as granting. */
.sapphire-consent-open {
    margin: 0;
}

.sapphire-consent-open button {
    padding: 0;
    font: inherit;
    font-size: 0.9em;
    color: inherit;
    background: none;
    border: 0;
    text-decoration: underline;
    cursor: pointer;
}

.sapphire-consent-open button:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}
