@import url('https://fonts.googleapis.com/css2?family=Inter:wght@700;800&family=Montserrat:wght@700;800&family=Oswald:wght@700&display=swap');

@font-face {
    font-family: 'MyFont GMB';
    src: url('../assets/fonts/myfontGMB.ttf') format('truetype'),
            url('/assets/fonts/myfontGMB.ttf') format('truetype');
    font-style: normal;
    font-weight: 400 900;
    font-display: swap;
}

:root {
    --bg-color: #000000;
    --card-color: #1E1E1E;
    --digit-color: #f1f1f4;
    --divider-color: #1f2026;
    --top-shade: #cbcbce;
    --bottom-shade: #f0f0f2;
    --digit-font: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    --digit-scale: 1;
    --flip-duration: 220ms;
    --flip-overlap: 180ms;
    --flip-top-ease: cubic-bezier(0.37, 0, 0.63, 1);
    --flip-bottom-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--bg-color);
    color: var(--digit-color);
    font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

body.cursor-hidden,
body.cursor-hidden * {
    cursor: none !important;
}

.clock-app {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.1vw;
    padding: 4vw;
}

.group {
    position: relative;
    width: min(37vw, 520px);
    aspect-ratio: 1.25 / 1;
    border-radius: 20px;
    background: var(--card-color);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    perspective: 1400px;
}

.group.is-hidden {
    display: none;
}

.group::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    transform: translateY(-50%);
    background: var(--divider-color);
    z-index: 2;
}

.value-top,
.value-bottom {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1;
    font-size: calc(clamp(98px, 21vw, 300px) * var(--digit-scale));
    font-family: var(--digit-font);
    user-select: none;
    pointer-events: none;
}

.value-top {
    top: 0;
    bottom: 0;
    color: var(--top-shade);
    clip-path: inset(0 0 50% 0);
}

.value-bottom {
    top: 0;
    bottom: 0;
    color: var(--bottom-shade);
    clip-path: inset(50% 0 0 0);
}

#secondsGroup.is-analog::after,
#secondsGroup.is-analog .value-top,
#secondsGroup.is-analog .value-bottom {
    display: none;
}

.seconds-analog {
    display: none;
    position: relative;
    width: min(68%, 220px);
    aspect-ratio: 1 / 1;
    border: 2px solid var(--top-shade);
    border-radius: 50%;
}

.seconds-analog::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bottom-shade);
    transform: translate(-50%, -50%);
}

.seconds-hand {
    position: absolute;
    left: 50%;
    bottom: 50%;
    width: 4px;
    height: 40%;
    border-radius: 4px;
    background: var(--bottom-shade);
    transform-origin: center 100%;
    transform: translateX(-50%) rotate(0deg);
}

#secondsGroup.is-analog .seconds-analog {
    display: block;
}

.flip-top,
.flip-bottom {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1;
    font-size: calc(clamp(98px, 21vw, 300px) * var(--digit-scale));
    font-family: var(--digit-font);
    pointer-events: none;
    z-index: 3;
    transform-style: preserve-3d;
    backface-visibility: hidden;
}

.flip-top {
    top: 0;
    bottom: 0;
    color: var(--top-shade);
    transform-origin: center 50%;
    clip-path: inset(0 0 50% 0);
    animation: topFlip var(--flip-duration) var(--flip-top-ease) forwards;
}

.flip-bottom {
    top: 0;
    bottom: 0;
    color: var(--bottom-shade);
    transform: rotateX(90deg);
    transform-origin: center 50%;
    clip-path: inset(50% 0 0 0);
    animation: bottomFlip var(--flip-duration) var(--flip-bottom-ease) var(--flip-duration) forwards;
}

@keyframes topFlip {
    to {
        transform: rotateX(-90deg);
    }
}

@keyframes bottomFlip {
    to {
        transform: rotateX(0deg);
    }
}

.ui-controls {
    position: fixed;
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(0, 0, 0, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 10px;
    backdrop-filter: blur(4px);
    transition: opacity 0.42s ease, transform 0.42s ease;
    opacity: 1;
    transform: translateY(0) scale(1);
    z-index: 10;
}

.ui-controls.is-hidden {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    pointer-events: none;
}

.control-row {
    display: flex;
    gap: 8px;
}

.ui-btn {
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: #121217;
    color: #f5f5f7;
    font-size: 14px;
    line-height: 1;
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
}

.ui-btn.icon-btn {
    width: 40px;
    padding: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ui-btn.icon-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.palette {
    display: none;
    grid-template-columns: 1fr;
    gap: 8px;
}

.palette.is-open {
    display: grid;
}

.color-line {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    font-size: 13px;
    color: #e7e7eb;
}

.color-line input[type="color"] {
    width: 38px;
    height: 28px;
    border: 0;
    background: transparent;
    padding: 0;
    cursor: pointer;
}

.color-line input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #f5f5f7;
    cursor: pointer;
}

.color-line select {
    background: #121217;
    color: #f5f5f7;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 6px;
    padding: 4px 8px;
    min-width: 140px;
}

#secondsToggleBtn {
    justify-self: end;
}

@media (max-width: 880px) {
    .clock-app {
        gap: 2vw;
        padding: 3vw;
    }

    .group {
        width: min(43vw, 410px);
        border-radius: 14px;
    }
}
