/* Global Styles */
* {
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    /* modern blue-purple gradient with subtle dotted texture */
    background-image:
        radial-gradient(rgba(0, 0, 0, 0.03) 1px, rgba(0, 0, 0, 0) 1px),
        linear-gradient(135deg, #e0e7ff 0%, #dbeafe 45%, #ede9fe 100%);
    background-size: 12px 12px, cover;
    background-repeat: repeat, no-repeat;
    background-attachment: fixed;
    color: #1f2937;
    /* tailwind gray-800 */
    /* Mobile font optimization */
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
}

/* Main content should grow to push footer down */
main {
    flex: 1 0 auto;
}

/* Footer should stick to bottom */
footer {
    flex-shrink: 0;
    margin-top: auto;
}

/* Mobile-optimized links and buttons */
a, button {
    /* Better touch targets */
    min-height: 44px;
    min-width: 44px;
    /* Touch feedback */
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

/* Input optimization for mobile */
input, textarea, select {
    /* Prevent zoom on iOS */
    font-size: 16px;
    /* Better touch targets */
    min-height: 44px;
    padding: 12px 16px;
    border-radius: 8px;
    /* Smooth focus transitions */
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* keep header translucent over the background */
header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    /* Mobile sticky positioning */
    position: sticky;
    top: 0;
    z-index: 30;
    /* Safe area for notched devices */
    padding-top: env(safe-area-inset-top);
}

/* Mobile Navigation Layout */
@media (max-width: 767px) {
    /* Mobile header spacing */
    header .max-w-5xl {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }
    
    /* Mobile hamburger button styling */
    #hamburgerBtn {
        min-width: 2.5rem;
        min-height: 2.5rem;
    }
    
    /* Mobile auth text styling */
    #mobileHeaderAuthBtn {
        min-width: 3rem;
        font-size: 0.875rem;
        padding: 0.25rem;
        text-decoration: none;
    }
    
    /* Mobile title styling */
    header a[href="index.html"] {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        z-index: 1;
    }
}

/* Mobile-optimized navigation */
nav a {
    display: block;
    padding: 12px 16px;
    text-decoration: none;
    transition: all 0.2s ease;
    border-radius: 8px;
}

nav a:hover, nav a:focus {
    background-color: rgba(99, 102, 241, 0.1);
    transform: translateX(4px);
}

/* Body styles */

/* Mobile Navigation Enhancements */
#mobileNavOverlay {
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
}

#mobileNavOverlay.active {
    opacity: 1;
    visibility: visible;
}

#mobileNav {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(-100%);
    /* Safe area for notched devices */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    max-width: 320px;
    width: 80vw;
}

#mobileNav.active {
    transform: translateX(0);
}

.nav-item {
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
}

.nav-item:hover {
    border-left-color: #6366f1;
    background-color: rgba(99, 102, 241, 0.05);
}

/* Hamburger Menu Styles */
#hamburgerBtn {
    position: relative;
    z-index: 31;
    transition: all 0.2s ease;
    background: none;
    border: none;
    cursor: pointer;
}

#hamburgerBtn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

#hamburgerBtn:focus {
    outline: none;
    box-shadow: 0 0 0 2px #6366f1;
}

/* Hamburger Animation */
.hamburger-line {
    display: block;
    width: 24px;
    height: 2px;
    background-color: #374151;
    transform-origin: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 1px;
}

/* When menu is open */
#hamburgerBtn.open .hamburger-line:nth-child(1) {
    transform: translateY(5px) rotate(45deg);
}

#hamburgerBtn.open .hamburger-line:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

#hamburgerBtn.open .hamburger-line:nth-child(3) {
    transform: translateY(-5px) rotate(-45deg);
}

/* Mobile Navigation Overlay */
#mobileNavOverlay {
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

#mobileNavOverlay.active {
    opacity: 1;
    visibility: visible;
}

/* Mobile Navigation Menu */
#mobileNav {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.1);
    transform: translateX(-100%);
}

#mobileNav.active {
    transform: translateX(0);
}

/* Mobile Navigation Items */
.nav-item {
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
    position: relative;
}

.nav-item:hover {
    background-color: rgba(99, 102, 241, 0.05);
    border-left-color: #6366f1;
}

.nav-item:active {
    background-color: rgba(99, 102, 241, 0.1);
    transform: scale(0.98);
}

/* Mobile menu scroll - additional properties */
#mobileNav {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Ensure left positioning is maintained */
    left: 0;
    right: auto;
}

/* Prevent body scroll when menu is open */
body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Mobile-First Typography */
h1, h2, h3, h4, h5, h6 {
    line-height: 1.3;
    margin-bottom: 0.5em;
    font-weight: 700;
}

h1 { 
    font-size: clamp(1.75rem, 4vw, 2.5rem);
}
h2 { 
    font-size: clamp(1.5rem, 3.5vw, 2rem);
}
h3 { 
    font-size: clamp(1.25rem, 3vw, 1.75rem);
}

p {
    line-height: 1.7;
    margin-bottom: 1em;
}

/* Mobile-optimized containers */
.container, .max-w-5xl, .max-w-4xl, .max-w-3xl {
    width: 100%;
    padding-left: 1rem;
    padding-right: 1rem;
    margin-left: auto;
    margin-right: auto;
}

/* Mobile card optimizations */
.bg-white {
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    /* Smooth interactions */
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.bg-white:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px -3px rgba(0, 0, 0, 0.15);
}

/* Mobile button optimizations */
button, .button, .bg-indigo-600 {
    border-radius: 12px;
    padding: 14px 20px;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    /* Better touch feedback */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

button:active, .button:active {
    transform: scale(0.98);
}

button:disabled, .button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Mobile spacing utilities */
.space-y-4 > * + * {
    margin-top: 1rem;
}

.space-y-6 > * + * {
    margin-top: 1.5rem;
}

.space-y-8 > * + * {
    margin-top: 2rem;
}

.container {
    @apply flex flex-col items-center bg-indigo-50;
}

.header {
    @apply text-2xl font-bold mb-4;
}

.code-box {
    @apply bg-indigo-600 text-white text-6xl font-bold py-4 px-8 rounded-lg shadow-lg mb-4;
}

.input-field {
    @apply border border-gray-300 rounded-lg p-2 mb-2 w-64;
}

.counter {
    @apply text-lg mb-2;
}

.balance {
    @apply text-lg mb-4;
}

.reward-text {
    @apply text-lg mb-4;
}

.withdraw-button {
    @apply bg-indigo-600 text-white font-bold py-2 px-4 rounded-lg shadow-lg transition duration-300 ease-in-out;
}

.withdraw-button.active {
    @apply bg-purple-600 cursor-pointer;
}

.error-message {
    @apply text-red-500 mb-4;
}

@media (max-width: 640px) {
    .code-box {
        font-size: 2rem;
    }

    .input-field {
        width: 12rem;
    }
}

/* Body styles */

/* Ultra-wide mobile landscape optimization */
@media (max-width: 896px) and (orientation: landscape) and (max-height: 500px) {
    /* Landscape mobile optimization */
    header {
        padding: 0.5rem 1rem !important;
    }
    
    main {
        padding: 0.75rem 1rem !important;
    }
    
    .bg-white {
        padding: 1rem !important;
        margin: 0.5rem 0 !important;
    }
    
    #mobileNav {
        width: 300px !important;
    }
}

/* Mobile PWA enhancements */
@media (display-mode: standalone) {
    /* PWA specific styles */
    body {
        padding-top: env(safe-area-inset-top) !important;
        padding-bottom: env(safe-area-inset-bottom) !important;
    }
    
    header {
        background: rgba(255, 255, 255, 0.98) !important;
        backdrop-filter: blur(10px) !important;
    }
}

/* small shake animation used by the typing app */
@keyframes shake {
    0% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-6px);
    }

    40% {
        transform: translateX(6px);
    }

    60% {
        transform: translateX(-4px);
    }

    80% {
        transform: translateX(4px);
    }

    100% {
        transform: translateX(0);
    }
}

.animate-shake {
    animation: shake 360ms ease;
}

/* minor layout helpers */
.min-h-\[1\.25rem\] {
    min-height: 1.25rem;
}

/* Withdraw page specific styles */
.tab-active {
    color: #6366f1;
    border-color: #6366f1;
    border-bottom: 2px solid #6366f1;
    background-color: rgba(99, 102, 241, 0.05);
}

.tab-inactive {
    color: #6b7280;
    border-color: transparent;
    border-bottom: 2px solid transparent;
}

/* Form field focus states */
.form-input:focus {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Success animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.3s ease-out;
}

