/* =============================================
   Keyframes & Global Styles
   ============================================= */
@keyframes slideOutUp { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-40px); opacity: 0; } }
@keyframes slideInUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes animateGradient { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@keyframes fadeinout { 0%, 100% { top: -100px; opacity: 0; } 10%, 90% { top: 30px; opacity: 1; } }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-20px); } }
@keyframes modal-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-slide-in { from { transform: translate(-50%, -70%); opacity: 0; } to { transform: translate(-50%, -50%); opacity: 1; } }

body {
    background-size: 400% 400%;
    animation: animateGradient 20s ease infinite;
    transition: background 2s ease-in-out;
    min-height: 100vh;
    margin: 0;
    padding: 15px 15px 120px 15px;
    color: white;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
    overflow-x: hidden;
}
main { padding-bottom: 100px; }
body.morning { background: linear-gradient(-45deg, #f8cdda, #a5d3f2, #f5e6a8); }
body.day { background: linear-gradient(-45deg, #89d8f8, #c4e9f8, #f0f8ff); }
body.evening { background: linear-gradient(-45deg, #7b68b6, #e47ec7, #f7ac83); }
body.night { background: linear-gradient(-45deg, #0f2027, #203a43, #2c5364); }
h1 { font-family: 'Cormorant Garamond', serif; text-align: center; margin: 20px 0 10px 0; font-size: 2.5em; }

.info-text {
    text-align: center;
    opacity: 0.7;
    padding: 20px 40px;
    max-width: 800px;
    margin: 0 auto;
}

/* =============================================
   Light Mode / High Contrast Styles
   ============================================= */
body.morning,
body.day,
body.evening {
    color: #2c3e50; /* A dark, soft black for all text */
    text-shadow: 1px 1px 4px rgba(255, 255, 255, 0.7); /* A light text shadow for depth */
}

/* Update buttons and specific elements for light background */
body.morning #view-toggle-btn, body.morning #format-toggle-btn,
body.day #view-toggle-btn, body.day #format-toggle-btn,
body.evening #view-toggle-btn, body.evening #format-toggle-btn,
body.morning .close-btn,
body.day .close-btn,
body.evening .close-btn {
    color: #ffffff; /* Text becomes white to contrast with new dark button */
    border-color: rgba(44, 62, 80, 0.4);
    background: rgba(44, 62, 80, 0.4); /* Darker, semi-transparent background */
}

body.morning #view-toggle-btn:hover, body.morning #format-toggle-btn:hover,
body.day #view-toggle-btn:hover, body.day #format-toggle-btn:hover,
body.evening #view-toggle-btn:hover, body.evening #format-toggle-btn:hover,
body.morning .close-btn:hover,
body.day .close-btn:hover,
body.evening .close-btn:hover {
    background: rgba(44, 62, 80, 0.6); /* Darker hover */
}

/* Update dial for light mode */
body.morning #dial-container,
body.day #dial-container,
body.evening #dial-container {
    background: rgba(255, 255, 255, 0.25);
    border-top-color: rgba(44, 62, 80, 0.2);
}

body.morning #dial-pointer,
body.day #dial-pointer,
body.evening #dial-pointer {
    border-top-color: #2c3e50;
}

body.morning .dial-item,
body.day .dial-item,
body.evening .dial-item {
    color: #2c3e50;
}

/* Update modal for light mode */
body.morning .modal-content,
body.day .modal-content,
body.evening .modal-content {
    background: rgba(240, 248, 255, 0.8); /* A light, glassy background */
    border-color: rgba(44, 62, 80, 0.2);
    color: #2c3e50;
}

body.morning #unlock-code-input,
body.day #unlock-code-input,
body.evening #unlock-code-input {
    background: rgba(255, 255, 255, 0.5);
    border-color: rgba(44, 62, 80, 0.3);
    color: #2c3e50;
}
body.morning #unlock-code-input::placeholder,
body.day #unlock-code-input::placeholder,
body.evening #unlock-code-input::placeholder {
    color: rgba(44, 62, 80, 0.5);
}

/* Update Footer links */
body.morning .footer-link,
body.day .footer-link,
body.evening .footer-link {
    color: #2c3e50;
}
body.morning .footer-separator,
body.day .footer-separator,
body.evening .footer-separator {
    color: #2c3e50;
}


/* =============================================
   Version Toggle Styles
   ============================================= */
#version-toggle { display: flex; justify-content: center; align-items: center; gap: 10px; margin-bottom: 20px; font-family: sans-serif; }
.switch { position: relative; display: inline-block; width: 60px; height: 34px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #7b68b6; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 26px; width: 26px; left: 4px; bottom: 4px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #89d8f8; }
input:checked + .slider:before { transform: translateX(26px); }

/* Style for the "locked" state of the toggle */
body.free-mode #version-toggle .slider::after {
    content: '🔒';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    opacity: 0.7;
}

/* =============================================
   Free/Pro Mode Logic
   ============================================= */
body.free-mode .top-controls {
    opacity: 0.5;
    cursor: not-allowed;
}
body.free-mode .top-controls button:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* =============================================
   Main Layout & Clock Display
   ============================================= */
.top-controls { 
    display: flex; 
    justify-content: space-between;
    align-items: center; 
    max-width: 900px; 
    margin: 0 auto 15px auto; 
    padding: 0 10px; 
    box-sizing: border-box; 
}
#view-toggle-btn, #format-toggle-btn { position: static; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.3); color: white; width: 50px; height: 50px; border-radius: 50%; cursor: pointer; transition: all 0.2s ease; z-index: 100; }
#view-toggle-btn { font-size: 1.5em; }
#format-toggle-btn { font-size: 1.1em; font-weight: bold; }
#view-toggle-btn:hover, #format-toggle-btn:hover { background: rgba(255, 255, 255, 0.2); }

#clock-container { border: 2px solid rgba(255, 255, 255, 0.5); min-height: 450px; max-width: 900px; margin: 0 auto 20px auto; width: 100%; border-radius: 15px; background: rgba(0, 0, 0, 0.2); backdrop-filter: blur(5px); display: flex; justify-content: center; align-items: center; text-align: center; position: relative; overflow: hidden; }
#clock-info-wrapper { width: 100%; }
.slide-out { animation: slideOutUp 0.3s forwards ease-in; }
.slide-in { animation: slideInUp 0.3s forwards ease-out; }
.city-display { display: flex; align-items: center; justify-content: center; }
#city-name-text { font-family: 'Cormorant Garamond', serif; font-weight: 400; font-size: 2.5em; margin: 0; }
#main-favorite-icon { font-size: 1.5em; margin-right: 15px; width: 1.5em; transition: opacity 0.3s ease, width 0.3s ease, margin-right 0.3s ease; }
#main-favorite-icon.hidden { width: 0; margin-right: 0; }
#time-display { font-family: 'Cormorant Garamond', serif; font-weight: 700; font-size: 6em; letter-spacing: 2px; margin: 10px 0; }
#utc-offset { font-family: sans-serif; font-size: 1.2em; opacity: 0.8; margin: 0; }
#date-display { font-family: sans-serif; font-size: 1.5em; opacity: 0.9; margin: 5px 0; }
.hidden { display: none !important; }

/* =============================================
   PRO FEATURE: Multi-Clock Grid
   ============================================= */
#multi-clock-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; width: 100%; height: 100%; padding: 20px; box-sizing: border-box; align-content: start; }
.mini-clock { background-color: rgba(0, 0, 0, 0.2); border-radius: 10px; padding: 15px; display: flex; flex-direction: column; justify-content: center; align-items: center; overflow: hidden; position: relative; min-height: 150px; }
.mini-clock h3 { margin: 0 0 10px 0; font-size: 1.5em; font-family: 'Cormorant Garamond', serif; font-weight: 400; opacity: 0.9; text-align: center; }
.mini-clock .mini-time { font-family: 'Cormorant Garamond', serif; font-size: 3em; font-weight: 700; margin: 5px 0; }
.mini-clock .mini-date { font-size: 0.9em; opacity: 0.8; margin: 0; }
.mini-clock .mini-utc { font-size: 0.8em; opacity: 0.7; margin: 4px 0 0 0; }
.delete-clock-btn { position: absolute; top: 5px; right: 8px; background: none; border: none; color: white; font-size: 1.8em; opacity: 0.4; cursor: pointer; transition: opacity 0.2s ease; }
.delete-clock-btn:hover { opacity: 1; }
.add-clock-placeholder { background-color: transparent; border: 2px dashed rgba(255, 255, 255, 0.4); border-radius: 10px; cursor: pointer; display: flex; justify-content: center; align-items: center; font-size: 4em; color: rgba(255, 255, 255, 0.4); transition: all 0.2s ease; min-height: 150px; }
.add-clock-placeholder:hover { background-color: rgba(255, 255, 255, 0.1); color: rgba(255, 255, 255, 0.8); border-color: rgba(255, 255, 255, 0.8); }

/* =============================================
   Dial & Toast
   ============================================= */
#dial-container { position: fixed; bottom: 0; left: 0; right: 0; height: 100px; background: rgba(0, 0, 0, 0.25); backdrop-filter: blur(8px); border-top: 1px solid rgba(255, 255, 255, 0.2); display: flex; align-items: center; user-select: none; }
#dial-container::before, #dial-container::after { content: ''; position: absolute; top: 0; bottom: 0; width: 50px; z-index: 5; pointer-events: none; }
#dial-container::before { left: 0; background: linear-gradient(to right, rgba(0,0,0,0.4), transparent); }
#dial-container::after { right: 0; background: linear-gradient(to left, rgba(0,0,0,0.4), transparent); }
#dial-pointer { position: absolute; top: -1px; left: 50%; transform: translateX(-50%); width: 0; height: 0; border-left: 14px solid transparent; border-right: 14px solid transparent; border-top: 14px solid white; z-index: 10; }
#dial-track { display: flex; position: absolute; height: 100%; transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.dial-track.nudge { animation: nudge 0.5s ease-in-out; }
.dial-item { flex-shrink: 0; width: 250px; height: 100%; display: flex; justify-content: center; align-items: center; padding: 0 5px; box-sizing: border-box; font-family: sans-serif; font-size: 18px; color: white; cursor: pointer; opacity: 0.5; transition: all 0.4s ease; overflow: hidden; }
.dial-item.active { opacity: 1; font-weight: bold; transform: scale(1.1); }
.dial-item-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dial-favorite-star { font-size: 1.2em; flex-shrink: 0; width: 1.2em; margin-right: 8px; transition: opacity 0.3s ease, width 0.3s ease, margin 0.3s ease; }
.dial-favorite-star.hidden { width: 0; margin: 0; }
#toast-notification { position: fixed; top: 30px; left: 50%; transform: translateX(-50%); background-color: rgba(30, 30, 30, 0.9); backdrop-filter: blur(5px); color: white; padding: 15px 25px; border-radius: 50px; z-index: 1000; font-family: sans-serif; }
#toast-notification.show { animation: fadeinout 4s ease-in-out; }

/* =============================================
   Responsive Styles
   ============================================= */
#time-display { font-size: 18vw; }
@media (max-width: 768px) {
    #clock-container { min-height: 500px; padding-bottom: 20px; }
    #multi-clock-grid { grid-template-columns: 1fr; }
    .mini-clock .mini-time { font-size: 10vw; }
}
@media only screen and (min-width: 769px) {
    #time-display { font-size: 6em; }
}

/* =============================================
   Footer & TOS Link
   ============================================= */
footer {
    text-align: center;
    padding: 20px 0;
    font-family: sans-serif;
    position: fixed;
    bottom: -20px;
    width: 100%;
    left: 0;
}
.footer-link {
    color: white;
    font-size: 0.8em;
    opacity: 0.6;
    text-decoration: none;
    transition: opacity 0.2s ease;
    margin: 0 5px;
}
.footer-link:hover {
    opacity: 1;
}
.footer-separator {
    opacity: 0.6;
    color: white;
}

/* =============================================
   Unlock Pro Modal Styles
   ============================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    z-index: 2000;
    animation: modal-fade-in 0.3s ease-out;
}
.modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(30, 30, 30, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    padding: 30px 40px;
    width: 90%;
    max-width: 400px;
    color: white;
    text-align: center;
    font-family: sans-serif;
    animation: modal-slide-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: white;
    font-size: 2em;
    opacity: 0.5;
    cursor: pointer;
    transition: opacity 0.2s ease;
}
.close-btn:hover { opacity: 1; }
.modal-content h2 { margin-top: 0; font-family: 'Cormorant Garamond', serif; font-size: 2em; }
.modal-section { margin-top: 25px; }
#unlock-code-input {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 1em;
    box-sizing: border-box;
    margin-bottom: 10px;
}
#submit-code-btn, #payment-btn {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: none;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}
#submit-code-btn {
    background: #5c67f2;
    color: white;
}
#payment-btn {
    background: #34d399;
    color: white;
}
#submit-code-btn:hover { background: #4a54c4; }
#payment-btn:hover { background: #10b981; }
.modal-separator {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 30px 0;
    opacity: 0.5;
}
.modal-separator::before, .modal-separator::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}
.modal-separator:not(:empty)::before { margin-right: .25em; }
.modal-separator:not(:empty)::after { margin-left: .25em; }
.small-text { font-size: 0.8em; opacity: 0.7; margin-top: 10px; }