:root {
    --bg-light: linear-gradient(135deg, #89f7fe 0%, #66a6ff 100%);
    --bg-dark: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);

    --glass-bg-light: rgba(255, 255, 255, 0.25);
    --glass-bg-dark: rgba(15, 23, 42, 0.4);

    --glass-border-light: rgba(255, 255, 255, 0.4);
    --glass-border-dark: rgba(255, 255, 255, 0.05);

    --text-primary-light: #1e293b;
    --text-primary-dark: #f1f5f9;

    --text-secondary-light: #475569;
    --text-secondary-dark: #94a3b8;

    --hand-hour: #334155;
    --hand-minute: #475569;
    --hand-second: #e11d48;

    --hand-hour-dark: #e2e8f0;
    --hand-minute-dark: #cbd5e1;

    --shadow-light: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --shadow-dark: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Vazirmatn', sans-serif;
    margin: 0;
    background: var(--bg-light);
    color: var(--text-primary-light);
    transition: background 0.6s cubic-bezier(0.4, 0, 0.2, 1), color 0.6s ease;
    min-height: 100dvh; /* Dynamic Viewport Height for Mobile */
    /*overflow: hidden;*/
}

body.dark-mode {
    background: var(--bg-dark);
    color: var(--text-primary-dark);
}

/* --- Layout Main --- */
.main-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    padding: 20px;
}

/* --- Glass Container --- */
.backgroundClock {
    /* Responsive sizing logic: */
    width: min(90vw, 420px);
    padding: 2rem;

    background: var(--glass-bg-light);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border-light);
    border-radius: 2.5rem;
    box-shadow: var(--shadow-light);

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;

    transition: all 0.5s ease;
    position: relative;
}

body.dark-mode .backgroundClock {
    background: var(--glass-bg-dark);
    border-color: var(--glass-border-dark);
    box-shadow: var(--shadow-dark);
}

/* --- Analog Clock --- */
#borderClock {
    width: 100%;
    aspect-ratio: 1;
    border: 4px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    position: relative;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.05), 0 10px 15px rgba(0,0,0,0.1);
    background: rgba(255,255,255,0.1);
}

body.dark-mode #borderClock {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 0 30px rgba(0,0,0,0.4);
    background: rgba(0,0,0,0.15);
}

/* Markers */
.degree {
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    height: 50%;
    transform-origin: bottom center;
}

.degree::after {
    content: '';/*baraye in ke after kar koneh  */
    position: absolute;
    top: 8px; /* فاصله از لبه */
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 8px;
    background-color: rgba(0,0,0,0.3);
    border-radius: 2px;
}

.degree.strong::after {
    width: 4px;
    height: 14px;
    background-color: rgba(0,0,0,0.6);
    top: 6px;
}
/*go to js*/
body.dark-mode .degree::after { background-color: rgba(255,255,255,0.3); }
body.dark-mode .degree.strong::after { background-color: rgba(255,255,255,0.7); }

/* Hands Logic (Improved for Smoothness) */
/*move container*/
.hand-container {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
}
/*fix container in center*/
.hand {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform: translateX(-50%);
    transform-origin: bottom center;
    border-radius: 10px;
    will-change: transform;
}

#hour {
    width: 6px;
    height: 28%;
    background-color: var(--hand-hour);
    z-index: 3;
}

#minute {
    width: 4px;
    height: 38%;
    background-color: var(--hand-minute);
    z-index: 2;
}

#second {
    width: 2px;
    height: 45%;
    background-color: var(--hand-second);
    z-index: 4;
}
/*baraye entehaye second*/
#second::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 20px;
    background-color: var(--hand-second);
    border-radius: 4px;
}
/*go to js*/
body.dark-mode #hour { background-color: var(--hand-hour-dark); }
body.dark-mode #minute { background-color: var(--hand-minute-dark); }

#dot {
    width: 16px;
    height: 16px;
    background-color: var(--text-primary-light);
    border: 3px solid var(--hand-second);
    border-radius: 50%;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
/*go to js */
body.dark-mode #dot { background-color: var(--text-primary-dark); }


/*digital clock and date*/
.info-wrapper {
    text-align: center;
    z-index: 5;
}

#digitalTime {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 800;
    line-height: 1;
    letter-spacing: 1px;
    font-variant-numeric: tabular-nums; /* جلوگیری از پرش اعداد */
    color: var(--text-primary-light);
}

#dateDisplay {
    font-size: clamp(0.85rem, 2.5vw, 1.1rem);
    color: var(--text-secondary-light);
    margin-top: 0.5rem;
    font-weight: 400;
}

body.dark-mode #digitalTime { color: var(--text-primary-dark); }
body.dark-mode #dateDisplay { color: var(--text-secondary-dark); }


/* --- Theme Toggle Button --- */
#themeChange {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--glass-bg-light);
    border: 1px solid var(--glass-border-light);
    color: var(--text-primary-light);
    font-size: 1.2rem;
    cursor: pointer;
    backdrop-filter: blur(10px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

#themeChange:active { transform: scale(0.95); }

body.dark-mode #themeChange {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-color: rgba(255,255,255,0.1);
}


/* =========================================
   RESPONSIVE DESIGN PRO
   ========================================= */

@media (max-width: 480px) {
    .backgroundClock {
        padding: 1.5rem;
        gap: 1rem;
        width: 85vw;
    }
}

@media (max-width: 320px) {
    .backgroundClock { padding: 1rem; }
    #digitalTime { font-size: 1.8rem; }
}

@media (max-height: 600px) and (orientation: landscape) {
    .main-wrapper {
        align-items: center;
        padding: 10px;
    }

    .backgroundClock {
        flex-direction: row;
        width: auto;
        height: 85dvh;
        aspect-ratio: auto;
        padding: 1rem 2rem;
        gap: 3rem;
        border-radius: 2rem;
    }

    #borderClock {
        height: 100%;
        width: auto;
        aspect-ratio: 1;
    }

    .info-wrapper {
        text-align: right;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    #digitalTime {
        font-size: clamp(2rem, 8vh, 4rem);
    }
}