/* ====================================================================
   File: /public_html/css/header/dropdown-system.css
   Version: 6.9.0
   Last Updated: 2026-02-04

   SCALABLE DROPDOWN MENU SYSTEM - SIMPLIFIED VERSION WITH MOBILE FIXES
   Unified system with single count class for all dropdown types

   Changelog v6.8.0:
   - Fix: Added invisible hover bridge to prevent dropdown closing when
     moving mouse from trigger to dropdown panel (12px margin-top gap)

   Changelog v6.7.0:
   - WCAG: Restored focus-visible indicators on .dropdown-item--view-all links
   - Removed duplicate focus-override rule from accessibility section

   Changelog v6.6.0:
   - WCAG 4.1.2: Added button resets for .dropdown-toggle (changed from <a> to <button>)

   Changelog v6.5.0:
   - Changed :focus to :focus-visible so blue outline only shows on keyboard nav, not mouse click

   Changelog v6.4.0:
   - Redesigned "View All" links: subtle centered text instead of accent bar + arrow
   ==================================================================== */

/* ====================================================================
   BASE DROPDOWN STRUCTURE (Shared by all dropdown types)
   ==================================================================== */

/* Common dropdown wrapper */
.dropdown-menu-item {
    position: relative;
    display: inline;
}

/* Common dropdown trigger (button element) */
.dropdown-toggle {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
    vertical-align: baseline;
}

.dropdown-toggle:hover {
    color: #0066cc;
}

/* Common dropdown arrow */
.dropdown-arrow {
    font-size: 14px;
    opacity: 0.7;
    transition: all 0.3s ease;
    line-height: 1;
    vertical-align: middle;
    margin-left: 6px;
    display: inline-flex;
    align-items: center;
}

/* Arrow animation on hover/focus */
.dropdown-menu-item:hover .dropdown-arrow,
.dropdown-menu-item:focus-within .dropdown-arrow {
    transform: rotate(180deg);
    opacity: 1;
}

/* ====================================================================
   DESKTOP DROPDOWN MENU (Base styles for all dropdown types)
   ==================================================================== */

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: -20px;
    background: #ffffff;
    border: 1px solid #e1e5e9;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
    min-width: 320px;
    max-width: 380px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    margin-top: 12px;
    pointer-events: none;
    overflow: hidden;
}

/* Show dropdown states (hover suppressed after explicit close-by-click) */
.dropdown-menu-item:not(.dropdown-hover-suppressed):hover .dropdown-menu,
.dropdown-menu-item:not(.dropdown-hover-suppressed):focus-within .dropdown-menu,
.dropdown-menu[data-state="open"] {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* Dropdown content container */
.dropdown-content {
    padding: 12px 0;
}

/* ====================================================================
   DROPDOWN ITEM STYLES (Base for all item types)
   ==================================================================== */

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    color: #374151;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    box-sizing: border-box;
    cursor: pointer;
}

.dropdown-item:hover,
.dropdown-item:focus-visible {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    color: #0066cc;
    text-decoration: none;
    transform: translateX(2px);
}

/* ====================================================================
   CATEGORY-SPECIFIC STYLES
   ==================================================================== */

.dropdown-item--category {
    gap: 14px;
    justify-content: space-between;
}

.category-emoji {
    font-size: 18px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.category-name {
    flex: 1;
    font-weight: 500;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ====================================================================
   TAG-SPECIFIC STYLES
   ==================================================================== */

.dropdown-menu--tags {
    min-width: 280px;
    max-width: 340px;
}

.dropdown-item--tag {
    gap: 12px;
}

.tag-icon {
    font-size: 16px;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    opacity: 0.7;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tag-name {
    flex: 1;
    font-weight: 500;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* ====================================================================
   TYPE-SPECIFIC STYLES
   ==================================================================== */

.dropdown-menu--types {
    min-width: 300px;
    max-width: 360px;
}

.dropdown-item--type {
    gap: 14px;
    justify-content: space-between;
}

.type-emoji {
    font-size: 18px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.type-name {
    flex: 1;
    font-weight: 500;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ====================================================================
   UNIFIED COUNT STYLES (Used by both categories and tags)
   ==================================================================== */

.count {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    color: #64748b;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
    min-width: 24px;
    text-align: center;
}

/* ====================================================================
   SHARED UTILITY STYLES
   ==================================================================== */

.dropdown-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, #e2e8f0, transparent);
    margin: 8px 16px;
}

/* View All/Show More pattern (reusable) - Subtle centered text */
.dropdown-item--view-all {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 400;
    color: #64748b;
    background: transparent;
    border: none;
    border-radius: 0;
    margin: 4px 0 0 0;
    padding: 12px 20px;
    gap: 0;
    box-sizing: border-box;
}

.dropdown-item--view-all:hover {
    background: transparent;
    color: #475569;
    text-decoration: underline;
    transform: none;
}

/* Focus-visible indicator for view-all links (keyboard only) */
.dropdown-item--view-all:focus-visible {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
    border-radius: 4px;
    background: transparent;
    color: #475569;
    text-decoration: underline;
    transform: none;
}

.view-all-text {
    font-size: 14px;
    font-weight: 400;
    white-space: nowrap;
}

/* Hide the arrow - no longer needed */
.view-all-arrow {
    display: none;
}

/* ====================================================================
   DESKTOP NAVIGATION ALIGNMENT - ACCESSIBILITY IMPROVED
   ==================================================================== */

@media (min-width: 769px) {
    nav ul li.dropdown-menu-item {
        display: inline;
        position: relative;
        vertical-align: top;
        z-index: 1;
    }

    /* Invisible hover bridge: covers the 12px margin-top gap between
       trigger and dropdown so the mouse doesn't leave the hover area.
       Extended 20px left to catch diagonal mouse movements. */
    nav ul li.dropdown-menu-item::after {
        content: '';
        position: absolute;
        top: 100%;
        left: -20px;
        width: calc(100% + 20px);
        height: 12px;
    }

    /* Actively open dropdown stacks above default siblings */
    nav ul li.dropdown-menu-item:has(.dropdown-menu[data-state="open"]) {
        z-index: 2;
    }

    /* Hovered dropdown stacks above everything, including open siblings */
    nav ul li.dropdown-menu-item:hover {
        z-index: 3;
    }

    nav ul li.dropdown-menu-item .dropdown-toggle {
        display: inline-flex;
        align-items: center;
        vertical-align: baseline;
        line-height: inherit;
        padding: 12px 0;
        color: #1a202c;
        font-weight: 500;
        font-size: 16px;
        white-space: nowrap;
        text-decoration: none;
        transition: color 0.2s ease;
        background: none;
        border: none;
        font-family: inherit;
    }

    nav ul li:not(.dropdown-menu-item) a {
        color: #1a202c !important;
        text-decoration: none !important;
        font-weight: 500 !important;
        font-size: 16px !important;
        padding: 12px 0 !important;
        display: inline !important;
        transition: color 0.2s ease !important;
    }

    nav ul li:not(.dropdown-menu-item) a:hover,
    nav ul li.dropdown-menu-item .dropdown-toggle:hover {
        color: #0066cc !important;
        text-decoration: none !important;
    }

    nav ul li:not(.dropdown-menu-item) a:visited {
        color: #1a202c !important;
        text-decoration: none !important;
    }

    /* Focus states for keyboard accessibility (not mouse clicks) */
    nav ul li:not(.dropdown-menu-item) a:focus-visible,
    nav ul li.dropdown-menu-item .dropdown-toggle:focus-visible {
        outline: 2px solid #0066cc !important;
        outline-offset: 2px !important;
        border-radius: 4px !important;
        color: #0066cc !important;
    }

    /* Active states */
    nav ul li:not(.dropdown-menu-item) a:active,
    nav ul li.dropdown-menu-item .dropdown-toggle:active {
        color: #004499 !important;
    }
}

.mobile-menu-search {
    display: none;
}

/* ====================================================================
   HAMBURGER MENU STYLES
   ==================================================================== */

.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    min-width: 48px;
    min-height: 48px;
    position: relative;
}

.hamburger span {
    display: block;
    width: 28px;
    height: 4px;
    background-color: #2c3e50;
    margin: 3px 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

/* ====================================================================
   MOBILE RESPONSIVE STYLES
   ==================================================================== */

@media (max-width: 768px) {
    .hamburger {
        display: flex !important;
    }
    
    .hamburger span {
        background-color: #2c3e50 !important;
        display: block !important;
    }
    
    .hamburger.active span:nth-child(1) {
        transform: rotate(45deg) translate(7px, 7px);
    }
    
    .hamburger.active span:nth-child(2) {
        opacity: 0;
    }
    
    .hamburger.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -7px);
    }

    .mobile-menu-search {
        display: block;
    }
    
    nav ul {
        background: #ffffff;
        padding: 0;
        margin: 0;
        list-style: none;
    }
    
    nav ul li {
        display: block;
        margin: 0;
        padding: 0;
        height: 56px;
        overflow: visible;
    }
    
    nav ul li:nth-child(odd) {
        background-color: #ffffff;
    }
    
    nav ul li:nth-child(even) {
        background-color: #f8fafc;
    }
    
    nav ul li > a,
    nav ul li .dropdown-toggle {
        display: block !important;
        width: 100% !important;
        height: 56px !important;
        padding: 0 20px !important;
        margin: 0 !important;
        border: none !important;
        background: inherit !important;
        font-size: 16px !important;
        font-weight: 500 !important;
        color: #374151 !important;
        text-decoration: none !important;
        box-sizing: border-box !important;
        line-height: 56px !important;
        text-align: left !important;
        cursor: pointer !important;
        position: relative !important;
    }
    
    nav ul li > a:hover,
    nav ul li .dropdown-toggle:hover {
        background: #e2e8f0 !important;
        color: #0066cc !important;
    }
    
    .dropdown-toggle .dropdown-text {
        display: none !important;
    }
    
    .dropdown-menu-item--explore .dropdown-toggle::before {
        content: "Explore";
    }
    
    .dropdown-menu-item--categories .dropdown-toggle::before {
        content: "Categories";
    }
    
    .dropdown-menu-item--tags .dropdown-toggle::before {
        content: "Tags";
    }

    /* Use label from HTML for all dropdowns */
.dropdown-menu-item .dropdown-toggle::before {
    content: attr(data-label);
}

    
    .dropdown-toggle::before {
        position: absolute;
        left: 20px;
        top: 0;
        height: 56px;
        line-height: 56px;
        font-size: 16px;
        font-weight: 500;
        color: inherit;
    }
    
    .dropdown-toggle .dropdown-arrow {
        position: absolute !important;
        right: 20px !important;
        top: 50% !important;
        margin-top: -7px !important;
        margin-left: 0 !important;
        font-size: 14px !important;
        opacity: 0.6 !important;
        display: block !important;
        line-height: 1 !important;
        transition: all 0.3s ease !important;
    }
    
    nav ul li.dropdown-menu-item {
        display: block !important;
        position: relative !important;
        overflow: visible !important;
        z-index: 10 !important;
    }
    
    nav ul li.dropdown-menu-item .dropdown-menu {
        position: absolute !important;
        top: 56px !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 20 !important;
        opacity: 0 !important;
        visibility: hidden !important;
        transform: none !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        min-width: auto !important;
        max-width: none !important;
        margin: 0 !important;
        background: #f8fafc !important;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
        pointer-events: none;
        width: 100%;
    }
    
    nav ul li.dropdown-menu-item .dropdown-menu[data-state="closed"] {
        opacity: 0 !important;
        visibility: hidden !important;
        max-height: 0 !important;
        pointer-events: none !important;
    }
    
    /* FIXED: Mobile dropdown open state with proper scrolling */
    nav ul li.dropdown-menu-item .dropdown-menu[data-state="open"] {
        opacity: 1 !important;
        visibility: visible !important;
        max-height: 75vh !important; /* Use 75% of viewport height for better mobile experience */
        pointer-events: auto !important;
        z-index: 100 !important;
        overflow-y: auto !important; /* Enable vertical scrolling */
        -webkit-overflow-scrolling: touch !important; /* Smooth scrolling on iOS */
        /* Ensure scrolling works properly on all mobile devices */
        overscroll-behavior: contain;
    }
    
    /* FIXED: Mobile dropdown content with bottom padding for scroll clearance */
    .dropdown-content {
        padding: 0 0 100px 0 !important; /* Generous bottom padding for scroll clearance */
        background: #f8fafc;
        min-height: 200px; /* Ensure there's always content to scroll */
    }
    
    /* Mobile dropdown items */
    .dropdown-item {
        padding: 16px 40px;
        border-bottom: 1px solid #e2e8f0;
        font-size: 16px;
        background: #f8fafc;
        margin: 0;
        min-height: 52px;
    }
    
    .dropdown-item:last-child {
        border-bottom: none;
    }
    
    .dropdown-item:hover {
        background: #e2e8f0;
        transform: none;
        padding-left: 44px;
    }
    
    .dropdown-item--category {
        gap: 16px;
    }
    
    .category-emoji {
        font-size: 20px;
        width: 28px;
    }
    
    .category-name {
        font-size: 16px;
        white-space: normal;
    }
    
    .dropdown-item--tag {
        gap: 14px;
    }
    
    .tag-icon {
        font-size: 18px;
        width: 24px;
    }
    
    .tag-name {
        font-size: 16px;
        white-space: normal;
    }


    .dropdown-item--type {
        gap: 16px;
    }
    
    .type-emoji {
        font-size: 20px;
        width: 28px;
    }
    
    .type-name {
        font-size: 16px;
        white-space: normal;
    }
    
    /* UNIFIED MOBILE COUNT STYLES */
    .count {
        font-size: 14px;
        background: #e2e8f0;
        color: #64748b;
    }
    
    /* FIXED: Mobile View All Item - Subtle centered text */
    .dropdown-item--view-all {
        background: transparent;
        color: #64748b;
        border: none;
        border-radius: 0;
        margin: 4px 0 80px 0 !important; /* Large bottom margin for scroll clearance */
        padding: 12px 40px;
        font-weight: 400;
        justify-content: center;
    }
    
    .dropdown-item--view-all:hover {
        background: transparent;
        text-decoration: underline;
        transform: none;
    }
    
    .dropdown-item--view-all:focus-visible {
        outline: 2px solid #0066cc;
        outline-offset: 2px;
        border-radius: 4px;
        background: transparent;
        text-decoration: underline;
    }
    
    .view-all-text {
        color: #64748b;
        font-size: 14px;
        font-weight: 400;
    }
    
    .view-all-arrow {
        display: none;
    }
    
    .dropdown-divider {
        display: none;
    }

    /* Z-index management for dropdowns */
    nav ul li:not(.dropdown-menu-item) {
        z-index: 1 !important;
    }
    
    nav ul li.dropdown-menu-item:not(:has(.dropdown-menu[data-state="open"])) {
        z-index: 1 !important;
    }
    
    nav ul li.dropdown-menu-item:has(.dropdown-menu[data-state="open"]) {
        z-index: 99 !important;
    }
    
    /* MOBILE SCROLLBAR STYLING - Make scrolling more obvious */
    nav ul li.dropdown-menu-item .dropdown-menu[data-state="open"]::-webkit-scrollbar {
        width: 6px;
    }
    
    nav ul li.dropdown-menu-item .dropdown-menu[data-state="open"]::-webkit-scrollbar-track {
        background: #f1f5f9;
        border-radius: 3px;
    }
    
    nav ul li.dropdown-menu-item .dropdown-menu[data-state="open"]::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 3px;
        border: 1px solid #e2e8f0;
    }
    
    nav ul li.dropdown-menu-item .dropdown-menu[data-state="open"]::-webkit-scrollbar-thumb:hover {
        background: #94a3b8;
    }
    
    /* MOBILE SCROLL HINT - Subtle visual cue that content is scrollable */
    nav ul li.dropdown-menu-item .dropdown-menu[data-state="open"]::after {
        content: "";
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        height: 20px;
        background: linear-gradient(transparent, rgba(248, 250, 252, 0.8));
        pointer-events: none;
        z-index: 1;
    }
}

/* ====================================================================
   ACCESSIBILITY & UX ENHANCEMENTS
   ==================================================================== */

.dropdown-toggle:focus-visible,
.dropdown-item:focus-visible {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
    border-radius: 4px;
}

.dropdown-menu-item:focus-within .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

@media (prefers-contrast: high) {
    .dropdown-menu {
        border: 2px solid #000;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    }
    
    .dropdown-item:hover,
    .dropdown-item:focus {
        background-color: #000;
        color: #fff;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dropdown-menu,
    .dropdown-arrow,
    .view-all-arrow,
    .dropdown-item {
        transition: none;
    }
}