:root {
    --cc-height: 40px;
}

.chuchay-wrapper {
    display: flex;
    align-items: center;
    background-color: var(--cc-bg, #f0f0f1);
    color: var(--cc-text, #333);
    height: var(--cc-height);
    line-height: var(--cc-height);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    border-radius: 4px;
    width: 100%;
    position: relative;
    z-index: 9999;
    /* Ensure it's always on top */
    box-sizing: border-box;
    /* Prevent overflow issues */
    clear: both;
    /* Clear floats */
    margin: 0;
    padding: 0;
    flex-grow: 1;
    /* CRITICAL: Allow expansion in flex containers */
    min-width: 0;
    /* CRITICAL: Allow shrinking in flex containers */
}

/* Support for transparent background */
.chuchay-wrapper[style*="--cc-bg: transparent"],
.chuchay-wrapper[style*="background-color: transparent"] {
    background-color: transparent !important;
}

/* Transparent label background when wrapper is transparent */
.chuchay-wrapper[style*="--cc-bg: transparent"] .chuchay-label,
.chuchay-wrapper[style*="background-color: transparent"] .chuchay-label {
    background: transparent !important;
}

.chuchay-wrapper * {
    box-sizing: border-box;
}

.chuchay-label {
    flex: 0 0 auto;
    width: 40px;
    /* Square */
    text-align: center;
    background: rgba(0, 0, 0, 0.05);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.chuchay-label .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.chuchay-label .chuchay-custom-icon {
    max-width: 30px;
    max-height: 30px;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
}

.chuchay-container {
    flex-grow: 1;
    overflow: hidden;
    position: relative;
    height: 100%;
    mask-image: linear-gradient(to right, transparent, black 20px, black 95%, transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, black 20px, black 95%, transparent);
}

.chuchay-content {
    display: flex;
    position: absolute;
    white-space: nowrap;
    /* Animation init */
    animation: chuchay-scroll-left var(--cc-speed, 10s) linear infinite;
}

.chuchay-item {
    display: inline-flex;
    align-items: center;
    margin-right: 40px;
}

.chuchay-icon {
    margin-right: 8px;
    font-size: 1.2em;
}

.chuchay-text {
    font-weight: 500;
}

/* Animations */
@keyframes chuchay-scroll-left {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
    }

    /* Assumption: Content is duplicated once, so 50% is the halfway point where it repeats perfectly */
}

@keyframes chuchay-scroll-right {
    0% {
        transform: translateX(-50%);
    }

    100% {
        transform: translateX(0);
    }
}

@keyframes chuchay-scroll-up {
    0% {
        transform: translateY(0);
    }

    100% {
        transform: translateY(-50%);
    }
}

@keyframes chuchay-scroll-down {
    0% {
        transform: translateY(-50%);
    }

    100% {
        transform: translateY(0);
    }
}


/* Direction Modifiers */
.chuchay-direction-right .chuchay-content {
    animation-name: chuchay-scroll-right;
}

/* For Up/Down, layout changes */
.chuchay-direction-up .chuchay-wrapper,
.chuchay-direction-down .chuchay-wrapper {
    height: 150px;
    /* Taller for vertical */
    align-items: flex-start;
}

.chuchay-direction-up .chuchay-label,
.chuchay-direction-down .chuchay-label {
    height: 40px;
    /* Keep label small or expand? Let's keep small */
}

.chuchay-direction-up .chuchay-container,
.chuchay-direction-down .chuchay-container {
    mask-image: linear-gradient(to bottom, transparent, black 10px, black 90%, transparent);
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 10px, black 90%, transparent);
}

.chuchay-direction-up .chuchay-content,
.chuchay-direction-down .chuchay-content {
    flex-direction: column;
    animation-name: chuchay-scroll-up;
    width: 100%;
}

.chuchay-direction-down .chuchay-content {
    animation-name: chuchay-scroll-down;
}

.chuchay-direction-up .chuchay-item,
.chuchay-direction-down .chuchay-item {
    margin-right: 0;
    margin-bottom: 20px;
    width: 100%;
    /* justify-content: center; Optional center text */
}

/* Links */
a.chuchay-link {
    color: var(--cc-item-color, inherit);
    text-decoration: none;
    transition: color 0.2s;
}

a.chuchay-link:hover {
    color: var(--cc-item-hover, var(--cc-item-color, inherit));
}

a.chuchay-link:hover .chuchay-text {
    text-decoration: underline;
    opacity: 0.8;
}

/* Entrance Effects */
@keyframes cc-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes cc-slide-down {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes cc-slide-up {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.chuchay-effect-fade-in {
    animation: cc-fade-in 1s ease-out forwards;
}

.chuchay-effect-slide-down {
    animation: cc-slide-down 0.5s ease-out forwards;
}

.chuchay-effect-slide-up {
    animation: cc-slide-up 0.5s ease-out forwards;
}


/* Visibility */
@media screen and (min-width: 768px) {
    .hide-on-desktop {
        display: none !important;
    }
}

@media screen and (max-width: 767px) {
    .hide-on-mobile {
        display: none !important;
    }
    
    /* Mobile optimizations */
    .chuchay-wrapper {
        font-size: 14px;
        min-height: var(--cc-height);
        height: auto;
        line-height: 1.4;
    }
    
    .chuchay-label {
        width: 35px;
        flex-shrink: 0;
    }
    
    .chuchay-label .dashicons {
        font-size: 18px;
        width: 18px;
        height: 18px;
    }
    
    .chuchay-label .chuchay-custom-icon {
        max-width: 25px;
        max-height: 25px;
    }
    
    .chuchay-item {
        margin-right: 30px;
    }
    
    .chuchay-icon {
        font-size: 1em;
    }
}

/* Ensure proper stacking context */
.chuchay-wrapper {
    isolation: isolate;
}

/* Prevent text selection during animation */
.chuchay-content {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Ensure links are clickable */
a.chuchay-link {
    pointer-events: auto;
    user-select: auto;
    -webkit-user-select: auto;
}

/* Fixed Position Modes */
.chuchay-fixed-top {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    z-index: 99999 !important;
    margin: 0 !important;
    border-radius: 0 !important;
}

.chuchay-fixed-bottom {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    z-index: 99999 !important;
    margin: 0 !important;
    border-radius: 0 !important;
}

/* Override hide-for-medium when using fixed position */
.chuchay-fixed-top.hide-on-mobile,
.chuchay-fixed-bottom.hide-on-mobile {
    display: flex !important;
}