/* =========================================================
   HEADER BLOCK — BEM
   ========================================================= */

.smartfix-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--sf-bg-white);
    border-bottom: 1px solid var(--sf-border-color);
    padding: 0 var(--sf-padding-section);
    transition: box-shadow 0.3s ease, background-color 0.3s ease;
}

.smartfix-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    height: 88px;
    /* Content stays within 1440px even on ultrawide screens, while the
       bar itself keeps spanning the full viewport. */
    max-width: 1440px;
    margin: 0 auto;
    transition: height 0.3s ease;
}

/* ── Shrunk state — .is-stuck is added by initStickyHeader() once the
   page has scrolled past the header's own height ── */
.smartfix-header.is-stuck {
    box-shadow: 0 6px 24px rgba(7, 18, 18, 0.08);
}

.smartfix-header.is-stuck .smartfix-header__inner {
    height: 64px;
}

.smartfix-header__logo-img,
.smartfix-header__logo-text {
    transition: height 0.3s ease, font-size 0.3s ease;
}

.smartfix-header.is-stuck .smartfix-header__logo-img {
    height: 34px;
}

.smartfix-header.is-stuck .smartfix-header__logo-text {
    font-size: 30px;
}

.smartfix-header__cta {
    transition: padding 0.3s ease, font-size 0.3s ease;
}

.smartfix-header.is-stuck .smartfix-header__cta {
    padding-top: 10px;
    padding-bottom: 10px;
}

@media (prefers-reduced-motion: reduce) {
    .smartfix-header,
    .smartfix-header__inner,
    .smartfix-header__logo-img,
    .smartfix-header__logo-text,
    .smartfix-header__cta {
        transition: none;
    }
}

/* ── Logo ── */
.smartfix-header__logo {
    flex-shrink: 0;
}

.smartfix-header__logo a {
    text-decoration: none;
    display: flex;
    align-items: center;
}

.smartfix-header__logo-img {
    height: 44px;
    width: auto;
    display: block;
}

.smartfix-header__logo-text {
    font-family: var(--sf-font-logo);
    font-size: 38px;
    color: var(--sf-text-dark);
    line-height: 1;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.smartfix-header__logo-text--accent {
    color: var(--sf-color-primary);
}

/* ── Nav ── */
.smartfix-header__nav {
    flex: 1;
    display: flex;
    justify-content: center;
}

.smartfix-header__menu {
    display: flex;
    align-items: center;
    gap: var(--sf-gap-nav);
    list-style: none;
    margin: 0;
    padding: 0;
}

.smartfix-header__menu li {
    position: relative;
}

.smartfix-header__menu li a {
    display: flex;
    align-items: center;
    font-family: var(--sf-font-body);
    font-size: var(--sf-fs-body);
    font-weight: 500;
    line-height: var(--sf-lh-nav);
    color: var(--sf-text-dark);
    text-decoration: none;
    text-transform: capitalize;
    transition: color 0.2s ease;
    white-space: nowrap;
}

.smartfix-header__menu li a:hover,
.smartfix-header__menu li.current-menu-item > a,
.smartfix-header__menu li.current-page-ancestor > a {
    color: var(--sf-color-primary);
}

/* ── Dropdown indicator for items with children ──
   The chevron is a rotated corner, so its visual centre sits below its
   box centre — the -3px nudge lines it up with the label's baseline
   instead of hanging low. On hover it flips to point up, matching the
   submenu that just opened. */
.smartfix-header__menu li.menu-item-has-children > a::after {
    content: '';
    width: 6px;
    height: 6px;
    margin-left: 8px;
    margin-top: -3px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
    transform-origin: center;
    flex-shrink: 0;
    transition: transform 0.25s ease, margin-top 0.25s ease;
}

.smartfix-header__menu li.menu-item-has-children:hover > a::after,
.smartfix-header__menu li.menu-item-has-children:focus-within > a::after {
    transform: rotate(-135deg);
    margin-top: 3px;
}

/* ── Dropdown submenu (desktop: hover/focus reveal) ── */
.smartfix-header__menu .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 200;
    min-width: 220px;
    margin: 14px 0 0;
    padding: 8px;
    list-style: none;
    background: var(--sf-bg-white);
    border: 1px solid var(--sf-border-color);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(7, 18, 18, 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.smartfix-header__menu li.menu-item-has-children:hover > .sub-menu,
.smartfix-header__menu li.menu-item-has-children:focus-within > .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.smartfix-header__menu .sub-menu li {
    width: 100%;
}

.smartfix-header__menu .sub-menu a {
    padding: 10px 14px;
    border-radius: 6px;
    white-space: nowrap;
}

.smartfix-header__menu .sub-menu a:hover {
    background: var(--sf-color-primary-10);
}

/* ── CTA Button ── */
.smartfix-header__cta {
    flex-shrink: 0;
}

/* ── WhatsApp shortcut + burger — both hidden on desktop, and sized
   from the same box so they read as a matched pair in the bar ── */
.smartfix-header__whatsapp,
.smartfix-header__burger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    background: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    padding: 8px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.smartfix-header__burger {
    flex-direction: column;
    gap: 5px;
}

.smartfix-header__whatsapp {
    color: var(--sf-color-whatsapp, #25D366);
}

.smartfix-header__whatsapp:hover,
.smartfix-header__whatsapp:focus-visible,
.smartfix-header__burger:hover,
.smartfix-header__burger:focus-visible {
    background: var(--sf-bg-light);
}

/* Explicit size — a bare svg collapses to zero width inside a flex
   container under GeneratePress's resets. */
.smartfix-header__whatsapp svg {
    display: block;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.smartfix-header__burger-line {
    display: block;
    width: 24px;
    height: 2px;
    background-color: var(--sf-text-dark);
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1024px) {
    .smartfix-header {
        padding: 0 32px;
    }

    .smartfix-header__menu {
        gap: 20px;
    }
}

@media (max-width: 834px) {
    .smartfix-header {
        padding: 0 24px;
    }

    .smartfix-header__inner {
        height: 68px;
        position: relative;
    }

    .smartfix-header.is-stuck .smartfix-header__inner {
        height: 56px;
    }

    .smartfix-header__whatsapp,
    .smartfix-header__burger {
        display: flex;
    }

    /* Tighten the gap so the pair sits together at the right edge
       rather than being spread apart by the inner's space-between. */
    .smartfix-header__whatsapp {
        margin-left: auto;
        margin-right: -4px;
    }

    /* Desktop dropdown nav is replaced by the off-canvas panel below */
    .smartfix-header__nav {
        display: none;
    }

    .smartfix-header__cta {
        display: none;
    }

    /* Burger open state */
    .smartfix-header__burger[aria-expanded="true"] .smartfix-header__burger-line:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    .smartfix-header__burger[aria-expanded="true"] .smartfix-header__burger-line:nth-child(2) {
        opacity: 0;
    }

    .smartfix-header__burger[aria-expanded="true"] .smartfix-header__burger-line:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }
}

@media (max-width: 375px) {
    .smartfix-header {
        padding: 0 16px;
    }
}

/* =========================================================
   OFF-CANVAS MOBILE MENU
   ========================================================= */

.smartfix-offcanvas {
    position: fixed;
    inset: 0;
    z-index: 1000;
}

.smartfix-offcanvas[hidden] {
    display: none;
}

.smartfix-offcanvas__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 18, 18, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.smartfix-offcanvas.is-open .smartfix-offcanvas__backdrop {
    opacity: 1;
}

.smartfix-offcanvas__panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(360px, 86vw);
    display: flex;
    flex-direction: column;
    background: var(--sf-bg-white);
    padding: 24px 24px 32px;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.35s ease;
    box-shadow: -8px 0 32px rgba(7, 18, 18, 0.16);
}

.smartfix-offcanvas.is-open .smartfix-offcanvas__panel {
    transform: translateX(0);
}

@media (prefers-reduced-motion: reduce) {
    .smartfix-offcanvas__backdrop,
    .smartfix-offcanvas__panel {
        transition: none;
    }
}

/* ── Header row: logo + close ── */
.smartfix-offcanvas__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
}

.smartfix-offcanvas__logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.smartfix-offcanvas__logo img {
    height: 34px;
    width: auto;
    display: block;
}

.smartfix-offcanvas__close {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: var(--sf-bg-light);
    border: 0;
    border-radius: 50%;
    color: var(--sf-text-dark);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.smartfix-offcanvas__close:hover,
.smartfix-offcanvas__close:focus-visible {
    background: var(--sf-border-color);
}

/* Explicit size — bare svg width collapses to 0 inside a flex container
   (same issue fixed for the project-modal close button). */
.smartfix-offcanvas__close svg {
    display: block;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* ── Nav menu ── */
.smartfix-offcanvas__nav {
    margin-bottom: 24px;
}

.smartfix-offcanvas__menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.smartfix-offcanvas__menu li {
    border-bottom: 1px solid var(--sf-border-color);
}

.smartfix-offcanvas__menu > li:last-child {
    border-bottom: none;
}

.smartfix-offcanvas__menu li.menu-item-has-children {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.smartfix-offcanvas__menu li a {
    display: flex;
    align-items: center;
    flex: 1;
    padding: 15px 2px;
    font-family: var(--sf-font-body);
    font-size: 17px;
    font-weight: 500;
    color: var(--sf-text-dark);
    text-decoration: none;
}

.smartfix-offcanvas__menu li a:hover,
.smartfix-offcanvas__menu li.current-menu-item > a,
.smartfix-offcanvas__menu li.current-page-ancestor > a {
    color: var(--sf-color-primary);
}

/* Submenu expand/collapse toggle (injected by JS next to parent links) */
.smartfix-offcanvas__submenu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    background: none;
    border: 0;
    color: var(--sf-text-dark);
    cursor: pointer;
}

.smartfix-offcanvas__submenu-toggle svg {
    display: block;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

.smartfix-offcanvas__menu li.is-submenu-open > .smartfix-offcanvas__submenu-toggle svg {
    transform: rotate(180deg);
}

.smartfix-offcanvas__menu .sub-menu {
    flex-basis: 100%;
    list-style: none;
    margin: 0;
    padding: 0 0 0 16px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.smartfix-offcanvas__menu li.is-submenu-open > .sub-menu {
    max-height: 400px;
}

.smartfix-offcanvas__menu .sub-menu li {
    border-bottom: none;
}

.smartfix-offcanvas__menu .sub-menu li a {
    padding: 10px 2px;
    font-size: 15px;
    font-weight: 400;
    color: var(--sf-text-muted);
}

/* ── CTA row: primary + WhatsApp, stacked full-width ── */
.smartfix-offcanvas__cta-group {
    flex-direction: column;
    align-items: stretch;
    margin-top: auto;
    padding-top: 24px;
}

.smartfix-offcanvas__cta-group .sf-btn {
    width: 100%;
    justify-content: center;
}

/* ── Socials ── */
.smartfix-offcanvas__socials {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--sf-border-color);
}

.smartfix-offcanvas__social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--sf-bg-light);
    color: var(--sf-text-dark);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.smartfix-offcanvas__social-link:hover,
.smartfix-offcanvas__social-link:focus-visible {
    background: var(--sf-color-primary);
    color: var(--sf-text-white);
}
