/*
 * Default install prompt / install links styles. Tokens first (REQ-UI-003): every --nowo-pwa-install-* token falls
 * back to the matching UiKit --nowo-ui-* token (set by nowo-ui.css or nowo_ui_kit.theme.tokens), then to the 1.x
 * value, so a host themes the prompt once through the UiKit tokens (or overrides a --nowo-pwa-install-* token).
 */
:root {
    --nowo-pwa-install-bg: var(--nowo-ui-surface, #0f172a);
    --nowo-pwa-install-color: var(--nowo-ui-text, #f8fafc);
    --nowo-pwa-install-border: var(--nowo-ui-border, transparent);
    --nowo-pwa-install-shadow: 0 10px 25px rgba(15, 23, 42, 0.25);
    --nowo-pwa-install-radius: var(--nowo-ui-radius, 0.75rem);
    --nowo-pwa-install-padding: 1rem 1.25rem;
    --nowo-pwa-install-panel-width: 28rem;
    --nowo-pwa-install-gap: 0.75rem;
    --nowo-pwa-install-brand-gap: 0.75rem;
    --nowo-pwa-install-mark-size: 2.5rem;
    --nowo-pwa-install-mark-radius: 0.75rem;
    --nowo-pwa-install-eyebrow-color: var(--nowo-ui-muted, #cbd5e1);
    --nowo-pwa-install-eyebrow-font-size: 0.75rem;
    --nowo-pwa-install-title-color: inherit;
    --nowo-pwa-install-title-font-size: 1.125rem;
    --nowo-pwa-install-message-color: var(--nowo-ui-muted, rgba(248, 250, 252, 0.92));
    --nowo-pwa-install-button-radius: var(--nowo-ui-radius, 0.375rem);
    --nowo-pwa-install-button-padding: 0.5rem 1rem;
    --nowo-pwa-install-button-font-weight: 600;
    --nowo-pwa-install-primary-bg: var(--nowo-ui-primary, #2563eb);
    --nowo-pwa-install-primary-color: var(--nowo-ui-primary-contrast, #ffffff);
    --nowo-pwa-install-secondary-bg: transparent;
    --nowo-pwa-install-secondary-color: var(--nowo-ui-muted, #cbd5e1);
    --nowo-pwa-install-backdrop-bg: rgba(15, 23, 42, 0.55);
    --nowo-pwa-install-z-index: 1050;
    --nowo-pwa-install-banner-max-width: 38rem;
    --nowo-pwa-install-banner-inset-x: 1rem;
    --nowo-pwa-install-banner-offset-bottom: 1rem;
    --nowo-pwa-install-banner-offset-top: 1rem;
    --nowo-pwa-install-flash-max-width: 42rem;
    --nowo-pwa-install-modal-padding: 1rem;
    --nowo-pwa-install-modal-panel-padding: 1.25rem 1.5rem;
    --nowo-pwa-install-eyebrow-font-weight: 700;
    --nowo-pwa-install-eyebrow-letter-spacing: 0.08em;
    --nowo-pwa-install-title-line-height: 1.25;
    --nowo-pwa-install-button-border-color: transparent;

    --nowo-pwa-install-links-gap: 0.5rem;
    --nowo-pwa-install-links-radius: var(--nowo-ui-radius, 0.375rem);
    --nowo-pwa-install-links-padding: 0.375rem 0.75rem;
    --nowo-pwa-install-links-font-size: 0.8125rem;
    --nowo-pwa-install-links-font-weight: 600;
    --nowo-pwa-install-links-line-height: 1.25;
    --nowo-pwa-install-links-install-bg: var(--nowo-ui-primary, #2563eb);
    --nowo-pwa-install-links-install-color: var(--nowo-ui-primary-contrast, #ffffff);
    --nowo-pwa-install-links-uninstall-bg: var(--nowo-ui-surface-muted, #e2e8f0);
    --nowo-pwa-install-links-uninstall-color: var(--nowo-ui-text, #0f172a);
}

/* Root: placement only (banner / flash / modal); the panel is the surface (theme slot `card`). */
.nowo-pwa-install {
    z-index: var(--nowo-pwa-install-z-index);
    color: var(--nowo-pwa-install-color);
}

.nowo-pwa-install[hidden] {
    display: none;
}

.nowo-pwa-install--banner {
    position: fixed;
    left: var(--nowo-pwa-install-banner-inset-x);
    right: var(--nowo-pwa-install-banner-inset-x);
    max-width: var(--nowo-pwa-install-banner-max-width);
    margin: 0 auto;
}

.nowo-pwa-install--banner.nowo-pwa-install--bottom {
    bottom: var(--nowo-pwa-install-banner-offset-bottom);
}

.nowo-pwa-install--banner.nowo-pwa-install--top {
    top: var(--nowo-pwa-install-banner-offset-top);
}

.nowo-pwa-install--flash {
    position: relative;
    max-width: var(--nowo-pwa-install-flash-max-width);
    margin: 0 0 1rem;
}

.nowo-pwa-install--modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--nowo-pwa-install-modal-padding);
}

.nowo-pwa-install--modal .nowo-pwa-install__backdrop {
    position: absolute;
    inset: 0;
    background: var(--nowo-pwa-install-backdrop-bg);
}

/* Two classes: the token paint wins over a framework `card` class whatever the stylesheet order. */
.nowo-pwa-install .nowo-pwa-install__panel {
    display: grid;
    gap: var(--nowo-pwa-install-gap);
    padding: var(--nowo-pwa-install-padding);
    color: var(--nowo-pwa-install-color);
    background: var(--nowo-pwa-install-bg);
    border: 1px solid var(--nowo-pwa-install-border);
    border-radius: var(--nowo-pwa-install-radius);
    box-shadow: var(--nowo-pwa-install-shadow);
}

.nowo-pwa-install--modal .nowo-pwa-install__panel {
    position: relative;
    z-index: 1;
    width: min(100%, var(--nowo-pwa-install-panel-width));
    padding: var(--nowo-pwa-install-modal-panel-padding);
}

.nowo-pwa-install__brand {
    display: flex;
    align-items: center;
    gap: var(--nowo-pwa-install-brand-gap);
}

.nowo-pwa-install__mark {
    display: block;
    width: var(--nowo-pwa-install-mark-size);
    height: var(--nowo-pwa-install-mark-size);
    object-fit: contain;
    border-radius: var(--nowo-pwa-install-mark-radius);
}

.nowo-pwa-install__text {
    display: grid;
    gap: 0.25rem;
}

.nowo-pwa-install .nowo-pwa-install__eyebrow {
    margin: 0;
    color: var(--nowo-pwa-install-eyebrow-color);
    font-size: var(--nowo-pwa-install-eyebrow-font-size);
    font-weight: var(--nowo-pwa-install-eyebrow-font-weight);
    letter-spacing: var(--nowo-pwa-install-eyebrow-letter-spacing);
    text-transform: uppercase;
}

.nowo-pwa-install .nowo-pwa-install__title {
    margin: 0;
    color: var(--nowo-pwa-install-title-color);
    font-size: var(--nowo-pwa-install-title-font-size);
    line-height: var(--nowo-pwa-install-title-line-height);
}

.nowo-pwa-install .nowo-pwa-install__message {
    margin: 0;
    color: var(--nowo-pwa-install-message-color);
}

.nowo-pwa-install .nowo-pwa-install__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--nowo-pwa-install-gap);
    margin: 0;
}

/* install_prompt.button_paint: host: layout only, the buttons carry just the host's slot classes. */
.nowo-pwa-install .nowo-pwa-install__actions-host {
    display: flex;
    flex-wrap: wrap;
    gap: var(--nowo-pwa-install-gap);
    margin: 0;
}

.nowo-pwa-install__button,
.nowo-pwa-install__actions button {
    padding: var(--nowo-pwa-install-button-padding);
    font-weight: var(--nowo-pwa-install-button-font-weight);
    border: 1px solid var(--nowo-pwa-install-button-border-color);
    border-radius: var(--nowo-pwa-install-button-radius);
    cursor: pointer;
}

.nowo-pwa-install__button--install,
.nowo-pwa-install__actions [data-pwa-install-action='install'] {
    color: var(--nowo-pwa-install-primary-color);
    background: var(--nowo-pwa-install-primary-bg);
}

.nowo-pwa-install__button--dismiss,
.nowo-pwa-install__button--never,
.nowo-pwa-install__actions [data-pwa-install-action='dismiss-remind'],
.nowo-pwa-install__actions [data-pwa-install-action='dismiss'],
.nowo-pwa-install__actions [data-pwa-install-action='dismiss-never'] {
    color: var(--nowo-pwa-install-secondary-color);
    background: var(--nowo-pwa-install-secondary-bg);
}

.nowo-pwa-install__button--dismiss {
    border-color: var(--nowo-pwa-install-border);
}

body.nowo-pwa-install-modal-open {
    overflow: hidden;
}

.nowo-pwa-install-links {
    display: inline-flex;
    align-items: center;
    gap: var(--nowo-pwa-install-links-gap);
    margin: 0;
}

.nowo-pwa-install-links a {
    display: inline-flex;
    align-items: center;
    padding: var(--nowo-pwa-install-links-padding);
    font-size: var(--nowo-pwa-install-links-font-size);
    font-weight: var(--nowo-pwa-install-links-font-weight);
    line-height: var(--nowo-pwa-install-links-line-height);
    text-decoration: none;
    border-radius: var(--nowo-pwa-install-links-radius);
}

.nowo-pwa-install-links__install {
    color: var(--nowo-pwa-install-links-install-color);
    background: var(--nowo-pwa-install-links-install-bg);
}

.nowo-pwa-install-links__uninstall {
    color: var(--nowo-pwa-install-links-uninstall-color);
    background: var(--nowo-pwa-install-links-uninstall-bg);
}

/* Push diagnostics panel (pwa/push_diagnostics.html.twig + Stimulus peer push-diagnostics). */
.nowo-pwa-push-diagnostics__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.5rem;
}

.nowo-pwa-push-check {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.nowo-pwa-push-check__icon {
    flex: 0 0 1.25rem;
    text-align: center;
    font-weight: 700;
}

.nowo-pwa-push-check--ok .nowo-pwa-push-check__icon { color: #15803d; }
.nowo-pwa-push-check--warn .nowo-pwa-push-check__icon { color: #b45309; }
.nowo-pwa-push-check--fail .nowo-pwa-push-check__icon { color: #b91c1c; }
.nowo-pwa-push-check--skip { opacity: 0.6; }

.nowo-pwa-push-check__body {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
}

.nowo-pwa-push-check__title { font-weight: 600; }

.nowo-pwa-push-check__detail {
    font-size: 0.75rem;
    overflow-wrap: anywhere;
    opacity: 0.75;
}

.nowo-pwa-push-diagnostics__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.nowo-pwa-push-diagnostics__test-result[data-state="ok"] { color: #15803d; }
.nowo-pwa-push-diagnostics__test-result[data-state="fail"] { color: #b91c1c; }

/* Browser hint banner (pwa/browser_hint.html.twig + Stimulus peer browser-hint). */
.nowo-pwa-browser-hint {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    background: rgba(15, 23, 42, 0.05);
}

.nowo-pwa-browser-hint[hidden],
.nowo-pwa-browser-guide__current[hidden] { display: none; }

.nowo-pwa-browser-hint__text { margin: 0; }

/*
 * Motion: UiKit's scale, read with own fallbacks. The prompt and its backdrop fade, the panel scales a little.
 * The close waits for this fade (motion.ts), then sets `hidden`. No `!important`, so a host's html[data-motion] rule wins.
 */
.nowo-pwa-install {
    --nowo-pwa-install-motion-open: var(--nowo-ui-motion-medium, 200ms);
    --nowo-pwa-install-motion-close: var(--nowo-ui-motion-medium-close, 150ms);
    --nowo-pwa-install-motion-scale: var(--nowo-ui-motion-scale, 0.98);
}

.nowo-pwa-install:not([hidden]) {
    animation: nowo-pwa-install-fade var(--nowo-pwa-install-motion-open) var(--nowo-ui-motion-ease-out, cubic-bezier(0.2, 0, 0, 1));
}

.nowo-pwa-install:not([hidden]) .nowo-pwa-install__panel {
    animation: nowo-pwa-install-scale var(--nowo-pwa-install-motion-open) var(--nowo-ui-motion-ease-out, cubic-bezier(0.2, 0, 0, 1));
}

.nowo-pwa-install[data-nowo-pwa-closing] {
    animation: none;
    opacity: 0;
    transition: opacity var(--nowo-pwa-install-motion-close) var(--nowo-ui-motion-ease-in, cubic-bezier(0.4, 0, 1, 1));
}

.nowo-pwa-install[data-nowo-pwa-closing] .nowo-pwa-install__panel {
    animation: none;
    transform: scale(var(--nowo-pwa-install-motion-scale));
    transition: transform var(--nowo-pwa-install-motion-close) var(--nowo-ui-motion-ease-in, cubic-bezier(0.4, 0, 1, 1));
}

@keyframes nowo-pwa-install-fade {
    from {
        opacity: 0;
    }
}

@keyframes nowo-pwa-install-scale {
    from {
        transform: scale(var(--nowo-pwa-install-motion-scale));
    }
}

/* Reduced motion keeps a short fade and no movement; html[data-motion='full'] keeps the full effect. */
@media (prefers-reduced-motion: reduce) {
    html:not([data-motion='full']) .nowo-pwa-install {
        --nowo-pwa-install-motion-open: var(--nowo-ui-motion-medium, 80ms);
        --nowo-pwa-install-motion-close: var(--nowo-ui-motion-medium-close, 80ms);
        --nowo-pwa-install-motion-scale: 1;
    }
}

[data-motion='reduce'] .nowo-pwa-install {
    --nowo-pwa-install-motion-open: var(--nowo-ui-motion-medium, 80ms);
    --nowo-pwa-install-motion-close: var(--nowo-ui-motion-medium-close, 80ms);
    --nowo-pwa-install-motion-scale: 1;
}
