/* =============================================================
   Taxonomy Fancy Menus — 5 Styles
   ============================================================= */

/* ---- BASE RESET ---- */
.tfm-menu {
    --tfm-radius: 10px;
    --tfm-gap: 8px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    margin-bottom: 20px;
}
.tfm-menu *,
.tfm-menu *::before,
.tfm-menu *::after {
    box-sizing: border-box;
}
.tfm-menu-title {
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 12px;
    padding-bottom: 8px;
}
.tfm-menu-items {
    display: flex;
    flex-direction: column;
    gap: var(--tfm-gap);
}
.tfm-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    text-decoration: none !important;
    border-radius: var(--tfm-radius);
    font-size: 14px;
    font-weight: 600;
    transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    /* Staggered entrance animation */
    animation: tfm-slide-in 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
    animation-delay: calc(var(--item-index, 0) * 0.07s);
}
.tfm-item-text {
    position: relative;
    z-index: 2;
}
.tfm-item-count {
    position: relative;
    z-index: 2;
    font-size: 12px;
    opacity: 0.8;
    min-width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50px;
}

/* Columns layout */
.tfm-columns-2 .tfm-menu-items { flex-direction: row; flex-wrap: wrap; }
.tfm-columns-2 .tfm-menu-item { flex: 0 0 calc(50% - var(--tfm-gap)/2); }
.tfm-columns-3 .tfm-menu-items { flex-direction: row; flex-wrap: wrap; }
.tfm-columns-3 .tfm-menu-item { flex: 0 0 calc(33.333% - var(--tfm-gap)); }
.tfm-columns-4 .tfm-menu-items { flex-direction: row; flex-wrap: wrap; }
.tfm-columns-4 .tfm-menu-item { flex: 0 0 calc(25% - var(--tfm-gap)); }

@keyframes tfm-slide-in {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}


/* =============================================================
   STYLE 1 — Неоновый градиент (Neon Gradient)
   Each button gets a unique hue rotation from a vibrant gradient
   ============================================================= */
.tfm-style-1 .tfm-menu-title {
    color: #e0e0e0;
    border-bottom: 2px solid;
    border-image: linear-gradient(90deg, #ff006e, #8338ec, #3a86ff) 1;
}
.tfm-style-1 .tfm-menu-item {
    color: #fff;
    background: linear-gradient(
        135deg,
        hsl(calc(280 + var(--item-index, 0) * 47), 85%, 55%),
        hsl(calc(320 + var(--item-index, 0) * 47), 90%, 45%)
    );
    box-shadow:
        0 4px 15px hsla(calc(280 + var(--item-index, 0) * 47), 80%, 50%, 0.35),
        inset 0 1px 0 rgba(255,255,255,0.2);
}
.tfm-style-1 .tfm-menu-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        hsl(calc(320 + var(--item-index, 0) * 47), 100%, 65%),
        hsl(calc(360 + var(--item-index, 0) * 47), 95%, 50%)
    );
    opacity: 0;
    transition: opacity 0.35s ease;
    border-radius: inherit;
}
.tfm-style-1 .tfm-menu-item:hover {
    transform: translateX(8px) scale(1.02);
    box-shadow:
        0 6px 25px hsla(calc(280 + var(--item-index, 0) * 47), 80%, 50%, 0.5),
        inset 0 1px 0 rgba(255,255,255,0.3);
}
.tfm-style-1 .tfm-menu-item:hover::before {
    opacity: 1;
}
.tfm-style-1 .tfm-item-count {
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(4px);
    color: #fff;
}
/* Pulsing glow animation on hover */
.tfm-style-1 .tfm-menu-item:hover {
    animation: tfm-neon-pulse 1.5s ease-in-out infinite alternate;
}
@keyframes tfm-neon-pulse {
    from { filter: brightness(1); }
    to   { filter: brightness(1.15); }
}


/* =============================================================
   STYLE 2 — Пастельные карточки (Pastel Cards)
   Soft, rounded cards with pastel backgrounds and subtle shadows
   ============================================================= */
.tfm-style-2 {
    --tfm-radius: 14px;
    --tfm-gap: 10px;
}
.tfm-style-2 .tfm-menu-title {
    color: #6b5b8a;
    border-bottom: 2px dashed #d4c5f0;
    font-size: 13px;
}
.tfm-style-2 .tfm-menu-item {
    --pastel-h: calc(200 + var(--item-index, 0) * 55);
    color: hsl(var(--pastel-h), 35%, 30%);
    background: linear-gradient(
        145deg,
        hsl(var(--pastel-h), 65%, 88%),
        hsl(calc(var(--pastel-h) + 30), 55%, 82%)
    );
    border: 2px solid hsl(var(--pastel-h), 50%, 80%);
    box-shadow: 0 3px 10px hsla(var(--pastel-h), 40%, 70%, 0.25);
    padding: 14px 20px;
}
.tfm-style-2 .tfm-menu-item::after {
    content: '→';
    position: absolute;
    right: 45px;
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s ease;
    font-size: 16px;
    z-index: 2;
    color: hsl(var(--pastel-h), 45%, 40%);
}
.tfm-style-2 .tfm-menu-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px hsla(var(--pastel-h), 40%, 60%, 0.3);
    border-color: hsl(var(--pastel-h), 60%, 70%);
    background: linear-gradient(
        145deg,
        hsl(var(--pastel-h), 75%, 85%),
        hsl(calc(var(--pastel-h) + 30), 65%, 78%)
    );
}
.tfm-style-2 .tfm-menu-item:hover::after {
    opacity: 1;
    transform: translateX(0);
}
.tfm-style-2 .tfm-item-count {
    background: hsl(var(--pastel-h), 40%, 75%);
    color: #fff;
    font-size: 11px;
    padding: 0 8px;
}
/* Entrance animation override — bounce */
.tfm-style-2 .tfm-menu-item {
    animation-name: tfm-bounce-in;
}
@keyframes tfm-bounce-in {
    0%   { opacity: 0; transform: translateY(20px) scale(0.95); }
    60%  { transform: translateY(-4px) scale(1.01); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}


/* =============================================================
   STYLE 3 — Огненные кнопки (Fire Buttons)
   Hot warm gradients with animated shimmer effect
   ============================================================= */
.tfm-style-3 .tfm-menu-title {
    color: #c0392b;
    border-bottom: 3px solid #e74c3c;
    font-weight: 800;
}
.tfm-style-3 .tfm-menu-item {
    --fire-h: calc(0 + var(--item-index, 0) * 18);
    color: #fff;
    background: linear-gradient(
        110deg,
        hsl(var(--fire-h), 90%, 50%),
        hsl(calc(var(--fire-h) + 15), 95%, 42%),
        hsl(calc(var(--fire-h) + 30), 85%, 35%)
    );
    background-size: 200% 100%;
    border-radius: 8px;
    border: none;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
    box-shadow:
        0 4px 12px hsla(var(--fire-h), 80%, 40%, 0.4),
        inset 0 -2px 4px rgba(0,0,0,0.15),
        inset 0 2px 4px rgba(255,255,255,0.15);
}
/* Shimmer sweep */
.tfm-style-3 .tfm-menu-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255,255,255,0.2),
        transparent
    );
    transform: skewX(-20deg);
    transition: none;
    border-radius: inherit;
}
.tfm-style-3 .tfm-menu-item:hover::before {
    animation: tfm-shimmer 0.8s ease forwards;
}
.tfm-style-3 .tfm-menu-item:hover {
    background-position: 100% 0;
    transform: scale(1.03);
    box-shadow:
        0 6px 20px hsla(var(--fire-h), 85%, 45%, 0.5),
        inset 0 -2px 4px rgba(0,0,0,0.2),
        inset 0 2px 4px rgba(255,255,255,0.2);
}
.tfm-style-3 .tfm-item-count {
    background: rgba(0,0,0,0.25);
    color: #ffeaa7;
    font-weight: 700;
}
@keyframes tfm-shimmer {
    to {
        left: 130%;
    }
}
/* Entrance — scale pop */
.tfm-style-3 .tfm-menu-item {
    animation-name: tfm-pop-in;
    animation-duration: 0.4s;
}
@keyframes tfm-pop-in {
    0%   { opacity: 0; transform: scale(0.8); }
    70%  { transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1); }
}


/* =============================================================
   STYLE 4 — Морская волна (Ocean Wave)
   Cool blues-teals with wave-like background animation
   ============================================================= */
.tfm-style-4 {
    --tfm-radius: 12px;
}
.tfm-style-4 .tfm-menu-title {
    color: #1a5276;
    border-bottom: 2px solid #48c9b0;
    letter-spacing: 2px;
}
.tfm-style-4 .tfm-menu-item {
    --ocean-h: calc(180 + var(--item-index, 0) * 22);
    color: #fff;
    background: linear-gradient(
        160deg,
        hsl(var(--ocean-h), 65%, 45%),
        hsl(calc(var(--ocean-h) + 20), 60%, 35%)
    );
    box-shadow:
        0 3px 12px hsla(var(--ocean-h), 50%, 35%, 0.3);
    border-left: 4px solid hsl(var(--ocean-h), 80%, 65%);
    padding-left: 22px;
}
/* Animated wave background */
.tfm-style-4 .tfm-menu-item::before {
    content: '';
    position: absolute;
    bottom: -50%;
    left: -10%;
    width: 120%;
    height: 100%;
    background: radial-gradient(ellipse, rgba(255,255,255,0.12) 0%, transparent 70%);
    border-radius: 50%;
    transform: translateY(0);
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.tfm-style-4 .tfm-menu-item:hover::before {
    transform: translateY(-35%);
}
.tfm-style-4 .tfm-menu-item:hover {
    transform: translateX(6px);
    border-left-width: 6px;
    box-shadow:
        0 6px 20px hsla(var(--ocean-h), 55%, 40%, 0.4);
    background: linear-gradient(
        160deg,
        hsl(var(--ocean-h), 75%, 50%),
        hsl(calc(var(--ocean-h) + 20), 70%, 40%)
    );
}
.tfm-style-4 .tfm-item-count {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    font-size: 11px;
    padding: 0 8px;
}
/* Entrance — wave slide */
.tfm-style-4 .tfm-menu-item {
    animation-name: tfm-wave-in;
    animation-duration: 0.6s;
}
@keyframes tfm-wave-in {
    0%   { opacity: 0; transform: translateX(-30px) rotate(-2deg); }
    60%  { transform: translateX(4px) rotate(0.5deg); }
    100% { opacity: 1; transform: translateX(0) rotate(0); }
}


/* =============================================================
   STYLE 5 — Стеклянный морфизм (Glassmorphism)
   Frosted glass effect with blurred backgrounds
   ============================================================= */
.tfm-style-5 {
    --tfm-radius: 16px;
    --tfm-gap: 6px;
    background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460, #533483);
    padding: 20px;
    border-radius: 20px;
    position: relative;
    overflow: hidden;
}
/* Decorative floating orbs */
.tfm-style-5::before,
.tfm-style-5::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(40px);
    z-index: 0;
    pointer-events: none;
}
.tfm-style-5::before {
    width: 120px;
    height: 120px;
    background: rgba(83, 52, 131, 0.5);
    top: -30px;
    right: -20px;
    animation: tfm-float-orb 6s ease-in-out infinite alternate;
}
.tfm-style-5::after {
    width: 80px;
    height: 80px;
    background: rgba(15, 52, 96, 0.6);
    bottom: -20px;
    left: 10px;
    animation: tfm-float-orb 8s ease-in-out infinite alternate-reverse;
}
.tfm-style-5 .tfm-menu-title {
    color: rgba(255,255,255,0.9);
    border-bottom: 1px solid rgba(255,255,255,0.15);
    position: relative;
    z-index: 1;
}
.tfm-style-5 .tfm-menu-items {
    position: relative;
    z-index: 1;
}
.tfm-style-5 .tfm-menu-item {
    --glass-h: calc(200 + var(--item-index, 0) * 35);
    color: rgba(255,255,255,0.95);
    background: linear-gradient(
        135deg,
        hsla(var(--glass-h), 50%, 50%, 0.15),
        hsla(calc(var(--glass-h) + 40), 50%, 50%, 0.08)
    );
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.tfm-style-5 .tfm-menu-item:hover {
    background: linear-gradient(
        135deg,
        hsla(var(--glass-h), 60%, 55%, 0.3),
        hsla(calc(var(--glass-h) + 40), 55%, 55%, 0.15)
    );
    border-color: rgba(255,255,255,0.25);
    transform: translateY(-2px);
    box-shadow:
        0 8px 32px rgba(0,0,0,0.2),
        0 0 20px hsla(var(--glass-h), 60%, 60%, 0.15);
}
.tfm-style-5 .tfm-item-count {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.7);
    font-size: 11px;
    padding: 0 8px;
    backdrop-filter: blur(4px);
}
@keyframes tfm-float-orb {
    from { transform: translate(0, 0); }
    to   { transform: translate(15px, 10px); }
}
/* Entrance — fade up with glass shimmer */
.tfm-style-5 .tfm-menu-item {
    animation-name: tfm-glass-in;
    animation-duration: 0.5s;
}
@keyframes tfm-glass-in {
    0%   { opacity: 0; transform: translateY(15px); backdrop-filter: blur(0); }
    100% { opacity: 1; transform: translateY(0); backdrop-filter: blur(12px); }
}


/* =============================================================
   RESPONSIVE
   ============================================================= */
@media (max-width: 480px) {
    .tfm-menu-item {
        padding: 10px 14px;
        font-size: 13px;
    }
    .tfm-columns-3 .tfm-menu-item,
    .tfm-columns-4 .tfm-menu-item {
        flex: 0 0 calc(50% - var(--tfm-gap)/2);
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .tfm-menu-item {
        animation: none !important;
        transition-duration: 0.01s !important;
    }
    .tfm-style-5::before,
    .tfm-style-5::after {
        animation: none !important;
    }
}

/* Sidebar-friendly: adapt to narrow containers */
.widget .tfm-menu,
.sidebar .tfm-menu {
    font-size: 13px;
}
.widget .tfm-menu-item,
.sidebar .tfm-menu-item {
    padding: 10px 14px;
}
.widget .tfm-style-5,
.sidebar .tfm-style-5 {
    padding: 14px;
}


/* =============================================================
   ACCORDION BEHAVIOR
   Applied to all styles EXCEPT tfm-style-5 (Glassmorphism),
   which keeps its original always-open layout.
   Uses native <details>/<summary> — no JS required.
   ============================================================= */

.tfm-accordion .tfm-accordion-details {
    /* reset default details styling */
    display: block;
}

/* Hide the default triangle marker across browsers */
.tfm-accordion .tfm-accordion-toggle {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    /* keep .tfm-menu-title sizing from base rules */
}
.tfm-accordion .tfm-accordion-toggle::-webkit-details-marker {
    display: none;
}
.tfm-accordion .tfm-accordion-toggle::marker {
    display: none;
    content: "";
}

.tfm-accordion .tfm-accordion-label {
    flex: 1 1 auto;
    min-width: 0;
}

.tfm-accordion .tfm-accordion-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                background-color 0.25s ease;
    background: rgba(127, 127, 127, 0.12);
    color: inherit;
    opacity: 0.9;
}
.tfm-accordion .tfm-accordion-toggle:hover .tfm-accordion-icon {
    background: rgba(127, 127, 127, 0.22);
    opacity: 1;
}
.tfm-accordion .tfm-accordion-details[open] > .tfm-accordion-toggle .tfm-accordion-icon {
    transform: rotate(180deg);
}

/* Focus ring for keyboard users */
.tfm-accordion .tfm-accordion-toggle:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
    border-radius: 6px;
}

/* Collapsed state: items hidden by default via <details> */
/* When opened, replay the staggered entrance animation on items */
.tfm-accordion .tfm-accordion-details[open] > .tfm-menu-items {
    animation: tfm-accordion-open 0.3s ease both;
}
.tfm-accordion .tfm-accordion-details[open] > .tfm-menu-items .tfm-menu-item {
    animation: tfm-slide-in 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
    animation-delay: calc(var(--item-index, 0) * 0.05s);
}

@keyframes tfm-accordion-open {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Style-specific title tweaks still apply to summary because
   .tfm-accordion-toggle also carries the .tfm-menu-title class.
   We just need to make sure border-bottom rules look OK when
   the title sits flush with the icon on the right. */

/* Style 3 (fiery) uses uppercase white title — ensure icon inherits */
.tfm-style-3.tfm-accordion .tfm-accordion-icon {
    background: rgba(255, 255, 255, 0.18);
}
.tfm-style-3.tfm-accordion .tfm-accordion-toggle:hover .tfm-accordion-icon {
    background: rgba(255, 255, 255, 0.3);
}

/* Style 1 (neon) — subtle white hint on dark backgrounds */
.tfm-style-1.tfm-accordion .tfm-accordion-icon {
    background: rgba(255, 255, 255, 0.12);
}
.tfm-style-1.tfm-accordion .tfm-accordion-toggle:hover .tfm-accordion-icon {
    background: rgba(255, 255, 255, 0.22);
}
