/*
 * WWU PWA Manager — frontend banner styles (install + offline).
 *
 * Scoped under .wwu-pwa-banner / .wwu-pwa-offline-banner so we don't bleed
 * into the theme. Mobile-first, respects safe-area-inset for iPhone notch.
 *
 * Trap #19 from CLAUDE.md: every selector with `display:` declared has a
 * paired `[hidden]` rule so element.hidden=true actually hides it even
 * with `display: flex/block` author CSS overriding the UA `[hidden]` rule.
 */

/* ─── Banner container ────────────────────────────────────────────── */

.wwu-pwa-banner {
    position: fixed;
    left: 16px;
    right: 16px;
    z-index: 99998;
    max-width: 480px;
    margin-inline: auto;
    background: #fff;
    color: #1d2327;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18), 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 16px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wwu-pwa-banner[hidden] {
    /* Trap #19 paired rule. */
    display: none !important;
}

.wwu-pwa-banner--bottom {
    bottom: max(16px, env(safe-area-inset-bottom));
}

.wwu-pwa-banner--top {
    top: max(16px, env(safe-area-inset-top));
}

.wwu-pwa-banner--theme-dark {
    background: #1d2327;
    color: #f0f0f1;
}

.wwu-pwa-banner--theme-auto {
    background: #fff;
    color: #1d2327;
}

@media (prefers-color-scheme: dark) {
    .wwu-pwa-banner--theme-auto {
        background: #1d2327;
        color: #f0f0f1;
    }
}

.wwu-pwa-banner__close {
    position: absolute;
    top: 6px;
    right: 6px;
    /* Touch target ≥40×40 — Apple HIG / WCAG 2.5.5 (audit M1 fix). */
    width: 40px;
    height: 40px;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    opacity: 0.6;
    display: flex;
    align-items: center;
    justify-content: center;
}
.wwu-pwa-banner__close:hover,
.wwu-pwa-banner__close:focus {
    opacity: 1;
    background: rgba(0, 0, 0, 0.08);
}

.wwu-pwa-banner__body {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.wwu-pwa-banner__body[hidden] {
    display: none !important;
}

.wwu-pwa-banner__text {
    flex: 1 1 auto;
    min-width: 0;
}

.wwu-pwa-banner__text strong {
    display: block;
    font-size: 15px;
    margin-bottom: 4px;
}

.wwu-pwa-banner__text p {
    margin: 0;
    color: inherit;
    opacity: 0.85;
}

.wwu-pwa-banner__actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.wwu-pwa-banner__actions[hidden] {
    display: none !important;
}

.wwu-pwa-banner__cta {
    background: #0a8a3e;
    color: #fff;
    border: 0;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    min-height: 40px; /* Apple HIG touch target */
}
.wwu-pwa-banner__cta:hover,
.wwu-pwa-banner__cta:focus {
    background: #086e30;
}

.wwu-pwa-banner__cta-secondary {
    background: transparent;
    color: inherit;
    border: 1px solid currentColor;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    opacity: 0.7;
    min-height: 40px;
}
.wwu-pwa-banner__cta-secondary:hover,
.wwu-pwa-banner__cta-secondary:focus {
    opacity: 1;
}

/* ─── iOS install instructions specifics ──────────────────────────── */

.wwu-pwa-banner__steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wwu-pwa-banner__steps[hidden] {
    display: none !important;
}

.wwu-pwa-banner__steps li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.wwu-pwa-banner__step-num {
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #0a8a3e;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
}

.wwu-pwa-banner__step-text {
    flex: 1 1 auto;
}

.wwu-pwa-banner__share-icon {
    flex: 0 0 28px;
    color: #007aff; /* iOS blue */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Subtle bounce on the share icon arrow to draw attention. */
.wwu-pwa-banner__share-svg {
    overflow: visible;
}
.wwu-pwa-banner__share-arrow {
    animation: wwu-pwa-bounce 2s ease-in-out infinite;
    transform-origin: center;
}

@keyframes wwu-pwa-bounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
    .wwu-pwa-banner__share-arrow {
        animation: none;
    }
}

/* ─── Install button shortcode ────────────────────────────────────── */

.wwu-pwa-install-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    min-height: 44px; /* Apple HIG / WCAG 2.5.5 touch target */
    border: 0;
    border-radius: 6px;
    background: #0a8a3e;
    color: #fff;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease;
}
.wwu-pwa-install-button:hover {
    background: #086e30;
}
/* Audit JS H1 fix: focus outline only on keyboard focus (not mouse hover),
   contrasted dark color so it's visible against the green button background. */
.wwu-pwa-install-button:focus {
    outline: 2px solid #1d2327;
    outline-offset: 2px;
}
.wwu-pwa-install-button:focus:not(:focus-visible) {
    /* Hide outline when focus came from mouse click (not keyboard). */
    outline: none;
}
.wwu-pwa-install-button:focus-visible {
    outline: 3px solid #1d2327;
    outline-offset: 2px;
}
.wwu-pwa-install-button:active {
    transform: translateY(1px);
}

.wwu-pwa-install-button--secondary {
    background: transparent;
    color: #0a8a3e;
    border: 2px solid #0a8a3e;
}
.wwu-pwa-install-button--secondary:hover {
    background: #0a8a3e;
    color: #fff;
}
.wwu-pwa-install-button--secondary:focus-visible {
    outline: 3px solid #086e30;
    outline-offset: 2px;
}

.wwu-pwa-install-button--minimal {
    background: transparent;
    color: inherit;
    padding: 8px 12px;
    font-weight: 500;
    text-decoration: underline;
}
.wwu-pwa-install-button--minimal:hover {
    /* color-mix adapts to current text color → works on light + dark themes. */
    background: color-mix(in srgb, currentColor 8%, transparent);
    text-decoration: none;
}
/* Fallback for browsers without color-mix support (~Safari < 16.2): rgba black. */
@supports not (background: color-mix(in srgb, currentColor 8%, transparent)) {
    .wwu-pwa-install-button--minimal:hover {
        background: rgba(127, 127, 127, 0.12);
    }
}
.wwu-pwa-install-button--minimal:focus-visible {
    outline: 3px solid currentColor;
    outline-offset: 2px;
}

/* Auto-hide when PWA is installed (display-mode: standalone covers
   Chrome/Edge/Android, navigator.standalone covers iOS — JS belt-and-
   suspenders adds `hidden` attribute on top). */
@media (display-mode: standalone) {
    .wwu-pwa-install-button {
        display: none !important;
    }
}

/* iOS standalone — `display-mode: standalone` is supported only iOS 16.4+,
   so on older iOS we rely on the JS `navigator.standalone` check that adds
   the [hidden] attribute. */
.wwu-pwa-install-button[hidden] {
    display: none !important;
}

/* ─── Chrome menu instructions modal ──────────────────────────────── */

/* Re-uses .wwu-pwa-banner base styles. Just tints the menu icon Chrome-blue. */
.wwu-pwa-banner__menu-icon {
    flex: 0 0 28px;
    color: #4285f4; /* Google blue */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Subtle pulse on the menu dots to draw attention. */
.wwu-pwa-banner__menu-svg circle {
    animation: wwu-pwa-menu-pulse 2s ease-in-out infinite;
}
.wwu-pwa-banner__menu-svg circle:nth-child(1) { animation-delay: 0s; }
.wwu-pwa-banner__menu-svg circle:nth-child(2) { animation-delay: 0.2s; }
.wwu-pwa-banner__menu-svg circle:nth-child(3) { animation-delay: 0.4s; }

@keyframes wwu-pwa-menu-pulse {
    0%, 100% { opacity: 0.4; }
    50%      { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .wwu-pwa-banner__menu-svg circle {
        animation: none;
        opacity: 1;
    }
}

/* ─── Offline banner ──────────────────────────────────────────────── */

.wwu-pwa-offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 99999;
    background: #b32d2e;
    color: #fff;
    padding: max(8px, env(safe-area-inset-top)) 16px 8px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    line-height: 1.4;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.wwu-pwa-offline-banner[hidden] {
    display: none !important;
}

.wwu-pwa-offline-banner__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fff;
    animation: wwu-pwa-pulse 1.5s ease-in-out infinite;
    flex: 0 0 auto;
}

@keyframes wwu-pwa-pulse {
    0%, 100% { opacity: 0.4; }
    50%      { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .wwu-pwa-offline-banner__dot {
        animation: none;
        opacity: 1;
    }
}
