/* ==================== */
/* CSS Reset & Base     */
/* ==================== */

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

:root {
    /* Light Mode Colors - Enhanced for Glass Effect */
    --bg-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-secondary: rgba(255, 255, 255, 0.25);
    --bg-glass: rgba(255, 255, 255, 0.15);
    --text-primary: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.85);
    --text-tertiary: rgba(255, 255, 255, 0.65);

    /* Brand Colors - More vibrant */
    --color-left: #007AFF;
    /* iOS blue */
    --color-left-light: rgba(0, 122, 255, 0.3);
    --color-left-glow: rgba(0, 122, 255, 0.5);
    --color-right: #FF2D55;
    /* iOS pink */
    --color-right-light: rgba(255, 45, 85, 0.3);
    --color-right-glow: rgba(255, 45, 85, 0.5);
    --color-neutral: rgba(255, 255, 255, 0.2);

    /* Glass Effects */
    --blur-sm: blur(10px);
    --blur-md: blur(20px);
    --blur-lg: blur(40px);

    /* Shadows & Effects */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.2);
    --shadow-inner: inset 0 1px 2px rgba(255, 255, 255, 0.3);

    /* Spacing */
    --space-xs: 8px;
    --space-sm: 16px;
    --space-md: 24px;
    --space-lg: 32px;
    --space-xl: 48px;

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;

    /* Transitions */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
        --bg-secondary: rgba(28, 28, 30, 0.4);
        --bg-glass: rgba(28, 28, 30, 0.25);
        --text-primary: #F5F5F7;
        --text-secondary: rgba(245, 245, 247, 0.85);
        --text-tertiary: rgba(245, 245, 247, 0.65);
        --color-neutral: rgba(255, 255, 255, 0.15);
    }
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-sm);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
    overflow: hidden;
}

/* Background orbs for depth */
body::before,
body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    z-index: 0;
    pointer-events: none;
}

body::before {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(103, 126, 234, 0.4) 0%, transparent 70%);
    top: -100px;
    left: -100px;
}

body::after {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(118, 75, 162, 0.4) 0%, transparent 70%);
    bottom: -100px;
    right: -100px;
}

/* ==================== */
/* Layout               */
/* ==================== */

.container {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
    position: relative;
    z-index: 1;
}

header {
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-xs);
}

.subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    font-weight: 400;
}

main {
    background: var(--bg-secondary);
    backdrop-filter: var(--blur-md);
    -webkit-backdrop-filter: var(--blur-md);
    border-radius: 32px;
    padding: var(--space-xl) var(--space-md);
    box-shadow: var(--shadow-md), var(--shadow-inner);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    position: relative;
    overflow: hidden;
}

/* Subtle gradient overlay */
main::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.5) 50%,
            transparent 100%);
}

footer {
    text-align: center;
}

.hint {
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

/* ==================== */
/* Timer Display        */
/* ==================== */

.timer-display {
    text-align: center;
    padding: var(--space-md) 0;
}

#timer {
    font-size: 4rem;
    font-weight: 300;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    display: block;
}

/* ==================== */
/* Switch Component     */
/* ==================== */

.switch-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: var(--space-md) 0;
}

.side-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    opacity: 0.5;
    transition: opacity var(--transition-fast);
}

.side-label.active {
    opacity: 1;
}

.side-label .emoji {
    font-size: 2rem;
}

.side-label .text {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Switch Wrapper */
.switch-wrapper {
    position: relative;
    flex-shrink: 0;
}

.switch-input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.switch-label {
    display: block;
    width: 120px;
    height: 64px;
    background: var(--color-neutral);
    backdrop-filter: var(--blur-sm);
    -webkit-backdrop-filter: var(--blur-sm);
    border-radius: 32px;
    cursor: pointer;
    position: relative;
    transition: all var(--transition-smooth);
    box-shadow: var(--shadow-sm), inset 0 1px 2px rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.switch-button {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 56px;
    height: 56px;
    background: white;
    border-radius: 50%;
    transition: all var(--transition-smooth);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Left Side (Unchecked) */
.switch-input:not(:checked)+.switch-label {
    background: var(--color-left-light);
    box-shadow: 0 4px 16px var(--color-left-glow),
        inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

.switch-input:not(:checked)+.switch-label .switch-button {
    transform: translateX(0);
    background: var(--color-left);
    box-shadow: 0 4px 20px rgba(0, 122, 255, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.4);
}

/* Right Side (Checked) */
.switch-input:checked+.switch-label {
    background: var(--color-right-light);
    box-shadow: 0 4px 16px var(--color-right-glow),
        inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

.switch-input:checked+.switch-label .switch-button {
    transform: translateX(56px);
    background: var(--color-right);
    box-shadow: 0 4px 20px rgba(255, 45, 85, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.4);
}

/* Active/Press State */
.switch-label:active .switch-button {
    width: 64px;
}

/* ==================== */
/* Status Info          */
/* ==================== */

.status-info {
    text-align: center;
    padding: var(--space-sm) 0;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#statusText {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 400;
}

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

@media (max-width: 380px) {
    header h1 {
        font-size: 2rem;
    }

    #timer {
        font-size: 3rem;
    }

    .switch-label {
        width: 100px;
        height: 54px;
    }

    .switch-button {
        width: 46px;
        height: 46px;
    }

    .switch-input:checked+.switch-label .switch-button {
        transform: translateX(46px);
    }

    .side-label .emoji {
        font-size: 1.5rem;
    }
}

/* ==================== */
/* Animations           */
/* ==================== */

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.timer-display.running #timer {
    animation: pulse 2s ease-in-out infinite;
}

/* Touch Feedback */
@media (hover: none) {
    .switch-label:active {
        transform: scale(0.98);
    }
}