/* Import Google Fonts for modern typography */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap');

/* CSS Variables for theme colors */
:root {
    --bg-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-secondary: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --border-color: rgba(255, 255, 255, 0.2);
    --accent-color: #00d4ff;
}

/* Dark mode variables */
[data-theme="dark"] {
    --bg-primary: linear-gradient(135deg, #0c0c0c 0%, #1a1a1a 100%);
    --bg-secondary: rgba(255, 255, 255, 0.05);
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --shadow-color: rgba(0, 0, 0, 0.8);
    --border-color: rgba(255, 255, 255, 0.1);
    --accent-color: #00ff88;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Orbitron', monospace;
    background: var(--bg-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
}

/* Animated background particles */
body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle at 25% 25%, var(--accent-color) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    animation: float 6s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes float {
    0% {
        transform: translateY(0px) rotate(0deg);
    }

    100% {
        transform: translateY(-20px) rotate(5deg);
    }
}

/* Dark mode toggle button */
.theme-toggle {
    position: fixed;
    top: 30px;
    right: 30px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    z-index: 1000;
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px var(--shadow-color);
}

.theme-toggle i {
    font-size: 24px;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

/* Main clock container */
.clock-container {
    text-align: center;
    position: relative;
    z-index: 10;
}

/* Clock styles */
.clock {
    background: var(--bg-secondary);
    backdrop-filter: blur(20px);
    border: 2px solid var(--border-color);
    border-radius: 25px;
    padding: 40px 60px;
    box-shadow:
        0 25px 50px var(--shadow-color),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    font-size: clamp(2.5rem, 8vw, 6rem);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.1em;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    animation: glow 2s ease-in-out infinite alternate;
}

.clock::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shine 3s infinite;
}

@keyframes glow {
    0% {
        box-shadow: 0 25px 50px var(--shadow-color), 0 0 30px rgba(0, 212, 255, 0.3);
    }

    100% {
        box-shadow: 0 30px 60px var(--shadow-color), 0 0 50px rgba(0, 212, 255, 0.5);
    }
}

@keyframes shine {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

.clock:hover {
    transform: translateY(-5px) scale(1.02);
}

/* Individual time segments */
.clock span {
    display: inline-block;
    transition: all 0.3s ease;
    position: relative;
}

.clock span:not(#ampm):hover {
    color: var(--accent-color);
    transform: scale(1.1);
}

/* AM/PM styling */
#ampm {
    font-size: 0.4em;
    vertical-align: top;
    margin-left: 15px;
    opacity: 0.8;
    background: var(--accent-color);
    color: #000;
    padding: 8px 12px;
    border-radius: 12px;
    font-weight: 900;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
    }
}

/* Colons styling */
.clock-colon {
    animation: blink 1s infinite;
    color: var(--accent-color);
}

@keyframes blink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0.3;
    }
}

/* Date display */
.date-display {
    margin-top: 30px;
    font-size: clamp(1rem, 3vw, 1.5rem);
    color: var(--text-secondary);
    font-weight: 400;
    opacity: 0.9;
}

/* Responsive design */
@media (max-width: 768px) {
    .clock {
        padding: 25px 35px;
        border-radius: 20px;
    }

    .theme-toggle {
        width: 50px;
        height: 50px;
        top: 20px;
        right: 20px;
    }

    .theme-toggle i {
        font-size: 20px;
    }

    #ampm {
        margin-left: 10px;
        padding: 5px 8px;
        border-radius: 8px;
    }
}

@media (max-width: 480px) {
    .clock {
        padding: 20px 25px;
        border-radius: 15px;
        margin: 0 15px;
    }

    body::before {
        display: none;
        /* Hide background animation on very small screens */
    }

    #ampm {
        display: block;
        margin: 10px auto 0;
        font-size: 0.6em;
    }
}

/* Ultra-wide screens */
@media (min-width: 1920px) {
    .clock {
        padding: 60px 80px;
        border-radius: 35px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
    .clock {
        border-width: 1px;
    }
}

/* Print styles */
@media print {
    body {
        background: white !important;
    }

    .clock {
        background: none !important;
        border: 2px solid #000 !important;
        color: #000 !important;
        box-shadow: none !important;
    }

    .theme-toggle {
        display: none !important;
    }
}