/* ============================================
   IceCreamSocial - Complete Stylesheet
   Login Page + Main Site
   ============================================ */

/* ============================================
   CSS Variables
   ============================================ */

:root {
    --strawberry-pink: #ffafcc;
    --mint-green: #bde0fe;
    --cream-white: #fefae0;
    --chocolate-brown: #5d4037;
    --sprinkle-yellow: #ffc300;
    --font-main: 'Fredoka', sans-serif;
    --font-pixel: 'VT323', monospace;
    --radius-bubbly: 25px;
    --fs-h1: clamp(2.5rem, 8vw, 4.5rem);
    --fs-h2: clamp(1.5rem, 4vw, 2rem);
    --transition-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ============================================
   Base Styles & Reset
   ============================================ */

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

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    background-color: transparent; /* Changed from var(--cream-white) to allow sprinkles to show */
    font-family: var(--font-main);
    color: var(--chocolate-brown);
    overflow-x: hidden;
    line-height: 1.6;
    
    /* iOS/Safari specific fixes */
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   Sprinkle Background (Shared)
   ============================================ */

.sprinkle-bg {
    position: fixed;
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
    background-color: var(--cream-white); /* Cream background here instead of on body */
}

.sprinkle {
    position: absolute;
    width: 8px; 
    height: 20px;
    border-radius: 10px;
    animation: float 15s linear infinite;
    will-change: transform;
}

@keyframes float {
    0% { 
        transform: translateY(-10vh) rotate(0deg); 
        opacity: 0.8;
    }
    50% {
        opacity: 1;
    }
    100% { 
        transform: translateY(110vh) rotate(360deg); 
        opacity: 0.6;
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .sprinkle {
        animation: none;
        opacity: 0.3;
    }
    .pulse {
        animation: none !important;
    }
}

/* ============================================
   LOGIN PAGE STYLES
   ============================================ */

/* Login Page Body */
.login-page {
    display: flex !important;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
    padding: 20px;
    
    /* iOS/Safari specific */
    min-height: -webkit-fill-available;
}

.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

/* Login Card */
.login-card {
    background: #ffffff;
    border: 8px solid var(--chocolate-brown);
    border-radius: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 15px 15px 0px var(--strawberry-pink);
    overflow: hidden;
    z-index: 10;
    
    /* iOS/Safari improvements */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.card-header {
    background: var(--mint-green);
    padding: 20px;
    border-bottom: 8px solid var(--chocolate-brown);
    text-align: center;
}

.scoop-icon { 
    font-size: 4rem; 
    line-height: 1;
}

.card-body {
    padding: 30px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Login Typography */
.card-body h1 {
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 2.5rem;
    margin: 0 0 5px 0;
    color: var(--chocolate-brown);
    line-height: 1.2;
}

.card-body p {
    font-family: var(--font-main);
    font-weight: 400;
    font-size: 1.1rem;
    margin-bottom: 25px;
    color: var(--chocolate-brown);
}

/* Login Form */
.login-card form {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.input-group {
    margin-bottom: 15px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.input-group label {
    display: block;
    font-family: var(--font-pixel);
    font-size: 1.4rem;
    margin-bottom: 6px;
    color: var(--chocolate-brown);
}

.input-group input {
    width: 90%;
    max-width: 300px;
    padding: 15px;
    border: 4px solid var(--mint-green);
    border-radius: 20px;
    font-family: var(--font-main);
    font-size: 1.1rem;
    text-align: center;
    outline: none;
    transition: all 0.2s ease;
    margin-bottom: 5px;
    background: white;
    
    /* iOS/Safari specific fixes */
    -webkit-appearance: none;
    appearance: none;
}

.input-group input:focus {
    border-color: var(--strawberry-pink);
    box-shadow: 0 0 0 5px rgba(255, 175, 204, 0.4);
}

.login-btn {
    width: 90%;
    max-width: 300px;
    padding: 18px;
    background: var(--sprinkle-yellow);
    border: 5px solid var(--chocolate-brown);
    border-radius: 20px;
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 1.3rem;
    color: var(--chocolate-brown);
    cursor: pointer;
    box-shadow: 0 6px 0 var(--chocolate-brown);
    margin-top: 10px;
    transition: transform 0.1s;
    
    /* iOS/Safari fixes */
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
}

.login-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 var(--chocolate-brown);
}

/* Error Message */
.error-box {
    margin-top: 20px;
    padding: 10px;
    border: 2px dashed #ff4d4d;
    border-radius: 10px;
    background: #fffafa;
}

.error-text {
    color: #ff4d4d;
    font-family: var(--font-pixel);
    font-size: 1.2rem;
    margin: 0;
}

/* ============================================
   HOME PAGE STYLES
   ============================================ */

/* Logout Button */
.logout-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    color: var(--chocolate-brown);
    text-decoration: none;
    font-family: var(--font-pixel);
    font-size: 1.3rem;
    background: white;
    padding: 8px 16px;
    border-radius: 12px;
    border: 3px solid var(--chocolate-brown);
    transition: all 0.2s;
    
    /* iOS/Safari fixes */
    -webkit-tap-highlight-color: transparent;
}

.logout-btn:hover,
.logout-btn:focus {
    background: var(--strawberry-pink);
    transform: translateY(-2px);
}

/* Home Page Body */
body:not(.login-page) {
    padding-bottom: 120px; /* Space for bottom navigation */
}

/* Hero Section */
.hero {
    padding: 80px 20px;
    text-align: center;
    min-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
}

h1 { 
    font-size: var(--fs-h1); 
    margin-bottom: 10px;
    font-weight: 600;
    line-height: 1.1;
}

.tagline {
    font-size: clamp(1rem, 3vw, 1.5rem);
    margin-bottom: 2rem;
    color: #6d5d52;
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: var(--chocolate-brown);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-family: var(--font-pixel);
    font-size: 1.5rem;
    border: 4px solid var(--mint-green);
    box-shadow: 4px 4px 0px rgba(0,0,0,0.1);
    margin-top: 1rem;
}

.indicator { 
    width: 12px; 
    height: 12px; 
    background: #55ff55; 
    border-radius: 50%; 
    box-shadow: 0 0 10px #55ff55;
    flex-shrink: 0;
}

.pulse { 
    animation: pulse 2s infinite;
}

@keyframes pulse { 
    0%, 100% { 
        opacity: 1; 
        transform: scale(1);
    } 
    50% { 
        opacity: 0.4; 
        transform: scale(0.9);
    } 
}

/* Game Cards */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    padding: 2rem;
    max-width: 1100px;
    margin: 0 auto;
}

.game-card {
    background: white;
    border: 6px solid var(--chocolate-brown);
    border-radius: var(--radius-bubbly);
    padding: 2rem;
    text-align: center;
    box-shadow: 8px 8px 0px rgba(0,0,0,0.05);
    transition: transform 0.3s var(--transition-bounce), 
                box-shadow 0.3s ease;
    
    /* iOS/Safari improvements */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.game-card:hover {
    transform: translateY(-8px) rotate(1deg);
    box-shadow: 12px 12px 0px rgba(0,0,0,0.08);
}

.pixel-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    line-height: 1;
}

.game-card h2 {
    font-size: var(--fs-h2);
    margin-bottom: 1rem;
    font-weight: 600;
}

.game-card p {
    color: #6d5d52;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.status-tag {
    display: inline-block;
    background: var(--mint-green);
    padding: 6px 16px;
    border-radius: 8px;
    font-family: var(--font-pixel);
    font-size: 1.2rem;
    border: 2px solid var(--chocolate-brown);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: env(safe-area-inset-bottom, 20px);
    left: 0;
    right: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    z-index: 1000;
    padding: 0 1rem;
}

.bowl-container {
    display: flex;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 25px;
    border-radius: 50px;
    border: 4px solid var(--chocolate-brown);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px); /* iOS/Safari fix */
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.scoop {
    width: 75px; 
    height: 75px;
    border-radius: 50%;
    display: flex; 
    align-items: center; 
    justify-content: center;
    text-decoration: none; 
    font-weight: 600; 
    color: var(--chocolate-brown);
    margin: 0 -5px; 
    border: 3px solid var(--chocolate-brown);
    transition: transform 0.3s var(--transition-bounce),
                box-shadow 0.3s ease;
    font-size: 0.9rem;
    position: relative;
    
    /* iOS/Safari fixes */
    -webkit-tap-highlight-color: transparent;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.vanilla { background: var(--cream-white); }
.mint { background: var(--mint-green); }
.strawberry { background: var(--strawberry-pink); }

.scoop:hover,
.scoop:focus { 
    transform: translateY(-15px) scale(1.05);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    outline: 2px solid var(--chocolate-brown);
    outline-offset: 2px;
}

.scoop:active {
    transform: translateY(-12px) scale(1.02);
}

/* ============================================
   Accessibility
   ============================================ */

:focus-visible {
    outline: 3px solid var(--strawberry-pink);
    outline-offset: 4px;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 768px) {
    /* Login Page */
    .login-card {
        max-width: 90%;
        box-shadow: 10px 10px 0px var(--strawberry-pink);
    }
    
    .card-body h1 {
        font-size: 2rem;
    }
    
    /* Home Page */
    .hero {
        padding: 60px 20px;
        min-height: 40vh;
    }

    .status-badge {
        font-size: 1.2rem;
        padding: 10px 18px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .card-grid { 
        padding: 1rem; 
        gap: 1.5rem;
        grid-template-columns: 1fr;
    }

    .game-card {
        padding: 1.5rem;
    }

    .scoop { 
        width: 60px; 
        height: 60px; 
        font-size: 0.8rem; 
    }

    .bowl-container {
        padding: 8px 20px;
    }
    
    .logout-btn {
        top: 10px;
        right: 10px;
        font-size: 1.1rem;
        padding: 6px 12px;
    }
}

@media (max-width: 480px) {
    .login-card {
        border-width: 6px;
        box-shadow: 8px 8px 0px var(--strawberry-pink);
    }
    
    .card-body {
        padding: 20px;
    }
    
    .card-body h1 {
        font-size: 1.75rem;
    }
    
    .input-group input,
    .login-btn {
        max-width: 100%;
        width: 100%;
    }

    .hero {
        padding: 40px 15px;
    }

    .status-badge {
        font-size: 1rem;
        padding: 8px 14px;
        gap: 8px;
    }

    .indicator {
        width: 10px;
        height: 10px;
    }

    .game-card {
        padding: 1.25rem;
    }

    .pixel-icon {
        font-size: 3rem;
    }

    .scoop {
        width: 55px;
        height: 55px;
        font-size: 0.75rem;
    }
}

/* ============================================
   iOS/Safari Specific Fixes
   ============================================ */

/* Fix for iOS viewport height issues */
@supports (-webkit-touch-callout: none) {
    .login-page {
        min-height: -webkit-fill-available;
    }
    
    body {
        min-height: -webkit-fill-available;
    }
}

/* Fix for iOS input zoom */
@media screen and (max-width: 768px) {
    input[type="text"],
    input[type="password"] {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .sprinkle-bg,
    .bottom-nav,
    .logout-btn {
        display: none;
    }

    .game-card {
        break-inside: avoid;
        box-shadow: none;
        border: 2px solid var(--chocolate-brown);
    }
}