/* ==========================================================================
   1. ПЕРЕМЕННЫЕ И ГЛОБАЛЬНЫЕ СТИЛИ
   ========================================================================== */
:root { 
    --main-bg: #000000; 
    --text-color: #f5f5f7; 
    --card-bg: #161617; /* Чуть светлее фона для глубины */
    --apple-blue: #0071e3;
    --apple-grey: #86868b;
    --modal-bg: rgba(28, 28, 30, 0.8);
    --glass-border: rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; -webkit-font-smoothing: antialiased; }

body { 
    margin: 0; 
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, sans-serif; 
    background: var(--main-bg); 
    color: var(--text-color); 
    overflow-x: hidden; 
    line-height: 1.47;
}

body.lightbox-open, body.menu-open { overflow: hidden; }

/* Плавная смена картинок (используется в JS) */
.phone-img, #modalImg, .lightbox-img {
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    will-change: opacity, transform;
}

.fade-out {
    opacity: 0 !important;
    transform: scale(0.98);
}

/* ==========================================================================
   2. ШАПКА И НАВИГАЦИЯ (Glassmorphism)
   ========================================================================== */
header { 
    background: rgba(0, 0, 0, 0.72); 
    padding: 10px 20px; 
    border-bottom: 0.5px solid var(--glass-border); 
    position: sticky; 
    top: 0; 
    z-index: 1000; 
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.nav-container {
    display: flex; align-items: center; justify-content: center;
    max-width: 1200px; margin: 0 auto; position: relative; min-height: 44px;
}

.logo-container { 
    position: absolute; left: 0; height: 32px; 
    display: flex; align-items: center; min-width: 120px; 
}
.logo-container img { height: 100%; width: auto; object-fit: contain; }

.nav-items { display: flex; gap: 30px; }
.nav-link { 
    text-decoration: none; color: #a1a1a6; font-size: 12px; 
    transition: color 0.3s; font-weight: 400; letter-spacing: -0.01em;
}
.nav-link:hover, .nav-link.active { color: #fff; }

.right-nav-block { 
    position: absolute; right: 0; 
    display: flex; align-items: center; gap: 15px;
    min-width: 120px; justify-content: flex-end;
}

.login-btn {
    color: #fff; text-decoration: none; font-size: 12px; padding: 6px 14px;
    background: rgba(255, 255, 255, 0.1); border-radius: 20px; 
    transition: all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
}
.login-btn:hover { background: rgba(255, 255, 255, 0.2); }

.header-contact-btn {
    background-color: var(--apple-blue) !important;
    color: white !important; padding: 6px 16px !important; 
    border-radius: 20px !important; font-size: 12px !important; 
    font-weight: 500; text-decoration: none !important;
    display: flex !important; transition: transform 0.2s ease !important;
}
.header-contact-btn:hover { transform: scale(1.05); }

.menu-btn { 
    display: none; background: rgba(255, 255, 255, 0.1); color: white; 
    border: none; padding: 8px 15px; border-radius: 12px; cursor: pointer;
}

/* ==========================================================================
   3. СТОРИС (Бесконечный поток в стиле Apple)
   ========================================================================== */
.stories-container { width: 100%; overflow: hidden; margin: 20px 0; position: relative; }

.stories-track { display: flex; gap: 12px; padding: 5px 20px; width: max-content; animation: scrollStories 45s linear infinite; }
.stories-container:hover .stories-track { animation-play-state: paused; }

@keyframes scrollStories {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

.story-card {
    width: 110px; height: 170px; border-radius: 22px;
    background-size: cover; background-position: center;
    position: relative; flex-shrink: 0;
    border: 1px solid var(--glass-border);
    cursor: pointer; transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.story-card:hover { transform: scale(1.04); z-index: 10; }

.story-card span {
    color: #ffffff; font-size: 11px; font-weight: 500;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    padding: 20px 10px 10px; border-radius: 0 0 22px 22px;
    position: absolute; bottom: 0; left: 0; right: 0;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ==========================================================================
   4. СЕТКА ТОВАРОВ
   ========================================================================== */
.category-title { font-size: 32px; font-weight: 700; margin: 40px 20px 20px; letter-spacing: -0.02em; }

.product-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); 
    gap: 20px; padding: 10px 20px; max-width: 1400px; margin: 0 auto;
}

@media (max-width: 1100px) { .product-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px) { .product-grid { grid-template-columns: repeat(2, 1fr); } }

.card {
    background: var(--card-bg); border-radius: 24px; padding: 25px;
    display: flex; flex-direction: column; text-align: center;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.4s ease;
    height: 100%; position: relative; border: 1px solid transparent;
}
.card:hover { 
    transform: translateY(-8px); 
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4); 
    background: #1c1c1e;
}

.image-wrapper { 
    position: relative; display: flex; align-items: center; justify-content: center;
    margin-bottom: 20px; min-height: 200px; overflow: visible; 
}

.phone-img { width: 100%; height: 200px; object-fit: contain; cursor: pointer; z-index: 1; }

/* УЛУЧШЕННЫЕ АППЛ-СТРЕЛКИ В КАРТОЧКЕ */
.arrow-btn {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15) !important;
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 0.5px solid rgba(255,255,255,0.2) !important;
    border-radius: 50%; width: 34px; height: 34px;
    cursor: pointer; color: white; display: flex; align-items: center; justify-content: center;
    z-index: 100 !important; pointer-events: auto !important; transition: all 0.3s;
    font-size: 18px; font-weight: 300;
}
.arrow-btn:hover { background: rgba(255, 255, 255, 0.3) !important; scale: 1.1; }
.arr-left { left: -5px; }
.arr-right { right: -5px; }

.options-spacer { flex-grow: 1; margin: 15px 0; font-size: 13px; color: var(--apple-grey); }

.contact-btn {
    display: block; background-color: var(--apple-blue); color: white;
    text-decoration: none; padding: 12px 0; border-radius: 20px;
    font-size: 14px; font-weight: 500; transition: background 0.3s;
}
.contact-btn:hover { background-color: #0077ed; }

/* ==========================================================================
   5. ПРОСМОТРЩИКИ И МОДАЛКИ
   ========================================================================== */
.story-viewer {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.94); z-index: 99999;
    display: flex; align-items: center; justify-content: center;
    display: none;
    backdrop-filter: blur(15px);
}

.story-viewer.active {
    display: flex; /* Когда добавится класс active, они появятся */
    opacity: 1;
}

.story-viewer .swiper { width: 100%; height: 100vh !important; }
.story-viewer img { width: 100%; height: 100%; object-fit: contain; }

.close-viewer {
    position: absolute; top: 30px; right: 30px; z-index: 100;
    background: rgba(255,255,255,0.15); border: none; color: white;
    font-size: 24px; cursor: pointer; width: 44px; height: 44px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; backdrop-filter: blur(10px);
}

.product-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 2000; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px);
}
.product-overlay.active { display: flex; }

.product-modal {
    background: var(--modal-bg); color: #fff; padding: 40px; width: 95%; max-width: 500px;
    border-radius: 30px; position: relative; border: 1px solid var(--glass-border);
    box-shadow: 0 30px 60px rgba(0,0,0,0.5);
}

.close-modal {
    position: absolute; top: 20px; left: 20px;
    background: rgba(255, 255, 255, 0.1); border: none; color: #fff;
    width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center; z-index: 10;
}

/* СТРЕЛКИ В МОДАЛКЕ */
.nav-arrow {
    position: absolute; top: 50%; transform: translateY(-50%);
    background-color: rgba(255, 255, 255, 0.12) !important;
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border: none; border-radius: 50%; width: 44px; height: 44px;
    cursor: pointer; color: white !important; font-size: 28px; font-weight: 200;
    display: flex; align-items: center; justify-content: center;
    z-index: 100 !important; transition: all 0.3s;
}
.nav-arrow:hover { background-color: rgba(255, 255, 255, 0.25) !important; }
.nav-arrow.left { left: 10px; } .nav-arrow.right { right: 10px; }

.price-item { display: flex; justify-content: space-between; padding: 15px 0; border-bottom: 0.5px solid var(--glass-border); font-size: 15px; }

#modalContactBtn {
    display: block !important; width: 100% !important; margin: 30px auto 0 !important;
    padding: 14px 0 !important; font-size: 15px !important; text-align: center !important;
    background-color: var(--apple-blue) !important; color: white !important;
    border-radius: 20px !important; font-weight: 500 !important;
}

#modalImg {
    max-height: 45vh; /* Ограничение по высоте (45% от высоты экрана) */
    max-width: 100%;  /* Ограничение по ширине */
    width: 300;     /* Укажите здесь конкретную ширину, если нужно */
    height: auto;     /* Высота подстроится автоматически, чтобы не искажать пропорции */
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.modal-gallery { 
    position: relative; /* ВАЖНО: стрелки будут центрироваться именно по этому блоку */
    display: flex; 
    align-items: center; 
    justify-content: center; 
    margin-bottom: 20px; 
    min-height: 200px; /* Чтобы контейнер имел высоту, даже если картинка еще не прогрузилась */
}
/* ==========================================================================
   6. МОБИЛЬНОЕ МЕНЮ И АДАПТИВНОСТЬ
   ========================================================================== */
#menuOverlay {
    position: fixed; top: 0; right: -100%; width: 85%; max-width: 320px; height: 100%;
    backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px);
    z-index: 9999; flex-direction: column; padding: 80px 40px; gap: 20px;
    transition: right 0.5s cubic-bezier(0.22, 1, 0.36, 1); visibility: hidden;
}
#menuOverlay.active { right: 0; visibility: visible; }

.menu-nav a {
    color: #fff !important; text-decoration: none !important; font-size: 24px !important;
    font-weight: 600; padding: 15px 0 !important; display: block !important;
    border-bottom: 0.5px solid var(--glass-border) !important;
}

    /* КНОПКА КАТЕГОРИИ ТОВАРОВ В МОБИЛЬНОМ МЕНЮ */
@media (max-width: 768px) {
    .nav-items, .header-contact-btn { display: none !important; }
    .menu-btn { display: block !important; border: none; font-size: 12px; }

    /* ВОТ ЗДЕСЬ ИСПРАВИЛ: СДЕЛАЛ ЗАГОЛОВОК МЕНЬШЕ (20px) */
    .category-title { font-size: 20px !important; margin: 25px 15px 10px !important; }
    
    .story-card { width: 80px; height: 80px; border-radius: 50%; border: 2px solid var(--apple-blue); }
    .story-card span { display: none !important; }

    .product-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 12px !important; padding: 10px !important; }
    .card { padding: 15px !important; border-radius: 20px !important; }
    .image-wrapper, .phone-img { height: 140px !important; min-height: 140px !important; }
    .arrow-btn { display: none !important; } 
}

.js-open-modal { cursor: zoom-in; }
