/* ===========================================
   Fun House Photo Booth - Festive Styles
   Winter/Christmas Theme
   =========================================== */

/* CSS Custom Properties for theming */
:root {
    --color-primary: #1a5f7a;
    --color-primary-dark: #0d3d4d;
    --color-secondary: #c41e3a;
    --color-secondary-dark: #8b1528;
    --color-accent: #228b22;
    --color-gold: #ffd700;
    --color-snow: #f0f8ff;
    --color-ice: #e0f7fa;
    --color-frost: #b3e5fc;
    --color-white: #ffffff;
    --color-dark: #1a1a2e;
    
    --shadow-soft: 0 4px 15px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 8px 30px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 20px rgba(255, 255, 255, 0.3);
    
    --border-radius: 12px;
    --transition-fast: 0.2s ease;
    --transition-medium: 0.3s ease;
}

/* Reset and Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary) 50%, var(--color-dark) 100%);
    min-height: 100vh;
    color: var(--color-white);
    overflow-x: hidden;
    position: relative;
}

/* ===========================================
   Snowfall Animation (CSS Only)
   =========================================== */
.snowfall {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.snow {
    position: absolute;
    top: -10px;
    width: 10px;
    height: 10px;
    background: radial-gradient(circle, var(--color-white) 0%, transparent 70%);
    border-radius: 50%;
    animation: snowfall linear infinite;
    opacity: 0.8;
}

.snow:nth-child(1) { left: 5%; animation-duration: 8s; animation-delay: 0s; width: 8px; height: 8px; }
.snow:nth-child(2) { left: 15%; animation-duration: 12s; animation-delay: 1s; width: 12px; height: 12px; }
.snow:nth-child(3) { left: 25%; animation-duration: 10s; animation-delay: 2s; width: 6px; height: 6px; }
.snow:nth-child(4) { left: 35%; animation-duration: 14s; animation-delay: 0.5s; width: 10px; height: 10px; }
.snow:nth-child(5) { left: 45%; animation-duration: 9s; animation-delay: 3s; width: 14px; height: 14px; }
.snow:nth-child(6) { left: 55%; animation-duration: 11s; animation-delay: 1.5s; width: 8px; height: 8px; }
.snow:nth-child(7) { left: 65%; animation-duration: 13s; animation-delay: 2.5s; width: 10px; height: 10px; }
.snow:nth-child(8) { left: 75%; animation-duration: 8s; animation-delay: 4s; width: 6px; height: 6px; }
.snow:nth-child(9) { left: 85%; animation-duration: 10s; animation-delay: 0.8s; width: 12px; height: 12px; }
.snow:nth-child(10) { left: 95%; animation-duration: 15s; animation-delay: 2s; width: 8px; height: 8px; }

@keyframes snowfall {
    0% {
        transform: translateY(-10px) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.8;
    }
    90% {
        opacity: 0.8;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* ===========================================
   App Container
   =========================================== */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===========================================
   Header
   =========================================== */
header {
    text-align: center;
    padding: 20px 0;
}

header h1 {
    font-size: 2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3), var(--shadow-glow);
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.subtitle {
    font-size: 1rem;
    color: var(--color-frost);
    opacity: 0.9;
}

/* ===========================================
   Main Content
   =========================================== */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ===========================================
   Camera Container
   =========================================== */
.camera-container {
    position: relative;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    aspect-ratio: 4 / 3;
    background: var(--color-dark);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-medium), 0 0 40px rgba(26, 95, 122, 0.3);
    border: 3px solid var(--color-frost);
}

#video, #canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: calc(var(--border-radius) - 3px);
}

#video {
    transform: scaleX(-1); /* Mirror for selfie view */
}

#canvas {
    pointer-events: none;
    transform: scaleX(-1); /* Mirror to match video */
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 26, 46, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 10;
    border-radius: calc(var(--border-radius) - 3px);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--color-frost);
    border-top-color: var(--color-secondary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Error Overlay */
.error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(196, 30, 58, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 10;
    border-radius: calc(var(--border-radius) - 3px);
    padding: 20px;
    text-align: center;
}

.hidden {
    display: none !important;
}

/* ===========================================
   Filter Section
   =========================================== */
.filter-section {
    text-align: center;
}

.filter-section h2 {
    font-size: 1.25rem;
    margin-bottom: 16px;
    color: var(--color-snow);
}

.filter-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    padding: 10px;
}

.filter-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    min-width: 90px;
    background: linear-gradient(145deg, var(--color-ice), var(--color-frost));
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-medium);
    color: var(--color-primary-dark);
    font-weight: 500;
    box-shadow: var(--shadow-soft);
}

.filter-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-medium);
    background: linear-gradient(145deg, var(--color-white), var(--color-ice));
}

.filter-btn:active {
    transform: translateY(0);
}

.filter-btn.active {
    background: linear-gradient(145deg, var(--color-secondary), var(--color-secondary-dark));
    color: var(--color-white);
    border-color: var(--color-gold);
    box-shadow: 0 0 15px rgba(196, 30, 58, 0.5);
}

.filter-icon {
    font-size: 1.5rem;
}

.filter-name {
    font-size: 0.75rem;
    white-space: nowrap;
}

/* ===========================================
   Action Buttons
   =========================================== */
.action-section {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 10px;
}

.btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-medium);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-icon {
    font-size: 1.25rem;
}

.btn-primary {
    background: linear-gradient(145deg, var(--color-primary), var(--color-primary-dark));
    color: var(--color-white);
    box-shadow: var(--shadow-soft);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.btn-capture {
    background: linear-gradient(145deg, var(--color-secondary), var(--color-secondary-dark));
    color: var(--color-white);
    box-shadow: 0 4px 15px rgba(196, 30, 58, 0.4);
}

.btn-capture:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(196, 30, 58, 0.6);
}

.btn-capture:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-download {
    background: linear-gradient(145deg, var(--color-accent), #1a6b1a);
    color: var(--color-white);
    box-shadow: 0 4px 15px rgba(34, 139, 34, 0.4);
}

.btn-download:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(34, 139, 34, 0.6);
}

/* ===========================================
   Footer
   =========================================== */
footer {
    text-align: center;
    padding: 20px;
    color: var(--color-frost);
    font-size: 0.875rem;
    opacity: 0.8;
}

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

/* Tablets */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.75rem;
    }
    
    .filter-btn {
        min-width: 80px;
        padding: 10px 12px;
    }
    
    .filter-icon {
        font-size: 1.25rem;
    }
    
    .filter-name {
        font-size: 0.7rem;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 0.9rem;
    }
}

/* Mobile phones */
@media (max-width: 480px) {
    .app-container {
        padding: 10px;
    }
    
    header {
        padding: 15px 0;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .subtitle {
        font-size: 0.875rem;
    }
    
    .camera-container {
        border-radius: 8px;
        border-width: 2px;
    }
    
    .filter-gallery {
        gap: 8px;
    }
    
    .filter-btn {
        min-width: 70px;
        padding: 8px 10px;
        border-radius: 8px;
    }
    
    .filter-icon {
        font-size: 1.1rem;
    }
    
    .filter-name {
        font-size: 0.65rem;
    }
    
    .action-section {
        gap: 12px;
    }
    
    .btn {
        padding: 12px 18px;
        font-size: 0.85rem;
        flex: 1;
        justify-content: center;
    }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .app-container {
        padding: 10px;
    }
    
    header {
        padding: 10px 0;
    }
    
    header h1 {
        font-size: 1.25rem;
    }
    
    .subtitle {
        display: none;
    }
    
    .camera-container {
        max-width: 400px;
        aspect-ratio: 16 / 9;
    }
    
    main {
        gap: 12px;
    }
    
    .filter-section h2 {
        display: none;
    }
    
    .filter-btn {
        padding: 6px 10px;
        min-width: 60px;
    }
    
    .filter-name {
        display: none;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .snow {
        box-shadow: 0 0 2px rgba(255, 255, 255, 0.5);
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .snow {
        animation: none;
        opacity: 0.3;
    }
    
    .spinner {
        animation: none;
        border-top-color: var(--color-frost);
    }
    
    .btn, .filter-btn {
        transition: none;
    }
}

/* Dark mode adjustments (if user prefers) */
@media (prefers-color-scheme: dark) {
    :root {
        --color-snow: #e8f4f8;
        --color-ice: #d0e8f0;
    }
}
