/* ========================================= */
/* === HYDRATION & CRITICAL LOGIC START === */
/* ========================================= */

:root {
    --color-bg: #030409;
    --color-text: #FFFFFF;
    --color-accent: #b8d8e8;
    --color-card: rgba(25, 29, 45, 0.4);
    --color-border: rgba(184, 216, 232, 0.2);
    --font-main: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --header-height: 80px;
}

/* 1. Если страница статическая — убираем лоадер сразу */
body[data-static-page="true"] #loader {
    display: none !important;
}

/* 2. Отменяем скрытие main при загрузке статики */
body[data-static-page="true"] main {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
}

/* 3. Принудительно показываем элементы, которые обычно анимируются JS-ом,
      чтобы пользователь видел текст сразу, пока JS не подгрузился */
body[data-static-page="true"] .animate-always,
body[data-static-page="true"] .floating-item,
body[data-static-page="true"] .hero-subtitle-container {
    opacity: 1 !important;
    transform: none !important;
}

/* ======================================= */
/* === HYDRATION & CRITICAL LOGIC END === */
/* ======================================= */

body { 
    margin: 0; 
    padding: 0; 
    background-color: var(--color-bg); 
    color: var(--color-text);
    font-family: var(--font-main);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    line-height: 1.6;
}

h1, h2, h3, h4 { font-weight: 600; letter-spacing: 0.5px; }
h2 { font-size: clamp(1.8rem, 1.5rem + 1.5vw, 2.5rem); }
a { color: var(--color-accent); text-decoration: none; }

#loader { 
    position: fixed; 
    top: 0; left: 0; 
    width: 100%; height: 100%; 
    background: var(--color-bg); 
    display: flex; justify-content: center; align-items: center; 
    z-index: 10000; 
    transition: opacity 0.5s ease-out;
}
#loader.hidden { opacity: 0; pointer-events: none; }
.spinner { 
    width: 50px; height: 50px; 
    border: 3px solid var(--color-accent); 
    border-radius: 50%; 
    border-top-color: transparent; 
    animation: spin 1s linear infinite; 
}
@keyframes spin { to { transform: rotate(360deg); } }

#custom-background-iframe {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    border: none;
    z-index: 0;
    display: none;
}

/* --- ANIMATIONS --- */
@keyframes slide-out {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(-30px); }
}

main {
    position: relative;
    z-index: 2;
    max-width: 1200px;
    margin: 0 auto;
    padding: 100px 30px;
    opacity: 1; 
    transition: opacity 0.4s ease-in-out;
}

main.loading {
    opacity: 0; 
    transition: none; 
}

main.is-transitioning {
    opacity: 0;
    transform: translateY(-30px);
}

.animate-always {
    opacity: 0;
    transform: translateY(35px);
    transition: transform 1.2s cubic-bezier(0.2, 0.82, 0.2, 1), 
                opacity 1.2s cubic-bezier(0.2, 0.82, 0.2, 1);
    will-change: transform, opacity;
}
.hero .hero-subtitle-container.animate-always {
    transition-delay: 0.15s;
}
.animate-always.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.floating-item {
    opacity: 0;
    transform: translateY(60px);
    transition: transform 1.2s cubic-bezier(0.2, 0.8, 0.2, 1), 
                opacity 1.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    will-change: transform, opacity;
}
.floating-item.is-visible { 
    opacity: 1; 
    transform: translateY(0); 
}
.floating-item.is-above { 
    opacity: 0.5; 
    transform: translateY(-60px); 
}

.animate-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
    will-change: transform, opacity;
}
.animate-on-scroll.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- COMPONENTS --- */
.hero { 
    min-height: 90vh; 
    display: flex; 
    flex-direction: column; 
    justify-content: center; 
    padding: 0 30px; 
    max-width: 1200px; 
    margin: 0 auto;
    contain: content; 
}
.hero h1 { 
    font-size: clamp(2.5rem, 8vw, 4.5rem); 
    margin: 0 0 20px; 
    line-height: 1.1; 
    font-weight: 700; 
    text-shadow: 0 0 15px rgba(184, 216, 232, 0.4);
}
.hero-subtitle-container p { 
    font-size: 1.4rem; 
    max-width: 600px; 
    opacity: 0.9; 
    margin-bottom: 25px;
    line-height: 1.5;
}
.hero-contact-list {
    list-style: disc;
    padding-left: 25px;
    margin: 0;
    font-size: 1.1rem;
}
.hero-contact-list li { margin-bottom: 10px; }
.hero-contact-list a { color: var(--color-accent); text-decoration: none; }

.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 30px; margin-top: 40px; }
.item-card { height: 520px; display: flex; flex-direction: column; background: var(--color-card); border: 1px solid var(--color-border); border-radius: 8px; overflow: hidden; transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1); }
.item-card:hover { transform: translateY(-10px) scale(1.02) !important; border-color: var(--color-accent); box-shadow: 0 10px 30px rgba(184, 216, 232, 0.3); }
.item-card__image { height: 220px; width: 100%; flex-shrink: 0; background: linear-gradient(135deg, rgba(184, 216, 232, 0.1), rgba(25, 29, 45, 0.7)); background-size: cover; background-position: center; opacity: 1; transition: opacity 0.8s ease-in-out; position: relative; overflow: hidden; }
.item-card__content { padding: 25px; display: flex; flex-direction: column; flex-grow: 1; overflow: hidden; }
.item-card h3 { margin: 0 0 10px; font-size: 1.3rem; transition: color 0.3s ease-out; color: var(--color-text); flex-shrink: 0; }
.item-card:hover h3 { color: var(--color-accent); }
.item-card .card-subtitle { display: block; margin-bottom: 15px; opacity: 0.8; font-size: 0.9rem; color: var(--color-text); flex-shrink: 0; }
.item-card p { margin: 0; font-size: 1.05rem; opacity: 0.9; color: var(--color-text); overflow-y: auto; flex-grow: 1; padding-right: 5px; scrollbar-width: thin; scrollbar-color: var(--color-accent) var(--color-border); }
.item-card p::-webkit-scrollbar { width: 4px; }
.item-card p::-webkit-scrollbar-track { background: rgba(184, 216, 232, 0.1); border-radius: 2px; }
.item-card p::-webkit-scrollbar-thumb { background: var(--color-accent); border-radius: 2px; }

.menu-toggle { position: fixed; top: 30px; right: 30px; z-index: 1000; background: transparent; border: none; padding: 0; cursor: pointer; width: 30px; height: 24px; display: flex; flex-direction: column; justify-content: space-between; transition: transform 0.4s; }
.menu-toggle:hover { transform: scale(1.1); }
.menu-toggle .bar { background: #FFFFFF; height: 2px; width: 100%; transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1); transform-origin: right; }
.menu-toggle.is-active .bar:nth-child(1) { transform: translateY(11px) rotate(-45deg); background: var(--color-accent); }
.menu-toggle.is-active .bar:nth-child(2) { opacity: 0; }
.menu-toggle.is-active .bar:nth-child(3) { transform: translateY(-11px) rotate(45deg); background: var(--color-accent); }
.nav-overlay { position: fixed; top: 0; right: -100%; width: 400px; height: 100vh; background: var(--color-card); backdrop-filter: blur(10px); z-index: 999; transition: right 0.6s cubic-bezier(0.77, 0, 0.175, 1); overflow: hidden; }
.nav-overlay.is-active { right: 0; }
.nav-menu { padding: 100px 40px; list-style: none; margin: 0; }
.nav-menu li { margin-bottom: 25px; opacity: 0; transform: translateX(30px); transition: all 0.4s ease-out; }
.nav-overlay.is-active .nav-menu li { opacity: 1; transform: translateX(0); }
.nav-menu li:nth-child(1) { transition-delay: 0.1s; } .nav-menu li:nth-child(2) { transition-delay: 0.2s; } .nav-menu li:nth-child(3) { transition-delay: 0.3s; } .nav-menu li:nth-child(4) { transition-delay: 0.4s; } .nav-menu li:nth-child(5) { transition-delay: 0.5s; }
.nav-menu a { color: var(--color-text); font-size: 1.8rem; position: relative; padding-bottom: 5px; transition: all 0.3s ease-out; }
.nav-menu a:hover { color: var(--color-accent); transform: translateX(5px); }
.nav-menu a::after { content: ''; position: absolute; bottom: 0; left: 0; width: 0; height: 1px; background: var(--color-accent); transition: width 0.4s; }
.nav-menu a:hover::after { width: 100%; }

.detail-page-header { text-align: left; margin-bottom: 60px; }
.detail-page-header h1 { font-size: clamp(2rem, 4vw, 3rem); margin: 0 0 20px; line-height: 1.1; font-weight: 700; text-shadow: 0 0 15px rgba(184, 216, 232, 0.4); }
.detail-price { font-size: 1.2rem; color: var(--color-accent); letter-spacing: 1px; }
.detail-content { font-size: clamp(1.1rem, 1rem + 0.5vw, 1.25rem); opacity: 0.95; max-width: 800px; margin: 0 auto; }
.detail-content p, .detail-content li, .detail-content div { margin-bottom: 1.5em; }
.detail-content b, .detail-content strong { color: var(--color-accent); font-weight: 600; }
.detail-content a { text-decoration: underline; }
#related-posts { margin-bottom: 60px; }
#related-posts h2 { text-align: center; font-size: 1.4rem; font-weight: 500; letter-spacing: 0.5px; opacity: 0.9; margin-bottom: 30px; }
#related-posts .item-grid { margin-top: 20px; }

/* Desktop Carousel */
.desktop-grid-wrapper { display: block; margin-top: 40px; }
.desktop-language-group { margin-bottom: 50px; }
.desktop-language-group:last-child { margin-bottom: 0; }
.desktop-lang-title { color: var(--color-accent); font-size: 1.1rem; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 1px solid var(--color-border); }
.desktop-carousel-container { position: relative; height: 530px !important; min-height: 530px !important; overflow: hidden; transition: none !important; }
.desktop-grid-slide { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 30px; position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 0.8s ease-in-out; pointer-events: none; z-index: 1; }
.desktop-grid-slide.active { opacity: 1; pointer-events: auto; z-index: 2; }
.desktop-slider-nav { text-align: center; margin-top: 25px; }
.desktop-slider-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background-color: var(--color-border); margin: 0 5px; cursor: pointer; transition: background-color 0.3s ease, transform 0.3s ease; }
.desktop-slider-dot.active { background-color: var(--color-accent); transform: scale(1.2); }

/* Mobile Slider */
.mobile-sliders-container { display: none; }
.language-slider-block { margin-bottom: 30px; }
.cross-fade-slider { position: relative; -webkit-tap-highlight-color: transparent; height: 530px !important; min-height: 530px !important; overflow: hidden; transition: none !important; }
.cross-fade-slider .item-card { position: absolute; top: 0; left: 0; width: 100%; opacity: 0; z-index: 1; pointer-events: none; transform: translateY(40px); transition: opacity 0.7s ease-in-out, transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1); }
.cross-fade-slider .item-card:hover { transform: translateY(0) !important; box-shadow: none; border-color: var(--color-border); }
.cross-fade-slider .item-card.active { opacity: 1; z-index: 2; pointer-events: auto; transform: translateY(0); }
.slider-nav { text-align: center; margin-top: 20px; position: relative; z-index: 3; }
.slider-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background-color: var(--color-border); margin: 0 5px; cursor: pointer; transition: background-color 0.3s ease, transform 0.3s ease; }
.slider-dot.active { background-color: var(--color-accent); transform: scale(1.2); }

.site-footer { position: relative; z-index: 2; text-align: center; padding: 20px 30px; font-size: 0.9rem; color: rgba(255, 255, 255, 0.5); margin-top: -60px; cursor: pointer; user-select: none; -webkit-user-select: none; }

@media (max-width: 1024px) { .nav-overlay { width: 100%; } }
@media (max-width: 767px) {
    section:not(#related-posts) > .desktop-grid-wrapper { display: none; }
    section:not(#related-posts) > .mobile-sliders-container { display: block; margin-top: 40px; }
    #related-posts .item-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) and (orientation: landscape) { #related-posts .item-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) {
    main { padding: 60px 15px; }
    section { margin-bottom: 60px; }
    .hero { padding: 0 16px; min-height: 85vh; justify-content: center; }
    .hero h1 { font-size: 2.5rem; margin-bottom: 15px; }
    .hero-subtitle-container p { font-size: 1.1rem; }
    .nav-menu { padding: 80px 20px; }
    .nav-menu a { font-size: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}