/*
 * Web app (PWA) www.sextasks.com / www.erotickahra.cz – loaded on every page of the website.
 * The app rules are scoped to html.pwa (only the installed app, see includes/controls/control_pwa_head.php);
 * the website in a browser only gets the "add to home screen" banner and the landscape safe areas below.
 */

.pwa-tabbar { display: none; }

/* ---------- Website in a browser: viewport-fit=cover (index.php) lets the page run under the notch in landscape ---------- */
html:not(.pwa) .navbar-fixed-top {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}
html:not(.pwa) body > .container,
html:not(.pwa) .footer > .container {
    padding-left: max(15px, env(safe-area-inset-left));
    padding-right: max(15px, env(safe-area-inset-right));
}

/* ---------- Left out of the app: dating, photos, users, messages ---------- */
html.pwa .pwa-hide { display: none !important; }
html.pwa a.pwa-link-off { cursor: default; text-decoration: none; }

/* ---------- Safe areas (notch, home indicator, landscape) ---------- */
html.pwa .navbar-fixed-top {
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}
html.pwa body { margin-top: calc(52px + env(safe-area-inset-top)); }
html.pwa body > .container,
html.pwa .footer > .container {
    padding-left: max(15px, env(safe-area-inset-left));
    padding-right: max(15px, env(safe-area-inset-right));
}
html.pwa body { overflow-x: clip; } /* clip, not hidden: no extra scroll container (iOS standalone) */
html.pwa body { -webkit-tap-highlight-color: transparent; }

/* ---------- Bottom tab bar (logged-in players, phones and tablets) ---------- */
@media (max-width: 991px) {
    html.pwa[data-pwa-member] .pwa-tabbar {
        display: flex;
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
        gap: 4px;
        padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
        background: #201826; /* solid: no backdrop-filter on a fixed bar (iOS standalone) */
        border-top: 1px solid rgba(255, 255, 255, .08);
        box-shadow: 0 -8px 24px rgba(20, 10, 30, .22);
        font-family: Poppins, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    }
    /* the bar continues below its box, so no page shows under it whatever iOS thinks the viewport height is */
    html.pwa[data-pwa-member] .pwa-tabbar::after { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 120px; background: inherit; }
    html.pwa[data-pwa-member] body { margin-bottom: calc(80px + env(safe-area-inset-bottom)); }
    /* the tab bar replaces the footer (copyright + social icons) and the messages/user icons */
    html.pwa[data-pwa-member] footer.footer,
    html.pwa[data-pwa-member] .navbar-icon-user { display: none !important; }

    .pwa-tab {
        flex: 1 1 0; min-width: 0; min-height: 52px;
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
        border-radius: 14px;
        color: rgba(255, 255, 255, .62);
        font-size: 11px; font-weight: 600; letter-spacing: .02em; line-height: 1.1;
        text-decoration: none !important;
        transition: color .15s ease, background-color .15s ease;
    }
    .pwa-tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .pwa-tab .fa { font-size: 21px; line-height: 1; }
    .pwa-tab:hover, .pwa-tab:focus { color: #fff; }
    .pwa-tab:active { background: rgba(255, 255, 255, .06); }
    .pwa-tab.active { color: #fff; background: linear-gradient(135deg, rgba(156, 2, 167, .38) 0%, rgba(214, 36, 159, .38) 100%); }
    .pwa-tab.active .fa { color: #f7a8ff; }
    .pwa-tab:focus-visible { outline: 2px solid #f7a8ff; outline-offset: -2px; }

    /* ---------- Playing: big, easy to hit answer buttons ---------- */
    html.pwa #answer_column .btn.full-width {
        min-height: 60px;
        border-radius: 18px !important;
        font-size: 22px !important;
        font-weight: 700;
        white-space: normal;
    }
    html.pwa #answer_column .btn.full-width + .btn.full-width,
    html.pwa #answer_column form + form .btn.full-width { margin-top: 12px !important; }
    html.pwa .pl-actions .btn { min-width: 56px; min-height: 52px; }
    html.pwa .btn-lg { min-height: 48px; }
}

/* ---------- "Add to home screen" banner (mobile website only) ---------- */
.pwa-install {
    position: fixed; z-index: 1045;
    left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 6px 14px 14px;
    border-radius: 18px;
    background: #2b2733; color: #fff;
    box-shadow: 0 14px 40px rgba(20, 10, 30, .38);
    font-family: Poppins, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px; line-height: 1.4;
    animation: pwa-install-in .35s ease-out both;
}
.pwa-install-icon { flex: 0 0 44px; width: 44px; height: 44px; }
.pwa-install-text { flex: 1 1 auto; min-width: 0; }
.pwa-install-text strong { display: block; font-size: 15px; margin-bottom: 2px; }
.pwa-install-text span { display: block; color: rgba(255, 255, 255, .75); }
.pwa-install-text b { color: #fff; }
.pwa-install-text svg { width: 15px; height: 15px; vertical-align: -2px; margin: 0 1px; }
.pwa-install-btn {
    display: inline-block; margin-top: 10px;
    border: 0; border-radius: 999px; padding: 10px 22px; min-height: 44px;
    font: inherit; font-size: 14px; font-weight: 700; color: #fff; cursor: pointer;
    background: linear-gradient(135deg, #9c02a7 0%, #d6249f 100%);
}
.pwa-install-close {
    flex: 0 0 44px; width: 44px; height: 44px; border: 0; padding: 0; cursor: pointer;
    margin-top: -10px;
    background: transparent; color: rgba(255, 255, 255, .6); font-size: 26px; line-height: 44px;
}
.pwa-install-close:hover, .pwa-install-close:focus { color: #fff; }
@media (min-width: 600px) {
    .pwa-install { left: auto; right: 20px; width: 400px; }
}
@keyframes pwa-install-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    .pwa-install { animation: none; }
    .pwa-tab { transition: none; }
}


/* ---------- Loader (pwa.js): bar at the top right away, spinner card when it takes longer; never blocks touches ---------- */
.pwa-loader { position: fixed; inset: 0; z-index: 2000; pointer-events: none; visibility: hidden; }
.pwa-loader.on { visibility: visible; }
.pwa-loader-bar {
    position: absolute; left: 0; right: 0; top: env(safe-area-inset-top); height: 3px; overflow: hidden;
    background: rgba(214, 36, 159, .18);
}
.pwa-loader-bar::before {
    content: ''; position: absolute; top: 0; bottom: 0; left: -40%; width: 40%;
    background: linear-gradient(90deg, #9c02a7, #d6249f, #f7a8ff);
    animation: pwa-loader-bar 1.1s ease-in-out infinite;
}
.pwa-loader-card {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(.92);
    display: flex; align-items: center; gap: 12px;
    padding: 14px 20px; border-radius: 18px;
    background: rgba(43, 39, 51, .92); color: #fff;
    box-shadow: 0 14px 40px rgba(20, 10, 30, .35);
    font-family: Poppins, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 15px; font-weight: 600;
    opacity: 0; transition: opacity .2s ease, transform .2s ease;
}
.pwa-loader.spin .pwa-loader-card { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.pwa-loader-spin {
    width: 22px; height: 22px; border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, .25); border-top-color: #f7a8ff;
    animation: pwa-loader-spin .8s linear infinite;
}
@keyframes pwa-loader-bar { 0% { left: -40%; } 100% { left: 100%; } }
@keyframes pwa-loader-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .pwa-loader-bar::before { animation-duration: 2.5s; }
    .pwa-loader-spin { animation-duration: 1.6s; }
}
