/**
 * Functions Page Styles
 * ExtremeXL Website - Formula Library Reference
 */

/* ===========================================
   Search Box Enhancements
   =========================================== */

#function-search:focus {
    outline: none;
    box-shadow: 0 4px 12px rgba(26, 77, 62, 0.2) !important;
    border: 2px solid #1a4d3e;
}

#function-search::placeholder {
    color: #999;
    font-style: italic;
}

/* ===========================================
   Category Tab Transitions
   =========================================== */

.category-tab {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.category-tab:active {
    transform: scale(0.95);
}

/* ===========================================
   Function Card Interactions
   =========================================== */

.function-card {
    transition: all 0.3s ease !important;
}

.function-card:hover {
    transform: translateY(-2px);
}

.function-header {
    transition: background-color 0.2s ease;
}

.expand-icon {
    transition: transform 0.3s ease, color 0.3s ease;
    user-select: none;
}

.function-header:hover .expand-icon {
    transform: scale(1.2);
    color: #2d7a5f;
}

/* ===========================================
   Code Styling
   =========================================== */

code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace !important;
    font-size: 0.95em;
}

.function-header code {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: inline-block;
}

/* ===========================================
   Category Badge Styles
   =========================================== */

.category-badge {
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* ===========================================
   Loading and Empty States
   =========================================== */

#functions-loading,
#no-results {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ===========================================
   Sticky Category Tabs Enhancement
   =========================================== */

.category-tabs-section {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

/* ===========================================
   Responsive Adjustments
   =========================================== */

/* Tablets */
@media (max-width: 992px) {
    .functions-hero {
        padding: 60px 15px !important;
    }
    
    .category-tabs-section {
        padding: 20px 15px !important;
    }
    
    .functions-display {
        padding: 40px 15px !important;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .functions-hero h1 {
        font-size: 1.8em !important;
        line-height: 1.2;
    }
    
    .functions-hero p:first-of-type {
        font-size: 1.1em !important;
    }
    
    .functions-hero p:last-of-type {
        font-size: 0.95em !important;
    }
    
    #function-search {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 12px 15px !important;
    }
    
    .category-tabs {
        gap: 8px !important;
        justify-content: flex-start !important;
    }
    
    .category-tab {
        font-size: 0.85em !important;
        padding: 8px 15px !important;
        white-space: nowrap;
    }
    
    .function-card {
        border-radius: 6px !important;
    }
    
    .function-header {
        padding: 15px !important;
        flex-direction: column !important;
        align-items: flex-start !important;
    }
    
    .function-header > div:first-child {
        width: 100%;
    }
    
    .function-header code {
        font-size: 0.9em !important;
        padding: 5px 10px !important;
    }
    
    .category-badge {
        font-size: 0.75em !important;
        padding: 3px 10px !important;
    }
    
    .function-header p {
        font-size: 0.95em !important;
    }
    
    .expand-icon {
        margin-left: 0 !important;
        align-self: flex-end;
        margin-top: -30px;
    }
    
    .function-details {
        padding: 0 15px 15px 15px !important;
    }
    
    .function-details code {
        font-size: 0.85em !important;
        word-break: break-all;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .functions-hero {
        padding: 40px 10px !important;
    }
    
    .functions-hero h1 {
        font-size: 1.5em !important;
    }
    
    .category-tabs {
        overflow-x: auto;
        overflow-y: hidden;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 10px;
    }
    
    .category-tabs::-webkit-scrollbar {
        height: 6px;
    }
    
    .category-tabs::-webkit-scrollbar-thumb {
        background: #1a4d3e;
        border-radius: 3px;
    }
    
    .function-header code {
        max-width: 200px;
    }
}

/* ===========================================
   Print Styles
   =========================================== */

@media print {
    .functions-hero,
    .category-tabs-section,
    #function-search,
    .expand-icon {
        display: none !important;
    }
    
    .function-card {
        page-break-inside: avoid;
        border: 1px solid #ccc !important;
        margin-bottom: 10px !important;
    }
    
    .function-details {
        display: block !important;
    }
    
    code {
        background: #f0f0f0 !important;
        color: #000 !important;
    }
}

/* ===========================================
   Accessibility Enhancements
   =========================================== */

.category-tab:focus,
#function-search:focus,
.function-header:focus {
    outline: 3px solid #2d7a5f;
    outline-offset: 2px;
}

.category-tab:focus:not(:focus-visible),
.function-header:focus:not(:focus-visible) {
    outline: none;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ===========================================
   Smooth Scrolling
   =========================================== */

html {
    scroll-behavior: smooth;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
