/* --- LAYOUT PRESERVATION --- */
:root {
    /* Fast-out easing for smoothness */
    --ann-transition: transform 0.25s cubic-bezier(0.165, 0.84, 0.44, 1);
}

body:has(.announcement-slide-content) .page-title {
  margin-top: 130px;
}

/* Base Wrapper */
.announcement-bar-wrapper {
    width: 100%;
    background-color: #cb9913;
    padding: 10px 0;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 998;
    min-height: var(--announcement-bar-height);
    box-sizing: border-box;
    overflow: hidden;
    transition: var(--ann-transition);
    
    /* Anti-blur rendering fixes */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* The Main Menu Wrapper - Glued to the bottom of the bar */
.mega-menu-wrapper {
    position: fixed;
    width: 100%;
    z-index: 10005;
    transition: var(--ann-transition);
    
    /* FIX: Pull the menu UP by 1px to overlap the announcement bar and hide the gap */
    top: calc(var(--announcement-bar-height) - 1px) !important;

    /* Anti-blur rendering fixes */
    transform: translateZ(0); 
    -webkit-font-smoothing: antialiased;
    backface-visibility: hidden;
}

/* --- THE SEAMLESS HIDE ACTION --- */
/* Ensure both hide exactly at the same rate */
body.announcement-bar-hidden .announcement-bar-wrapper,
body.announcement-bar-hidden .mega-menu-wrapper {
    /* FIX: Exact height translation prevents the sub-pixel "leak" line */
    transform: translateY(calc(-1 * var(--announcement-bar-height)));
}

/* WP Admin Bar Handling */
body.admin-bar .announcement-bar-wrapper { top: 32px; }
body.admin-bar .mega-menu-wrapper { 
    /* Maintain the 1px overlap even with Admin Bar */
    top: calc(31px + var(--announcement-bar-height)) !important; 
}

@media screen and (max-width: 782px) {
    body.admin-bar .announcement-bar-wrapper { top: 46px; }
    body.admin-bar .mega-menu-wrapper { 
        /* Maintain the 1px overlap on mobile Admin Bar */
        top: calc(45px + var(--announcement-bar-height)) !important; 
    }
}

/* --- FOUC FIX --- */
.announcement-bar-container:not(.is-initialized) .splide__slide:not(:first-child) {
    display: none;
}

.announcement-bar-container {
    max-width: 1140px;
    margin: 0 auto;
    position: relative;
    padding: 0 50px;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.announcement-bar-container.is-initialized {
    opacity: 1;
}

/* --- CONTENT STYLING --- */
.announcement-slide-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0px;
    text-align: center;
    color: #ffffff;
    font-family: var(--font-secondary);
    font-size: 0.8em;
    line-height: 1.2;
}

.ann-link {
    text-decoration: underline;
    color: #ffffff;
    margin-left: 5px;
    white-space: nowrap; /* Keeps button text like "Shop Now" on one line */
}

.announcement-arrows .splide__arrow {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 2.2rem;
    cursor: pointer;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

.splide__arrow--prev { left: 10px; }
.splide__arrow--next { right: 10px; }

@media screen and (max-width: 767px) {
    .announcement-slide-content {
        display: block; /* Switch from flex to block to allow natural wrapping */
        padding: 5px 0;
        width: 100%;
        line-height: 1.4;
    }

    .ann-text {
        display: inline; /* Keep as inline so the link follows immediately after */
        white-space: normal; /* Allow the text to wrap if it's too long */
    }

    .ann-link {
        display: inline-block; /* Treat as a button-like element that stays with the text */
        margin-left: 5px;
    }
}