/**
 * KKeyQik Sticky Bar Widget — Styles
 *
 * Layout, sticky state, orientation, separator, active indicator,
 * glassmorphism, responsive dropdown, pill mode.
 *
 * @package KKeyQik
 * @since   1.0.5
 */

/* =============================================
   Bar Container
   ============================================= */

.kkeyqik-sticky-bar {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    z-index: 9990;
    box-sizing: border-box;
    overflow: visible;
    border-radius: 50px;
    will-change: width, box-shadow, border-radius;
    transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.5s cubic-bezier(0.22, 1, 0.36, 1),
        border-radius 0.5s cubic-bezier(0.22, 1, 0.36, 1),
        background-color 0.3s ease;
    -webkit-backdrop-filter: blur(var(--kkeyqik-sb-blur, 0px)) saturate(var(--kkeyqik-sb-saturate, 100%));
    backdrop-filter: blur(var(--kkeyqik-sb-blur, 0px)) saturate(var(--kkeyqik-sb-saturate, 100%));
}

/* Fit Content width mode — pill shape */
[class*="kkeyqik-sticky-bar--width-fit-content"] .kkeyqik-sticky-bar {
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

/* Placeholder — preserves layout space when the bar goes fixed */
.kkeyqik-sticky-bar__placeholder {
    display: none;
    width: 100%;
}

/* =============================================
   Sticky State — JS toggles .is-stuck
   ============================================= */

.kkeyqik-sticky-bar.is-stuck {
    position: fixed;
    top: var(--kkeyqik-sticky-top, 0px);
    z-index: 9999;
    overflow: visible;
    box-shadow: 0 1px 4px 0 rgba(34, 34, 34, 0.15);
    border-radius: 50px;
}

/* Fixed centering for fit-content mode */
[class*="kkeyqik-sticky-bar--width-fit-content"] .kkeyqik-sticky-bar.is-stuck {
    left: 50% !important;
    transform: translateX(-50%);
}

.kkeyqik-sticky-bar.is-stuck + .kkeyqik-sticky-bar__placeholder {
    display: block;
}

/* =============================================
   List Container — wraps the inner flex
   ============================================= */

.kkeyqik-sticky-bar__list-container {
    position: relative;
    width: 100%;
}

/* =============================================
   Inner Flex Container
   ============================================= */

.kkeyqik-sticky-bar__inner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    width: 100%;
    list-style: none;
    gap: var(--kkeyqik-sb-gap, 24px);
    margin: 0;
}

/* =============================================
   Orientation — Horizontal (default)
   ============================================= */

[class*="kkeyqik-sticky-bar--horizontal"] .kkeyqik-sticky-bar__inner {
    flex-direction: row;
}

/* =============================================
   Orientation — Vertical
   ============================================= */

[class*="kkeyqik-sticky-bar--vertical"] .kkeyqik-sticky-bar__inner {
    flex-direction: column;
    align-items: stretch;
}

[class*="kkeyqik-sticky-bar--vertical"] .kkeyqik-sticky-bar__item {
    justify-content: center;
}

/* =============================================
   Navigation Items
   ============================================= */

.kkeyqik-sticky-bar__item {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    position: relative;
    isolation: isolate;
    transition: color 0.25s ease, background-color 0.25s ease, font-weight 0.25s ease;
    flex-shrink: 0;
}

/* =============================================
   Mobile Dropdown Label (WebFX-style)
   Hidden by default on desktop
   ============================================= */

.kkeyqik-sticky-bar__label {
    display: none;
    align-items: center;
    padding: 16px 32px;
    border-radius: 50px;
    gap: 8px;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
    /* Button reset — element is a <button> for accessibility */
    background: none;
    border: none;
    font: inherit;
    color: inherit;
    text-align: left;
    -webkit-appearance: none;
    appearance: none;
}

.kkeyqik-sticky-bar__current-link {
    flex: 1;
    font-weight: 600;
    font-size: 18px;
    line-height: 28px;
    letter-spacing: -0.081px;
    text-decoration: none;
}

.kkeyqik-sticky-bar__chevron {
    flex-shrink: 0;
    transition: transform 0.3s ease;
    width: 20px;
    height: 20px;
}

.kkeyqik-sticky-bar.is-open .kkeyqik-sticky-bar__chevron {
    transform: rotate(180deg);
}

/* =============================================
   Separator — ::before on every item except first
   ============================================= */

.kkeyqik-sticky-bar__item::before {
    display: none;
}

/* Horizontal separator */
[class*="kkeyqik-sticky-bar--separator-yes"][class*="kkeyqik-sticky-bar--horizontal"] .kkeyqik-sticky-bar__item + .kkeyqik-sticky-bar__item::before {
    content: '';
    display: block;
    position: absolute;
    left: calc(-1 * var(--kkeyqik-sb-gap, 24px) / 2);
    top: 50%;
    transform: translate(-50%, -50%);
    width: 1px;
    height: 60%;
    background-color: currentColor;
    opacity: 0.3;
    pointer-events: none;
}

/* Vertical separator */
[class*="kkeyqik-sticky-bar--separator-yes"][class*="kkeyqik-sticky-bar--vertical"] .kkeyqik-sticky-bar__item + .kkeyqik-sticky-bar__item::before {
    content: '';
    display: block;
    position: absolute;
    top: calc(-1 * var(--kkeyqik-sb-gap, 24px) / 2);
    left: 50%;
    transform: translate(-50%, -50%);
    height: 1px;
    width: 60%;
    background-color: currentColor;
    opacity: 0.3;
    pointer-events: none;
}

/* =============================================
   Active Indicator — ::after pseudo-element
   ============================================= */

/* None */
[class*="kkeyqik-sticky-bar--indicator-none"] .kkeyqik-sticky-bar__item::after {
    display: none;
}

/* Underline */
[class*="kkeyqik-sticky-bar--indicator-underline"] .kkeyqik-sticky-bar__item::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background-color: currentColor;
    transform: scaleX(0);
    transform-origin: center center;
    transition: transform 0.3s ease;
    pointer-events: none;
}

[class*="kkeyqik-sticky-bar--indicator-underline"] .kkeyqik-sticky-bar__item.is-active::after {
    transform: scaleX(1);
}

/* Background */
[class*="kkeyqik-sticky-bar--indicator-background"] .kkeyqik-sticky-bar__item::after {
    content: '';
    position: absolute;
    inset: 0;
    background-color: currentColor;
    opacity: 0;
    border-radius: inherit;
    transition: opacity 0.3s ease;
    z-index: -1;
    pointer-events: none;
}

[class*="kkeyqik-sticky-bar--indicator-background"] .kkeyqik-sticky-bar__item.is-active::after {
    opacity: 0.1;
}

/* Dot */
[class*="kkeyqik-sticky-bar--indicator-dot"] .kkeyqik-sticky-bar__item::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -4px;
    transform: translateX(-50%) scale(0);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
    transition: transform 0.3s ease;
    pointer-events: none;
}

[class*="kkeyqik-sticky-bar--indicator-dot"] .kkeyqik-sticky-bar__item.is-active::after {
    transform: translateX(-50%) scale(1);
}

/* =============================================
   Responsive — Desktop (≥ 992px)
   No overflow: hide label, show horizontal list
   ============================================= */

@media (min-width: 992px) {
    .kkeyqik-sticky-bar:not(.kkeyqik-sticky-bar--has-overflow) .kkeyqik-sticky-bar__label {
        display: none !important;
    }

    .kkeyqik-sticky-bar:not(.kkeyqik-sticky-bar--has-overflow) .kkeyqik-sticky-bar__inner {
        display: inline-flex !important;
    }

    .kkeyqik-sticky-bar:not(.kkeyqik-sticky-bar--has-overflow) .kkeyqik-sticky-bar__list-container {
        display: flex !important;
        justify-content: center;
    }
}

/* =============================================
   Shared Dropdown Layout
   Used by both overflow detection AND mobile dropdown mode
   ============================================= */

.kkeyqik-sticky-bar--dropdown-active .kkeyqik-sticky-bar__label {
    display: flex;
}

.kkeyqik-sticky-bar--dropdown-active .kkeyqik-sticky-bar__list-container {
    position: absolute;
    z-index: 9;
    display: none;
    width: 100%;
    top: 100%;
    left: 0;
}

.kkeyqik-sticky-bar--dropdown-active .kkeyqik-sticky-bar__inner {
    flex-direction: column;
    width: 100%;
    border-radius: 16px;
    background: inherit;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.kkeyqik-sticky-bar--dropdown-active .kkeyqik-sticky-bar__item {
    width: 100%;
    display: flex;
    padding: 12px 24px;
}

/* =============================================
   Responsive — Mobile / Tablet (≤ 991px)
   ============================================= */

@media (max-width: 991px) {

    /* --- Horizontal scroll mode (legacy) --- */
    .kkeyqik-sticky-bar[data-mobile-behavior="scroll"] .kkeyqik-sticky-bar__label {
        display: none !important;
    }

    .kkeyqik-sticky-bar[data-mobile-behavior="scroll"] .kkeyqik-sticky-bar__inner {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        justify-content: flex-start;
        padding: 8px 10px; /* 8px top/bottom padding to prevent focus ring clipping */
    }

    .kkeyqik-sticky-bar[data-mobile-behavior="scroll"] .kkeyqik-sticky-bar__inner::-webkit-scrollbar {
        display: none;
    }

    .kkeyqik-sticky-bar[data-mobile-behavior="scroll"] .kkeyqik-sticky-bar__item {
        padding: 8px 12px;
        font-size: 14px;
    }

    /* --- Hide mode --- */
    .kkeyqik-sticky-bar[data-mobile-behavior="hide"] {
        display: none !important;
    }

    /* --- Force Full Width on Mobile/Tablet --- */
    html body .elementor-widget-kkeyqik-sticky-bar .kkeyqik-sticky-bar {
        width: 100% !important;
        max-width: 100% !important;
        transform: none !important;
        left: 0 !important;
    }
}

/* =============================================
   Dropdown Open State (Unified Flush Connection)
   Using high specificity to override Elementor without !important
   ============================================= */

html body .elementor-widget-kkeyqik-sticky-bar .kkeyqik-sticky-bar.is-open {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

html body .elementor-widget-kkeyqik-sticky-bar .kkeyqik-sticky-bar.is-open .kkeyqik-sticky-bar__label {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

html body .elementor-widget-kkeyqik-sticky-bar .kkeyqik-sticky-bar.is-open .kkeyqik-sticky-bar__inner {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.kkeyqik-sticky-bar--dropdown-active .kkeyqik-sticky-bar__list-container {
    top: 100%;
    margin: 0;
}

/* =============================================
   Reduced Motion — Accessibility
   ============================================= */

@media (prefers-reduced-motion: reduce) {
    .kkeyqik-sticky-bar,
    .kkeyqik-sticky-bar__chevron,
    .kkeyqik-sticky-bar__item,
    .kkeyqik-sticky-bar__item::after,
    .kkeyqik-sticky-bar__item::before {
        transition: none !important;
    }
}