/* =================================
   0. ПЕРЕМЕННЫЕ (VARIABLES / CUSTOM PROPERTIES)
   ================================= */

:root {
    /* Цвета */
    --color-text: #111827;
    --color-primary: #3B82F6;
    --color-background: #FDFDFD;
    --color-background-section: #F9F7F5;
    --hero-bg-desktop: url('../images/background.webp');
    --hero-bg-mobile: url('../images/background-mobile.webp');

    /* Типографика */
    --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Эффекты */
    --transition-main: all 0.3s ease;
    --shadow-button-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-card-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* =================================
   1. ОБЩИЕ СТИЛИ (GLOBAL STYLES)
   ================================= */

html {
    overflow-x: hidden;
}

body {
    font-family: var(--font-main);
    background-color: var(--color-background);
    color: var(--color-text);
    overflow-wrap: break-word;
    word-break: break-word;
    overflow-x: hidden;
}

/* =================================
   2. ВСПОМОГАТЕЛЬНЫЕ КЛАССЫ (UTILITY CLASSES)
   ================================= */

.hero-bg {
    background-image: var(--hero-bg-desktop);
    background-size: cover;
    background-position: center top 30%;
    background-repeat: no-repeat;
}

/* Mobile uses a dedicated crop instead of reusing the desktop composition. */
@media (max-width: 767px) {
    .hero-bg {
        background-image: var(--hero-bg-mobile);
        background-position: center top 18%;
    }
}

.section-bg {
    background-color: var(--color-background-section);
}

/* =================================
   3. КОМПОНЕНТЫ (COMPONENTS)
   ================================= */

/* --- Кнопка (Button) --- */
.cta-button {
    transition: var(--transition-main);
}

.cta-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-button-hover);
}

/* --- Карточки (Cards) --- */
.service-card,
.team-card,
.testimonial-card {
    transition: var(--transition-main);
}

.service-card:hover,
.team-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-card-hover);
}

/* --- Навигационная ссылка (Nav Link) --- */
.nav-link {
    position: relative;
    transition: color 0.3s;
}

.nav-link:hover {
    color: var(--color-primary);
}

.nav-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--color-primary);
    transition: width 0.3s;
}

.nav-link:hover::after {
    width: 100%;
}

/* --- Header brand --- */
.brand-title {
    line-height: 1;
    letter-spacing: 0.01em;
}

.site-header-brand {
    align-items: center;
}

.site-header-phone {
    flex-shrink: 0;
}

@media (max-width: 1023px) {
    .site-header-row {
        min-height: 2.75rem;
    }

    .site-header-brand .brand-title {
        font-size: 1.75rem;
        line-height: 1;
    }

    .site-header-mobile-actions {
        align-items: center;
    }

    .site-header-mobile-icon {
        width: 2.5rem;
        height: 2.5rem;
        flex-shrink: 0;
    }

    #mobile-menu-button svg,
    #low-vision-btn-mobile svg {
        width: 1.25rem;
        height: 1.25rem;
    }
}

@media (max-width: 639px) {
    .site-header-brand .brand-title {
        font-size: 1.5rem;
    }
}

@media (min-width: 1024px) and (max-width: 1539px) {
    .site-header-row {
        gap: 0.75rem;
    }

    .site-header-row .brand-title {
        font-size: 1.35rem;
    }

    .site-header-phone {
        margin-left: 0.75rem !important;
        padding-left: 0.75rem !important;
        font-size: 0.8125rem;
    }
}

/* =================================
   4. ПАНЕЛЬ ДОСТУПНОСТИ (ACCESSIBILITY PANEL — ГОСТ Р 52872-2019)
   ================================= */

/* --- Panel Control Buttons --- */
.lv-ctrl {
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.3);
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.lv-ctrl:hover {
    background-color: rgba(255,255,255,0.15);
}
.lv-ctrl.lv-active {
    background-color: #3B82F6;
    border-color: #3B82F6;
    color: #fff;
}

/* Theme preview buttons (idle state) */
.lv-ctrl[data-lv-theme="bw"]:not(.lv-active) {
    background-color: #fff;
    color: #000;
    border-color: #9ca3af;
}
.lv-ctrl[data-lv-theme="wb"]:not(.lv-active) {
    background-color: #000;
    color: #fff;
    border-color: #6b7280;
}

/* --- Panel Open: show panel & shift fixed header --- */
html.lv-panel-open #lv-panel {
    transform: translateY(0);
}
html.lv-panel-open header {
    top: var(--lv-panel-h, 0px) !important;
}
html.lv-panel-open {
    padding-top: var(--lv-panel-h, 0px);
}

/* --- Font Size Scaling (rem-based) --- */
html.lv-font-large { font-size: 125% !important; }
html.lv-font-huge  { font-size: 150% !important; }

/* ======== Theme: Black on White (high contrast) ======== */
html.lv-theme-bw { background-color: #fff !important; }
html.lv-theme-bw * {
    background-color: #fff !important;
    color: #000 !important;
    border-color: #333 !important;
    box-shadow: none !important;
    text-shadow: none !important;
}
html.lv-theme-bw a {
    color: #0000CC !important;
    text-decoration: underline !important;
}
html.lv-theme-bw .hero-bg {
    background-image: none !important;
}

/* ======== Theme: White on Black (inverted) ======== */
html.lv-theme-wb { background-color: #1a1a1a !important; }
html.lv-theme-wb * {
    background-color: #1a1a1a !important;
    color: #f0f0f0 !important;
    border-color: #555 !important;
    box-shadow: none !important;
    text-shadow: none !important;
}
html.lv-theme-wb a {
    color: #FFD700 !important;
    text-decoration: underline !important;
}
html.lv-theme-wb .hero-bg {
    background-image: none !important;
}

/* ======== Panel Protection from theme overrides ======== */
/* ID selectors beat html.lv-theme-* class selectors, keeping panel styled */
#lv-panel {
    background-color: #111827 !important;
}
#lv-panel * {
    background-color: transparent !important;
    color: #fff !important;
    border-color: rgba(255,255,255,0.3) !important;
    box-shadow: none !important;
}
#lv-panel #lv-reset {
    background-color: #dc2626 !important;
}
#lv-panel #lv-reset:hover {
    background-color: #b91c1c !important;
}
#lv-panel .lv-active {
    background-color: #3B82F6 !important;
    border-color: #3B82F6 !important;
    color: #fff !important;
}
#lv-panel .lv-ctrl:hover:not(.lv-active) {
    background-color: rgba(255,255,255,0.15) !important;
}
#lv-panel [data-lv-theme="bw"]:not(.lv-active) {
    background-color: #fff !important;
    color: #000 !important;
    border-color: #9ca3af !important;
}
#lv-panel [data-lv-theme="wb"]:not(.lv-active) {
    background-color: #000 !important;
    color: #fff !important;
    border-color: #6b7280 !important;
}

/* ======== Hide Images ======== */
html.lv-hide-images img,
html.lv-hide-images iframe {
    visibility: hidden !important;
}
html.lv-hide-images .hero-bg {
    background-image: none !important;
}
html.lv-hide-images svg:not(header svg):not(#mobile-cta svg):not(#lv-panel svg) {
    display: none !important;
}

/* =================================
   5. АНИМАЦИИ (ANIMATIONS)
   ================================= */

/* --- Hero title: adaptive line spacing --- */
.hero-title {
    line-height: 1.2;
}

/* Gap between static line and rotating phrases — scales with font size */
.hero-title .hero-phrase-grid {
    margin-top: 0.15em;
}

/* --- Hero: CSS Grid phrase stack (all phrases in one cell) --- */
.hero-phrase-grid {
    display: inline-grid;
    justify-items: center;
    align-items: center;
    line-height: 1.15;
}

/* Every phrase occupies the same grid cell — container sizes to the largest */
.hero-phrase {
    grid-area: 1 / 1;
    opacity: 0;
    transform: translateY(12px);
    filter: blur(4px);
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                filter  0.5s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.hero-phrase.is-active {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
    pointer-events: auto;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-6px); }
    30% { transform: translateX(5px); }
    45% { transform: translateX(-4px); }
    60% { transform: translateX(3px); }
    75% { transform: translateX(-2px); }
}

.animate-shake {
    animation: shake 0.5s ease-in-out;
}

/* =================================
   6. ГОРИЗОНТАЛЬНАЯ КАРУСЕЛЬ (HORIZONTAL SCROLL CAROUSEL)
   ================================= */

/* Скрытие полосы прокрутки для каруселей */
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

/* =================================
   6b. СЛАЙДЕР УСЛУГ (FEATURE SLIDER)
   ================================= */

/* Gradient overlay for text readability on slide images */
.feature-slide > div::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.1) 40%, transparent 70%);
    border-radius: inherit;
    pointer-events: none;
    z-index: 1;
}

/* =================================
   7. МОБИЛЬНАЯ АДАПТАЦИЯ (MOBILE RESPONSIVENESS)
   ================================= */

/* --- Минимальные области касания (44x44px per WCAG) --- */
@media (pointer: coarse) {
    .mobile-nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    #mobile-menu-button {
        min-width: 44px;
        min-height: 44px;
    }

    input[type="checkbox"] {
        min-width: 20px;
        min-height: 20px;
    }
}

/* --- Код услуги (Service Code) --- */
.text-muted {
    color: #6b7280;
}

.service-code {
    display: inline;
    font-size: 0.7em;
    font-weight: 400;
    margin-left: 0.4em;
    opacity: 0.45;
}

/* --- Прайс-лист: мобильная карточная раскладка --- */
@media (max-width: 640px) {
    #price-accordion table {
        font-size: 0.875rem;
    }

    #price-accordion thead {
        display: none;
    }

    #price-accordion tbody tr {
        display: flex;
        flex-direction: column;
        padding: 0.75rem 1rem;
    }

    #price-accordion tbody tr:hover {
        background-color: #f9fafb;
    }

    html.dark #price-accordion tbody tr:hover {
        background-color: rgba(31, 41, 55, 0.5);
    }

    #price-accordion tbody td {
        padding: 0.125rem 0;
        text-align: left !important;
        white-space: normal !important;
    }

    #price-accordion tbody td:last-child {
        font-size: 0.9375rem;
        margin-top: 0.25rem;
    }

    /* Аккордеон-кнопки */
    #price-accordion button {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    #price-accordion button span:first-child {
        font-size: 0.9375rem;
    }

    .service-code {
        display: inline;
        margin-left: 0.3em;
        margin-top: 0;
    }
}

/* --- Прайс-лист: предотвращение горизонтального скролла --- */
@media (max-width: 767px) {
    #price-accordion .overflow-x-auto {
        overflow-x: hidden;
    }
}

/* --- Футер: мобильная однокколоночная раскладка --- */
@media (max-width: 767px) {
    footer .grid {
        text-align: center;
    }
}

@media (min-width: 1024px) {
    html.lv-font-large .site-header-row,
    html.lv-font-huge .site-header-row {
        gap: 1rem;
    }

    html.lv-font-large .site-header-phone,
    html.lv-font-huge .site-header-phone {
        font-size: 0.875rem;
        line-height: 1.2;
    }
}

/* =================================
   7b. COOKIE CONSENT
   ================================= */

.cookie-toggle-thumb {
    will-change: transform;
}

#cookie-banner {
    max-height: calc(100dvh - 1rem);
}

.cookie-banner-panel {
    overflow-y: auto;
}

#cookie-settings-dialog {
    max-height: calc(100dvh - 1.5rem);
    overflow-y: auto;
}

html.lv-theme-bw #cookie-consent-root,
html.lv-theme-wb #cookie-consent-root {
    position: relative;
    z-index: 90;
}

html.lv-theme-bw #cookie-consent-root *,
html.lv-theme-wb #cookie-consent-root * {
    box-shadow: none !important;
    text-shadow: none !important;
}

html.lv-theme-bw #cookie-banner > div,
html.lv-theme-bw #cookie-settings-dialog {
    background: #ffffff !important;
    color: #000000 !important;
    border-color: #111827 !important;
}

html.lv-theme-wb #cookie-banner > div,
html.lv-theme-wb #cookie-settings-dialog {
    background: #111111 !important;
    color: #ffffff !important;
    border-color: #ffffff !important;
}

html.lv-theme-bw #cookie-settings-modal > div:first-child,
html.lv-theme-wb #cookie-settings-modal > div:first-child {
    background: rgba(0, 0, 0, 0.35) !important;
}

@media (max-width: 640px) {
    #cookie-banner {
        left: 0;
        right: 0;
        transform: none;
        bottom: max(0.75rem, env(safe-area-inset-bottom));
    }

    .cookie-banner-panel {
        max-height: calc(100dvh - 1.5rem);
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    #cookie-settings-modal {
        padding-bottom: env(safe-area-inset-bottom);
    }

    #cookie-settings-dialog {
        max-height: calc(100dvh - 1rem);
        border-radius: 1.25rem;
    }
}

/* =================================
   8. ТЁМНАЯ ТЕМА (DARK MODE)
   ================================= */

html.dark {
    --color-text: #f3f4f6;
    --color-background: #111827;
    --color-background-section: #1f2937;
}

html.dark body {
    background-color: var(--color-background);
    color: var(--color-text);
}

/* Section alternating background */
html.dark .section-bg {
    background-color: var(--color-background-section);
}

/* Hero glassmorphism card — dark mode handled via Tailwind dark: class on element */

/* Header in dark mode */
html.dark header {
    background-color: rgba(17, 24, 39, 0.85) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
