/**
 * Kirby Newsletter Reminder Banner
 *
 * Scoped under .nl-banner — no resets, no framework, no global styles.
 * Colors meet WCAG AA in both light and dark mode.
 */

.nl-banner {
    /**
     * Design token adoption.
     *
     * Each value first looks for a host design token of the usual name and
     * only falls back to the built-in palette when the site does not define
     * one. On a site whose tokens are theme-aware (light-dark(), a
     * [data-theme] switch, …) the banner follows the active theme for free —
     * including a manual toggle, which a plain prefers-color-scheme block
     * could never see.
     */
    --nlb-bg: var(--color-surface, #ffffff);
    --nlb-fg: var(--color-ink, #16181d);
    --nlb-muted: var(--color-muted, #5b6270);
    --nlb-border: var(--color-border, rgba(16, 18, 24, 0.10));
    --nlb-accent: var(--color-accent, #1a1d24);
    --nlb-accent-fg: var(--color-accent-ink, #ffffff);
    --nlb-accent-hover: var(--color-accent-hover, #32363f);
    --nlb-ghost-hover: rgba(128, 128, 128, 0.12);
    --nlb-focus: var(--color-accent, #2563eb);
    --nlb-shadow: var(--shadow-card-hover,
        0 1px 2px rgba(16, 18, 24, 0.06),
        0 12px 32px -8px rgba(16, 18, 24, 0.22));
    --nlb-radius: 14px;
    --nlb-radius-button: 9px;
    --nlb-font-ui: var(--font-heading, inherit);

    position: fixed;
    z-index: 2147483000; /* above sticky headers, below nothing sensible */
    inset-inline: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    padding: clamp(0.75rem, 2vw, 1.5rem);
    padding-bottom: calc(clamp(0.75rem, 2vw, 1.5rem) + env(safe-area-inset-bottom, 0px));
    pointer-events: none; /* the wrapper must not block the page */

    font-family: inherit;
    line-height: 1.5;
    color: var(--nlb-fg);

    opacity: 0;
    transform: translateY(115%);
    transition:
        transform 320ms cubic-bezier(0.16, 1, 0.3, 1),
        opacity 240ms ease;
    will-change: transform, opacity;
}

.nl-banner[hidden] {
    display: none;
}

.nl-banner.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.nl-banner__inner {
    pointer-events: auto;
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: clamp(0.75rem, 2vw, 1.5rem);
    width: min(46rem, 100%);
    padding: 1.125rem 3rem 1.125rem 1.375rem;

    background: var(--nlb-bg);
    border: 1px solid var(--nlb-border);
    border-radius: var(--nlb-radius);
    box-shadow: var(--nlb-shadow);
}

.nl-banner__content {
    flex: 1 1 16rem;
    min-width: 0;
}

.nl-banner__title {
    margin: 0;
    font-size: 0.9375rem;
    font-family: var(--nlb-font-ui);
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--nlb-fg);
}

.nl-banner__text {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: var(--nlb-muted);
}

.nl-banner__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

/* Buttons ---------------------------------------------------------- */

.nl-banner__button {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.375rem;
    padding: 0.5rem 0.9375rem;

    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;

    border: 1px solid transparent;
    border-radius: var(--nlb-radius-button);
    font-family: var(--nlb-font-ui);
    cursor: pointer;
    transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.nl-banner__button--ghost {
    color: var(--nlb-fg);
    background: transparent;
    border-color: var(--nlb-border);
}

.nl-banner__button--ghost:hover {
    background: var(--nlb-ghost-hover);
}

.nl-banner__button--primary {
    color: var(--nlb-accent-fg);
    background: var(--nlb-accent);
}

.nl-banner__button--primary:hover {
    background: var(--nlb-accent-hover);
}

.nl-banner__close {
    position: absolute;
    top: 0.5rem;
    inset-inline-end: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;

    color: var(--nlb-muted);
    background: transparent;
    border: 0;
    border-radius: var(--nlb-radius-button);
    cursor: pointer;
    transition: background-color 140ms ease, color 140ms ease;
}

.nl-banner__close:hover {
    color: var(--nlb-fg);
    background: var(--nlb-ghost-hover);
}

/* Focus ------------------------------------------------------------ */

.nl-banner :focus-visible {
    outline: 2px solid var(--nlb-focus);
    outline-offset: 2px;
}

/* Fallback for browsers without :focus-visible */
.nl-banner__button:focus,
.nl-banner__close:focus {
    outline: 2px solid var(--nlb-focus);
    outline-offset: 2px;
}

.nl-banner__button:focus:not(:focus-visible),
.nl-banner__close:focus:not(:focus-visible) {
    outline: none;
}

/* Small screens ---------------------------------------------------- */

@media (max-width: 34rem) {
    .nl-banner__inner {
        align-items: stretch;
        padding-right: 1.375rem;
        padding-top: 2.25rem;
    }

    .nl-banner__actions {
        width: 100%;
    }

    .nl-banner__button {
        flex: 1 1 100%;
        white-space: normal;
    }
}

/* Dark mode -------------------------------------------------------- */

@media (prefers-color-scheme: dark) {
    .nl-banner {
        --nlb-bg: var(--color-surface, #14161b);
        --nlb-fg: var(--color-ink, #f2f4f7);
        --nlb-muted: var(--color-muted, #a2aab8);
        --nlb-border: var(--color-border, rgba(255, 255, 255, 0.12));
        --nlb-accent: var(--color-accent, #f2f4f7);
        --nlb-accent-fg: var(--color-accent-ink, #14161b);
        --nlb-accent-hover: var(--color-accent-hover, #d9dde4);
        --nlb-focus: var(--color-accent, #7aa2ff);
        --nlb-shadow: var(--shadow-card-hover, 0 16px 40px -12px rgba(0, 0, 0, 0.65));
    }
}

/* Motion preferences ----------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .nl-banner {
        transform: none;
        transition: opacity 120ms linear;
    }

    .nl-banner.is-visible {
        transform: none;
    }

    .nl-banner__button,
    .nl-banner__close {
        transition: none;
    }
}

/* High contrast ---------------------------------------------------- */

@media (forced-colors: active) {
    .nl-banner__inner {
        border: 1px solid CanvasText;
    }

    .nl-banner__button {
        border: 1px solid ButtonText;
    }
}
