/**
 * WooCommerce Category Description Toggle - Minimal Styles
 * Compatible with Flatsome and clean themes
 */

/* Main wrapper */
.wc-cat-description-toggle {
    position: relative;
    margin: 0;
    padding: 0;
}

/* Prevent FOUC - hide content until JS processes it */
.wc-cat-description-toggle:not(.is-processed) .wc-cat-description-content {
    visibility: hidden;
}

.wc-cat-description-toggle.is-processed .wc-cat-description-content {
    visibility: visible;
}

/* Content container */
.wc-cat-description-content {
    position: relative;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

/* Collapsed state - limit to X lines */
.wc-cat-description-toggle.is-collapsed .wc-cat-description-content {
    max-height: calc(1.6em * var(--max-lines, 3));
    line-height: 1.6;
}

/* Expanded state */
.wc-cat-description-toggle.is-expanded .wc-cat-description-content {
    max-height: none;
}

/* Fade effect when collapsed */
.wc-cat-description-toggle.is-collapsed .wc-cat-description-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3em;
    background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.95));
    pointer-events: none;
}

/* Toggle button */
.wc-cat-toggle-btn {
    display: inline-block;
    margin: 15px 0 0 0;
    padding: 0;
    background: none;
    border: none;
    color: inherit;
    font-size: inherit;
    font-family: inherit;
    font-weight: 400;
    cursor: pointer;
    text-decoration: underline;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.wc-cat-toggle-btn:hover {
    opacity: 1;
}

.wc-cat-toggle-btn:focus {
    outline: 1px dotted currentColor;
    outline-offset: 2px;
}

/* Arrow indicator */
.wc-cat-toggle-arrow {
    display: inline-block;
    margin-left: 4px;
    font-size: 0.85em;
    transition: transform 0.3s ease;
}

.wc-cat-description-toggle.is-expanded .wc-cat-toggle-arrow {
    transform: rotate(180deg);
}

/* Responsive */
@media (max-width: 768px) {
    .wc-cat-description-toggle.is-collapsed .wc-cat-description-content {
        max-height: calc(1.5em * var(--max-lines, 3));
        line-height: 1.5;
    }
}

/* If background is dark, adjust fade */
@media (prefers-color-scheme: dark) {
    .wc-cat-description-toggle.is-collapsed .wc-cat-description-content::after {
        background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.95));
    }
}

/* Flatsome specific adjustments */
.term-description .wc-cat-description-toggle {
    margin-top: 0;
}

.term-description .wc-cat-toggle-btn {
    margin-top: 10px;
}

/* Ensure content flows naturally */
.wc-cat-description-content h1,
.wc-cat-description-content h2,
.wc-cat-description-content h3,
.wc-cat-description-content p,
.wc-cat-description-content ul,
.wc-cat-description-content ol {
    margin-top: 0;
}

.wc-cat-description-content h1:first-child,
.wc-cat-description-content h2:first-child,
.wc-cat-description-content h3:first-child,
.wc-cat-description-content p:first-child {
    margin-top: 0;
}

/* Hidden class */
.wc-cat-toggle-hidden {
    display: none !important;
}
