/* BASE STYLES */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 100%);
    color: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.4;
}

/* ————————————————————————————————————————
   HAMBURGER MENU
   ———————————————————————————————————————— */

/* Menu Toggle Button */
.menu-toggle {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 10001;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 10px;
    transition: all 0.3s ease;
}

.menu-toggle:hover {
    background: rgba(0, 212, 170, 0.2);
    border-color: rgba(0, 212, 170, 0.4);
}

.menu-toggle:active {
    transform: scale(0.95);
}

.menu-bar {
    width: 20px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Animated X when open */
.menu-toggle.open .menu-bar:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.menu-toggle.open .menu-bar:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.menu-toggle.open .menu-bar:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Menu Overlay */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.menu-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Menu Drawer */
.menu-drawer {
    position: fixed;
    top: 0;
    right: -100%; /* Fallback for browsers with transform issues */
    width: 280px;
    max-width: 85vw;
    height: 100%;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    background: linear-gradient(180deg, #1a1a2e 0%, #0f0f23 100%);
    z-index: 10000;
    -webkit-transform: translateX(0); /* Already positioned via right: -100% */
    transform: translateX(0);
    -webkit-transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    visibility: hidden;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    overscroll-behavior: contain;
}

.menu-drawer.open {
    right: 0;
    visibility: visible;
}

/* Menu Header */
.menu-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.2);
}

.menu-logo {
    font-size: 28px;
}

.menu-title {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    letter-spacing: -0.3px;
}

/* Menu List */
.menu-list {
    list-style: none;
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.menu-link:hover {
    background: rgba(0, 212, 170, 0.1);
    color: #fff;
}

.menu-link:active {
    background: rgba(0, 212, 170, 0.15);
}

.menu-link.active {
    background: rgba(0, 212, 170, 0.12);
    color: #00d4aa;
    border-left-color: #00d4aa;
}

.menu-link.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.menu-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.menu-badge {
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    background: rgba(0, 212, 170, 0.2);
    color: #00d4aa;
    padding: 3px 8px;
    border-radius: 10px;
    letter-spacing: 0.5px;
}

.menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 8px 20px;
}

/* Menu Footer */
.menu-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.2);
}

.menu-version {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    font-family: 'SF Mono', Monaco, 'Consolas', monospace;
}

/* Safe area support for iOS */
@supports (padding-top: env(safe-area-inset-top)) {
    .menu-toggle {
        top: calc(12px + env(safe-area-inset-top));
    }
    
    .menu-header {
        padding-top: calc(20px + env(safe-area-inset-top));
    }
    
    .menu-footer {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
}

h1 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.pwa-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #000;
    color: white;
    padding: 12px 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transform: translateY(-100%);
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: none;
}

.pwa-banner.show {
    transform: translateY(0);
    display: block;
}

.pwa-banner-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    gap: 12px;
    flex-wrap: nowrap;
}

.pwa-icon {
    font-size: 32px;
    margin-right: 8px;
}

.pwa-text {
    flex: 1;
    font-size: 15px;
    line-height: 1.3;
}

.pwa-text strong {
    font-size: 16px;
}

.pwa-btn {
    background: #00d4aa;
    color: black;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 15px;
    cursor: pointer;
}

.pwa-close {
    background: none;
    border: none;
    color: #aaa;
    font-size: 28px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* iOS Safari bottom safe area */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .pwa-banner {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
}

/* ————————————————————————————————————————
   PAGE TRANSITION LOADING BAR
   ———————————————————————————————————————— */
#page-loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 99999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

#page-loading-bar.active {
    opacity: 1;
}

#page-loading-bar .loading-progress {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #00d4aa, #00bfff, #00d4aa);
    background-size: 200% 100%;
    animation: loading-grow 0.8s ease-out forwards, loading-shimmer 1s linear infinite;
    border-radius: 0 2px 2px 0;
    box-shadow: 0 0 10px rgba(0, 212, 170, 0.5);
}

@keyframes loading-grow {
    0% { width: 0; }
    20% { width: 30%; }
    50% { width: 60%; }
    80% { width: 85%; }
    100% { width: 92%; }
}

@keyframes loading-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}