/* =================================
   Стилізація блоку .service-header
   ================================= */

/* 1. Загальні стилі хедера */
.service-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 80px;
    background: transparent;
    z-index: 1000;
    transition: all 0.3s ease;
}

.service-header.is-scrolled {
    background: var(--bg-surface);
    box-shadow: 0 -6px 10px 10px var(--primary-20);
}

.service-header__inner {
    /* width / gutter → dsa-theme layout.css */
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* 2. Логотип */
.service-header__logo {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    min-height: 48px;
}

.service-header__logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    min-height: 48px;
}

.service-header__logo-placeholder {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-body);
    background: var(--primary-10);
    padding: 8px 16px;
    border-radius: var(--radius-s);
}

/* Логотип: любой формат (SVG, PNG, JPG, WebP). height задаёт размер для SVG без размеров. */
.service-header__logo-img {
    display: block;
    height: 48px;
    width: auto;
    max-height: 48px;
    max-width: 240px;
    object-fit: contain;
    vertical-align: middle;
    transition: height 0.3s ease, max-height 0.3s ease;
}

/* 3. Головне меню */
.service-header__nav {
    flex: 1;
    display: flex;
    justify-content: center;
}

.service-header__menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 56px;
    align-items: center;
}

.service-header__menu-item {
    position: relative;
    font-weight: 400;
}

.service-header__menu-item a,
.service-header__menu-link {
    position: relative;
    display: block;
    text-decoration: none;
    color: var(--text-body);
    font-size: 16px;
    font-weight: 500;
    padding: 10px 16px;
    transition: color 0.3s ease;
    cursor: pointer;
}

@media (min-width: 991px) {
    .service-header__menu-item a,
    .service-header__menu-link {
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }

    .service-header__logo,
    .service-header__logo-link {
        min-height: 60px;
    }

    .service-header__logo-img {
        height: 60px;
        max-height: 60px;
    }

    .service-header.is-scrolled .service-header__logo,
    .service-header.is-scrolled .service-header__logo-link {
        min-height: 48px;
    }

    .service-header.is-scrolled .service-header__logo-img {
        height: 48px;
        max-height: 48px;
    }

    .service-header__lang-item a {
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }
}

.service-header__menu-item a:hover,
.service-header__menu-item a:focus,
.service-header__menu-link:hover,
.service-header__menu-link:focus {
    color: var(--primary);
}

/* Линия снизу: растёт из центра при наведении */
.service-header__menu-item a::after,
.service-header__menu-link::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 0;
    height: 2px;
    background-color: var(--primary);
    transition: width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    transform: translateX(-50%);
}

.service-header__menu-item a:hover::after,
.service-header__menu-item a:focus::after,
.service-header__menu-link:hover::after,
.service-header__menu-link:focus::after {
    width: 100%;
}

.service-header__menu-item.current-menu-item a {
    color: var(--primary);
}

.service-header__menu-item.current-menu-item a::after {
    width: 100%;
}

/* 4. Пункт "Послуги" */
.service-header__menu-item--has-children {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.service-header__menu-toggle {
    background: var(--border-primary);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-s);
    padding: 0;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-body);
}

.service-header__menu-toggle:hover,
.service-header__menu-toggle:focus {
    background: var(--error-20);
    color: var(--primary);
}

.service-header__menu-toggle-icon {
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid currentColor;
    transition: transform 0.3s ease;
}

.service-header__menu-toggle[aria-expanded="true"] .service-header__menu-toggle-icon {
    transform: rotate(180deg);
}

.service-header__menu-toggle[aria-expanded="true"] {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* 5. Canvas */
.service-header__canvas {
    position: fixed;
    top: 0;
    left: -480px;
    width: 480px;
    height: 100vh;
    background: var(--bg-surface);
    box-shadow: var(--shadow-xl);
    z-index: 1001;
    transition: transform 0.3s ease;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-primary) transparent;
}

.service-header__canvas.is-open {
    transform: translateX(480px);
}

/* Стильный скроллбар: WebKit (Chrome, Safari, Edge) */
.service-header__canvas::-webkit-scrollbar {
    width: 8px;
}

.service-header__canvas::-webkit-scrollbar-track {
    background: transparent;
}

.service-header__canvas::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border-radius: 4px;
}

.service-header__canvas::-webkit-scrollbar-thumb:hover {
    background: var(--text-body);
}

/* 6. Overlay */
.service-header__canvas-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.service-header__canvas-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* 7. Контент canvas */
.service-header__canvas-content {
    padding: 40px 30px;
    width: 100%;
    box-sizing: border-box;
}

.service-header__canvas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    padding-top: 20px;
    border-bottom: 1px solid var(--border-primary);
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    z-index: 10;
}

.service-header__canvas-title {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-title);
    margin: 0;
}

.service-header__canvas-close {
    background: var(--primary-5);
    border: 1px solid var(--primary);
    font-size: 24px;
    cursor: pointer;
    color: var(--text-title);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-s);
    transition:
        background-color 0.3s ease,
        color 0.3s ease,
        border-color 0.3s ease;
}

.service-header__canvas-close:hover,
.service-header__canvas-close:focus,
.service-header__canvas-close:active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-title);
}

/* 8. Список послуг */
.service-header__services-list {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
}

.service-header__services-list > .menu-item {
    margin-bottom: 4px;
    width: 100%;
    box-sizing: border-box;
}

.service-header__services-list > .menu-item > a {
    display: block;
    padding: 12px 16px;
    color: var(--text-body);
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--radius-s);
    border: 1px solid transparent;
    transition: all 0.3s ease;
}

.service-header__services-list > .menu-item > a:hover,
.service-header__services-list > .menu-item > a:focus {
    background: var(--primary-10);
    color: var(--primary);
    border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
}

.service-header__services-list > .menu-item.menu-item-has-children {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
}

/* Подменю — всегда с новой строки, на всю ширину */
.service-header__services-list > .menu-item.menu-item-has-children > .sub-menu {
    flex-basis: 100%;
    width: 100%;
}

.service-header__services-list > .menu-item.menu-item-has-children > a {
    flex: 1 1 0%;
    min-width: 0;
    overflow-wrap: break-word;
    display: block;
}

.service-header__submenu-toggle {
    flex-shrink: 0;
    align-self: stretch;
    width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-body);
    font-size: 14px;
    cursor: pointer;
    border-radius: var(--radius-s);
    transition: transform 0.3s ease, color 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}

.service-header__submenu-toggle:hover,
.service-header__submenu-toggle:focus {
    background: var(--primary-10);
    color: var(--primary);
    border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
}

.service-header__submenu-toggle[aria-expanded="true"] {
    transform: rotate(180deg);
}

.sub-menu {
    list-style: none;
    margin: 8px 0 0 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.sub-menu.is-open {
    max-height: 500px; /* fallback */
    max-height: min(500px, 60vh);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border-primary) transparent;
}

.sub-menu.is-open::-webkit-scrollbar {
    width: 6px;
}

.sub-menu.is-open::-webkit-scrollbar-track {
    background: transparent;
}

.sub-menu.is-open::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border-radius: 3px;
}

.sub-menu .menu-item {
    margin-bottom: 4px;
}

.sub-menu .menu-item a {
    display: block;
    padding: 10px 16px 10px 32px;
    color: var(--text-body);
    opacity: 0.8;
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
    border-radius: var(--radius-s);
    border: 1px solid transparent;
    transition: all 0.3s ease;
}

.sub-menu .menu-item a:hover,
.sub-menu .menu-item a:focus {
    background: var(--primary-10);
    color: var(--primary);
    opacity: 1;
    border-color: color-mix(in srgb, var(--primary) 35%, transparent);
}

/* 9. Мета-блок */
.service-header__meta {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-shrink: 0;
}

/* 10. Мовний перемикач */
.service-header__lang-switcher {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 8px;
}

.service-header__lang-item.is-active {
    display: none;
}

.service-header__lang-item a {
    text-decoration: none;
    color: var(--text-body);
    opacity: 0.8;
    font-size: 16px;
    font-weight: 700;
    padding: 10px 16px;
    border-radius: var(--radius-s);
    transition: all 0.3s ease;
}

.service-header__lang-item a:hover,
.service-header__lang-item a:focus {
    background: var(--primary-10);
    color: var(--primary);
    opacity: 1;
}

.service-header__lang-item.is-active a {
    background: var(--primary);
    color: var(--text-body);
    opacity: 1;
}

/* 11. Соціальні іконки */
.service-header__socials {
    display: flex;
    gap: 12px;
}

.service-header__social {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: transparent;
    border: none;
    border-radius: var(--radius-s);
    color: var(--text-body);
    text-decoration: none;
    transition:
        background-color 0.3s ease,
        color 0.3s ease,
        transform 0.3s ease;
    font-size: 21px;
}

.service-header__social:hover,
.service-header__social:focus {
    background: var(--primary);
    color: var(--text-title);
    transform: translateY(-2px);
}

/* 12. Телефон */
.service-header__phone a {
    text-decoration: none;
    color: var(--text-body);
    font-size: 16px;
    font-weight: 600;
    transition: color 0.3s ease;
}

.service-header__phone a:hover,
.service-header__phone a:focus {
    color: var(--primary);
}

/* 13. Адаптивність */
.service-header__mobile-toggle {
    display: none;
    background: var(--primary-5);
    border: 1px solid var(--primary);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-s);
    padding: 0;
    cursor: pointer;
    transition:
        background-color 0.3s ease,
        color 0.3s ease,
        border-color 0.3s ease;
    position: relative;
    color: var(--text-title);
    z-index: 1003;
}

.service-header__mobile-toggle:hover,
.service-header__mobile-toggle:focus,
.service-header__mobile-toggle:active,
.service-header__mobile-toggle.is-open {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-title);
}

.service-header__mobile-toggle span {
    display: block;
    width: 16px;
    height: 2px;
    background: currentColor;
    margin: 0;
    position: absolute;
    left: 11px;
    transition: all 0.3s ease;
    transform-origin: center;
}

.service-header__mobile-toggle span:nth-child(1) { top: 12px; }
.service-header__mobile-toggle span:nth-child(2) { top: 19px; }
.service-header__mobile-toggle span:nth-child(3) { top: 26px; }

.service-header__mobile-toggle.is-open span:nth-child(1) {
    transform: rotate(45deg);
    top: 19px;
    left: 11px;
}

.service-header__mobile-toggle.is-open span:nth-child(2) {
    opacity: 0;
}

.service-header__mobile-toggle.is-open span:nth-child(3) {
    transform: rotate(-45deg);
    top: 19px;
    left: 11px;
}

@media (max-width: 1024px) {
    .service-header__menu { gap: 30px; }
    .service-header__meta { gap: 20px; }
    .service-header__canvas {
        left: auto;
        right: -400px;
        width: 400px;
    }
    .service-header__canvas.is-open {
        transform: translateX(-400px);
    }
}

@media (max-width: 990px) {
    .service-header__mobile-toggle { display: block; }
    .service-header__nav,
    .service-header__meta { display: none; }
    .service-header__inner { justify-content: space-between; }
    .service-header__canvas {
        left: auto;
        right: -100%;
        width: 100%;
    }
    .service-header__canvas.is-open {
        transform: translateX(-100%);
    }
    .service-header__canvas-content { padding: 30px 20px; }

    .service-header__canvas-logo {
        display: flex;
        align-items: center;
        min-height: 0;
        text-decoration: none;
    }

    .service-header__canvas-logo .service-header__logo-img {
        height: 48px;
        max-height: 48px;
    }

    .service-header__canvas-logo--text {
        font-size: 2rem;
        font-weight: 700;
        color: var(--text-title);
    }

    .service-header__services-list > .menu-item > a {
        font-size: 16px;
        padding: 12px 0;
    }
    .sub-menu .menu-item a {
        font-size: 14px;
        padding: 12px 0 12px 16px;
    }
    .service-header__mobile-menu {
        width: 100%;
        box-sizing: border-box;
        border-bottom: 1px solid var(--border-primary);
        padding-bottom: 20px;
        margin-bottom: 20px;
    }
    .service-header__mobile-menu-title {
        display: block;
        font-size: 16px;
        font-weight: 400;
        color: var(--text-body);
        margin: 0 0 8px;
        padding: 12px 0;
        text-transform: none;
        letter-spacing: normal;
        text-decoration: none;
        transition: color 0.3s ease;
    }

    a.service-header__mobile-menu-title:hover,
    a.service-header__mobile-menu-title:focus-visible {
        color: var(--primary);
    }
    .service-header__mobile-nav {
        list-style: none;
        margin: 0;
        padding: 0;
    }
    .service-header__mobile-nav li { margin-bottom: 8px; }
    .service-header__mobile-nav a {
        display: block;
        padding: 12px 0;
        color: var(--text-body);
        text-decoration: none;
        font-size: 16px;
        border-radius: var(--radius-s);
        transition: all 0.3s ease;
    }
    .service-header__mobile-nav a:hover,
    .service-header__mobile-nav a:focus-visible {
        background: var(--primary-10);
        color: var(--primary);
    }

    .service-header__mobile-nav .current-menu-item > a {
        background: var(--primary-10);
        color: var(--primary);
    }
    .service-header__mobile-meta {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }
    .service-header__mobile-meta--top {
        padding: 15px 0;
        border-bottom: 1px solid var(--border-primary);
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }
    .service-header__mobile-languages {
        padding: 0;
        border-bottom: none;
    }
    .service-header__mobile-languages ul {
        display: flex;
        gap: 12px;
        list-style: none;
        margin: 0;
        padding: 0;
    }
    .service-header__mobile-languages a {
        padding: 0;
        color: var(--text-body);
        text-decoration: none;
        font-size: 18px;
        font-weight: 600;
        border-radius: 0;
        transition: color 0.3s ease;
    }
    .service-header__mobile-languages a:hover,
    .service-header__mobile-languages a:focus {
        background: transparent;
        color: var(--primary);
    }
    .service-header__mobile-socials {
        display: flex;
        gap: 12px;
        padding: 15px 0;
        border-bottom: 1px solid var(--border-primary);
    }
    .service-header__mobile-socials a {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        color: var(--text-body);
        background: transparent;
        border: none;
        border-radius: var(--radius-full);
        text-decoration: none;
        transition:
            background-color 0.3s ease,
            color 0.3s ease;
    }
    .service-header__mobile-socials a:hover,
    .service-header__mobile-socials a:focus {
        background: var(--primary);
        color: var(--text-title);
    }
    .service-header__mobile-phone {
        padding: 0;
        text-align: right;
    }
    .service-header__mobile-phone a {
        color: var(--text-body);
        text-decoration: none;
        font-size: 18px;
        font-weight: 600;
    }
    .service-header__mobile-phone a:hover,
    .service-header__mobile-phone a:focus { color: var(--primary); }
}

@media (max-width: 768px) {
    .service-header { min-height: 60px; }
    .service-header__inner {
        height: 60px;
        padding: 0 16px;
    }
    .service-header__nav { display: none; }
    .service-header__meta { gap: 16px; }
    .service-header__lang-switcher { display: none; }
    .service-header__socials { gap: 8px; }
    .service-header__social {
        width: 48px;
        height: 48px;
        font-size: 21px;
    }
    .service-header__phone { display: none; }
    .service-header__canvas {
        left: auto;
        right: -100%;
        width: 100%;
    }
    .service-header__canvas.is-open { transform: translateX(-100%); }
    .service-header__canvas-content { padding: 30px 20px; }
    .service-header__services-list > .menu-item > a {
        font-size: 16px;
        padding: 12px 0;
    }
    .sub-menu .menu-item a {
        font-size: 14px;
        padding: 12px 0 12px 16px;
    }
}

@media (max-width: 480px) {
    .service-header__logo-placeholder {
        font-size: 18px;
        padding: 6px 12px;
    }
    .service-header__meta { gap: 12px; }
    .service-header__social {
        width: 42px;
        height: 42px;
        font-size: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

.service-header__menu-toggle:focus,
.service-header__canvas-close:focus,
.service-header__social:focus,
.service-header__lang-item a:focus,
.service-header__phone a:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.service-header__dropdown {
    display: none;
}
