/*
 * Favicon and PWA Styles for Graceful Zen Blog
 *
 * Дополнительные стили для поддержки favicon и PWA функциональности
 */

/* Стили для favicon в разных состояниях */
link[rel="icon"] {
    transition: all 0.3s ease;
}

/* Поддержка высокого разрешения для Retina дисплеев */
@media only screen and (-webkit-min-device-pixel-ratio: 2),
       only screen and (min--moz-device-pixel-ratio: 2),
       only screen and (-o-min-device-pixel-ratio: 2/1),
       only screen and (min-device-pixel-ratio: 2),
       only screen and (min-resolution: 192dpi),
       only screen and (min-resolution: 2dppx) {

    /* Обеспечиваем четкость иконок на Retina */
    link[rel="apple-touch-icon"] {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Стили для PWA установки */
.pwa-install-button {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, #16b7cc 0%, #14a5b8 100%);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(22, 183, 204, 0.3);
    z-index: 9999;
    transition: all 0.3s ease;
}

.pwa-install-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(22, 183, 204, 0.4);
}

.pwa-install-button.show {
    display: block;
    animation: slideInFromRight 0.5s ease;
}

@keyframes slideInFromRight {
    from {
        transform: translateX(100px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Стили для splash screen (iOS) */
@media screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) {
    /* iPhone X/XS */
    link[rel="apple-touch-startup-image"] {
        content: url('/wp-content/themes/graceful-zen-blog/favicon/apple-touch-icon.png');
    }
}

/* Скрытие стандартных элементов браузера в PWA режиме */
@media all and (display-mode: standalone) {
    /* Стили для автономного режима PWA */
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Скрываем элементы, которые не нужны в PWA */
    .browser-only {
        display: none !important;
    }
}

/* Стили для уведомления об установке PWA */
.pwa-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    max-width: 300px;
    text-align: center;
    display: none;
}

.pwa-notification.show {
    display: block;
    animation: popIn 0.5s ease;
}

@keyframes popIn {
    from {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.pwa-notification h3 {
    color: #16b7cc;
    margin: 0 0 15px 0;
    font-size: 18px;
}

.pwa-notification p {
    color: #666;
    margin: 0 0 20px 0;
    line-height: 1.5;
}

.pwa-notification .buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.pwa-notification button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.pwa-notification .install-btn {
    background: #16b7cc;
    color: white;
}

.pwa-notification .install-btn:hover {
    background: #14a5b8;
}

.pwa-notification .cancel-btn {
    background: #f8f9fa;
    color: #666;
}

.pwa-notification .cancel-btn:hover {
    background: #e9ecef;
}

/* Overlay для PWA уведомления */
.pwa-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: none;
}

.pwa-overlay.show {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Адаптивные стили для мобильных устройств */
@media (max-width: 768px) {
    .pwa-install-button {
        bottom: 15px;
        right: 15px;
        padding: 10px 16px;
        font-size: 13px;
    }

    .pwa-notification {
        max-width: 280px;
        padding: 20px;
        margin: 0 20px;
    }

    .pwa-notification .buttons {
        flex-direction: column;
    }

    .pwa-notification button {
        width: 100%;
    }
}

/* Стили для темной темы */
@media (prefers-color-scheme: dark) {
    .pwa-notification {
        background: #2d3748;
        color: white;
    }

    .pwa-notification p {
        color: #cbd5e0;
    }

    .pwa-notification .cancel-btn {
        background: #4a5568;
        color: #cbd5e0;
    }

    .pwa-notification .cancel-btn:hover {
        background: #2d3748;
    }
}

/* Анимация для лоадинга favicon */
@keyframes faviconPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.favicon-loading {
    animation: faviconPulse 1.5s ease-in-out infinite;
}

/* Стили для индикатора уведомлений в favicon */
.favicon-badge {
    position: relative;
}

.favicon-badge::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 8px;
    background: #ff4444;
    border-radius: 50%;
    border: 1px solid white;
}
