/* Базовые стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    background-color: #000;
    color: #FFFFFF;
    height: 100dvh;
    overflow: hidden;
    position: relative;
    /* Поддержка безопасной зоны для устройств с notch */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    /* Фиксация для Chrome на мобильных */
    min-height: 100dvh;
    min-height: -webkit-fill-available;
}

:root {
    --safe-top: env(safe-area-inset-top);
    --safe-right: env(safe-area-inset-right);
    --safe-bottom: env(safe-area-inset-bottom);
    --safe-left: env(safe-area-inset-left);
}

/* WebGL фоновая анимация */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    pointer-events: none;
    z-index: -1;
    /* Фиксация для Chrome на мобильных */
    height: -webkit-fill-available;
}

/* Синяя рамка */
.blue-frame {
    position: absolute;
    top: calc(15px + var(--safe-top));
    left: calc(15px + var(--safe-left));
    right: calc(15px + var(--safe-right));
    bottom: calc(15px + var(--safe-bottom));
    border: 5px solid #0000FF;
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 30px;
}

/* Логотип */
.logo-container {
    position: absolute;
    top: calc(15px + var(--safe-top));
    left: calc(15px + var(--safe-left));
    z-index: 1000;
}
/* Переключатель языков */
.lang-switcher {
    position: absolute;
    top: calc(15px + var(--safe-top));
    right: calc(20px + var(--safe-right));
    z-index: 1000;
}

.lang-current {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    color: #FFFFFF;
    border: 1px solid rgba(0, 39, 255, 0.6);
    border-radius: 0;
    cursor: pointer;
    transition: all 0.25s ease;
}
.globe-icon {
    width: 22px;
    height: 22px;
}

.lang-current:hover {
    background: rgba(0, 39, 255, 0.2);
    border-color: #0000FF;
    box-shadow: 0 4px 12px rgba(0, 39, 255, 0.25);
}

.lang-menu {
    position: absolute;
    top: 40px;
    right: 0;
    display: none;
    width: 240px;
    display: none;
    grid-template-columns: 1fr;
    gap: 4px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 39, 255, 0.5);
    border-radius: 0;
    padding: 10px;
    box-shadow: 0 8px 24px rgba(0, 39, 255, 0.2);
}

.lang-menu.open {
    display: grid;
}

.lang-item {
    background: transparent;
    color: #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 8px 10px;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.lang-item .lang-names {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.lang-item .lang-name-en {
    font-weight: 700;
}

.lang-item .lang-name-native {
    opacity: 0.7;
    font-size: 11px;
}

.lang-item:hover, .lang-item.active {
    border-color: #0000FF;
    background: rgba(0, 39, 255, 0.18);
}

.lang-item.active {
    background: rgba(0, 39, 255, 0.28);
    padding-right: 28px; /* место для галочки справа */
    outline: 2px solid #0000FF;
    outline-offset: -2px;
}

.lang-item.active::after {
    content: '✓';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #0000FF;
    font-weight: 800;
    font-size: 14px;
}

.lang-item .lang-code {
    margin-left: auto;
    opacity: 0.8;
}

.lang-item.active .lang-code {
    display: none; /* заменяем код галочкой */
}

.logo-link {
    display: block;
    width: 44px;
    height: 44px;
    position: relative;
    transition: all 0.3s ease;
}

/* Эффект внешней рамки при наведении */
.logo-link::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border: 3px solid #1300F3;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.logo-link:hover::before {
    opacity: 1;
}

/* Убираем рамку при клике */
.logo-link:active::before {
    opacity: 0;
}

/* Убираем рамку при клике также для hover состояния */
.logo-link:active:hover::before {
    opacity: 0;
}

.logo-svg {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.3s ease;
}

/* Состояния логотипа */
.logo-clicked {
    opacity: 0;
}

/* При клике - показываем am-2.svg */
.logo-link:active .logo-svg:not(.logo-clicked) {
    opacity: 0;
}

.logo-link:active .logo-clicked {
    opacity: 1;
}

/* Основной контейнер часов */
.clock-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Часы */
.clock {
    position: relative;
    width: min(90vw, 90vh);
    height: min(90vw, 90vh);
    max-width: 800px;
    max-height: 800px;
}

/* Циферблат */
.clock-face {
    position: relative;
    width: 100%;
    height: 100%;
    background: transparent;
}

/* Палочки на циферблате - по краям страницы */
.line {
    position: fixed;
    background-color: #FFFFFF;
    z-index: 100;
}

.line-12 {
    top: calc(15px + var(--safe-top));
    left: 50%;
    width: 2px;
    height: 30px;
    transform: translateX(-50%);
}

.line-3 {
    top: 50%;
    right: calc(15px + var(--safe-right));
    width: 30px;
    height: 2px;
    transform: translateY(-50%);
}

.line-6 {
    bottom: calc(15px + var(--safe-bottom));
    left: 50%;
    width: 2px;
    height: 30px;
    transform: translateX(-50%);
}

.line-9 {
    top: 50%;
    left: calc(15px + var(--safe-left));
    width: 30px;
    height: 2px;
    transform: translateY(-50%);
}

/* 404 контент в нижнем левом углу */
.error-text {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(24px, 4vw, 48px);
    font-weight: 900;
    color: #0000FF;
    letter-spacing: 0.1em;
    margin-bottom: 10px;
}

.error-description {
    font-family: 'Inter', sans-serif;
    font-size: clamp(12px, 1.5vw, 18px);
    font-weight: 400;
    color: #FFFFFF;
    line-height: 1.4;
    opacity: 0.8;
    max-width: 300px;
    margin-bottom: 5px;
}

.date-block {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.4;
    margin-bottom: 5px;
}

.week-number {
    font-family: 'Inter', sans-serif;
    font-size: clamp(12px, 1.5vw, 18px);
    font-weight: 400;
    color: #FFFFFF;
    line-height: 1.4;
    opacity: 0.8;
    margin-top: 0;
}

/* Центральная точка */
.center-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    background: #FFFFFF;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
}

/* Стрелки */
.hand {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform-origin: 50% 100%;
    background: #FFFFFF;
    border-radius: 2px;
}

.hour-hand {
    width: 4px;
    height: 25%;
    margin-left: -2px;
    z-index: 15;
}

.minute-hand {
    width: 3px;
    height: 35%;
    margin-left: -1.5px;
    z-index: 16;
}

.second-hand {
    width: 1px;
    height: 40%;
    background: #FF0000;
    margin-left: -0.5px;
    z-index: 17;
    transition: none;
}

/* Информация в нижних углах */
.bottom-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: #888;
    z-index: 1000;
    position: absolute;
    bottom: calc(15px + var(--safe-bottom));
    left: calc(20px + var(--safe-left));
    right: calc(20px + var(--safe-right));
    /* Дополнительный отступ для Chrome на мобильных */
    padding-bottom: 5px;
}

.bottom-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    margin-bottom: -5px;
}

.bottom-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    justify-content: flex-end;
    margin-bottom: -5px;
}

.date {
    font-family: 'Inter', sans-serif;
    font-size: clamp(12px, 1.5vw, 18px);
    font-weight: 400;
    color: #FFFFFF;
    line-height: 1.4;
    opacity: 0.8;
    margin-bottom: 0;
}

.uptime-value {
    font-weight: 600;
    font-family: 'Space Grotesk', monospace;
}

/* Адаптивность */
@media (max-width: 768px) {
    .blue-frame {
        top: calc(12px + var(--safe-top));
        left: calc(12px + var(--safe-left));
        right: calc(12px + var(--safe-right));
        bottom: calc(12px + var(--safe-bottom));
        border-width: 4px;
        padding: 25px;
    }
    
    .logo-container {
        top: calc(12px + var(--safe-top));
        left: calc(12px + var(--safe-left));
    }
    
    .lang-switcher { 
        top: calc(12px + var(--safe-top)); 
        right: calc(16px + var(--safe-right)); 
    }
    
    .lang-menu { 
        top: 40px; 
        width: 220px;
    }
    
    .logo-link {
        width: 42px;
        height: 42px;
    }
    
    .clock {
        width: min(85vw, 85vh);
        height: min(85vw, 85vh);
        max-width: 600px;
        max-height: 600px;
    }
    
    .bottom-info {
        font-size: 11px;
        bottom: calc(12px + var(--safe-bottom));
        left: calc(25px + var(--safe-left));
        right: calc(25px + var(--safe-right));
    }
    
    .error-text {
        font-size: clamp(18px, 3vw, 32px);
    }
    
    .error-description {
        font-size: clamp(11px, 1.4vw, 16px);
        max-width: 280px;
    }
    
    .date {
        font-size: clamp(11px, 1.4vw, 16px);
    }
    
    .week-number {
        font-size: clamp(11px, 1.4vw, 16px);
    }
}

@media (max-width: 480px) {
    .blue-frame {
        top: calc(10px + var(--safe-top));
        left: calc(10px + var(--safe-left));
        right: calc(10px + var(--safe-right));
        bottom: calc(10px + var(--safe-bottom));
        border-width: 3px;
        padding: 20px;
    }
    
    .logo-container {
        top: calc(10px + var(--safe-top));
        left: calc(10px + var(--safe-left));
    }
    
    .lang-switcher { 
        top: calc(10px + var(--safe-top)); 
        right: calc(12px + var(--safe-right)); 
    }
    
    .lang-current { 
        padding: 8px 10px; 
        font-size: 12px; 
    }
    
    .lang-menu { 
        top: 36px; 
        width: 200px;
        grid-template-columns: 1fr;
    }
    
    .clock {
        width: min(80vw, 80vh);
        height: min(80vw, 80vh);
        max-width: 400px;
        max-height: 400px;
    }
    
    .error-text {
        font-size: clamp(16px, 2.8vw, 28px);
        margin-bottom: 6px;
    }
    
    .error-description {
        font-size: clamp(10px, 1.3vw, 14px);
        max-width: 220px;
        line-height: 1.3;
    }
    
    .date {
        font-size: clamp(10px, 1.3vw, 14px);
    }
    
    .week-number {
        font-size: clamp(10px, 1.3vw, 14px);
    }
    
    .bottom-info {
        font-size: 10px;
        bottom: calc(10px + var(--safe-bottom));
        left: calc(20px + var(--safe-left));
        right: calc(20px + var(--safe-right));
    }
    
    .bottom-left {
        margin-bottom: 0;
    }
    
    .bottom-right {
        margin-bottom: 0;
    }
}

/* iPhone 11 и современные устройства */
@media (max-width: 414px) {
    .blue-frame {
        top: calc(8px + var(--safe-top));
        left: calc(8px + var(--safe-left));
        right: calc(8px + var(--safe-right));
        bottom: calc(8px + var(--safe-bottom));
        border-width: 3px;
        padding: 18px;
    }
    
    .logo-container {
        top: calc(8px + var(--safe-top));
        left: calc(8px + var(--safe-left));
    }
    
    .lang-switcher { 
        top: calc(8px + var(--safe-top)); 
        right: calc(10px + var(--safe-right)); 
    }
    
    .lang-current { 
        width: 40px;
        height: 40px;
        padding: 6px;
    }
    
    .globe-icon {
        width: 20px;
        height: 20px;
    }
    
    .lang-menu { 
        top: 32px; 
        width: 180px;
        padding: 8px;
    }
    
    .lang-item {
        padding: 6px 8px;
        font-size: 11px;
    }
    
    .clock {
        width: min(75vw, 75vh);
        height: min(75vw, 75vh);
        max-width: 350px;
        max-height: 350px;
    }
    
    .error-text {
        font-size: clamp(14px, 2.5vw, 24px);
        margin-bottom: 4px;
    }
    
    .error-description {
        font-size: clamp(9px, 1.2vw, 12px);
        max-width: 200px;
        line-height: 1.2;
    }
    
    .date {
        font-size: clamp(9px, 1.2vw, 12px);
    }
    
    .week-number {
        font-size: clamp(9px, 1.2vw, 12px);
    }
    
    .bottom-info {
        font-size: 9px;
        bottom: calc(8px + var(--safe-bottom));
        left: calc(18px + var(--safe-left));
        right: calc(18px + var(--safe-right));
    }
}

/* Очень маленькие экраны */
@media (max-width: 375px) {
    .blue-frame {
        top: calc(6px + var(--safe-top));
        left: calc(6px + var(--safe-left));
        right: calc(6px + var(--safe-right));
        bottom: calc(6px + var(--safe-bottom));
        border-width: 2px;
        padding: 15px;
    }
    
    .logo-container {
        top: calc(6px + var(--safe-top));
        left: calc(6px + var(--safe-left));
    }
    
    .lang-switcher { 
        top: calc(6px + var(--safe-top)); 
        right: calc(8px + var(--safe-right)); 
    }
    
    .lang-current { 
        width: 36px;
        height: 36px;
        padding: 5px;
    }
    
    .globe-icon {
        width: 18px;
        height: 18px;
    }
    
    .lang-menu { 
        top: 28px; 
        width: 160px;
        padding: 6px;
    }
    
    .lang-item {
        padding: 5px 6px;
        font-size: 10px;
    }
    
    .clock {
        width: min(70vw, 70vh);
        height: min(70vw, 70vh);
        max-width: 300px;
        max-height: 300px;
    }
    
    .error-text {
        font-size: clamp(12px, 2.2vw, 20px);
        margin-bottom: 3px;
    }
    
    .error-description {
        font-size: clamp(8px, 1.1vw, 10px);
        max-width: 180px;
        line-height: 1.1;
    }
    
    .date {
        font-size: clamp(8px, 1.1vw, 10px);
    }
    
    .week-number {
        font-size: clamp(8px, 1.1vw, 10px);
    }
    
    .bottom-info {
        font-size: 8px;
        bottom: calc(6px + var(--safe-bottom));
        left: calc(15px + var(--safe-left));
        right: calc(15px + var(--safe-right));
    }
}

/* Анимации */
@keyframes tick {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(6deg); }
}

.second-hand {
    animation: none;
}

/* Часы сразу видны без анимации */
.clock-container {
    opacity: 1;
    transform: scale(1);
}

/* Эффект этикетки - градиентные края как на главной */
.blue-frame::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #0000FF, #0040FF, #0000FF);
    z-index: -1;
    border-radius: 2px;
    opacity: 0.3;
}