/* Mobile Overlay Styles */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0047AB 0%, #003380 100%);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    overflow: hidden;
}

/* Space canvas background (matches 404 / login error pages) */
.mobile-overlay--space {
    background: linear-gradient(180deg, #004aad, #003a87 70%, #012a63);
}

.mobile-overlay .animated-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.mobile-overlay .animated-background::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, rgba(1, 20, 55, 0) 35%, rgba(1, 20, 55, 0.55) 100%);
}

.mobile-overlay #spaceCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Logo Styles */
.mobile-overlay-logo-link {
    grid-row: 1;
    align-self: end;
    display: inline-block;
    padding-bottom: 0.85rem;
}

.mobile-overlay-logo {
    width: min(240px, 60vw);
    height: auto;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.3));
    transition: transform 0.3s ease;
    object-fit: contain;
}

.mobile-overlay-logo-link:hover .mobile-overlay-logo {
    transform: scale(1.05);
}

/* Stars Animation */
.mobile-stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.mobile-star {
    position: absolute;
    background-color: #fff;
    border-radius: 50%;
    opacity: 0.6;
}

/* Black Hole Animation */
.mobile-black-hole {
    position: absolute;
    top: 20%;
    right: 20%;
    transform: translate(50%, -50%);
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: radial-gradient(circle at center, #003380 0%, #0047AB 70%);
    box-shadow: 0 0 50px rgba(255, 255, 255, 0.3);
    animation: mobilePulse 4s infinite;
}

.mobile-orbit {
    position: absolute;
    top: 20%;
    right: 20%;
    transform: translate(50%, -50%);
    width: 200px;
    height: 200px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    animation: mobileRotate 20s linear infinite;
}

.mobile-orbit::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    width: 10px;
    height: 10px;
    background: #fff;
    border-radius: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 10px #fff;
}

@keyframes mobilePulse {
    0%, 100% { transform: translate(50%, -50%) scale(1); }
    50% { transform: translate(50%, -50%) scale(1.1); }
}

@keyframes mobileRotate {
    from { transform: translate(50%, -50%) rotate(0deg); }
    to { transform: translate(50%, -50%) rotate(360deg); }
}

.mobile-overlay-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding: 50px 40px;
    border-radius: 15px;
    width: min(500px, 90vw);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    z-index: 2;
}

/* Hero: logo -> icon -> title (mirrors 404 error-page-hero) */
.mobile-overlay-hero {
    display: grid;
    grid-template-rows: 1fr auto auto;
    align-items: center;
    justify-items: center;
    width: 100%;
    min-height: 240px;
    margin-bottom: 35px;
}

.mobile-overlay-icon-wrap {
    grid-row: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.mobile-overlay-icon-wrap i {
    color: #fff;
    font-size: 3rem;
    line-height: 1;
}

.mobile-overlay-title {
    grid-row: 3;
    align-self: start;
    padding-top: 0.85rem;
    color: #fff;
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
}

.mobile-overlay-subtext {
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 25px;
    line-height: 1.6;
    font-size: 18px;
    text-align: center;
}

/* Button (mirrors 404 login-btn) */
.mobile-overlay-btn {
    width: 100%;
    padding: 14px;
    border: none;
    background: #00a0ff;
    color: white;
    font-size: 18px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.mobile-overlay-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: 0.5s;
}

.mobile-overlay-btn:hover::before {
    left: 100%;
}

.mobile-overlay-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 160, 255, 0.4);
}

@media only screen and (max-width: 768px) {
    .mobile-overlay-hero {
        min-height: 200px;
    }

    .mobile-overlay-icon-wrap i {
        font-size: 2.5rem;
    }

    .mobile-overlay-title {
        font-size: 1.35rem;
    }
}

/* Mobile Detection - Disabled for pages with mobile-container */
@media (hover: none) and (pointer: coarse) and (max-width: 768px) {
    body:not(.has-mobile-layout) .mobile-overlay {
        display: flex;
    }
    body:not(.has-mobile-layout) {
        overflow: hidden;
    }
}

/* =============================================================
   Mobile top-nav — Classroom / Trading Desk / Account accordion groups
   ============================================================= */
/* Beat legacy page CSS that leaves .mobile-nav-links a at opacity:0
   until a slide-in animation runs (grouped nav does not use that path). */
.mobile-nav-menu:has(.mobile-nav-links--grouped),
.mobile-nav-menu:has(.mobile-nav-links--grouped).expanded {
    opacity: 1 !important;
    transform: none !important;
}

.mobile-nav-menu:has(.mobile-nav-links--grouped).expanded {
    max-height: min(80vh, 720px) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

.mobile-nav-links--grouped {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.mobile-nav-links--grouped .mobile-nav-group__toggle,
.mobile-nav-links--grouped a {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
}

.mobile-nav-standalone {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 0.95rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-light, #fff);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.mobile-nav-standalone:hover,
.mobile-nav-standalone.active {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(250, 204, 21, 0.35);
    color: #fff;
}

.mobile-nav-standalone i {
    width: 1.25rem;
    text-align: center;
}

.mobile-nav-group {
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.mobile-nav-group__toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 0.95rem;
    border: none;
    background: transparent;
    color: var(--text-light, #fff);
    font: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.01em;
    cursor: pointer;
    text-align: left;
}

.mobile-nav-group__toggle:hover,
.mobile-nav-group__toggle:focus-visible {
    background: rgba(255, 255, 255, 0.08);
    outline: none;
}

.mobile-nav-group__label {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
}

.mobile-nav-group__label i {
    width: 1.25rem;
    text-align: center;
    opacity: 0.95;
}

.mobile-nav-group__chevron {
    font-size: 0.75rem;
    opacity: 0.8;
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.mobile-nav-group.is-open .mobile-nav-group__chevron {
    transform: rotate(180deg);
}

.mobile-nav-group__panel {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.mobile-nav-group.is-open .mobile-nav-group__panel {
    grid-template-rows: 1fr;
}

.mobile-nav-group__panel-inner {
    overflow: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0 0.45rem;
    opacity: 0;
    transform: translateY(-4px);
    transition:
        opacity 0.22s ease,
        transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1),
        padding 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.mobile-nav-group.is-open .mobile-nav-group__panel-inner {
    opacity: 1;
    transform: translateY(0);
    padding: 0 0.45rem 0.55rem;
}

.mobile-nav-links--grouped .mobile-nav-group__panel a,
.mobile-nav-links--grouped .mobile-nav-group__panel-inner a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.75rem;
    margin-bottom: 0;
    border-radius: 10px;
    color: var(--text-light, #fff);
    text-decoration: none;
    transition: background 0.2s ease;
}

.mobile-nav-links--grouped .mobile-nav-group__panel a:hover,
.mobile-nav-links--grouped .mobile-nav-group__panel a.active,
.mobile-nav-links--grouped .mobile-nav-group__panel-inner a:hover,
.mobile-nav-links--grouped .mobile-nav-group__panel-inner a.active {
    background: rgba(255, 255, 255, 0.14);
}

.mobile-nav-links--grouped .mobile-nav-group__panel a i,
.mobile-nav-links--grouped .mobile-nav-group__panel-inner a i {
    font-size: 1.1rem;
    width: 1.35rem;
    text-align: center;
}

.mobile-nav-group:has(.mobile-nav-group__panel a.active) .mobile-nav-group__toggle {
    color: #fff;
}

.mobile-nav-group:has(.mobile-nav-group__panel a.active) {
    border-color: rgba(250, 204, 21, 0.35);
    background: rgba(255, 255, 255, 0.09);
}

html[data-theme='dark'] .mobile-nav-group {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}

html[data-theme='dark'] .mobile-nav-group:has(.mobile-nav-group__panel a.active) {
    border-color: rgba(250, 204, 21, 0.3);
    background: rgba(255, 255, 255, 0.07);
}

@media (prefers-reduced-motion: reduce) {
    .mobile-nav-group__chevron,
    .mobile-nav-group__panel,
    .mobile-nav-group__panel-inner {
        transition: none;
    }
}
