/* ========================================
   CSS Variables for Theme Support
   ======================================== */
:root {
    /* Light Mode Colors */
    --bg-start: #667eea;
    --bg-mid: #764ba2;
    --bg-end: #f093fb;
    --text-primary: #ffffff;
    --text-secondary: #f0f0f0;
    --control-bg: rgba(255, 255, 255, 0.1);
    --control-hover: rgba(255, 255, 255, 0.2);
    --control-text: #ffffff;
}

[data-theme="dark"] {
    /* Dark Mode Colors */
    --bg-start: #0f0c29;
    --bg-mid: #302b63;
    --bg-end: #24243e;
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --control-bg: rgba(255, 255, 255, 0.05);
    --control-hover: rgba(255, 255, 255, 0.15);
    --control-text: #ffffff;
}

/* ========================================
   Global Styles
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: var(--text-primary);
    overflow: hidden;
}

/* ========================================
   Animated Background Gradient
   ======================================== */
.background-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: linear-gradient(
        135deg,
        var(--bg-start) 0%,
        var(--bg-mid) 50%,
        var(--bg-end) 100%
    );
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* ========================================
   Clock Display
   ======================================== */
.clock-display {
    font-size: clamp(3rem, 15vw, 8rem);
    line-height: 1;
    color: var(--text-primary);
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

/* Fullscreen Enhancement */
:fullscreen .clock-display,
:-webkit-full-screen .clock-display,
:-moz-full-screen .clock-display {
    font-size: clamp(4rem, 20vw, 12rem);
}

/* ========================================
   Tagline
   ======================================== */
.tagline-text {
    font-size: clamp(1rem, 3vw, 1.5rem);
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* Fullscreen Enhancement */
:fullscreen .tagline-text,
:-webkit-full-screen .tagline-text,
:-moz-full-screen .tagline-text {
    font-size: clamp(1.25rem, 4vw, 2rem);
}

/* ========================================
   Control Buttons
   ======================================== */
.control-btn {
    background: var(--control-bg);
    color: var(--control-text);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.control-btn:hover {
    background: var(--control-hover);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.control-btn:active {
    transform: scale(0.95);
}

/* ========================================
   Fade-in Animation for Tagline Rotation
   ======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 0.8;
        transform: translateY(0);
    }
}

.tagline-fade {
    animation: fadeIn 1s ease-out;
}

/* ========================================
   iOS Install Prompt Animation
   ======================================== */
@keyframes fadeInModal {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

/* ========================================
   Fullscreen Styles
   ======================================== */
:fullscreen,
:-webkit-full-screen,
:-moz-full-screen {
    background: linear-gradient(
        135deg,
        var(--bg-start) 0%,
        var(--bg-mid) 50%,
        var(--bg-end) 100%
    );
}

/* Hide controls in fullscreen (optional) */
:fullscreen .absolute.top-4,
:-webkit-full-screen .absolute.top-4,
:-moz-full-screen .absolute.top-4 {
    opacity: 0;
    transition: opacity 0.3s ease;
}

:fullscreen:hover .absolute.top-4,
:-webkit-full-screen:hover .absolute.top-4,
:-moz-full-screen:hover .absolute.top-4 {
    opacity: 1;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 640px) {
    .control-btn {
        padding: 0.625rem !important;
    }
    
    .control-btn svg {
        width: 1.25rem !important;
        height: 1.25rem !important;
    }
    
    #formatToggle {
        font-size: 0.875rem;
        padding: 0.625rem 0.875rem !important;
    }
}

/* ========================================
   Accessibility
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .background-gradient {
        animation: none;
    }
    
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
.control-btn:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

/* ========================================
   Performance Optimizations
   ======================================== */
.background-gradient,
.clock-display,
.tagline-text {
    will-change: auto;
}

/* Use GPU acceleration for animations */
.control-btn,
.clock-display {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* ========================================
   Buy Me a Coffee Button Animations
   ======================================== */
@keyframes gentlePulse {
    0%, 100% {
        transform: translateX(-50%) translateY(0) scale(1);
    }
    50% {
        transform: translateX(-50%) translateY(0) scale(1.05);
    }
}

#bmcButtonContainer {
    transition: opacity 1s ease-in-out, transform 1s ease-in-out;
}

/* Hide BMC button in fullscreen mode */
:fullscreen #bmcButtonContainer,
:-webkit-full-screen #bmcButtonContainer,
:-moz-full-screen #bmcButtonContainer {
    opacity: 0;
    pointer-events: none;
}
