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

body {
    background-color: #f8f8f8;
    font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Settings Icon */
#settings-icon {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #333;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

#settings-icon:hover {
    background: rgba(255, 255, 255, 1);
    transform: rotate(45deg);
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    top: 0;
    right: -350px; /* 增加隐藏距离，确保完全隐藏 */
    width: 300px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 80px 30px 30px;
    transition: right 0.3s ease;
    z-index: 999;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
}

.settings-panel.active {
    right: 0;
}

.settings-panel h3 {
    color: #333;
    margin-bottom: 30px;
    font-weight: 300;
    font-size: 24px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px 0; /* 增加点击区域 */
    cursor: pointer; /* 整个区域可点击 */
}

.setting-item label {
    color: #333;
    font-size: 16px;
    font-weight: 300;
    cursor: pointer; /* 标签也可点击 */
    flex: 1; /* 让标签占据更多空间 */
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 50px;
    height: 24px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #007AFF;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* Main clock display */
#clock-display {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20vw;
    font-weight: 300;
    color: #333;
    text-align: center;
    line-height: 1;
    transition: color 0.3s ease;
}

main {
    min-height: 100vh;
    display: flex;
    align-items: center;      /* 垂直居中 */
    justify-content: center;  /* 水平居中 */
}

/* Footer styling */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 20px;
    font-size: 12px;
    color: #666;
    transition: color 0.3s ease;
}

footer a {
    color: #666;
    text-decoration: none;
    transition: color 0.3s ease;
}

footer a:hover {
    color: #333;
}

/* Dark Mode Styles */
body.dark-mode {
    background-color: #000000;
}

body.dark-mode #clock-display {
    color: #FFFFFF;
}

body.dark-mode footer,
body.dark-mode footer a {
    color: #999;
}

body.dark-mode footer a:hover {
    color: #FFFFFF;
}

body.dark-mode #settings-icon {
    color: #FFFFFF;
    background: rgba(0, 0, 0, 0.8);
}

body.dark-mode #settings-icon:hover {
    background: rgba(0, 0, 0, 1);
}

body.dark-mode .settings-panel {
    background: rgba(0, 0, 0, 0.95);
}

body.dark-mode .settings-panel h3,
body.dark-mode .setting-item label {
    color: #FFFFFF;
}

/* 辅助功能 - 屏幕阅读器专用内容 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 键盘导航焦点样式 */
#settings-icon:focus,
.setting-item:focus,
footer a:focus {
    outline: 2px solid #007AFF;
    outline-offset: 2px;
}

body.dark-mode #settings-icon:focus,
body.dark-mode .setting-item:focus,
body.dark-mode footer a:focus {
    outline-color: #FFFFFF;
}

/* 确保设置面板在活动时更新aria-hidden */
.settings-panel[aria-hidden="false"] {
    right: 0;
}

.settings-panel[aria-hidden="true"] {
    right: -350px;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    /* Adjust clock font size for mobile */
    #clock-display {
        font-size: 15vw;
        padding: 0 10px;
    }
    
    /* Make settings icon larger for easier tapping */
    #settings-icon {
        width: 50px;
        height: 50px;
        top: 15px;
        right: 15px;
    }
    
    #settings-icon svg {
        width: 28px;
        height: 28px;
    }
    
    /* Settings panel slides up from bottom on mobile */
    .settings-panel {
        top: auto;
        bottom: -100vh;
        right: 0;
        left: 0;
        width: 100%;
        height: 50vh;
        border-radius: 20px 20px 0 0;
        padding: 30px;
        transition: bottom 0.3s ease;
        box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.1);
    }
    
    .settings-panel.active {
        bottom: 0;
        right: 0;
    }
    
    .settings-panel h3 {
        font-size: 20px;
        margin-bottom: 25px;
    }
    
    /* Make toggle switch larger for easier tapping */
    .toggle-switch {
        width: 60px;
        height: 30px;
    }
    
    .slider:before {
        height: 22px;
        width: 22px;
        left: 4px;
        bottom: 4px;
    }
    
    input:checked + .slider:before {
        transform: translateX(30px);
    }
    
    /* Adjust setting item spacing */
    .setting-item {
        margin-bottom: 25px;
        padding: 10px 0;
    }
    
    .setting-item label {
        font-size: 18px;
    }
    
    /* Footer adjustments for mobile */
    footer {
        padding: 15px;
        font-size: 11px;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    #clock-display {
        font-size: 12vw;
        padding: 0 5px;
    }
    
    #settings-icon {
        width: 45px;
        height: 45px;
        top: 10px;
        right: 10px;
    }
    
    #settings-icon svg {
        width: 24px;
        height: 24px;
    }
    
    .settings-panel {
        height: 40vh;
        padding: 25px 20px;
    }
    
    .settings-panel h3 {
        font-size: 18px;
        margin-bottom: 20px;
    }
    
    footer {
        padding: 12px;
        font-size: 10px;
    }
}

/* Large screens optimization */
@media (min-width: 1200px) {
    #clock-display {
        font-size: 18vw;
    }
    
    .settings-panel {
        width: 350px;
        padding: 100px 40px 40px;
    }
    
    .settings-panel h3 {
        font-size: 28px;
        margin-bottom: 35px;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    #clock-display {
        font-size: 10vh;
    }
    
    .settings-panel {
        height: 60vh;
    }
}
