/**
 * Taxonomy Single Page CSS - Hero + Filter Chips
 * Path: public_html/css/taxonomy-single.css
 * Version: 1.6.0
 *
 * Changelog v1.6.0:
 * - Added .taxonomy-toolbar flex container (search left, sort right)
 * - Added .taxonomy-sort-wrapper and .taxonomy-sort-dropdown styles
 * - Dark mode, responsive, and focus states for sort dropdown
 * - Adjusted search wrapper to flex inside toolbar
 *
 * Changelog v1.5.0:
 * - Issue #186: Added on-page search input styles (search wrapper, input, icon, clear button)
 * - Dark mode, responsive, and focus states for search
 *
 * Styles for individual category and tag pages:
 * - Hero section integration (reuses hero.css)
 * - Filter chip bar (below hero cards)
 * - Tool count badge in hero
 * - Responsive + dark mode
 */

/* ====================================================================
   HERO TOOL COUNT - Badge in hero subtitle area
   ==================================================================== */
.hero-tool-count {
    display: inline-block;
    margin-top: 12px;
    padding: 6px 16px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
    font-size: 0.9rem;
    color: #94a3b8;
    font-weight: 500;
}

/* ====================================================================
   FILTER CHIP BAR - Below hero cards
   ==================================================================== */
.filter-chip-bar {
    max-width: 1100px;
    margin: 24px auto 0;
    padding: 0 20px;
}

.filter-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
}

/* Individual chip */
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
    min-height: 36px;
    text-decoration: none;
    user-select: none;
}

.filter-chip:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
    color: #334155;
}

/* Active state */
.filter-chip[aria-selected="true"] {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #ffffff;
}

.filter-chip[aria-selected="true"]:hover {
    background: #2563eb;
    border-color: #2563eb;
}

/* Chip count */
.filter-chip-count {
    font-size: 0.75rem;
    opacity: 0.7;
}

.filter-chip[aria-selected="true"] .filter-chip-count {
    opacity: 0.85;
}

/* Clear button inside active chip */
.filter-chip-clear {
    display: none;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    border: none;
    padding: 0;
    cursor: pointer;
    color: #ffffff;
    font-size: 12px;
    line-height: 1;
    margin-left: 2px;
}

.filter-chip[aria-selected="true"] .filter-chip-clear {
    display: inline-flex;
}

.filter-chip-clear:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* ====================================================================
   TOOLBAR - Search + Sort on one row
   ==================================================================== */
.taxonomy-toolbar {
    max-width: 1100px;
    margin: 16px auto 0;
    padding: 0 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

/* ====================================================================
   ON-PAGE SEARCH INPUT - Left side of toolbar
   ==================================================================== */
.taxonomy-search-wrapper {
    flex: 1;
    min-width: 0;
}

.taxonomy-search-box {
    position: relative;
    max-width: 400px;
}

.taxonomy-search-input {
    width: 100%;
    padding: 10px 40px 10px 38px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    background: #f8fafc;
    color: #1e293b;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.taxonomy-search-input::placeholder {
    color: #94a3b8;
}

.taxonomy-search-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    background: #ffffff;
}

.taxonomy-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}

.taxonomy-search-clear {
    display: none;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    padding: 0;
    transition: color 0.15s ease, background 0.15s ease;
}

.taxonomy-search-clear:hover {
    color: #475569;
    background: #e2e8f0;
}

/* ====================================================================
   SORT DROPDOWN - Right side of toolbar
   ==================================================================== */
.taxonomy-sort-wrapper {
    flex-shrink: 0;
}

.taxonomy-sort-dropdown {
    padding: 10px 36px 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    font-weight: 500;
    background: #f8fafc;
    color: #1e293b;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%23475569' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    white-space: nowrap;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.taxonomy-sort-dropdown:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    background-color: #ffffff;
}

.taxonomy-sort-dropdown:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ====================================================================
   TOOL GRID CONTAINER - Consistent with taxonomy pages
   ==================================================================== */
.taxonomy-single-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px 0;
}

/* Live region for screen readers */
.filter-live-region {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* No results message */
.filter-no-results {
    text-align: center;
    padding: 48px 20px;
    color: #64748b;
    font-size: 1rem;
}

.filter-no-results a {
    color: #3b82f6;
    text-decoration: underline;
    cursor: pointer;
}

.filter-no-results a:hover {
    color: #2563eb;
}

/* ====================================================================
   MOBILE DROPDOWN - Replaces chip buttons on small screens
   ==================================================================== */
.filter-chip-dropdown {
    display: none;
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #334155;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%23475569' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    cursor: pointer;
}

.filter-chip-dropdown:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-color: #3b82f6;
}

[data-theme="dark"] .filter-chip-dropdown {
    background-color: #2d2d2d;
    border-color: #3d3d3d;
    color: #d4d4d4;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%23b0b0b0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* ====================================================================
   FOCUS STATES - Keyboard navigation
   ==================================================================== */
.filter-chip:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.25);
}

.filter-chip-clear:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 1px;
}

.taxonomy-search-clear:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

/* ====================================================================
   DARK MODE
   ==================================================================== */
[data-theme="dark"] .hero-tool-count {
    background: rgba(255, 255, 255, 0.08);
    color: #94a3b8;
}

[data-theme="dark"] .filter-chip {
    background: #2d2d2d;
    border-color: #3d3d3d;
    color: #b0b0b0;
}

[data-theme="dark"] .filter-chip:hover {
    background: #363636;
    border-color: #4a4a4a;
    color: #d4d4d4;
}

[data-theme="dark"] .filter-chip[aria-selected="true"] {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #ffffff;
}

[data-theme="dark"] .filter-chip[aria-selected="true"]:hover {
    background: #2563eb;
    border-color: #2563eb;
}

[data-theme="dark"] .filter-chip-clear {
    background: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .taxonomy-search-input {
    background: #2d2d2d;
    border-color: #3d3d3d;
    color: #e4e4e7;
}

[data-theme="dark"] .taxonomy-search-input::placeholder {
    color: #71717a;
}

[data-theme="dark"] .taxonomy-search-input:focus {
    border-color: #3b82f6;
    background: #1e1e1e;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

[data-theme="dark"] .taxonomy-search-icon {
    color: #71717a;
}

[data-theme="dark"] .taxonomy-search-clear {
    color: #71717a;
}

[data-theme="dark"] .taxonomy-search-clear:hover {
    color: #d4d4d4;
    background: #3d3d3d;
}

[data-theme="dark"] .taxonomy-sort-dropdown {
    background-color: #2d2d2d;
    border-color: #3d3d3d;
    color: #e4e4e7;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%23b0b0b0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

[data-theme="dark"] .taxonomy-sort-dropdown:focus {
    border-color: #3b82f6;
    background-color: #1e1e1e;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

[data-theme="dark"] .filter-no-results {
    color: #9ca3af;
}

[data-theme="dark"] .filter-no-results a {
    color: #6db3f2;
}

/* ====================================================================
   RESPONSIVE - Tablet
   ==================================================================== */
@media (min-width: 769px) and (max-width: 1024px) {
    .filter-chip-bar {
        margin-top: 20px;
    }

    .filter-chip {
        padding: 7px 14px;
        font-size: 0.82rem;
    }
}

/* ====================================================================
   RESPONSIVE - Mobile: hide chip buttons, show dropdown
   ==================================================================== */
@media (max-width: 768px) {
    .filter-chip-bar {
        margin-top: 16px;
        padding: 0 16px;
    }

    .filter-chip-list {
        display: none;
    }

    .filter-chip-dropdown {
        display: block;
    }

    .taxonomy-toolbar {
        flex-direction: column;
        padding: 0 16px;
        margin-top: 12px;
        gap: 10px;
    }

    .taxonomy-search-box {
        max-width: 100%;
    }

    .taxonomy-sort-wrapper {
        width: 100%;
    }

    .taxonomy-sort-dropdown {
        width: 100%;
    }

    .taxonomy-single-content {
        padding: 16px 16px 0;
    }
}

/* ====================================================================
   RESPONSIVE - Small mobile
   ==================================================================== */
@media (max-width: 480px) {
    .filter-chip-bar {
        padding: 0 12px;
    }

    .taxonomy-toolbar {
        padding: 0 12px;
    }

    .taxonomy-single-content {
        padding: 12px 12px 0;
    }
}

/* ====================================================================
   HIGH CONTRAST
   ==================================================================== */
@media (prefers-contrast: high) {
    .filter-chip {
        border: 2px solid #000000;
        color: #000000;
    }

    .filter-chip[aria-selected="true"] {
        border-color: #000000;
        background: #0000ff;
    }

    [data-theme="dark"] .filter-chip {
        border-color: #ffffff;
        color: #ffffff;
    }

    [data-theme="dark"] .filter-chip[aria-selected="true"] {
        border-color: #ffffff;
    }
}

/* ====================================================================
   REDUCED MOTION
   ==================================================================== */
@media (prefers-reduced-motion: reduce) {
    .filter-chip {
        transition: none;
    }
}

/* ====================================================================
   SCROLL-TO-FOOTER BUTTON — matches .back-to-top from styles.css
   Footer (↓) sits left of back-to-top (↑), both on the right side
   ==================================================================== */
.view-footer-btn {
    position: fixed;
    bottom: 20px;
    left: calc(50% - 58px);
    z-index: 1000;

    /* Match styles.css .back-to-top exactly */
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #007cba;
    color: white;
    border: none;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 124, 186, 0.3);

    /* Hidden by default */
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;

    display: flex;
    align-items: center;
    justify-content: center;

    -webkit-appearance: none;
    appearance: none;
    padding: 0;
}

.view-footer-btn.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.view-footer-btn:hover {
    background-color: #005a87;
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 124, 186, 0.4);
}

@media screen and (max-width: 768px) {
    .view-footer-btn {
        display: none !important;
    }
}
