/*
 * SviyNews — interface states shared by all themes (menus, notices, installed app)
 * Copyright 2026 SviySoft. All Rights Reserved.
 * Solid colours only.
 */

/* ---------- Desktop menus: keyboard and touch open the same lists as hover ---------- */
@media (min-width: 992px) {
    .mega-menu-wrapper .has-megamenu.is-open .megamenu,
    .mega-menu-wrapper .has-megamenu:focus-within .megamenu,
    .mega-menu-wrapper .nav-item.dropdown.is-open > .dropdown-menu,
    .mega-menu-wrapper .nav-item.dropdown:focus-within > .dropdown-menu {
        display: block;
        animation: none;
        margin-top: 0;
    }

    /* Escape closes the list even while the item keeps the focus or the mouse */
    .mega-menu-wrapper .has-megamenu.is-dismissed .megamenu,
    .mega-menu-wrapper .nav-item.dropdown.is-dismissed > .dropdown-menu {
        display: none;
    }

    .mega-menu-wrapper .dropdown-submenu:focus-within > .dropdown-menu,
    .mega-menu-wrapper .dropdown-submenu:focus-within > .submenu {
        display: block;
    }
}

/* Visible focus for keyboard users, invisible for mouse and touch */
.mega-menu-wrapper a:focus-visible,
.mobile-nav-wrapper a:focus-visible,
.mobile-nav-wrapper button:focus-visible,
.header-btn:focus-visible,
#header-search-btn:focus-visible {
    outline: 2px solid var(--sviynews-theme-color, #0a84ff);
    outline-offset: 2px;
    border-radius: 6px;
}

/* ---------- Mobile menu: long menus scroll inside, the page behind does not ---------- */
.mobile-nav-wrapper .offcanvas {
    overscroll-behavior: contain;
}

.mobile-nav-wrapper .offcanvas-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* ---------- Notice at the bottom of the screen (offline, install hint) ---------- */
.sn-notice {
    position: fixed;
    left: 50%;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    z-index: 2000;
    max-width: calc(100vw - 32px);
    padding: 12px 18px;
    border-radius: 12px;
    background: #1d1d1f;
    color: #ffffff;
    font-size: 14px;
    line-height: 1.45;
    text-align: center;
    box-shadow: 0 10px 30px -12px #000000;
    transform: translate(-50%, 140%);
    visibility: hidden;
    transition: transform .25s ease, visibility 0s linear .25s;
}

.sn-notice.show {
    transform: translate(-50%, 0);
    visibility: visible;
    transition: transform .25s ease;
}

html[data-bs-theme="dark"] .sn-notice {
    background: #f5f5f7;
    color: #1d1d1f;
}

/* ---------- Installed app (PWA) ---------- */
.sn-header-start {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* With the back button the logo stays exactly in the centre */
.mobile-nav-wrapper .mobile-header:has(.sn-header-start) {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
}

.mobile-nav-wrapper .mobile-header:has(.sn-header-start) > :last-child {
    justify-self: end;
}

html.is-pwa .mobile-nav-wrapper .mobile-header {
    padding-left: calc(0.5rem + env(safe-area-inset-left, 0px));
    padding-right: calc(0.5rem + env(safe-area-inset-right, 0px));
}

html.is-pwa body {
    padding-bottom: env(safe-area-inset-bottom, 0px);
    -webkit-tap-highlight-color: transparent;
}

html.is-pwa .offcanvas {
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Pull to refresh indicator */
.sn-ptr {
    position: fixed;
    top: 0;
    left: 50%;
    z-index: 1050;
    width: 40px;
    height: 40px;
    margin-top: calc(10px + env(safe-area-inset-top, 0px));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    color: #6e6e73;
    box-shadow: 0 4px 14px -4px #8e8e93;
    transform: translate(-50%, -60px);
    visibility: hidden;
    pointer-events: none;
}

.sn-ptr.visible {
    visibility: visible;
}

.sn-ptr.ready {
    color: var(--sviynews-theme-color, #0a84ff);
}

.sn-ptr.loading svg {
    animation: sn-spin .8s linear infinite;
}

html[data-bs-theme="dark"] .sn-ptr {
    background: #2c2c2e;
    color: #98989d;
    box-shadow: none;
}

@keyframes sn-spin {
    to {
        transform: rotate(360deg);
    }
}

/* "Install app" item in the mobile menu */
.sn-install-app[hidden] {
    display: none !important;
}

@media (prefers-reduced-motion: reduce) {
    .sn-notice,
    .sn-notice.show {
        transition: none;
    }

    .sn-ptr.loading svg {
        animation: none;
    }
}

.mobile-nav-wrapper .sn-install-app {
    width: 100%;
    margin-bottom: 10px;
    border: 0;
    font: inherit;
    color: inherit;
    text-align: start;
    cursor: pointer;
}

/* Classic: a small gap between the fixed mobile header and the first homepage block */
@media (max-width: 991.98px) {
    html[data-theme="classic"] .body-index-page .mobile-header-spacer {
        margin-bottom: 12px;
    }
}

.js-native-share[hidden] {
    display: none !important;
}

/* ---------- Push notifications ---------- */
.js-push-toggle[hidden] {
    display: none !important;
}

.mobile-nav-wrapper .sn-push-item {
    width: 100%;
    margin-bottom: 10px;
    border: 0;
    font: inherit;
    color: inherit;
    text-align: start;
    cursor: pointer;
}

.mobile-nav-wrapper .sn-push-item .theme-switcher {
    pointer-events: none;
}

.sn-push-hint {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.35;
    color: #86868b;
}

.sn-push-bell .sn-bell-off,
.sn-push-bell[data-state="on"] .sn-bell-on {
    display: inline;
}

.sn-push-bell .sn-bell-on,
.sn-push-bell[data-state="on"] .sn-bell-off {
    display: none;
}

.sn-push-bell[data-state="on"] {
    color: var(--sviynews-theme-color, #0a84ff) !important;
}

.sn-push-prompt {
    position: fixed;
    right: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    z-index: 1990;
    display: flex;
    gap: 14px;
    width: 360px;
    max-width: calc(100vw - 32px);
    padding: 18px;
    border: 1px solid #e5e5ea;
    border-radius: 16px;
    background: #ffffff;
    color: #1d1d1f;
    box-shadow: 0 18px 40px -18px #3a3a3c;
    transform: translateY(140%);
    visibility: hidden;
    transition: transform .3s ease, visibility 0s linear .3s;
}

.sn-push-prompt.show {
    transform: translateY(0);
    visibility: visible;
    transition: transform .3s ease;
}

.sn-push-prompt-icon {
    flex: 0 0 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sviynews-theme-color, #0a84ff);
    color: #ffffff;
}

.sn-push-prompt strong {
    display: block;
    font-size: 15px;
    margin-bottom: 4px;
}

.sn-push-prompt p {
    margin: 0 0 12px;
    font-size: 13.5px;
    line-height: 1.45;
    color: #6e6e73;
}

.sn-push-prompt-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.sn-push-prompt-actions button {
    border: 0;
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.sn-push-later {
    background: #f2f2f7;
    color: #1d1d1f;
}

.sn-push-allow {
    background: var(--sviynews-theme-color, #0a84ff);
    color: #ffffff;
}

html[data-bs-theme="dark"] .sn-push-prompt {
    border-color: #2c2c2e;
    background: #1c1c1e;
    color: #f5f5f7;
    box-shadow: none;
}

html[data-bs-theme="dark"] .sn-push-prompt p {
    color: #98989d;
}

html[data-bs-theme="dark"] .sn-push-later {
    background: #2c2c2e;
    color: #f5f5f7;
}

@media (max-width: 575.98px) {
    .sn-push-prompt {
        left: 16px;
        right: 16px;
        width: auto;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }
}

/* The notifications switch is a plain switch (no sun / moon icons of the theme switch) */
.mobile-nav-wrapper .sn-push-item .theme-switcher .slider:before,
.mobile-nav-wrapper .sn-push-item .theme-switcher input:checked + .slider:before {
    background-image: none;
}

.mobile-nav-wrapper .sn-push-item .theme-switcher input:checked + .slider {
    background-color: var(--sviynews-theme-color, #0a84ff);
}

/* ---------- 404 page ---------- */
.sn-404 {
    max-width: 520px;
    min-height: 520px;
    margin: 0 auto;
    padding: 48px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.sn-404-code {
    margin: 0 0 8px;
    font-size: 120px;
    line-height: 1;
    font-weight: 800;
    letter-spacing: -.04em;
    color: var(--sviynews-theme-color, #0a84ff);
}

.sn-404-title {
    margin: 0 0 8px;
    font-size: 28px;
    font-weight: 700;
}

.sn-404-text {
    margin: 0 0 24px;
    font-size: 16px;
    color: #6e6e73;
}

.sn-404-search {
    display: flex;
    width: 100%;
    max-width: 400px;
    margin-bottom: 18px;
    border: 1px solid #d2d2d7;
    border-radius: 12px;
    overflow: hidden;
    background: #ffffff;
}

.sn-404-search input {
    flex: 1;
    min-width: 0;
    height: 46px;
    padding: 0 14px;
    border: 0;
    outline: 0;
    background: transparent;
    color: inherit;
    font-size: 15px;
}

.sn-404-search button {
    width: 48px;
    border: 0;
    background: var(--sviynews-theme-color, #0a84ff);
    color: #ffffff;
}

.sn-404-home {
    display: inline-block;
    padding: 11px 22px;
    border-radius: 10px;
    background: #f2f2f7;
    color: #1d1d1f !important;
    font-weight: 600;
    text-decoration: none;
}

.sn-404-home:hover {
    background: #e5e5ea;
}

html[data-bs-theme="dark"] .sn-404-text {
    color: #98989d;
}

html[data-bs-theme="dark"] .sn-404-search {
    border-color: #3a3a3c;
    background: #1c1c1e;
}

html[data-bs-theme="dark"] .sn-404-home {
    background: #2c2c2e;
    color: #f5f5f7 !important;
}

@media (max-width: 575.98px) {
    .sn-404 {
        min-height: 420px;
    }

    .sn-404-code {
        font-size: 88px;
    }
}

/* ---------- Account settings on phones: menu as a scrollable row of tabs ---------- */
@media (max-width: 991.98px) {
    .ps-sidebar {
        display: flex;
        gap: 8px;
        margin: 0 -12px;
        padding: 2px 12px 6px;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .ps-sidebar::-webkit-scrollbar {
        display: none;
    }

    .ps-sidebar .ps-sidebar-title {
        display: none;
    }

    .ps-sidebar .ps-menu {
        display: flex;
        flex-direction: row;
        gap: 8px;
        margin: 0;
        padding: 0;
    }

    .ps-sidebar .ps-menu-item {
        flex: 0 0 auto;
        margin: 0;
        padding: 8px 14px;
        border: 1px solid #d2d2d7;
        border-radius: 999px;
        white-space: nowrap;
    }

    .ps-sidebar .ps-menu-item.active {
        border-color: var(--sviynews-theme-color, #0a84ff);
    }

    html[data-bs-theme="dark"] .ps-sidebar .ps-menu-item {
        border-color: #3a3a3c;
    }
}

/* Account tables with no rows: only the message, no empty columns wider than the phone */
.account-table:has(.empty-state) {
    min-width: 0 !important;
    width: 100%;
}

.account-table:has(.empty-state) thead {
    display: none;
}
